[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200626140931.2daea960@carbon>
Date: Fri, 26 Jun 2020 14:09:31 +0200
From: Jesper Dangaard Brouer <brouer@...hat.com>
To: Denis Kirjanov <kda@...ux-powerpc.org>
Cc: netdev@...r.kernel.org, jgross@...e.com, wei.liu@...nel.org,
paul@....org, ilias.apalodimas@...aro.org, brouer@...hat.com
Subject: Re: [PATCH net-next v13 2/3] xen networking: add basic XDP support
for xen-netfront
On Fri, 26 Jun 2020 14:40:38 +0300
Denis Kirjanov <kda@...ux-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
Powered by blists - more mailing lists