From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Claudiu Manoil <claudiu.manoil@nxp.com>
Subject: [PATCH net-next 06/12] net: enetc: bring "bool extended" to top-level in enetc_open()
Date: Wed, 18 Jan 2023 01:02:28 +0200 [thread overview]
Message-ID: <20230117230234.2950873-7-vladimir.oltean@nxp.com> (raw)
In-Reply-To: <20230117230234.2950873-1-vladimir.oltean@nxp.com>
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>
---
drivers/net/ethernet/freescale/enetc/enetc.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index 94580496ef64..67471c8ea447 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -1829,8 +1829,6 @@ static int enetc_alloc_rxbdr(struct enetc_bdr *rxr, bool extended)
return err;
}
- rxr->ext_en = extended;
-
return 0;
}
@@ -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++) {
@@ -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;
@@ -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;
@@ -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;
@@ -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)
@@ -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;
@@ -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;
@@ -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;
--
2.34.1
next prev parent reply other threads:[~2023-01-17 23:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-17 23:02 [PATCH net-next 00/12] ENETC BD ring cleanup Vladimir Oltean
2023-01-17 23:02 ` [PATCH net-next 01/12] net: enetc: set next_to_clean/next_to_use just from enetc_setup_txbdr() Vladimir Oltean
2023-01-17 23:02 ` [PATCH net-next 02/12] net: enetc: set up RX ring indices from enetc_setup_rxbdr() Vladimir Oltean
2023-01-17 23:02 ` [PATCH net-next 03/12] net: enetc: create enetc_dma_free_bdr() Vladimir Oltean
2023-01-17 23:02 ` [PATCH net-next 04/12] net: enetc: rx_swbd and tx_swbd are never NULL in enetc_free_rxtx_rings() Vladimir Oltean
2023-01-17 23:02 ` [PATCH net-next 05/12] net: enetc: drop redundant enetc_free_tx_frame() call from enetc_free_txbdr() Vladimir Oltean
2023-01-17 23:02 ` Vladimir Oltean [this message]
2023-01-17 23:02 ` [PATCH net-next 07/12] net: enetc: split ring resource allocation from assignment Vladimir Oltean
2023-01-17 23:02 ` [PATCH net-next 08/12] net: enetc: move phylink_start/stop out of enetc_start/stop Vladimir Oltean
2023-01-17 23:02 ` [PATCH net-next 09/12] net: enetc: implement ring reconfiguration procedure for PTP RX timestamping Vladimir Oltean
2023-01-18 10:51 ` Vladimir Oltean
2023-01-17 23:02 ` [PATCH net-next 10/12] net: enetc: rename "xdp" and "dev" in enetc_setup_bpf() Vladimir Oltean
2023-01-17 23:02 ` [PATCH net-next 11/12] net: enetc: set up XDP program under enetc_reconfigure() Vladimir Oltean
2023-01-17 23:02 ` [PATCH net-next 12/12] net: enetc: prioritize ability to go down over packet processing Vladimir Oltean
2023-01-19 5:10 ` [PATCH net-next 00/12] ENETC BD ring cleanup patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230117230234.2950873-7-vladimir.oltean@nxp.com \
--to=vladimir.oltean@nxp.com \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox