Re: [PATCH net] net: enetc: preserve TX ring priority across reconfiguration

Alexander Lobakin
2022-11-23T15:53:05Z

From: Vladimir Oltean <vladimir.oltean@nxp.com>
Date: Tue, 22 Nov 2022 15:09:36 +0200

> 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>
> ---
> drivers/net/ethernet/freescale/enetc/enetc.c | 8 ++++---
> drivers/net/ethernet/freescale/enetc/enetc.h | 1 +
> .../net/ethernet/freescale/enetc/enetc_qos.c | 21 ++++++++++++-------
> 3 files changed, 19 insertions(+), 11 deletions(-)

[...]

> 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;

Side note: is that `taprio ? 0 : i` correct? It's an error path
IIUC, why not just unconditional 0?
I guess it is, so

Reviewed-by: Alexander Lobakin <alexandr.lobakin@intel.com>

> + enetc_set_bdr_prio(hw, tx_ring->index, tx_ring->prio);
> + }
> + }
>
> return err;
> }
> --
> 2.34.1

Thanks,
Olek