Skip to content

Commit 2e3e94c

Browse files
Hariprasad Kelamdavem330
authored andcommitted
octeontx2-af: Reset MAC features in FLR
AF driver configures MAC features like internal loopback and PFC upon receiving the request from PF and its VF netdev. But these features are not getting reset in FLR. This patch fixes the issue by resetting the same. Fixes: 23999b3 ("octeontx2-af: Enable or disable CGX internal loopback") Fixes: 1121f6b ("octeontx2-af: Priority flow control configuration support") Signed-off-by: Hariprasad Kelam <[email protected]> Signed-off-by: Sunil Goutham <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 79ebb53 commit 2e3e94c

File tree

8 files changed

+77
-6
lines changed

8 files changed

+77
-6
lines changed

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,14 +537,15 @@ static u32 cgx_get_lmac_fifo_len(void *cgxd, int lmac_id)
537537
int cgx_lmac_internal_loopback(void *cgxd, int lmac_id, bool enable)
538538
{
539539
struct cgx *cgx = cgxd;
540-
u8 lmac_type;
540+
struct lmac *lmac;
541541
u64 cfg;
542542

543543
if (!is_lmac_valid(cgx, lmac_id))
544544
return -ENODEV;
545545

546-
lmac_type = cgx->mac_ops->get_lmac_type(cgx, lmac_id);
547-
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) {
548549
cfg = cgx_read(cgx, lmac_id, CGXX_GMP_PCS_MRX_CTL);
549550
if (enable)
550551
cfg |= CGXX_GMP_PCS_MRX_CTL_LBK;
@@ -1563,6 +1564,23 @@ int cgx_lmac_linkup_start(void *cgxd)
15631564
return 0;
15641565
}
15651566

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+
15661584
static int cgx_configure_interrupt(struct cgx *cgx, struct lmac *lmac,
15671585
int cnt, bool req_free)
15681586
{
@@ -1682,6 +1700,7 @@ static int cgx_lmac_init(struct cgx *cgx)
16821700
cgx->lmac_idmap[lmac->lmac_id] = lmac;
16831701
set_bit(lmac->lmac_id, &cgx->lmac_bmap);
16841702
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);
16851704
}
16861705

16871706
return cgx_lmac_verify_fwi_version(cgx);
@@ -1778,6 +1797,7 @@ static struct mac_ops cgx_mac_ops = {
17781797
.mac_tx_enable = cgx_lmac_tx_enable,
17791798
.pfc_config = cgx_lmac_pfc_config,
17801799
.mac_get_pfc_frm_cfg = cgx_lmac_get_pfc_frm_cfg,
1800+
.mac_reset = cgx_lmac_reset,
17811801
};
17821802

17831803
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: 27 additions & 3 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 = {
@@ -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: 2 additions & 0 deletions
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)
@@ -132,4 +133,5 @@ int rpm_lmac_get_pfc_frm_cfg(void *rpmd, int lmac_id, u8 *tx_pause,
132133
int rpm2_get_nr_lmacs(void *rpmd);
133134
bool is_dev_rpm2(void *rpmd);
134135
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);
135137
#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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@ int rvu_cgx_config_tx(void *cgxd, int lmac_id, bool enable);
895895
int rvu_cgx_prio_flow_ctrl_cfg(struct rvu *rvu, u16 pcifunc, u8 tx_pause, u8 rx_pause,
896896
u16 pfc_en);
897897
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);
898899
u32 rvu_cgx_get_lmac_fifolen(struct rvu *rvu, int cgx, int lmac);
899900
int npc_get_nixlf_mcam_index(struct npc_mcam *mcam, u16 pcifunc, int nixlf,
900901
int type);

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)