From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
andrii@kernel.org
Cc: netdev@vger.kernel.org, magnus.karlsson@intel.com,
bjorn@kernel.org, tirthendu.sarkar@intel.com, toke@kernel.org,
kuba@kernel.org, horms@kernel.org,
Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Subject: [PATCH v6 bpf-next 10/24] xsk: add new netlink attribute dedicated for ZC max frags
Date: Fri, 14 Jul 2023 13:36:26 +0200 [thread overview]
Message-ID: <20230714113640.556893-11-maciej.fijalkowski@intel.com> (raw)
In-Reply-To: <20230714113640.556893-1-maciej.fijalkowski@intel.com>
Introduce new netlink attribute NETDEV_A_DEV_XDP_ZC_MAX_SEGS that will
carry maximum fragments that underlying ZC driver is able to handle on
TX side. It is going to be included in netlink response only when driver
supports ZC. Any value higher than 1 implies multi-buffer ZC support on
underlying device.
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
Documentation/netlink/specs/netdev.yaml | 6 ++++++
include/linux/netdevice.h | 1 +
include/uapi/linux/netdev.h | 1 +
net/core/dev.c | 1 +
net/core/netdev-genl.c | 8 ++++++++
tools/include/uapi/linux/netdev.h | 1 +
tools/lib/bpf/libbpf.h | 3 ++-
tools/lib/bpf/netlink.c | 5 +++++
8 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml
index b99e7ffef7a1..e41015310a6e 100644
--- a/Documentation/netlink/specs/netdev.yaml
+++ b/Documentation/netlink/specs/netdev.yaml
@@ -62,6 +62,12 @@ attribute-sets:
type: u64
enum: xdp-act
enum-as-flags: true
+ -
+ name: xdp_zc_max_segs
+ doc: max fragment count supported by ZC driver
+ type: u32
+ checks:
+ min: 1
operations:
list:
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index b828c7a75be2..b12477ea4032 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2250,6 +2250,7 @@ struct net_device {
#define GRO_MAX_SIZE (8 * 65535u)
unsigned int gro_max_size;
unsigned int gro_ipv4_max_size;
+ unsigned int xdp_zc_max_segs;
rx_handler_func_t __rcu *rx_handler;
void __rcu *rx_handler_data;
diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h
index 639524b59930..bf71698a1e82 100644
--- a/include/uapi/linux/netdev.h
+++ b/include/uapi/linux/netdev.h
@@ -41,6 +41,7 @@ enum {
NETDEV_A_DEV_IFINDEX = 1,
NETDEV_A_DEV_PAD,
NETDEV_A_DEV_XDP_FEATURES,
+ NETDEV_A_DEV_XDP_ZC_MAX_SEGS,
__NETDEV_A_DEV_MAX,
NETDEV_A_DEV_MAX = (__NETDEV_A_DEV_MAX - 1)
diff --git a/net/core/dev.c b/net/core/dev.c
index 69a3e544676c..b14dd28eb51e 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -10617,6 +10617,7 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
dev_net_set(dev, &init_net);
dev->gso_max_size = GSO_LEGACY_MAX_SIZE;
+ dev->xdp_zc_max_segs = 1;
dev->gso_max_segs = GSO_MAX_SEGS;
dev->gro_max_size = GRO_LEGACY_MAX_SIZE;
dev->gso_ipv4_max_size = GSO_LEGACY_MAX_SIZE;
diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
index a4270fafdf11..65ef4867fc49 100644
--- a/net/core/netdev-genl.c
+++ b/net/core/netdev-genl.c
@@ -25,6 +25,14 @@ netdev_nl_dev_fill(struct net_device *netdev, struct sk_buff *rsp,
return -EINVAL;
}
+ if (netdev->xdp_features & NETDEV_XDP_ACT_XSK_ZEROCOPY) {
+ if (nla_put_u32(rsp, NETDEV_A_DEV_XDP_ZC_MAX_SEGS,
+ netdev->xdp_zc_max_segs)) {
+ genlmsg_cancel(rsp, hdr);
+ return -EINVAL;
+ }
+ }
+
genlmsg_end(rsp, hdr);
return 0;
diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/netdev.h
index 639524b59930..bf71698a1e82 100644
--- a/tools/include/uapi/linux/netdev.h
+++ b/tools/include/uapi/linux/netdev.h
@@ -41,6 +41,7 @@ enum {
NETDEV_A_DEV_IFINDEX = 1,
NETDEV_A_DEV_PAD,
NETDEV_A_DEV_XDP_FEATURES,
+ NETDEV_A_DEV_XDP_ZC_MAX_SEGS,
__NETDEV_A_DEV_MAX,
NETDEV_A_DEV_MAX = (__NETDEV_A_DEV_MAX - 1)
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 10642ad69d76..674e5788eb10 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -1105,9 +1105,10 @@ struct bpf_xdp_query_opts {
__u32 skb_prog_id; /* output */
__u8 attach_mode; /* output */
__u64 feature_flags; /* output */
+ __u32 xdp_zc_max_segs; /* output */
size_t :0;
};
-#define bpf_xdp_query_opts__last_field feature_flags
+#define bpf_xdp_query_opts__last_field xdp_zc_max_segs
LIBBPF_API int bpf_xdp_attach(int ifindex, int prog_fd, __u32 flags,
const struct bpf_xdp_attach_opts *opts);
diff --git a/tools/lib/bpf/netlink.c b/tools/lib/bpf/netlink.c
index 84dd5fa14905..090bcf6e3b3d 100644
--- a/tools/lib/bpf/netlink.c
+++ b/tools/lib/bpf/netlink.c
@@ -45,6 +45,7 @@ struct xdp_id_md {
struct xdp_features_md {
int ifindex;
+ __u32 xdp_zc_max_segs;
__u64 flags;
};
@@ -421,6 +422,9 @@ static int parse_xdp_features(struct nlmsghdr *nh, libbpf_dump_nlmsg_t fn,
return NL_CONT;
md->flags = libbpf_nla_getattr_u64(tb[NETDEV_A_DEV_XDP_FEATURES]);
+ if (tb[NETDEV_A_DEV_XDP_ZC_MAX_SEGS])
+ md->xdp_zc_max_segs =
+ libbpf_nla_getattr_u32(tb[NETDEV_A_DEV_XDP_ZC_MAX_SEGS]);
return NL_DONE;
}
@@ -493,6 +497,7 @@ int bpf_xdp_query(int ifindex, int xdp_flags, struct bpf_xdp_query_opts *opts)
return libbpf_err(err);
opts->feature_flags = md.flags;
+ opts->xdp_zc_max_segs = md.xdp_zc_max_segs;
skip_feature_flags:
return 0;
--
2.34.1
next prev parent reply other threads:[~2023-07-14 11:37 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-14 11:36 [PATCH v6 bpf-next 00/24] xsk: multi-buffer support Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 01/24] xsk: prepare 'options' in xdp_desc for multi-buffer use Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 02/24] xsk: introduce XSK_USE_SG bind flag for xsk socket Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 03/24] xsk: prepare both copy and zero-copy modes to co-exist Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 04/24] xsk: move xdp_buff's data length check to xsk_rcv_check Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 05/24] xsk: add support for AF_XDP multi-buffer on Rx path Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 06/24] xsk: introduce wrappers and helpers for supporting multi-buffer in Tx path Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 07/24] xsk: allow core/drivers to test EOP bit Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 08/24] xsk: add support for AF_XDP multi-buffer on Tx path Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 09/24] xsk: discard zero length descriptors in " Maciej Fijalkowski
2023-07-14 11:36 ` Maciej Fijalkowski [this message]
2023-07-14 11:36 ` [PATCH v6 bpf-next 11/24] xsk: support mbuf on ZC RX Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 12/24] ice: xsk: add RX multi-buffer support Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 13/24] i40e: " Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 14/24] xsk: support ZC Tx multi-buffer in batch API Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 15/24] ice: xsk: Tx multi-buffer support Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 16/24] i40e: xsk: add TX " Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 17/24] xsk: add multi-buffer documentation Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 18/24] selftests/xsk: transmit and receive multi-buffer packets Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 19/24] selftests/xsk: add basic multi-buffer test Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 20/24] selftests/xsk: add unaligned mode test for multi-buffer Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 21/24] selftests/xsk: add invalid descriptor " Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 22/24] selftests/xsk: add metadata copy test for multi-buff Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 23/24] selftests/xsk: add test for too many frags Maciej Fijalkowski
2023-07-14 11:36 ` [PATCH v6 bpf-next 24/24] selftests/xsk: reset NIC settings to default after running test suite Maciej Fijalkowski
2023-07-14 15:34 ` [PATCH v6 bpf-next 00/24] xsk: multi-buffer support Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230714113640.556893-11-maciej.fijalkowski@intel.com \
--to=maciej.fijalkowski@intel.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.org \
--cc=tirthendu.sarkar@intel.com \
--cc=toke@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).