diff mbox series

[net,2/3] net: enetc: refactor bulk flipping of RX buffers to separate function

Message ID 20250417120005.3288549-3-vladimir.oltean@nxp.com (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series ENETC bug fixes for bpf_xdp_adjust_head() and bpf_xdp_adjust_tail() | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 11 of 11 maintainers
netdev/build_clang success Errors and warnings before: 2 this patch: 2
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 3 this patch: 3
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 28 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2025-04-18--09-00 (tests: 916)

Commit Message

Vladimir Oltean April 17, 2025, noon UTC
This small snippet of code ensures that we do something with the array
of RX software buffer descriptor elements after passing the skb to the
stack. In this case, we see if the other half of the page is reusable,
and if so, we "turn around" the buffers, making them directly usable by
enetc_refill_rx_ring() without going to enetc_new_page().

We will need to perform this kind of buffer flipping from a new code
path, i.e. from XDP_PASS. Currently, enetc_build_skb() does it there
buffer by buffer, but in a subsequent change we will stop using
enetc_build_skb() for XDP_PASS.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/ethernet/freescale/enetc/enetc.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

Comments

Wei Fang April 18, 2025, 7:44 a.m. UTC | #1
> This small snippet of code ensures that we do something with the array
> of RX software buffer descriptor elements after passing the skb to the
> stack. In this case, we see if the other half of the page is reusable,
> and if so, we "turn around" the buffers, making them directly usable by
> enetc_refill_rx_ring() without going to enetc_new_page().
> 
> We will need to perform this kind of buffer flipping from a new code
> path, i.e. from XDP_PASS. Currently, enetc_build_skb() does it there
> buffer by buffer, but in a subsequent change we will stop using
> enetc_build_skb() for XDP_PASS.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>  drivers/net/ethernet/freescale/enetc/enetc.c | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c
> b/drivers/net/ethernet/freescale/enetc/enetc.c
> index 9b333254c73e..74721995cb1f 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc.c
> @@ -1850,6 +1850,16 @@ static void enetc_xdp_drop(struct enetc_bdr *rx_ring,
> int rx_ring_first,
>  	}
>  }
> 
> +static void enetc_bulk_flip_buff(struct enetc_bdr *rx_ring, int rx_ring_first,
> +				 int rx_ring_last)
> +{
> +	while (rx_ring_first != rx_ring_last) {
> +		enetc_flip_rx_buff(rx_ring,
> +				   &rx_ring->rx_swbd[rx_ring_first]);
> +		enetc_bdr_idx_inc(rx_ring, &rx_ring_first);
> +	}
> +}
> +
>  static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring,
>  				   struct napi_struct *napi, int work_limit,
>  				   struct bpf_prog *prog)
> @@ -1965,11 +1975,7 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr
> *rx_ring,
>  				enetc_xdp_drop(rx_ring, orig_i, i);
>  				rx_ring->stats.xdp_redirect_failures++;
>  			} else {
> -				while (orig_i != i) {
> -					enetc_flip_rx_buff(rx_ring,
> -							   &rx_ring->rx_swbd[orig_i]);
> -					enetc_bdr_idx_inc(rx_ring, &orig_i);
> -				}
> +				enetc_bulk_flip_buff(rx_ring, orig_i, i);
>  				xdp_redirect_frm_cnt++;
>  				rx_ring->stats.xdp_redirect++;
>  			}
> --
> 2.34.1

Reviewed-by: Wei Fang <wei.fang@nxp.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index 9b333254c73e..74721995cb1f 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -1850,6 +1850,16 @@  static void enetc_xdp_drop(struct enetc_bdr *rx_ring, int rx_ring_first,
 	}
 }
 
+static void enetc_bulk_flip_buff(struct enetc_bdr *rx_ring, int rx_ring_first,
+				 int rx_ring_last)
+{
+	while (rx_ring_first != rx_ring_last) {
+		enetc_flip_rx_buff(rx_ring,
+				   &rx_ring->rx_swbd[rx_ring_first]);
+		enetc_bdr_idx_inc(rx_ring, &rx_ring_first);
+	}
+}
+
 static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring,
 				   struct napi_struct *napi, int work_limit,
 				   struct bpf_prog *prog)
@@ -1965,11 +1975,7 @@  static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring,
 				enetc_xdp_drop(rx_ring, orig_i, i);
 				rx_ring->stats.xdp_redirect_failures++;
 			} else {
-				while (orig_i != i) {
-					enetc_flip_rx_buff(rx_ring,
-							   &rx_ring->rx_swbd[orig_i]);
-					enetc_bdr_idx_inc(rx_ring, &orig_i);
-				}
+				enetc_bulk_flip_buff(rx_ring, orig_i, i);
 				xdp_redirect_frm_cnt++;
 				rx_ring->stats.xdp_redirect++;
 			}