xdp: introduce xdp-feature support
Subsystems (40)
Lorenzo Bianconi
maintainerv2 cover xdp: introduce xdp-feature support
Introduce the capability to export the XDP features supported by the NIC. Introduce a XDP compliance test tool (xdp_features) to check the features exported by the NIC match the real features supported by the driver. Allow XDP_REDIRECT of non-linear XDP frames into a devmap. Export XDP features for each XDP capable driver.
Extend libbpf netlink implementation in order to support netlink_generic protocol.
Introduce a simple generic netlink family for netdev data.
Changes since v1:
- add Documentation to netdev.yaml
- use flags instead of enum as type for netdev.yaml definitions
- squash XDP_PASS, XDP_DROP, XDP_TX and XDP_ABORTED into XDP_BASIC since they are supported by all drivers.
- add notifier event to xdp_features_set_redirect_target() and xdp_features_clear_redirect_target()
- add selftest for xdp-features support in bpf_xdp_detach()
- add IPv6 preliminary support to XDP compliance test tool
Changes since RFCv2:
- do not assume fixed layout for genl kernel messages
- fix warnings in netdev_nl_dev_fill
- fix capabilities for nfp driver
- add supported_sg parameter to xdp_features_set_redirect_target and drop __xdp_features_set_redirect_target routine
Changes since RFCv1:
- Introduce netdev-genl implementation and get rid of rtnl one.
- Introduce netlink_generic support in libbpf netlink implementation
- Rename XDP_FEATURE_* in NETDEV_XDP_ACT_*
- Rename XDP_FEATURE_REDIRECT_TARGET in NETDEV_XDP_ACT_NDO_XMIT
- Rename XDP_FEATURE_FRAG_RX in NETDEV_XDP_ACT_RX_SG
- Rename XDP_FEATURE_FRAG_TARFET in NETDEV_XDP_ACT_NDO_XMIT
- Get rid of XDP_LOCK feature.
- Move xdp_feature field in a netdevice struct hole in the 4th cacheline.
Jakub Kicinski (1):
netdev-genl: create a simple family for netdev stuff
Lorenzo Bianconi (5):
libbpf: add the capability to specify netlink proto in
libbpf_netlink_send_recv
libbpf: add API to get XDP/XSK supported features
bpf: devmap: check XDP features in __xdp_enqueue routine selftests/bpf: add test for bpf_xdp_query xdp-features support selftests/bpf: introduce XDP compliance test tool
Marek Majtyka (2):
drivers: net: turn on XDP features
xsk: add usage of XDP features flags
Documentation/netlink/specs/netdev.yaml | 100 +++ drivers/net/ethernet/amazon/ena/ena_netdev.c | 4 + .../net/ethernet/aquantia/atlantic/aq_nic.c | 5 + drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 + drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 2 + .../net/ethernet/cavium/thunder/nicvf_main.c | 2 + .../net/ethernet/freescale/dpaa/dpaa_eth.c | 4 + .../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 4 + .../net/ethernet/freescale/enetc/enetc_pf.c | 3 + .../ethernet/fungible/funeth/funeth_main.c | 6 + drivers/net/ethernet/intel/i40e/i40e_main.c | 10 +- drivers/net/ethernet/intel/ice/ice_main.c | 5 + drivers/net/ethernet/intel/igb/igb_main.c | 9 +- drivers/net/ethernet/intel/igc/igc_main.c | 3 + drivers/net/ethernet/intel/igc/igc_xdp.c | 5 + drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 6 + .../net/ethernet/intel/ixgbevf/ixgbevf_main.c | 1 + drivers/net/ethernet/marvell/mvneta.c | 3 + .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 4 + .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 8 +- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 + .../net/ethernet/mellanox/mlx4/en_netdev.c | 2 + .../net/ethernet/mellanox/mlx5/core/en_main.c | 11 + drivers/net/ethernet/microsoft/mana/mana_en.c | 2 + .../ethernet/netronome/nfp/nfp_net_common.c | 5 + drivers/net/ethernet/qlogic/qede/qede_main.c | 3 + drivers/net/ethernet/sfc/efx.c | 4 + drivers/net/ethernet/sfc/siena/efx.c | 4 + drivers/net/ethernet/socionext/netsec.c | 3 + .../net/ethernet/stmicro/stmmac/stmmac_main.c | 2 + drivers/net/ethernet/ti/cpsw.c | 4 + drivers/net/ethernet/ti/cpsw_new.c | 4 + drivers/net/hyperv/netvsc_drv.c | 2 + drivers/net/netdevsim/netdev.c | 1 + drivers/net/tun.c | 5 + drivers/net/veth.c | 4 + drivers/net/virtio_net.c | 4 + drivers/net/xen-netfront.c | 2 + include/linux/netdevice.h | 3 + include/net/xdp.h | 18 + include/uapi/linux/netdev.h | 59 ++ kernel/bpf/devmap.c | 16 +- net/core/Makefile | 3 +- net/core/dev.c | 1 + net/core/filter.c | 13 +- net/core/netdev-genl-gen.c | 48 ++ net/core/netdev-genl-gen.h | 23 + net/core/netdev-genl.c | 179 +++++ net/core/xdp.c | 18 + net/xdp/xsk_buff_pool.c | 7 +- tools/include/uapi/linux/netdev.h | 59 ++ tools/lib/bpf/libbpf.h | 3 +- tools/lib/bpf/netlink.c | 121 ++- tools/lib/bpf/nlattr.h | 12 + tools/testing/selftests/bpf/.gitignore | 1 + tools/testing/selftests/bpf/Makefile | 11 +- .../bpf/prog_tests/xdp_do_redirect.c | 27 +- .../selftests/bpf/prog_tests/xdp_info.c | 8 + .../selftests/bpf/progs/xdp_features.c | 249 ++++++ .../selftests/bpf/test_xdp_features.sh | 99 +++ tools/testing/selftests/bpf/xdp_features.c | 736 ++++++++++++++++++ tools/testing/selftests/bpf/xdp_features.h | 33 + 62 files changed, 1969 insertions(+), 33 deletions(-) create mode 100644 Documentation/netlink/specs/netdev.yaml create mode 100644 include/uapi/linux/netdev.h create mode 100644 net/core/netdev-genl-gen.c create mode 100644 net/core/netdev-genl-gen.h create mode 100644 net/core/netdev-genl.c create mode 100644 tools/include/uapi/linux/netdev.h create mode 100644 tools/testing/selftests/bpf/progs/xdp_features.c create mode 100755 tools/testing/selftests/bpf/test_xdp_features.sh create mode 100644 tools/testing/selftests/bpf/xdp_features.c create mode 100644 tools/testing/selftests/bpf/xdp_features.h
Signature · 1 line
2.39.1
Lorenzo Bianconi
maintainerPATCH v2 1/8 netdev-genl: create a simple family for netdev stuff
From: Jakub Kicinski <[email protected]>
Add a Netlink spec-compatible family for netdevs.
This is a very simple implementation without much
thought going into it.
It allows us to reap all the benefits of Netlink specs, one can use the generic client to issue the commands:
$ ./cli.py --spec netdev.yaml --dump dev_get
[{'ifindex': 1, 'xdp-features': set()},
{'ifindex': 2, 'xdp-features': {'basic', 'ndo-xmit', 'redirect'}},
{'ifindex': 3, 'xdp-features': {'rx-sg'}}]the generic python library does not have flags-by-name support, yet, but we also don't have to carry strings in the messages, as user space can get the names from the spec.
--- Documentation/netlink/specs/netdev.yaml | 100 +++++++++++++ include/linux/netdevice.h | 3 + include/net/xdp.h | 3 + include/uapi/linux/netdev.h | 59 ++++++++ net/core/Makefile | 3 +- net/core/dev.c | 1 + net/core/netdev-genl-gen.c | 48 +++++++ net/core/netdev-genl-gen.h | 23 +++ net/core/netdev-genl.c | 179 ++++++++++++++++++++++++ tools/include/uapi/linux/netdev.h | 59 ++++++++ 10 files changed, 477 insertions(+), 1 deletion(-) create mode 100644 Documentation/netlink/specs/netdev.yaml create mode 100644 include/uapi/linux/netdev.h create mode 100644 net/core/netdev-genl-gen.c create mode 100644 net/core/netdev-genl-gen.h create mode 100644 net/core/netdev-genl.c create mode 100644 tools/include/uapi/linux/netdev.h
Documentation/netlink/specs/netdev.yaml new file +100 -0
@@ -0,0 +1,100 @@ +name: netdev + +doc: + netdev configuration over generic netlink. + +definitions: + - + type: flags + name: xdp-act + entries: + - + name: basic + doc: + XDP feautues set supported by all drivers + (XDP_ABORTED, XDP_DROP, XDP_PASS, XDP_TX) + - + name: redirect + doc: + The netdev supports XDP_REDIRECT + - + name: ndo-xmit + doc: + This feature informs if netdev implements ndo_xdp_xmit callback. + - + name: xsk-zerocopy + doc: + This feature informs if netdev supports AF_XDP in zero copy mode. + - + name: hw-offload + doc: + This feature informs if netdev supports XDP hw oflloading. + - + name: rx-sg + doc: + This feature informs if netdev implements non-linear XDP buffer + support in the driver napi callback. + - + name: ndo-xmit-sg + doc: + This feature informs if netdev implements non-linear XDP buffer + support in ndo_xdp_xmit callback. + +attribute-sets: + - + name: dev + attributes: + - + name: ifindex + doc: netdev ifindex + type: u32 + value: 1 + checks: + min: 1 + - + name: pad + type: pad + - + name: xdp-features + doc: Bitmask of enabled xdp-features. + type: u64 + enum: xdp-act + enum-as-flags: true + +operations: + list: + - + name: dev-get + doc: Get / dump information about a netdev. + value: 1 + attribute-set: dev + do: + request: + attributes: + - ifindex + reply: &dev-all + attributes: + - ifindex + - xdp-features + dump: + reply: *dev-all + - + name: dev-add-ntf + doc: Notification about device appearing. + notify: dev-get + mcgrp: mgmt + - + name: dev-del-ntf + doc: Notification about device disappearing. + notify: dev-get + mcgrp: mgmt + - + name: dev-change-ntf + doc: Notification about device configuration being changed. + notify: dev-get + mcgrp: mgmt + +mcast-groups: + list: + - + name: mgmt
include/linux/netdevice.h +3 -0
@@ -47,6 +47,7 @@#include <uapi/linux/netdevice.h> #include <uapi/linux/if_bonding.h> #include <uapi/linux/pkt_cls.h> +#include <uapi/linux/netdev.h> #include <linux/hashtable.h> #include <linux/rbtree.h> #include <net/net_trackers.h>
@@ -2055,6 +2056,7 @@ struct net_device {/* Read-mostly cache-line for fast-path access */ unsigned int flags; +xdp_features_t xdp_features;unsigned long long priv_flags;const struct net_device_ops *netdev_ops;const struct xdp_metadata_ops *xdp_metadata_ops;
@@ -2839,6 +2841,7 @@ enum netdev_cmd {NETDEV_OFFLOAD_XSTATS_DISABLE ,NETDEV_OFFLOAD_XSTATS_REPORT_USED ,NETDEV_OFFLOAD_XSTATS_REPORT_DELTA , + NETDEV_XDP_FEAT_CHANGE, };const char *netdev_cmd_to_name (enum netdev_cmd cmd);
include/net/xdp.h +3 -0
@@ -7,6 +7,7 @@#define __LINUX_NET_XDP_H__#include <linux/skbuff.h> /* skb_shared_info */ +#include <uapi/linux/netdev.h> /** * DOC: XDP RX-queue information
@@ -43,6 +44,8 @@ enum xdp_mem_type { MEM_TYPE_MAX, }; +typedef u32 xdp_features_t ; +/* XDP flags for ndo_xdp_xmit */ #define XDP_XMIT_FLUSH (1U << 0)/* doorbell signal consumer */ #define XDP_XMIT_FLAGS_MASK XDP_XMIT_FLUSH
include/uapi/linux/netdev.h new file +59 -0
59 lines not on this page · raw message
net/core/Makefile +2 -1
@@ -12,7 +12,8 @@ obj-$(CONFIG_SYSCTL) += sysctl_net_core.o obj-y += dev.o dev_addr_lists.o dst.o netevent.o \ neighbour.o rtnetlink.o utils.o link_watch.o filter.o \ sock_diag.o dev_ioctl.o tso.o sock_reuseport.o \ - fib_notifier.o xdp.o flow_offload.o gro.o + fib_notifier.o xdp.o flow_offload.o gro.o \ + netdev-genl.o netdev-genl-gen.o obj-$(CONFIG_NETDEV_ADDR_LIST_TEST) += dev_addr_lists_test.o
net/core/dev.c +1 -0
@@ -1614,6 +1614,7 @@ const char *netdev_cmd_to_name(enum netdev_cmd cmd) N(SVLAN_FILTER_PUSH_INFO) N(SVLAN_FILTER_DROP_INFO) N(PRE_CHANGEADDR) N(OFFLOAD_XSTATS_ENABLE) N(OFFLOAD_XSTATS_DISABLE) N(OFFLOAD_XSTATS_REPORT_USED) N(OFFLOAD_XSTATS_REPORT_DELTA) + N(XDP_FEAT_CHANGE) }#undef Nreturn "UNKNOWN_NETDEV_EVENT" ;
net/core/netdev-genl-gen.c new file +48 -0
48 lines not on this page · raw message
net/core/netdev-genl-gen.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/netdev.yaml */ +/* YNL-GEN kernel header */ + +#ifndef _LINUX_NETDEV_GEN_H +#define _LINUX_NETDEV_GEN_H + +#include <net/netlink.h> +#include <net/genetlink.h> + +#include <linux/netdev.h> + +int netdev_nl_dev_get_doit (struct sk_buff *skb,struct genl_info *info); +int netdev_nl_dev_get_dumpit (struct sk_buff *skb,struct netlink_callback *cb); + +enum { +NETDEV_NLGRP_MGMT , +}; + +extern struct genl_family netdev_nl_family; + +#endif /* _LINUX_NETDEV_GEN_H */
net/core/netdev-genl.c new file +179 -0
179 lines not on this page · raw message
tools/include/uapi/linux/netdev.h new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
2.39.1
Re: [PATCH v2 bpf-next 1/8] netdev-genl: create a simple family for netdev stuff
Quoted 13 lines · Lorenzo Bianconi
include/linux/netdevice.h +1
-0@@ -47,6 +47,7 @@#include <uapi/linux/netdevice.h> #include <uapi/linux/if_bonding.h> #include <uapi/linux/pkt_cls.h> +#include <uapi/linux/netdev.h> #include <linux/hashtable.h> #include <linux/rbtree.h> #include <net/net_trackers.h>
include/linux/netdevice.h struct net_device { · line 2059
Quoted 4 lines
include/linux/netdevice.h +1
-0@@ -2055,6 +2056,7 @@ struct net_device {/* Read-mostly cache-line for fast-path access */ unsigned int flags; +xdp_features_t xdp_features;
Nice you found a 4 bytes hole to place the u32 xdp_features member in and in a "Read-mostly cache-line for fast-path access" that is good :-) (Added my pahole output for reference below)
Quoted 24 lines
include/linux/netdevice.h +1
-0unsigned long long priv_flags;const struct net_device_ops *netdev_ops;const struct xdp_metadata_ops *xdp_metadata_ops;@@ -2839,6 +2841,7 @@ enum netdev_cmd {NETDEV_OFFLOAD_XSTATS_DISABLE ,NETDEV_OFFLOAD_XSTATS_REPORT_USED ,NETDEV_OFFLOAD_XSTATS_REPORT_DELTA , + NETDEV_XDP_FEAT_CHANGE, };const char *netdev_cmd_to_name (enum netdev_cmd cmd);include/net/xdp.h +1
-0@@ -7,6 +7,7 @@#define __LINUX_NET_XDP_H__#include <linux/skbuff.h> /* skb_shared_info */ +#include <uapi/linux/netdev.h> /** * DOC: XDP RX-queue information
include/net/xdp.h enum xdp_mem_type { · line 51
Quoted 8 lines
include/net/xdp.h +2
-0@@ -43,6 +44,8 @@ enum xdp_mem_type { MEM_TYPE_MAX, }; +typedef u32 xdp_features_t ; +/* XDP flags for ndo_xdp_xmit */ #define XDP_XMIT_FLUSH (1U << 0)/* doorbell signal consumer */ #define XDP_XMIT_FLAGS_MASK XDP_XMIT_FLUSH
--Jesper
On 64 bit arch partial output from:
pahole -C net_device net/core/skbuff.o
struct net_device {
char name[16]; /* 0 16 */
struct netdev_name_node * name_node; /* 16 8 */
struct dev_ifalias * ifalias; /* 24 8 */
long unsigned int mem_end; /* 32 8 */
long unsigned int mem_start; /* 40 8 */
long unsigned int base_addr; /* 48 8 */
long unsigned int state; /* 56 8 */ /* --- cacheline 1 boundary (64 bytes) --- */
struct list_head dev_list; /* 64 16 */
struct list_head napi_list; /* 80 16 */
struct list_head unreg_list; /* 96 16 */
struct list_head close_list; /* 112 16 */
/* --- cacheline 2 boundary (128 bytes) --- */
struct list_head ptype_all; /* 128 16 */
struct list_head ptype_specific; /* 144 16 */
struct {
struct list_head upper; /* 160 16 */
struct list_head lower; /* 176 16 */
} adj_list; /* 160 32 */
/* --- cacheline 3 boundary (192 bytes) --- */
unsigned int flags; /* 192 4 */
/* XXX 4 bytes hole, try to pack */
long long unsigned int priv_flags; /* 200 8 */
const struct net_device_ops * netdev_ops; /* 208 8 */
const struct xdp_metadata_ops * xdp_metadata_ops; /* 216
8 */
int ifindex; /* 224 4 */
short unsigned int gflags; /* 228 2 */
short unsigned int hard_header_len; /* 230 2 */
unsigned int mtu; /* 232 4 */
short unsigned int needed_headroom; /* 236 2 */
short unsigned int needed_tailroom; /* 238 2 */
netdev_features_t features; /* 240 8 */
netdev_features_t hw_features; /* 248 8 */ /* --- cacheline 4 boundary (256 bytes) --- */
netdev_features_t wanted_features; /* 256 8 */
netdev_features_t vlan_features; /* 264 8 */
netdev_features_t hw_enc_features; /* 272 8 */
netdev_features_t mpls_features; /* 280 8 */
netdev_features_t gso_partial_features; /* 288 8 */
unsigned int min_mtu; /* 296 4 */
unsigned int max_mtu; /* 300 4 */
short unsigned int type; /* 304 2 */
unsigned char min_header_len; /* 306 1 */
unsigned char name_assign_type; /* 307 1 */
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Lorenzo Bianconi
maintainerPATCH v2 2/8 drivers: net: turn on XDP features
In reply to Lorenzo BianconiFrom: Marek Majtyka <[email protected]>
A summary of the flags being set for various drivers is given below. Note that XDP_F_REDIRECT_TARGET and XDP_F_FRAG_TARGET are features that can be turned off and on at runtime. This means that these flags may be set and unset under RTNL lock protection by the driver. Hence, READ_ONCE must be used by code loading the flag value.
Also, these flags are not used for synchronization against the availability of XDP resources on a device. It is merely a hint, and hence the read may race with the actual teardown of XDP resources on the device. This may change in the future, e.g. operations taking a reference on the XDP resources of the driver, and in turn inhibiting turning off this flag. However, for now, it can only be used as a hint to check whether device supports becoming a redirection target.
Turn 'hw-offload' feature flag on for:
- netronome (nfp)
- netdevsim.
Turn 'native' and 'zerocopy' features flags on for:
- intel (i40e, ice, ixgbe, igc)
- mellanox (mlx5).
- stmmac
Turn 'native' features flags on for:
- amazon (ena)
- broadcom (bnxt)
- freescale (dpaa, dpaa2, enetc)
- funeth
- intel (igb)
- marvell (mvneta, mvpp2, octeontx2)
- mellanox (mlx4)
- qlogic (qede)
- sfc
- socionext (netsec)
- ti (cpsw)
- tap
- veth
- xen
- virtio_net.
Turn 'basic' (tx, pass, aborted and drop) features flags on for:
- netronome (nfp)
- cavium (thunder)
- hyperv.
Turn 'redirect_target' feature flag on for:
- amanzon (ena)
- broadcom (bnxt)
- freescale (dpaa, dpaa2)
- intel (i40e, ice, igb, ixgbe)
- ti (cpsw)
- marvell (mvneta, mvpp2)
- sfc
- socionext (netsec)
- qlogic (qede)
- mellanox (mlx5)
- tap
- veth
- virtio_net
- xen
--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 4 ++++ .../net/ethernet/aquantia/atlantic/aq_nic.c | 5 +++++ drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 +++ drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 2 ++ .../net/ethernet/cavium/thunder/nicvf_main.c | 2 ++ drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 4 ++++ .../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 4 ++++ .../net/ethernet/freescale/enetc/enetc_pf.c | 3 +++ .../net/ethernet/fungible/funeth/funeth_main.c | 6 ++++++ drivers/net/ethernet/intel/i40e/i40e_main.c | 10 ++++++++-- drivers/net/ethernet/intel/ice/ice_main.c | 5 +++++ drivers/net/ethernet/intel/igb/igb_main.c | 9 ++++++++- drivers/net/ethernet/intel/igc/igc_main.c | 3 +++ drivers/net/ethernet/intel/igc/igc_xdp.c | 5 +++++ drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 6 ++++++ .../net/ethernet/intel/ixgbevf/ixgbevf_main.c | 1 + drivers/net/ethernet/marvell/mvneta.c | 3 +++ .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 4 ++++ .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 8 ++++++-- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 ++++++ drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 ++ .../net/ethernet/mellanox/mlx5/core/en_main.c | 11 +++++++++++ drivers/net/ethernet/microsoft/mana/mana_en.c | 2 ++ .../ethernet/netronome/nfp/nfp_net_common.c | 5 +++++ drivers/net/ethernet/qlogic/qede/qede_main.c | 3 +++ drivers/net/ethernet/sfc/efx.c | 4 ++++ drivers/net/ethernet/sfc/siena/efx.c | 4 ++++ drivers/net/ethernet/socionext/netsec.c | 3 +++ .../net/ethernet/stmicro/stmmac/stmmac_main.c | 2 ++ drivers/net/ethernet/ti/cpsw.c | 4 ++++ drivers/net/ethernet/ti/cpsw_new.c | 4 ++++ drivers/net/hyperv/netvsc_drv.c | 2 ++ drivers/net/netdevsim/netdev.c | 1 + drivers/net/tun.c | 5 +++++ drivers/net/veth.c | 4 ++++ drivers/net/virtio_net.c | 4 ++++ drivers/net/xen-netfront.c | 2 ++ include/net/xdp.h | 15 +++++++++++++++ net/core/xdp.c | 18 ++++++++++++++++++ 39 files changed, 183 insertions(+), 5 deletions(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +4 -0
@@ -597,7 +597,9 @@ static int ena_xdp_set(struct net_device *netdev, struct netdev_bpf *bpf)if (rc)return rc; } +xdp_features_set_redirect_target (netdev, false); }else if (old_bpf_prog) { +xdp_features_clear_redirect_target (netdev); rc =ena_destroy_and_free_all_xdp_queues (adapter);if (rc)return rc;
@@ -4103,6 +4105,8 @@ static void ena_set_conf_feat_params(struct ena_adapter *adapter,/* Set offload features */ ena_set_dev_offloads (feat, netdev); + netdev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT ; + adapter->max_mtu = feat->dev_attr.max_mtu; netdev->max_mtu = adapter->max_mtu; netdev->min_mtu =ENA_MIN_MTU ;
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +5 -0
@@ -384,6 +384,11 @@ void aq_nic_ndev_init(struct aq_nic_s *self) self->ndev->mtu = aq_nic_cfg->mtu -ETH_HLEN ; self->ndev->max_mtu = aq_hw_caps->mtu -ETH_FCS_LEN -ETH_HLEN ; + self->ndev->xdp_features =NETDEV_XDP_ACT_BASIC | +NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT | +NETDEV_XDP_ACT_RX_SG | +NETDEV_XDP_ACT_NDO_XMIT_SG ; } void aq_nic_set_tx_ring(struct aq_nic_s *self, unsigned int idx,
drivers/net/ethernet/broadcom/bnxt/bnxt.c +3 -0
@@ -13686,6 +13686,9 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)netif_set_tso_max_size (dev,GSO_MAX_SIZE ); + dev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_RX_SG ; +#ifdef CONFIG_BNXT_SRIOV init_waitqueue_head (&bp->sriov_cfg_wait);#endif
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +2 -0
@@ -422,9 +422,11 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)if (prog) {bnxt_set_rx_skb_mode (bp, true); +xdp_features_set_redirect_target (dev, true); }else {int rx, tx; +xdp_features_clear_redirect_target (dev);bnxt_set_rx_skb_mode (bp, false);bnxt_get_max_rings (bp, &rx, &tx, true);if (rx >1 ) {
drivers/net/ethernet/cavium/thunder/nicvf_main.c +2 -0
@@ -2218,6 +2218,8 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) netdev->netdev_ops = &nicvf_netdev_ops; netdev->watchdog_timeo =NICVF_TX_TIMEOUT ; + netdev->xdp_features =NETDEV_XDP_ACT_BASIC ; +/* MTU range: 64 - 9200 */ netdev->min_mtu =NIC_HW_MIN_FRS ; netdev->max_mtu =NIC_HW_MAX_FRS ;
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +4 -0
@@ -244,6 +244,10 @@ static int dpaa_netdev_init(struct net_device *net_dev, net_dev->features |= net_dev->hw_features; net_dev->vlan_features = net_dev->features; + net_dev->xdp_features =NETDEV_XDP_ACT_BASIC | +NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT ; +if (is_valid_ether_addr (mac_addr)) {memcpy (net_dev->perm_addr, mac_addr, net_dev->addr_len);eth_hw_addr_set (net_dev, mac_addr);
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +4 -0
@@ -4593,6 +4593,10 @@ static int dpaa2_eth_netdev_init(struct net_device *net_dev)NETIF_F_LLTX |NETIF_F_HW_TC |NETIF_F_TSO ; net_dev->gso_max_segs =DPAA2_ETH_ENQUEUE_MAX_FDS ; net_dev->hw_features = net_dev->features; + net_dev->xdp_features =NETDEV_XDP_ACT_BASIC | +NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_XSK_ZEROCOPY | +NETDEV_XDP_ACT_NDO_XMIT ;if (priv->dpni_attrs.vlan_filter_entries) net_dev->hw_features |=NETIF_F_HW_VLAN_CTAG_FILTER ;
drivers/net/ethernet/freescale/enetc/enetc_pf.c +3 -0
@@ -825,6 +825,9 @@ static void enetc_pf_netdev_setup(struct enetc_si *si, struct net_device *ndev, ndev->hw_features |=NETIF_F_RXHASH ; ndev->priv_flags |=IFF_UNICAST_FLT ; + ndev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT |NETDEV_XDP_ACT_RX_SG | +NETDEV_XDP_ACT_NDO_XMIT_SG ;if (si->hw_features &ENETC_SI_F_PSFP && !enetc_psfp_enable (priv)) { priv->active_offloads |=ENETC_F_QCI ;
drivers/net/ethernet/fungible/funeth/funeth_main.c +6 -0
@@ -1160,6 +1160,11 @@ static int fun_xdp_setup(struct net_device *dev, struct netdev_bpf *xdp)WRITE_ONCE (rxqs[i]->xdp_prog, prog); } +if (prog) +xdp_features_set_redirect_target (dev, true); +else +xdp_features_clear_redirect_target (dev); + dev->max_mtu = prog ?XDP_MAX_MTU :FUN_MAX_MTU ; old_prog =xchg (&fp->xdp_prog, prog);if (old_prog)
@@ -1765,6 +1770,7 @@ static int fun_create_netdev(struct fun_ethdev *ed, unsigned int portid) netdev->vlan_features = netdev->features &VLAN_FEAT ; netdev->mpls_features = netdev->vlan_features; netdev->hw_enc_features = netdev->hw_features; + netdev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT ; netdev->min_mtu =ETH_MIN_MTU ; netdev->max_mtu =FUN_MAX_MTU ;
drivers/net/ethernet/intel/i40e/i40e_main.c +8 -2
@@ -13339,9 +13339,11 @@ static int i40e_xdp_setup(struct i40e_vsi *vsi, struct bpf_prog *prog, old_prog =xchg (&vsi->xdp_prog, prog);if (need_reset) { -if (!prog) +if (!prog) { +xdp_features_clear_redirect_target (vsi->netdev);/* Wait until ndo_xsk_wakeup completes. */ synchronize_rcu (); + }i40e_reset_and_rebuild (pf, true, true); }
@@ -13362,11 +13364,13 @@ static int i40e_xdp_setup(struct i40e_vsi *vsi, struct bpf_prog *prog,/* Kick start the NAPI context if there is an AF_XDP socket open * on that queue id. This so that receiving will start. */ -if (need_reset && prog) +if (need_reset && prog) {for (i =0 ; i < vsi->num_queue_pairs; i++)if (vsi->xdp_rings[i]->xsk_pool) (void )i40e_xsk_wakeup (vsi->netdev, i,XDP_WAKEUP_RX ); +xdp_features_set_redirect_target (vsi->netdev, true); + }return 0 ; }
@@ -13783,6 +13787,8 @@ static int i40e_config_netdev(struct i40e_vsi *vsi) netdev->hw_enc_features |=NETIF_F_TSO_MANGLEID ; netdev->features &= ~NETIF_F_HW_TC ; + netdev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_XSK_ZEROCOPY ;if (vsi->type ==I40E_VSI_MAIN ) {SET_NETDEV_DEV (netdev, &pf->pdev->dev);
drivers/net/ethernet/intel/ice/ice_main.c +5 -0
@@ -22,6 +22,7 @@#include "ice_eswitch.h" #include "ice_tc_lib.h" #include "ice_vsi_vlan_ops.h" +#include <net/xdp_sock_drv.h> #define DRV_SUMMARY "Intel(R) Ethernet Connection E800 Series Linux Driver"static const char ice_driver_string[] =DRV_SUMMARY ;
@@ -2899,11 +2900,13 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog,if (xdp_ring_err)NL_SET_ERR_MSG_MOD (extack,"Setting up XDP Tx resources failed" ); } +xdp_features_set_redirect_target (vsi->netdev, false);/* reallocate Rx queues that are used for zero-copy */ xdp_ring_err =ice_realloc_zc_buf (vsi, true);if (xdp_ring_err)NL_SET_ERR_MSG_MOD (extack,"Setting up XDP Rx resources failed" ); }else if (ice_is_xdp_ena_vsi (vsi) && !prog) { +xdp_features_clear_redirect_target (vsi->netdev); xdp_ring_err =ice_destroy_xdp_rings (vsi);if (xdp_ring_err)NL_SET_ERR_MSG_MOD (extack,"Freeing XDP Tx resources failed" );
@@ -3446,6 +3449,8 @@ static int ice_cfg_netdev(struct ice_vsi *vsi) np->vsi = vsi;ice_set_netdev_features (netdev); + netdev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_XSK_ZEROCOPY ;ice_set_ops (netdev);
drivers/net/ethernet/intel/igb/igb_main.c +8 -1
@@ -2871,8 +2871,14 @@ static int igb_xdp_setup(struct net_device *dev, struct netdev_bpf *bpf)bpf_prog_put (old_prog);/* bpf is just replaced, RXQ and MTU are already setup */ -if (!need_reset) +if (!need_reset) {return 0 ; + }else { +if (prog) +xdp_features_set_redirect_target (dev, true); +else +xdp_features_clear_redirect_target (dev); + }if (running)igb_open (dev);
@@ -3317,6 +3323,7 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) netdev->priv_flags |=IFF_SUPP_NOFCS ; netdev->priv_flags |=IFF_UNICAST_FLT ; + netdev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT ;/* MTU range: 68 - 9216 */ netdev->min_mtu =ETH_MIN_MTU ;
drivers/net/ethernet/intel/igc/igc_main.c +3 -0
@@ -6533,6 +6533,9 @@ static int igc_probe(struct pci_dev *pdev, netdev->mpls_features |=NETIF_F_HW_CSUM ; netdev->hw_enc_features |= netdev->vlan_features; + netdev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_XSK_ZEROCOPY ; +/* MTU range: 68 - 9216 */ netdev->min_mtu =ETH_MIN_MTU ; netdev->max_mtu =MAX_STD_JUMBO_FRAME_SIZE ;
drivers/net/ethernet/intel/igc/igc_xdp.c +5 -0
@@ -29,6 +29,11 @@ int igc_xdp_set_prog(struct igc_adapter *adapter, struct bpf_prog *prog,if (old_prog)bpf_prog_put (old_prog); +if (prog) +xdp_features_set_redirect_target (dev, true); +else +xdp_features_clear_redirect_target (dev); +if (if_running)igc_open (dev);
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +6 -0
@@ -10301,6 +10301,8 @@ static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog)rcu_assign_pointer (adapter->xdp_prog, old_prog);return -EINVAL ; } +if (!prog) +xdp_features_clear_redirect_target (dev); }else {for (i =0 ; i < adapter->num_rx_queues; i++) (void)xchg(&adapter->rx_ring[i]->xdp_prog,
@@ -10320,6 +10322,7 @@ static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog)if (adapter->xdp_ring[i]->xsk_pool) (void )ixgbe_xsk_wakeup (adapter->netdev, i,XDP_WAKEUP_RX ); +xdp_features_set_redirect_target (dev, true); }return 0 ;
@@ -11017,6 +11020,9 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent) netdev->priv_flags |=IFF_UNICAST_FLT ; netdev->priv_flags |=IFF_SUPP_NOFCS ; + netdev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_XSK_ZEROCOPY ; +/* MTU range: 68 - 9710 */ netdev->min_mtu =ETH_MIN_MTU ; netdev->max_mtu =IXGBE_MAX_JUMBO_FRAME_SIZE - (ETH_HLEN +ETH_FCS_LEN );
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +1 -0
@@ -4634,6 +4634,7 @@ static int ixgbevf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)NETIF_F_HW_VLAN_CTAG_TX ; netdev->priv_flags |=IFF_UNICAST_FLT ; + netdev->xdp_features =NETDEV_XDP_ACT_BASIC ;/* MTU range: 68 - 1504 or 9710 */ netdev->min_mtu =ETH_MIN_MTU ;
drivers/net/ethernet/marvell/mvneta.c +3 -0
@@ -5612,6 +5612,9 @@ static int mvneta_probe(struct platform_device *pdev)NETIF_F_TSO |NETIF_F_RXCSUM ; dev->hw_features |= dev->features; dev->vlan_features |= dev->features; + dev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT |NETDEV_XDP_ACT_RX_SG | +NETDEV_XDP_ACT_NDO_XMIT_SG ; dev->priv_flags |=IFF_LIVE_ADDR_CHANGE ;netif_set_tso_max_segs (dev,MVNETA_MAX_TSO_SEGS );
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +4 -0
@@ -6866,6 +6866,10 @@ static int mvpp2_port_probe(struct platform_device *pdev, dev->vlan_features |= features;netif_set_tso_max_segs (dev,MVPP2_MAX_TSO_SEGS ); + + dev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT ; + dev->priv_flags |=IFF_UNICAST_FLT ;/* MTU range: 68 - 9704 */
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +6 -2
@@ -2512,10 +2512,13 @@ static int otx2_xdp_setup(struct otx2_nic *pf, struct bpf_prog *prog)/* Network stack and XDP shared same rx queues. * Use separate tx queues for XDP and network stack. */ -if (pf->xdp_prog) +if (pf->xdp_prog) { pf->hw.xdp_queues = pf->hw.rx_queues; -else +xdp_features_set_redirect_target (dev, false); + }else { pf->hw.xdp_queues =0 ; +xdp_features_clear_redirect_target (dev); + } pf->hw.tot_tx_queues += pf->hw.xdp_queues;
@@ -2878,6 +2881,7 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id) netdev->watchdog_timeo =OTX2_TX_TIMEOUT ; netdev->netdev_ops = &otx2_netdev_ops; + netdev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT ; netdev->min_mtu =OTX2_MIN_MTU ; netdev->max_mtu =otx2_get_max_mtu (pf);
drivers/net/ethernet/mediatek/mtk_eth_soc.c +6 -0
@@ -4186,6 +4186,12 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)register_netdevice_notifier (&mac->device_notifier); } +if (mtk_page_pool_enabled (eth)) + eth->netdev[id]->xdp_features =NETDEV_XDP_ACT_BASIC | +NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT | +NETDEV_XDP_ACT_NDO_XMIT_SG ; +return 0 ; free_netdev:
drivers/net/ethernet/mellanox/mlx4/en_netdev.c +2 -0
@@ -3416,6 +3416,8 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, priv->rss_hash_fn =ETH_RSS_HASH_TOP ; } + dev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT ; +/* MTU range: 68 - hw-specific max */ dev->min_mtu =ETH_MIN_MTU ; dev->max_mtu = priv->max_mtu;
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +11 -0
@@ -4776,6 +4776,13 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)if (old_prog)bpf_prog_put (old_prog); +if (reset) { +if (prog) +xdp_features_set_redirect_target (netdev, true); +else +xdp_features_clear_redirect_target (netdev); + } +if (!test_bit (MLX5E_STATE_OPENED , &priv->state) || reset) goto unlock;
@@ -5171,6 +5178,10 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev) netdev->features |=NETIF_F_HIGHDMA ; netdev->features |=NETIF_F_HW_VLAN_STAG_FILTER ; + netdev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_XSK_ZEROCOPY | +NETDEV_XDP_ACT_RX_SG ; + netdev->priv_flags |=IFF_UNICAST_FLT ;netif_set_tso_max_size (netdev,GSO_MAX_SIZE );
drivers/net/ethernet/microsoft/mana/mana_en.c +2 -0
@@ -2160,6 +2160,8 @@ static int mana_probe_port(struct mana_context *ac, int port_idx, ndev->hw_features |=NETIF_F_RXHASH ; ndev->features = ndev->hw_features; ndev->vlan_features =0 ; + ndev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT ; err =register_netdev (ndev);if (err) {
drivers/net/ethernet/netronome/nfp/nfp_net_common.c +5 -0
@@ -2529,10 +2529,15 @@ 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 ; + netdev->xdp_features =NETDEV_XDP_ACT_BASIC ; +if (nn->app && nn->app->type->id ==NFP_APP_BPF_NIC ) + 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; + netdev->xdp_features |=NETDEV_XDP_ACT_XSK_ZEROCOPY ;break ;case NFP_NFD_VER_NFDK : netdev->netdev_ops = &nfp_nfdk_netdev_ops;
drivers/net/ethernet/qlogic/qede/qede_main.c +3 -0
@@ -892,6 +892,9 @@ static void qede_init_ndev(struct qede_dev *edev) ndev->hw_features = hw_features; + ndev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT ; +/* MTU range: 46 - 9600 */ ndev->min_mtu =ETH_ZLEN -ETH_HLEN ; ndev->max_mtu =QEDE_MAX_JUMBO_PACKET_SIZE ;
drivers/net/ethernet/sfc/efx.c +4 -0
@@ -1078,6 +1078,10 @@ static int efx_pci_probe(struct pci_dev *pci_dev,pci_info (pci_dev,"Solarflare NIC detected\n" ); + efx->net_dev->xdp_features =NETDEV_XDP_ACT_BASIC | +NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT ; +if (!efx->type->is_vf)efx_probe_vpd_strings (efx);
drivers/net/ethernet/sfc/siena/efx.c +4 -0
@@ -1048,6 +1048,10 @@ static int efx_pci_probe(struct pci_dev *pci_dev,pci_info (pci_dev,"Solarflare NIC detected\n" ); + efx->net_dev->xdp_features =NETDEV_XDP_ACT_BASIC | +NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT ; +if (!efx->type->is_vf)efx_probe_vpd_strings (efx);
drivers/net/ethernet/socionext/netsec.c +3 -0
@@ -2104,6 +2104,9 @@ static int netsec_probe(struct platform_device *pdev)NETIF_F_IP_CSUM |NETIF_F_IPV6_CSUM ; ndev->hw_features = ndev->features; + ndev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT ; + priv->rx_cksum_offload_flag = true; ret =netsec_register_mdio (priv, phy_addr);
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -0
@@ -7145,6 +7145,8 @@ int stmmac_dvr_probe(struct device *device, ndev->hw_features =NETIF_F_SG |NETIF_F_IP_CSUM |NETIF_F_IPV6_CSUM |NETIF_F_RXCSUM ; + ndev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT ; ret =stmmac_tc_init (priv, priv);if (!ret) {
drivers/net/ethernet/ti/cpsw.c +4 -0
@@ -1458,6 +1458,8 @@ static int cpsw_probe_dual_emac(struct cpsw_priv *priv) priv_sl2->emac_port =1 ; cpsw->slaves[1 ].ndev = ndev; ndev->features |=NETIF_F_HW_VLAN_CTAG_FILTER |NETIF_F_HW_VLAN_CTAG_RX ; + ndev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT ; ndev->netdev_ops = &cpsw_netdev_ops; ndev->ethtool_ops = &cpsw_ethtool_ops;
@@ -1635,6 +1637,8 @@ static int cpsw_probe(struct platform_device *pdev) cpsw->slaves[0 ].ndev = ndev; ndev->features |=NETIF_F_HW_VLAN_CTAG_FILTER |NETIF_F_HW_VLAN_CTAG_RX ; + ndev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT ; ndev->netdev_ops = &cpsw_netdev_ops; ndev->ethtool_ops = &cpsw_ethtool_ops;
drivers/net/ethernet/ti/cpsw_new.c +4 -0
@@ -1405,6 +1405,10 @@ static int cpsw_create_ports(struct cpsw_common *cpsw) ndev->features |=NETIF_F_HW_VLAN_CTAG_FILTER |NETIF_F_HW_VLAN_CTAG_RX |NETIF_F_NETNS_LOCAL |NETIF_F_HW_TC ; + ndev->xdp_features =NETDEV_XDP_ACT_BASIC | +NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT ; + ndev->netdev_ops = &cpsw_netdev_ops; ndev->ethtool_ops = &cpsw_ethtool_ops;SET_NETDEV_DEV (ndev, dev);
drivers/net/hyperv/netvsc_drv.c +2 -0
@@ -2559,6 +2559,8 @@ static int netvsc_probe(struct hv_device *dev,netdev_lockdep_set_classes (net); + net->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT ; +/* MTU range: 68 - 1500 or 65521 */ net->min_mtu =NETVSC_MTU_MIN ;if (nvdev->nvsp_version >=NVSP_PROTOCOL_VERSION_2 )
drivers/net/netdevsim/netdev.c +1 -0
@@ -286,6 +286,7 @@ static void nsim_setup(struct net_device *dev)NETIF_F_TSO ; dev->hw_features |=NETIF_F_HW_TC ; dev->max_mtu =ETH_MAX_MTU ; + dev->xdp_features =NETDEV_XDP_ACT_HW_OFFLOAD ; }static int nsim_init_netdevsim (struct netdevsim *ns)
drivers/net/tun.c +5 -0
@@ -1401,6 +1401,11 @@ static void tun_net_initialize(struct net_device *dev)eth_hw_addr_random (dev); +/* Currently tun does not support XDP, only tap does. */ + dev->xdp_features =NETDEV_XDP_ACT_BASIC | +NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT ; +break ; }
drivers/net/veth.c +4 -0
@@ -1686,6 +1686,10 @@ static void veth_setup(struct net_device *dev) dev->hw_enc_features =VETH_FEATURES ; dev->mpls_features =NETIF_F_HW_CSUM |NETIF_F_GSO_SOFTWARE ;netif_set_tso_max_size (dev,GSO_MAX_SIZE ); + + dev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT |NETDEV_XDP_ACT_RX_SG | +NETDEV_XDP_ACT_NDO_XMIT_SG ; }/*
drivers/net/virtio_net.c +4 -0
@@ -3155,7 +3155,10 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,if (i ==0 && !old_prog)virtnet_clear_guest_offloads (vi); } +if (!old_prog) +xdp_features_set_redirect_target (dev, false); }else { +xdp_features_clear_redirect_target (dev); vi->xdp_enabled = false; }
@@ -3785,6 +3788,7 @@ static int virtnet_probe(struct virtio_device *vdev) dev->hw_features |=NETIF_F_GRO_HW ; dev->vlan_features = dev->features; + dev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT ;/* MTU range: 68 - 65535 */ dev->min_mtu =MIN_MTU ;
drivers/net/xen-netfront.c +2 -0
@@ -1741,6 +1741,8 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)* negotiate with the backend regarding supported features. */ netdev->features |= netdev->hw_features; + netdev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT ; netdev->ethtool_ops = &xennet_ethtool_ops; netdev->min_mtu =ETH_MIN_MTU ;
include/net/xdp.h +15 -0
@@ -410,6 +410,21 @@ struct netdev_bpf;void xdp_attachment_setup (struct xdp_attachment_info *info,struct netdev_bpf *bpf); +#if defined(CONFIG_NET ) && defined(CONFIG_BPF_SYSCALL ) +void xdp_features_set_redirect_target (struct net_device *dev,bool support_sg); +void xdp_features_clear_redirect_target (struct net_device *dev); +#else +static inline void +xdp_features_set_redirect_target (struct net_device *dev,bool support_sg) +{ +} + +static inline void +xdp_features_clear_redirect_target (struct net_device *dev) +{ +} +#endif +#define DEV_MAP_BULK_SIZE XDP_BULK_QUEUE_SIZE#define XDP_METADATA_KFUNC_xxx \
net/core/xdp.c +18 -0
@@ -773,3 +773,21 @@ static int __init xdp_metadata_init(void)return register_btf_kfunc_id_set (BPF_PROG_TYPE_XDP , &xdp_metadata_kfunc_set); }late_initcall (xdp_metadata_init); + +void xdp_features_set_redirect_target (struct net_device *dev,bool support_sg) +{ + dev->xdp_features |=NETDEV_XDP_ACT_NDO_XMIT ; +if (support_sg) + dev->xdp_features |=NETDEV_XDP_ACT_NDO_XMIT_SG ; + +call_netdevice_notifiers (NETDEV_XDP_FEAT_CHANGE , dev); +} +EXPORT_SYMBOL_GPL (xdp_features_set_redirect_target); + +void xdp_features_clear_redirect_target (struct net_device *dev) +{ + dev->xdp_features &= ~(NETDEV_XDP_ACT_NDO_XMIT | +NETDEV_XDP_ACT_NDO_XMIT_SG ); +call_netdevice_notifiers (NETDEV_XDP_FEAT_CHANGE , dev); +} +EXPORT_SYMBOL_GPL (xdp_features_clear_redirect_target);
Signature · 1 line
2.39.1
Re: [PATCH v2 bpf-next 2/8] drivers: net: turn on XDP features
Quoted 6 lines · On Wed, 25 Jan 2023 01:33:22 +0100 Lorenzo Bianconi wrote:
A summary of the flags being set for various drivers is given below. Note that
XDP_F_REDIRECT_TARGETandXDP_F_FRAG_TARGETare features that can be turned off and on at runtime. This means that these flags may be set and unset under RTNL lock protection by the driver. Hence,READ_ONCEmust be used by code loading the flag value.
Quoted 7 lines
Also, these flags are not used for synchronization against the availability of XDP resources on a device. It is merely a hint, and hence the read may race with the actual teardown of XDP resources on the device. This may change in the future, e.g. operations taking a reference on the XDP resources of the driver, and in turn inhibiting turning off this flag. However, for now, it can only be used as a hint to check whether device supports becoming a redirection target.
kernel test robot
build botRe: [PATCH v2 bpf-next 2/8] drivers: net: turn on XDP features
In reply to Lorenzo BianconiThank you for the patch! Yet something to improve:
Hi Lorenzo,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on bpf-next/master]
url: https://github.com/intel-lab-lkp/linux/commits/Lorenzo-Bianconi/netdev-genl-create-a-simple-family-for-netdev-stuff/20230125-083645 base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master patch link: https://lore.kernel.org/r/c1171111f8af76da11331277b1e4a930c10f3c30.1674606197.git.lorenzo%40kernel.org patch subject: [PATCH v2 bpf-next 2/8] drivers: net: turn on XDP features config: arc-defconfig (https://download.01.org/0day-ci/archive/20230125/[email protected]/config) compiler: arc-elf-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/7dab4c7d96218eccccedd50e72c84e0ef4de0f4a
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Lorenzo-Bianconi/netdev-genl-create-a-simple-family-for-netdev-stuff/20230125-083645 git checkout 7dab4c7d96218eccccedd50e72c84e0ef4de0f4a
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arc olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arc SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <[email protected]>
All errors (new ones prefixed by >>):
>> net/core/xdp.c:777:6: error: redefinition of 'xdp_features_set_redirect_target'
777 | void xdp_features_set_redirect_target(struct net_device *dev, bool support_sg)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from include/linux/netdevice.h:43,
from include/linux/if_vlan.h:10,
from include/linux/filter.h:20,
from net/core/xdp.c:8:
include/net/xdp.h:418:1: note: previous definition of 'xdp_features_set_redirect_target' with type 'void(struct net_device *, bool)' {aka 'void(struct net_device *, _Bool)'}
418 | xdp_features_set_redirect_target(struct net_device *dev, bool support_sg)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> net/core/xdp.c:787:6: error: redefinition of 'xdp_features_clear_redirect_target' 787 | void xdp_features_clear_redirect_target(struct net_device *dev)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/net/xdp.h:423:1: note: previous definition of 'xdp_features_clear_redirect_target' with type 'void(struct net_device *)'
423 | xdp_features_clear_redirect_target(struct net_device *dev)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/xdp_features_set_redirect_target +777 net/core/xdp.c
776
> 777 void xdp_features_set_redirect_target(struct net_device *dev, bool support_sg)
778 {
779 dev->xdp_features |= NETDEV_XDP_ACT_NDO_XMIT;
780 if (support_sg)
781 dev->xdp_features |= NETDEV_XDP_ACT_NDO_XMIT_SG;
782
783 call_netdevice_notifiers(NETDEV_XDP_FEAT_CHANGE, dev);
784 }
785 EXPORT_SYMBOL_GPL(xdp_features_set_redirect_target);
786
> 787 void xdp_features_clear_redirect_target(struct net_device *dev)Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Re: [PATCH v2 bpf-next 2/8] drivers: net: turn on XDP features
In reply to Lorenzo Bianconi+ Niklas, oss-drivers@corigine
Quoted 16 lines · Lorenzo Bianconi
From: Marek Majtyka <[email protected]>
A summary of the flags being set for various drivers is given below. Note that
XDP_F_REDIRECT_TARGETandXDP_F_FRAG_TARGETare features that can be turned off and on at runtime. This means that these flags may be set and unset under RTNL lock protection by the driver. Hence,READ_ONCEmust be used by code loading the flag value.Also, these flags are not used for synchronization against the availability of XDP resources on a device. It is merely a hint, and hence the read may race with the actual teardown of XDP resources on the device. This may change in the future, e.g. operations taking a reference on the XDP resources of the driver, and in turn inhibiting turning off this flag. However, for now, it can only be used as a hint to check whether device supports becoming a redirection target.
Quoted 8 lines
Turn 'hw-offload' feature flag on for:
- netronome (nfp)
- netdevsim.Turn 'native' and 'zerocopy' features flags on for:
- intel (i40e, ice, ixgbe, igc)
- mellanox (mlx5).
- stmmac
nit: possibly nfp goes in the above list too.
Quoted 38 lines
Turn 'native' features flags on for:
- amazon (ena)
- broadcom (bnxt)
- freescale (dpaa, dpaa2, enetc)
- funeth
- intel (igb)
- marvell (mvneta, mvpp2, octeontx2)
- mellanox (mlx4)
- qlogic (qede)
- sfc
- socionext (netsec)
- ti (cpsw)
- tap
- veth
- xen
-virtio_net.Turn 'basic' (tx, pass, aborted and drop) features flags on for:
- netronome (nfp)
- cavium (thunder)
- hyperv.Turn '
redirect_target' feature flag on for:
- amanzon (ena)
- broadcom (bnxt)
- freescale (dpaa, dpaa2)
- intel (i40e, ice, igb, ixgbe)
- ti (cpsw)
- marvell (mvneta, mvpp2)
- sfc
- socionext (netsec)
- qlogic (qede)
- mellanox (mlx5)
- tap
- veth
-virtio_net
- xen
Quoted 5 lines
Co-developed-by Kumar Kartikeya Dwivedi <[email protected]>Signed-off-by Kumar Kartikeya Dwivedi <[email protected]>Co-developed-by Lorenzo Bianconi <[email protected]>Signed-off-by Lorenzo Bianconi <[email protected]>Signed-off-by Marek Majtyka <[email protected]>
The code below matches my understanding of what was discussed wrt earlier versions of this patchset.
For the nfp driver portion:
Quoted 10 lines
drivers/net/ethernet/netronome/nfp/nfp_net_common.c +2
-0@@ -2529,10 +2529,15 @@ 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 ; + netdev->xdp_features =NETDEV_XDP_ACT_BASIC ; +if (nn->app && nn->app->type->id ==NFP_APP_BPF_NIC )
drivers/net/ethernet/netronome/nfp/nfp_net_common.c static void nfp_net_netdev_init(struct nfp_net *nn) · line 2543
Quoted 10 lines
drivers/net/ethernet/netronome/nfp/nfp_net_common.c +3
-0+ 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; + netdev->xdp_features |=NETDEV_XDP_ACT_XSK_ZEROCOPY ;break ;case NFP_NFD_VER_NFDK : netdev->netdev_ops = &nfp_nfdk_netdev_ops;
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [PATCH v2 bpf-next 2/8] drivers: net: turn on XDP features
In reply to Lorenzo BianconiQuoted 47 lines · Lorenzo Bianconi
From: Marek Majtyka <[email protected]>
A summary of the flags being set for various drivers is given below. Note that
XDP_F_REDIRECT_TARGETandXDP_F_FRAG_TARGETare features that can be turned off and on at runtime. This means that these flags may be set and unset under RTNL lock protection by the driver. Hence,READ_ONCEmust be used by code loading the flag value.Also, these flags are not used for synchronization against the availability of XDP resources on a device. It is merely a hint, and hence the read may race with the actual teardown of XDP resources on the device. This may change in the future, e.g. operations taking a reference on the XDP resources of the driver, and in turn inhibiting turning off this flag. However, for now, it can only be used as a hint to check whether device supports becoming a redirection target.
Turn 'hw-offload' feature flag on for:
- netronome (nfp)
- netdevsim.Turn 'native' and 'zerocopy' features flags on for:
- intel (i40e, ice, ixgbe, igc)
- mellanox (mlx5).
- stmmacTurn 'native' features flags on for:
- amazon (ena)
- broadcom (bnxt)
- freescale (dpaa, dpaa2, enetc)
- funeth
- intel (igb)
- marvell (mvneta, mvpp2, octeontx2)
- mellanox (mlx4)
- qlogic (qede)
- sfc
- socionext (netsec)
- ti (cpsw)
- tap
- veth
- xen
-virtio_net.Turn 'basic' (tx, pass, aborted and drop) features flags on for:
- netronome (nfp)
- cavium (thunder)
- hyperv.
Quoted 15 lines
Turn '
redirect_target' feature flag on for:
- amanzon (ena)
- broadcom (bnxt)
- freescale (dpaa, dpaa2)
- intel (i40e, ice, igb, ixgbe)
- ti (cpsw)
- marvell (mvneta, mvpp2)
- sfc
- socionext (netsec)
- qlogic (qede)
- mellanox (mlx5)
- tap
- veth
-virtio_net
- xen
XDP support for tsnep was merged to net-next last week. So this driver cannot get XDP feature support in bpf-next as it is not there currently. Should I add these flags with a fix afterwards? Or would net-next be the better target for this patch series?
Gerhard
Lorenzo Bianconi
maintainerRe: [PATCH v2 bpf-next 2/8] drivers: net: turn on XDP features
Quoted 64 lines · Lorenzo Bianconi
Quoted 47 lines
From: Marek Majtyka <[email protected]>
A summary of the flags being set for various drivers is given below. Note that
XDP_F_REDIRECT_TARGETandXDP_F_FRAG_TARGETare features that can be turned off and on at runtime. This means that these flags may be set and unset under RTNL lock protection by the driver. Hence,READ_ONCEmust be used by code loading the flag value.Also, these flags are not used for synchronization against the availability of XDP resources on a device. It is merely a hint, and hence the read may race with the actual teardown of XDP resources on the device. This may change in the future, e.g. operations taking a reference on the XDP resources of the driver, and in turn inhibiting turning off this flag. However, for now, it can only be used as a hint to check whether device supports becoming a redirection target.
Turn 'hw-offload' feature flag on for:
- netronome (nfp)
- netdevsim.Turn 'native' and 'zerocopy' features flags on for:
- intel (i40e, ice, ixgbe, igc)
- mellanox (mlx5).
- stmmacTurn 'native' features flags on for:
- amazon (ena)
- broadcom (bnxt)
- freescale (dpaa, dpaa2, enetc)
- funeth
- intel (igb)
- marvell (mvneta, mvpp2, octeontx2)
- mellanox (mlx4)
- qlogic (qede)
- sfc
- socionext (netsec)
- ti (cpsw)
- tap
- veth
- xen
-virtio_net.Turn 'basic' (tx, pass, aborted and drop) features flags on for:
- netronome (nfp)
- cavium (thunder)
- hyperv.Quoted 15 lines
Turn '
redirect_target' feature flag on for:
- amanzon (ena)
- broadcom (bnxt)
- freescale (dpaa, dpaa2)
- intel (i40e, ice, igb, ixgbe)
- ti (cpsw)
- marvell (mvneta, mvpp2)
- sfc
- socionext (netsec)
- qlogic (qede)
- mellanox (mlx5)
- tap
- veth
-virtio_net
- xen
Quoted 4 lines
XDP support for tsnep was merged to net-next last week. So this driver cannot get XDP feature support in bpf-next as it is not there currently. Should I add these flags with a fix afterwards? Or would net-next be the better target for this patch series?
It is better to target this series to bpf-next I guess since there are some libbpf and bpf changes.
I would say we can fix tsnep with a follow-up patch or I can add it to the series if bpf-next will be rebased before the series is merged, it depends on the upstream discussion.
Regards,
Lorenzo
Quoted 2 lines
Gerhard
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Lorenzo Bianconi
maintainerRe: [PATCH v2 bpf-next 2/8] drivers: net: turn on XDP features
In reply to Gerhard EnglederQuoted 64 lines · Lorenzo Bianconi
Quoted 47 lines
From: Marek Majtyka <[email protected]>
A summary of the flags being set for various drivers is given below. Note that
XDP_F_REDIRECT_TARGETandXDP_F_FRAG_TARGETare features that can be turned off and on at runtime. This means that these flags may be set and unset under RTNL lock protection by the driver. Hence,READ_ONCEmust be used by code loading the flag value.Also, these flags are not used for synchronization against the availability of XDP resources on a device. It is merely a hint, and hence the read may race with the actual teardown of XDP resources on the device. This may change in the future, e.g. operations taking a reference on the XDP resources of the driver, and in turn inhibiting turning off this flag. However, for now, it can only be used as a hint to check whether device supports becoming a redirection target.
Turn 'hw-offload' feature flag on for:
- netronome (nfp)
- netdevsim.Turn 'native' and 'zerocopy' features flags on for:
- intel (i40e, ice, ixgbe, igc)
- mellanox (mlx5).
- stmmacTurn 'native' features flags on for:
- amazon (ena)
- broadcom (bnxt)
- freescale (dpaa, dpaa2, enetc)
- funeth
- intel (igb)
- marvell (mvneta, mvpp2, octeontx2)
- mellanox (mlx4)
- qlogic (qede)
- sfc
- socionext (netsec)
- ti (cpsw)
- tap
- veth
- xen
-virtio_net.Turn 'basic' (tx, pass, aborted and drop) features flags on for:
- netronome (nfp)
- cavium (thunder)
- hyperv.Quoted 15 lines
Turn '
redirect_target' feature flag on for:
- amanzon (ena)
- broadcom (bnxt)
- freescale (dpaa, dpaa2)
- intel (i40e, ice, igb, ixgbe)
- ti (cpsw)
- marvell (mvneta, mvpp2)
- sfc
- socionext (netsec)
- qlogic (qede)
- mellanox (mlx5)
- tap
- veth
-virtio_net
- xen
Quoted 4 lines
XDP support for tsnep was merged to net-next last week. So this driver cannot get XDP feature support in bpf-next as it is not there currently. Should I add these flags with a fix afterwards? Or would net-next be the better target for this patch series?
bpf-next has been rebased on top of net-next so we can add tsnep support to the series. Do you think the patch below is fine?
Regards,
Lorenzo
drivers/net/ethernet/engleder/tsnep_main.c +4 -0
@@ -1926,6 +1926,10 @@ static int tsnep_probe(struct platform_device *pdev) netdev->features =NETIF_F_SG ; netdev->hw_features = netdev->features |NETIF_F_LOOPBACK ; + netdev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT | +NETDEV_XDP_ACT_NDO_XMIT_SG ; +/* carrier off reporting is important to ethtool even BEFORE open */ netif_carrier_off (netdev);
Quoted 2 lines
Gerhard
Re: [PATCH v2 bpf-next 2/8] drivers: net: turn on XDP features
Quoted 87 lines · Lorenzo Bianconi
Quoted 64 lines · Lorenzo Bianconi
Quoted 47 lines
From: Marek Majtyka <[email protected]>
A summary of the flags being set for various drivers is given below. Note that
XDP_F_REDIRECT_TARGETandXDP_F_FRAG_TARGETare features that can be turned off and on at runtime. This means that these flags may be set and unset under RTNL lock protection by the driver. Hence,READ_ONCEmust be used by code loading the flag value.Also, these flags are not used for synchronization against the availability of XDP resources on a device. It is merely a hint, and hence the read may race with the actual teardown of XDP resources on the device. This may change in the future, e.g. operations taking a reference on the XDP resources of the driver, and in turn inhibiting turning off this flag. However, for now, it can only be used as a hint to check whether device supports becoming a redirection target.
Turn 'hw-offload' feature flag on for:
- netronome (nfp)
- netdevsim.Turn 'native' and 'zerocopy' features flags on for:
- intel (i40e, ice, ixgbe, igc)
- mellanox (mlx5).
- stmmacTurn 'native' features flags on for:
- amazon (ena)
- broadcom (bnxt)
- freescale (dpaa, dpaa2, enetc)
- funeth
- intel (igb)
- marvell (mvneta, mvpp2, octeontx2)
- mellanox (mlx4)
- qlogic (qede)
- sfc
- socionext (netsec)
- ti (cpsw)
- tap
- veth
- xen
-virtio_net.Turn 'basic' (tx, pass, aborted and drop) features flags on for:
- netronome (nfp)
- cavium (thunder)
- hyperv.Quoted 15 lines
Turn '
redirect_target' feature flag on for:
- amanzon (ena)
- broadcom (bnxt)
- freescale (dpaa, dpaa2)
- intel (i40e, ice, igb, ixgbe)
- ti (cpsw)
- marvell (mvneta, mvpp2)
- sfc
- socionext (netsec)
- qlogic (qede)
- mellanox (mlx5)
- tap
- veth
-virtio_net
- xenQuoted 4 lines
XDP support for tsnep was merged to net-next last week. So this driver cannot get XDP feature support in bpf-next as it is not there currently. Should I add these flags with a fix afterwards? Or would net-next be the better target for this patch series?
bpf-next has been rebased on top of net-next so we can add tsnep support to the series. Do you think the patch below is fine?
Regards,
Lorenzodrivers/net/ethernet/engleder/tsnep_main.c +1
-0@@ -1926,6 +1926,10 @@ static int tsnep_probe(struct platform_device *pdev) netdev->features =NETIF_F_SG ; netdev->hw_features = netdev->features |NETIF_F_LOOPBACK ; + netdev->xdp_features =NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT |
drivers/net/ethernet/engleder/tsnep_main.c static int tsnep_probe(struct platform_device *pdev) · line 1932
Quoted 3 lines
drivers/net/ethernet/engleder/tsnep_main.c +3
-0+NETDEV_XDP_ACT_NDO_XMIT | +NETDEV_XDP_ACT_NDO_XMIT_SG ; +
Looks good. Thanks!
Gerhard
Lorenzo Bianconi
maintainerPATCH v2 3/8 xsk: add usage of XDP features flags
In reply to Lorenzo BianconiFrom: Marek Majtyka <[email protected]>
Change necessary condition check for XSK from ndo functions to xdp features flags.
--- net/xdp/xsk_buff_pool.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/xdp/xsk_buff_pool.c +5 -2
@@ -140,6 +140,10 @@ static void xp_disable_drv_zc(struct xsk_buff_pool *pool) } } +#define NETDEV_XDP_ACT_ZC (NETDEV_XDP_ACT_BASIC | \ + NETDEV_XDP_ACT_REDIRECT | \ + NETDEV_XDP_ACT_XSK_ZEROCOPY) +int xp_assign_dev (struct xsk_buff_pool *pool,struct net_device *netdev,u16 queue_id,u16 flags) {
@@ -178,8 +182,7 @@ int xp_assign_dev(struct xsk_buff_pool *pool,/* For copy-mode, we are done. */ return 0 ; -if (!netdev->netdev_ops->ndo_bpf || - !netdev->netdev_ops->ndo_xsk_wakeup) { +if ((netdev->xdp_features &NETDEV_XDP_ACT_ZC ) !=NETDEV_XDP_ACT_ZC ) { err = -EOPNOTSUPP ; goto err_unreg_pool; }
Signature · 6 lines
2.39.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Lorenzo Bianconi
maintainerPATCH v2 4/8 libbpf: add the capability to specify netlink proto in libbpf_netlink_send_recv
In reply to Lorenzo BianconiThis is a preliminary patch in order to introduce netlink_generic protocol support to libbpf.
--- tools/lib/bpf/netlink.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
tools/lib/bpf/netlink.c +12 -10
@@ -41,7 +41,7 @@ struct xdp_id_md {struct xdp_link_info info; }; -static int libbpf_netlink_open (__u32 *nl_pid) +static int libbpf_netlink_open (__u32 *nl_pid,int proto) {struct sockaddr_nl sa;socklen_t addrlen;
@@ -51,7 +51,7 @@ static int libbpf_netlink_open(__u32 *nl_pid)memset (&sa,0 ,sizeof (sa)); sa.nl_family =AF_NETLINK ; - sock =socket (AF_NETLINK ,SOCK_RAW |SOCK_CLOEXEC ,NETLINK_ROUTE ); + sock =socket (AF_NETLINK ,SOCK_RAW |SOCK_CLOEXEC , proto);if (sock <0 )return -errno;
@@ -212,14 +212,14 @@ static int libbpf_netlink_recv(int sock, __u32 nl_pid, int seq, }static int libbpf_netlink_send_recv (struct libbpf_nla_req *req, -__dump_nlmsg_t parse_msg, +int proto,__dump_nlmsg_t parse_msg,libbpf_dump_nlmsg_t parse_attr,void *cookie) {__u32 nl_pid =0 ;int sock, ret; - sock =libbpf_netlink_open (&nl_pid); + sock =libbpf_netlink_open (&nl_pid, proto);if (sock <0 )return sock;
@@ -271,7 +271,7 @@ static int __bpf_set_link_xdp_fd_replace(int ifindex, int fd, int old_fd, }nlattr_end_nested (&req, nla); -return libbpf_netlink_send_recv (&req,NULL ,NULL ,NULL ); +return libbpf_netlink_send_recv (&req,NETLINK_ROUTE ,NULL ,NULL ,NULL ); }int bpf_xdp_attach (int ifindex,int prog_fd,__u32 flags,const struct bpf_xdp_attach_opts *opts)
@@ -382,7 +382,7 @@ int bpf_xdp_query(int ifindex, int xdp_flags, struct bpf_xdp_query_opts *opts) xdp_id.ifindex = ifindex; xdp_id.flags = xdp_flags; - err =libbpf_netlink_send_recv (&req, __dump_link_nlmsg, + err =libbpf_netlink_send_recv (&req,NETLINK_ROUTE , __dump_link_nlmsg, get_xdp_info, &xdp_id);if (err)return libbpf_err (err);
@@ -493,7 +493,7 @@ static int tc_qdisc_modify(struct bpf_tc_hook *hook, int cmd, int flags)if (ret <0 )return ret; -return libbpf_netlink_send_recv (&req,NULL ,NULL ,NULL ); +return libbpf_netlink_send_recv (&req,NETLINK_ROUTE ,NULL ,NULL ,NULL ); }static int tc_qdisc_create_excl (struct bpf_tc_hook *hook)
@@ -673,7 +673,8 @@ int bpf_tc_attach(const struct bpf_tc_hook *hook, struct bpf_tc_opts *opts) info.opts = opts; - ret =libbpf_netlink_send_recv (&req, get_tc_info,NULL , &info); + ret =libbpf_netlink_send_recv (&req,NETLINK_ROUTE , get_tc_info,NULL , + &info);if (ret <0 )return libbpf_err (ret);if (!info.processed)
@@ -739,7 +740,7 @@ static int __bpf_tc_detach(const struct bpf_tc_hook *hook,return ret; } -return libbpf_netlink_send_recv (&req,NULL ,NULL ,NULL ); +return libbpf_netlink_send_recv (&req,NETLINK_ROUTE ,NULL ,NULL ,NULL ); } int bpf_tc_detach(const struct bpf_tc_hook *hook,
@@ -804,7 +805,8 @@ int bpf_tc_query(const struct bpf_tc_hook *hook, struct bpf_tc_opts *opts) info.opts = opts; - ret =libbpf_netlink_send_recv (&req, get_tc_info,NULL , &info); + ret =libbpf_netlink_send_recv (&req,NETLINK_ROUTE , get_tc_info,NULL , + &info);if (ret <0 )return libbpf_err (ret);if (!info.processed)
Signature · 6 lines
2.39.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Lorenzo Bianconi
maintainerPATCH v2 5/8 libbpf: add API to get XDP/XSK supported features
In reply to Lorenzo BianconiExtend bpf_xdp_query routine in order to get XDP/XSK supported features of netdev over route netlink interface.
Extend libbpf netlink implementation in order to support netlink_generic protocol.
--- tools/lib/bpf/libbpf.h | 3 +- tools/lib/bpf/netlink.c | 99 +++++++++++++++++++++++++++++++++++++++++ tools/lib/bpf/nlattr.h | 12 +++++ 3 files changed, 113 insertions(+), 1 deletion(-)
tools/lib/bpf/libbpf.h +2 -1
@@ -982,9 +982,10 @@ struct bpf_xdp_query_opts {__u32 hw_prog_id;/* output */ __u32 skb_prog_id;/* output */ __u8 attach_mode;/* output */ +__u64 fflags;/* output */ size_t :0; }; -#define bpf_xdp_query_opts__last_field attach_mode +#define bpf_xdp_query_opts__last_field fflags LIBBPF_API int bpf_xdp_attach(int ifindex, int prog_fd, __u32 flags,const struct bpf_xdp_attach_opts *opts);
tools/lib/bpf/netlink.c +99 -0
129 lines not on this page · raw message
tools/lib/bpf/nlattr.h +12 -0
@@ -14,6 +14,7 @@#include <errno.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> +#include <linux/genetlink.h> /* avoid multiple definition of netlink features */ #define __LINUX_NETLINK_H
@@ -58,6 +59,7 @@ struct libbpf_nla_req {union {struct ifinfomsg ifinfo;struct tcmsg tc; +struct genlmsghdr gnl; };char buf[128 ]; };
@@ -89,11 +91,21 @@ static inline uint8_t libbpf_nla_getattr_u8(const struct nlattr *nla)return *(uint8_t *)libbpf_nla_data (nla); } +static inline uint16_t libbpf_nla_getattr_u16 (const struct nlattr *nla) +{ +return *(uint16_t *)libbpf_nla_data (nla); +} +static inline uint32_t libbpf_nla_getattr_u32 (const struct nlattr *nla) {return *(uint32_t *)libbpf_nla_data (nla); } +static inline uint64_t libbpf_nla_getattr_u64 (const struct nlattr *nla) +{ +return *(uint64_t *)libbpf_nla_data (nla); +} +static inline const char *libbpf_nla_getattr_str (const struct nlattr *nla) {return (const char *)libbpf_nla_data (nla);
Signature · 6 lines
2.39.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Lorenzo Bianconi
maintainerPATCH v2 6/8 bpf: devmap: check XDP features in __xdp_enqueue routine
In reply to Lorenzo BianconiCheck if the destination device implements ndo_xdp_xmit callback relying on NETDEV_XDP_ACT_NDO_XMIT flags. Moreover, check if the destination device supports XDP non-linear frame in __xdp_enqueue and is_valid_dst routines. This patch allows to perform XDP_REDIRECT on non-linear XDP buffers.
--- kernel/bpf/devmap.c | 16 +++++++++++++--- net/core/filter.c | 13 +++++-------- 2 files changed, 18 insertions(+), 11 deletions(-)
kernel/bpf/devmap.c +13 -3
@@ -474,7 +474,11 @@ static inline int __xdp_enqueue(struct net_device *dev, struct xdp_frame *xdpf, {int err; -if (!dev->netdev_ops->ndo_xdp_xmit) +if (!(dev->xdp_features &NETDEV_XDP_ACT_NDO_XMIT )) +return -EOPNOTSUPP ; + +if (unlikely (!(dev->xdp_features &NETDEV_XDP_ACT_NDO_XMIT_SG ) && +xdp_frame_has_frags (xdpf)))return -EOPNOTSUPP ; err =xdp_ok_fwd_dev (dev,xdp_get_frame_len (xdpf));
@@ -532,8 +536,14 @@ int dev_map_enqueue(struct bpf_dtab_netdev *dst, struct xdp_frame *xdpf,static bool is_valid_dst (struct bpf_dtab_netdev *obj,struct xdp_frame *xdpf) { -if (!obj || - !obj->dev->netdev_ops->ndo_xdp_xmit) +if (!obj) +return false; + +if (!(obj->dev->xdp_features &NETDEV_XDP_ACT_NDO_XMIT )) +return false; + +if (unlikely (!(obj->dev->xdp_features &NETDEV_XDP_ACT_NDO_XMIT_SG ) && +xdp_frame_has_frags (xdpf)))return false;if (xdp_ok_fwd_dev (obj->dev,xdp_get_frame_len (xdpf)))
net/core/filter.c +5 -8
@@ -4314,16 +4314,13 @@ int xdp_do_redirect(struct net_device *dev, struct xdp_buff *xdp,struct bpf_redirect_info *ri =this_cpu_ptr (&bpf_redirect_info);enum bpf_map_type map_type = ri->map_type; -/* XDP_REDIRECT is not fully supported yet for xdp frags since -* not all XDP capable drivers can map non-linear xdp_frame in -* ndo_xdp_xmit. -*/ -if (unlikely (xdp_buff_has_frags (xdp) && - map_type !=BPF_MAP_TYPE_CPUMAP )) -return -EOPNOTSUPP ; +if (map_type ==BPF_MAP_TYPE_XSKMAP ) { +/* XDP_REDIRECT is not supported AF_XDP yet. */ +if (unlikely (xdp_buff_has_frags (xdp))) +return -EOPNOTSUPP ; -if (map_type ==BPF_MAP_TYPE_XSKMAP )return __xdp_do_redirect_xsk (ri, dev, xdp, xdp_prog); + }return __xdp_do_redirect_frame (ri, dev,xdp_convert_buff_to_frame (xdp), xdp_prog);
Signature · 6 lines
2.39.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [PATCH v2 bpf-next 6/8] bpf: devmap: check XDP features in __xdp_enqueue routine
Quoted 5 lines · Lorenzo Bianconi
Check if the destination device implements
ndo_xdp_xmitcallback relying onNETDEV_XDP_ACT_NDO_XMITflags. Moreover, check if the destination device supports XDP non-linear frame in__xdp_enqueueandis_valid_dstroutines. This patch allows to performXDP_REDIRECTon non-linear XDP buffers.
Quoted 8 lines
Co-developed-by Kumar Kartikeya Dwivedi <[email protected]>Signed-off-by Kumar Kartikeya Dwivedi <[email protected]>Signed-off-by Lorenzo Bianconi <[email protected]>--- kernel/bpf/devmap.c | 16 +++++++++++++--- net/core/filter.c | 13 +++++-------- 2 files changed, 18 insertions(+), 11 deletions(-)
LGTM
kernel/bpf/devmap.c static inline int __xdp_enqueue(struct net_device *dev, struct xdp_frame *xdpf, · line 478
Quoted 11 lines
kernel/bpf/devmap.c +2
-1@@ -474,7 +474,11 @@ static inline int __xdp_enqueue(struct net_device *dev, struct xdp_frame *xdpf, {int err; -if (!dev->netdev_ops->ndo_xdp_xmit) +if (!(dev->xdp_features &NETDEV_XDP_ACT_NDO_XMIT )) +return -EOPNOTSUPP ;
Good: dev->netdev_ops and dev->xdp_features are on same cacheline.
This means dev->netdev_ops will be hot, once we need to deref netdev_ops->ndo_xdp_xmit, which only happens as part of bulking towards driver.
kernel/bpf/devmap.c static inline int __xdp_enqueue(struct net_device *dev, struct xdp_frame *xdpf, · line 481
Quoted 3 lines
kernel/bpf/devmap.c +3
-0+ +if (unlikely (!(dev->xdp_features &NETDEV_XDP_ACT_NDO_XMIT_SG ) && +xdp_frame_has_frags (xdpf)))
Good: xdp_frame_has_frags() look at xdpf->flags and avoids deref of shared_info area.
Quoted 25 lines
kernel/bpf/devmap.c +8
-2return -EOPNOTSUPP ; err =xdp_ok_fwd_dev (dev,xdp_get_frame_len (xdpf));@@ -532,8 +536,14 @@ int dev_map_enqueue(struct bpf_dtab_netdev *dst, struct xdp_frame *xdpf,static bool is_valid_dst (struct bpf_dtab_netdev *obj,struct xdp_frame *xdpf) { -if (!obj || - !obj->dev->netdev_ops->ndo_xdp_xmit) +if (!obj) +return false; + +if (!(obj->dev->xdp_features &NETDEV_XDP_ACT_NDO_XMIT )) +return false; + +if (unlikely (!(obj->dev->xdp_features &NETDEV_XDP_ACT_NDO_XMIT_SG ) && +xdp_frame_has_frags (xdpf)))return false;if (xdp_ok_fwd_dev (obj->dev,xdp_get_frame_len (xdpf)))net/core/filter.c +0
-0
net/core/filter.c int xdp_do_redirect(struct net_device *dev, struct xdp_buff *xdp, · line 4323
Quoted 10 lines
net/core/filter.c +0
-7@@ -4314,16 +4314,13 @@ int xdp_do_redirect(struct net_device *dev, struct xdp_buff *xdp,struct bpf_redirect_info *ri =this_cpu_ptr (&bpf_redirect_info);enum bpf_map_type map_type = ri->map_type; -/* XDP_REDIRECT is not fully supported yet for xdp frags since -* not all XDP capable drivers can map non-linear xdp_frame in -* ndo_xdp_xmit. -*/ -if (unlikely (xdp_buff_has_frags (xdp) && - map_type !=BPF_MAP_TYPE_CPUMAP )) -return -EOPNOTSUPP ;
Nice to see this limitation being lifted :-)
net/core/filter.c int xdp_do_redirect(struct net_device *dev, struct xdp_buff *xdp, · line 4326
Quoted 11 lines
net/core/filter.c +5
-1+if (map_type ==BPF_MAP_TYPE_XSKMAP ) { +/* XDP_REDIRECT is not supported AF_XDP yet. */ +if (unlikely (xdp_buff_has_frags (xdp))) +return -EOPNOTSUPP ; -if (map_type ==BPF_MAP_TYPE_XSKMAP )return __xdp_do_redirect_xsk (ri, dev, xdp, xdp_prog); + }return __xdp_do_redirect_frame (ri, dev,xdp_convert_buff_to_frame (xdp), xdp_prog);
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Lorenzo Bianconi
maintainerPATCH v2 7/8 selftests/bpf: add test for bpf_xdp_query xdp-features support
In reply to Lorenzo BianconiIntroduce a self-test to verify libbpf bpf_xdp_query capability to dump the xdp-features supported by the device (lo and veth in this case).
--- .../bpf/prog_tests/xdp_do_redirect.c | 27 ++++++++++++++++++- .../selftests/bpf/prog_tests/xdp_info.c | 8 ++++++ 2 files changed, 34 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c +26 -1
@@ -4,10 +4,12 @@#include <net/if.h> #include <linux/if_ether.h> #include <linux/if_packet.h> +#include <linux/if_link.h> #include <linux/ipv6.h> #include <linux/in6.h> #include <linux/udp.h> #include <bpf/bpf_endian.h> +#include <uapi/linux/netdev.h> #include "test_xdp_do_redirect.skel.h" #define SYS (fmt, ...) \
@@ -92,7 +94,7 @@ void test_xdp_do_redirect(void)struct test_xdp_do_redirect *skel =NULL ;struct nstoken *nstoken =NULL ;struct bpf_link *link; - +LIBBPF_OPTS (bpf_xdp_query_opts, query_opts);struct xdp_md ctx_in = { .data =sizeof (__u32), .data_end =sizeof (data) }; DECLARE_LIBBPF_OPTS(bpf_test_run_opts, opts,
@@ -153,6 +155,29 @@ void test_xdp_do_redirect(void) !ASSERT_NEQ(ifindex_dst, 0, "ifindex_dst")) goto out; +/* Check xdp features supported by veth driver */ + err =bpf_xdp_query (ifindex_src,XDP_FLAGS_DRV_MODE , &query_opts); +if (!ASSERT_OK (err,"veth_src bpf_xdp_query" )) + goto out; + +if (!ASSERT_EQ (query_opts.fflags, +NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT |NETDEV_XDP_ACT_RX_SG | +NETDEV_XDP_ACT_NDO_XMIT_SG , +"veth_src query_opts.fflags" )) + goto out; + + err =bpf_xdp_query (ifindex_dst,XDP_FLAGS_DRV_MODE , &query_opts); +if (!ASSERT_OK (err,"veth_dst bpf_xdp_query" )) + goto out; + +if (!ASSERT_EQ (query_opts.fflags, +NETDEV_XDP_ACT_BASIC |NETDEV_XDP_ACT_REDIRECT | +NETDEV_XDP_ACT_NDO_XMIT |NETDEV_XDP_ACT_RX_SG | +NETDEV_XDP_ACT_NDO_XMIT_SG , +"veth_dst query_opts.fflags" )) + goto out; +memcpy (skel->rodata->expect_dst, &pkt_udp.eth.h_dest,ETH_ALEN ); skel->rodata->ifindex_out = ifindex_src;/* redirect back to the same iface */ skel->rodata->ifindex_in = ifindex_src;
tools/testing/selftests/bpf/prog_tests/xdp_info.c +8 -0
@@ -8,6 +8,7 @@ void serial_test_xdp_info(void) {__u32 len =sizeof (struct bpf_prog_info ), duration =0 , prog_id;const char *file ="./xdp_dummy.bpf.o" ; +LIBBPF_OPTS (bpf_xdp_query_opts, opts);struct bpf_prog_info info = {};struct bpf_object *obj;int err, prog_fd;
@@ -61,6 +62,13 @@ void serial_test_xdp_info(void)if (CHECK (prog_id,"prog_id_drv" ,"unexpected prog_id=%u\n" , prog_id)) goto out; +/* Check xdp features supported by lo device */ + opts.fflags = ~0 ; + err =bpf_xdp_query (IFINDEX_LO ,XDP_FLAGS_DRV_MODE , &opts); +if (!ASSERT_OK (err,"bpf_xdp_query" )) + goto out; + +ASSERT_EQ (opts.fflags,0 ,"opts.fflags" ); out:bpf_xdp_detach (IFINDEX_LO ,0 ,NULL ); out_close:
Signature · 6 lines
2.39.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Lorenzo Bianconi
maintainerPATCH v2 8/8 selftests/bpf: introduce XDP compliance test tool
In reply to Lorenzo BianconiIntroduce xdp_features tool in order to test XDP features supported by the NIC and match them against advertised ones.
In order to test supported/advertised XDP features, xdp_features must run on the Device Under Test (DUT) and on a Tester device. xdp_features opens a control TCP channel between DUT and Tester devices to send control commands from Tester to the DUT and a UDP data channel where the Tester sends UDP 'echo' packets and the DUT is expected to reply back with the same packet. DUT installs multiple XDP programs on the NIC to test XDP capabilities and reports back to the Tester some XDP stats. Currently xdp_features supports the following XDP features:
- XDP_DROP
- XDP_PASS
- XDP_TX
- XDP_REDIRECT
- XDP_REDIRECT_TARGET
--- tools/testing/selftests/bpf/.gitignore | 1 + tools/testing/selftests/bpf/Makefile | 11 +- .../selftests/bpf/progs/xdp_features.c | 249 ++++++ .../selftests/bpf/test_xdp_features.sh | 99 +++ tools/testing/selftests/bpf/xdp_features.c | 736 ++++++++++++++++++ tools/testing/selftests/bpf/xdp_features.h | 33 + 6 files changed, 1127 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/xdp_features.c create mode 100755 tools/testing/selftests/bpf/test_xdp_features.sh create mode 100644 tools/testing/selftests/bpf/xdp_features.c create mode 100644 tools/testing/selftests/bpf/xdp_features.h
tools/testing/selftests/bpf/.gitignore +1 -0
@@ -48,3 +48,4 @@ xskxceiver xdp_redirect_multi xdp_synproxy xdp_hw_metadata +xdp_features
tools/testing/selftests/bpf/Makefile +9 -2
@@ -73,7 +73,8 @@ TEST_PROGS := test_kmod.sh \ test_bpftool.sh \ test_bpftool_metadata.sh \ test_doc_build.sh \ - test_xsk.sh + test_xsk.sh \ + test_xdp_features.sh TEST_PROGS_EXTENDED := with_addr.sh \ with_tunnels.sh ima_setup.sh verify_sig_setup.sh \
@@ -83,7 +84,8 @@ TEST_PROGS_EXTENDED := with_addr.sh \ TEST_GEN_PROGS_EXTENDED = test_sock_addr test_skb_cgroup_id_user \ flow_dissector_load test_flow_dissector test_tcp_check_syncookie_user \ test_lirc_mode2_user xdping test_cpp runqslower bench bpf_testmod.ko \ - xskxceiver xdp_redirect_multi xdp_synproxy veristat xdp_hw_metadata + xskxceiver xdp_redirect_multi xdp_synproxy veristat xdp_hw_metadata \ + xdp_features TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read $(OUTPUT)/sign-file TEST_GEN_FILES += liburandom_read.so
@@ -384,6 +386,7 @@ test_subskeleton_lib.skel.h-deps := test_subskeleton_lib2.bpf.o test_subskeleton test_usdt.skel.h-deps := test_usdt.bpf.o test_usdt_multispec.bpf.o xsk_xdp_progs.skel.h-deps := xsk_xdp_progs.bpf.o xdp_hw_metadata.skel.h-deps := xdp_hw_metadata.bpf.o +xdp_features.skel.h-deps := xdp_features.bpf.o LINKED_BPF_SRCS := $(patsubst %.bpf.o,%.c,$(foreach skel,$(LINKED_SKELS),$($(skel)-deps)))
@@ -585,6 +588,10 @@ $(OUTPUT)/xdp_hw_metadata: xdp_hw_metadata.c $(OUTPUT)/network_helpers.o $(OUTPU $(call msg,BINARY,,$@) $(Q)$(CC) $(CFLAGS) $(filter %.a %.o %.c,$^) $(LDLIBS) -o $@ +$(OUTPUT)/xdp_features: xdp_features.c $(OUTPUT)/xdp_features.skel.h | $(OUTPUT) + $(call msg,BINARY,,$@) + $(Q)$(CC) $(CFLAGS) $(filter %.a %.o %.c,$^) $(LDLIBS) -o $@ + # Make sure we are able to include and link libbpf against c++. $(OUTPUT)/test_cpp: test_cpp.cpp $(OUTPUT)/test_core_extern.skel.h $(BPFOBJ) $(call msg,CXX,,$@)
tools/testing/selftests/bpf/progs/xdp_features.c new file +249 -0
249 lines not on this page · raw message
tools/testing/selftests/bpf/test_xdp_features.sh new file +99 -0
99 lines not on this page · raw message
tools/testing/selftests/bpf/xdp_features.c new file +736 -0
736 lines not on this page · raw message
tools/testing/selftests/bpf/xdp_features.h new file +33 -0
@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* test commands */ +enum test_commands { +CMD_STOP ,/* CMD */ +CMD_START ,/* CMD + xdp feature */ +CMD_ECHO ,/* CMD */ +CMD_ACK ,/* CMD + data */ +CMD_GET_XDP_CAP ,/* CMD */ +CMD_GET_STATS ,/* CMD */ +}; + +#define DUT_CTRL_PORT 12345 +#define DUT_ECHO_PORT 12346 + +struct tlv_hdr { +__be16 type; +__be16 len; +__be32 data[]; +}; + +enum { +XDP_FEATURE_ABORTED , +XDP_FEATURE_DROP , +XDP_FEATURE_PASS , +XDP_FEATURE_TX , +XDP_FEATURE_REDIRECT , +XDP_FEATURE_NDO_XMIT , +XDP_FEATURE_XSK_ZEROCOPY , +XDP_FEATURE_HW_OFFLOAD , +XDP_FEATURE_RX_SG , +XDP_FEATURE_NDO_XMIT_SG , +};
Signature · 6 lines
2.39.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan