Skip to content

Commit

Permalink
net: enetc: bring "bool extended" to top-level in enetc_open()
Browse files Browse the repository at this point in the history
Extended RX buffer descriptors are necessary if they carry RX
timestamps, which will be true when PTP timestamping is enabled.

Right now, the rx_ring->ext_en is set from the function that allocates
ring resources (enetc_alloc_rx_resources() -> enetc_alloc_rxbdr()), and
also used later, in enetc_setup_rxbdr(). It is also used in the
enetc_rxbd() and enetc_rxbd_next() fast path helpers.

We want to decouple resource allocation from BD ring setup, but both
procedures depend on BD size (extended or not). Move the "extended"
boolean to enetc_open() and pass it both to the RX allocation procedure
as well as to the RX ring setup procedure. The latter will set
rx_ring->ext_en from now on.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Vladimir Oltean authored and Jakub Kicinski committed Jan 19, 2023
1 parent bbd6043 commit d075db5
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions drivers/net/ethernet/freescale/enetc/enetc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1829,8 +1829,6 @@ static int enetc_alloc_rxbdr(struct enetc_bdr *rxr, bool extended)
return err;
}

rxr->ext_en = extended;

return 0;
}

Expand All @@ -1842,9 +1840,8 @@ static void enetc_free_rxbdr(struct enetc_bdr *rxr)
rxr->rx_swbd = NULL;
}

static int enetc_alloc_rx_resources(struct enetc_ndev_priv *priv)
static int enetc_alloc_rx_resources(struct enetc_ndev_priv *priv, bool extended)
{
bool extended = !!(priv->active_offloads & ENETC_F_RX_TSTAMP);
int i, err;

for (i = 0; i < priv->num_rx_rings; i++) {
Expand Down Expand Up @@ -2022,7 +2019,8 @@ static void enetc_setup_txbdr(struct enetc_hw *hw, struct enetc_bdr *tx_ring)
tx_ring->idr = hw->reg + ENETC_SITXIDR;
}

static void enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring)
static void enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring,
bool extended)
{
int idx = rx_ring->index;
u32 rbmr;
Expand Down Expand Up @@ -2054,6 +2052,7 @@ static void enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring)

rbmr = ENETC_RBMR_EN;

rx_ring->ext_en = extended;
if (rx_ring->ext_en)
rbmr |= ENETC_RBMR_BDS;

Expand All @@ -2075,7 +2074,7 @@ static void enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring)
enetc_rxbdr_wr(hw, idx, ENETC_RBMR, rbmr);
}

static void enetc_setup_bdrs(struct enetc_ndev_priv *priv)
static void enetc_setup_bdrs(struct enetc_ndev_priv *priv, bool extended)
{
struct enetc_hw *hw = &priv->si->hw;
int i;
Expand All @@ -2084,7 +2083,7 @@ static void enetc_setup_bdrs(struct enetc_ndev_priv *priv)
enetc_setup_txbdr(hw, priv->tx_ring[i]);

for (i = 0; i < priv->num_rx_rings; i++)
enetc_setup_rxbdr(hw, priv->rx_ring[i]);
enetc_setup_rxbdr(hw, priv->rx_ring[i], extended);
}

static void enetc_clear_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring)
Expand Down Expand Up @@ -2308,8 +2307,11 @@ int enetc_open(struct net_device *ndev)
{
struct enetc_ndev_priv *priv = netdev_priv(ndev);
int num_stack_tx_queues;
bool extended;
int err;

extended = !!(priv->active_offloads & ENETC_F_RX_TSTAMP);

err = enetc_setup_irqs(priv);
if (err)
return err;
Expand All @@ -2322,7 +2324,7 @@ int enetc_open(struct net_device *ndev)
if (err)
goto err_alloc_tx;

err = enetc_alloc_rx_resources(priv);
err = enetc_alloc_rx_resources(priv, extended);
if (err)
goto err_alloc_rx;

Expand All @@ -2337,7 +2339,7 @@ int enetc_open(struct net_device *ndev)
goto err_set_queues;

enetc_tx_onestep_tstamp_init(priv);
enetc_setup_bdrs(priv);
enetc_setup_bdrs(priv, extended);
enetc_start(ndev);

return 0;
Expand Down

0 comments on commit d075db5

Please sign in to comment.