Skip to content

Commit 6e8ad43

Browse files
Geetha sowjanyadavem330
authored andcommitted
octeontx2-pf: cn10k: Map LMTST region
On CN10K platform transmit/receive buffer alloc and free from/to hardware had changed to support burst operation. Whereas pervious silicon's only support single buffer free at a time. To Support the same firmware allocates a DRAM region for each PF/VF for storing LMTLINES. These LMTLINES are used for NPA batch free and for flushing SQE to the hardware. PF/VF LMTST region is accessed via BAR4. PFs LMTST region is followed by its VFs mbox memory. The size of region varies from 2KB to 256KB based on number of LMTLINES configured. This patch adds support for - Mapping PF/VF LMTST region. - Reserves 0-71 (RX + TX + XDP) LMTST lines for NPA batch free operation. - Reserves 72-512 LMTST lines for NIX SQE flush. Signed-off-by: Geetha sowjanya <[email protected]> Signed-off-by: Sunil Goutham <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d21a857 commit 6e8ad43

File tree

3 files changed

+100
-4
lines changed

3 files changed

+100
-4
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,14 @@ struct otx2_hw {
209209
u8 lbk_links; /* No. of LBK links present in HW */
210210
#define HW_TSO BIT_ULL(0)
211211
#define CN10K_MBOX BIT_ULL(1)
212+
#define CN10K_LMTST BIT_ULL(2)
212213
unsigned long cap_flag;
214+
215+
#define LMT_LINE_SIZE 128
216+
#define NIX_LMTID_BASE 72 /* RX + TX + XDP */
217+
void __iomem *lmt_base;
218+
u64 *npa_lmt_base;
219+
u64 *nix_lmt_base;
213220
};
214221

215222
struct otx2_vf_config {
@@ -319,6 +326,10 @@ struct otx2_nic {
319326

320327
/* Block address of NIX either BLKADDR_NIX0 or BLKADDR_NIX1 */
321328
int nix_blkaddr;
329+
/* LMTST Lines info */
330+
u16 tot_lmt_lines;
331+
u16 nix_lmt_lines;
332+
u32 nix_lmt_size;
322333

323334
struct otx2_ptp *ptp;
324335
struct hwtstamp_config tstamp;
@@ -384,8 +395,10 @@ static inline void otx2_setup_dev_hw_settings(struct otx2_nic *pfvf)
384395
pfvf->hw.rq_skid = 600;
385396
pfvf->qset.rqe_cnt = Q_COUNT(Q_SIZE_1K);
386397
}
387-
if (!is_dev_otx2(pfvf->pdev))
398+
if (!is_dev_otx2(pfvf->pdev)) {
388399
__set_bit(CN10K_MBOX, &hw->cap_flag);
400+
__set_bit(CN10K_LMTST, &hw->cap_flag);
401+
}
389402
}
390403

391404
/* Register read/write APIs */

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

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,39 @@ enum {
4646
static int otx2_config_hw_tx_tstamp(struct otx2_nic *pfvf, bool enable);
4747
static int otx2_config_hw_rx_tstamp(struct otx2_nic *pfvf, bool enable);
4848

49+
static int cn10k_lmtst_init(struct otx2_nic *pf)
50+
{
51+
int size, num_lines;
52+
u64 base;
53+
54+
if (!test_bit(CN10K_LMTST, &pf->hw.cap_flag))
55+
return 0;
56+
57+
base = pci_resource_start(pf->pdev, PCI_MBOX_BAR_NUM) +
58+
(MBOX_SIZE * (pf->total_vfs + 1));
59+
60+
size = pci_resource_len(pf->pdev, PCI_MBOX_BAR_NUM) -
61+
(MBOX_SIZE * (pf->total_vfs + 1));
62+
63+
pf->hw.lmt_base = ioremap(base, size);
64+
65+
if (!pf->hw.lmt_base) {
66+
dev_err(pf->dev, "Unable to map PF LMTST region\n");
67+
return -ENOMEM;
68+
}
69+
70+
/* FIXME: Get the num of LMTST lines from LMT table */
71+
pf->tot_lmt_lines = size / LMT_LINE_SIZE;
72+
num_lines = (pf->tot_lmt_lines - NIX_LMTID_BASE) /
73+
pf->hw.tx_queues;
74+
/* Number of LMT lines per SQ queues */
75+
pf->nix_lmt_lines = num_lines > 32 ? 32 : num_lines;
76+
77+
pf->nix_lmt_size = pf->nix_lmt_lines * LMT_LINE_SIZE;
78+
79+
return 0;
80+
}
81+
4982
static int otx2_change_mtu(struct net_device *netdev, int new_mtu)
5083
{
5184
bool if_up = netif_running(netdev);
@@ -1498,6 +1531,14 @@ int otx2_open(struct net_device *netdev)
14981531
if (!qset->rq)
14991532
goto err_free_mem;
15001533

1534+
if (test_bit(CN10K_LMTST, &pf->hw.cap_flag)) {
1535+
/* Reserve LMT lines for NPA AURA batch free */
1536+
pf->hw.npa_lmt_base = (__force u64 *)pf->hw.lmt_base;
1537+
/* 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));
1540+
}
1541+
15011542
err = otx2_init_hw_resources(pf);
15021543
if (err)
15031544
goto err_free_mem;
@@ -2336,6 +2377,8 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)
23362377
goto err_free_netdev;
23372378
}
23382379

2380+
otx2_setup_dev_hw_settings(pf);
2381+
23392382
/* Init PF <=> AF mailbox stuff */
23402383
err = otx2_pfaf_mbox_init(pf);
23412384
if (err)
@@ -2361,7 +2404,9 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)
23612404
if (err)
23622405
goto err_detach_rsrc;
23632406

2364-
otx2_setup_dev_hw_settings(pf);
2407+
err = cn10k_lmtst_init(pf);
2408+
if (err)
2409+
goto err_detach_rsrc;
23652410

23662411
/* Assign default mac address */
23672412
otx2_get_mac_from_af(netdev);
@@ -2446,6 +2491,8 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)
24462491
err_ptp_destroy:
24472492
otx2_ptp_destroy(pf);
24482493
err_detach_rsrc:
2494+
if (hw->lmt_base)
2495+
iounmap(hw->lmt_base);
24492496
otx2_detach_resources(&pf->mbox);
24502497
err_disable_mbox_intr:
24512498
otx2_disable_mbox_intr(pf);
@@ -2605,6 +2652,9 @@ static void otx2_remove(struct pci_dev *pdev)
26052652
otx2_ptp_destroy(pf);
26062653
otx2_mcam_flow_del(pf);
26072654
otx2_detach_resources(&pf->mbox);
2655+
if (pf->hw.lmt_base)
2656+
iounmap(pf->hw.lmt_base);
2657+
26082658
otx2_disable_mbox_intr(pf);
26092659
otx2_pfaf_mbox_destroy(pf);
26102660
pci_free_irq_vectors(pf->pdev);

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

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,31 @@ enum {
2727
RVU_VF_INT_VEC_MBOX = 0x0,
2828
};
2929

30+
static int cn10k_lmtst_init(struct otx2_nic *vf)
31+
{
32+
int size, num_lines;
33+
34+
if (!test_bit(CN10K_LMTST, &vf->hw.cap_flag))
35+
return 0;
36+
37+
size = pci_resource_len(vf->pdev, PCI_MBOX_BAR_NUM);
38+
vf->hw.lmt_base = ioremap_wc(pci_resource_start(vf->pdev,
39+
PCI_MBOX_BAR_NUM),
40+
size);
41+
if (!vf->hw.lmt_base) {
42+
dev_err(vf->dev, "Unable to map VF LMTST region\n");
43+
return -ENOMEM;
44+
}
45+
46+
vf->tot_lmt_lines = size / LMT_LINE_SIZE;
47+
/* LMTST lines per SQ */
48+
num_lines = (vf->tot_lmt_lines - NIX_LMTID_BASE) /
49+
vf->hw.tx_queues;
50+
vf->nix_lmt_lines = num_lines > 32 ? 32 : num_lines;
51+
vf->nix_lmt_size = vf->nix_lmt_lines * LMT_LINE_SIZE;
52+
return 0;
53+
}
54+
3055
static void otx2vf_process_vfaf_mbox_msg(struct otx2_nic *vf,
3156
struct mbox_msghdr *msg)
3257
{
@@ -536,6 +561,7 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
536561
goto err_free_irq_vectors;
537562
}
538563

564+
otx2_setup_dev_hw_settings(vf);
539565
/* Init VF <=> PF mailbox stuff */
540566
err = otx2vf_vfaf_mbox_init(vf);
541567
if (err)
@@ -559,7 +585,9 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
559585
if (err)
560586
goto err_detach_rsrc;
561587

562-
otx2_setup_dev_hw_settings(vf);
588+
err = cn10k_lmtst_init(vf);
589+
if (err)
590+
goto err_detach_rsrc;
563591

564592
/* Assign default mac address */
565593
otx2_get_mac_from_af(netdev);
@@ -611,6 +639,8 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
611639
return 0;
612640

613641
err_detach_rsrc:
642+
if (hw->lmt_base)
643+
iounmap(hw->lmt_base);
614644
otx2_detach_resources(&vf->mbox);
615645
err_disable_mbox_intr:
616646
otx2vf_disable_mbox_intr(vf);
@@ -639,8 +669,11 @@ static void otx2vf_remove(struct pci_dev *pdev)
639669
cancel_work_sync(&vf->reset_task);
640670
unregister_netdev(netdev);
641671
otx2vf_disable_mbox_intr(vf);
642-
643672
otx2_detach_resources(&vf->mbox);
673+
674+
if (vf->hw.lmt_base)
675+
iounmap(vf->hw.lmt_base);
676+
644677
otx2vf_vfaf_mbox_destroy(vf);
645678
pci_free_irq_vectors(vf->pdev);
646679
pci_set_drvdata(pdev, NULL);

0 commit comments

Comments
 (0)