Skip to contentSkip to conversation

ynl: couple of unrelated fixes

PATCH Applied Stanislav Fomichev 3 participants 7 messages Jul 27, 2023 – Jul 28, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover ynl: couple of unrelated fixes

- spelling of xdp-features
- s/xdp_zc_max_segs/xdp-zc-max-segs/
- expose xdp-zc-max-segs
- add /* private: */
- regenerate headers
- print xdp_zc_max_segs from sample

v2:
- don't put newline after /* private: */ (Jakub)
- use ynl-regen.sh for regen (Jakub)

Stanislav Fomichev (4):
ynl: expose xdp-zc-max-segs
ynl: mark max/mask as private for kdoc
ynl: regenerate all headers
ynl: print xdp-zc-max-segs in the sample

 Documentation/netlink/specs/netdev.yaml | 5 +++--
 include/uapi/linux/netdev.h             | 3 ++-
 tools/include/uapi/linux/netdev.h       | 3 ++-
 tools/net/ynl/Makefile                  | 1 +
 tools/net/ynl/generated/netdev-user.c   | 6 ++++++
 tools/net/ynl/generated/netdev-user.h   | 2 ++
 tools/net/ynl/samples/netdev.c          | 2 ++
 tools/net/ynl/ynl-gen-c.py              | 1 +
 tools/net/ynl/ynl-regen.sh              | 5 +++++
 9 files changed, 24 insertions(+), 4 deletions(-)
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#1 lore raw

PATCH v2 1/4 ynl: expose xdp-zc-max-segs

Also rename it to dashes, to match the rest. And fix unrelated spelling error while we're at it.

---
 Documentation/netlink/specs/netdev.yaml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/netlink/specs/netdev.yaml +3 -2
index e41015310a6e..1c7284fd535b 100644
@@ -14,7 +14,7 @@ name: netdev
       -
         name: basic
         doc:
-          XDP feautues set supported by all drivers
+          XDP features set supported by all drivers
           (XDP_ABORTED, XDP_DROP, XDP_PASS, XDP_TX)
       -
         name: redirect
@@ -63,7 +63,7 @@ name: netdev
         enum: xdp-act
         enum-as-flags: true
       -
-        name: xdp_zc_max_segs
+        name: xdp-zc-max-segs
         doc: max fragment count supported by ZC driver
         type: u32
         checks:
@@ -83,6 +83,7 @@ name: netdev
           attributes:
             - ifindex
             - xdp-features
+            - xdp-zc-max-segs
       dump:
         reply: *dev-all
     -
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#2 lore raw

PATCH v2 2/4 ynl: mark max/mask as private for kdoc

In reply to Stanislav Fomichev

Simon mentioned in another thread that it makes kdoc happy
and Jakub confirms that commit e27cb89a22ad ("scripts: kernel-doc: support private / public marking for enums") actually added the needed support.

---
 tools/net/ynl/ynl-gen-c.py | 1 +
 1 file changed, 1 insertion(+)
tools/net/ynl/ynl-gen-c.py +1 -0
index 71c5e79e877f..650be9b8b693 100755
@@ -2125,6 +2125,7 @@ _C_KW = {
 
             if const.get('render-max', False):
                 cw.nl()
+                cw.p('/* private: */')
                 if const['type'] == 'flags':
                     max_name = c_upper(name_pfx + 'mask')
                     max_val = f' = {enum.get_mask()},'
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#3 lore raw

PATCH v2 3/4 ynl: regenerate all headers

In reply to Stanislav Fomichev

Also add support to pass topdir to ynl-regen.sh (Jakub) and call it from the makefile to update the UAPI headers.

---
 include/uapi/linux/netdev.h           | 3 ++-
 tools/include/uapi/linux/netdev.h     | 3 ++-
 tools/net/ynl/Makefile                | 1 +
 tools/net/ynl/generated/netdev-user.c | 6 ++++++
 tools/net/ynl/generated/netdev-user.h | 2 ++
 tools/net/ynl/ynl-regen.sh            | 5 +++++
 6 files changed, 18 insertions(+), 2 deletions(-)
include/uapi/linux/netdev.h +2 -1
index bf71698a1e82..c1634b95c223 100644
@@ -11,7 +11,7 @@
 
 /**
  * enum netdev_xdp_act
- * @NETDEV_XDP_ACT_BASIC: XDP feautues set supported by all drivers
+ * @NETDEV_XDP_ACT_BASIC: XDP features set supported by all drivers
  *   (XDP_ABORTED, XDP_DROP, XDP_PASS, XDP_TX)
  * @NETDEV_XDP_ACT_REDIRECT: The netdev supports XDP_REDIRECT
  * @NETDEV_XDP_ACT_NDO_XMIT: This feature informs if netdev implements
@@ -34,6 +34,7 @@ enum netdev_xdp_act {
 	NETDEV_XDP_ACT_RX_SG = 32,
 	NETDEV_XDP_ACT_NDO_XMIT_SG = 64,
 
+	/* private: */
 	NETDEV_XDP_ACT_MASK = 127,
 };
 
tools/include/uapi/linux/netdev.h +2 -1
index bf71698a1e82..c1634b95c223 100644
@@ -11,7 +11,7 @@
 
 /**
  * enum netdev_xdp_act
- * @NETDEV_XDP_ACT_BASIC: XDP feautues set supported by all drivers
+ * @NETDEV_XDP_ACT_BASIC: XDP features set supported by all drivers
  *   (XDP_ABORTED, XDP_DROP, XDP_PASS, XDP_TX)
  * @NETDEV_XDP_ACT_REDIRECT: The netdev supports XDP_REDIRECT
  * @NETDEV_XDP_ACT_NDO_XMIT: This feature informs if netdev implements
@@ -34,6 +34,7 @@ enum netdev_xdp_act {
 	NETDEV_XDP_ACT_RX_SG = 32,
 	NETDEV_XDP_ACT_NDO_XMIT_SG = 64,
 
+	/* private: */
 	NETDEV_XDP_ACT_MASK = 127,
 };
 
tools/net/ynl/Makefile +1 -0
index d664b36deb5b..8156f03e23ac 100644
@@ -3,6 +3,7 @@
 SUBDIRS = lib generated samples
 
 all: $(SUBDIRS)
+	./ynl-regen.sh -f -p $(PWD)/../../../
 
 $(SUBDIRS):
 	@if [ -f "$@/Makefile" ] ; then \
tools/net/ynl/generated/netdev-user.c +6 -0
index 4eb8aefef0cd..68b408ca0f7f 100644
@@ -50,6 +50,7 @@ struct ynl_policy_attr netdev_dev_policy[NETDEV_A_DEV_MAX + 1] = {
 	[NETDEV_A_DEV_IFINDEX] = { .name = "ifindex", .type = YNL_PT_U32, },
 	[NETDEV_A_DEV_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, },
 	[NETDEV_A_DEV_XDP_FEATURES] = { .name = "xdp-features", .type = YNL_PT_U64, },
+	[NETDEV_A_DEV_XDP_ZC_MAX_SEGS] = { .name = "xdp-zc-max-segs", .type = YNL_PT_U32, },
 };
 
 struct ynl_policy_nest netdev_dev_nest = {
@@ -91,6 +92,11 @@ int netdev_dev_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
 				return MNL_CB_ERROR;
 			dst->_present.xdp_features = 1;
 			dst->xdp_features = mnl_attr_get_u64(attr);
+		} else if (type == NETDEV_A_DEV_XDP_ZC_MAX_SEGS) {
+			if (ynl_attr_validate(yarg, attr))
+				return MNL_CB_ERROR;
+			dst->_present.xdp_zc_max_segs = 1;
+			dst->xdp_zc_max_segs = mnl_attr_get_u32(attr);
 		}
 	}
 
tools/net/ynl/generated/netdev-user.h +2 -0
index 5554dc69bb9c..0952d3261f4d 100644
@@ -47,10 +47,12 @@ struct netdev_dev_get_rsp {
 	struct {
 		__u32 ifindex:1;
 		__u32 xdp_features:1;
+		__u32 xdp_zc_max_segs:1;
 	} _present;
 
 	__u32 ifindex;
 	__u64 xdp_features;
+	__u32 xdp_zc_max_segs;
 };
 
 void netdev_dev_get_rsp_free(struct netdev_dev_get_rsp *rsp);
tools/net/ynl/ynl-regen.sh +5 -0
index 8d4ca6a50582..bdba24066cf1 100755
@@ -4,15 +4,18 @@
 TOOL=$(dirname $(realpath $0))/ynl-gen-c.py
 
 force=
+search=
 
 while [ ! -z "$1" ]; do
   case "$1" in
     -f ) force=yes; shift ;;
+    -p ) search=$2; shift 2 ;;
     * )  echo "Unrecognized option '$1'"; exit 1 ;;
   esac
 done
 
 KDIR=$(dirname $(dirname $(dirname $(dirname $(realpath $0)))))
+pushd ${search:-$KDIR} >>/dev/null
 
 files=$(git grep --files-with-matches '^/\* YNL-GEN \(kernel\|uapi\|user\)')
 for f in $files; do
@@ -30,3 +33,5 @@ for f in $files; do
     $TOOL --mode ${params[2]} --${params[3]} --spec $KDIR/${params[0]} \
 	  $args -o $f
 done
+
+popd >>/dev/null
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#4 lore raw

PATCH v2 4/4 ynl: print xdp-zc-max-segs in the sample

In reply to Stanislav Fomichev

Technically we don't have to keep extending the sample, but it feels useful to run these tools locally to confirm everything is working.

---
 tools/net/ynl/samples/netdev.c | 2 ++
 1 file changed, 2 insertions(+)
tools/net/ynl/samples/netdev.c +2 -0
index d31268aa47c5..06433400dddd 100644
@@ -38,6 +38,8 @@ static void netdev_print_device(struct netdev_dev_get_rsp *d, unsigned int op)
 			printf(" %s", netdev_xdp_act_str(1 << i));
 	}
 
+	printf(" xdp-zc-max-segs=%u", d->xdp_zc_max_segs);
+
 	name = netdev_op_str(op);
 	if (name)
 		printf(" (ntf: %s)", name);
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#6 lore raw
In reply to Stanislav Fomichev
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Thu, 27 Jul 2023 09:29:57 -0700 you wrote:

- spelling of xdp-features
- s/xdp_zc_max_segs/xdp-zc-max-segs/
- expose xdp-zc-max-segs
- add /* private: */
- regenerate headers
- print xdp_zc_max_segs from sample

[...]

Here is the summary with links:
- [net-next,v2,1/4] ynl: expose xdp-zc-max-segs

    https://git.kernel.org/netdev/net-next/c/e5c157f081ab
  - [net-next,v2,2/4] ynl: mark max/mask as private for kdoc
    https://git.kernel.org/netdev/net-next/c/37844828d290
  - [net-next,v2,3/4] ynl: regenerate all headers
    https://git.kernel.org/netdev/net-next/c/25b5a2a1905f
  - [net-next,v2,4/4] ynl: print xdp-zc-max-segs in the sample
    https://git.kernel.org/netdev/net-next/c/26fdb67e8b4a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html