From: Brenden Blanco <bblanco@plumgrid.com>
To: Jesper Dangaard Brouer <brouer@redhat.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org, tom@herbertland.com,
alexei.starovoitov@gmail.com, ogerlitz@mellanox.com,
daniel@iogearbox.net, eric.dumazet@gmail.com,
ecree@solarflare.com, john.fastabend@gmail.com, tgraf@suug.ch,
johannes@sipsolutions.net, eranlinuxmellanox@gmail.com,
lorenzo@google.com
Subject: Re: [RFC PATCH v2 2/5] net: add ndo to set bpf prog in adapter rx
Date: Fri, 8 Apr 2016 09:39:55 -0700 [thread overview]
Message-ID: <20160408163954.GA28353@gmail.com> (raw)
In-Reply-To: <20160408113858.4d39b274@redhat.com>
On Fri, Apr 08, 2016 at 11:38:58AM +0200, Jesper Dangaard Brouer wrote:
>
> On Thu, 7 Apr 2016 21:48:47 -0700 Brenden Blanco <bblanco@plumgrid.com> wrote:
>
> > Add two new set/get netdev ops for drivers implementing the
> > BPF_PROG_TYPE_PHYS_DEV filter.
> >
> > Signed-off-by: Brenden Blanco <bblanco@plumgrid.com>
> [...]
> >
> > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> > index cb4e508..3acf732 100644
> > --- a/include/linux/netdevice.h
> > +++ b/include/linux/netdevice.h
> [...]
> > @@ -1102,6 +1103,14 @@ struct tc_to_netdev {
> > * appropriate rx headroom value allows avoiding skb head copy on
> > * forward. Setting a negative value resets the rx headroom to the
> > * default value.
> > + * int (*ndo_bpf_set)(struct net_device *dev, struct bpf_prog *prog);
> > + * This function is used to set or clear a bpf program used in the
> > + * earliest stages of packet rx. The prog will have been loaded as
> > + * BPF_PROG_TYPE_PHYS_DEV. The callee is responsible for calling
> > + * bpf_prog_put on any old progs that are stored, but not on the passed
> > + * in prog.
> > + * bool (*ndo_bpf_get)(struct net_device *dev);
> > + * This function is used to check if a bpf program is set on the device.
> > *
>
> This interface for the entire device, right. I can imagine that users
> want to attach a eBPF program per RX queue. Can we adapt the interface
> to support this? (could default to adding it all queues)
>
Currently yes, for the entire device. I don't see rx queue exposed in
common setlink APIs. Wouldn't this be available only through ethtool,
generally? That would be a significant change to the api, but not a lot
of code. I would defer to others on which is cleaner. An alternative
could be to always run the program, but expose the queue number in
struct bpf_phys_dev_md. That is not as flexible since the program is
still shared, but maybe still useful.
>
> I'm also wondering if we should add a "flags" parameter. Or maybe we
> can extend 'struct bpf_prog' with I have in mind.
>
> When the eBPF program is attached to a RX queue, I want to know if the
> program want to modify packet-data, up-front.
>
> The problem is that most drivers use dma_sync, which means that data is
> considered 'read-only' (the "considered" part depend on DMA engine, and
> we might find a DMA loop-hole for some configs).
> If the program want to write, the driver have the option of
> reconfiguring the driver routine to use dma_unmap, before handing over
> the page. Or driver can also choose to realloc the specific RX ring
> queue pages as single pages (using dma_map/unmap consistently).
> This also allow us to give a return code indicating given driver does
> not support writable packet-pages (rejecting program).
When write-mode is enabled for this prog type, we'll add the flag. I
don't want to add unused flags prematurely. When we add such support, it
should be available in the bpf_prog struct, similar to the cb_access or
dst_needed bool fields.
>
> --
> Best regards,
> Jesper Dangaard Brouer
> MSc.CS, Principal Kernel Engineer at Red Hat
> Author of http://www.iptv-analyzer.org
> LinkedIn: http://www.linkedin.com/in/brouer
next prev parent reply other threads:[~2016-04-08 16:39 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-08 4:48 [RFC PATCH v2 1/5] bpf: add PHYS_DEV prog type for early driver filter Brenden Blanco
2016-04-08 4:48 ` [RFC PATCH v2 2/5] net: add ndo to set bpf prog in adapter rx Brenden Blanco
2016-04-08 9:38 ` Jesper Dangaard Brouer
2016-04-08 16:39 ` Brenden Blanco [this message]
2016-04-08 4:48 ` [RFC PATCH v2 3/5] rtnl: add option for setting link bpf prog Brenden Blanco
2016-04-08 4:48 ` [RFC PATCH v2 4/5] mlx4: add support for fast rx drop bpf program Brenden Blanco
2016-04-08 11:41 ` Jesper Dangaard Brouer
2016-04-08 17:04 ` Brenden Blanco
2016-04-08 4:48 ` [RFC PATCH v2 5/5] Add sample for adding simple drop program to link Brenden Blanco
2016-04-09 14:48 ` Jamal Hadi Salim
2016-04-09 16:43 ` Brenden Blanco
2016-04-09 17:27 ` Jamal Hadi Salim
2016-04-10 18:38 ` Brenden Blanco
2016-04-13 10:40 ` Jamal Hadi Salim
2016-04-08 10:36 ` [RFC PATCH v2 1/5] bpf: add PHYS_DEV prog type for early driver filter Jesper Dangaard Brouer
2016-04-08 11:09 ` Daniel Borkmann
2016-04-08 16:48 ` Brenden Blanco
2016-04-08 12:33 ` Jesper Dangaard Brouer
2016-04-08 17:02 ` Brenden Blanco
2016-04-08 19:05 ` Jesper Dangaard Brouer
2016-04-08 17:26 ` Alexei Starovoitov
2016-04-08 20:08 ` Jesper Dangaard Brouer
2016-04-08 21:34 ` Alexei Starovoitov
2016-04-09 11:29 ` Tom Herbert
2016-04-09 15:29 ` Jamal Hadi Salim
2016-04-09 17:26 ` Alexei Starovoitov
2016-04-10 7:55 ` Thomas Graf
2016-04-10 16:53 ` Tom Herbert
2016-04-10 18:09 ` Jamal Hadi Salim
2016-04-10 13:07 ` Jamal Hadi Salim
2016-04-09 11:17 ` Tom Herbert
2016-04-09 12:27 ` Jesper Dangaard Brouer
2016-04-09 13:17 ` Tom Herbert
2016-04-09 17:00 ` Alexei Starovoitov
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=20160408163954.GA28353@gmail.com \
--to=bblanco@plumgrid.com \
--cc=alexei.starovoitov@gmail.com \
--cc=brouer@redhat.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=ecree@solarflare.com \
--cc=eranlinuxmellanox@gmail.com \
--cc=eric.dumazet@gmail.com \
--cc=johannes@sipsolutions.net \
--cc=john.fastabend@gmail.com \
--cc=lorenzo@google.com \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@mellanox.com \
--cc=tgraf@suug.ch \
--cc=tom@herbertland.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;
as well as URLs for NNTP newsgroup(s).