netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: "Niklas Söderlund" <niklas.soderlund@corigine.com>
Cc: Lorenzo Bianconi <lorenzo@kernel.org>,
	bpf@vger.kernel.org, netdev@vger.kernel.org, ast@kernel.org,
	daniel@iogearbox.net, andrii@kernel.org, davem@davemloft.net,
	kuba@kernel.org, hawk@kernel.org, pabeni@redhat.com,
	edumazet@google.com, memxor@gmail.com, alardam@gmail.com,
	saeedm@nvidia.com, anthony.l.nguyen@intel.com,
	gospo@broadcom.com, vladimir.oltean@nxp.com, nbd@nbd.name,
	john@phrozen.org, leon@kernel.org, simon.horman@corigine.com,
	aelior@marvell.com, christophe.jaillet@wanadoo.fr,
	ecree.xilinx@gmail.com, mst@redhat.com, bjorn@kernel.org,
	magnus.karlsson@intel.com, maciej.fijalkowski@intel.com,
	intel-wired-lan@lists.osuosl.org, lorenzo.bianconi@redhat.com
Subject: Re: [RFC v2 bpf-next 2/7] drivers: net: turn on XDP features
Date: Tue, 17 Jan 2023 23:42:07 +0100	[thread overview]
Message-ID: <87pmbcbx6o.fsf@toke.dk> (raw)
In-Reply-To: <Y8chM32w/ZWsOOT+@oden.dyn.berto.se>

Niklas Söderlund <niklas.soderlund@corigine.com> writes:

> On 2023-01-17 23:15:47 +0100, Toke Høiland-Jørgensen wrote:
>> Niklas Söderlund <niklas.soderlund@corigine.com> writes:
>> 
>> > Hi Toke,
>> >
>> > On 2023-01-17 22:58:57 +0100, Toke Høiland-Jørgensen wrote:
>> >> Niklas Söderlund <niklas.soderlund@corigine.com> writes:
>> >> 
>> >> > Hi Lorenzo and Marek,
>> >> >
>> >> > Thanks for your work.
>> >> >
>> >> > On 2023-01-14 16:54:32 +0100, Lorenzo Bianconi wrote:
>> >> >
>> >> > [...]
>> >> >
>> >> >> 
>> >> >> Turn 'hw-offload' feature flag on for:
>> >> >>  - netronome (nfp)
>> >> >>  - netdevsim.
>> >> >
>> >> > Is there a definition of the 'hw-offload' written down somewhere? From 
>> >> > reading this series I take it is the ability to offload a BPF program?  
>> >> 
>> >> Yeah, basically this means "allows loading and attaching programs in
>> >> XDP_MODE_HW", I suppose :)
>> >> 
>> >> > It would also be interesting to read documentation for the other flags 
>> >> > added in this series.
>> >> 
>> >> Yup, we should definitely document them :)
>> >> 
>> >> > [...]
>> >> >
>> >> >> diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c 
>> >> >> b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
>> >> >> index 18fc9971f1c8..5a8ddeaff74d 100644
>> >> >> --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
>> >> >> +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c
>> >> >> @@ -2529,10 +2529,14 @@ static void nfp_net_netdev_init(struct nfp_net *nn)
>> >> >>  	netdev->features &= ~NETIF_F_HW_VLAN_STAG_RX;
>> >> >>  	nn->dp.ctrl &= ~NFP_NET_CFG_CTRL_RXQINQ;
>> >> >>  
>> >> >> +	nn->dp.netdev->xdp_features = NETDEV_XDP_ACT_BASIC |
>> >> >> +				      NETDEV_XDP_ACT_HW_OFFLOAD;
>> >> >
>> >> > If my assumption about the 'hw-offload' flag above is correct I think 
>> >> > NETDEV_XDP_ACT_HW_OFFLOAD should be conditioned on that the BPF firmware 
>> >> > flavor is in use.
>> >> >
>> >> >     nn->dp.netdev->xdp_features = NETDEV_XDP_ACT_BASIC;
>> >> >
>> >> >     if (nn->app->type->id == NFP_APP_BPF_NIC)
>> >> >         nn->dp.netdev->xdp_features |= NETDEV_XDP_ACT_HW_OFFLOAD;
>> >> >
>> >> >> +
>> >> >>  	/* Finalise the netdev setup */
>> >> >>  	switch (nn->dp.ops->version) {
>> >> >>  	case NFP_NFD_VER_NFD3:
>> >> >>  		netdev->netdev_ops = &nfp_nfd3_netdev_ops;
>> >> >> +		nn->dp.netdev->xdp_features |= NETDEV_XDP_ACT_XSK_ZEROCOPY;
>> >> >>  		break;
>> >> >>  	case NFP_NFD_VER_NFDK:
>> >> >>  		netdev->netdev_ops = &nfp_nfdk_netdev_ops;
>> >> >
>> >> > This is also a wrinkle I would like to understand. Currently NFP support 
>> >> > zero-copy on NFD3, but not for offloaded BPF programs. But with the BPF 
>> >> > firmware flavor running the device can still support zero-copy for 
>> >> > non-offloaded programs.
>> >> >
>> >> > Is it a problem that the driver advertises support for both 
>> >> > hardware-offload _and_ zero-copy at the same time, even if they can't be 
>> >> > used together but separately?
>> >> 
>> >> Hmm, so the idea with this is to only expose feature flags that are
>> >> supported "right now" (you'll note that some of the drivers turn the
>> >> REDIRECT_TARGET flag on and off at runtime). Having features that are
>> >> "supported but in a different configuration" is one of the points of
>> >> user confusion we want to clear up with the explicit flags.
>> >> 
>> >> So I guess it depends a little bit what you mean by "can't be used
>> >> together"? I believe it's possible to load two programs at the same
>> >> time, one in HW mode and one in native (driver) mode, right? In this
>> >> case, could the driver mode program use XSK zerocopy while the HW mode
>> >> program is also loaded?
>> >
>> > Exactly, this is my concern. Two programs can be loaded at the same 
>> > time, one in HW mode and one in native mode. The program in native mode 
>> > can use zero-copy at the same time as another program runs in HW mode.
>> >
>> > But the program running in HW mode can never use zero-copy.
>> 
>> Hmm, but zero-copy is an AF_XDP feature, and AFAIK offloaded programs
>> can't use AF_XDP at all? So the zero-copy "feature" is available on the
>> hardware, it's just intrinsic to that feature that it doesn't work on
>> offloaded programs?
>
> That is true, so this is indeed not an issue then. Thanks for the 
> clarification.

Cool - you're welcome :)

-Toke


  reply	other threads:[~2023-01-17 23:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-14 15:54 [RFC v2 bpf-next 0/7] xdp: introduce xdp-feature support Lorenzo Bianconi
2023-01-14 15:54 ` [RFC v2 bpf-next 1/7] netdev-genl: create a simple family for netdev stuff Lorenzo Bianconi
2023-01-14 15:54 ` [RFC v2 bpf-next 2/7] drivers: net: turn on XDP features Lorenzo Bianconi
2023-01-17 21:29   ` Niklas Söderlund
2023-01-17 21:58     ` Toke Høiland-Jørgensen
2023-01-17 22:05       ` Niklas Söderlund
2023-01-17 22:15         ` Toke Høiland-Jørgensen
2023-01-17 22:29           ` Niklas Söderlund
2023-01-17 22:42             ` Toke Høiland-Jørgensen [this message]
2023-01-17 23:45     ` Lorenzo Bianconi
2023-01-18  8:50       ` Niklas Söderlund
2023-01-18  9:38         ` Lorenzo Bianconi
2023-01-18 20:30   ` sdf
2023-01-19 14:23     ` Lorenzo Bianconi
2023-01-14 15:54 ` [RFC v2 bpf-next 3/7] xsk: add usage of XDP features flags Lorenzo Bianconi
2023-01-17 22:07   ` Yonghong Song
2023-01-17 23:34     ` Lorenzo Bianconi
2023-01-17 23:37       ` Yonghong Song
2023-01-14 15:54 ` [RFC v2 bpf-next 4/7] libbpf: add the capability to specify netlink proto in libbpf_netlink_send_recv Lorenzo Bianconi
2023-01-14 15:54 ` [RFC v2 bpf-next 5/7] libbpf: add API to get XDP/XSK supported features Lorenzo Bianconi
2023-01-18  0:58   ` Jakub Kicinski
2023-01-19 22:39     ` Lorenzo Bianconi
2023-01-14 15:54 ` [RFC v2 bpf-next 6/7] bpf: devmap: check XDP features in bpf_map_update_elem and __xdp_enqueue Lorenzo Bianconi
2023-01-14 15:54 ` [RFC v2 bpf-next 7/7] selftests/bpf: introduce XDP compliance test tool Lorenzo Bianconi

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=87pmbcbx6o.fsf@toke.dk \
    --to=toke@redhat.com \
    --cc=aelior@marvell.com \
    --cc=alardam@gmail.com \
    --cc=andrii@kernel.org \
    --cc=anthony.l.nguyen@intel.com \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=ecree.xilinx@gmail.com \
    --cc=edumazet@google.com \
    --cc=gospo@broadcom.com \
    --cc=hawk@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=john@phrozen.org \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=lorenzo.bianconi@redhat.com \
    --cc=lorenzo@kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=memxor@gmail.com \
    --cc=mst@redhat.com \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=niklas.soderlund@corigine.com \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=simon.horman@corigine.com \
    --cc=vladimir.oltean@nxp.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).