Skip to content

Commit 05cff25

Browse files
author
Paolo Abeni
committed
Merge branch 'octeontx2-af-misc-rpm-fixes'
Hariprasad Kelam says: ==================== octeontx2-af: misc RPM fixes There are few issues with the RPM driver, such as FIFO overflow and network performance problems due to wrong FIFO values. This patchset adds fixes for the same. Patch1: Fixes the mismatch between the lmac type reported by the driver and the actual hardware configuration. Patch2: Addresses low network performance observed even on RPMs with larger FIFO lengths. Patch 3 & 4: Fix the stale FEC counters reported by the driver by accessing the correct CSRs Patch 5: Resolves the issue related to RPM FIFO overflow during system reboots ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 407618d + 762ca6e commit 05cff25

File tree

8 files changed

+194
-40
lines changed

8 files changed

+194
-40
lines changed

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

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ struct mac_ops *get_mac_ops(void *cgxd)
112112
return ((struct cgx *)cgxd)->mac_ops;
113113
}
114114

115+
u32 cgx_get_fifo_len(void *cgxd)
116+
{
117+
return ((struct cgx *)cgxd)->fifo_len;
118+
}
119+
115120
void cgx_write(struct cgx *cgx, u64 lmac, u64 offset, u64 val)
116121
{
117122
writeq(val, cgx->reg_base + (lmac << cgx->mac_ops->lmac_offset) +
@@ -209,6 +214,24 @@ u8 cgx_lmac_get_p2x(int cgx_id, int lmac_id)
209214
return (cfg & CMR_P2X_SEL_MASK) >> CMR_P2X_SEL_SHIFT;
210215
}
211216

217+
static u8 cgx_get_nix_resetbit(struct cgx *cgx)
218+
{
219+
int first_lmac;
220+
u8 p2x;
221+
222+
/* non 98XX silicons supports only NIX0 block */
223+
if (cgx->pdev->subsystem_device != PCI_SUBSYS_DEVID_98XX)
224+
return CGX_NIX0_RESET;
225+
226+
first_lmac = find_first_bit(&cgx->lmac_bmap, cgx->max_lmac_per_mac);
227+
p2x = cgx_lmac_get_p2x(cgx->cgx_id, first_lmac);
228+
229+
if (p2x == CMR_P2X_SEL_NIX1)
230+
return CGX_NIX1_RESET;
231+
else
232+
return CGX_NIX0_RESET;
233+
}
234+
212235
/* Ensure the required lock for event queue(where asynchronous events are
213236
* posted) is acquired before calling this API. Else an asynchronous event(with
214237
* latest link status) can reach the destination before this function returns
@@ -501,7 +524,7 @@ static u32 cgx_get_lmac_fifo_len(void *cgxd, int lmac_id)
501524
u8 num_lmacs;
502525
u32 fifo_len;
503526

504-
fifo_len = cgx->mac_ops->fifo_len;
527+
fifo_len = cgx->fifo_len;
505528
num_lmacs = cgx->mac_ops->get_nr_lmacs(cgx);
506529

507530
switch (num_lmacs) {
@@ -1719,6 +1742,8 @@ static int cgx_lmac_init(struct cgx *cgx)
17191742
lmac->lmac_type = cgx->mac_ops->get_lmac_type(cgx, lmac->lmac_id);
17201743
}
17211744

1745+
/* Start X2P reset on given MAC block */
1746+
cgx->mac_ops->mac_x2p_reset(cgx, true);
17221747
return cgx_lmac_verify_fwi_version(cgx);
17231748

17241749
err_bitmap_free:
@@ -1764,7 +1789,7 @@ static void cgx_populate_features(struct cgx *cgx)
17641789
u64 cfg;
17651790

17661791
cfg = cgx_read(cgx, 0, CGX_CONST);
1767-
cgx->mac_ops->fifo_len = FIELD_GET(CGX_CONST_RXFIFO_SIZE, cfg);
1792+
cgx->fifo_len = FIELD_GET(CGX_CONST_RXFIFO_SIZE, cfg);
17681793
cgx->max_lmac_per_mac = FIELD_GET(CGX_CONST_MAX_LMACS, cfg);
17691794

17701795
if (is_dev_rpm(cgx))
@@ -1784,6 +1809,45 @@ static u8 cgx_get_rxid_mapoffset(struct cgx *cgx)
17841809
return 0x60;
17851810
}
17861811

1812+
static void cgx_x2p_reset(void *cgxd, bool enable)
1813+
{
1814+
struct cgx *cgx = cgxd;
1815+
int lmac_id;
1816+
u64 cfg;
1817+
1818+
if (enable) {
1819+
for_each_set_bit(lmac_id, &cgx->lmac_bmap, cgx->max_lmac_per_mac)
1820+
cgx->mac_ops->mac_enadis_rx(cgx, lmac_id, false);
1821+
1822+
usleep_range(1000, 2000);
1823+
1824+
cfg = cgx_read(cgx, 0, CGXX_CMR_GLOBAL_CONFIG);
1825+
cfg |= cgx_get_nix_resetbit(cgx) | CGX_NSCI_DROP;
1826+
cgx_write(cgx, 0, CGXX_CMR_GLOBAL_CONFIG, cfg);
1827+
} else {
1828+
cfg = cgx_read(cgx, 0, CGXX_CMR_GLOBAL_CONFIG);
1829+
cfg &= ~(cgx_get_nix_resetbit(cgx) | CGX_NSCI_DROP);
1830+
cgx_write(cgx, 0, CGXX_CMR_GLOBAL_CONFIG, cfg);
1831+
}
1832+
}
1833+
1834+
static int cgx_enadis_rx(void *cgxd, int lmac_id, bool enable)
1835+
{
1836+
struct cgx *cgx = cgxd;
1837+
u64 cfg;
1838+
1839+
if (!is_lmac_valid(cgx, lmac_id))
1840+
return -ENODEV;
1841+
1842+
cfg = cgx_read(cgx, lmac_id, CGXX_CMRX_CFG);
1843+
if (enable)
1844+
cfg |= DATA_PKT_RX_EN;
1845+
else
1846+
cfg &= ~DATA_PKT_RX_EN;
1847+
cgx_write(cgx, lmac_id, CGXX_CMRX_CFG, cfg);
1848+
return 0;
1849+
}
1850+
17871851
static struct mac_ops cgx_mac_ops = {
17881852
.name = "cgx",
17891853
.csr_offset = 0,
@@ -1815,6 +1879,8 @@ static struct mac_ops cgx_mac_ops = {
18151879
.mac_get_pfc_frm_cfg = cgx_lmac_get_pfc_frm_cfg,
18161880
.mac_reset = cgx_lmac_reset,
18171881
.mac_stats_reset = cgx_stats_reset,
1882+
.mac_x2p_reset = cgx_x2p_reset,
1883+
.mac_enadis_rx = cgx_enadis_rx,
18181884
};
18191885

18201886
static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id)

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
#define CGX_LMAC_TYPE_MASK 0xF
3333
#define CGXX_CMRX_INT 0x040
3434
#define FW_CGX_INT BIT_ULL(1)
35+
#define CGXX_CMR_GLOBAL_CONFIG 0x08
36+
#define CGX_NIX0_RESET BIT_ULL(2)
37+
#define CGX_NIX1_RESET BIT_ULL(3)
38+
#define CGX_NSCI_DROP BIT_ULL(9)
3539
#define CGXX_CMRX_INT_ENA_W1S 0x058
3640
#define CGXX_CMRX_RX_ID_MAP 0x060
3741
#define CGXX_CMRX_RX_STAT0 0x070
@@ -185,4 +189,5 @@ int cgx_lmac_get_pfc_frm_cfg(void *cgxd, int lmac_id, u8 *tx_pause,
185189
int verify_lmac_fc_cfg(void *cgxd, int lmac_id, u8 tx_pause, u8 rx_pause,
186190
int pfvf_idx);
187191
int cgx_lmac_reset(void *cgxd, int lmac_id, u8 pf_req_flr);
192+
u32 cgx_get_fifo_len(void *cgxd);
188193
#endif /* CGX_H */

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ struct mac_ops {
7272
u8 irq_offset;
7373
u8 int_ena_bit;
7474
u8 lmac_fwi;
75-
u32 fifo_len;
7675
bool non_contiguous_serdes_lane;
7776
/* RPM & CGX differs in number of Receive/transmit stats */
7877
u8 rx_stats_cnt;
@@ -133,6 +132,8 @@ struct mac_ops {
133132
int (*get_fec_stats)(void *cgxd, int lmac_id,
134133
struct cgx_fec_stats_rsp *rsp);
135134
int (*mac_stats_reset)(void *cgxd, int lmac_id);
135+
void (*mac_x2p_reset)(void *cgxd, bool enable);
136+
int (*mac_enadis_rx)(void *cgxd, int lmac_id, bool enable);
136137
};
137138

138139
struct cgx {
@@ -142,6 +143,10 @@ struct cgx {
142143
u8 lmac_count;
143144
/* number of LMACs per MAC could be 4 or 8 */
144145
u8 max_lmac_per_mac;
146+
/* length of fifo varies depending on the number
147+
* of LMACS
148+
*/
149+
u32 fifo_len;
145150
#define MAX_LMAC_COUNT 8
146151
struct lmac *lmac_idmap[MAX_LMAC_COUNT];
147152
struct work_struct cgx_cmd_work;

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

Lines changed: 67 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ static struct mac_ops rpm_mac_ops = {
3939
.mac_get_pfc_frm_cfg = rpm_lmac_get_pfc_frm_cfg,
4040
.mac_reset = rpm_lmac_reset,
4141
.mac_stats_reset = rpm_stats_reset,
42+
.mac_x2p_reset = rpm_x2p_reset,
43+
.mac_enadis_rx = rpm_enadis_rx,
4244
};
4345

4446
static struct mac_ops rpm2_mac_ops = {
@@ -72,6 +74,8 @@ static struct mac_ops rpm2_mac_ops = {
7274
.mac_get_pfc_frm_cfg = rpm_lmac_get_pfc_frm_cfg,
7375
.mac_reset = rpm_lmac_reset,
7476
.mac_stats_reset = rpm_stats_reset,
77+
.mac_x2p_reset = rpm_x2p_reset,
78+
.mac_enadis_rx = rpm_enadis_rx,
7579
};
7680

7781
bool is_dev_rpm2(void *rpmd)
@@ -467,7 +471,7 @@ u8 rpm_get_lmac_type(void *rpmd, int lmac_id)
467471
int err;
468472

469473
req = FIELD_SET(CMDREG_ID, CGX_CMD_GET_LINK_STS, req);
470-
err = cgx_fwi_cmd_generic(req, &resp, rpm, 0);
474+
err = cgx_fwi_cmd_generic(req, &resp, rpm, lmac_id);
471475
if (!err)
472476
return FIELD_GET(RESP_LINKSTAT_LMAC_TYPE, resp);
473477
return err;
@@ -480,7 +484,7 @@ u32 rpm_get_lmac_fifo_len(void *rpmd, int lmac_id)
480484
u8 num_lmacs;
481485
u32 fifo_len;
482486

483-
fifo_len = rpm->mac_ops->fifo_len;
487+
fifo_len = rpm->fifo_len;
484488
num_lmacs = rpm->mac_ops->get_nr_lmacs(rpm);
485489

486490
switch (num_lmacs) {
@@ -533,9 +537,9 @@ u32 rpm2_get_lmac_fifo_len(void *rpmd, int lmac_id)
533537
*/
534538
max_lmac = (rpm_read(rpm, 0, CGX_CONST) >> 24) & 0xFF;
535539
if (max_lmac > 4)
536-
fifo_len = rpm->mac_ops->fifo_len / 2;
540+
fifo_len = rpm->fifo_len / 2;
537541
else
538-
fifo_len = rpm->mac_ops->fifo_len;
542+
fifo_len = rpm->fifo_len;
539543

540544
if (lmac_id < 4) {
541545
num_lmacs = hweight8(lmac_info & 0xF);
@@ -699,46 +703,51 @@ int rpm_get_fec_stats(void *rpmd, int lmac_id, struct cgx_fec_stats_rsp *rsp)
699703
if (rpm->lmac_idmap[lmac_id]->link_info.fec == OTX2_FEC_NONE)
700704
return 0;
701705

706+
/* latched registers FCFECX_CW_HI/RSFEC_STAT_FAST_DATA_HI_CDC are common
707+
* for all counters. Acquire lock to ensure serialized reads
708+
*/
709+
mutex_lock(&rpm->lock);
702710
if (rpm->lmac_idmap[lmac_id]->link_info.fec == OTX2_FEC_BASER) {
703-
val_lo = rpm_read(rpm, lmac_id, RPMX_MTI_FCFECX_VL0_CCW_LO);
704-
val_hi = rpm_read(rpm, lmac_id, RPMX_MTI_FCFECX_CW_HI);
711+
val_lo = rpm_read(rpm, 0, RPMX_MTI_FCFECX_VL0_CCW_LO(lmac_id));
712+
val_hi = rpm_read(rpm, 0, RPMX_MTI_FCFECX_CW_HI(lmac_id));
705713
rsp->fec_corr_blks = (val_hi << 16 | val_lo);
706714

707-
val_lo = rpm_read(rpm, lmac_id, RPMX_MTI_FCFECX_VL0_NCCW_LO);
708-
val_hi = rpm_read(rpm, lmac_id, RPMX_MTI_FCFECX_CW_HI);
715+
val_lo = rpm_read(rpm, 0, RPMX_MTI_FCFECX_VL0_NCCW_LO(lmac_id));
716+
val_hi = rpm_read(rpm, 0, RPMX_MTI_FCFECX_CW_HI(lmac_id));
709717
rsp->fec_uncorr_blks = (val_hi << 16 | val_lo);
710718

711719
/* 50G uses 2 Physical serdes lines */
712720
if (rpm->lmac_idmap[lmac_id]->link_info.lmac_type_id ==
713721
LMAC_MODE_50G_R) {
714-
val_lo = rpm_read(rpm, lmac_id,
715-
RPMX_MTI_FCFECX_VL1_CCW_LO);
716-
val_hi = rpm_read(rpm, lmac_id,
717-
RPMX_MTI_FCFECX_CW_HI);
722+
val_lo = rpm_read(rpm, 0,
723+
RPMX_MTI_FCFECX_VL1_CCW_LO(lmac_id));
724+
val_hi = rpm_read(rpm, 0,
725+
RPMX_MTI_FCFECX_CW_HI(lmac_id));
718726
rsp->fec_corr_blks += (val_hi << 16 | val_lo);
719727

720-
val_lo = rpm_read(rpm, lmac_id,
721-
RPMX_MTI_FCFECX_VL1_NCCW_LO);
722-
val_hi = rpm_read(rpm, lmac_id,
723-
RPMX_MTI_FCFECX_CW_HI);
728+
val_lo = rpm_read(rpm, 0,
729+
RPMX_MTI_FCFECX_VL1_NCCW_LO(lmac_id));
730+
val_hi = rpm_read(rpm, 0,
731+
RPMX_MTI_FCFECX_CW_HI(lmac_id));
724732
rsp->fec_uncorr_blks += (val_hi << 16 | val_lo);
725733
}
726734
} else {
727735
/* enable RS-FEC capture */
728-
cfg = rpm_read(rpm, 0, RPMX_MTI_STAT_STATN_CONTROL);
736+
cfg = rpm_read(rpm, 0, RPMX_MTI_RSFEC_STAT_STATN_CONTROL);
729737
cfg |= RPMX_RSFEC_RX_CAPTURE | BIT(lmac_id);
730-
rpm_write(rpm, 0, RPMX_MTI_STAT_STATN_CONTROL, cfg);
738+
rpm_write(rpm, 0, RPMX_MTI_RSFEC_STAT_STATN_CONTROL, cfg);
731739

732740
val_lo = rpm_read(rpm, 0,
733741
RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_2);
734-
val_hi = rpm_read(rpm, 0, RPMX_MTI_STAT_DATA_HI_CDC);
742+
val_hi = rpm_read(rpm, 0, RPMX_MTI_RSFEC_STAT_FAST_DATA_HI_CDC);
735743
rsp->fec_corr_blks = (val_hi << 32 | val_lo);
736744

737745
val_lo = rpm_read(rpm, 0,
738746
RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_3);
739-
val_hi = rpm_read(rpm, 0, RPMX_MTI_STAT_DATA_HI_CDC);
747+
val_hi = rpm_read(rpm, 0, RPMX_MTI_RSFEC_STAT_FAST_DATA_HI_CDC);
740748
rsp->fec_uncorr_blks = (val_hi << 32 | val_lo);
741749
}
750+
mutex_unlock(&rpm->lock);
742751

743752
return 0;
744753
}
@@ -763,3 +772,41 @@ int rpm_lmac_reset(void *rpmd, int lmac_id, u8 pf_req_flr)
763772

764773
return 0;
765774
}
775+
776+
void rpm_x2p_reset(void *rpmd, bool enable)
777+
{
778+
rpm_t *rpm = rpmd;
779+
int lmac_id;
780+
u64 cfg;
781+
782+
if (enable) {
783+
for_each_set_bit(lmac_id, &rpm->lmac_bmap, rpm->max_lmac_per_mac)
784+
rpm->mac_ops->mac_enadis_rx(rpm, lmac_id, false);
785+
786+
usleep_range(1000, 2000);
787+
788+
cfg = rpm_read(rpm, 0, RPMX_CMR_GLOBAL_CFG);
789+
rpm_write(rpm, 0, RPMX_CMR_GLOBAL_CFG, cfg | RPM_NIX0_RESET);
790+
} else {
791+
cfg = rpm_read(rpm, 0, RPMX_CMR_GLOBAL_CFG);
792+
cfg &= ~RPM_NIX0_RESET;
793+
rpm_write(rpm, 0, RPMX_CMR_GLOBAL_CFG, cfg);
794+
}
795+
}
796+
797+
int rpm_enadis_rx(void *rpmd, int lmac_id, bool enable)
798+
{
799+
rpm_t *rpm = rpmd;
800+
u64 cfg;
801+
802+
if (!is_lmac_valid(rpm, lmac_id))
803+
return -ENODEV;
804+
805+
cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG);
806+
if (enable)
807+
cfg |= RPM_RX_EN;
808+
else
809+
cfg &= ~RPM_RX_EN;
810+
rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg);
811+
return 0;
812+
}

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
/* Registers */
1919
#define RPMX_CMRX_CFG 0x00
20+
#define RPMX_CMR_GLOBAL_CFG 0x08
21+
#define RPM_NIX0_RESET BIT_ULL(3)
2022
#define RPMX_RX_TS_PREPEND BIT_ULL(22)
2123
#define RPMX_TX_PTP_1S_SUPPORT BIT_ULL(17)
2224
#define RPMX_CMRX_RX_ID_MAP 0x80
@@ -84,16 +86,18 @@
8486
/* FEC stats */
8587
#define RPMX_MTI_STAT_STATN_CONTROL 0x10018
8688
#define RPMX_MTI_STAT_DATA_HI_CDC 0x10038
87-
#define RPMX_RSFEC_RX_CAPTURE BIT_ULL(27)
89+
#define RPMX_RSFEC_RX_CAPTURE BIT_ULL(28)
8890
#define RPMX_CMD_CLEAR_RX BIT_ULL(30)
8991
#define RPMX_CMD_CLEAR_TX BIT_ULL(31)
92+
#define RPMX_MTI_RSFEC_STAT_STATN_CONTROL 0x40018
93+
#define RPMX_MTI_RSFEC_STAT_FAST_DATA_HI_CDC 0x40000
9094
#define RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_2 0x40050
9195
#define RPMX_MTI_RSFEC_STAT_COUNTER_CAPTURE_3 0x40058
92-
#define RPMX_MTI_FCFECX_VL0_CCW_LO 0x38618
93-
#define RPMX_MTI_FCFECX_VL0_NCCW_LO 0x38620
94-
#define RPMX_MTI_FCFECX_VL1_CCW_LO 0x38628
95-
#define RPMX_MTI_FCFECX_VL1_NCCW_LO 0x38630
96-
#define RPMX_MTI_FCFECX_CW_HI 0x38638
96+
#define RPMX_MTI_FCFECX_VL0_CCW_LO(a) (0x38618 + ((a) * 0x40))
97+
#define RPMX_MTI_FCFECX_VL0_NCCW_LO(a) (0x38620 + ((a) * 0x40))
98+
#define RPMX_MTI_FCFECX_VL1_CCW_LO(a) (0x38628 + ((a) * 0x40))
99+
#define RPMX_MTI_FCFECX_VL1_NCCW_LO(a) (0x38630 + ((a) * 0x40))
100+
#define RPMX_MTI_FCFECX_CW_HI(a) (0x38638 + ((a) * 0x40))
97101

98102
/* CN10KB CSR Declaration */
99103
#define RPM2_CMRX_SW_INT 0x1b0
@@ -137,4 +141,6 @@ bool is_dev_rpm2(void *rpmd);
137141
int rpm_get_fec_stats(void *cgxd, int lmac_id, struct cgx_fec_stats_rsp *rsp);
138142
int rpm_lmac_reset(void *rpmd, int lmac_id, u8 pf_req_flr);
139143
int rpm_stats_reset(void *rpmd, int lmac_id);
144+
void rpm_x2p_reset(void *rpmd, bool enable);
145+
int rpm_enadis_rx(void *rpmd, int lmac_id, bool enable);
140146
#endif /* RPM_H */

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,7 @@ static int rvu_setup_hw_resources(struct rvu *rvu)
11621162
}
11631163

11641164
rvu_program_channels(rvu);
1165+
cgx_start_linkup(rvu);
11651166

11661167
err = rvu_mcs_init(rvu);
11671168
if (err) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,7 @@ int rvu_cgx_prio_flow_ctrl_cfg(struct rvu *rvu, u16 pcifunc, u8 tx_pause, u8 rx_
10251025
int rvu_cgx_cfg_pause_frm(struct rvu *rvu, u16 pcifunc, u8 tx_pause, u8 rx_pause);
10261026
void rvu_mac_reset(struct rvu *rvu, u16 pcifunc);
10271027
u32 rvu_cgx_get_lmac_fifolen(struct rvu *rvu, int cgx, int lmac);
1028+
void cgx_start_linkup(struct rvu *rvu);
10281029
int npc_get_nixlf_mcam_index(struct npc_mcam *mcam, u16 pcifunc, int nixlf,
10291030
int type);
10301031
bool is_mcam_entry_enabled(struct rvu *rvu, struct npc_mcam *mcam, int blkaddr,

0 commit comments

Comments
 (0)