From: Jesper Dangaard Brouer <brouer@redhat.com>
To: John Fastabend <john.fastabend@gmail.com>
Cc: netdev@vger.kernel.org,
"Daniel Borkmann" <borkmann@iogearbox.net>,
"Alexei Starovoitov" <alexei.starovoitov@gmail.com>,
"Christoph Hellwig" <hch@infradead.org>,
BjörnTöpel <bjorn.topel@intel.com>,
"Magnus Karlsson" <magnus.karlsson@intel.com>,
makita.toshiaki@lab.ntt.co.jp, brouer@redhat.com
Subject: Re: [bpf-next V4 PATCH 6/8] xdp: change ndo_xdp_xmit API to support bulking
Date: Wed, 23 May 2018 17:27:15 +0200 [thread overview]
Message-ID: <20180523172715.2d16d2c9@redhat.com> (raw)
In-Reply-To: <c9f0c7b0-26a8-815d-71bf-4e5ccdaa74aa@gmail.com>
On Wed, 23 May 2018 07:42:14 -0700
John Fastabend <john.fastabend@gmail.com> wrote:
> On 05/18/2018 06:35 AM, Jesper Dangaard Brouer wrote:
> [...]
>
> Couple suggestions for some optimizations/improvements but otherwise
> looks good to me.
>
> Thanks,
> John
>
[...]
> > diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
> > index 5efa68de935b..9b698c5acd05 100644
> > --- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
> > +++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
> > @@ -3664,14 +3664,19 @@ netdev_tx_t i40e_lan_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
> > * @dev: netdev
> > * @xdp: XDP buffer
> > *
> > - * Returns Zero if sent, else an error code
> > + * Returns number of frames successfully sent. Frames that fail are
> > + * free'ed via XDP return API.
> > + *
> > + * For error cases, a negative errno code is returned and no-frames
> > + * are transmitted (caller must handle freeing frames).
> > **/
> > -int i40e_xdp_xmit(struct net_device *dev, struct xdp_frame *xdpf)
> > +int i40e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames)
> > {
> > struct i40e_netdev_priv *np = netdev_priv(dev);
> > unsigned int queue_index = smp_processor_id();
> > struct i40e_vsi *vsi = np->vsi;
> > - int err;
> > + int drops = 0;
> > + int i;
> >
> > if (test_bit(__I40E_VSI_DOWN, vsi->state))
> > return -ENETDOWN;
> > @@ -3679,11 +3684,18 @@ int i40e_xdp_xmit(struct net_device *dev, struct xdp_frame *xdpf)
> > if (!i40e_enabled_xdp_vsi(vsi) || queue_index >= vsi->num_queue_pairs)
> > return -ENXIO;
> >
> > - err = i40e_xmit_xdp_ring(xdpf, vsi->xdp_rings[queue_index]);
> > - if (err != I40E_XDP_TX)
> > - return -ENOSPC;
> > + for (i = 0; i < n; i++) {
> > + struct xdp_frame *xdpf = frames[i];
> > + int err;
> >
> > - return 0;
> > + err = i40e_xmit_xdp_ring(xdpf, vsi->xdp_rings[queue_index]);
> > + if (err != I40E_XDP_TX) {
> > + xdp_return_frame_rx_napi(xdpf);
> > + drops++;
> > + }
> > + }
> > +
>
> Perhaps not needed in this series, but I wonder how useful it is to hit
> the ring with the remaining frames after the first error. The error will
> typically be due to the TX queue being full. In this case it might make
> more sense to just drop the entire train of frames vs beating the up a
> full queue.
Yes, that would be an optimization, but I think we can do that in
another series.
This patcheset actually open up for a lot of followup optimizations.
I imagine/plan to optimize i40e_xmit_xdp_ring() further, e.g. by
implementing a bulking variant (e.g check I40E_DESC_UNUSED+update
xdp_ring->next_to_use once, map several DMA pages in one call, only
call smp_wmb() once per bulk, etc.),
> > + return n - drops;
> > }
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
next prev parent reply other threads:[~2018-05-23 15:27 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-18 13:34 [bpf-next V4 PATCH 0/8] xdp: introduce bulking for ndo_xdp_xmit API Jesper Dangaard Brouer
2018-05-18 13:34 ` [bpf-next V4 PATCH 1/8] bpf: devmap introduce dev_map_enqueue Jesper Dangaard Brouer
2018-05-23 9:34 ` Daniel Borkmann
2018-05-23 11:12 ` Jesper Dangaard Brouer
2018-05-18 13:34 ` [bpf-next V4 PATCH 2/8] bpf: devmap prepare xdp frames for bulking Jesper Dangaard Brouer
2018-05-23 9:54 ` Daniel Borkmann
2018-05-23 10:29 ` Jesper Dangaard Brouer
2018-05-23 10:45 ` Daniel Borkmann
2018-05-23 10:38 ` Jesper Dangaard Brouer
2018-05-18 13:34 ` [bpf-next V4 PATCH 3/8] xdp: add tracepoint for devmap like cpumap have Jesper Dangaard Brouer
2018-05-23 14:24 ` John Fastabend
2018-05-23 15:04 ` Jesper Dangaard Brouer
2018-05-18 13:34 ` [bpf-next V4 PATCH 4/8] samples/bpf: xdp_monitor use tracepoint xdp:xdp_devmap_xmit Jesper Dangaard Brouer
2018-05-18 13:34 ` [bpf-next V4 PATCH 5/8] xdp: introduce xdp_return_frame_rx_napi Jesper Dangaard Brouer
2018-05-18 20:46 ` Jesper Dangaard Brouer
2018-05-18 13:35 ` [bpf-next V4 PATCH 6/8] xdp: change ndo_xdp_xmit API to support bulking Jesper Dangaard Brouer
2018-05-23 14:42 ` John Fastabend
2018-05-23 15:27 ` Jesper Dangaard Brouer [this message]
2018-05-18 13:35 ` [bpf-next V4 PATCH 7/8] xdp/trace: extend tracepoint in devmap with an err Jesper Dangaard Brouer
2018-05-18 20:49 ` Jesper Dangaard Brouer
2018-05-18 13:35 ` [bpf-next V4 PATCH 8/8] samples/bpf: xdp_monitor use err code from tracepoint xdp:xdp_devmap_xmit Jesper Dangaard Brouer
2018-05-18 20:48 ` Jesper Dangaard Brouer
2018-05-23 9:24 ` [bpf-next V4 PATCH 0/8] xdp: introduce bulking for ndo_xdp_xmit API Daniel Borkmann
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=20180523172715.2d16d2c9@redhat.com \
--to=brouer@redhat.com \
--cc=alexei.starovoitov@gmail.com \
--cc=bjorn.topel@intel.com \
--cc=borkmann@iogearbox.net \
--cc=hch@infradead.org \
--cc=john.fastabend@gmail.com \
--cc=magnus.karlsson@intel.com \
--cc=makita.toshiaki@lab.ntt.co.jp \
--cc=netdev@vger.kernel.org \
/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.