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 v10 2/3] xen networking: add basic XDP support for xen-netfront
Date: Mon, 22 Jun 2020 11:58:04 +0200 [thread overview]
Message-ID: <20200622115804.3c63aba9@carbon> (raw)
In-Reply-To: <1592817672-2053-3-git-send-email-kda@linux-powerpc.org>
On Mon, 22 Jun 2020 12:21:11 +0300 Denis Kirjanov <kda@linux-powerpc.org> wrote:
> diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
> index 482c6c8..1b9f49e 100644
> --- a/drivers/net/xen-netfront.c
> +++ b/drivers/net/xen-netfront.c
[...]
> @@ -560,6 +572,65 @@ 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 xdp_frame *xdpf)
> +{
> + struct netfront_info *np = netdev_priv(dev);
> + struct netfront_stats *tx_stats = this_cpu_ptr(np->tx_stats);
> + unsigned int num_queues = dev->real_num_tx_queues;
> + struct netfront_queue *queue = NULL;
> + struct xen_netif_tx_request *tx;
> + unsigned long flags;
> + int notify;
> +
> + queue = &np->queues[smp_processor_id() % num_queues];
> +
> + spin_lock_irqsave(&queue->tx_lock, flags);
Why are you taking a lock per packet (xdp_frame)?
> +
> + 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);
> +
> + 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);
> +
> + spin_unlock_irqrestore(&queue->tx_lock, flags);
Is the irqsave/irqrestore variant really needed here?
> + return 0;
> +}
> +
> +static int xennet_xdp_xmit(struct net_device *dev, int n,
> + struct xdp_frame **frames, u32 flags)
> +{
> + int drops = 0;
> + int i, err;
> +
> + if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
> + return -EINVAL;
> +
> + for (i = 0; i < n; i++) {
> + struct xdp_frame *xdpf = frames[i];
> +
> + if (!xdpf)
> + continue;
> + err = xennet_xdp_xmit_one(dev, xdpf);
> + if (err) {
> + xdp_return_frame_rx_napi(xdpf);
> + drops++;
> + }
> + }
> +
> + 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-22 9:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-22 9:21 [PATCH net-next v10 0/3] xen networking: add XDP support to xen-netfront Denis Kirjanov
2020-06-22 9:21 ` [PATCH net-next v10 1/3] xen: netif.h: add a new extra type for XDP Denis Kirjanov
2020-06-22 9:21 ` [PATCH net-next v10 2/3] xen networking: add basic XDP support for xen-netfront Denis Kirjanov
2020-06-22 9:58 ` Jesper Dangaard Brouer [this message]
2020-06-22 12:45 ` Denis Kirjanov
2020-06-22 13:28 ` Jesper Dangaard Brouer
2020-06-22 14:27 ` Denis Kirjanov
2020-06-22 12:34 ` kernel test robot
2020-06-22 9:21 ` [PATCH net-next v10 3/3] xen networking: add XDP offset adjustment to xen-netback Denis Kirjanov
2020-06-22 10:10 ` Paul Durrant
2020-06-22 12:50 ` Denis Kirjanov
2020-06-22 14:56 ` 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=20200622115804.3c63aba9@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).