Skip to content

Commit 5c05120

Browse files
Geetha sowjanyadavem330
authored andcommitted
octeontx2-pf: cn10k: Use runtime allocated LMTLINE region
The 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. Signed-off-by: Geetha sowjanya <gakula@marvell.com> Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 893ae97 commit 5c05120

File tree

6 files changed

+54
-73
lines changed

6 files changed

+54
-73
lines changed

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

Lines changed: 35 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -22,69 +22,52 @@ static struct dev_hw_ops cn10k_hw_ops = {
2222
.refill_pool_ptrs = cn10k_refill_pool_ptrs,
2323
};
2424

25-
int cn10k_pf_lmtst_init(struct otx2_nic *pf)
25+
int cn10k_lmtst_init(struct otx2_nic *pfvf)
2626
{
27-
int size, num_lines;
28-
u64 base;
2927

30-
if (!test_bit(CN10K_LMTST, &pf->hw.cap_flag)) {
31-
pf->hw_ops = &otx2_hw_ops;
28+
struct lmtst_tbl_setup_req *req;
29+
int qcount, err;
30+
31+
if (!test_bit(CN10K_LMTST, &pfvf->hw.cap_flag)) {
32+
pfvf->hw_ops = &otx2_hw_ops;
3233
return 0;
3334
}
3435

35-
pf->hw_ops = &cn10k_hw_ops;
36-
base = pci_resource_start(pf->pdev, PCI_MBOX_BAR_NUM) +
37-
(MBOX_SIZE * (pf->total_vfs + 1));
38-
39-
size = pci_resource_len(pf->pdev, PCI_MBOX_BAR_NUM) -
40-
(MBOX_SIZE * (pf->total_vfs + 1));
41-
42-
pf->hw.lmt_base = ioremap(base, size);
36+
pfvf->hw_ops = &cn10k_hw_ops;
37+
qcount = pfvf->hw.max_queues;
38+
/* LMTST lines allocation
39+
* qcount = num_online_cpus();
40+
* NPA = TX + RX + XDP.
41+
* NIX = TX * 32 (For Burst SQE flush).
42+
*/
43+
pfvf->tot_lmt_lines = (qcount * 3) + (qcount * 32);
44+
pfvf->npa_lmt_lines = qcount * 3;
45+
pfvf->nix_lmt_size = LMT_BURST_SIZE * LMT_LINE_SIZE;
4346

44-
if (!pf->hw.lmt_base) {
45-
dev_err(pf->dev, "Unable to map PF LMTST region\n");
47+
mutex_lock(&pfvf->mbox.lock);
48+
req = otx2_mbox_alloc_msg_lmtst_tbl_setup(&pfvf->mbox);
49+
if (!req) {
50+
mutex_unlock(&pfvf->mbox.lock);
4651
return -ENOMEM;
4752
}
4853

49-
/* FIXME: Get the num of LMTST lines from LMT table */
50-
pf->tot_lmt_lines = size / LMT_LINE_SIZE;
51-
num_lines = (pf->tot_lmt_lines - NIX_LMTID_BASE) /
52-
pf->hw.tx_queues;
53-
/* Number of LMT lines per SQ queues */
54-
pf->nix_lmt_lines = num_lines > 32 ? 32 : num_lines;
55-
56-
pf->nix_lmt_size = pf->nix_lmt_lines * LMT_LINE_SIZE;
57-
return 0;
58-
}
54+
req->use_local_lmt_region = true;
5955

60-
int cn10k_vf_lmtst_init(struct otx2_nic *vf)
61-
{
62-
int size, num_lines;
63-
64-
if (!test_bit(CN10K_LMTST, &vf->hw.cap_flag)) {
65-
vf->hw_ops = &otx2_hw_ops;
66-
return 0;
56+
err = qmem_alloc(pfvf->dev, &pfvf->dync_lmt, pfvf->tot_lmt_lines,
57+
LMT_LINE_SIZE);
58+
if (err) {
59+
mutex_unlock(&pfvf->mbox.lock);
60+
return err;
6761
}
62+
pfvf->hw.lmt_base = (u64 *)pfvf->dync_lmt->base;
63+
req->lmt_iova = (u64)pfvf->dync_lmt->iova;
6864

69-
vf->hw_ops = &cn10k_hw_ops;
70-
size = pci_resource_len(vf->pdev, PCI_MBOX_BAR_NUM);
71-
vf->hw.lmt_base = ioremap_wc(pci_resource_start(vf->pdev,
72-
PCI_MBOX_BAR_NUM),
73-
size);
74-
if (!vf->hw.lmt_base) {
75-
dev_err(vf->dev, "Unable to map VF LMTST region\n");
76-
return -ENOMEM;
77-
}
65+
err = otx2_sync_mbox_msg(&pfvf->mbox);
66+
mutex_unlock(&pfvf->mbox.lock);
7867

79-
vf->tot_lmt_lines = size / LMT_LINE_SIZE;
80-
/* LMTST lines per SQ */
81-
num_lines = (vf->tot_lmt_lines - NIX_LMTID_BASE) /
82-
vf->hw.tx_queues;
83-
vf->nix_lmt_lines = num_lines > 32 ? 32 : num_lines;
84-
vf->nix_lmt_size = vf->nix_lmt_lines * LMT_LINE_SIZE;
8568
return 0;
8669
}
87-
EXPORT_SYMBOL(cn10k_vf_lmtst_init);
70+
EXPORT_SYMBOL(cn10k_lmtst_init);
8871

8972
int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura)
9073
{
@@ -93,9 +76,11 @@ int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura)
9376
struct otx2_snd_queue *sq;
9477

9578
sq = &pfvf->qset.sq[qidx];
96-
sq->lmt_addr = (__force u64 *)((u64)pfvf->hw.nix_lmt_base +
79+
sq->lmt_addr = (u64 *)((u64)pfvf->hw.nix_lmt_base +
9780
(qidx * pfvf->nix_lmt_size));
9881

82+
sq->lmt_id = pfvf->npa_lmt_lines + (qidx * LMT_BURST_SIZE);
83+
9984
/* Get memory to put this msg */
10085
aq = otx2_mbox_alloc_msg_nix_cn10k_aq_enq(&pfvf->mbox);
10186
if (!aq)
@@ -158,15 +143,13 @@ void cn10k_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq)
158143

159144
void cn10k_sqe_flush(void *dev, struct otx2_snd_queue *sq, int size, int qidx)
160145
{
161-
struct otx2_nic *pfvf = dev;
162-
int lmt_id = NIX_LMTID_BASE + (qidx * pfvf->nix_lmt_lines);
163146
u64 val = 0, tar_addr = 0;
164147

165148
/* FIXME: val[0:10] LMT_ID.
166149
* [12:15] no of LMTST - 1 in the burst.
167150
* [19:63] data size of each LMTST in the burst except first.
168151
*/
169-
val = (lmt_id & 0x7FF);
152+
val = (sq->lmt_id & 0x7FF);
170153
/* Target address for LMTST flush tells HW how many 128bit
171154
* words are present.
172155
* tar_addr[6:4] size of first LMTST - 1 in units of 128b.

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
void cn10k_refill_pool_ptrs(void *dev, struct otx2_cq_queue *cq);
1313
void cn10k_sqe_flush(void *dev, struct otx2_snd_queue *sq, int size, int qidx);
1414
int cn10k_sq_aq_init(void *dev, u16 qidx, u16 sqb_aura);
15-
int cn10k_pf_lmtst_init(struct otx2_nic *pf);
16-
int cn10k_vf_lmtst_init(struct otx2_nic *vf);
15+
int cn10k_lmtst_init(struct otx2_nic *pfvf);
1716
int cn10k_free_all_ipolicers(struct otx2_nic *pfvf);
1817
int cn10k_alloc_matchall_ipolicer(struct otx2_nic *pfvf);
1918
int cn10k_free_matchall_ipolicer(struct otx2_nic *pfvf);

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ struct otx2_hw {
218218
unsigned long cap_flag;
219219

220220
#define LMT_LINE_SIZE 128
221-
#define NIX_LMTID_BASE 72 /* RX + TX + XDP */
222-
void __iomem *lmt_base;
221+
#define LMT_BURST_SIZE 32 /* 32 LMTST lines for burst SQE flush */
222+
u64 *lmt_base;
223223
u64 *npa_lmt_base;
224224
u64 *nix_lmt_base;
225225
};
@@ -363,8 +363,9 @@ struct otx2_nic {
363363
/* Block address of NIX either BLKADDR_NIX0 or BLKADDR_NIX1 */
364364
int nix_blkaddr;
365365
/* LMTST Lines info */
366+
struct qmem *dync_lmt;
366367
u16 tot_lmt_lines;
367-
u16 nix_lmt_lines;
368+
u16 npa_lmt_lines;
368369
u32 nix_lmt_size;
369370

370371
struct otx2_ptp *ptp;

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,10 +1533,10 @@ int otx2_open(struct net_device *netdev)
15331533

15341534
if (test_bit(CN10K_LMTST, &pf->hw.cap_flag)) {
15351535
/* Reserve LMT lines for NPA AURA batch free */
1536-
pf->hw.npa_lmt_base = (__force u64 *)pf->hw.lmt_base;
1536+
pf->hw.npa_lmt_base = pf->hw.lmt_base;
15371537
/* Reserve LMT lines for NIX TX */
1538-
pf->hw.nix_lmt_base = (__force u64 *)((u64)pf->hw.npa_lmt_base +
1539-
(NIX_LMTID_BASE * LMT_LINE_SIZE));
1538+
pf->hw.nix_lmt_base = (u64 *)((u64)pf->hw.npa_lmt_base +
1539+
(pf->npa_lmt_lines * LMT_LINE_SIZE));
15401540
}
15411541

15421542
err = otx2_init_hw_resources(pf);
@@ -2526,7 +2526,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)
25262526
if (err)
25272527
goto err_detach_rsrc;
25282528

2529-
err = cn10k_pf_lmtst_init(pf);
2529+
err = cn10k_lmtst_init(pf);
25302530
if (err)
25312531
goto err_detach_rsrc;
25322532

@@ -2630,8 +2630,8 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)
26302630
err_ptp_destroy:
26312631
otx2_ptp_destroy(pf);
26322632
err_detach_rsrc:
2633-
if (hw->lmt_base)
2634-
iounmap(hw->lmt_base);
2633+
if (test_bit(CN10K_LMTST, &pf->hw.cap_flag))
2634+
qmem_free(pf->dev, pf->dync_lmt);
26352635
otx2_detach_resources(&pf->mbox);
26362636
err_disable_mbox_intr:
26372637
otx2_disable_mbox_intr(pf);
@@ -2772,9 +2772,8 @@ static void otx2_remove(struct pci_dev *pdev)
27722772
otx2_mcam_flow_del(pf);
27732773
otx2_shutdown_tc(pf);
27742774
otx2_detach_resources(&pf->mbox);
2775-
if (pf->hw.lmt_base)
2776-
iounmap(pf->hw.lmt_base);
2777-
2775+
if (test_bit(CN10K_LMTST, &pf->hw.cap_flag))
2776+
qmem_free(pf->dev, pf->dync_lmt);
27782777
otx2_disable_mbox_intr(pf);
27792778
otx2_pfaf_mbox_destroy(pf);
27802779
pci_free_irq_vectors(pf->pdev);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ struct otx2_snd_queue {
8383
u16 num_sqbs;
8484
u16 sqe_thresh;
8585
u8 sqe_per_sqb;
86+
u32 lmt_id;
8687
u64 io_addr;
8788
u64 *aura_fc_addr;
8889
u64 *lmt_addr;

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
609609
if (err)
610610
goto err_detach_rsrc;
611611

612-
err = cn10k_vf_lmtst_init(vf);
612+
err = cn10k_lmtst_init(vf);
613613
if (err)
614614
goto err_detach_rsrc;
615615

@@ -667,8 +667,8 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
667667
err_unreg_netdev:
668668
unregister_netdev(netdev);
669669
err_detach_rsrc:
670-
if (hw->lmt_base)
671-
iounmap(hw->lmt_base);
670+
if (test_bit(CN10K_LMTST, &vf->hw.cap_flag))
671+
qmem_free(vf->dev, vf->dync_lmt);
672672
otx2_detach_resources(&vf->mbox);
673673
err_disable_mbox_intr:
674674
otx2vf_disable_mbox_intr(vf);
@@ -700,10 +700,8 @@ static void otx2vf_remove(struct pci_dev *pdev)
700700
destroy_workqueue(vf->otx2_wq);
701701
otx2vf_disable_mbox_intr(vf);
702702
otx2_detach_resources(&vf->mbox);
703-
704-
if (vf->hw.lmt_base)
705-
iounmap(vf->hw.lmt_base);
706-
703+
if (test_bit(CN10K_LMTST, &vf->hw.cap_flag))
704+
qmem_free(vf->dev, vf->dync_lmt);
707705
otx2vf_vfaf_mbox_destroy(vf);
708706
pci_free_irq_vectors(vf->pdev);
709707
pci_set_drvdata(pdev, NULL);

0 commit comments

Comments
 (0)