All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: "Toke Høiland-Jørgensen" <toke@toke.dk>
Cc: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>,
	Kalle Valo <kvalo@codeaurora.org>,
	linux-wireless@vger.kernel.org, nbd@nbd.name, brouer@redhat.com,
	Daniel Borkmann <borkmann@iogearbox.net>,
	Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [RFC 0/5] add XDP support to mt76x2e/mt76x0e drivers
Date: Wed, 28 Nov 2018 16:43:06 +0100	[thread overview]
Message-ID: <20181128164306.0135ca83@redhat.com> (raw)
In-Reply-To: <87bm69v0ol.fsf@toke.dk>

On Wed, 28 Nov 2018 13:36:26 +0100
Toke Høiland-Jørgensen <toke@toke.dk> wrote:

> Lorenzo Bianconi <lorenzo.bianconi@redhat.com> writes:
> 
> >> Lorenzo Bianconi <lorenzo.bianconi@redhat.com> writes:
> >>   
> >> > This series is intended as a playground to start experimenting/developing
> >> > with XDP/eBPF over WiFi and collect ideas/concerns about it.
> >> > Introduce XDP support to mt76x2e/mt76x0e drivers. Currently supported
> >> > actions are:
> >> > - XDP_PASS
> >> > - XDP_ABORTED
> >> > - XDP_DROP
> >> > Introduce ndo_bpf mac80211 callback in order to to load a bpf
> >> > program into low level driver XDP rx hook.
> >> > This series has been tested through a simple bpf program (available here:
> >> > https://github.com/LorenzoBianconi/bpf-workspace/tree/master/mt76_xdp_stats)
> >> > used to count frame types received by the device.
> >> > Possible eBPF use cases could be:
> >> > - implement new statistics through bpf maps
> >> > - implement fast packet filtering (e.g in monitor mode)
> >> > - ...  
> >
> > Hi Kalle,
> >  
> >> 
> >> This is most likely a stupid question, but why do this in the driver and
> >> not in mac80211 so that all drivers could benefit from it? I guess there
> >> are reasons for that, I just can't figure that out.  
> 
> XDP achieves its speedup by running the eBPF program inside the driver
> NAPI loop, before the kernel even touches the data in any other capacity
> (and in particular, before it allocates an SKB). Which kinda means the
> hook needs to be in the driver... Could be a fallback in mac80211,
> though; although we'd have to figure out how that interacts with Generic
> XDP.
> 
> > This is an early stage implementation, at this point I would collect
> > other people opinions/concerns about using bpf/xdp directly on 802.11
> > frames.  
> 
> Thanks for looking into this!
> 
> I have two concerns with running XDP on 802.11 frames:
> 
> 1. It makes it more difficult to add other XDP actions (such as
>    REDIRECT), as the XDP program would then have to make sure that the
>    outer packet headers are removed before, say, redirecting the packet
>    out of an ethernet interface. Also, if we do add redirect, we would
>    be bypassing mac80211 entirely; to what extent would that mess up
>    internal state?
> 
> 2. UI consistency; suddenly, the user needs to know which kind of
>    frames to expect, and XDP program reuse becomes more difficult. This
>    may be unavoidable given the nature of XDP, but some thought needs to
>    go into this. Especially since we wouldn't necessarily be consistent
>    between WiFi drivers (there are fullmac devices that remove 802.11
>    headers before sending up the frame, right?).
> 
> 
> Adding in Jesper; maybe he has some thoughts on this?

Today XDP assumes the frame is an Ethernet frame.  With WiFi I guess
this assumption change, right?
  I worry a bit about this, as XDP is all about performance, and I don't
want to add performance regressions, by requiring all XDP programs or
core-code to having to check-frame-type before proceeding. That said, I
do think it is doable, without adding performance regressions.

Option #1 is to move the check-frame-type to setup time.  By either
having frame-type be part of eBPF prog, or supply frame-type as option
XDP attach call.  And then reject attaching XDP prog to a device, where
the expected frame-type does not match.

Option#2, leave it up to eBPF-programmer if they want to add runtime
checks.  By extending xdp_rxq_info with frame-type (default to
Ethernet), which allow the eBPF-programmer choose to write a generic
XDP program that both work on Ethernet and WiFi, or skip-check as they
know this will e.g. only run on Wifi.  (Note xdp_rxq_info is static
read-only info per RX-queue, will all Wifi frames have same frame-type?.


Also consider what happens in case of XDP_REDIRECT, from a Wifi NIC to
an Ethernet NIC.  It would of-cause be cool to get this working cross,
Wifi-Ethernet.

Option#3 is to say, Wifi XDP is so different that we should create a
new (enum) bpf_prog_type.  And then still see if we can leverage some
of the same core-code (as long as it doesn't slowdown performance).

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

WARNING: multiple messages have this Message-ID (diff)
From: Jesper Dangaard Brouer <brouer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: "Toke Høiland-Jørgensen" <toke-LJ9M9ZcSy1A@public.gmane.org>
Cc: Lorenzo Bianconi
	<lorenzo.bianconi-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Kalle Valo <kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	nbd-Vt+b4OUoWG0@public.gmane.org,
	brouer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	Daniel Borkmann
	<borkmann-FeC+5ew28dpmcu3hnIyYJQ@public.gmane.org>,
	Alexei Starovoitov
	<alexei.starovoitov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [RFC 0/5] add XDP support to mt76x2e/mt76x0e drivers
Date: Wed, 28 Nov 2018 16:43:06 +0100	[thread overview]
Message-ID: <20181128164306.0135ca83@redhat.com> (raw)
In-Reply-To: <87bm69v0ol.fsf-LJ9M9ZcSy1A@public.gmane.org>

On Wed, 28 Nov 2018 13:36:26 +0100
Toke Høiland-Jørgensen <toke-LJ9M9ZcSy1A@public.gmane.org> wrote:

> Lorenzo Bianconi <lorenzo.bianconi-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> writes:
> 
> >> Lorenzo Bianconi <lorenzo.bianconi-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> writes:
> >>   
> >> > This series is intended as a playground to start experimenting/developing
> >> > with XDP/eBPF over WiFi and collect ideas/concerns about it.
> >> > Introduce XDP support to mt76x2e/mt76x0e drivers. Currently supported
> >> > actions are:
> >> > - XDP_PASS
> >> > - XDP_ABORTED
> >> > - XDP_DROP
> >> > Introduce ndo_bpf mac80211 callback in order to to load a bpf
> >> > program into low level driver XDP rx hook.
> >> > This series has been tested through a simple bpf program (available here:
> >> > https://github.com/LorenzoBianconi/bpf-workspace/tree/master/mt76_xdp_stats)
> >> > used to count frame types received by the device.
> >> > Possible eBPF use cases could be:
> >> > - implement new statistics through bpf maps
> >> > - implement fast packet filtering (e.g in monitor mode)
> >> > - ...  
> >
> > Hi Kalle,
> >  
> >> 
> >> This is most likely a stupid question, but why do this in the driver and
> >> not in mac80211 so that all drivers could benefit from it? I guess there
> >> are reasons for that, I just can't figure that out.  
> 
> XDP achieves its speedup by running the eBPF program inside the driver
> NAPI loop, before the kernel even touches the data in any other capacity
> (and in particular, before it allocates an SKB). Which kinda means the
> hook needs to be in the driver... Could be a fallback in mac80211,
> though; although we'd have to figure out how that interacts with Generic
> XDP.
> 
> > This is an early stage implementation, at this point I would collect
> > other people opinions/concerns about using bpf/xdp directly on 802.11
> > frames.  
> 
> Thanks for looking into this!
> 
> I have two concerns with running XDP on 802.11 frames:
> 
> 1. It makes it more difficult to add other XDP actions (such as
>    REDIRECT), as the XDP program would then have to make sure that the
>    outer packet headers are removed before, say, redirecting the packet
>    out of an ethernet interface. Also, if we do add redirect, we would
>    be bypassing mac80211 entirely; to what extent would that mess up
>    internal state?
> 
> 2. UI consistency; suddenly, the user needs to know which kind of
>    frames to expect, and XDP program reuse becomes more difficult. This
>    may be unavoidable given the nature of XDP, but some thought needs to
>    go into this. Especially since we wouldn't necessarily be consistent
>    between WiFi drivers (there are fullmac devices that remove 802.11
>    headers before sending up the frame, right?).
> 
> 
> Adding in Jesper; maybe he has some thoughts on this?

Today XDP assumes the frame is an Ethernet frame.  With WiFi I guess
this assumption change, right?
  I worry a bit about this, as XDP is all about performance, and I don't
want to add performance regressions, by requiring all XDP programs or
core-code to having to check-frame-type before proceeding. That said, I
do think it is doable, without adding performance regressions.

Option #1 is to move the check-frame-type to setup time.  By either
having frame-type be part of eBPF prog, or supply frame-type as option
XDP attach call.  And then reject attaching XDP prog to a device, where
the expected frame-type does not match.

Option#2, leave it up to eBPF-programmer if they want to add runtime
checks.  By extending xdp_rxq_info with frame-type (default to
Ethernet), which allow the eBPF-programmer choose to write a generic
XDP program that both work on Ethernet and WiFi, or skip-check as they
know this will e.g. only run on Wifi.  (Note xdp_rxq_info is static
read-only info per RX-queue, will all Wifi frames have same frame-type?.


Also consider what happens in case of XDP_REDIRECT, from a Wifi NIC to
an Ethernet NIC.  It would of-cause be cool to get this working cross,
Wifi-Ethernet.

Option#3 is to say, Wifi XDP is so different that we should create a
new (enum) bpf_prog_type.  And then still see if we can leverage some
of the same core-code (as long as it doesn't slowdown performance).

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

  parent reply	other threads:[~2018-11-28 15:43 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-27 22:21 [RFC 0/5] add XDP support to mt76x2e/mt76x0e drivers Lorenzo Bianconi
2018-11-27 22:21 ` [RFC 1/5] mac80211: introduce ieee80211_xdp handler Lorenzo Bianconi
2018-11-27 22:21 ` [RFC 2/5] mac80211: introduce ieee80211_vif_to_netdev routine Lorenzo Bianconi
2018-11-27 22:21 ` [RFC 3/5] mt76: split mt76_dma_rx_reset in init_rx_reset and complete_rx_reset Lorenzo Bianconi
2018-11-27 22:21 ` [RFC 4/5] mt76: make mt76x02_vif_init return int Lorenzo Bianconi
2018-11-27 22:21 ` [RFC 5/5] mt76: add XDP support Lorenzo Bianconi
2018-11-28 10:15 ` [RFC 0/5] add XDP support to mt76x2e/mt76x0e drivers Kalle Valo
2018-11-28 10:44   ` Lorenzo Bianconi
2018-11-28 12:36     ` Toke Høiland-Jørgensen
2018-11-28 12:53       ` Michał Kazior
2018-11-28 14:19         ` Toke Høiland-Jørgensen
2018-11-28 13:11       ` Lorenzo Bianconi
2018-11-28 14:21         ` Toke Høiland-Jørgensen
2018-11-28 14:35           ` Lorenzo Bianconi
2018-11-28 14:43             ` Toke Høiland-Jørgensen
2018-11-28 15:35               ` Lorenzo Bianconi
2018-11-28 23:12                 ` Toke Høiland-Jørgensen
2018-11-29 12:59                   ` Lorenzo Bianconi
2018-11-29 13:29                     ` Toke Høiland-Jørgensen
2018-11-29 13:45                     ` Michał Kazior
2018-11-29 13:53                       ` Toke Høiland-Jørgensen
2018-12-03 17:57                         ` Johannes Berg
2018-12-03 19:36                           ` Toke Høiland-Jørgensen
2018-12-03 19:41                             ` Johannes Berg
2018-12-03 19:51                               ` Toke Høiland-Jørgensen
2018-12-03 20:00                               ` Lorenzo Bianconi
2018-11-28 15:43       ` Jesper Dangaard Brouer [this message]
2018-11-28 15:43         ` Jesper Dangaard Brouer
2018-11-29 10:30         ` Lorenzo Bianconi
2018-11-29 13:27           ` Toke Høiland-Jørgensen
2018-11-29 13:27             ` Toke Høiland-Jørgensen
2018-11-29 13:41             ` Michał Kazior
2018-11-29 13:48               ` Toke Høiland-Jørgensen
2018-11-29 13:58             ` Lorenzo Bianconi
2018-11-29 14:06               ` Toke Høiland-Jørgensen
2018-11-29 14:06                 ` Toke Høiland-Jørgensen
2018-11-29 15:45                 ` Lorenzo Bianconi
2018-11-29 16:06                   ` Toke Høiland-Jørgensen

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=20181128164306.0135ca83@redhat.com \
    --to=brouer@redhat.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=borkmann@iogearbox.net \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=toke@toke.dk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.