From: Paul Durrant <xadimgnik@gmail.com>
To: "'Denis Kirjanov'" <kda@linux-powerpc.org>, <netdev@vger.kernel.org>
Cc: <brouer@redhat.com>, <jgross@suse.com>, <wei.liu@kernel.org>,
<ilias.apalodimas@linaro.org>
Subject: RE: [PATCH net-next v13 3/3] xen networking: add XDP offset adjustment to xen-netback
Date: Fri, 26 Jun 2020 12:59:00 +0100 [thread overview]
Message-ID: <000a01d64bb1$2e5e87d0$8b1b9770$@xen.org> (raw)
In-Reply-To: <1593171639-8136-4-git-send-email-kda@linux-powerpc.org>
> -----Original Message-----
> From: Denis Kirjanov <kda@linux-powerpc.org>
> Sent: 26 June 2020 12:41
> To: netdev@vger.kernel.org
> Cc: brouer@redhat.com; jgross@suse.com; wei.liu@kernel.org; paul@xen.org; ilias.apalodimas@linaro.org
> Subject: [PATCH net-next v13 3/3] xen networking: add XDP offset adjustment to xen-netback
>
> the patch basically adds the offset adjustment and netfront
> state reading to make XDP work on netfront side.
>
> Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
Reviewed-by: Paul Durrant <paul@xen.org>
> ---
> drivers/net/xen-netback/common.h | 4 ++++
> drivers/net/xen-netback/interface.c | 2 ++
> drivers/net/xen-netback/netback.c | 7 +++++++
> drivers/net/xen-netback/rx.c | 15 ++++++++++++++-
> drivers/net/xen-netback/xenbus.c | 34 ++++++++++++++++++++++++++++++++++
> 5 files changed, 61 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h
> index 05847eb..ae477f7 100644
> --- a/drivers/net/xen-netback/common.h
> +++ b/drivers/net/xen-netback/common.h
> @@ -281,6 +281,9 @@ struct xenvif {
> u8 ipv6_csum:1;
> u8 multicast_control:1;
>
> + /* headroom requested by xen-netfront */
> + u16 xdp_headroom;
> +
> /* Is this interface disabled? True when backend discovers
> * frontend is rogue.
> */
> @@ -395,6 +398,7 @@ static inline pending_ring_idx_t nr_pending_reqs(struct xenvif_queue *queue)
> irqreturn_t xenvif_interrupt(int irq, void *dev_id);
>
> extern bool separate_tx_rx_irq;
> +extern bool provides_xdp_headroom;
>
> extern unsigned int rx_drain_timeout_msecs;
> extern unsigned int rx_stall_timeout_msecs;
> diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
> index 0c8a02a..8af49728 100644
> --- a/drivers/net/xen-netback/interface.c
> +++ b/drivers/net/xen-netback/interface.c
> @@ -483,6 +483,8 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
> vif->queues = NULL;
> vif->num_queues = 0;
>
> + vif->xdp_headroom = 0;
> +
> spin_lock_init(&vif->lock);
> INIT_LIST_HEAD(&vif->fe_mcast_addr);
>
> diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
> index 315dfc6..6dfca72 100644
> --- a/drivers/net/xen-netback/netback.c
> +++ b/drivers/net/xen-netback/netback.c
> @@ -96,6 +96,13 @@
> module_param_named(hash_cache_size, xenvif_hash_cache_size, uint, 0644);
> MODULE_PARM_DESC(hash_cache_size, "Number of flows in the hash cache");
>
> +/* The module parameter tells that we have to put data
> + * for xen-netfront with the XDP_PACKET_HEADROOM offset
> + * needed for XDP processing
> + */
> +bool provides_xdp_headroom = true;
> +module_param(provides_xdp_headroom, bool, 0644);
> +
> static void xenvif_idx_release(struct xenvif_queue *queue, u16 pending_idx,
> u8 status);
>
> diff --git a/drivers/net/xen-netback/rx.c b/drivers/net/xen-netback/rx.c
> index ef58870..ac034f6 100644
> --- a/drivers/net/xen-netback/rx.c
> +++ b/drivers/net/xen-netback/rx.c
> @@ -258,6 +258,19 @@ static void xenvif_rx_next_skb(struct xenvif_queue *queue,
> pkt->extra_count++;
> }
>
> + if (queue->vif->xdp_headroom) {
> + struct xen_netif_extra_info *extra;
> +
> + extra = &pkt->extras[XEN_NETIF_EXTRA_TYPE_XDP - 1];
> +
> + memset(extra, 0, sizeof(struct xen_netif_extra_info));
> + extra->u.xdp.headroom = queue->vif->xdp_headroom;
> + extra->type = XEN_NETIF_EXTRA_TYPE_XDP;
> + extra->flags = 0;
> +
> + pkt->extra_count++;
> + }
> +
> if (skb->sw_hash) {
> struct xen_netif_extra_info *extra;
>
> @@ -356,7 +369,7 @@ static void xenvif_rx_data_slot(struct xenvif_queue *queue,
> struct xen_netif_rx_request *req,
> struct xen_netif_rx_response *rsp)
> {
> - unsigned int offset = 0;
> + unsigned int offset = queue->vif->xdp_headroom;
> unsigned int flags;
>
> do {
> diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
> index 286054b..7e62a6e 100644
> --- a/drivers/net/xen-netback/xenbus.c
> +++ b/drivers/net/xen-netback/xenbus.c
> @@ -393,6 +393,24 @@ static void set_backend_state(struct backend_info *be,
> }
> }
>
> +static void read_xenbus_frontend_xdp(struct backend_info *be,
> + struct xenbus_device *dev)
> +{
> + struct xenvif *vif = be->vif;
> + u16 headroom;
> + int err;
> +
> + err = xenbus_scanf(XBT_NIL, dev->otherend,
> + "xdp-headroom", "%hu", &headroom);
> + if (err != 1) {
> + vif->xdp_headroom = 0;
> + return;
> + }
> + if (headroom > XEN_NETIF_MAX_XDP_HEADROOM)
> + headroom = XEN_NETIF_MAX_XDP_HEADROOM;
> + vif->xdp_headroom = headroom;
> +}
> +
> /**
> * Callback received when the frontend's state changes.
> */
> @@ -417,6 +435,11 @@ static void frontend_changed(struct xenbus_device *dev,
> set_backend_state(be, XenbusStateConnected);
> break;
>
> + case XenbusStateReconfiguring:
> + read_xenbus_frontend_xdp(be, dev);
> + xenbus_switch_state(dev, XenbusStateReconfigured);
> + break;
> +
> case XenbusStateClosing:
> set_backend_state(be, XenbusStateClosing);
> break;
> @@ -947,6 +970,8 @@ static int read_xenbus_vif_flags(struct backend_info *be)
> vif->ipv6_csum = !!xenbus_read_unsigned(dev->otherend,
> "feature-ipv6-csum-offload", 0);
>
> + read_xenbus_frontend_xdp(be, dev);
> +
> return 0;
> }
>
> @@ -1036,6 +1061,15 @@ static int netback_probe(struct xenbus_device *dev,
> goto abort_transaction;
> }
>
> + /* we can adjust a headroom for netfront XDP processing */
> + err = xenbus_printf(xbt, dev->nodename,
> + "feature-xdp-headroom", "%d",
> + provides_xdp_headroom);
> + if (err) {
> + message = "writing feature-xdp-headroom";
> + goto abort_transaction;
> + }
> +
> /* We don't support rx-flip path (except old guests who
> * don't grok this feature flag).
> */
> --
> 1.8.3.1
prev parent reply other threads:[~2020-06-26 11:59 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
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 [this message]
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='000a01d64bb1$2e5e87d0$8b1b9770$@xen.org' \
--to=xadimgnik@gmail.com \
--cc=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).