From: Jason Wang <jasowang@redhat.com>
To: Jesper Dangaard Brouer <brouer@redhat.com>,
Daniel Borkmann <borkmann@iogearbox.net>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Willem de Bruijn <willemb@google.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
netdev@vger.kernel.org, dsahern@gmail.com, gospo@broadcom.com,
bjorn.topel@intel.com, michael.chan@broadcom.com
Subject: Re: [bpf-next V3 PATCH 10/14] tun: setup xdp_rxq_info
Date: Tue, 2 Jan 2018 11:38:19 +0800 [thread overview]
Message-ID: <fe4e28c2-77e9-aafc-8920-66a424cee41d@redhat.com> (raw)
In-Reply-To: <151471810498.30703.8255042101110220378.stgit@firesoul>
On 2017年12月31日 19:01, Jesper Dangaard Brouer wrote:
> Driver hook points for xdp_rxq_info:
> * reg : tun_attach
> * unreg: __tun_detach
>
> I've done some manual testing of this tun driver, but I would
> appriciate good review and someone else running their use-case tests,
> as I'm not 100% sure I understand the tfile->detached semantics.
>
> V2: Removed the skb_array_cleanup() call from V1 by request from Jason Wang.
>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Willem de Bruijn <willemb@google.com>
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
> ---
> drivers/net/tun.c | 24 +++++++++++++++++++++++-
> 1 file changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index e367d6310353..e7c5f4b2a9a6 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -180,6 +180,7 @@ struct tun_file {
> struct list_head next;
> struct tun_struct *detached;
> struct skb_array tx_array;
> + struct xdp_rxq_info xdp_rxq;
> };
>
> struct tun_flow_entry {
> @@ -687,8 +688,10 @@ static void __tun_detach(struct tun_file *tfile, bool clean)
> tun->dev->reg_state == NETREG_REGISTERED)
> unregister_netdevice(tun->dev);
> }
> - if (tun)
> + if (tun) {
> skb_array_cleanup(&tfile->tx_array);
> + xdp_rxq_info_unreg(&tfile->xdp_rxq);
> + }
> sock_put(&tfile->sk);
> }
> }
> @@ -728,11 +731,13 @@ static void tun_detach_all(struct net_device *dev)
> tun_napi_del(tun, tfile);
> /* Drop read queue */
> tun_queue_purge(tfile);
> + xdp_rxq_info_unreg(&tfile->xdp_rxq);
> sock_put(&tfile->sk);
> }
> list_for_each_entry_safe(tfile, tmp, &tun->disabled, next) {
> tun_enable_queue(tfile);
> tun_queue_purge(tfile);
> + xdp_rxq_info_unreg(&tfile->xdp_rxq);
> sock_put(&tfile->sk);
> }
> BUG_ON(tun->numdisabled != 0);
> @@ -784,6 +789,22 @@ static int tun_attach(struct tun_struct *tun, struct file *file,
>
> tfile->queue_index = tun->numqueues;
> tfile->socket.sk->sk_shutdown &= ~RCV_SHUTDOWN;
> +
> + if (tfile->detached) {
> + /* Re-attach detached tfile, updating XDP queue_index */
> + WARN_ON(!xdp_rxq_info_is_reg(&tfile->xdp_rxq));
> +
> + if (tfile->xdp_rxq.queue_index != tfile->queue_index)
> + tfile->xdp_rxq.queue_index = tfile->queue_index;
> + } else {
> + /* Setup XDP RX-queue info, for new tfile getting attached */
> + err = xdp_rxq_info_reg(&tfile->xdp_rxq,
> + tun->dev, tfile->queue_index);
> + if (err < 0)
> + goto out;
> + err = 0;
> + }
> +
> rcu_assign_pointer(tfile->tun, tun);
> rcu_assign_pointer(tun->tfiles[tun->numqueues], tfile);
> tun->numqueues++;
> @@ -1508,6 +1529,7 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,
> xdp.data = buf + pad;
> xdp_set_data_meta_invalid(&xdp);
> xdp.data_end = xdp.data + len;
> + xdp.rxq = &tfile->xdp_rxq;
> orig_data = xdp.data;
> act = bpf_prog_run_xdp(xdp_prog, &xdp);
>
>
Reviewed-by: Jason Wang <jasowang@redhat.com>
next prev parent reply other threads:[~2018-01-02 3:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-31 11:00 [bpf-next V3 PATCH 00/14] xdp: new XDP rx-queue info concept Jesper Dangaard Brouer
2017-12-31 11:00 ` [bpf-next V3 PATCH 01/14] xdp: base API for " Jesper Dangaard Brouer
2017-12-31 11:01 ` [bpf-next V3 PATCH 02/14] xdp/mlx5: setup xdp_rxq_info Jesper Dangaard Brouer
2017-12-31 11:01 ` [bpf-next V3 PATCH 03/14] i40e: " Jesper Dangaard Brouer
2017-12-31 12:33 ` [Intel-wired-lan] " Paul Menzel
2017-12-31 11:01 ` [bpf-next V3 PATCH 04/14] ixgbe: " Jesper Dangaard Brouer
2017-12-31 11:01 ` [bpf-next V3 PATCH 05/14] xdp/qede: setup xdp_rxq_info and intro xdp_rxq_info_is_reg Jesper Dangaard Brouer
2017-12-31 11:01 ` [bpf-next V3 PATCH 06/14] mlx4: setup xdp_rxq_info Jesper Dangaard Brouer
2017-12-31 11:01 ` [bpf-next V3 PATCH 07/14] bnxt_en: " Jesper Dangaard Brouer
2017-12-31 11:01 ` [bpf-next V3 PATCH 08/14] nfp: " Jesper Dangaard Brouer
2017-12-31 11:01 ` [bpf-next V3 PATCH 09/14] thunderx: " Jesper Dangaard Brouer
2017-12-31 11:01 ` [bpf-next V3 PATCH 10/14] tun: " Jesper Dangaard Brouer
2018-01-02 3:38 ` Jason Wang [this message]
2017-12-31 11:01 ` [bpf-next V3 PATCH 11/14] virtio_net: " Jesper Dangaard Brouer
2018-01-02 3:38 ` Jason Wang
2017-12-31 11:01 ` [bpf-next V3 PATCH 12/14] xdp: generic XDP handling of xdp_rxq_info Jesper Dangaard Brouer
2017-12-31 11:02 ` [bpf-next V3 PATCH 13/14] bpf: finally expose xdp_rxq_info to XDP bpf-programs Jesper Dangaard Brouer
2018-01-02 17:47 ` David Ahern
2017-12-31 11:02 ` [bpf-next V3 PATCH 14/14] samples/bpf: program demonstrating access to xdp_rxq_info Jesper Dangaard Brouer
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=fe4e28c2-77e9-aafc-8920-66a424cee41d@redhat.com \
--to=jasowang@redhat.com \
--cc=alexei.starovoitov@gmail.com \
--cc=bjorn.topel@intel.com \
--cc=borkmann@iogearbox.net \
--cc=brouer@redhat.com \
--cc=dsahern@gmail.com \
--cc=gospo@broadcom.com \
--cc=michael.chan@broadcom.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=willemb@google.com \
/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