Skip to content

Commit 81a4362

Browse files
Geetha sowjanyadavem330
authored andcommitted
octeontx2-pf: Add RSS multi group support
Hardware supports 8 RSS groups per interface. Currently we are using only group '0'. This patch allows user to create new RSS groups/contexts and use the same as destination for flow steering rules. usage: To steer the traffic to RQ 2,3 ethtool -X eth0 weight 0 0 1 1 context new (It will print the allocated context id number) New RSS context is 1 ethtool -N eth0 flow-type tcp4 dst-port 80 context 1 loc 1 To delete the context ethtool -X eth0 context 1 delete When an RSS context is removed, the active classification rules using this context are also removed. Change-log: v4 - Fixed compiletime warning. - Address Saeed's comments on v3. v3 - Coverted otx2_set_rxfh() to use new function. v2 - Removed unrelated whitespace - Coverted otx2_get_rxfh() to use new function. Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com> Signed-off-by: Geetha sowjanya <gakula@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f011539 commit 81a4362

File tree

4 files changed

+163
-44
lines changed

4 files changed

+163
-44
lines changed

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,17 @@ int otx2_set_flowkey_cfg(struct otx2_nic *pfvf)
270270
return err;
271271
}
272272

273-
int otx2_set_rss_table(struct otx2_nic *pfvf)
273+
int otx2_set_rss_table(struct otx2_nic *pfvf, int ctx_id)
274274
{
275275
struct otx2_rss_info *rss = &pfvf->hw.rss_info;
276+
const int index = rss->rss_size * ctx_id;
276277
struct mbox *mbox = &pfvf->mbox;
278+
struct otx2_rss_ctx *rss_ctx;
277279
struct nix_aq_enq_req *aq;
278280
int idx, err;
279281

280282
mutex_lock(&mbox->lock);
283+
rss_ctx = rss->rss_ctx[ctx_id];
281284
/* Get memory to put this msg */
282285
for (idx = 0; idx < rss->rss_size; idx++) {
283286
aq = otx2_mbox_alloc_msg_nix_aq_enq(mbox);
@@ -297,10 +300,10 @@ int otx2_set_rss_table(struct otx2_nic *pfvf)
297300
}
298301
}
299302

300-
aq->rss.rq = rss->ind_tbl[idx];
303+
aq->rss.rq = rss_ctx->ind_tbl[idx];
301304

302305
/* Fill AQ info */
303-
aq->qidx = idx;
306+
aq->qidx = index + idx;
304307
aq->ctype = NIX_AQ_CTYPE_RSS;
305308
aq->op = NIX_AQ_INSTOP_INIT;
306309
}
@@ -335,23 +338,30 @@ void otx2_set_rss_key(struct otx2_nic *pfvf)
335338
int otx2_rss_init(struct otx2_nic *pfvf)
336339
{
337340
struct otx2_rss_info *rss = &pfvf->hw.rss_info;
341+
struct otx2_rss_ctx *rss_ctx;
338342
int idx, ret = 0;
339343

340-
rss->rss_size = sizeof(rss->ind_tbl);
344+
rss->rss_size = sizeof(*rss->rss_ctx[DEFAULT_RSS_CONTEXT_GROUP]);
341345

342346
/* Init RSS key if it is not setup already */
343347
if (!rss->enable)
344348
netdev_rss_key_fill(rss->key, sizeof(rss->key));
345349
otx2_set_rss_key(pfvf);
346350

347351
if (!netif_is_rxfh_configured(pfvf->netdev)) {
348-
/* Default indirection table */
352+
/* Set RSS group 0 as default indirection table */
353+
rss->rss_ctx[DEFAULT_RSS_CONTEXT_GROUP] = kzalloc(rss->rss_size,
354+
GFP_KERNEL);
355+
if (!rss->rss_ctx[DEFAULT_RSS_CONTEXT_GROUP])
356+
return -ENOMEM;
357+
358+
rss_ctx = rss->rss_ctx[DEFAULT_RSS_CONTEXT_GROUP];
349359
for (idx = 0; idx < rss->rss_size; idx++)
350-
rss->ind_tbl[idx] =
360+
rss_ctx->ind_tbl[idx] =
351361
ethtool_rxfh_indir_default(idx,
352362
pfvf->hw.rx_queues);
353363
}
354-
ret = otx2_set_rss_table(pfvf);
364+
ret = otx2_set_rss_table(pfvf, DEFAULT_RSS_CONTEXT_GROUP);
355365
if (ret)
356366
return ret;
357367

@@ -986,7 +996,7 @@ int otx2_config_nix(struct otx2_nic *pfvf)
986996
nixlf->sq_cnt = pfvf->hw.tx_queues;
987997
nixlf->cq_cnt = pfvf->qset.cq_cnt;
988998
nixlf->rss_sz = MAX_RSS_INDIR_TBL_SIZE;
989-
nixlf->rss_grps = 1; /* Single RSS indir table supported, for now */
999+
nixlf->rss_grps = MAX_RSS_GROUPS;
9901000
nixlf->xqe_sz = NIX_XQESZ_W16;
9911001
/* We don't know absolute NPA LF idx attached.
9921002
* AF will replace 'RVU_DEFAULT_PF_FUNC' with

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,17 @@ enum arua_mapped_qtypes {
5151
#define NIX_LF_POISON_VEC 0x82
5252

5353
/* RSS configuration */
54+
struct otx2_rss_ctx {
55+
u8 ind_tbl[MAX_RSS_INDIR_TBL_SIZE];
56+
};
57+
5458
struct otx2_rss_info {
5559
u8 enable;
5660
u32 flowkey_cfg;
5761
u16 rss_size;
58-
u8 ind_tbl[MAX_RSS_INDIR_TBL_SIZE];
5962
#define RSS_HASH_KEY_SIZE 44 /* 352 bit key */
6063
u8 key[RSS_HASH_KEY_SIZE];
64+
struct otx2_rss_ctx *rss_ctx[MAX_RSS_GROUPS];
6165
};
6266

6367
/* NIX (or NPC) RX errors */
@@ -643,7 +647,7 @@ void otx2_cleanup_tx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq);
643647
int otx2_rss_init(struct otx2_nic *pfvf);
644648
int otx2_set_flowkey_cfg(struct otx2_nic *pfvf);
645649
void otx2_set_rss_key(struct otx2_nic *pfvf);
646-
int otx2_set_rss_table(struct otx2_nic *pfvf);
650+
int otx2_set_rss_table(struct otx2_nic *pfvf, int ctx_id);
647651

648652
/* Mbox handlers */
649653
void mbox_handler_msix_offset(struct otx2_nic *pfvf,
@@ -684,10 +688,11 @@ int otx2_get_flow(struct otx2_nic *pfvf,
684688
int otx2_get_all_flows(struct otx2_nic *pfvf,
685689
struct ethtool_rxnfc *nfc, u32 *rule_locs);
686690
int otx2_add_flow(struct otx2_nic *pfvf,
687-
struct ethtool_rx_flow_spec *fsp);
691+
struct ethtool_rxnfc *nfc);
688692
int otx2_remove_flow(struct otx2_nic *pfvf, u32 location);
689693
int otx2_prepare_flow_request(struct ethtool_rx_flow_spec *fsp,
690694
struct npc_install_flow_req *req);
695+
void otx2_rss_ctx_flow_del(struct otx2_nic *pfvf, int ctx_id);
691696
int otx2_del_macfilter(struct net_device *netdev, const u8 *mac);
692697
int otx2_add_macfilter(struct net_device *netdev, const u8 *mac);
693698
int otx2_enable_rxvlan(struct otx2_nic *pf, bool enable);

drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c

Lines changed: 105 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ static int otx2_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *nfc)
581581
break;
582582
case ETHTOOL_SRXCLSRLINS:
583583
if (netif_running(dev) && ntuple)
584-
ret = otx2_add_flow(pfvf, &nfc->fs);
584+
ret = otx2_add_flow(pfvf, nfc);
585585
break;
586586
case ETHTOOL_SRXCLSRLDEL:
587587
if (netif_running(dev) && ntuple)
@@ -641,42 +641,50 @@ static u32 otx2_get_rxfh_key_size(struct net_device *netdev)
641641

642642
static u32 otx2_get_rxfh_indir_size(struct net_device *dev)
643643
{
644-
struct otx2_nic *pfvf = netdev_priv(dev);
645-
646-
return pfvf->hw.rss_info.rss_size;
644+
return MAX_RSS_INDIR_TBL_SIZE;
647645
}
648646

649-
/* Get RSS configuration */
650-
static int otx2_get_rxfh(struct net_device *dev, u32 *indir,
651-
u8 *hkey, u8 *hfunc)
647+
static int otx2_rss_ctx_delete(struct otx2_nic *pfvf, int ctx_id)
652648
{
653-
struct otx2_nic *pfvf = netdev_priv(dev);
654-
struct otx2_rss_info *rss;
655-
int idx;
649+
struct otx2_rss_info *rss = &pfvf->hw.rss_info;
656650

657-
rss = &pfvf->hw.rss_info;
651+
otx2_rss_ctx_flow_del(pfvf, ctx_id);
652+
kfree(rss->rss_ctx[ctx_id]);
653+
rss->rss_ctx[ctx_id] = NULL;
658654

659-
if (indir) {
660-
for (idx = 0; idx < rss->rss_size; idx++)
661-
indir[idx] = rss->ind_tbl[idx];
662-
}
655+
return 0;
656+
}
663657

664-
if (hkey)
665-
memcpy(hkey, rss->key, sizeof(rss->key));
658+
static int otx2_rss_ctx_create(struct otx2_nic *pfvf,
659+
u32 *rss_context)
660+
{
661+
struct otx2_rss_info *rss = &pfvf->hw.rss_info;
662+
u8 ctx;
666663

667-
if (hfunc)
668-
*hfunc = ETH_RSS_HASH_TOP;
664+
for (ctx = 0; ctx < MAX_RSS_GROUPS; ctx++) {
665+
if (!rss->rss_ctx[ctx])
666+
break;
667+
}
668+
if (ctx == MAX_RSS_GROUPS)
669+
return -EINVAL;
670+
671+
rss->rss_ctx[ctx] = kzalloc(sizeof(*rss->rss_ctx[ctx]), GFP_KERNEL);
672+
if (!rss->rss_ctx[ctx])
673+
return -ENOMEM;
674+
*rss_context = ctx;
669675

670676
return 0;
671677
}
672678

673-
/* Configure RSS table and hash key */
674-
static int otx2_set_rxfh(struct net_device *dev, const u32 *indir,
675-
const u8 *hkey, const u8 hfunc)
679+
/* RSS context configuration */
680+
static int otx2_set_rxfh_context(struct net_device *dev, const u32 *indir,
681+
const u8 *hkey, const u8 hfunc,
682+
u32 *rss_context, bool delete)
676683
{
677684
struct otx2_nic *pfvf = netdev_priv(dev);
685+
struct otx2_rss_ctx *rss_ctx;
678686
struct otx2_rss_info *rss;
679-
int idx;
687+
int ret, idx;
680688

681689
if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
682690
return -EOPNOTSUPP;
@@ -688,20 +696,85 @@ static int otx2_set_rxfh(struct net_device *dev, const u32 *indir,
688696
return -EIO;
689697
}
690698

699+
if (hkey) {
700+
memcpy(rss->key, hkey, sizeof(rss->key));
701+
otx2_set_rss_key(pfvf);
702+
}
703+
if (delete)
704+
return otx2_rss_ctx_delete(pfvf, *rss_context);
705+
706+
if (*rss_context == ETH_RXFH_CONTEXT_ALLOC) {
707+
ret = otx2_rss_ctx_create(pfvf, rss_context);
708+
if (ret)
709+
return ret;
710+
}
691711
if (indir) {
712+
rss_ctx = rss->rss_ctx[*rss_context];
692713
for (idx = 0; idx < rss->rss_size; idx++)
693-
rss->ind_tbl[idx] = indir[idx];
714+
rss_ctx->ind_tbl[idx] = indir[idx];
694715
}
716+
otx2_set_rss_table(pfvf, *rss_context);
695717

696-
if (hkey) {
697-
memcpy(rss->key, hkey, sizeof(rss->key));
698-
otx2_set_rss_key(pfvf);
718+
return 0;
719+
}
720+
721+
static int otx2_get_rxfh_context(struct net_device *dev, u32 *indir,
722+
u8 *hkey, u8 *hfunc, u32 rss_context)
723+
{
724+
struct otx2_nic *pfvf = netdev_priv(dev);
725+
struct otx2_rss_ctx *rss_ctx;
726+
struct otx2_rss_info *rss;
727+
int idx, rx_queues;
728+
729+
rss = &pfvf->hw.rss_info;
730+
731+
if (hfunc)
732+
*hfunc = ETH_RSS_HASH_TOP;
733+
734+
if (!indir)
735+
return 0;
736+
737+
if (!rss->enable && rss_context == DEFAULT_RSS_CONTEXT_GROUP) {
738+
rx_queues = pfvf->hw.rx_queues;
739+
for (idx = 0; idx < MAX_RSS_INDIR_TBL_SIZE; idx++)
740+
indir[idx] = ethtool_rxfh_indir_default(idx, rx_queues);
741+
return 0;
742+
}
743+
if (rss_context >= MAX_RSS_GROUPS)
744+
return -ENOENT;
745+
746+
rss_ctx = rss->rss_ctx[rss_context];
747+
if (!rss_ctx)
748+
return -ENOENT;
749+
750+
if (indir) {
751+
for (idx = 0; idx < rss->rss_size; idx++)
752+
indir[idx] = rss_ctx->ind_tbl[idx];
699753
}
754+
if (hkey)
755+
memcpy(hkey, rss->key, sizeof(rss->key));
700756

701-
otx2_set_rss_table(pfvf);
702757
return 0;
703758
}
704759

760+
/* Get RSS configuration */
761+
static int otx2_get_rxfh(struct net_device *dev, u32 *indir,
762+
u8 *hkey, u8 *hfunc)
763+
{
764+
return otx2_get_rxfh_context(dev, indir, hkey, hfunc,
765+
DEFAULT_RSS_CONTEXT_GROUP);
766+
}
767+
768+
/* Configure RSS table and hash key */
769+
static int otx2_set_rxfh(struct net_device *dev, const u32 *indir,
770+
const u8 *hkey, const u8 hfunc)
771+
{
772+
773+
u32 rss_context = DEFAULT_RSS_CONTEXT_GROUP;
774+
775+
return otx2_set_rxfh_context(dev, indir, hkey, hfunc, &rss_context, 0);
776+
}
777+
705778
static u32 otx2_get_msglevel(struct net_device *netdev)
706779
{
707780
struct otx2_nic *pfvf = netdev_priv(netdev);
@@ -771,6 +844,8 @@ static const struct ethtool_ops otx2_ethtool_ops = {
771844
.get_rxfh_indir_size = otx2_get_rxfh_indir_size,
772845
.get_rxfh = otx2_get_rxfh,
773846
.set_rxfh = otx2_set_rxfh,
847+
.get_rxfh_context = otx2_get_rxfh_context,
848+
.set_rxfh_context = otx2_set_rxfh_context,
774849
.get_msglevel = otx2_get_msglevel,
775850
.set_msglevel = otx2_set_msglevel,
776851
.get_pauseparam = otx2_get_pauseparam,
@@ -866,6 +941,8 @@ static const struct ethtool_ops otx2vf_ethtool_ops = {
866941
.get_rxfh_indir_size = otx2_get_rxfh_indir_size,
867942
.get_rxfh = otx2_get_rxfh,
868943
.set_rxfh = otx2_set_rxfh,
944+
.get_rxfh_context = otx2_get_rxfh_context,
945+
.set_rxfh_context = otx2_set_rxfh_context,
869946
.get_ringparam = otx2_get_ringparam,
870947
.set_ringparam = otx2_set_ringparam,
871948
.get_coalesce = otx2_get_coalesce,

0 commit comments

Comments
 (0)