Dynamic LMTST region setup
Subsystems (4)
Geetha sowjanya
maintainercover Dynamic LMTST region setup
This patch series allows RVU PF/VF to allocate memory for LMTST operations instead of using memory reserved by firmware which is mapped as device memory.
The LMTST mapping table contains the RVU PF/VF LMTST memory base address entries. This table is used by hardware for LMTST operations. Patch1 introduces new mailbox message to update the LMTST table with the new allocated memory address.
Geetha sowjanya (2):
octeontx2-af: Support configurable LMTST regions
octeontx2-pf: Use runtime allocated LMTLINE region
Harman Kalra (1):
octeontx2-af: cn10k: setting up lmtst map table
.../net/ethernet/marvell/octeontx2/af/mbox.h | 10 + .../net/ethernet/marvell/octeontx2/af/rvu.c | 1 + .../net/ethernet/marvell/octeontx2/af/rvu.h | 4 + .../ethernet/marvell/octeontx2/af/rvu_cn10k.c | 202 ++++++++++++++++++ .../ethernet/marvell/octeontx2/af/rvu_reg.h | 10 + .../marvell/octeontx2/af/rvu_struct.h | 3 +- .../ethernet/marvell/octeontx2/nic/cn10k.c | 87 +++----- .../ethernet/marvell/octeontx2/nic/cn10k.h | 3 +- .../marvell/octeontx2/nic/otx2_common.h | 7 +- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 17 +- .../marvell/octeontx2/nic/otx2_txrx.h | 1 + .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 12 +- 12 files changed, 283 insertions(+), 74 deletions(-)
Signature · 1 line
2.17.1
Geetha sowjanya
maintainerPATCH 1/3 octeontx2-af: cn10k: Setting up lmtst map table
From: Harman Kalra <[email protected]>
Introducing a new mailbox to support updating lmt entries and common lmt base address scheme i.e. multiple pcifuncs can share lmt region to reduce L1 cache pressure for application. Parameters passed to mailbox includes the primary pcifunc value whose lmt regions will be shared by other secondary pcifuncs. Here secondary pcifunc will be the one who is calling the mailbox.
For example:
By default each pcifunc has its own LMT base address:
PCIFUNC1 LMT_BASE_ADDR A
PCIFUNC2 LMT_BASE_ADDR B
PCIFUNC3 LMT_BASE_ADDR C
PCIFUNC4 LMT_BASE_ADDR DApplication will choose PCIFUNC1 as base/primary pcifunc and as and when other pcifunc(secondary pcifuncs) gets probed, this mailbox will be called and LMTST table will be updated as:
PCIFUNC1 LMT_BASE_ADDR A
PCIFUNC2 LMT_BASE_ADDR A
PCIFUNC3 LMT_BASE_ADDR A
PCIFUNC4 LMT_BASE_ADDR AOn FLR lmtst map table gets resetted to the default lmt base addresses for all secondary pcifuncs.
--- .../net/ethernet/marvell/octeontx2/af/mbox.h | 7 + .../net/ethernet/marvell/octeontx2/af/rvu.c | 1 + .../net/ethernet/marvell/octeontx2/af/rvu.h | 4 + .../ethernet/marvell/octeontx2/af/rvu_cn10k.c | 140 ++++++++++++++++++ .../ethernet/marvell/octeontx2/af/rvu_reg.h | 5 + .../marvell/octeontx2/af/rvu_struct.h | 3 +- 6 files changed, 159 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +7 -0
@@ -134,6 +134,8 @@ M(MSIX_OFFSET, 0x005, msix_offset, msg_req, msix_offset_rsp) \ M(VF_FLR, 0x006, vf_flr, msg_req, msg_rsp) \ M(PTP_OP, 0x007, ptp_op, ptp_req, ptp_rsp) \ M(GET_HW_CAP, 0x008, get_hw_cap, msg_req, get_hw_cap_rsp) \ +M (LMTST_TBL_SETUP ,0x00a , lmtst_tbl_setup, lmtst_tbl_setup_req, \ + msg_rsp) \M (SET_VF_PERM ,0x00b , set_vf_perm, set_vf_perm, msg_rsp) \ /* CGX mbox IDs (range 0x200 - 0x3FF) */ \M (CGX_START_RXTX ,0x200 , cgx_start_rxtx, msg_req, msg_rsp) \
@@ -1278,6 +1280,11 @@ struct set_vf_perm {u64 flags; }; +struct lmtst_tbl_setup_req { +struct mbox_msghdr hdr; +u16 base_pcifunc; +}; +/* CPT mailbox error codes * Range 901 - 1000. */
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +1 -0
@@ -2333,6 +2333,7 @@ static void __rvu_flr_handler(struct rvu *rvu, u16 pcifunc)rvu_blklf_teardown (rvu, pcifunc,BLKADDR_SSOW );rvu_blklf_teardown (rvu, pcifunc,BLKADDR_SSO );rvu_blklf_teardown (rvu, pcifunc,BLKADDR_NPA ); +rvu_reset_lmt_map_tbl (rvu, pcifunc);rvu_detach_rsrcs (rvu,NULL , pcifunc);mutex_unlock (&rvu->flr_lock); }
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +4 -0
@@ -243,6 +243,7 @@ struct rvu_pfvf {u8 nix_blkaddr;/* BLKADDR_NIX0/1 assigned to this PF */ u8 nix_rx_intf;/* NIX0_RX/NIX1_RX interface to NPC */ u8 nix_tx_intf;/* NIX0_TX/NIX1_TX interface to NPC */ +u64 lmt_base_addr;/* Preseving the pcifunc's lmtst base addr*/ unsigned long flags; };
@@ -754,6 +755,9 @@ int rvu_cpt_lf_teardown(struct rvu *rvu, u16 pcifunc, int lf, int slot);int rvu_set_channels_base (struct rvu *rvu);void rvu_program_channels (struct rvu *rvu); +/* CN10K RVU - LMT*/ +void rvu_reset_lmt_map_tbl (struct rvu *rvu,u16 pcifunc); +#ifdef CONFIG_DEBUG_FS void rvu_dbg_init (struct rvu *rvu);void rvu_dbg_exit (struct rvu *rvu);
drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c +140 -0
146 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h +5 -0
@@ -692,4 +692,9 @@#define LBK_LINK_CFG_ID_MASK GENMASK_ULL(11, 6)#define LBK_LINK_CFG_BASE_MASK GENMASK_ULL(5, 0) +/* APR */ +#define APR_AF_LMT_CFG (0x000ull) +#define APR_AF_LMT_MAP_BASE (0x008ull) +#define APR_AF_LMT_CTL (0x010ull) +#endif /* RVU_REG_H */
drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h +2 -1
@@ -35,7 +35,8 @@ enum rvu_block_addr_e {BLKADDR_NDC_NPA0 =0xeULL ,BLKADDR_NDC_NIX1_RX =0x10ULL ,BLKADDR_NDC_NIX1_TX =0x11ULL , - BLK_COUNT = 0x12ULL, +BLKADDR_APR =0x16ULL , + BLK_COUNT = 0x17ULL, };/* RVU Block Type Enumeration */
Signature · 1 line
2.17.1
Geetha sowjanya
maintainerPATCH 2/3 octeontx2-af: cn10k: Support configurable LMTST regions
In reply to Geetha sowjanyaThis patch extends the lmtst_tbl_setup_req mbox to support run time LMTST configuration.
RVU PF/VF and DPDK/ODP allocates a LMT region, creates a translation entry for a device via VFIO IOCTLs.
This IOVA is shared with AF through above mbox. AF then uses RVU_SMMU transulation Widget and gets PA for the IOVA and updates the LMTtable entry for that device.
--- .../net/ethernet/marvell/octeontx2/af/mbox.h | 3 + .../ethernet/marvell/octeontx2/af/rvu_cn10k.c | 130 +++++++++++++----- .../ethernet/marvell/octeontx2/af/rvu_reg.h | 5 + 3 files changed, 103 insertions(+), 35 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +3 -0
@@ -1283,6 +1283,9 @@ struct set_vf_perm {struct lmtst_tbl_setup_req {struct mbox_msghdr hdr;u16 base_pcifunc; +u8 use_local_lmt_region; +u64 lmt_iova; +u64 rsvd[4 ]; };/* CPT mailbox error codes
drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c +95 -35
160 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_reg.h +5 -0
@@ -49,6 +49,11 @@#define RVU_AF_PFX_VF_BAR4_ADDR (0x5400 | (a) << 4)#define RVU_AF_PFX_VF_BAR4_CFG (0x5600 | (a) << 4)#define RVU_AF_PFX_LMTLINE_ADDR (0x5800 | (a) << 4) +#define RVU_AF_SMMU_ADDR_REQ (0x6000) +#define RVU_AF_SMMU_TXN_REQ (0x6008) +#define RVU_AF_SMMU_ADDR_RSP_STS (0x6010) +#define RVU_AF_SMMU_ADDR_TLN (0x6018) +#define RVU_AF_SMMU_TLN_FLIT1 (0x6030)/* Admin function's privileged PF/VF registers */ #define RVU_PRIV_CONST (0x8000000)
Signature · 1 line
2.17.1
Geetha sowjanya
maintainerPATCH 3/3 octeontx2-pf: cn10k: Use runtime allocated LMTLINE region
In reply to Geetha sowjanyaThe current driver uses static LMTST region allocated by firmware. This memory gets populated as PF/VF BAR2. RVU PF/VF driver ioremap the memory as device memory for NIX/NPA operation. Since the memory is mapped as device memory we see performance degration. To address this issue this patch implements runtime memory allocation. RVU PF/VF allocates memory during device probe and share the base address with RVU AF. RVU AF then configure the LMT MAP table accordingly.
--- .../ethernet/marvell/octeontx2/nic/cn10k.c | 87 ++++++++----------- .../ethernet/marvell/octeontx2/nic/cn10k.h | 3 +- .../marvell/octeontx2/nic/otx2_common.h | 7 +- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 17 ++-- .../marvell/octeontx2/nic/otx2_txrx.h | 1 + .../ethernet/marvell/octeontx2/nic/otx2_vf.c | 12 ++- 6 files changed, 54 insertions(+), 73 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c +35 -52
@@ -22,69 +22,52 @@ static struct dev_hw_ops cn10k_hw_ops = { .refill_pool_ptrs = cn10k_refill_pool_ptrs, }; -int cn10k_pf_lmtst_init (struct otx2_nic *pf) +int cn10k_lmtst_init (struct otx2_nic *pfvf) { -int size, num_lines; -u64 base; -if (!test_bit (CN10K_LMTST , &pf->hw.cap_flag)) { - pf->hw_ops = &otx2_hw_ops; +struct lmtst_tbl_setup_req *req; +int qcount, err; + +if (!test_bit (CN10K_LMTST , &pfvf->hw.cap_flag)) { + pfvf->hw_ops = &otx2_hw_ops;return 0 ; } - pf->hw_ops = &cn10k_hw_ops; - base =pci_resource_start (pf->pdev,PCI_MBOX_BAR_NUM ) + - (MBOX_SIZE * (pf->total_vfs +1 )); - - size =pci_resource_len (pf->pdev,PCI_MBOX_BAR_NUM ) - - (MBOX_SIZE * (pf->total_vfs +1 )); - - pf->hw.lmt_base =ioremap (base, size); + pfvf->hw_ops = &cn10k_hw_ops; + qcount = pfvf->hw.max_queues; +/* LMTST lines allocation +* qcount = num_online_cpus(); +* NPA = TX + RX + XDP. +* NIX = TX * 32 (For Burst SQE flush). +*/ + pfvf->tot_lmt_lines = (qcount *3 ) + (qcount *32 ); + pfvf->npa_lmt_lines = qcount *3 ; + pfvf->nix_lmt_size =LMT_BURST_SIZE *LMT_LINE_SIZE ; -if (!pf->hw.lmt_base) { -dev_err (pf->dev,"Unable to map PF LMTST region\n" ); +mutex_lock (&pfvf->mbox.lock); + req =otx2_mbox_alloc_msg_lmtst_tbl_setup (&pfvf->mbox); +if (!req) { +mutex_unlock (&pfvf->mbox.lock);return -ENOMEM ; } -/* FIXME: Get the num of LMTST lines from LMT table */ - pf->tot_lmt_lines = size /LMT_LINE_SIZE ; - num_lines = (pf->tot_lmt_lines -NIX_LMTID_BASE ) / - pf->hw.tx_queues; -/* Number of LMT lines per SQ queues */ - pf->nix_lmt_lines = num_lines >32 ?32 : num_lines; - - pf->nix_lmt_size = pf->nix_lmt_lines *LMT_LINE_SIZE ; -return 0 ; -} + req->use_local_lmt_region = true; -int cn10k_vf_lmtst_init (struct otx2_nic *vf) -{ -int size, num_lines; - -if (!test_bit (CN10K_LMTST , &vf->hw.cap_flag)) { - vf->hw_ops = &otx2_hw_ops; -return 0 ; + err =qmem_alloc (pfvf->dev, &pfvf->dync_lmt, pfvf->tot_lmt_lines, +LMT_LINE_SIZE ); +if (err) { +mutex_unlock (&pfvf->mbox.lock); +return err; } + pfvf->hw.lmt_base = (u64 *)pfvf->dync_lmt->base; + req->lmt_iova = (u64 )pfvf->dync_lmt->iova; - vf->hw_ops = &cn10k_hw_ops; - size =pci_resource_len (vf->pdev,PCI_MBOX_BAR_NUM ); - vf->hw.lmt_base =ioremap_wc (pci_resource_start (vf->pdev, -PCI_MBOX_BAR_NUM ), - size); -if (!vf->hw.lmt_base) { -dev_err (vf->dev,"Unable to map VF LMTST region\n" ); -return -ENOMEM ; - } + err =otx2_sync_mbox_msg (&pfvf->mbox); +mutex_unlock (&pfvf->mbox.lock); - vf->tot_lmt_lines = size /LMT_LINE_SIZE ; -/* LMTST lines per SQ */ - num_lines = (vf->tot_lmt_lines -NIX_LMTID_BASE ) / - vf->hw.tx_queues; - vf->nix_lmt_lines = num_lines >32 ?32 : num_lines; - vf->nix_lmt_size = vf->nix_lmt_lines *LMT_LINE_SIZE ;return 0 ; } -EXPORT_SYMBOL (cn10k_vf_lmtst_init); +EXPORT_SYMBOL (cn10k_lmtst_init);int cn10k_sq_aq_init (void *dev,u16 qidx,u16 sqb_aura) {
@@ -93,9 +76,11 @@ int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura)struct otx2_snd_queue *sq; sq = &pfvf->qset.sq[qidx]; - sq->lmt_addr = (__force u64 *)((u64 )pfvf->hw.nix_lmt_base + + sq->lmt_addr = (u64 *)((u64 )pfvf->hw.nix_lmt_base + (qidx * pfvf->nix_lmt_size)); + sq->lmt_id = pfvf->npa_lmt_lines + (qidx *LMT_BURST_SIZE ); +/* Get memory to put this msg */ aq =otx2_mbox_alloc_msg_nix_cn10k_aq_enq (&pfvf->mbox);if (!aq)
@@ -158,15 +143,13 @@ void cn10k_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq)void cn10k_sqe_flush (void *dev,struct otx2_snd_queue *sq,int size,int qidx) { -struct otx2_nic *pfvf = dev; -int lmt_id =NIX_LMTID_BASE + (qidx * pfvf->nix_lmt_lines);u64 val =0 , tar_addr =0 ;/* FIXME: val[0:10] LMT_ID. * [12:15] no of LMTST - 1 in the burst. * [19:63] data size of each LMTST in the burst except first. */ - val = (lmt_id &0x7FF ); + val = (sq->lmt_id &0x7FF );/* Target address for LMTST flush tells HW how many 128bit * words are present. * tar_addr[6:4] size of first LMTST - 1 in units of 128b.
drivers/net/ethernet/marvell/octeontx2/nic/cn10k.h +1 -2
@@ -12,8 +12,7 @@void cn10k_refill_pool_ptrs (void *dev,struct otx2_cq_queue *cq);void cn10k_sqe_flush (void *dev,struct otx2_snd_queue *sq,int size,int qidx);int cn10k_sq_aq_init (void *dev,u16 qidx,u16 sqb_aura); -int cn10k_pf_lmtst_init (struct otx2_nic *pf); -int cn10k_vf_lmtst_init (struct otx2_nic *vf); +int cn10k_lmtst_init (struct otx2_nic *pfvf);int cn10k_free_all_ipolicers (struct otx2_nic *pfvf);int cn10k_alloc_matchall_ipolicer (struct otx2_nic *pfvf);int cn10k_free_matchall_ipolicer (struct otx2_nic *pfvf);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +4 -3
@@ -218,8 +218,8 @@ struct otx2_hw {unsigned long cap_flag;#define LMT_LINE_SIZE 128 -#define NIX_LMTID_BASE 72/* RX + TX + XDP */ -void __iomem *lmt_base; +#define LMT_BURST_SIZE 32/* 32 LMTST lines for burst SQE flush */ +u64 *lmt_base;u64 *npa_lmt_base;u64 *nix_lmt_base; };
@@ -363,8 +363,9 @@ struct otx2_nic {/* Block address of NIX either BLKADDR_NIX0 or BLKADDR_NIX1 */ int nix_blkaddr;/* LMTST Lines info */ +struct qmem *dync_lmt;u16 tot_lmt_lines; -u16 nix_lmt_lines; +u16 npa_lmt_lines;u32 nix_lmt_size;struct otx2_ptp *ptp;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +8 -9
@@ -1533,10 +1533,10 @@ int otx2_open(struct net_device *netdev)if (test_bit (CN10K_LMTST , &pf->hw.cap_flag)) {/* Reserve LMT lines for NPA AURA batch free */ - pf->hw.npa_lmt_base = (__force u64 *)pf->hw.lmt_base; + pf->hw.npa_lmt_base = pf->hw.lmt_base;/* Reserve LMT lines for NIX TX */ - pf->hw.nix_lmt_base = (__force u64 *)((u64 )pf->hw.npa_lmt_base + - (NIX_LMTID_BASE *LMT_LINE_SIZE )); + pf->hw.nix_lmt_base = (u64 *)((u64 )pf->hw.npa_lmt_base + + (pf->npa_lmt_lines *LMT_LINE_SIZE )); } err =otx2_init_hw_resources (pf);
@@ -2526,7 +2526,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (err) goto err_detach_rsrc; - err =cn10k_pf_lmtst_init (pf); + err =cn10k_lmtst_init (pf);if (err) goto err_detach_rsrc;
@@ -2630,8 +2630,8 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) err_ptp_destroy:otx2_ptp_destroy (pf); err_detach_rsrc: -if (hw->lmt_base) -iounmap (hw->lmt_base); +if (test_bit (CN10K_LMTST , &pf->hw.cap_flag)) +qmem_free (pf->dev, pf->dync_lmt);otx2_detach_resources (&pf->mbox); err_disable_mbox_intr:otx2_disable_mbox_intr (pf);
@@ -2772,9 +2772,8 @@ static void otx2_remove(struct pci_dev *pdev)otx2_mcam_flow_del (pf);otx2_shutdown_tc (pf);otx2_detach_resources (&pf->mbox); -if (pf->hw.lmt_base) -iounmap (pf->hw.lmt_base); - +if (test_bit (CN10K_LMTST , &pf->hw.cap_flag)) +qmem_free (pf->dev, pf->dync_lmt);otx2_disable_mbox_intr (pf);otx2_pfaf_mbox_destroy (pf);pci_free_irq_vectors (pf->pdev);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +1 -0
@@ -83,6 +83,7 @@ struct otx2_snd_queue {u16 num_sqbs;u16 sqe_thresh;u8 sqe_per_sqb; +u32 lmt_id;u64 io_addr;u64 *aura_fc_addr;u64 *lmt_addr;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +5 -7
@@ -609,7 +609,7 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (err) goto err_detach_rsrc; - err =cn10k_vf_lmtst_init (vf); + err =cn10k_lmtst_init (vf);if (err) goto err_detach_rsrc;
@@ -667,8 +667,8 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id) err_unreg_netdev:unregister_netdev (netdev); err_detach_rsrc: -if (hw->lmt_base) -iounmap (hw->lmt_base); +if (test_bit (CN10K_LMTST , &vf->hw.cap_flag)) +qmem_free (vf->dev, vf->dync_lmt);otx2_detach_resources (&vf->mbox); err_disable_mbox_intr:otx2vf_disable_mbox_intr (vf);
@@ -700,10 +700,8 @@ static void otx2vf_remove(struct pci_dev *pdev)destroy_workqueue (vf->otx2_wq);otx2vf_disable_mbox_intr (vf);otx2_detach_resources (&vf->mbox); - -if (vf->hw.lmt_base) -iounmap (vf->hw.lmt_base); - +if (test_bit (CN10K_LMTST , &vf->hw.cap_flag)) +qmem_free (vf->dev, vf->dync_lmt);otx2vf_vfaf_mbox_destroy (vf);pci_free_irq_vectors (vf->pdev);pci_set_drvdata (pdev,NULL );
Signature · 1 line
2.17.1
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 9 lines · On Tue, 29 Jun 2021 22:30:03 +0530 you wrote:
This patch series allows RVU PF/VF to allocate memory for LMTST operations instead of using memory reserved by firmware which is mapped as device memory.
The LMTST mapping table contains the RVU PF/VF LMTST memory base address entries. This table is used by hardware for LMTST operations. Patch1 introduces new mailbox message to update the LMTST table with the new allocated memory address.[...]
Here is the summary with links:
- [net-next,1/3] octeontx2-af: cn10k: Setting up lmtst map table
https://git.kernel.org/netdev/net-next/c/873a1e3d207a - [net-next,2/3] octeontx2-af: cn10k: Support configurable LMTST regions https://git.kernel.org/netdev/net-next/c/893ae97214c3 - [net-next,3/3] octeontx2-pf: cn10k: Use runtime allocated LMTLINE region https://git.kernel.org/netdev/net-next/c/5c0512072f65
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html