Skip to content

Commit d075db5

Browse files
vladimirolteankuba-moo
authored andcommitted
net: enetc: bring "bool extended" to top-level in enetc_open()
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 <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent bbd6043 commit d075db5

File tree

1 file changed

+11
-9
lines changed
  • drivers/net/ethernet/freescale/enetc

1 file changed

+11
-9
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,8 +1829,6 @@ static int enetc_alloc_rxbdr(struct enetc_bdr *rxr, bool extended)
18291829
return err;
18301830
}
18311831

1832-
rxr->ext_en = extended;
1833-
18341832
return 0;
18351833
}
18361834

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

1845-
static int enetc_alloc_rx_resources(struct enetc_ndev_priv *priv)
1843+
static int enetc_alloc_rx_resources(struct enetc_ndev_priv *priv, bool extended)
18461844
{
1847-
bool extended = !!(priv->active_offloads & ENETC_F_RX_TSTAMP);
18481845
int i, err;
18491846

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

2025-
static void enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring)
2022+
static void enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring,
2023+
bool extended)
20262024
{
20272025
int idx = rx_ring->index;
20282026
u32 rbmr;
@@ -2054,6 +2052,7 @@ static void enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring)
20542052

20552053
rbmr = ENETC_RBMR_EN;
20562054

2055+
rx_ring->ext_en = extended;
20572056
if (rx_ring->ext_en)
20582057
rbmr |= ENETC_RBMR_BDS;
20592058

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

2078-
static void enetc_setup_bdrs(struct enetc_ndev_priv *priv)
2077+
static void enetc_setup_bdrs(struct enetc_ndev_priv *priv, bool extended)
20792078
{
20802079
struct enetc_hw *hw = &priv->si->hw;
20812080
int i;
@@ -2084,7 +2083,7 @@ static void enetc_setup_bdrs(struct enetc_ndev_priv *priv)
20842083
enetc_setup_txbdr(hw, priv->tx_ring[i]);
20852084

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

20902089
static void enetc_clear_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring)
@@ -2308,8 +2307,11 @@ int enetc_open(struct net_device *ndev)
23082307
{
23092308
struct enetc_ndev_priv *priv = netdev_priv(ndev);
23102309
int num_stack_tx_queues;
2310+
bool extended;
23112311
int err;
23122312

2313+
extended = !!(priv->active_offloads & ENETC_F_RX_TSTAMP);
2314+
23132315
err = enetc_setup_irqs(priv);
23142316
if (err)
23152317
return err;
@@ -2322,7 +2324,7 @@ int enetc_open(struct net_device *ndev)
23222324
if (err)
23232325
goto err_alloc_tx;
23242326

2325-
err = enetc_alloc_rx_resources(priv);
2327+
err = enetc_alloc_rx_resources(priv, extended);
23262328
if (err)
23272329
goto err_alloc_rx;
23282330

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

23392341
enetc_tx_onestep_tstamp_init(priv);
2340-
enetc_setup_bdrs(priv);
2342+
enetc_setup_bdrs(priv, extended);
23412343
enetc_start(ndev);
23422344

23432345
return 0;

0 commit comments

Comments
 (0)