]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
net: enetc: preserve TX ring priority across reconfiguration
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 22 Nov 2022 13:09:36 +0000 (15:09 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 14 Dec 2022 13:00:28 +0000 (14:00 +0100)
[ Upstream commit 290b5fe096e7dd0aad730d1af4f7f2d9fea43e11 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 26c31e7c73d4aa6c2d88d22ff600d4fd8da5f4dc)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
drivers/net/ethernet/freescale/enetc/enetc.c
drivers/net/ethernet/freescale/enetc/enetc.h
drivers/net/ethernet/freescale/enetc/enetc_qos.c

index 0ced688bf9ba4c66aee99a94fccb0edb222b07e0..222a250fba84a9ccbde29d2db1caa9506380b81f 100644 (file)
@@ -1768,7 +1768,7 @@ static void enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
        /* enable Tx ints by setting pkt thr to 1 */
        enetc_txbdr_wr(hw, idx, ENETC_TBICR0, ENETC_TBICR0_ICEN | 0x1);
 
-       tbmr = ENETC_TBMR_EN;
+       tbmr = ENETC_TBMR_EN | ENETC_TBMR_SET_PRIO(tx_ring->prio);
        if (tx_ring->ndev->features & NETIF_F_HW_VLAN_CTAG_TX)
                tbmr |= ENETC_TBMR_VIH;
 
@@ -2171,7 +2171,8 @@ int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data)
                /* Reset all ring priorities to 0 */
                for (i = 0; i < priv->num_tx_rings; i++) {
                        tx_ring = priv->tx_ring[i];
-                       enetc_set_bdr_prio(hw, tx_ring->index, 0);
+                       tx_ring->prio = 0;
+                       enetc_set_bdr_prio(hw, tx_ring->index, tx_ring->prio);
                }
 
                return 0;
@@ -2190,7 +2191,8 @@ int enetc_setup_tc_mqprio(struct net_device *ndev, void *type_data)
         */
        for (i = 0; i < num_tc; i++) {
                tx_ring = priv->tx_ring[i];
-               enetc_set_bdr_prio(hw, tx_ring->index, i);
+               tx_ring->prio = i;
+               enetc_set_bdr_prio(hw, tx_ring->index, tx_ring->prio);
        }
 
        /* Reset the number of netdev queues based on the TC count */
index 7ec807bd982808fbf7775947749a636f597525f3..a3b936375c56129e138ef920e8f68406abbabc17 100644 (file)
@@ -91,6 +91,7 @@ struct enetc_bdr {
                void __iomem *rcir;
        };
        u16 index;
+       u16 prio;
        int bd_count; /* # of BDs */
        int next_to_use;
        int next_to_clean;
index 6baf2619a51e453841356566b32159055d291933..ba51fb381f0cbe0fef9b69727c0ee23f96e8019e 100644 (file)
@@ -145,6 +145,7 @@ int enetc_setup_tc_taprio(struct net_device *ndev, void *type_data)
        struct tc_taprio_qopt_offload *taprio = type_data;
        struct enetc_ndev_priv *priv = netdev_priv(ndev);
        struct enetc_hw *hw = &priv->si->hw;
+       struct enetc_bdr *tx_ring;
        int err;
        int i;
 
@@ -153,16 +154,20 @@ int enetc_setup_tc_taprio(struct net_device *ndev, void *type_data)
                if (priv->tx_ring[i]->tsd_enable)
                        return -EBUSY;
 
-       for (i = 0; i < priv->num_tx_rings; i++)
-               enetc_set_bdr_prio(hw, priv->tx_ring[i]->index,
-                                  taprio->enable ? i : 0);
+       for (i = 0; i < priv->num_tx_rings; i++) {
+               tx_ring = priv->tx_ring[i];
+               tx_ring->prio = taprio->enable ? i : 0;
+               enetc_set_bdr_prio(hw, tx_ring->index, tx_ring->prio);
+       }
 
        err = enetc_setup_taprio(ndev, taprio);
-
-       if (err)
-               for (i = 0; i < priv->num_tx_rings; i++)
-                       enetc_set_bdr_prio(hw, priv->tx_ring[i]->index,
-                                          taprio->enable ? 0 : i);
+       if (err) {
+               for (i = 0; i < priv->num_tx_rings; i++) {
+                       tx_ring = priv->tx_ring[i];
+                       tx_ring->prio = taprio->enable ? 0 : i;
+                       enetc_set_bdr_prio(hw, tx_ring->index, tx_ring->prio);
+               }
+       }
 
        return err;
 }