From patchwork Wed Feb 1 10:24:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1735460 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=g796e0ep; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P6JBp4WP3z23j9 for ; Wed, 1 Feb 2023 21:32:18 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 08AC581D3A; Wed, 1 Feb 2023 10:32:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 08AC581D3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1675247537; bh=ZZB+tly9XUIgh1Q92lA6dme0Rbocgz4woy07QamdRQk=; h=From:To:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:Cc:From; b=g796e0eplvZUgGjB701NtmjFAK9BxixpasOnrr9OO0TY/DLj3u+1N/HzueVOrBgRn PBuWPkIJ/lxRuRzHMeJYckVUhSxVRDaGbCYFPcQIjKqkIZRdBG76PTOl1f/+Z5bzo0 ooIBZUJHn3ZOX4YSTZPbNPlMhnsK04fQf1AlBxUwTWrvY2NyP1QDdmryfm/q9vcl9p 8EHHKHiywT87mVQgZ2G35J4cOflxPr/tbbr+yg3jx1WWX0m5tfpEzyNgv54dWOR9i5 YR5yIuxq9Z+b9aTYr2+lGKrzHK7yv9MSruEDI9xUf4CIAeM4g2bIiBxPDskLuczTLn Kb1EB9BQhaKFQ== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kWewgdPObLNi; Wed, 1 Feb 2023 10:32:16 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id CA3FF8139E; Wed, 1 Feb 2023 10:32:15 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org CA3FF8139E X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 567AE1BF59C for ; Wed, 1 Feb 2023 10:32:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 3D54E408D8 for ; Wed, 1 Feb 2023 10:32:10 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 3D54E408D8 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qhgYHDt-mYcO for ; Wed, 1 Feb 2023 10:32:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 5F04C408D7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by smtp2.osuosl.org (Postfix) with ESMTPS id 5F04C408D7 for ; Wed, 1 Feb 2023 10:32:09 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1F6D66174C; Wed, 1 Feb 2023 10:25:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 075F9C433D2; Wed, 1 Feb 2023 10:25:02 +0000 (UTC) From: Lorenzo Bianconi To: bpf@vger.kernel.org Date: Wed, 1 Feb 2023 11:24:16 +0100 Message-Id: X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675247102; bh=Gnuijlikm1O785voXzUwrttoVBA0l8YR5XPtX5J4Kfk=; h=From:To:Cc:Subject:Date:From; b=RRlElD9E0KlkHPuSVoykG+lPIRubwCcC0vCs8kO2bgURUstVwKKheLRGKHCpbzVC8 KjBeOs+VkWSgE25N6jxDURIF4pDpyeXqUNfpkBCeambUy5rLo60NecPkOT2JknP03+ UGbopZQXCju/KwH0+d3T5s2QlVSwUazMkKVsizGouK5oiWzVbMo9k1IHkh9IV2eu7T Y7d+QPD0LKOe0RXyM2doJqx5ngXdM55+CAJkFAiQiyjMQu7w1WTdApa7MVtvd1HjwP pb+GHXmSKN6ljncnvfs7ctlYOO+8XZqApyLyzXZSuSVInE7P5eVwSe21BTRu4IOcxu MaDSu8WyCRdug== X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=RRlElD9E Subject: [Intel-wired-lan] [PATCH v5 bpf-next 0/8] xdp: introduce xdp-feature support X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mst@redhat.com, vladimir.oltean@nxp.com, ast@kernel.org, edumazet@google.com, anthony.l.nguyen@intel.com, sdf@google.com, gerhard@engleder-embedded.com, daniel@iogearbox.net, andrii@kernel.org, intel-wired-lan@lists.osuosl.org, simon.horman@corigine.com, kuba@kernel.org, pabeni@redhat.com, aelior@marvell.com, hawk@kernel.org, christophe.jaillet@wanadoo.fr, memxor@gmail.com, john@phrozen.org, bjorn@kernel.org, magnus.karlsson@intel.com, leon@kernel.org, netdev@vger.kernel.org, toke@redhat.com, martin.lau@linux.dev, ecree.xilinx@gmail.com, alardam@gmail.com, gospo@broadcom.com, saeedm@nvidia.com, davem@davemloft.net, nbd@nbd.name Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" 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 v4: - rebase on top of bpf-next - get rid of XDP_FEATURE_* enum in XDP compliance test tool - rely on AF_INET6 address family and on IPv6-mapped-IPv6 addresses for IPv4 in XDP compliance test tool - add tsnep driver support Changes since v3: - add IPv6 support to XDP compliance test tool - rely on network_helpers in XDP compliance test tool - cosmetics changes Changes since v2: - rebase on top of bpf-next - fix compilation error 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 + drivers/net/ethernet/engleder/tsnep_main.c | 4 + .../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 | 15 + 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 | 118 ++- 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 | 269 +++++++ .../selftests/bpf/test_xdp_features.sh | 107 +++ tools/testing/selftests/bpf/xdp_features.c | 699 ++++++++++++++++++ tools/testing/selftests/bpf/xdp_features.h | 20 + 63 files changed, 1945 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