From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Denis Kirjanov <kda@linux-powerpc.org>
Cc: netdev@vger.kernel.org, jgross@suse.com, wei.liu@kernel.org,
paul@xen.org, ilias.apalodimas@linaro.org, brouer@redhat.com
Subject: Re: [PATCH net-next v13 2/3] xen networking: add basic XDP support for xen-netfront
Date: Fri, 26 Jun 2020 14:09:31 +0200 [thread overview]
Message-ID: <20200626140931.2daea960@carbon> (raw)
In-Reply-To: <1593171639-8136-3-git-send-email-kda@linux-powerpc.org>
On Fri, 26 Jun 2020 14:40:38 +0300
Denis Kirjanov <kda@linux-powerpc.org> wrote:
> diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
> index 482c6c8..91a3b53 100644
> --- a/drivers/net/xen-netfront.c
> +++ b/drivers/net/xen-netfront.c
[...]
> @@ -560,6 +572,67 @@ static u16 xennet_select_queue(struct net_device *dev, struct sk_buff *skb,
> return queue_idx;
> }
>
> +static int xennet_xdp_xmit_one(struct net_device *dev,
> + struct netfront_queue *queue,
> + struct xdp_frame *xdpf)
> +{
> + struct netfront_info *np = netdev_priv(dev);
> + struct netfront_stats *tx_stats = this_cpu_ptr(np->tx_stats);
> + struct xen_netif_tx_request *tx;
> + int notify;
> +
> + tx = xennet_make_first_txreq(queue, NULL,
> + virt_to_page(xdpf->data),
> + offset_in_page(xdpf->data),
> + xdpf->len);
> +
> + RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&queue->tx, notify);
> + if (notify)
> + notify_remote_via_irq(queue->tx_irq);
Is this an expensive operation?
Do you think this can be moved outside the loop?
So that it is called once per bulk.
> + u64_stats_update_begin(&tx_stats->syncp);
> + tx_stats->bytes += xdpf->len;
> + tx_stats->packets++;
> + u64_stats_update_end(&tx_stats->syncp);
> +
> + xennet_tx_buf_gc(queue);
> +
> + return 0;
> +}
> +
> +static int xennet_xdp_xmit(struct net_device *dev, int n,
> + struct xdp_frame **frames, u32 flags)
> +{
> + unsigned int num_queues = dev->real_num_tx_queues;
> + struct netfront_info *np = netdev_priv(dev);
> + struct netfront_queue *queue = NULL;
> + unsigned long irq_flags;
> + int drops = 0;
> + int i, err;
> +
> + if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
> + return -EINVAL;
> +
> + queue = &np->queues[smp_processor_id() % num_queues];
> +
> + spin_lock_irqsave(&queue->tx_lock, irq_flags);
> + for (i = 0; i < n; i++) {
> + struct xdp_frame *xdpf = frames[i];
> +
> + if (!xdpf)
> + continue;
> + err = xennet_xdp_xmit_one(dev, queue, xdpf);
> + if (err) {
> + xdp_return_frame_rx_napi(xdpf);
> + drops++;
> + }
> + }
> + spin_unlock_irqrestore(&queue->tx_lock, irq_flags);
> +
> + 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:[~2020-06-26 12:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-26 11:40 [PATCH net-next v13 0/3] xen networking: add XDP support to xen-netfront Denis Kirjanov
2020-06-26 11:40 ` [PATCH net-next v13 1/3] xen: netif.h: add a new extra type for XDP Denis Kirjanov
2020-06-26 11:40 ` [PATCH net-next v13 2/3] xen networking: add basic XDP support for xen-netfront Denis Kirjanov
2020-06-26 12:09 ` Jesper Dangaard Brouer [this message]
2020-06-29 10:13 ` Denis Kirjanov
2020-06-26 16:05 ` Jakub Kicinski
2020-06-29 10:14 ` Denis Kirjanov
2020-06-27 2:42 ` kernel test robot
2020-06-26 11:40 ` [PATCH net-next v13 3/3] xen networking: add XDP offset adjustment to xen-netback Denis Kirjanov
2020-06-26 11:59 ` Paul Durrant
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=20200626140931.2daea960@carbon \
--to=brouer@redhat.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jgross@suse.com \
--cc=kda@linux-powerpc.org \
--cc=netdev@vger.kernel.org \
--cc=paul@xen.org \
--cc=wei.liu@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).