octeontx2-pf: Add RSS multi group support
Geetha sowjanya
maintainerPATCH v2 1/1 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:
v2
- Removed unrelated whitespace
- Coverted otx2_get_rxfh() to use new function.
--- .../ethernet/marvell/octeontx2/nic/otx2_common.c | 26 +++-- .../ethernet/marvell/octeontx2/nic/otx2_common.h | 11 +- .../ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 114 +++++++++++++++++++-- .../ethernet/marvell/octeontx2/nic/otx2_flows.c | 37 ++++++- 4 files changed, 163 insertions(+), 25 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +18 -8
@@ -270,14 +270,17 @@ int otx2_set_flowkey_cfg(struct otx2_nic *pfvf)return err; } -int otx2_set_rss_table (struct otx2_nic *pfvf) +int otx2_set_rss_table (struct otx2_nic *pfvf,int ctx_id) {struct otx2_rss_info *rss = &pfvf->hw.rss_info; +const int index = rss->rss_size * ctx_id;struct mbox *mbox = &pfvf->mbox; +struct otx2_rss_ctx *rss_ctx;struct nix_aq_enq_req *aq;int idx, err;mutex_lock (&mbox->lock); + rss_ctx = rss->rss_ctx[ctx_id];/* Get memory to put this msg */ for (idx =0 ; idx < rss->rss_size; idx++) { aq =otx2_mbox_alloc_msg_nix_aq_enq (mbox);
@@ -297,10 +300,10 @@ int otx2_set_rss_table(struct otx2_nic *pfvf) } } - aq->rss.rq = rss->ind_tbl[idx]; + aq->rss.rq = rss_ctx->ind_tbl[idx];/* Fill AQ info */ - aq->qidx = idx; + aq->qidx = index + idx; aq->ctype =NIX_AQ_CTYPE_RSS ; aq->op =NIX_AQ_INSTOP_INIT ; }
@@ -335,9 +338,10 @@ void otx2_set_rss_key(struct otx2_nic *pfvf)int otx2_rss_init (struct otx2_nic *pfvf) {struct otx2_rss_info *rss = &pfvf->hw.rss_info; +struct otx2_rss_ctx *rss_ctx;int idx, ret =0 ; - rss->rss_size =sizeof (rss->ind_tbl); + rss->rss_size =sizeof (*rss->rss_ctx[DEFAULT_RSS_CONTEXT_GROUP ]);/* Init RSS key if it is not setup already */ if (!rss->enable)
@@ -345,13 +349,19 @@ int otx2_rss_init(struct otx2_nic *pfvf)otx2_set_rss_key (pfvf);if (!netif_is_rxfh_configured (pfvf->netdev)) { -/* Default indirection table */ +/* Set RSS group 0 as default indirection table */ + rss->rss_ctx[DEFAULT_RSS_CONTEXT_GROUP ] =kzalloc (rss->rss_size, +GFP_KERNEL ); +if (!rss->rss_ctx[DEFAULT_RSS_CONTEXT_GROUP ]) +return -ENOMEM ; + + rss_ctx = rss->rss_ctx[DEFAULT_RSS_CONTEXT_GROUP ];for (idx =0 ; idx < rss->rss_size; idx++) - rss->ind_tbl[idx] = + rss_ctx->ind_tbl[idx] =ethtool_rxfh_indir_default (idx, pfvf->hw.rx_queues); } - ret =otx2_set_rss_table (pfvf); + ret =otx2_set_rss_table (pfvf,DEFAULT_RSS_CONTEXT_GROUP );if (ret)return ret;
@@ -986,7 +996,7 @@ int otx2_config_nix(struct otx2_nic *pfvf) nixlf->sq_cnt = pfvf->hw.tx_queues; nixlf->cq_cnt = pfvf->qset.cq_cnt; nixlf->rss_sz =MAX_RSS_INDIR_TBL_SIZE ; - nixlf->rss_grps =1 ;/* Single RSS indir table supported, for now */ + nixlf->rss_grps =MAX_RSS_GROUPS ; nixlf->xqe_sz =NIX_XQESZ_W16 ;/* We don't know absolute NPA LF idx attached. * AF will replace 'RVU_DEFAULT_PF_FUNC' with
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +8 -3
@@ -51,13 +51,17 @@ enum arua_mapped_qtypes {#define NIX_LF_POISON_VEC 0x82/* RSS configuration */ +struct otx2_rss_ctx { +u8 ind_tbl[MAX_RSS_INDIR_TBL_SIZE ]; +}; +struct otx2_rss_info {u8 enable;u32 flowkey_cfg;u16 rss_size; -u8 ind_tbl[MAX_RSS_INDIR_TBL_SIZE ];#define RSS_HASH_KEY_SIZE 44/* 352 bit key */ u8 key[RSS_HASH_KEY_SIZE ]; +struct otx2_rss_ctx *rss_ctx[MAX_RSS_GROUPS ]; };/* NIX (or NPC) RX errors */
@@ -643,7 +647,7 @@ void otx2_cleanup_tx_cqes(struct otx2_nic *pfvf, struct otx2_cq_queue *cq);int otx2_rss_init (struct otx2_nic *pfvf);int otx2_set_flowkey_cfg (struct otx2_nic *pfvf);void otx2_set_rss_key (struct otx2_nic *pfvf); -int otx2_set_rss_table (struct otx2_nic *pfvf); +int otx2_set_rss_table (struct otx2_nic *pfvf,int ctx_id);/* Mbox handlers */ void mbox_handler_msix_offset(struct otx2_nic *pfvf,
@@ -684,10 +688,11 @@ int otx2_get_flow(struct otx2_nic *pfvf,int otx2_get_all_flows (struct otx2_nic *pfvf,struct ethtool_rxnfc *nfc,u32 *rule_locs);int otx2_add_flow (struct otx2_nic *pfvf, -struct ethtool_rx_flow_spec *fsp); +struct ethtool_rxnfc *nfc);int otx2_remove_flow (struct otx2_nic *pfvf,u32 location);int otx2_prepare_flow_request (struct ethtool_rx_flow_spec *fsp,struct npc_install_flow_req *req); +void otx2_rss_ctx_flow_del (struct otx2_nic *pfvf,int ctx_id);int otx2_del_macfilter (struct net_device *netdev,const u8 *mac);int otx2_add_macfilter (struct net_device *netdev,const u8 *mac);int otx2_enable_rxvlan (struct otx2_nic *pf,bool enable);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +105 -9
176 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c +32 -5
@@ -16,6 +16,7 @@ struct otx2_flow {u32 location;u16 entry;bool is_vf; +u8 rss_ctx_id;int vf; };
@@ -245,6 +246,7 @@ int otx2_get_flow(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc,list_for_each_entry (iter, &pfvf->flow_cfg->flow_list, list) {if (iter->location == location) { nfc->fs = iter->flow_spec; + nfc->rss_context = iter->rss_ctx_id;return 0 ; } }
@@ -429,7 +431,7 @@ int otx2_prepare_flow_request(struct ethtool_rx_flow_spec *fsp,struct flow_msg *pkt = &req->packet;u32 flow_type; - flow_type = fsp->flow_type & ~(FLOW_EXT |FLOW_MAC_EXT ); + flow_type = fsp->flow_type & ~(FLOW_EXT |FLOW_MAC_EXT |FLOW_RSS );switch (flow_type) {/* bits not set in mask are don't care */ case ETHER_FLOW :
@@ -532,9 +534,13 @@ static int otx2_add_flow_msg(struct otx2_nic *pfvf, struct otx2_flow *flow)/* change to unicast only if action of default entry is not * requested by user */ -if (req->op !=NIX_RX_ACTION_DEFAULT ) +if (flow->flow_spec.flow_type &FLOW_RSS ) { + req->op =NIX_RX_ACTIONOP_RSS ; + req->index = flow->rss_ctx_id; + }else { req->op =NIX_RX_ACTIONOP_UCAST ; - req->index =ethtool_get_flow_spec_ring (ring_cookie); + req->index =ethtool_get_flow_spec_ring (ring_cookie); + } vf =ethtool_get_flow_spec_ring_vf (ring_cookie);if (vf >pci_num_vf (pfvf->pdev)) {mutex_unlock (&pfvf->mbox.lock);
@@ -555,14 +561,16 @@ static int otx2_add_flow_msg(struct otx2_nic *pfvf, struct otx2_flow *flow)return err; } -int otx2_add_flow (struct otx2_nic *pfvf,struct ethtool_rx_flow_spec *fsp) +int otx2_add_flow (struct otx2_nic *pfvf,struct ethtool_rxnfc *nfc) {struct otx2_flow_config *flow_cfg = pfvf->flow_cfg; -u32 ring =ethtool_get_flow_spec_ring (fsp->ring_cookie); +struct ethtool_rx_flow_spec *fsp = &nfc->fs;struct otx2_flow *flow;bool new = false; +u32 ring;int err; + ring =ethtool_get_flow_spec_ring (fsp->ring_cookie);if (!(pfvf->flags &OTX2_FLAG_NTUPLE_SUPPORT ))return -ENOMEM ;
@@ -585,6 +593,9 @@ int otx2_add_flow(struct otx2_nic *pfvf, struct ethtool_rx_flow_spec *fsp)/* struct copy */ flow->flow_spec = *fsp; +if (fsp->flow_type &FLOW_RSS ) + flow->rss_ctx_id = nfc->rss_context; + err =otx2_add_flow_msg (pfvf, flow);if (err) {if (new)
@@ -647,6 +658,22 @@ int otx2_remove_flow(struct otx2_nic *pfvf, u32 location)return 0 ; } +void otx2_rss_ctx_flow_del (struct otx2_nic *pfvf,int ctx_id) +{ +struct otx2_flow *flow, *tmp; +int err; + +list_for_each_entry_safe (flow, tmp, &pfvf->flow_cfg->flow_list, list) { +if (flow->rss_ctx_id != ctx_id) +continue ; + err =otx2_remove_flow (pfvf, flow->location); +if (err) +netdev_warn (pfvf->netdev, +"Can't delete the rule %d associated with this rss group err:%d" , + flow->location, err); + } +} +int otx2_destroy_ntuple_flows (struct otx2_nic *pfvf) {struct otx2_flow_config *flow_cfg = pfvf->flow_cfg;
Signature · 1 line
2.7.4
Jakub Kicinski
maintainerQuoted 16 lines · On Mon, 7 Dec 2020 21:40:18 +0530 Geetha sowjanya wrote:
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,3ethtool -X eth0 weight 0 0 1 1 context new
(It will print the allocated context id number)
New RSS context is 1ethtool -N eth0 flow-type tcp4 dst-port 80 context 1 loc 1
To delete the context
ethtool -X eth0 context 1 delete
Quoted 7 lines
When an RSS context is removed, the active classification rules using this context are also removed.
Change-log:
v2
- Removed unrelated whitespace
- Covertedotx2_get_rxfh()to use new function.
Thanks, I gave otx2_get_rxfh() as an example, please also convert otx2_set_rxfh().
Geethasowjanya Akula
maintainerThanks, Jakub. Will address your comments in next version.
________________________________________
From: Jakub Kicinski <[email protected]>
Sent: Wednesday, December 9, 2020 3:04 AM
To: Geethasowjanya Akula
Cc: [email protected]; [email protected]; Sunil Kovvuri Goutham; [email protected]; Subbaraya Sundeep Bhatta
Subject: [EXT] Re: [PATCH v2] octeontx2-pf: Add RSS multi group support
External Email
----------------------------------------------------------------------
Quoted 16 lines · On Mon, 7 Dec 2020 21:40:18 +0530 Geetha sowjanya wrote:
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,3ethtool -X eth0 weight 0 0 1 1 context new
(It will print the allocated context id number)
New RSS context is 1ethtool -N eth0 flow-type tcp4 dst-port 80 context 1 loc 1
To delete the context
ethtool -X eth0 context 1 delete
Quoted 7 lines
When an RSS context is removed, the active classification rules using this context are also removed.
Change-log:
v2
- Removed unrelated whitespace
- Covertedotx2_get_rxfh()to use new function.
Thanks, I gave otx2_get_rxfh() as an example, please also convert otx2_set_rxfh().