Message ID | 20230605144433.290114-14-maciej.fijalkowski@intel.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | xsk: multi-buffer support | expand |
On Mon, 5 Jun 2023 16:44:24 +0200 Maciej Fijalkowski wrote: > diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h > index 639524b59930..c293014a4197 100644 > --- a/include/uapi/linux/netdev.h > +++ b/include/uapi/linux/netdev.h > @@ -24,6 +24,8 @@ > * XDP buffer support in the driver napi callback. > * @NETDEV_XDP_ACT_NDO_XMIT_SG: This feature informs if netdev implements > * non-linear XDP buffer support in ndo_xdp_xmit callback. > + * @NETDEV_XDP_ACT_ZC_SG: This feature informs if netdev implements > + * non-linear XDP buffer support in AF_XDP zero copy mode. > */ > enum netdev_xdp_act { > NETDEV_XDP_ACT_BASIC = 1, > @@ -33,8 +35,8 @@ enum netdev_xdp_act { > NETDEV_XDP_ACT_HW_OFFLOAD = 16, > NETDEV_XDP_ACT_RX_SG = 32, > NETDEV_XDP_ACT_NDO_XMIT_SG = 64, > - > - NETDEV_XDP_ACT_MASK = 127, > + NETDEV_XDP_ACT_ZC_SG = 128, > + NETDEV_XDP_ACT_MASK = 255, This is auto-generated, you need to make a change to Documentation/netlink/specs/netdev.yaml then run ./tools/net/ynl/ynl-regen.sh to regenerate the code (you may need to install python-yaml or some such package).
On Mon, Jun 05, 2023 at 02:43:10PM -0700, Jakub Kicinski wrote: > On Mon, 5 Jun 2023 16:44:24 +0200 Maciej Fijalkowski wrote: > > diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h > > index 639524b59930..c293014a4197 100644 > > --- a/include/uapi/linux/netdev.h > > +++ b/include/uapi/linux/netdev.h > > @@ -24,6 +24,8 @@ > > * XDP buffer support in the driver napi callback. > > * @NETDEV_XDP_ACT_NDO_XMIT_SG: This feature informs if netdev implements > > * non-linear XDP buffer support in ndo_xdp_xmit callback. > > + * @NETDEV_XDP_ACT_ZC_SG: This feature informs if netdev implements > > + * non-linear XDP buffer support in AF_XDP zero copy mode. > > */ > > enum netdev_xdp_act { > > NETDEV_XDP_ACT_BASIC = 1, > > @@ -33,8 +35,8 @@ enum netdev_xdp_act { > > NETDEV_XDP_ACT_HW_OFFLOAD = 16, > > NETDEV_XDP_ACT_RX_SG = 32, > > NETDEV_XDP_ACT_NDO_XMIT_SG = 64, > > - > > - NETDEV_XDP_ACT_MASK = 127, > > + NETDEV_XDP_ACT_ZC_SG = 128, > > + NETDEV_XDP_ACT_MASK = 255, > > This is auto-generated, you need to make a change to > Documentation/netlink/specs/netdev.yaml > then run ./tools/net/ynl/ynl-regen.sh to regenerate the code > (you may need to install python-yaml or some such package). Oh boy I was not aware of this at all. Thanks for letting me know.
diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h index 639524b59930..c293014a4197 100644 --- a/include/uapi/linux/netdev.h +++ b/include/uapi/linux/netdev.h @@ -24,6 +24,8 @@ * XDP buffer support in the driver napi callback. * @NETDEV_XDP_ACT_NDO_XMIT_SG: This feature informs if netdev implements * non-linear XDP buffer support in ndo_xdp_xmit callback. + * @NETDEV_XDP_ACT_ZC_SG: This feature informs if netdev implements + * non-linear XDP buffer support in AF_XDP zero copy mode. */ enum netdev_xdp_act { NETDEV_XDP_ACT_BASIC = 1, @@ -33,8 +35,8 @@ enum netdev_xdp_act { NETDEV_XDP_ACT_HW_OFFLOAD = 16, NETDEV_XDP_ACT_RX_SG = 32, NETDEV_XDP_ACT_NDO_XMIT_SG = 64, - - NETDEV_XDP_ACT_MASK = 127, + NETDEV_XDP_ACT_ZC_SG = 128, + NETDEV_XDP_ACT_MASK = 255, }; enum { diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c index 0a9f8ea68de3..c8d65e5883ec 100644 --- a/net/xdp/xsk_buff_pool.c +++ b/net/xdp/xsk_buff_pool.c @@ -189,6 +189,12 @@ int xp_assign_dev(struct xsk_buff_pool *pool, goto err_unreg_pool; } + if (!(netdev->xdp_features & NETDEV_XDP_ACT_ZC_SG) && + flags & XDP_USE_SG) { + err = -EOPNOTSUPP; + goto err_unreg_pool; + } + bpf.command = XDP_SETUP_XSK_POOL; bpf.xsk.pool = pool; bpf.xsk.queue_id = queue_id;
Introduce new xdp_feature NETDEV_XDP_ACT_ZC_SG that will be used to find out if user space that wants to do ZC multi-buffer will be able to do so against underlying ZC driver. Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> --- include/uapi/linux/netdev.h | 6 ++++-- net/xdp/xsk_buff_pool.c | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-)