Skip to content

Commit b9d0fed

Browse files
Hariprasad KelamPaolo Abeni
authored andcommitted
octeontx2-af: cn10kb: Add RPM_USX MAC support
OcteonTx2's next gen platform the CN10KB has RPM_USX MAC which has a different serdes when compared to RPM MAC. Though the underlying HW is different, the CSR interface has been designed largely inline with RPM MAC, with few exceptions though. So we are using the same CGX driver for RPM_USX MAC as well and will have a different set of APIs for RPM_USX where ever necessary. The RPM and RPM_USX blocks support a different number of LMACS. RPM_USX support 8 LMACS per MAC block whereas legacy RPM supports only 4 LMACS per MAC. with this RPM_USX support double the number of DMAC filters and fifo size. This patch adds initial support for CN10KB's RPM_USX MAC i.e registering the driver and defining MAC operations (mac_ops). Adds the logic to configure internal loopback and pause frames and assign FIFO length to LMACS. Kernel reads lmac features like lmac type, autoneg, etc from shared firmware data this structure only supports 4 lmacs per MAC, this patch extends this structure to accommodate 8 lmacs. Signed-off-by: Hariprasad Kelam <[email protected]> Signed-off-by: Sunil Kovvuri Goutham <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent f2e664a commit b9d0fed

File tree

8 files changed

+270
-41
lines changed

8 files changed

+270
-41
lines changed

drivers/net/ethernet/marvell/octeontx2/af/cgx.c

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ static int cgx_fwi_link_change(struct cgx *cgx, int lmac_id, bool en);
6464
static const struct pci_device_id cgx_id_table[] = {
6565
{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_OCTEONTX2_CGX) },
6666
{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_CN10K_RPM) },
67+
{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVID_CN10KB_RPM) },
6768
{ 0, } /* end of table */
6869
};
6970

@@ -73,7 +74,8 @@ static bool is_dev_rpm(void *cgxd)
7374
{
7475
struct cgx *cgx = cgxd;
7576

76-
return (cgx->pdev->device == PCI_DEVID_CN10K_RPM);
77+
return (cgx->pdev->device == PCI_DEVID_CN10K_RPM) ||
78+
(cgx->pdev->device == PCI_DEVID_CN10KB_RPM);
7779
}
7880

7981
bool is_lmac_valid(struct cgx *cgx, int lmac_id)
@@ -485,7 +487,7 @@ int cgx_set_pkind(void *cgxd, u8 lmac_id, int pkind)
485487
if (!is_lmac_valid(cgx, lmac_id))
486488
return -ENODEV;
487489

488-
cgx_write(cgx, lmac_id, CGXX_CMRX_RX_ID_MAP, (pkind & 0x3F));
490+
cgx_write(cgx, lmac_id, cgx->mac_ops->rxid_map_offset, (pkind & 0x3F));
489491
return 0;
490492
}
491493

@@ -1224,7 +1226,7 @@ static inline void link_status_user_format(u64 lstat,
12241226
linfo->speed = cgx_speed_mbps[FIELD_GET(RESP_LINKSTAT_SPEED, lstat)];
12251227
linfo->an = FIELD_GET(RESP_LINKSTAT_AN, lstat);
12261228
linfo->fec = FIELD_GET(RESP_LINKSTAT_FEC, lstat);
1227-
linfo->lmac_type_id = cgx_get_lmac_type(cgx, lmac_id);
1229+
linfo->lmac_type_id = FIELD_GET(RESP_LINKSTAT_LMAC_TYPE, lstat);
12281230
lmac_string = cgx_lmactype_string[linfo->lmac_type_id];
12291231
strncpy(linfo->lmac_type, lmac_string, LMACTYPE_STR_LEN - 1);
12301232
}
@@ -1599,8 +1601,14 @@ static int cgx_lmac_init(struct cgx *cgx)
15991601
/* lmac_list specifies which lmacs are enabled
16001602
* when bit n is set to 1, LMAC[n] is enabled
16011603
*/
1602-
if (cgx->mac_ops->non_contiguous_serdes_lane)
1603-
lmac_list = cgx_read(cgx, 0, CGXX_CMRX_RX_LMACS) & 0xFULL;
1604+
if (cgx->mac_ops->non_contiguous_serdes_lane) {
1605+
if (is_dev_rpm2(cgx))
1606+
lmac_list =
1607+
cgx_read(cgx, 0, RPM2_CMRX_RX_LMACS) & 0xFFULL;
1608+
else
1609+
lmac_list =
1610+
cgx_read(cgx, 0, CGXX_CMRX_RX_LMACS) & 0xFULL;
1611+
}
16041612

16051613
if (cgx->lmac_count > cgx->max_lmac_per_mac)
16061614
cgx->lmac_count = cgx->max_lmac_per_mac;
@@ -1624,7 +1632,9 @@ static int cgx_lmac_init(struct cgx *cgx)
16241632

16251633
lmac->cgx = cgx;
16261634
lmac->mac_to_index_bmap.max =
1627-
MAX_DMAC_ENTRIES_PER_CGX / cgx->lmac_count;
1635+
cgx->mac_ops->dmac_filter_count /
1636+
cgx->lmac_count;
1637+
16281638
err = rvu_alloc_bitmap(&lmac->mac_to_index_bmap);
16291639
if (err)
16301640
goto err_name_free;
@@ -1711,6 +1721,15 @@ static void cgx_populate_features(struct cgx *cgx)
17111721
RVU_LMAC_FEAT_PTP | RVU_LMAC_FEAT_DMACF);
17121722
}
17131723

1724+
static u8 cgx_get_rxid_mapoffset(struct cgx *cgx)
1725+
{
1726+
if (cgx->pdev->subsystem_device == PCI_SUBSYS_DEVID_CNF10KB_RPM ||
1727+
is_dev_rpm2(cgx))
1728+
return 0x80;
1729+
else
1730+
return 0x60;
1731+
}
1732+
17141733
static struct mac_ops cgx_mac_ops = {
17151734
.name = "cgx",
17161735
.csr_offset = 0,
@@ -1723,6 +1742,7 @@ static struct mac_ops cgx_mac_ops = {
17231742
.non_contiguous_serdes_lane = false,
17241743
.rx_stats_cnt = 9,
17251744
.tx_stats_cnt = 18,
1745+
.dmac_filter_count = 32,
17261746
.get_nr_lmacs = cgx_get_nr_lmacs,
17271747
.get_lmac_type = cgx_get_lmac_type,
17281748
.lmac_fifo_len = cgx_get_lmac_fifo_len,
@@ -1754,11 +1774,13 @@ static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id)
17541774
pci_set_drvdata(pdev, cgx);
17551775

17561776
/* Use mac_ops to get MAC specific features */
1757-
if (pdev->device == PCI_DEVID_CN10K_RPM)
1758-
cgx->mac_ops = rpm_get_mac_ops();
1777+
if (is_dev_rpm(cgx))
1778+
cgx->mac_ops = rpm_get_mac_ops(cgx);
17591779
else
17601780
cgx->mac_ops = &cgx_mac_ops;
17611781

1782+
cgx->mac_ops->rxid_map_offset = cgx_get_rxid_mapoffset(cgx);
1783+
17621784
err = pci_enable_device(pdev);
17631785
if (err) {
17641786
dev_err(dev, "Failed to enable PCI device\n");

drivers/net/ethernet/marvell/octeontx2/af/cgx.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#define PCI_CFG_REG_BAR_NUM 0
2020

2121
#define CGX_ID_MASK 0xF
22-
#define MAX_DMAC_ENTRIES_PER_CGX 32
2322

2423
/* Registers */
2524
#define CGXX_CMRX_CFG 0x00
@@ -53,7 +52,7 @@
5352
#define CGXX_SCRATCH0_REG 0x1050
5453
#define CGXX_SCRATCH1_REG 0x1058
5554
#define CGX_CONST 0x2000
56-
#define CGX_CONST_RXFIFO_SIZE GENMASK_ULL(23, 0)
55+
#define CGX_CONST_RXFIFO_SIZE GENMASK_ULL(55, 32)
5756
#define CGX_CONST_MAX_LMACS GENMASK_ULL(31, 24)
5857
#define CGXX_SPUX_CONTROL1 0x10000
5958
#define CGXX_SPUX_LNX_FEC_CORR_BLOCKS 0x10700

drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ struct mac_ops {
7575
/* RPM & CGX differs in number of Receive/transmit stats */
7676
u8 rx_stats_cnt;
7777
u8 tx_stats_cnt;
78+
/* Unlike CN10K which shares same CSR offset with CGX
79+
* CNF10KB has different csr offset
80+
*/
81+
u64 rxid_map_offset;
82+
u8 dmac_filter_count;
7883
/* Incase of RPM get number of lmacs from RPMX_CMR_RX_LMACS[LMAC_EXIST]
7984
* number of setbits in lmac_exist tells number of lmacs
8085
*/
@@ -153,6 +158,6 @@ struct lmac *lmac_pdata(u8 lmac_id, struct cgx *cgx);
153158
int cgx_fwi_cmd_send(u64 req, u64 *resp, struct lmac *lmac);
154159
int cgx_fwi_cmd_generic(u64 req, u64 *resp, struct cgx *cgx, int lmac_id);
155160
bool is_lmac_valid(struct cgx *cgx, int lmac_id);
156-
struct mac_ops *rpm_get_mac_ops(void);
161+
struct mac_ops *rpm_get_mac_ops(struct cgx *cgx);
157162

158163
#endif /* LMAC_COMMON_H */

0 commit comments

Comments
 (0)