octeontx2-af: Introduce DMAC based switching
Subbaraya Sundeep
maintainercover octeontx2-af: Introduce DMAC based switching
With this patch set packets can be switched between
all CGX mapped PFs and VFs in the system based on
the DMAC addresses. To implement this:
AF allocates high priority rules from top entry(0) in MCAM. Rules are allocated for all the CGX mapped PFs and VFs though they are not active and with no NIXLFs attached.
Rules for a PF/VF will be enabled only after they are brought up. Two rules one for TX and one for RX are allocated for each PF/VF.
A packet sent from a PF/VF with a destination mac of another PF/VF will be hit by TX rule and sent to LBK channel 63. The same returned packet will be hit by RX rule whose action is to forward packet to PF/VF with that destination mac.
Implementation of this for 98xx is tricky since there are two NIX blocks and till now a PF/VF can install rule for
an NIX0/1 interface only if it is mapped to corresponding NIX0/1 block. Hence Tx rules are modified such that TX interface in MCAM entry can be either NIX0-TX or NIX1-TX.
Testing:
1. Create two VFs over PF1(on NIX0) and assign two VFs to two VMs
2. Assign ip addresses to two VFs in VMs and PF2(on NIX1) in host.
3. Assign static arp entries in two VMs and PF2.
4. Ping between VMs and host PF2.
Thanks,
Sundeep
Subbaraya Sundeep (3):
octeontx2-af: Enable transmit side LBK link
octeontx2-af: Prepare for allocating MCAM rules for AF
octeontx2-af: Introduce internal packet switching
drivers/net/ethernet/marvell/octeontx2/af/Makefile | 2 +- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 10 +- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 21 ++ .../net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 3 + .../ethernet/marvell/octeontx2/af/rvu_debugfs.c | 5 +- .../ethernet/marvell/octeontx2/af/rvu_devlink.c | 48 +++- .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 36 +++ .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 47 +++- .../net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 29 ++- .../net/ethernet/marvell/octeontx2/af/rvu_switch.c | 258 +++++++++++++++++++++ 10 files changed, 427 insertions(+), 32 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c
Signature · 1 line
2.7.4
Subbaraya Sundeep
maintainerPATCH 1/3 octeontx2-af: Enable transmit side LBK link
For enabling VF-VF switching the packets egressing out of CGX mapped VFs needed to be sent to LBK
so that same packets are received back to the system. But the LBK link also needs to be enabled in addition to a VF's mapped CGX_LMAC link otherwise hardware raises send error interrupt indicating selected LBK link is not enabled in NIX_AF_TL3_TL2X_LINKX_CFG register. Hence this patch enables all LBK links in TL3_TL2_LINKX_CFG registers.
Also to enable packet flow between PFs/VFs of NIX0 to PFs/VFs of NIX1(in 98xx silicon) the NPC TX DMAC rules has to be installed such that rules must be hit for any TX interface i.e., NIX0-TX or NIX1-TX provided DMAC match creteria is met. Hence this patch changes the behavior such that MCAM is programmed to match with any NIX0/1-TX interface for TX rules.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 6 ++++ drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 2 ++ .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 32 ++++++++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 15 ++++++++-- .../net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 9 +++++- 5 files changed, 61 insertions(+), 3 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +6 -0
@@ -2859,6 +2859,12 @@ static int rvu_enable_sriov(struct rvu *rvu)if (!vfs)return 0 ; +/* LBK channel number 63 is used for switching packets between +* CGX mapped VFs. Hence limit LBK pairs till 62 only. +*/ +if (vfs >62 ) + vfs =62 ; +/* Save VFs number for reference in VF interrupts handlers. * Since interrupts might start arriving during SRIOV enablement * ordinary API cannot be used to get number of enabled VFs.
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +2 -0
@@ -415,6 +415,8 @@ struct npc_kpu_profile_adapter {size_t kpus; }; +#define RVU_SWITCH_LBK_CHAN 63 +struct rvu {void __iomem *afreg_base;void __iomem *pfreg_base;
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +32 -0
@@ -1952,6 +1952,35 @@ static void nix_tl1_default_cfg(struct rvu *rvu, struct nix_hw *nix_hw, pfvf_map[schq] =TXSCH_SET_FLAG (pfvf_map[schq],NIX_TXSCHQ_CFG_DONE ); } +static void rvu_nix_tx_tl2_cfg (struct rvu *rvu,int blkaddr, +u16 pcifunc,struct nix_txsch *txsch) +{ +struct rvu_hwinfo *hw = rvu->hw; +int lbk_link_start, lbk_links; +u8 pf =rvu_get_pf (pcifunc); +int schq; + +if (!is_pf_cgxmapped (rvu, pf)) +return ; + + lbk_link_start = hw->cgx_links; + +for (schq =0 ; schq < txsch->schq.max; schq++) { +if (TXSCH_MAP_FUNC (txsch->pfvf_map[schq]) != pcifunc) +continue ; +/* Enable all LBK links with channel 63 by default so that +* packets can be sent to LBK with a NPC TX MCAM rule +*/ + lbk_links = hw->lbk_links; +while (lbk_links--) +rvu_write64 (rvu, blkaddr, +NIX_AF_TL3_TL2X_LINKX_CFG (schq, + lbk_link_start + + lbk_links), +BIT_ULL (12 ) |RVU_SWITCH_LBK_CHAN ); + } +} +int rvu_mbox_handler_nix_txschq_cfg (struct rvu *rvu,struct nix_txschq_config *req,struct msg_rsp *rsp)
@@ -2040,6 +2069,9 @@ int rvu_mbox_handler_nix_txschq_cfg(struct rvu *rvu,rvu_write64 (rvu, blkaddr, reg, regval); } +rvu_nix_tx_tl2_cfg (rvu, blkaddr, pcifunc, + &nix_hw->txsch[NIX_TXSCH_LVL_TL2 ]); +return 0 ; }
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +13 -2
@@ -468,6 +468,8 @@ static void npc_config_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam, {int bank =npc_get_bank (mcam, index);int kw =0 , actbank, actindex; +u8 tx_intf_mask = ~intf &0x3 ; +u8 tx_intf = intf;u64 cam0, cam1; actbank = bank;/* Save bank id, to set action later on */
@@ -488,12 +490,21 @@ static void npc_config_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam,*/ for (; bank < (actbank + mcam->banks_per_entry); bank++, kw = kw +2 ) {/* Interface should be set in all banks */ +if (is_npc_intf_tx (intf)) { +/* Last bit must be set and rest don't care +* for TX interfaces +*/ + tx_intf_mask =0x1 ; + tx_intf = intf & tx_intf_mask; + tx_intf_mask = ~tx_intf & tx_intf_mask; + } +rvu_write64 (rvu, blkaddr,NPC_AF_MCAMEX_BANKX_CAMX_INTF (index, bank,1 ), - intf); + tx_intf);rvu_write64 (rvu, blkaddr,NPC_AF_MCAMEX_BANKX_CAMX_INTF (index, bank,0 ), - ~intf &0x3 ); + tx_intf_mask);/* Set the match key */ npc_get_keyword (entry, kw, &cam0, &cam1);
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +8 -1
@@ -949,9 +949,16 @@ static void npc_update_tx_entry(struct rvu *rvu, struct rvu_pfvf *pfvf, struct npc_install_flow_req *req, u16 target) {struct nix_tx_action action; +u64 mask = ~0ULL ; + +/* If AF is installing then do not care about +* PF_FUNC in Send Descriptor +*/ +if (is_pffunc_af (req->hdr.pcifunc)) + mask =0 ;npc_update_entry (rvu,NPC_PF_FUNC , entry, (__force u16 )htons (target), -0 , ~0ULL ,0 ,NIX_INTF_TX ); +0 , mask,0 ,NIX_INTF_TX ); *(u64 *)&action =0x00 ; action.op = req->op;
Signature · 1 line
2.7.4
Subbaraya Sundeep
maintainerPATCH 2/3 octeontx2-af: Prepare for allocating MCAM rules for AF
In reply to Subbaraya SundeepAF till now only manages the allocation and freeing of MCAM rules for other PF/VFs in system. To implement L2 switching between all CGX mapped PF and VFs, AF requires MCAM entries for DMAC rules for each PF and VF. This patch modifies AF driver such that AF can also allocate MCAM rules and install rules for other PFs and VFs. All the checks like channel verification for RX rules and PF_FUNC verification for TX rules are relaxed in case AF is allocating or installing rules. Also all the entry and counter to owner mappings are set to NPC_MCAM_INVALID_MAP when they are free indicating those are not allocated to AF nor PF/VFs.
This patch also ensures that AF allocated and installed entries are displayed in debugfs.
--- .../ethernet/marvell/octeontx2/af/rvu_debugfs.c | 5 +--- .../net/ethernet/marvell/octeontx2/af/rvu_npc.c | 32 ++++++++++++++++------ .../net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 11 ++++---- 3 files changed, 30 insertions(+), 18 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +1 -4
@@ -2113,9 +2113,6 @@ static void rvu_print_npc_mcam_info(struct seq_file *s,int entry_acnt, entry_ecnt;int cntr_acnt, cntr_ecnt; -/* Skip PF0 */ -if (!pcifunc) -return ;rvu_npc_get_mcam_entry_alloc_info (rvu, pcifunc, blkaddr, &entry_acnt, &entry_ecnt); rvu_npc_get_mcam_counter_alloc_info(rvu, pcifunc, blkaddr,
@@ -2298,7 +2295,7 @@ static void rvu_dbg_npc_mcam_show_flows(struct seq_file *s,static void rvu_dbg_npc_mcam_show_action (struct seq_file *s,struct rvu_npc_mcam_rule *rule) { -if (rule->intf ==NIX_INTF_TX ) { +if (is_npc_intf_tx (rule->intf)) {switch (rule->tx_action.op) {case NIX_TX_ACTIONOP_DROP :seq_puts (s,"\taction: Drop\n" );
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +23 -9
@@ -442,7 +442,8 @@ static void npc_fixup_vf_rule(struct rvu *rvu, struct npc_mcam *mcam, owner = mcam->entry2pfvf_map[index]; target_func = (entry->action >>4 ) &0xffff ;/* do nothing when target is LBK/PF or owner is not PF */ -if (is_afvf (target_func) || (owner &RVU_PFVF_FUNC_MASK ) || +if (is_pffunc_af (owner) ||is_afvf (target_func) || + (owner &RVU_PFVF_FUNC_MASK ) || !(target_func &RVU_PFVF_FUNC_MASK ))return ;
@@ -661,6 +662,7 @@ void rvu_npc_install_ucast_entry(struct rvu *rvu, u16 pcifunc,eth_broadcast_addr ((u8 *)&req.mask.dmac); req.features =BIT_ULL (NPC_DMAC ); req.channel = chan; + req.chan_mask =0xFFFU ; req.intf = pfvf->nix_rx_intf; req.op = action.op; req.hdr.pcifunc =0 ;/* AF is requester */
@@ -810,6 +812,7 @@ void rvu_npc_install_bcast_match_entry(struct rvu *rvu, u16 pcifunc,eth_broadcast_addr ((u8 *)&req.mask.dmac); req.features =BIT_ULL (NPC_DMAC ); req.channel = chan; + req.chan_mask =0xFFFU ; req.intf = pfvf->nix_rx_intf; req.entry = index; req.hdr.pcifunc =0 ;/* AF is requester */
@@ -1756,6 +1759,8 @@ static int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr)int nixlf_count =rvu_get_nixlf_count (rvu);struct npc_mcam *mcam = &rvu->hw->mcam;int rsvd, err; +u16 index; +int cntr;u64 cfg;/* Actual number of MCAM entries vary by entry size */
@@ -1856,6 +1861,14 @@ static int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr)if (!mcam->entry2target_pffunc) goto free_mem; +for (index =0 ; index < mcam->bmap_entries; index++) { + mcam->entry2pfvf_map[index] =NPC_MCAM_INVALID_MAP ; + mcam->entry2cntr_map[index] =NPC_MCAM_INVALID_MAP ; + } + +for (cntr =0 ; cntr < mcam->counters.max; cntr++) + mcam->cntr2pfvf_map[cntr] =NPC_MCAM_INVALID_MAP ; +mutex_init (&mcam->lock);return 0 ;
@@ -2573,7 +2586,7 @@ int rvu_mbox_handler_npc_mcam_alloc_entry(struct rvu *rvu, }/* Alloc request from PFFUNC with no NIXLF attached should be denied */ -if (!is_nixlf_attached (rvu, pcifunc)) +if (!is_pffunc_af (pcifunc) && !is_nixlf_attached (rvu, pcifunc))return NPC_MCAM_ALLOC_DENIED ;return npc_mcam_alloc_entries (mcam, pcifunc, req, rsp);
@@ -2593,7 +2606,7 @@ int rvu_mbox_handler_npc_mcam_free_entry(struct rvu *rvu,return NPC_MCAM_INVALID_REQ ;/* Free request from PFFUNC with no NIXLF attached, ignore */ -if (!is_nixlf_attached (rvu, pcifunc)) +if (!is_pffunc_af (pcifunc) && !is_nixlf_attached (rvu, pcifunc))return NPC_MCAM_INVALID_REQ ;mutex_lock (&mcam->lock);
@@ -2605,7 +2618,7 @@ int rvu_mbox_handler_npc_mcam_free_entry(struct rvu *rvu,if (rc) goto exit; - mcam->entry2pfvf_map[req->entry] =0 ; + mcam->entry2pfvf_map[req->entry] =NPC_MCAM_INVALID_MAP ; mcam->entry2target_pffunc[req->entry] =0x0 ;npc_mcam_clear_bit (mcam, req->entry);npc_enable_mcam_entry (rvu, mcam, blkaddr, req->entry, false);
@@ -2690,13 +2703,14 @@ int rvu_mbox_handler_npc_mcam_write_entry(struct rvu *rvu,else nix_intf = pfvf->nix_rx_intf; -if (npc_mcam_verify_channel (rvu, pcifunc, req->intf, channel)) { +if (!is_pffunc_af (pcifunc) && +npc_mcam_verify_channel (rvu, pcifunc, req->intf, channel)) { rc =NPC_MCAM_INVALID_REQ ; goto exit; } -if (npc_mcam_verify_pf_func (rvu, &req->entry_data, req->intf, - pcifunc)) { +if (!is_pffunc_af (pcifunc) && +npc_mcam_verify_pf_func (rvu, &req->entry_data, req->intf, pcifunc)) { rc =NPC_MCAM_INVALID_REQ ; goto exit; }
@@ -2847,7 +2861,7 @@ int rvu_mbox_handler_npc_mcam_alloc_counter(struct rvu *rvu,return NPC_MCAM_INVALID_REQ ;/* If the request is from a PFFUNC with no NIXLF attached, ignore */ -if (!is_nixlf_attached (rvu, pcifunc)) +if (!is_pffunc_af (pcifunc) && !is_nixlf_attached (rvu, pcifunc))return NPC_MCAM_INVALID_REQ ;/* Since list of allocated counter IDs needs to be sent to requester,
@@ -3092,7 +3106,7 @@ int rvu_mbox_handler_npc_mcam_alloc_and_write_entry(struct rvu *rvu,if (rc) {/* Free allocated MCAM entry */ mutex_lock (&mcam->lock); - mcam->entry2pfvf_map[entry] =0 ; + mcam->entry2pfvf_map[entry] =NPC_MCAM_INVALID_MAP ;npc_mcam_clear_bit (mcam, entry);mutex_unlock (&mcam->lock);return rc;
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +6 -5
@@ -913,11 +913,9 @@ 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; - 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 ); +npc_update_entry (rvu,NPC_CHAN , entry, req->channel,0 , req->chan_mask, +0 ,NIX_INTF_RX ); *(u64 *)&action =0x00 ; action.pf_func = target;
@@ -1171,7 +1169,9 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,if (err)return err; -if (npc_mcam_verify_channel (rvu, target, req->intf, req->channel)) +/* Skip channel validation if AF is installing */ +if (!is_pffunc_af (req->hdr.pcifunc) && +npc_mcam_verify_channel (rvu, target, req->intf, req->channel))return -EINVAL ; pfvf =rvu_get_pfvf (rvu, target);
@@ -1187,6 +1187,7 @@ int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,eth_broadcast_addr ((u8 *)&req->mask.dmac); } +/* Proceed if NIXLF is attached or not for TX rules */ err =nix_get_nixlf (rvu, target, &nixlf,NULL );if (err &&is_npc_intf_rx (req->intf) && !pf_set_vfs_mac)return -EINVAL ;
Signature · 1 line
2.7.4
Subbaraya Sundeep
maintainerPATCH 3/3 octeontx2-af: Introduce internal packet switching
In reply to Subbaraya SundeepAs of now any communication between CGXs PFs and their VFs within the system is possible only by external switches sending packets back to the system. This patch adds internal switching support. Broadcast packet replication is not covered here. RVU admin function (AF) maintains MAC addresses of all interfaces in the system. When switching is enabled, MCAM entries are allocated to install rules such that packets with DMAC matching any of the internal interface MAC addresses is punted back into the system via the loopback channel.
On the receive side the default unicast rules are modified to not check for ingress channel. So any packet with matching DMAC irrespective of which interface it is coming from will be forwarded to the respective PF/VF interface.
The transmit side rules and default unicast rules are updated if user changes MAC address of an interface.
--- drivers/net/ethernet/marvell/octeontx2/af/Makefile | 2 +- drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 4 +- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 19 ++ .../net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 3 + .../ethernet/marvell/octeontx2/af/rvu_devlink.c | 48 +++- .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 4 + .../net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c | 9 +- .../net/ethernet/marvell/octeontx2/af/rvu_switch.c | 258 +++++++++++++++++++++ 8 files changed, 336 insertions(+), 11 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c
drivers/net/ethernet/marvell/octeontx2/af/Makefile +1 -1
@@ -10,4 +10,4 @@ obj-$(CONFIG_OCTEONTX2_AF) += rvu_af.o rvu_mbox-y := mbox.o rvu_trace.o rvu_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \ rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o rvu_npc_fs.o \ - rvu_cpt.o rvu_devlink.o rpm.o rvu_cn10k.o + rvu_cpt.o rvu_devlink.o rpm.o rvu_cn10k.o rvu_switch.o
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +3 -1
@@ -1314,7 +1314,7 @@ int rvu_mbox_handler_detach_resources(struct rvu *rvu,return rvu_detach_rsrcs (rvu, detach, detach->hdr.pcifunc); } -static int rvu_get_nix_blkaddr (struct rvu *rvu,u16 pcifunc) +int rvu_get_nix_blkaddr (struct rvu *rvu,u16 pcifunc) {struct rvu_pfvf *pfvf =rvu_get_pfvf (rvu, pcifunc);int blkaddr =BLKADDR_NIX0 , vf;
@@ -3007,6 +3007,8 @@ static int rvu_probe(struct pci_dev *pdev, const struct pci_device_id *id)/* Initialize debugfs */ rvu_dbg_init (rvu); +mutex_init (&rvu->rswitch.switch_lock); +return 0 ; err_dl:rvu_unregister_dl (rvu);
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +19 -0
@@ -417,6 +417,14 @@ struct npc_kpu_profile_adapter {#define RVU_SWITCH_LBK_CHAN 63 +struct rvu_switch { +struct mutex switch_lock;/* Serialize flow installation */ +u32 used_entries; +u16 *entry2pcifunc; +u16 mode; +u16 start_entry; +}; +struct rvu {void __iomem *afreg_base;void __iomem *pfreg_base;
@@ -447,6 +455,7 @@ struct rvu {/* CGX */ #define PF_CGXMAP_BASE 1/* PF 0 is reserved for RVU PF */ +u16 cgx_mapped_vfs;/* maximum CGX mapped VFs */ u8 cgx_mapped_pfs;u8 cgx_cnt_max;/* CGX port count max */ u8 *pf2cgxlmac_map;/* pf to cgx_lmac map */
@@ -479,6 +488,9 @@ struct rvu {struct rvu_debugfs rvu_dbg;#endif struct rvu_devlink *rvu_dl; + +/* RVU switch implementation over NPC with DMAC rules */ +struct rvu_switch rswitch; };static inline void rvu_write64 (struct rvu *rvu,u64 block,u64 offset,u64 val)
@@ -693,6 +705,7 @@ int nix_aq_context_read(struct rvu *rvu, struct nix_hw *nix_hw,struct nix_cn10k_aq_enq_req *aq_req, struct nix_cn10k_aq_enq_rsp *aq_rsp, u16 pcifunc, u8 ctype, u32 qidx); +int rvu_get_nix_blkaddr (struct rvu *rvu,u16 pcifunc);/* NPC APIs */ int rvu_npc_init (struct rvu *rvu);
@@ -770,4 +783,10 @@ void rvu_dbg_exit(struct rvu *rvu);static inline void rvu_dbg_init (struct rvu *rvu) {}static inline void rvu_dbg_exit (struct rvu *rvu) {}#endif + +/* RVU Switch */ +void rvu_switch_enable (struct rvu *rvu); +void rvu_switch_disable (struct rvu *rvu); +void rvu_switch_update_rules (struct rvu *rvu,u16 pcifunc); +#endif /* RVU_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +3 -0
@@ -126,6 +126,7 @@ static int rvu_map_cgx_lmac_pf(struct rvu *rvu)unsigned long lmac_bmap;int size, free_pkind;int cgx, lmac, iter; +int numvfs, hwvfs;if (!cgx_cnt_max)return 0 ;
@@ -166,6 +167,8 @@ static int rvu_map_cgx_lmac_pf(struct rvu *rvu) pkind->pfchan_map[free_pkind] = ((pf) &0x3F ) <<16 ;rvu_map_cgx_nix_block (rvu, pf, cgx, lmac); rvu->cgx_mapped_pfs++; +rvu_get_pf_numvfs (rvu, pf, &numvfs, &hwvfs); + rvu->cgx_mapped_vfs += numvfs; pf++; } }
drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c +41 -7
82 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +4 -0
@@ -3212,6 +3212,8 @@ int rvu_mbox_handler_nix_set_mac_addr(struct rvu *rvu,if (test_bit (PF_SET_VF_TRUSTED , &pfvf->flags) && from_vf)ether_addr_copy (pfvf->default_mac, req->mac_addr); +rvu_switch_update_rules (rvu, pcifunc); +return 0 ; }
@@ -3881,6 +3883,8 @@ int rvu_mbox_handler_nix_lf_start_rx(struct rvu *rvu, struct msg_req *req, pfvf =rvu_get_pfvf (rvu, pcifunc);set_bit (NIXLF_INITIALIZED , &pfvf->flags); +rvu_switch_update_rules (rvu, pcifunc); +return rvu_cgx_start_stop_io (rvu, pcifunc, true); }
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c +7 -2
@@ -910,10 +910,15 @@ static void rvu_mcam_add_counter_to_rule(struct rvu *rvu, u16 pcifunc,static void npc_update_rx_entry (struct rvu *rvu,struct rvu_pfvf *pfvf,struct mcam_entry *entry, -struct npc_install_flow_req *req,u16 target) +struct npc_install_flow_req *req, +u16 target,bool pf_set_vfs_mac) { +struct rvu_switch *rswitch = &rvu->rswitch;struct nix_rx_action action; +if (rswitch->mode ==DEVLINK_ESWITCH_MODE_SWITCHDEV && pf_set_vfs_mac) + req->chan_mask =0x0 ;/* Do not care channel */ +npc_update_entry (rvu,NPC_CHAN , entry, req->channel,0 , req->chan_mask,0 ,NIX_INTF_RX );
@@ -1007,7 +1012,7 @@ static int npc_install_flow(struct rvu *rvu, int blkaddr, u16 target, req->intf);if (is_npc_intf_rx (req->intf)) -npc_update_rx_entry (rvu, pfvf, entry, req, target); +npc_update_rx_entry (rvu, pfvf, entry, req, target, pf_set_vfs_mac);else npc_update_tx_entry (rvu, pfvf, entry, req, target);
drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c new file +258 -0
258 lines not on this page · raw message
Signature · 1 line
2.7.4
Jakub Kicinski
maintainerRe: [net-next PATCH 3/3] octeontx2-af: Introduce internal packet switching
Quoted 8 lines · Subbaraya Sundeep
drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c +8
-0+static int rvu_devlink_eswitch_mode_set (struct devlink *devlink,u16 mode, +struct netlink_ext_ack *extack) +{ +struct rvu_devlink *rvu_dl =devlink_priv (devlink); +struct rvu *rvu = rvu_dl->rvu; +struct rvu_switch *rswitch; + + rswitch = &rvu->rswitch;
drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c static void rvu_health_reporters_destroy(struct rvu *rvu) · line 1396
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c +10
-0+switch (mode) { +case DEVLINK_ESWITCH_MODE_LEGACY : +case DEVLINK_ESWITCH_MODE_SWITCHDEV : +if (rswitch->mode == mode) +return 0 ; + rswitch->mode = mode; +if (mode ==DEVLINK_ESWITCH_MODE_SWITCHDEV ) +rvu_switch_enable (rvu); +else +rvu_switch_disable (rvu);
I don't see the code handle creation and tearing down of representors.
How do things work in this driver? Does AF have a representor netdev for each VF (that's separate from the VF netdev itself)? Those should only exist in switchdev mode, while legacy mode should use DMAC switching.
I think what you want is a textbook VEPA vs VEB switch. Please take a look at drivers implementing .ndo_bridge_getlink/.ndo_bridge_setlink.
Re: [net-next PATCH 3/3] octeontx2-af: Introduce internal packet switching
Hi Jakub,
Quoted 23 lines · Jakub Kicinski
Quoted 8 lines · Subbaraya Sundeep
drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c +8
-0+static int rvu_devlink_eswitch_mode_set (struct devlink *devlink,u16 mode, +struct netlink_ext_ack *extack) +{ +struct rvu_devlink *rvu_dl =devlink_priv (devlink); +struct rvu *rvu = rvu_dl->rvu; +struct rvu_switch *rswitch; + + rswitch = &rvu->rswitch;drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c static void rvu_health_reporters_destroy(struct rvu *rvu) · line 1396
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c +10
-0+switch (mode) { +case DEVLINK_ESWITCH_MODE_LEGACY : +case DEVLINK_ESWITCH_MODE_SWITCHDEV : +if (rswitch->mode == mode) +return 0 ; + rswitch->mode = mode; +if (mode ==DEVLINK_ESWITCH_MODE_SWITCHDEV ) +rvu_switch_enable (rvu); +else +rvu_switch_disable (rvu);I don't see the code handle creation and tearing down of representors.
Quoted 7 lines
How do things work in this driver? Does AF have a representor netdev for each VF (that's separate from the VF netdev itself)? Those should only exist in switchdev mode, while legacy mode should use DMAC switching.
I think what you want is a textbook VEPA vs VEB switch. Please take a look at drivers implementing .ndo_bridge_getlink/.ndo_bridge_setlink.
MCAM used for switching is present in AF and AF is not a netdev to use ndo_bridge_setlink. Currently VF->VF/ PF->VF switching is possible only with an external switch in hairpin mode (like VEPA), what we want to achieve is switching based on DMAC in MCAM itself(internally). We used DEVLINK_ESWITCH_MODE_SWITCHDEV as a trigger to allocate MCAM rules. I understand now that it can be used to create VF representors only. Can you please suggest any appropriate devlink command we can use here so that new rules are created. Having these rules by default will waste MCAM space.
Thanks,
Sundeep