All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, davem@davemloft.net,
	kuba@kernel.org, ast@kernel.org, daniel@iogearbox.net,
	toke@redhat.com, freysteinn.alfredsson@kau.se,
	lorenzo.bianconi@redhat.com, john.fastabend@gmail.com,
	jasowang@redhat.com, mst@redhat.com,
	thomas.petazzoni@bootlin.com, mw@semihalf.com,
	linux@armlinux.org.uk, ilias.apalodimas@linaro.org,
	netanel@amazon.com, akiyano@amazon.com,
	michael.chan@broadcom.com, madalin.bucur@nxp.com,
	ioana.ciornei@nxp.com, jesse.brandeburg@intel.com,
	anthony.l.nguyen@intel.com, saeedm@nvidia.com,
	grygorii.strashko@ti.com, ecree.xilinx@gmail.com,
	maciej.fijalkowski@intel.com, brouer@redhat.com
Subject: Re: [PATCH v3 bpf-next] bpf: devmap: move drop error path to devmap for XDP_REDIRECT
Date: Mon, 8 Mar 2021 15:02:11 +0100	[thread overview]
Message-ID: <20210308150211.1fffca3f@carbon> (raw)
In-Reply-To: <ed670de24f951cfd77590decf0229a0ad7fd12f6.1615201152.git.lorenzo@kernel.org>

On Mon,  8 Mar 2021 12:06:58 +0100
Lorenzo Bianconi <lorenzo@kernel.org> wrote:

> We want to change the current ndo_xdp_xmit drop semantics because
> it will allow us to implement better queue overflow handling.
> This is working towards the larger goal of a XDP TX queue-hook.
> Move XDP_REDIRECT error path handling from each XDP ethernet driver to
> devmap code. According to the new APIs, the driver running the
> ndo_xdp_xmit pointer, will break tx loop whenever the hw reports a tx
> error and it will just return to devmap caller the number of successfully
> transmitted frames. It will be devmap responsability to free dropped
> frames.
> Move each XDP ndo_xdp_xmit capable driver to the new APIs:
> - veth
> - virtio-net
> - mvneta
> - mvpp2
> - socionext
> - amazon ena
> - bnxt
> - freescale (dpaa2, dpaa)
> - xen-frontend
> - qede
> - ice
> - igb
> - ixgbe
> - i40e
> - mlx5
> - ti (cpsw, cpsw-new)
> - tun
> - sfc
> 
> Acked-by: Edward Cree <ecree.xilinx@gmail.com>
> Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> More details about the new ndo_xdp_xmit design can be found here [0].
> 
> [0] https://github.com/xdp-project/xdp-project/blob/master/areas/core/redesign01_ndo_xdp_xmit.org
> 
> Changes since v2:
> - drop wrong comment in ena driver
> - simplify drop condition using unlikey in the for condition of devmap code
> - rebase on top of bpf-next
> - collect acked-by/reviewed-by
> 
> Changes since v1:
> - rebase on top of bpf-next
> - add driver maintainers in cc
> - add Edward's ack
> ---
>  drivers/net/ethernet/amazon/ena/ena_netdev.c  | 21 ++++++-------
>  drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 20 +++++--------
>  .../net/ethernet/freescale/dpaa/dpaa_eth.c    | 12 ++++----
>  .../net/ethernet/freescale/dpaa2/dpaa2-eth.c  |  2 --
>  drivers/net/ethernet/intel/i40e/i40e_txrx.c   | 15 +++++-----
>  drivers/net/ethernet/intel/ice/ice_txrx.c     | 15 +++++-----
>  drivers/net/ethernet/intel/igb/igb_main.c     | 11 ++++---
>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 11 ++++---
>  drivers/net/ethernet/marvell/mvneta.c         | 13 ++++----
>  .../net/ethernet/marvell/mvpp2/mvpp2_main.c   | 13 ++++----
>  .../net/ethernet/mellanox/mlx5/core/en/xdp.c  | 15 ++++------
>  drivers/net/ethernet/qlogic/qede/qede_fp.c    | 19 +++++-------
>  drivers/net/ethernet/sfc/tx.c                 | 15 +---------
>  drivers/net/ethernet/socionext/netsec.c       | 16 +++++-----
>  drivers/net/ethernet/ti/cpsw.c                | 14 ++++-----
>  drivers/net/ethernet/ti/cpsw_new.c            | 14 ++++-----
>  drivers/net/ethernet/ti/cpsw_priv.c           | 11 +++----
>  drivers/net/tun.c                             | 15 ++++++----
>  drivers/net/veth.c                            | 28 +++++++++--------
>  drivers/net/virtio_net.c                      | 25 ++++++++--------
>  drivers/net/xen-netfront.c                    | 18 +++++------
>  kernel/bpf/devmap.c                           | 30 ++++++++-----------
>  22 files changed, 153 insertions(+), 200 deletions(-)

Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>

Acking core changes to bpf/devmap.c (kept below).
I've only skimmed the driver changes.

> diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
> index 85d9d1b72a33..d6330bbe1209 100644
> --- a/kernel/bpf/devmap.c
> +++ b/kernel/bpf/devmap.c
> @@ -330,7 +330,7 @@ bool dev_map_can_have_prog(struct bpf_map *map)
>  static void bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags)
>  {
>  	struct net_device *dev = bq->dev;
> -	int sent = 0, drops = 0, err = 0;
> +	int sent = 0, err = 0;
>  	int i;
>  
>  	if (unlikely(!bq->count))
> @@ -344,29 +344,23 @@ static void bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags)
>  
>  	sent = dev->netdev_ops->ndo_xdp_xmit(dev, bq->count, bq->q, flags);
>  	if (sent < 0) {
> +		/* If ndo_xdp_xmit fails with an errno, no frames have
> +		 * been xmit'ed.
> +		 */
>  		err = sent;
>  		sent = 0;
> -		goto error;
>  	}
> -	drops = bq->count - sent;
> -out:
> -	bq->count = 0;
>  
> -	trace_xdp_devmap_xmit(bq->dev_rx, dev, sent, drops, err);
> -	bq->dev_rx = NULL;
> -	__list_del_clearprev(&bq->flush_node);
> -	return;
> -error:
> -	/* If ndo_xdp_xmit fails with an errno, no frames have been
> -	 * xmit'ed and it's our responsibility to them free all.
> +	/* If not all frames have been transmitted, it is our
> +	 * responsibility to free them
>  	 */
> -	for (i = 0; i < bq->count; i++) {
> -		struct xdp_frame *xdpf = bq->q[i];
> +	for (i = sent; unlikely(i < bq->count); i++)
> +		xdp_return_frame_rx_napi(bq->q[i]);
>  
> -		xdp_return_frame_rx_napi(xdpf);
> -		drops++;
> -	}
> -	goto out;
> +	trace_xdp_devmap_xmit(bq->dev_rx, dev, sent, bq->count - sent, err);
> +	bq->dev_rx = NULL;
> +	bq->count = 0;
> +	__list_del_clearprev(&bq->flush_node);
>  }
>  
>  /* __dev_flush is called from xdp_do_flush() which _must_ be signaled



-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer


  parent reply	other threads:[~2021-03-08 14:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-08 11:06 [PATCH v3 bpf-next] bpf: devmap: move drop error path to devmap for XDP_REDIRECT Lorenzo Bianconi
2021-03-08 13:46 ` Camelia Alexandra Groza
2021-03-08 14:02 ` Jesper Dangaard Brouer [this message]
2021-03-08 16:15 ` Shay Agroskin
2021-03-18 15:47 ` Daniel Borkmann
2021-03-18 15:50 ` 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=20210308150211.1fffca3f@carbon \
    --to=brouer@redhat.com \
    --cc=akiyano@amazon.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=ecree.xilinx@gmail.com \
    --cc=freysteinn.alfredsson@kau.se \
    --cc=grygorii.strashko@ti.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=ioana.ciornei@nxp.com \
    --cc=jasowang@redhat.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=lorenzo@kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=madalin.bucur@nxp.com \
    --cc=michael.chan@broadcom.com \
    --cc=mst@redhat.com \
    --cc=mw@semihalf.com \
    --cc=netanel@amazon.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=toke@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.