Skip to content

Commit 97791d3

Browse files
committed
Merge branch 'octeontx2-af-fixes'
Hariprasad Kelam says: ==================== octeontx2-af: MAC block fixes for CN10KB This patch set contains fixes for the issues encountered in testing CN10KB MAC block RPM_USX. Patch1: firmware to kernel communication is not working due to wrong interrupt configuration. CSR addresses are corrected. Patch2: NIX to RVU PF mapping errors encountered due to wrong firmware config. Corrects this mapping error. Patch3: Driver is trying to access non exist cgx/lmac which is resulting in kernel panic. Address this issue by adding proper checks. Patch4: MAC features are not getting reset on FLR. Fix the issue by resetting the stale config. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents c97d3fb + 2e3e94c commit 97791d3

File tree

8 files changed

+99
-9
lines changed

8 files changed

+99
-9
lines changed

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

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,20 @@ void cgx_lmac_write(int cgx_id, int lmac_id, u64 offset, u64 val)
169169
{
170170
struct cgx *cgx_dev = cgx_get_pdata(cgx_id);
171171

172+
/* Software must not access disabled LMAC registers */
173+
if (!is_lmac_valid(cgx_dev, lmac_id))
174+
return;
172175
cgx_write(cgx_dev, lmac_id, offset, val);
173176
}
174177

175178
u64 cgx_lmac_read(int cgx_id, int lmac_id, u64 offset)
176179
{
177180
struct cgx *cgx_dev = cgx_get_pdata(cgx_id);
178181

182+
/* Software must not access disabled LMAC registers */
183+
if (!is_lmac_valid(cgx_dev, lmac_id))
184+
return 0;
185+
179186
return cgx_read(cgx_dev, lmac_id, offset);
180187
}
181188

@@ -530,14 +537,15 @@ static u32 cgx_get_lmac_fifo_len(void *cgxd, int lmac_id)
530537
int cgx_lmac_internal_loopback(void *cgxd, int lmac_id, bool enable)
531538
{
532539
struct cgx *cgx = cgxd;
533-
u8 lmac_type;
540+
struct lmac *lmac;
534541
u64 cfg;
535542

536543
if (!is_lmac_valid(cgx, lmac_id))
537544
return -ENODEV;
538545

539-
lmac_type = cgx->mac_ops->get_lmac_type(cgx, lmac_id);
540-
if (lmac_type == LMAC_MODE_SGMII || lmac_type == LMAC_MODE_QSGMII) {
546+
lmac = lmac_pdata(lmac_id, cgx);
547+
if (lmac->lmac_type == LMAC_MODE_SGMII ||
548+
lmac->lmac_type == LMAC_MODE_QSGMII) {
541549
cfg = cgx_read(cgx, lmac_id, CGXX_GMP_PCS_MRX_CTL);
542550
if (enable)
543551
cfg |= CGXX_GMP_PCS_MRX_CTL_LBK;
@@ -1556,6 +1564,23 @@ int cgx_lmac_linkup_start(void *cgxd)
15561564
return 0;
15571565
}
15581566

1567+
int cgx_lmac_reset(void *cgxd, int lmac_id, u8 pf_req_flr)
1568+
{
1569+
struct cgx *cgx = cgxd;
1570+
u64 cfg;
1571+
1572+
if (!is_lmac_valid(cgx, lmac_id))
1573+
return -ENODEV;
1574+
1575+
/* Resetting PFC related CSRs */
1576+
cfg = 0xff;
1577+
cgx_write(cgxd, lmac_id, CGXX_CMRX_RX_LOGL_XON, cfg);
1578+
1579+
if (pf_req_flr)
1580+
cgx_lmac_internal_loopback(cgxd, lmac_id, false);
1581+
return 0;
1582+
}
1583+
15591584
static int cgx_configure_interrupt(struct cgx *cgx, struct lmac *lmac,
15601585
int cnt, bool req_free)
15611586
{
@@ -1675,6 +1700,7 @@ static int cgx_lmac_init(struct cgx *cgx)
16751700
cgx->lmac_idmap[lmac->lmac_id] = lmac;
16761701
set_bit(lmac->lmac_id, &cgx->lmac_bmap);
16771702
cgx->mac_ops->mac_pause_frm_config(cgx, lmac->lmac_id, true);
1703+
lmac->lmac_type = cgx->mac_ops->get_lmac_type(cgx, lmac->lmac_id);
16781704
}
16791705

16801706
return cgx_lmac_verify_fwi_version(cgx);
@@ -1771,6 +1797,7 @@ static struct mac_ops cgx_mac_ops = {
17711797
.mac_tx_enable = cgx_lmac_tx_enable,
17721798
.pfc_config = cgx_lmac_pfc_config,
17731799
.mac_get_pfc_frm_cfg = cgx_lmac_get_pfc_frm_cfg,
1800+
.mac_reset = cgx_lmac_reset,
17741801
};
17751802

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

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#define CGXX_CMRX_INT_ENA_W1S 0x058
3636
#define CGXX_CMRX_RX_ID_MAP 0x060
3737
#define CGXX_CMRX_RX_STAT0 0x070
38+
#define CGXX_CMRX_RX_LOGL_XON 0x100
3839
#define CGXX_CMRX_RX_LMACS 0x128
3940
#define CGXX_CMRX_RX_DMAC_CTL0 (0x1F8 + mac_ops->csr_offset)
4041
#define CGX_DMAC_CTL0_CAM_ENABLE BIT_ULL(3)
@@ -181,4 +182,5 @@ int cgx_lmac_get_pfc_frm_cfg(void *cgxd, int lmac_id, u8 *tx_pause,
181182
u8 *rx_pause);
182183
int verify_lmac_fc_cfg(void *cgxd, int lmac_id, u8 tx_pause, u8 rx_pause,
183184
int pfvf_idx);
185+
int cgx_lmac_reset(void *cgxd, int lmac_id, u8 pf_req_flr);
184186
#endif /* CGX_H */

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* @cgx: parent cgx port
2525
* @mcast_filters_count: Number of multicast filters installed
2626
* @lmac_id: lmac port id
27+
* @lmac_type: lmac type like SGMII/XAUI
2728
* @cmd_pend: flag set before new command is started
2829
* flag cleared after command response is received
2930
* @name: lmac port name
@@ -43,6 +44,7 @@ struct lmac {
4344
struct cgx *cgx;
4445
u8 mcast_filters_count;
4546
u8 lmac_id;
47+
u8 lmac_type;
4648
bool cmd_pend;
4749
char *name;
4850
};
@@ -125,6 +127,7 @@ struct mac_ops {
125127

126128
int (*mac_get_pfc_frm_cfg)(void *cgxd, int lmac_id,
127129
u8 *tx_pause, u8 *rx_pause);
130+
int (*mac_reset)(void *cgxd, int lmac_id, u8 pf_req_flr);
128131

129132
/* FEC stats */
130133
int (*get_fec_stats)(void *cgxd, int lmac_id,

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

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static struct mac_ops rpm_mac_ops = {
3737
.mac_tx_enable = rpm_lmac_tx_enable,
3838
.pfc_config = rpm_lmac_pfc_config,
3939
.mac_get_pfc_frm_cfg = rpm_lmac_get_pfc_frm_cfg,
40+
.mac_reset = rpm_lmac_reset,
4041
};
4142

4243
static struct mac_ops rpm2_mac_ops = {
@@ -47,7 +48,7 @@ static struct mac_ops rpm2_mac_ops = {
4748
.int_set_reg = RPM2_CMRX_SW_INT_ENA_W1S,
4849
.irq_offset = 1,
4950
.int_ena_bit = BIT_ULL(0),
50-
.lmac_fwi = RPM_LMAC_FWI,
51+
.lmac_fwi = RPM2_LMAC_FWI,
5152
.non_contiguous_serdes_lane = true,
5253
.rx_stats_cnt = 43,
5354
.tx_stats_cnt = 34,
@@ -68,6 +69,7 @@ static struct mac_ops rpm2_mac_ops = {
6869
.mac_tx_enable = rpm_lmac_tx_enable,
6970
.pfc_config = rpm_lmac_pfc_config,
7071
.mac_get_pfc_frm_cfg = rpm_lmac_get_pfc_frm_cfg,
72+
.mac_reset = rpm_lmac_reset,
7173
};
7274

7375
bool is_dev_rpm2(void *rpmd)
@@ -537,14 +539,15 @@ u32 rpm2_get_lmac_fifo_len(void *rpmd, int lmac_id)
537539
int rpm_lmac_internal_loopback(void *rpmd, int lmac_id, bool enable)
538540
{
539541
rpm_t *rpm = rpmd;
540-
u8 lmac_type;
542+
struct lmac *lmac;
541543
u64 cfg;
542544

543545
if (!is_lmac_valid(rpm, lmac_id))
544546
return -ENODEV;
545-
lmac_type = rpm->mac_ops->get_lmac_type(rpm, lmac_id);
546547

547-
if (lmac_type == LMAC_MODE_QSGMII || lmac_type == LMAC_MODE_SGMII) {
548+
lmac = lmac_pdata(lmac_id, rpm);
549+
if (lmac->lmac_type == LMAC_MODE_QSGMII ||
550+
lmac->lmac_type == LMAC_MODE_SGMII) {
548551
dev_err(&rpm->pdev->dev, "loopback not supported for LPC mode\n");
549552
return 0;
550553
}
@@ -713,3 +716,24 @@ int rpm_get_fec_stats(void *rpmd, int lmac_id, struct cgx_fec_stats_rsp *rsp)
713716

714717
return 0;
715718
}
719+
720+
int rpm_lmac_reset(void *rpmd, int lmac_id, u8 pf_req_flr)
721+
{
722+
u64 rx_logl_xon, cfg;
723+
rpm_t *rpm = rpmd;
724+
725+
if (!is_lmac_valid(rpm, lmac_id))
726+
return -ENODEV;
727+
728+
/* Resetting PFC related CSRs */
729+
rx_logl_xon = is_dev_rpm2(rpm) ? RPM2_CMRX_RX_LOGL_XON :
730+
RPMX_CMRX_RX_LOGL_XON;
731+
cfg = 0xff;
732+
733+
rpm_write(rpm, lmac_id, rx_logl_xon, cfg);
734+
735+
if (pf_req_flr)
736+
rpm_lmac_internal_loopback(rpm, lmac_id, false);
737+
738+
return 0;
739+
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
#define RPMX_MTI_MAC100X_CL01_PAUSE_QUANTA 0x80A8
7575
#define RPMX_MTI_MAC100X_CL89_PAUSE_QUANTA 0x8108
7676
#define RPM_DEFAULT_PAUSE_TIME 0x7FF
77+
#define RPMX_CMRX_RX_LOGL_XON 0x4100
7778

7879
#define RPMX_MTI_MAC100X_XIF_MODE 0x8100
7980
#define RPMX_ONESTEP_ENABLE BIT_ULL(5)
@@ -94,7 +95,8 @@
9495

9596
/* CN10KB CSR Declaration */
9697
#define RPM2_CMRX_SW_INT 0x1b0
97-
#define RPM2_CMRX_SW_INT_ENA_W1S 0x1b8
98+
#define RPM2_CMRX_SW_INT_ENA_W1S 0x1c8
99+
#define RPM2_LMAC_FWI 0x12
98100
#define RPM2_CMR_CHAN_MSK_OR 0x3120
99101
#define RPM2_CMR_RX_OVR_BP_EN BIT_ULL(2)
100102
#define RPM2_CMR_RX_OVR_BP_BP BIT_ULL(1)
@@ -131,4 +133,5 @@ int rpm_lmac_get_pfc_frm_cfg(void *rpmd, int lmac_id, u8 *tx_pause,
131133
int rpm2_get_nr_lmacs(void *rpmd);
132134
bool is_dev_rpm2(void *rpmd);
133135
int rpm_get_fec_stats(void *cgxd, int lmac_id, struct cgx_fec_stats_rsp *rsp);
136+
int rpm_lmac_reset(void *rpmd, int lmac_id, u8 pf_req_flr);
134137
#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
@@ -2629,6 +2629,7 @@ static void __rvu_flr_handler(struct rvu *rvu, u16 pcifunc)
26292629
* Since LF is detached use LF number as -1.
26302630
*/
26312631
rvu_npc_free_mcam_entries(rvu, pcifunc, -1);
2632+
rvu_mac_reset(rvu, pcifunc);
26322633

26332634
mutex_unlock(&rvu->flr_lock);
26342635
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#define PCI_DEVID_OCTEONTX2_LBK 0xA061
2424

2525
/* Subsystem Device ID */
26+
#define PCI_SUBSYS_DEVID_98XX 0xB100
2627
#define PCI_SUBSYS_DEVID_96XX 0xB200
2728
#define PCI_SUBSYS_DEVID_CN10K_A 0xB900
2829
#define PCI_SUBSYS_DEVID_CNF10K_B 0xBC00
@@ -686,6 +687,16 @@ static inline u16 rvu_nix_chan_cpt(struct rvu *rvu, u8 chan)
686687
return rvu->hw->cpt_chan_base + chan;
687688
}
688689

690+
static inline bool is_rvu_supports_nix1(struct rvu *rvu)
691+
{
692+
struct pci_dev *pdev = rvu->pdev;
693+
694+
if (pdev->subsystem_device == PCI_SUBSYS_DEVID_98XX)
695+
return true;
696+
697+
return false;
698+
}
699+
689700
/* Function Prototypes
690701
* RVU
691702
*/
@@ -884,6 +895,7 @@ int rvu_cgx_config_tx(void *cgxd, int lmac_id, bool enable);
884895
int rvu_cgx_prio_flow_ctrl_cfg(struct rvu *rvu, u16 pcifunc, u8 tx_pause, u8 rx_pause,
885896
u16 pfc_en);
886897
int rvu_cgx_cfg_pause_frm(struct rvu *rvu, u16 pcifunc, u8 tx_pause, u8 rx_pause);
898+
void rvu_mac_reset(struct rvu *rvu, u16 pcifunc);
887899
u32 rvu_cgx_get_lmac_fifolen(struct rvu *rvu, int cgx, int lmac);
888900
int npc_get_nixlf_mcam_index(struct npc_mcam *mcam, u16 pcifunc, int nixlf,
889901
int type);

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static void rvu_map_cgx_nix_block(struct rvu *rvu, int pf,
114114
p2x = cgx_lmac_get_p2x(cgx_id, lmac_id);
115115
/* Firmware sets P2X_SELECT as either NIX0 or NIX1 */
116116
pfvf->nix_blkaddr = BLKADDR_NIX0;
117-
if (p2x == CMR_P2X_SEL_NIX1)
117+
if (is_rvu_supports_nix1(rvu) && p2x == CMR_P2X_SEL_NIX1)
118118
pfvf->nix_blkaddr = BLKADDR_NIX1;
119119
}
120120

@@ -1250,3 +1250,21 @@ int rvu_mbox_handler_cgx_prio_flow_ctrl_cfg(struct rvu *rvu,
12501250
mac_ops->mac_get_pfc_frm_cfg(cgxd, lmac_id, &rsp->tx_pause, &rsp->rx_pause);
12511251
return err;
12521252
}
1253+
1254+
void rvu_mac_reset(struct rvu *rvu, u16 pcifunc)
1255+
{
1256+
int pf = rvu_get_pf(pcifunc);
1257+
struct mac_ops *mac_ops;
1258+
struct cgx *cgxd;
1259+
u8 cgx, lmac;
1260+
1261+
if (!is_pf_cgxmapped(rvu, pf))
1262+
return;
1263+
1264+
rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx, &lmac);
1265+
cgxd = rvu_cgx_pdata(cgx, rvu);
1266+
mac_ops = get_mac_ops(cgxd);
1267+
1268+
if (mac_ops->mac_reset(cgxd, lmac, !is_vf(pcifunc)))
1269+
dev_err(rvu->dev, "Failed to reset MAC\n");
1270+
}

0 commit comments

Comments
 (0)