diff mbox series

[net,4/7] ice: use correct xdp_ring with XDP_TX action

Message ID 20210122235734.447240-5-anthony.l.nguyen@intel.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Intel Wired LAN Driver Updates 2021-01-22 | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net
netdev/subject_prefix success Link
netdev/cc_maintainers warning 9 maintainers not CCed: jeffrey.t.kirsher@intel.com intel-wired-lan@lists.osuosl.org jesse.brandeburg@intel.com daniel@iogearbox.net maciej.fijalkowski@intel.com ast@kernel.org bpf@vger.kernel.org john.fastabend@gmail.com hawk@kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Tony Nguyen Jan. 22, 2021, 11:57 p.m. UTC
From: Piotr Raczynski <piotr.raczynski@intel.com>

XDP queue number for XDP_TX action is used inconsistently
and may result with no packets transmitted. Fix queue number
used by the driver when doing XDP_TX, i.e. use receive queue
number as in ice_finalize_xdp_rx.

Also, using smp_processor_id() is wrong here and won't
work with less queues.

Fixes: efc2214b6047 ("ice: Add support for XDP")
Signed-off-by: Piotr Raczynski <piotr.raczynski@intel.com>
Tested-by: George Kuruvinakunnel <george.kuruvinakunnel@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jakub Kicinski Jan. 24, 2021, 3:52 a.m. UTC | #1
On Fri, 22 Jan 2021 15:57:31 -0800 Tony Nguyen wrote:
> From: Piotr Raczynski <piotr.raczynski@intel.com>
> 
> XDP queue number for XDP_TX action is used inconsistently
> and may result with no packets transmitted. Fix queue number
> used by the driver when doing XDP_TX, i.e. use receive queue
> number as in ice_finalize_xdp_rx.
> 
> Also, using smp_processor_id() is wrong here and won't
> work with less queues.
> 
> Fixes: efc2214b6047 ("ice: Add support for XDP")
> Signed-off-by: Piotr Raczynski <piotr.raczynski@intel.com>
> Tested-by: George Kuruvinakunnel <george.kuruvinakunnel@intel.com>
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
> index b6fa83c619dd..7946a90b2da7 100644
> --- a/drivers/net/ethernet/intel/ice/ice_txrx.c
> +++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
> @@ -546,7 +546,7 @@ ice_run_xdp(struct ice_ring *rx_ring, struct xdp_buff *xdp,
>  	case XDP_PASS:
>  		break;
>  	case XDP_TX:
> -		xdp_ring = rx_ring->vsi->xdp_rings[smp_processor_id()];
> +		xdp_ring = rx_ring->vsi->xdp_rings[rx_ring->q_index];

But then what protects you from one CPU trying to use the tx ring from
XDP_TX and another from ice_xdp_xmit() ?

Also why does this code not check queue_index < vsi->num_xdp_txq
like ice_xdp_xmit() does?

Let me CC your local XDP experts whose tags I'm surprised not to see on
this patch.

>  		result = ice_xmit_xdp_buff(xdp, xdp_ring);
>  		break;
>  	case XDP_REDIRECT:
Tony Nguyen Jan. 26, 2021, 9:33 p.m. UTC | #2
On Sat, 2021-01-23 at 19:52 -0800, Jakub Kicinski wrote:
> On Fri, 22 Jan 2021 15:57:31 -0800 Tony Nguyen wrote:
> > From: Piotr Raczynski <piotr.raczynski@intel.com>
> > 
> > XDP queue number for XDP_TX action is used inconsistently
> > and may result with no packets transmitted. Fix queue number
> > used by the driver when doing XDP_TX, i.e. use receive queue
> > number as in ice_finalize_xdp_rx.
> > 
> > Also, using smp_processor_id() is wrong here and won't
> > work with less queues.
> > 
> > Fixes: efc2214b6047 ("ice: Add support for XDP")
> > Signed-off-by: Piotr Raczynski <piotr.raczynski@intel.com>
> > Tested-by: George Kuruvinakunnel <george.kuruvinakunnel@intel.com>
> > Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
> > ---
> >  drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c
> > b/drivers/net/ethernet/intel/ice/ice_txrx.c
> > index b6fa83c619dd..7946a90b2da7 100644
> > --- a/drivers/net/ethernet/intel/ice/ice_txrx.c
> > +++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
> > @@ -546,7 +546,7 @@ ice_run_xdp(struct ice_ring *rx_ring, struct
> > xdp_buff *xdp,
> >  	case XDP_PASS:
> >  		break;
> >  	case XDP_TX:
> > -		xdp_ring = rx_ring->vsi->xdp_rings[smp_processor_id()];
> > +		xdp_ring = rx_ring->vsi->xdp_rings[rx_ring->q_index];
> 
> But then what protects you from one CPU trying to use the tx ring
> from
> XDP_TX and another from ice_xdp_xmit() ?
> 
> Also why does this code not check queue_index < vsi->num_xdp_txq
> like ice_xdp_xmit() does?

Hi Jakub

I'm still waiting for information from the author. I'm going to drop
this patch from the series and resubmit.

> Let me CC your local XDP experts whose tags I'm surprised not to see
> on
> this patch.

I'll add them to the XDP patches in the future.


Thanks,
Tony
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
index b6fa83c619dd..7946a90b2da7 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx.c
+++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
@@ -546,7 +546,7 @@  ice_run_xdp(struct ice_ring *rx_ring, struct xdp_buff *xdp,
 	case XDP_PASS:
 		break;
 	case XDP_TX:
-		xdp_ring = rx_ring->vsi->xdp_rings[smp_processor_id()];
+		xdp_ring = rx_ring->vsi->xdp_rings[rx_ring->q_index];
 		result = ice_xmit_xdp_buff(xdp, xdp_ring);
 		break;
 	case XDP_REDIRECT: