Skip to content

Commit f1cd565

Browse files
committed
Merge branch 'enetc-mqprio-fixes'
Wei Fang sayus: ==================== fix crash issue when setting MQPRIO for VFs There is a crash issue when setting MQPRIO for ENETC VFs, the root casue is that ENETC VFs don't like ENETC PFs, they don't have port registers, so hw->port of VFs is NULL. However, this NULL pointer will be accessed without any checks in enetc_mm_commit_preemptible_tcs() when configuring MQPRIO for VFs. Therefore, two patches are added to fix this issue. The first patch sets ENETC_SI_F_QBU flag only for SIs that support 802.1Qbu. The second patch adds a check in enetc_change_preemptible_tcs() to ensure that SIs that do not support 802.1Qbu do not configure preemptible TCs. --- v1 Link: https://lore.kernel.org/imx/20241030082117.1172634-1-wei.fang@nxp.com/ v2 Link: https://lore.kernel.org/imx/20241104054309.1388433-1-wei.fang@nxp.com/ --- ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 65ae975 + b2420b8 commit f1cd565

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

drivers/net/ethernet/freescale/enetc/enetc.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ EXPORT_SYMBOL_GPL(enetc_port_mac_wr);
2929
static void enetc_change_preemptible_tcs(struct enetc_ndev_priv *priv,
3030
u8 preemptible_tcs)
3131
{
32+
if (!(priv->si->hw_features & ENETC_SI_F_QBU))
33+
return;
34+
3235
priv->preemptible_tcs = preemptible_tcs;
3336
enetc_mm_commit_preemptible_tcs(priv);
3437
}
@@ -1756,15 +1759,6 @@ void enetc_get_si_caps(struct enetc_si *si)
17561759
rss = enetc_rd(hw, ENETC_SIRSSCAPR);
17571760
si->num_rss = ENETC_SIRSSCAPR_GET_NUM_RSS(rss);
17581761
}
1759-
1760-
if (val & ENETC_SIPCAPR0_QBV)
1761-
si->hw_features |= ENETC_SI_F_QBV;
1762-
1763-
if (val & ENETC_SIPCAPR0_QBU)
1764-
si->hw_features |= ENETC_SI_F_QBU;
1765-
1766-
if (val & ENETC_SIPCAPR0_PSFP)
1767-
si->hw_features |= ENETC_SI_F_PSFP;
17681762
}
17691763
EXPORT_SYMBOL_GPL(enetc_get_si_caps);
17701764

drivers/net/ethernet/freescale/enetc/enetc_hw.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323
#define ENETC_SICTR0 0x18
2424
#define ENETC_SICTR1 0x1c
2525
#define ENETC_SIPCAPR0 0x20
26-
#define ENETC_SIPCAPR0_PSFP BIT(9)
2726
#define ENETC_SIPCAPR0_RSS BIT(8)
28-
#define ENETC_SIPCAPR0_QBV BIT(4)
29-
#define ENETC_SIPCAPR0_QBU BIT(3)
3027
#define ENETC_SIPCAPR0_RFS BIT(2)
3128
#define ENETC_SIPCAPR1 0x24
3229
#define ENETC_SITGTGR 0x30
@@ -194,6 +191,9 @@ enum enetc_bdr_type {TX, RX};
194191
#define ENETC_PCAPR0 0x0900
195192
#define ENETC_PCAPR0_RXBDR(val) ((val) >> 24)
196193
#define ENETC_PCAPR0_TXBDR(val) (((val) >> 16) & 0xff)
194+
#define ENETC_PCAPR0_PSFP BIT(9)
195+
#define ENETC_PCAPR0_QBV BIT(4)
196+
#define ENETC_PCAPR0_QBU BIT(3)
197197
#define ENETC_PCAPR1 0x0904
198198
#define ENETC_PSICFGR0(n) (0x0940 + (n) * 0xc) /* n = SI index */
199199
#define ENETC_PSICFGR0_SET_TXBDR(val) ((val) & 0xff)

drivers/net/ethernet/freescale/enetc/enetc_pf.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,13 +409,32 @@ static void enetc_port_assign_rfs_entries(struct enetc_si *si)
409409
enetc_port_wr(hw, ENETC_PRFSMR, ENETC_PRFSMR_RFSE);
410410
}
411411

412+
static void enetc_port_get_caps(struct enetc_si *si)
413+
{
414+
struct enetc_hw *hw = &si->hw;
415+
u32 val;
416+
417+
val = enetc_port_rd(hw, ENETC_PCAPR0);
418+
419+
if (val & ENETC_PCAPR0_QBV)
420+
si->hw_features |= ENETC_SI_F_QBV;
421+
422+
if (val & ENETC_PCAPR0_QBU)
423+
si->hw_features |= ENETC_SI_F_QBU;
424+
425+
if (val & ENETC_PCAPR0_PSFP)
426+
si->hw_features |= ENETC_SI_F_PSFP;
427+
}
428+
412429
static void enetc_port_si_configure(struct enetc_si *si)
413430
{
414431
struct enetc_pf *pf = enetc_si_priv(si);
415432
struct enetc_hw *hw = &si->hw;
416433
int num_rings, i;
417434
u32 val;
418435

436+
enetc_port_get_caps(si);
437+
419438
val = enetc_port_rd(hw, ENETC_PCAPR0);
420439
num_rings = min(ENETC_PCAPR0_RXBDR(val), ENETC_PCAPR0_TXBDR(val));
421440

0 commit comments

Comments
 (0)