Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: enetc: preserve TX ring priority across reconfiguration

In the blamed commit, a rudimentary reallocation procedure for RX buffer
descriptors was implemented, for the situation when their format changes
between normal (no PTP) and extended (PTP).

enetc_hwtstamp_set() calls enetc_close() and enetc_open() in a sequence,
and this sequence loses information which was previously configured in
the TX BDR Mode Register, specifically via the enetc_set_bdr_prio() call.
The TX ring priority is configured by tc-mqprio and tc-taprio, and
affects important things for TSN such as the TX time of packets. The
issue manifests itself most visibly by the fact that isochron --txtime
reports premature packet transmissions when PTP is first enabled on an
enetc interface.

Save the TX ring priority in a new field in struct enetc_bdr (occupies a
2 byte hole on arm64) in order to make this survive a ring reconfiguration.

Fixes: 434cebabd3a2 ("enetc: Add dynamic allocation of extended Rx BD rings")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Alexander Lobakin <alexandr.lobakin@intel.com>
Link: https://lore.kernel.org/r/20221122130936.1704151-1-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Vladimir Oltean and committed by
Jakub Kicinski
290b5fe0 9a234a2a

+19 -11
+5 -3
drivers/net/ethernet/freescale/enetc/enetc.c
··· 2058 2058 /* enable Tx ints by setting pkt thr to 1 */ 2059 2059 enetc_txbdr_wr(hw, idx, ENETC_TBICR0, ENETC_TBICR0_ICEN | 0x1); 2060 2060 2061 - tbmr = ENETC_TBMR_EN; 2061 + tbmr = ENETC_TBMR_EN | ENETC_TBMR_SET_PRIO(tx_ring->prio); 2062 2062 if (tx_ring->ndev->features & NETIF_F_HW_VLAN_CTAG_TX) 2063 2063 tbmr |= ENETC_TBMR_VIH; 2064 2064 ··· 2461 2461 /* Reset all ring priorities to 0 */ 2462 2462 for (i = 0; i < priv->num_tx_rings; i++) { 2463 2463 tx_ring = priv->tx_ring[i]; 2464 - enetc_set_bdr_prio(hw, tx_ring->index, 0); 2464 + tx_ring->prio = 0; 2465 + enetc_set_bdr_prio(hw, tx_ring->index, tx_ring->prio); 2465 2466 } 2466 2467 2467 2468 return 0; ··· 2481 2480 */ 2482 2481 for (i = 0; i < num_tc; i++) { 2483 2482 tx_ring = priv->tx_ring[i]; 2484 - enetc_set_bdr_prio(hw, tx_ring->index, i); 2483 + tx_ring->prio = i; 2484 + enetc_set_bdr_prio(hw, tx_ring->index, tx_ring->prio); 2485 2485 } 2486 2486 2487 2487 /* Reset the number of netdev queues based on the TC count */
+1
drivers/net/ethernet/freescale/enetc/enetc.h
··· 95 95 void __iomem *rcir; 96 96 }; 97 97 u16 index; 98 + u16 prio; 98 99 int bd_count; /* # of BDs */ 99 100 int next_to_use; 100 101 int next_to_clean;
+13 -8
drivers/net/ethernet/freescale/enetc/enetc_qos.c
··· 137 137 struct tc_taprio_qopt_offload *taprio = type_data; 138 138 struct enetc_ndev_priv *priv = netdev_priv(ndev); 139 139 struct enetc_hw *hw = &priv->si->hw; 140 + struct enetc_bdr *tx_ring; 140 141 int err; 141 142 int i; 142 143 ··· 146 145 if (priv->tx_ring[i]->tsd_enable) 147 146 return -EBUSY; 148 147 149 - for (i = 0; i < priv->num_tx_rings; i++) 150 - enetc_set_bdr_prio(hw, priv->tx_ring[i]->index, 151 - taprio->enable ? i : 0); 148 + for (i = 0; i < priv->num_tx_rings; i++) { 149 + tx_ring = priv->tx_ring[i]; 150 + tx_ring->prio = taprio->enable ? i : 0; 151 + enetc_set_bdr_prio(hw, tx_ring->index, tx_ring->prio); 152 + } 152 153 153 154 err = enetc_setup_taprio(ndev, taprio); 154 - 155 - if (err) 156 - for (i = 0; i < priv->num_tx_rings; i++) 157 - enetc_set_bdr_prio(hw, priv->tx_ring[i]->index, 158 - taprio->enable ? 0 : i); 155 + if (err) { 156 + for (i = 0; i < priv->num_tx_rings; i++) { 157 + tx_ring = priv->tx_ring[i]; 158 + tx_ring->prio = taprio->enable ? 0 : i; 159 + enetc_set_bdr_prio(hw, tx_ring->index, tx_ring->prio); 160 + } 161 + } 159 162 160 163 return err; 161 164 }