refactor code related to npc install flow
cover refactor code related to npc install flow
This patchset refactors and cleans up the code associated with the npc install flow API, specifically to eliminate different code paths while installing MCAM rules by AF and PF. This makes the code easier to understand and maintain. Also added support for multi channel NIX promisc entry.
Nalla, Pradeep (1):
octeontx2-af: Add support for multi channel in NIX promisc entry
Naveen Mamindlapalli (3):
octeontx2-af: refactor function npc_install_flow for default entry
octeontx2-af: Use npc_install_flow API for promisc and broadcast
entries
octeontx2-af: Modify the return code for unsupported flow keys
Subbaraya Sundeep (1):
octeontx2-af: Avoid duplicate unicast rule in mcam_rules list
drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 2 + drivers/net/ethernet/marvell/octeontx2/af/npc.h | 5 + drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 17 ++- .../ethernet/marvell/octeontx2/af/rvu_debugfs.c | 2 +- .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 10 +- .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 157 +++++++++++---------- .../net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 62 ++++---- 7 files changed, 139 insertions(+), 116 deletions(-)
Signature · 1 line
2.16.5
PATCH 1/5 octeontx2-af: refactor function npc_install_flow for default entry
This patch refactors npc_install_flow function to install AF installed default MCAM entries similar to other MCAM entries installed by PF/VF. As a result the code would be more readable and easy to maintain. Modified npc_verify_entry and npc_verify_channel to properly check MCAM rules installed by AF.
--- drivers/net/ethernet/marvell/octeontx2/af/npc.h | 5 +++ drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 14 +++++-- .../ethernet/marvell/octeontx2/af/rvu_debugfs.c | 2 +- .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 47 +++++++--------------- .../net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 45 +++++++++------------ 5 files changed, 51 insertions(+), 62 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/npc.h +5 -0
@@ -420,6 +420,11 @@ struct nix_tx_action {#define TX_VTAG1_LID_MASK GENMASK_ULL(42, 40)#define TX_VTAG1_RELPTR_MASK GENMASK_ULL(39, 32) +/* NPC MCAM reserved entry index per nixlf */ +#define NIXLF_UCAST_ENTRY 0 +#define NIXLF_BCAST_ENTRY 1 +#define NIXLF_PROMISC_ENTRY 2 +struct npc_mcam_kex {/* MKEX Profle Header */ u64 mkex_sign;/* "mcam-kex-profile" (8 bytes/ASCII characters) */
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +11 -3
@@ -548,6 +548,12 @@ static inline int is_afvf(u16 pcifunc)return !(pcifunc & ~RVU_PFVF_FUNC_MASK ); } +/* check if PF_FUNC is AF */ +static inline bool is_pffunc_af (u16 pcifunc) +{ +return !pcifunc; +} +static inline bool is_rvu_fwdata_valid (struct rvu *rvu) { return (rvu->fwdata->header_magic == RVU_FWDATA_HEADER_MAGIC) &&
@@ -665,9 +671,6 @@ int rvu_npc_get_tx_nibble_cfg(struct rvu *rvu, u64 nibble_ena);int npc_mcam_verify_channel (struct rvu *rvu,u16 pcifunc,u8 intf,u16 channel);int npc_flow_steering_init (struct rvu *rvu,int blkaddr);const char *npc_get_field_name (u8 hdr); -bool rvu_npc_write_default_rule (struct rvu *rvu,int blkaddr,int nixlf, -u16 pcifunc,u8 intf,struct mcam_entry *entry, -int *entry_index);int npc_get_bank (struct npc_mcam *mcam,int index);void npc_mcam_enable_flows (struct rvu *rvu,u16 target);void npc_mcam_disable_flows (struct rvu *rvu,u16 target);
@@ -679,6 +682,11 @@ void npc_read_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam,bool is_mac_feature_supported (struct rvu *rvu,int pf,int feature);u32 rvu_cgx_get_fifolen (struct rvu *rvu); +int npc_get_nixlf_mcam_index (struct npc_mcam *mcam,u16 pcifunc,int nixlf, +int type); +bool is_mcam_entry_enabled (struct rvu *rvu,struct npc_mcam *mcam,int blkaddr, +int index); +/* CPT APIs */ int rvu_cpt_lf_teardown (struct rvu *rvu,u16 pcifunc,int lf,int slot);
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +1 -1
@@ -2145,7 +2145,7 @@ static int rvu_dbg_npc_mcam_show_rules(struct seq_file *s, void *unused)seq_printf (s,"\tmcam entry: %d\n" , iter->entry);rvu_dbg_npc_mcam_show_flows (s, iter); -if (iter->intf ==NIX_INTF_RX ) { +if (is_npc_intf_rx (iter->intf)) { target = iter->rx_action.pf_func; pf = (target >>RVU_PFVF_PF_SHIFT ) &RVU_PFVF_PF_MASK ;seq_printf (s,"\tForward to: PF%d " , pf);
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +15 -32
89 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +19 -26
84 lines not on this page · raw message
Signature · 1 line
2.16.5
PATCH 2/5 octeontx2-af: Add support for multi channel in NIX promisc entry
In reply to Naveen MamindlapalliFrom: "Nalla, Pradeep" <[email protected]>
This patch adds support for multi channel NIX promisc entry. Packets sent on all those channels by the host should be received by the interface to which those channels belong. Channel count, if greater than 1, should be power of 2 as only one promisc entry is available for the interface. Key mask is modified such that incoming packets from channel base to channel count are directed to the same pci function.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 3 ++- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 6 ++++-- drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c | 14 +++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +2 -1
@@ -646,7 +646,8 @@ int npc_config_ts_kpuaction(struct rvu *rvu, int pf, u16 pcifunc, bool en);void rvu_npc_install_ucast_entry (struct rvu *rvu,u16 pcifunc,int nixlf,u64 chan,u8 *mac_addr);void rvu_npc_install_promisc_entry (struct rvu *rvu,u16 pcifunc, -int nixlf,u64 chan,bool allmulti); +int nixlf,u64 chan,u8 chan_cnt, +bool allmulti);void rvu_npc_disable_promisc_entry (struct rvu *rvu,u16 pcifunc,int nixlf);void rvu_npc_enable_promisc_entry (struct rvu *rvu,u16 pcifunc,int nixlf); void rvu_npc_install_bcast_match_entry(struct rvu *rvu, u16 pcifunc,
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +4 -2
@@ -273,7 +273,8 @@ static int nix_interface_init(struct rvu *rvu, u16 pcifunc, int type, int nixlf) pfvf->rx_chan_cnt =1 ; pfvf->tx_chan_cnt =1 ;rvu_npc_install_promisc_entry (rvu, pcifunc, nixlf, - pfvf->rx_chan_base, false); + pfvf->rx_chan_base, + pfvf->rx_chan_cnt, false);break ; }
@@ -3088,7 +3089,8 @@ int rvu_mbox_handler_nix_set_rx_mode(struct rvu *rvu, struct nix_rx_mode *req,rvu_npc_disable_promisc_entry (rvu, pcifunc, nixlf); else rvu_npc_install_promisc_entry(rvu, pcifunc, nixlf, - pfvf->rx_chan_base, allmulti); + pfvf->rx_chan_base, + pfvf->rx_chan_cnt, allmulti);return 0 ; }
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +13 -1
@@ -647,13 +647,15 @@ void rvu_npc_install_ucast_entry(struct rvu *rvu, u16 pcifunc, }void rvu_npc_install_promisc_entry (struct rvu *rvu,u16 pcifunc, -int nixlf,u64 chan,bool allmulti) +int nixlf,u64 chan,u8 chan_cnt, +bool allmulti) {struct rvu_pfvf *pfvf =rvu_get_pfvf (rvu, pcifunc);struct npc_mcam *mcam = &rvu->hw->mcam;int blkaddr, ucast_idx, index, kwi;struct mcam_entry entry = { {0 } };struct nix_rx_action action = { }; +u64 relaxed_mask;/* Only PF or AF VF can add a promiscuous entry */ if ((pcifunc &RVU_PFVF_FUNC_MASK ) && !is_afvf (pcifunc))
@@ -669,6 +671,16 @@ void rvu_npc_install_promisc_entry(struct rvu *rvu, u16 pcifunc, entry.kw[0 ] = chan; entry.kw_mask[0 ] =0xFFFULL ; +if (chan_cnt >1 ) { +if (!is_power_of_2 (chan_cnt)) { +dev_err (rvu->dev,"channel count more than 1, must be power of 2\n" ); +return ; + } + relaxed_mask =GENMASK_ULL (BITS_PER_LONG_LONG -1 , +ilog2 (chan_cnt)); + entry.kw_mask[0 ] &= relaxed_mask; + } +if (allmulti) { kwi =NPC_KEXOF_DMAC /sizeof (u64); entry.kw[kwi] =BIT_ULL (40 );/* LSB bit of 1st byte in DMAC */
Signature · 1 line
2.16.5
PATCH 3/5 octeontx2-af: Use npc_install_flow API for promisc and broadcast entries
In reply to Naveen MamindlapalliUse npc_install_flow mailbox API for installing the default promisc and broadcast match entries. Earlier these entries were installed using low level npc_config_mcam_entry API, which does not store these rules and is not available when the rules are dumped using debugfs. Added chan_mask field to npc_install_flow_req to calculate channel mask when channel count is greater than 1 and configure the channel mask in entry kw_mask.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 1 + .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 107 +++++++++++---------- .../net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 10 +- 3 files changed, 67 insertions(+), 51 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +1 -0
@@ -1141,6 +1141,7 @@ struct npc_install_flow_req {u64 features;u16 entry;u16 channel; +u16 chan_mask;u8 intf;u8 set_cntr;/* If counter is available set counter for this entry ? */ u8 default_rule;
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +58 -49
155 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +8 -2
@@ -903,9 +903,11 @@ static void npc_update_rx_entry(struct rvu *rvu, struct rvu_pfvf *pfvf, struct npc_install_flow_req *req, u16 target) {struct nix_rx_action action; +u64 chan_mask; -npc_update_entry (rvu,NPC_CHAN , entry, req->channel,0 , - ~0ULL ,0 ,NIX_INTF_RX ); + chan_mask = req->chan_mask ? req->chan_mask : ~0ULL ; +npc_update_entry (rvu,NPC_CHAN , entry, req->channel,0 , chan_mask,0 , +NIX_INTF_RX ); *(u64 *)&action =0x00 ; action.pf_func = target;
@@ -1137,6 +1139,10 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,else target = req->hdr.pcifunc; +/* ignore chan_mask in case pf func is not AF, revisit later */ +if (!is_pffunc_af (req->hdr.pcifunc)) + req->chan_mask =0xFFF ; +if (npc_check_unsupported_flows (rvu, req->features, req->intf))return -EOPNOTSUPP ;
Signature · 1 line
2.16.5
PATCH 4/5 octeontx2-af: Avoid duplicate unicast rule in mcam_rules list
In reply to Naveen MamindlapalliFrom: Subbaraya Sundeep <[email protected]>
A mcam rule described by mcam_rule struct has all the info such as the hardware MCAM entry number, match criteria and corresponding action etc. All mcam rules are stored in a linked list mcam->rules. When adding/updating a rule to the mcam->rules it is checked if a rule already exists for the mcam entry. If the rule already exists, the same rule is updated instead of creating new rule. This way only one mcam_rule exists for the only one default unicast entry installed by AF. But a PF/VF can get different NIXLF (or default unicast entry number) after a attach-detach-attach sequence. When that happens mcam_rules list end up with two default unicast rules. Fix the problem by deleting the default unicast rule list node always when disabling mcam rules.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 4 +--- drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c | 9 ++++++--- 2 files changed, 7 insertions(+), 6 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +1 -3
@@ -3637,9 +3637,7 @@ int rvu_mbox_handler_nix_lf_stop_rx(struct rvu *rvu, struct msg_req *req,if (err)return err; -rvu_npc_disable_default_entries (rvu, pcifunc, nixlf); - -npc_mcam_disable_flows (rvu, pcifunc); +rvu_npc_disable_mcam_entries (rvu, pcifunc, nixlf);return rvu_cgx_start_stop_io (rvu, pcifunc, false); }
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +6 -3
@@ -988,7 +988,7 @@ void rvu_npc_disable_mcam_entries(struct rvu *rvu, u16 pcifunc, int nixlf) {struct rvu_pfvf *pfvf =rvu_get_pfvf (rvu, pcifunc);struct npc_mcam *mcam = &rvu->hw->mcam; -struct rvu_npc_mcam_rule *rule; +struct rvu_npc_mcam_rule *rule, *tmp;int blkaddr; blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NPC ,0 );
@@ -998,15 +998,18 @@ void rvu_npc_disable_mcam_entries(struct rvu *rvu, u16 pcifunc, int nixlf)mutex_lock (&mcam->lock);/* Disable MCAM entries directing traffic to this 'pcifunc' */ -list_for_each_entry (rule, &mcam->mcam_rules, list) { +list_for_each_entry_safe (rule, tmp, &mcam->mcam_rules, list) {if (is_npc_intf_rx (rule->intf) && rule->rx_action.pf_func == pcifunc) {npc_enable_mcam_entry (rvu, mcam, blkaddr, rule->entry, false); rule->enable = false;/* Indicate that default rule is disabled */ -if (rule->default_rule) +if (rule->default_rule) { pfvf->def_ucast_rule =NULL ; +list_del (&rule->list); +kfree (rule); + } } }
Signature · 1 line
2.16.5
PATCH 5/5 octeontx2-af: Modify the return code for unsupported flow keys
In reply to Naveen MamindlapalliThe mbox handler npc_install_flow returns ENOTSUPP for unsupported flow keys. This patch modifies the return value to AF driver defined error code for debugging purpose.
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 1 + drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +1 -0
@@ -605,6 +605,7 @@ enum nix_af_status {NIX_AF_INVAL_SSO_PF_FUNC =-420 ,NIX_AF_ERR_TX_VTAG_NOSPC =-421 ,NIX_AF_ERR_RX_VTAG_INUSE =-422 , + NIX_AF_ERR_NPC_KEY_NOT_SUPP = -423, };/* For NIX RX vtag action */
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +4 -3
@@ -597,7 +597,7 @@ static int npc_check_unsupported_flows(struct rvu *rvu, u64 features, u8 intf)dev_info (rvu->dev,"Unsupported flow(s):\n" );for_each_set_bit (bit, (unsigned long *)&unsupported,64 )dev_info (rvu->dev,"%s " ,npc_get_field_name (bit)); -return -EOPNOTSUPP ; +return NIX_AF_ERR_NPC_KEY_NOT_SUPP ; }return 0 ;
@@ -1143,8 +1143,9 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,if (!is_pffunc_af (req->hdr.pcifunc)) req->chan_mask =0xFFF ; -if (npc_check_unsupported_flows (rvu, req->features, req->intf)) -return -EOPNOTSUPP ; + err =npc_check_unsupported_flows (rvu, req->features, req->intf); +if (err) +return err;if (npc_mcam_verify_channel (rvu, target, req->intf, req->channel))return -EINVAL ;
Signature · 1 line
2.16.5
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 10 lines · On Wed, 17 Mar 2021 19:05:33 +0530 you wrote:
This patchset refactors and cleans up the code associated with the npc install flow API, specifically to eliminate different code paths while installing MCAM rules by AF and PF. This makes the code easier to understand and maintain. Also added support for multi channel NIX promisc entry.
Nalla, Pradeep (1):
octeontx2-af: Add support for multi channel in NIX promisc entry[...]
Here is the summary with links:
- [net-next,1/5] octeontx2-af: refactor function npc_install_flow for default entry
https://git.kernel.org/netdev/net-next/c/63f925dc55b3 - [net-next,2/5] octeontx2-af: Add support for multi channel in NIX promisc entry https://git.kernel.org/netdev/net-next/c/d450a23515e0 - [net-next,3/5] octeontx2-af: Use npc_install_flow API for promisc and broadcast entries https://git.kernel.org/netdev/net-next/c/56bcef528bd8 - [net-next,4/5] octeontx2-af: Avoid duplicate unicast rule in mcam_rules list https://git.kernel.org/netdev/net-next/c/b6b0e3667e1b - [net-next,5/5] octeontx2-af: Modify the return code for unsupported flow keys https://git.kernel.org/netdev/net-next/c/058fa3d915ea
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html