Skip to contentSkip to conversation

devlink: finish conversion to generated split_ops

PATCH Superseded Jiri Pirko 4 participants 38 messages Oct 10, 2023 – Oct 13, 2023

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jiri Pirko

author maintainer
#0 lore raw

cover devlink: finish conversion to generated split_ops

From: Jiri Pirko <[email protected]>

This patchset converts the remaining genetlink commands to generated split_ops and removes the existing small_ops arrays entirely alongside with shared netlink attribute policy.

Patches #1-#6 are just small preparations and small fixes on multiple
places. Note that couple of patches contain the "Fixes" tag but no need to put them into -net tree.
Patch #7 is a simple rename preparation
Patch #8 is the main one in this set and adds actual definitions of cmds
in to yaml file.
Patches #9-#10 finalize the change removing bits that are no longer in
use.

Jiri Pirko (10):
genetlink: don't merge dumpit split op for different cmds into single
iter
tools: ynl-gen: introduce support for bitfield32 attribute type
netlink: specs: devlink: remove reload-action from devlink-get cmd
reply
netlink: specs: devlink: make dont-validate single line
netlink: specs: devlink: fix reply command values
devlink: make devlink_flash_overwrite enum named one
devlink: rename netlink callback to be aligned with the generated ones
netlink: specs: devlink: add the remaining command to generate
complete split_ops
devlink: remove duplicated netlink callback prototypes
devlink: remove netlink small_ops

 Documentation/netlink/genetlink-c.yaml      |    2 +-
 Documentation/netlink/genetlink-legacy.yaml |    4 +-
 Documentation/netlink/genetlink.yaml        |    2 +-
 Documentation/netlink/specs/devlink.yaml    | 1607 +++++-
 include/uapi/linux/devlink.h                |    2 +-
 net/devlink/dev.c                           |   10 +-
 net/devlink/devl_internal.h                 |   64 -
 net/devlink/dpipe.c                         |   14 +-
 net/devlink/health.c                        |   24 +-
 net/devlink/linecard.c                      |    3 +-
 net/devlink/netlink.c                       |  328 +-
 net/devlink/netlink_gen.c                   |  757 ++-
 net/devlink/netlink_gen.h                   |   64 +-
 net/devlink/param.c                         |   14 +-
 net/devlink/port.c                          |   11 +-
 net/devlink/rate.c                          |    6 +-
 net/devlink/region.c                        |    8 +-
 net/devlink/resource.c                      |    4 +-
 net/devlink/sb.c                            |   17 +-
 net/devlink/trap.c                          |    9 +-
 net/netlink/genetlink.c                     |    4 +-
 tools/net/ynl/generated/devlink-user.c      | 4920 ++++++++++++++++---
 tools/net/ynl/generated/devlink-user.h      | 4192 ++++++++++++++--
 tools/net/ynl/generated/ethtool-user.h      |    1 +
 tools/net/ynl/generated/fou-user.h          |    1 +
 tools/net/ynl/generated/handshake-user.h    |    1 +
 tools/net/ynl/generated/netdev-user.h       |    1 +
 tools/net/ynl/lib/ynl.c                     |    6 +
 tools/net/ynl/lib/ynl.h                     |    1 +
 tools/net/ynl/ynl-gen-c.py                  |   31 +
 30 files changed, 10491 insertions(+), 1617 deletions(-)
Signature · 1 line
2.41.0
author maintainer
#1 lore raw

PATCH 1/10 genetlink: don't merge dumpit split op for different cmds into single iter

From: Jiri Pirko <[email protected]>

Currently, split ops of doit and dumpit are merged into a single iter item when they are subsequent. However, there is no guarantee that the dumpit op is for the same cmd as doit op.

Fix this by checking if cmd is the same for both.

Fixes b8fd60c36a44 ("genetlink: allow families to use split ops directly")
---
 net/netlink/genetlink.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/netlink/genetlink.c +3 -1
index 8315d31b53db..34346a73a0d6 100644
@@ -225,7 +225,9 @@ static void genl_op_from_split(struct genl_op_iter *iter)
 	}
 
 	if (i + cnt < family->n_split_ops &&
-	    family->split_ops[i + cnt].flags & GENL_CMD_CAP_DUMP) {
+	    family->split_ops[i + cnt].flags & GENL_CMD_CAP_DUMP &&
+	    (!cnt ||
+	     (cnt && family->split_ops[i + cnt].cmd == iter->doit.cmd))) {
 		iter->dumpit = family->split_ops[i + cnt];
 		genl_op_fill_in_reject_policy_split(family, &iter->dumpit);
 		cnt++;
Signature · 1 line
2.41.0
#2 lore raw

Re: [patch net-next 01/10] genetlink: don't merge dumpit split op for different cmds into single iter

Quoted 7 lines · Jiri Pirko

From: Jiri Pirko <[email protected]>

Currently, split ops of doit and dumpit are merged into a single iter item when they are subsequent. However, there is no guarantee that the dumpit op is for the same cmd as doit op.

Fix this by checking if cmd is the same for both.

It's confusing, but I don't think this is needed, I believe genl_validate_ops() ensures that do comes before dump, and the commands are sorted, so that you cannot end up in this situation?

And even if you can end up in this situation, I don't think this patch is the correct way to address it - we should then improve the validation in genl_validate_ops() instead.

(And maybe add a comment here, but ...)

johannes

author maintainer
#3 lore raw

Re: [patch net-next 01/10] genetlink: don't merge dumpit split op for different cmds into single iter

Quoted 7 lines · Tue, Oct 10, 2023 at 01:24:31PM CEST, [email protected] wrote:
Quoted 6 lines · Jiri Pirko

From: Jiri Pirko <[email protected]>

Currently, split ops of doit and dumpit are merged into a single iter item when they are subsequent. However, there is no guarantee that the dumpit op is for the same cmd as doit op.

Quoted 5 lines
Quoted 1 line

Fix this by checking if cmd is the same for both.

It's confusing, but I don't think this is needed, I believe genl_validate_ops() ensures that do comes before dump, and the commands are sorted, so that you cannot end up in this situation?

Apply this patchset w/o this patch and you'll hit it :) Otherwise I would not care...

The problem is dumpit op of cmd Y with previous doit op of cmd X. They should not be merged, they are not same cmd, yet existing code does that.

Quoted 4 lines

And even if you can end up in this situation, I don't think this patch is the correct way to address it - we should then improve the validation in genl_validate_ops() instead.

The problem is incorrect merge of 2 consequent split ops into iter. This function does the merging. Where else to fix it?

Quoted 5 lines

(And maybe add a comment here, but ...)

johannes

#4 lore raw

Re: [patch net-next 01/10] genetlink: don't merge dumpit split op for different cmds into single iter

Quoted 2 lines · Jiri Pirko

Apply this patchset w/o this patch and you'll hit it :) Otherwise I would not care...

:)

Quoted 3 lines

The problem is dumpit op of cmd Y with previous doit op of cmd X. They should not be merged, they are not same cmd, yet existing code does that.

Yeah, on second thought, you're right, if you have CMDs X < Y and then

X/do
Y/dump

(and no X/dump, nor Y/do) then indeed this can happen.

Sorry for the noise.

johannes

Reviewed-by on v1 1/10
#5 lore raw

Re: [patch net-next 01/10] genetlink: don't merge dumpit split op for different cmds into single iter

In reply to Jiri Pirko
Quoted 10 lines · Jiri Pirko

From: Jiri Pirko <[email protected]>

Currently, split ops of doit and dumpit are merged into a single iter item when they are subsequent. However, there is no guarantee that the dumpit op is for the same cmd as doit op.

Fix this by checking if cmd is the same for both.

Fixes b8fd60c36a44 ("genetlink: allow families to use split ops directly")

johannes

maintainer
#6 lore raw

Re: [patch net-next 01/10] genetlink: don't merge dumpit split op for different cmds into single iter

In reply to Jiri Pirko
Quoted 1 line · On Tue, 10 Oct 2023 13:08:20 +0200 Jiri Pirko wrote:
Fixes b8fd60c36a44 ("genetlink: allow families to use split ops directly")

Drop Fixes, add "currently no family declares ops which could trigger this issue".

net/netlink/genetlink.c static void genl_op_from_split(struct genl_op_iter *iter) · line 230

Quoted 5 lines
net/netlink/genetlink.c +3 -1
 	if (i + cnt < family->n_split_ops &&
-	    family->split_ops[i + cnt].flags & GENL_CMD_CAP_DUMP) {
+	    family->split_ops[i + cnt].flags & GENL_CMD_CAP_DUMP &&
+	    (!cnt ||
+	     (cnt && family->split_ops[i + cnt].cmd == iter->doit.cmd))) {

Why are you checking cnt? if do was not found cmd will be 0, which cannot mis-match.

author maintainer
#7 lore raw

Re: [patch net-next 01/10] genetlink: don't merge dumpit split op for different cmds into single iter

Quoted 5 lines · Tue, Oct 10, 2023 at 08:48:45PM CEST, [email protected] wrote:
Quoted 1 line · On Tue, 10 Oct 2023 13:08:20 +0200 Jiri Pirko wrote:
Fixes b8fd60c36a44 ("genetlink: allow families to use split ops directly")

Drop Fixes, add "currently no family declares ops which could trigger this issue".

Yeah, we need fixes semantics written down somewhere. I can do it, sure.

Quoted 9 lines

net/netlink/genetlink.c static void genl_op_from_split(struct genl_op_iter *iter) · line 230

Quoted 6 lines
net/netlink/genetlink.c +3 -1
 	if (i + cnt < family->n_split_ops &&
-	    family->split_ops[i + cnt].flags & GENL_CMD_CAP_DUMP) {
+	    family->split_ops[i + cnt].flags & GENL_CMD_CAP_DUMP &&
+	    (!cnt ||
+	     (cnt && family->split_ops[i + cnt].cmd == iter->doit.cmd))) {

Why are you checking cnt? if do was not found cmd will be 0, which cannot mis-match.

Correct. Will remove cnt check.

author maintainer
#8 lore raw

Re: [patch net-next 01/10] genetlink: don't merge dumpit split op for different cmds into single iter

Quoted 9 lines · Wed, Oct 11, 2023 at 08:08:57AM CEST, [email protected] wrote:
Quoted 5 lines · Tue, Oct 10, 2023 at 08:48:45PM CEST, [email protected] wrote:
Quoted 1 line · On Tue, 10 Oct 2023 13:08:20 +0200 Jiri Pirko wrote:
Fixes b8fd60c36a44 ("genetlink: allow families to use split ops directly")

Drop Fixes, add "currently no family declares ops which could trigger this issue".

Yeah, we need fixes semantics written down somewhere. I can do it, sure.

I found 2 mentions that relate to netdev regarging Fixes:

Quoting Documentation/process/submitting-patches.rst:
If your patch fixes a bug in a specific commit, e.g. you found an issue using ``git bisect``, please use the 'Fixes:' tag with the first 12 characters of the SHA-1 ID, and the one line summary.

Quoting Documentation/process/maintainer-netdev.rst:
- for fixes the ``Fixes:`` tag is required, regardless of the tree

This patch fixes a bug, sure, bug is not hit by existing code, but still it is present.

Why it is wrong to put "Fixes" in this case?
Could you please document this?

Quoted 13 lines
Quoted 11 lines

net/netlink/genetlink.c static void genl_op_from_split(struct genl_op_iter *iter) · line 230

Quoted 8 lines
net/netlink/genetlink.c +3 -1
 	if (i + cnt < family->n_split_ops &&
-	    family->split_ops[i + cnt].flags & GENL_CMD_CAP_DUMP) {
+	    family->split_ops[i + cnt].flags & GENL_CMD_CAP_DUMP &&
+	    (!cnt ||
+	     (cnt && family->split_ops[i + cnt].cmd == iter->doit.cmd))) {

Why are you checking cnt? if do was not found cmd will be 0, which cannot mis-match.

Correct. Will remove cnt check.

maintainer
#9 lore raw

Re: [patch net-next 01/10] genetlink: don't merge dumpit split op for different cmds into single iter

Quoted 10 lines · On Wed, 11 Oct 2023 13:27:05 +0200 Jiri Pirko wrote:
Quoted 2 lines

Yeah, we need fixes semantics written down somewhere. I can do it, sure.

I found 2 mentions that relate to netdev regarging Fixes:

Quoting Documentation/process/submitting-patches.rst:
If your patch fixes a bug in a specific commit, e.g. you found an issue using ``git bisect``, please use the 'Fixes:' tag with the first 12 characters of the SHA-1 ID, and the one line summary.

Quoted 8 lines

Quoting Documentation/process/maintainer-netdev.rst:
- for fixes the ``Fixes:`` tag is required, regardless of the tree

This patch fixes a bug, sure, bug is not hit by existing code, but still it is present.

Why it is wrong to put "Fixes" in this case?
Could you please document this?

I think you're asking me to document what a bug is because the existing doc clearly says Fixes is for bugs. If the code does not misbehave, there is no bug.

author maintainer
#10 lore raw

Re: [patch net-next 01/10] genetlink: don't merge dumpit split op for different cmds into single iter

Quoted 17 lines · Wed, Oct 11, 2023 at 06:47:02PM CEST, [email protected] wrote:
Quoted 16 lines · On Wed, 11 Oct 2023 13:27:05 +0200 Jiri Pirko wrote:
Quoted 2 lines

Yeah, we need fixes semantics written down somewhere. I can do it, sure.

I found 2 mentions that relate to netdev regarging Fixes:

Quoting Documentation/process/submitting-patches.rst:
If your patch fixes a bug in a specific commit, e.g. you found an issue using ``git bisect``, please use the 'Fixes:' tag with the first 12 characters of the SHA-1 ID, and the one line summary.

Quoting Documentation/process/maintainer-netdev.rst:
- for fixes the ``Fixes:`` tag is required, regardless of the tree

This patch fixes a bug, sure, bug is not hit by existing code, but still it is present.

Quoted 6 lines
Quoted 2 lines

Why it is wrong to put "Fixes" in this case?
Could you please document this?

I think you're asking me to document what a bug is because the existing doc clearly says Fixes is for bugs. If the code does not misbehave, there is no bug.

Interesting. Will try to remember :)

#11 lore raw

Re: [patch net-next 01/10] genetlink: don't merge dumpit split op for different cmds into single iter

In reply to Jakub Kicinski
Quoted 17 lines · Jakub Kicinski
Quoted 16 lines · On Wed, 11 Oct 2023 13:27:05 +0200 Jiri Pirko wrote:
Quoted 2 lines

Yeah, we need fixes semantics written down somewhere. I can do it, sure.

I found 2 mentions that relate to netdev regarging Fixes:

Quoting Documentation/process/submitting-patches.rst:
If your patch fixes a bug in a specific commit, e.g. you found an issue using ``git bisect``, please use the 'Fixes:' tag with the first 12 characters of the SHA-1 ID, and the one line summary.

Quoting Documentation/process/maintainer-netdev.rst:
- for fixes the ``Fixes:`` tag is required, regardless of the tree

This patch fixes a bug, sure, bug is not hit by existing code, but still it is present.

Quoted 7 lines
Quoted 2 lines

Why it is wrong to put "Fixes" in this case?
Could you please document this?

I think you're asking me to document what a bug is because the existing doc clearly says Fixes is for bugs. If the code does not misbehave, there is no bug.

Well this code misbehaves if given the right input. We just don't give it that input today. I would have called that a bug too. But from a strict sense of "can you make this fail on a current kernel" the answer is no, since no families exist which have this requirement until after this series.

author maintainer
#12 lore raw

PATCH 2/10 tools: ynl-gen: introduce support for bitfield32 attribute type

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

Introduce support for forgotten attribute type bitfield32. Note that since the generated code works with struct nla_bitfiel32, the generator adds netlink.h to the list of includes for userspace headers. Regenerate the headers.

---
 Documentation/netlink/genetlink-c.yaml      |  2 +-
 Documentation/netlink/genetlink-legacy.yaml |  4 +--
 Documentation/netlink/genetlink.yaml        |  2 +-
 tools/net/ynl/generated/devlink-user.h      |  1 +
 tools/net/ynl/generated/ethtool-user.h      |  1 +
 tools/net/ynl/generated/fou-user.h          |  1 +
 tools/net/ynl/generated/handshake-user.h    |  1 +
 tools/net/ynl/generated/netdev-user.h       |  1 +
 tools/net/ynl/lib/ynl.c                     |  6 ++++
 tools/net/ynl/lib/ynl.h                     |  1 +
 tools/net/ynl/ynl-gen-c.py                  | 31 +++++++++++++++++++++
 11 files changed, 47 insertions(+), 4 deletions(-)
Documentation/netlink/genetlink-c.yaml +1 -1
index f9366aaddd21..8192b87b3046 100644
@@ -144,7 +144,7 @@ properties:
               name:
                 type: string
               type: &attr-type
-                enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64,
+                enum: [ unused, pad, flag, binary, bitfield32, u8, u16, u32, u64, s32, s64,
                         string, nest, array-nest, nest-type-value ]
               doc:
                 description: Documentation of the attribute.
Documentation/netlink/genetlink-legacy.yaml +2 -2
index a6a490333a1a..8b867b5b9966 100644
@@ -120,7 +120,7 @@ properties:
                 type: string
               type:
                 description: The netlink attribute type
-                enum: [ u8, u16, u32, u64, s8, s16, s32, s64, string, binary ]
+                enum: [ u8, u16, u32, u64, s8, s16, s32, s64, string, binary, bitfield32 ]
               len:
                 $ref: '#/$defs/len-or-define'
               byte-order:
@@ -187,7 +187,7 @@ properties:
                 type: string
               type: &attr-type
                 description: The netlink attribute type
-                enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64,
+                enum: [ unused, pad, flag, binary, bitfield32, u8, u16, u32, u64, s32, s64,
                         string, nest, array-nest, nest-type-value ]
               doc:
                 description: Documentation of the attribute.
Documentation/netlink/genetlink.yaml +1 -1
index 2b788e607a14..5cde1b030e8e 100644
@@ -117,7 +117,7 @@ properties:
               name:
                 type: string
               type: &attr-type
-                enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64,
+                enum: [ unused, pad, flag, binary, bitfield32, u8, u16, u32, u64, s32, s64,
                         string, nest, array-nest, nest-type-value ]
               doc:
                 description: Documentation of the attribute.
tools/net/ynl/generated/devlink-user.h +1 -0
index 4b686d147613..a490466fb98a 100644
@@ -9,6 +9,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <linux/types.h>
+#include <linux/netlink.h>
 #include <linux/devlink.h>
 
 struct ynl_sock;
tools/net/ynl/generated/ethtool-user.h +1 -0
index ddc1a5209992..f7bce36f8485 100644
@@ -10,6 +10,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <linux/types.h>
+#include <linux/netlink.h>
 #include <linux/ethtool.h>
 
 struct ynl_sock;
tools/net/ynl/generated/fou-user.h +1 -0
index a8f860892540..2ae6d1b66393 100644
@@ -9,6 +9,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <linux/types.h>
+#include <linux/netlink.h>
 #include <linux/fou.h>
 
 struct ynl_sock;
tools/net/ynl/generated/handshake-user.h +1 -0
index 2b34acc608de..1007f8db5c5e 100644
@@ -9,6 +9,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <linux/types.h>
+#include <linux/netlink.h>
 #include <linux/handshake.h>
 
 struct ynl_sock;
tools/net/ynl/generated/netdev-user.h +1 -0
index b4351ff34595..d6ffc0c8ccf4 100644
@@ -9,6 +9,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <linux/types.h>
+#include <linux/netlink.h>
 #include <linux/netdev.h>
 
 struct ynl_sock;
tools/net/ynl/lib/ynl.c +6 -0
index 514e0d69e731..4a94ef092b6e 100644
@@ -373,6 +373,12 @@ int ynl_attr_validate(struct ynl_parse_arg *yarg, const struct nlattr *attr)
 		yerr(yarg->ys, YNL_ERROR_ATTR_INVALID,
 		     "Invalid attribute (string %s)", policy->name);
 		return -1;
+	case YNL_PT_BITFIELD32:
+		if (len == sizeof(struct nla_bitfield32))
+			break;
+		yerr(yarg->ys, YNL_ERROR_ATTR_INVALID,
+		     "Invalid attribute (bitfield32 %s)", policy->name);
+		return -1;
 	default:
 		yerr(yarg->ys, YNL_ERROR_ATTR_INVALID,
 		     "Invalid attribute (unknown %s)", policy->name);
tools/net/ynl/lib/ynl.h +1 -0
index 9eafa3552c16..813b26a08145 100644
@@ -134,6 +134,7 @@ enum ynl_policy_type {
 	YNL_PT_U32,
 	YNL_PT_U64,
 	YNL_PT_NUL_STR,
+	YNL_PT_BITFIELD32,
 };
 
 struct ynl_policy_attr {
tools/net/ynl/ynl-gen-c.py +31 -0
index f125b5f704ba..27bbe376054d 100755
@@ -433,6 +433,34 @@ class TypeBinary(Type):
                 f'memcpy({member}, {self.c_name}, {presence}_len);']
 
 
+class TypeBitfield32(Type):
+    def arg_member(self, ri):
+        return [f"const struct nla_bitfield32 *{self.c_name}"]
+
+    def struct_member(self, ri):
+        ri.cw.p(f"struct nla_bitfield32 {self.c_name};")
+
+    def _attr_typol(self):
+        return f'.type = YNL_PT_BITFIELD32, '
+
+    def _attr_policy(self, policy):
+        if not 'enum' in self.attr:
+            raise Exception('Enum required for bitfield32 attr')
+        enum = self.family.consts[self.attr['enum']]
+        mask = enum.get_mask(as_flags=True)
+        return f"NLA_POLICY_BITFIELD32({mask})"
+
+    def attr_put(self, ri, var):
+        line = f"mnl_attr_put(nlh, {self.enum_name}, sizeof(struct nla_bitfield32), &{var}->{self.c_name})"
+        self._attr_put_line(ri, var, line)
+
+    def _attr_get(self, ri, var):
+        return f"memcpy(&{var}->{self.c_name}, mnl_attr_get_payload(attr), sizeof(struct nla_bitfield32));", None, None
+
+    def _setter_lines(self, ri, member, presence):
+        return [f"memcpy(&{member}, {self.c_name}, sizeof(struct nla_bitfield32));"]
+
+
 class TypeNest(Type):
     def _complex_member_type(self, ri):
         return self.nested_struct_type
@@ -735,6 +763,8 @@ class AttrSet(SpecAttrSet):
             t = TypeString(self.family, self, elem, value)
         elif elem['type'] == 'binary':
             t = TypeBinary(self.family, self, elem, value)
+        elif elem['type'] == 'bitfield32':
+            t = TypeBitfield32(self.family, self, elem, value)
         elif elem['type'] == 'nest':
             t = TypeNest(self.family, self, elem, value)
         elif elem['type'] == 'array-nest':
@@ -2406,6 +2436,7 @@ def main():
         cw.p('#include <string.h>')
         if args.header:
             cw.p('#include <linux/types.h>')
+            cw.p('#include <linux/netlink.h>')
         else:
             cw.p(f'#include "{parsed.name}-user.h"')
             cw.p('#include "ynl.h"')
Signature · 1 line
2.41.0
Reviewed-by on v1 2/10
#13 lore raw

Re: [patch net-next 02/10] tools: ynl-gen: introduce support for bitfield32 attribute type

Quoted 4 lines · Jiri Pirko

From: Jiri Pirko <[email protected]>

Introduce support for forgotten attribute type bitfield32. Note that since the generated code works with struct nla_bitfiel32,

^ typo

Otherwise, looks good.

johannes

maintainer
#14 lore raw

Re: [patch net-next 02/10] tools: ynl-gen: introduce support for bitfield32 attribute type

In reply to Jiri Pirko
Quoted 1 line · On Tue, 10 Oct 2023 13:08:21 +0200 Jiri Pirko wrote:

Introduce support for forgotten attribute type bitfield32.

s/forgotten//, no family need it so far

Quoted 3 lines

Note that since the generated code works with struct nla_bitfiel32, the generator adds netlink.h to the list of includes for userspace headers. Regenerate the headers.

If all we need it for is bitfield32 it should be added dynamically. bitfiled32 is an odd concept.

Documentation/netlink/genetlink-c.yaml properties: · line 148

Quoted 11 lines
Documentation/netlink/genetlink-c.yaml +1 -1
index f9366aaddd21..8192b87b3046 100644
@@ -144,7 +144,7 @@ properties:
               name:
                 type: string
               type: &attr-type
-                enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64,
+                enum: [ unused, pad, flag, binary, bitfield32, u8, u16, u32, u64, s32, s64,
                         string, nest, array-nest, nest-type-value ]

Just for genetlink-legacy, please.
Also I think you need to update Documentation.

Documentation/netlink/genetlink-c.yaml properties:

Quoted 6 lines
Documentation/netlink/genetlink-c.yaml +6 -0
+class TypeBitfield32(Type):
+    def arg_member(self, ri):
+        return [f"const struct nla_bitfield32 *{self.c_name}"]
+
+    def struct_member(self, ri):
+        ri.cw.p(f"struct nla_bitfield32 {self.c_name};")

I think that you can re-implement _complex_member_type() instead of these two?

author maintainer
#15 lore raw

Re: [patch net-next 02/10] tools: ynl-gen: introduce support for bitfield32 attribute type

Quoted 11 lines · Tue, Oct 10, 2023 at 08:58:04PM CEST, [email protected] wrote:
Quoted 1 line · On Tue, 10 Oct 2023 13:08:21 +0200 Jiri Pirko wrote:

Introduce support for forgotten attribute type bitfield32.

s/forgotten//, no family need it so far

Quoted 3 lines

Note that since the generated code works with struct nla_bitfiel32, the generator adds netlink.h to the list of includes for userspace headers. Regenerate the headers.

If all we need it for is bitfield32 it should be added dynamically. bitfiled32 is an odd concept.

What do you mean by "added dynamically"?

Quoted 14 lines

Documentation/netlink/genetlink-c.yaml properties: · line 148

Quoted 12 lines
Documentation/netlink/genetlink-c.yaml +1 -1
index f9366aaddd21..8192b87b3046 100644
@@ -144,7 +144,7 @@ properties:
               name:
                 type: string
               type: &attr-type
-                enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64,
+                enum: [ unused, pad, flag, binary, bitfield32, u8, u16, u32, u64, s32, s64,
                         string, nest, array-nest, nest-type-value ]

Just for genetlink-legacy, please.

Why? Should be usable for all, same as other types, no?

Quoted 11 lines

Also I think you need to update Documentation.

Documentation/netlink/genetlink-c.yaml properties:

Quoted 6 lines
Documentation/netlink/genetlink-c.yaml +6 -0
+class TypeBitfield32(Type):
+    def arg_member(self, ri):
+        return [f"const struct nla_bitfield32 *{self.c_name}"]
+
+    def struct_member(self, ri):
+        ri.cw.p(f"struct nla_bitfield32 {self.c_name};")

I think that you can re-implement _complex_member_type() instead of these two?

Will check.

Quoted 1 line
maintainer
#16 lore raw

Re: [patch net-next 02/10] tools: ynl-gen: introduce support for bitfield32 attribute type

Quoted 8 lines · On Wed, 11 Oct 2023 08:07:12 +0200 Jiri Pirko wrote:
Quoted 6 lines
Quoted 3 lines

Note that since the generated code works with struct nla_bitfiel32, the generator adds netlink.h to the list of includes for userspace headers. Regenerate the headers.

If all we need it for is bitfield32 it should be added dynamically. bitfiled32 is an odd concept.

What do you mean by "added dynamically"?

Scan the family, see if it has any bitfields and only then add the include? It's not that common, no point slowing down compilation for all families if the header is not otherwise needed.

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
Documentation/netlink/genetlink-c.yaml +0 -0
index f9366aaddd21..8192b87b3046 100644
@@ -144,7 +144,7 @@ properties:
Quoted 8 lines

Documentation/netlink/genetlink-c.yaml properties: · line 148

Quoted 6 lines
Documentation/netlink/genetlink-c.yaml +1 -1
               name:
                 type: string
               type: &attr-type
-                enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64,
+                enum: [ unused, pad, flag, binary, bitfield32, u8, u16, u32, u64, s32, s64,
                         string, nest, array-nest, nest-type-value ]  

Just for genetlink-legacy, please.

Quoted 1 line

Why? Should be usable for all, same as other types, no?

array-nest already isn't. I don't see much value in bitfiled32 and listing it means every future codegen for genetlink will have to support it to be compatible. It's easier to add stuff than to remove it, so let's not.

author maintainer
#17 lore raw

Re: [patch net-next 02/10] tools: ynl-gen: introduce support for bitfield32 attribute type

Quoted 5 lines · Wed, Oct 11, 2023 at 06:52:36PM CEST, [email protected] wrote:
Quoted 4 lines · On Wed, 11 Oct 2023 08:07:12 +0200 Jiri Pirko wrote:
Quoted 4 lines
Quoted 3 lines

Note that since the generated code works with struct nla_bitfiel32, the generator adds netlink.h to the list of includes for userspace headers. Regenerate the headers.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

If all we need it for is bitfield32 it should be added dynamically. bitfiled32 is an odd concept.

What do you mean by "added dynamically"?

Scan the family, see if it has any bitfields and only then add the include? It's not that common, no point slowing down compilation for all families if the header is not otherwise needed.

Got it. Will try.

Quoted 15 lines
Quoted 15 lines
Quoted 14 lines

Documentation/netlink/genetlink-c.yaml properties: · line 148

Quoted 12 lines
Documentation/netlink/genetlink-c.yaml +1 -1
index f9366aaddd21..8192b87b3046 100644
@@ -144,7 +144,7 @@ properties:
               name:
                 type: string
               type: &attr-type
-                enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64,
+                enum: [ unused, pad, flag, binary, bitfield32, u8, u16, u32, u64, s32, s64,
                         string, nest, array-nest, nest-type-value ]  

Just for genetlink-legacy, please.

Quoted 6 lines
Quoted 1 line

Why? Should be usable for all, same as other types, no?

array-nest already isn't. I don't see much value in bitfiled32 and listing it means every future codegen for genetlink will have to support it to be compatible. It's easier to add stuff than to remove it, so let's not.

Interesting. You want to somehow mark bitfield32 obsolete? But why is it? I mean, what is the reason to discourage use of bitfield32?

maintainer
#18 lore raw

Re: [patch net-next 02/10] tools: ynl-gen: introduce support for bitfield32 attribute type

Quoted 9 lines · On Wed, 11 Oct 2023 19:04:42 +0200 Jiri Pirko wrote:
Quoted 6 lines
Quoted 1 line

Why? Should be usable for all, same as other types, no?

array-nest already isn't. I don't see much value in bitfiled32 and listing it means every future codegen for genetlink will have to support it to be compatible. It's easier to add stuff than to remove it, so let's not.

Interesting. You want to somehow mark bitfield32 obsolete? But why is it? I mean, what is the reason to discourage use of bitfield32?

It's a tradeoff between simplicity of base types and usefulness. bitfield32 is not bad in any way, but:

- it's 32b, new features/caps like to start with 64b
- it doesn't support "by name" operations so ethtool didn't use it
- it can be trivially re-implemented with 2 attrs

all in all there aren't very many new uses. So I think we should put it in legacy for now. Maybe somehow mark it as being there due to limited applicability rather than being "bad"?

author maintainer
#19 lore raw

Re: [patch net-next 02/10] tools: ynl-gen: introduce support for bitfield32 attribute type

Quoted 8 lines · Wed, Oct 11, 2023 at 08:25:37PM CEST, [email protected] wrote:
Quoted 7 lines · On Wed, 11 Oct 2023 19:04:42 +0200 Jiri Pirko wrote:
Quoted 6 lines
Quoted 1 line

Why? Should be usable for all, same as other types, no?

array-nest already isn't. I don't see much value in bitfiled32 and listing it means every future codegen for genetlink will have to support it to be compatible. It's easier to add stuff than to remove it, so let's not.

Quoted 7 lines
Quoted 2 lines

Interesting. You want to somehow mark bitfield32 obsolete? But why is it? I mean, what is the reason to discourage use of bitfield32?

It's a tradeoff between simplicity of base types and usefulness. bitfield32 is not bad in any way, but:

- it's 32b, new features/caps like to start with 64b

That's fun. Back when Jamal (I think it was him) was pushing bitfield32, I argued that it would be better to make it flexible bitfield so it it future proof. IIRC DavidM said that it should be enough and that you can use extra attr in case the current one overflows.

Sigh :/

Quoted 1 line

- it doesn't support "by name" operations so ethtool didn't use it

It follows the original Netlink rule: "all uapi should be well defined in enums/defines".

Quoted 1 line

- it can be trivially re-implemented with 2 attrs

Yeah, it's basically a wrapper to avoid unnecessary boilerplate and re-implementations. But I think that is a good thing. Or do you say it is not desirable to rather re-implement this with 2 attrs instead of using bitfield32 directly?

Quoted 4 lines

all in all there aren't very many new uses. So I think we should put it in legacy for now. Maybe somehow mark it as being there due to limited applicability rather than being "bad"?

I think it is odd, but if you insists, sure. Your the boss.

#20 lore raw

Re: [patch net-next 02/10] tools: ynl-gen: introduce support for bitfield32 attribute type

Quoted 9 lines · Jiri Pirko
Quoted 8 lines · Wed, Oct 11, 2023 at 08:25:37PM CEST, [email protected] wrote:
Quoted 7 lines · On Wed, 11 Oct 2023 19:04:42 +0200 Jiri Pirko wrote:
Quoted 6 lines
Quoted 1 line

Why? Should be usable for all, same as other types, no?

array-nest already isn't. I don't see much value in bitfiled32 and listing it means every future codegen for genetlink will have to support it to be compatible. It's easier to add stuff than to remove it, so let's not.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

Interesting. You want to somehow mark bitfield32 obsolete? But why is it? I mean, what is the reason to discourage use of bitfield32?

It's a tradeoff between simplicity of base types and usefulness. bitfield32 is not bad in any way, but:

- it's 32b, new features/caps like to start with 64b

To me, this is the biggest annoyance with bitfield32: that its not flexible in size, which is one of the big benefits of netlink. That limits bitfield32 to be most useful in places where you don't expect any such extension.

Quoted 7 lines

That's fun. Back when Jamal (I think it was him) was pushing bitfield32, I argued that it would be better to make it flexible bitfield so it it future proof. IIRC DavidM said that it should be enough and that you can use extra attr in case the current one overflows.

Sigh :/

I don't like that approach because it means you need different handling for different sets of bits which can be a bit frustrating. I would have also preferred flexible bitfield as well.

Quoted 5 lines
Quoted 1 line

- it doesn't support "by name" operations so ethtool didn't use it

It follows the original Netlink rule: "all uapi should be well defined in enums/defines".

What's the "by name" operation?

Quoted 8 lines
Quoted 2 lines

- it can be trivially re-implemented with 2 attrs

Yeah, it's basically a wrapper to avoid unnecessary boilerplate and re-implementations. But I think that is a good thing. Or do you say it is not desirable to rather re-implement this with 2 attrs instead of using bitfield32 directly?

This reads to me as "its easy to re-implement with 2 attributes rather than baking them into one", and those attributes can support varying sizes instead of just bitfield32

maintainer
#21 lore raw

Re: [patch net-next 02/10] tools: ynl-gen: introduce support for bitfield32 attribute type

Quoted 6 lines · On Thu, 12 Oct 2023 14:06:57 -0700 Jacob Keller wrote:
Quoted 4 lines
Quoted 1 line

- it doesn't support "by name" operations so ethtool didn't use it

It follows the original Netlink rule: "all uapi should be well defined in enums/defines".

What's the "by name" operation?

Instead of sending the full bit mask sending the list of bits and what state we want them in. And that list can either have bit numbers or names. Looking at ethnl_parse_bit() could be helpful.

#22 lore raw

Re: [patch net-next 02/10] tools: ynl-gen: introduce support for bitfield32 attribute type

Quoted 12 lines · Jakub Kicinski
Quoted 6 lines · On Thu, 12 Oct 2023 14:06:57 -0700 Jacob Keller wrote:
Quoted 4 lines
Quoted 1 line

- it doesn't support "by name" operations so ethtool didn't use it

It follows the original Netlink rule: "all uapi should be well defined in enums/defines".

What's the "by name" operation?

Instead of sending the full bit mask sending the list of bits and what state we want them in. And that list can either have bit numbers or names. Looking at ethnl_parse_bit() could be helpful.

Ah, yep. Thanks for the clarification.

-Jake

maintainer
#23 lore raw

Re: [patch net-next 02/10] tools: ynl-gen: introduce support for bitfield32 attribute type

In reply to Jiri Pirko
Quoted 5 lines · On Thu, 12 Oct 2023 11:28:40 +0200 Jiri Pirko wrote:
Quoted 3 lines

all in all there aren't very many new uses. So I think we should put it in legacy for now. Maybe somehow mark it as being there due to limited applicability rather than being "bad"?

I think it is odd, but if you insists, sure. Your the boss.

Just to be clear here - we're talking about what goes into which level of compatibility within YNL. So yes, I wrote YNL, I'd prefer to retain the ability to make some decisions about it :(

maintainer
#24 lore raw

Re: [patch net-next 02/10] tools: ynl-gen: introduce support for bitfield32 attribute type

In reply to Jiri Pirko
Quoted 3 lines · On Tue, 10 Oct 2023 13:08:21 +0200 Jiri Pirko wrote:
 tools/net/ynl/lib/ynl.c                     |  6 ++++
 tools/net/ynl/lib/ynl.h                     |  1 +
 tools/net/ynl/ynl-gen-c.py                  | 31 +++++++++++++++++++++

"forgotten" to add support to tools/net/ynl/lib/ynl.py ? :]

author maintainer
#25 lore raw

Re: [patch net-next 02/10] tools: ynl-gen: introduce support for bitfield32 attribute type

Quoted 6 lines · Tue, Oct 10, 2023 at 09:01:30PM CEST, [email protected] wrote:
Quoted 3 lines · On Tue, 10 Oct 2023 13:08:21 +0200 Jiri Pirko wrote:
 tools/net/ynl/lib/ynl.c                     |  6 ++++
 tools/net/ynl/lib/ynl.h                     |  1 +
 tools/net/ynl/ynl-gen-c.py                  | 31 +++++++++++++++++++++

"forgotten" to add support to tools/net/ynl/lib/ynl.py ? :]

Will check.

author maintainer
#26 lore raw

PATCH 3/10 netlink: specs: devlink: remove reload-action from devlink-get cmd reply

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

devlink-get command does not contain reload-action attr in reply. Remove it.

---
 Documentation/netlink/specs/devlink.yaml | 1 -
 tools/net/ynl/generated/devlink-user.c   | 5 -----
 tools/net/ynl/generated/devlink-user.h   | 2 --
 3 files changed, 8 deletions(-)
Documentation/netlink/specs/devlink.yaml +0 -1
index 86a12c5bcff1..08f0ffe72e63 100644
@@ -263,7 +263,6 @@ operations:
             - bus-name
             - dev-name
             - reload-failed
-            - reload-action
             - dev-stats
       dump:
         reply: *get-reply
tools/net/ynl/generated/devlink-user.c +0 -5
index 3a8d8499fab6..34ed9319a2b2 100644
@@ -475,11 +475,6 @@ int devlink_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
 				return MNL_CB_ERROR;
 			dst->_present.reload_failed = 1;
 			dst->reload_failed = mnl_attr_get_u8(attr);
-		} else if (type == DEVLINK_ATTR_RELOAD_ACTION) {
-			if (ynl_attr_validate(yarg, attr))
-				return MNL_CB_ERROR;
-			dst->_present.reload_action = 1;
-			dst->reload_action = mnl_attr_get_u8(attr);
 		} else if (type == DEVLINK_ATTR_DEV_STATS) {
 			if (ynl_attr_validate(yarg, attr))
 				return MNL_CB_ERROR;
tools/net/ynl/generated/devlink-user.h +0 -2
index a490466fb98a..5fbb20859837 100644
@@ -113,14 +113,12 @@ struct devlink_get_rsp {
 		__u32 bus_name_len;
 		__u32 dev_name_len;
 		__u32 reload_failed:1;
-		__u32 reload_action:1;
 		__u32 dev_stats:1;
 	} _present;
 
 	char *bus_name;
 	char *dev_name;
 	__u8 reload_failed;
-	__u8 reload_action;
 	struct devlink_dl_dev_stats dev_stats;
 };
 
Signature · 1 line
2.41.0
author maintainer
#27 lore raw

PATCH 4/10 netlink: specs: devlink: make dont-validate single line

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

Make dont-validate field more compact and push it into a single line.

---
 Documentation/netlink/specs/devlink.yaml | 67 ++++++------------------
 1 file changed, 16 insertions(+), 51 deletions(-)
Documentation/netlink/specs/devlink.yaml +16 -51
index 08f0ffe72e63..5308cc54cfc1 100644
@@ -245,10 +245,7 @@ operations:
       name: get
       doc: Get devlink instances.
       attribute-set: devlink
-      dont-validate:
-        - strict
-        - dump
-
+      dont-validate: [ strict, dump ]
       do:
         pre: devlink-nl-pre-doit
         post: devlink-nl-post-doit
@@ -271,9 +268,7 @@ operations:
       name: port-get
       doc: Get devlink port instances.
       attribute-set: devlink
-      dont-validate:
-        - strict
-
+      dont-validate: [ strict ]
       do:
         pre: devlink-nl-pre-doit-port
         post: devlink-nl-post-doit
@@ -299,9 +294,7 @@ operations:
       name: sb-get
       doc: Get shared buffer instances.
       attribute-set: devlink
-      dont-validate:
-        - strict
-
+      dont-validate: [ strict ]
       do:
         pre: devlink-nl-pre-doit
         post: devlink-nl-post-doit
@@ -325,9 +318,7 @@ operations:
       name: sb-pool-get
       doc: Get shared buffer pool instances.
       attribute-set: devlink
-      dont-validate:
-        - strict
-
+      dont-validate: [ strict ]
       do:
         pre: devlink-nl-pre-doit
         post: devlink-nl-post-doit
@@ -352,9 +343,7 @@ operations:
       name: sb-port-pool-get
       doc: Get shared buffer port-pool combinations and threshold.
       attribute-set: devlink
-      dont-validate:
-        - strict
-
+      dont-validate: [ strict ]
       do:
         pre: devlink-nl-pre-doit-port
         post: devlink-nl-post-doit
@@ -380,9 +369,7 @@ operations:
       name: sb-tc-pool-bind-get
       doc: Get shared buffer port-TC to pool bindings and threshold.
       attribute-set: devlink
-      dont-validate:
-        - strict
-
+      dont-validate: [ strict ]
       do:
         pre: devlink-nl-pre-doit-port
         post: devlink-nl-post-doit
@@ -409,9 +396,7 @@ operations:
       name: param-get
       doc: Get param instances.
       attribute-set: devlink
-      dont-validate:
-        - strict
-
+      dont-validate: [ strict ]
       do:
         pre: devlink-nl-pre-doit
         post: devlink-nl-post-doit
@@ -435,9 +420,7 @@ operations:
       name: region-get
       doc: Get region instances.
       attribute-set: devlink
-      dont-validate:
-        - strict
-
+      dont-validate: [ strict ]
       do:
         pre: devlink-nl-pre-doit-port-optional
         post: devlink-nl-post-doit
@@ -462,10 +445,7 @@ operations:
       name: info-get
       doc: Get device information, like driver name, hardware and firmware versions etc.
       attribute-set: devlink
-      dont-validate:
-        - strict
-        - dump
-
+      dont-validate: [ strict, dump ]
       do:
         pre: devlink-nl-pre-doit
         post: devlink-nl-post-doit
@@ -489,9 +469,7 @@ operations:
       name: health-reporter-get
       doc: Get health reporter instances.
       attribute-set: devlink
-      dont-validate:
-        - strict
-
+      dont-validate: [ strict ]
       do:
         pre: devlink-nl-pre-doit-port-optional
         post: devlink-nl-post-doit
@@ -514,9 +492,7 @@ operations:
       name: trap-get
       doc: Get trap instances.
       attribute-set: devlink
-      dont-validate:
-        - strict
-
+      dont-validate: [ strict ]
       do:
         pre: devlink-nl-pre-doit
         post: devlink-nl-post-doit
@@ -540,9 +516,7 @@ operations:
       name: trap-group-get
       doc: Get trap group instances.
       attribute-set: devlink
-      dont-validate:
-        - strict
-
+      dont-validate: [ strict ]
       do:
         pre: devlink-nl-pre-doit
         post: devlink-nl-post-doit
@@ -566,9 +540,7 @@ operations:
       name: trap-policer-get
       doc: Get trap policer instances.
       attribute-set: devlink
-      dont-validate:
-        - strict
-
+      dont-validate: [ strict ]
       do:
         pre: devlink-nl-pre-doit
         post: devlink-nl-post-doit
@@ -592,9 +564,7 @@ operations:
       name: rate-get
       doc: Get rate instances.
       attribute-set: devlink
-      dont-validate:
-        - strict
-
+      dont-validate: [ strict ]
       do:
         pre: devlink-nl-pre-doit
         post: devlink-nl-post-doit
@@ -619,9 +589,7 @@ operations:
       name: linecard-get
       doc: Get line card instances.
       attribute-set: devlink
-      dont-validate:
-        - strict
-
+      dont-validate: [ strict ]
       do:
         pre: devlink-nl-pre-doit
         post: devlink-nl-post-doit
@@ -645,10 +613,7 @@ operations:
       name: selftests-get
       doc: Get device selftest instances.
       attribute-set: devlink
-      dont-validate:
-        - strict
-        - dump
-
+      dont-validate: [ strict, dump ]
       do:
         pre: devlink-nl-pre-doit
         post: devlink-nl-post-doit
Signature · 1 line
2.41.0
author maintainer
#28 lore raw

PATCH 5/10 netlink: specs: devlink: fix reply command values

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

Make sure that the command values used for replies are correct. This is only affecting generated userspace helpers, no change on kernel code.

Fixes 7199c86247e9 ("netlink: specs: devlink: add commands that do per-instance dump")
---
 Documentation/netlink/specs/devlink.yaml | 18 ++++----
 tools/net/ynl/generated/devlink-user.c   | 54 ++++++++++++------------
 2 files changed, 36 insertions(+), 36 deletions(-)
Documentation/netlink/specs/devlink.yaml +9 -9
index 5308cc54cfc1..dd035a8f5eb4 100644
@@ -305,7 +305,7 @@ operations:
             - dev-name
             - sb-index
         reply: &sb-get-reply
-          value: 11
+          value: 13
           attributes: *sb-id-attrs
       dump:
         request:
@@ -330,7 +330,7 @@ operations:
             - sb-index
             - sb-pool-index
         reply: &sb-pool-get-reply
-          value: 15
+          value: 17
           attributes: *sb-pool-id-attrs
       dump:
         request:
@@ -356,7 +356,7 @@ operations:
             - sb-index
             - sb-pool-index
         reply: &sb-port-pool-get-reply
-          value: 19
+          value: 21
           attributes: *sb-port-pool-id-attrs
       dump:
         request:
@@ -383,7 +383,7 @@ operations:
             - sb-pool-type
             - sb-tc-index
         reply: &sb-tc-pool-bind-get-reply
-          value: 23
+          value: 25
           attributes: *sb-tc-pool-bind-id-attrs
       dump:
         request:
@@ -503,7 +503,7 @@ operations:
             - dev-name
             - trap-name
         reply: &trap-get-reply
-          value: 61
+          value: 63
           attributes: *trap-id-attrs
       dump:
         request:
@@ -527,7 +527,7 @@ operations:
             - dev-name
             - trap-group-name
         reply: &trap-group-get-reply
-          value: 65
+          value: 67
           attributes: *trap-group-id-attrs
       dump:
         request:
@@ -551,7 +551,7 @@ operations:
             - dev-name
             - trap-policer-id
         reply: &trap-policer-get-reply
-          value: 69
+          value: 71
           attributes: *trap-policer-id-attrs
       dump:
         request:
@@ -576,7 +576,7 @@ operations:
             - port-index
             - rate-node-name
         reply: &rate-get-reply
-          value: 74
+          value: 76
           attributes: *rate-id-attrs
       dump:
         request:
@@ -600,7 +600,7 @@ operations:
             - dev-name
             - linecard-index
         reply: &linecard-get-reply
-          value: 78
+          value: 80
           attributes: *linecard-id-attrs
       dump:
         request:
tools/net/ynl/generated/devlink-user.c +27 -27

172 lines not on this page · raw message

Signature · 1 line
2.41.0
maintainer
#29 lore raw

Re: [patch net-next 05/10] netlink: specs: devlink: fix reply command values

Quoted 4 lines · On Tue, 10 Oct 2023 13:08:24 +0200 Jiri Pirko wrote:

From: Jiri Pirko <[email protected]>

Make sure that the command values used for replies are correct. This is only affecting generated userspace helpers, no change on kernel code.

Still, I think this needs net.

author maintainer
#30 lore raw

Re: [patch net-next 05/10] netlink: specs: devlink: fix reply command values

Quoted 7 lines · Tue, Oct 10, 2023 at 08:59:35PM CEST, [email protected] wrote:
Quoted 4 lines · On Tue, 10 Oct 2023 13:08:24 +0200 Jiri Pirko wrote:

From: Jiri Pirko <[email protected]>

Make sure that the command values used for replies are correct. This is only affecting generated userspace helpers, no change on kernel code.

Still, I think this needs net.

It affects only userspace generated code, that's why I didn't bother. If you insist, I can send separate patch to net.

maintainer
#31 lore raw

Re: [patch net-next 05/10] netlink: specs: devlink: fix reply command values

Quoted 4 lines · On Wed, 11 Oct 2023 08:04:27 +0200 Jiri Pirko wrote:
Quoted 1 line

Still, I think this needs net.

It affects only userspace generated code, that's why I didn't bother. If you insist, I can send separate patch to net.

Yes, please.

author maintainer
#32 lore raw

Re: [patch net-next 05/10] netlink: specs: devlink: fix reply command values

Quoted 7 lines · Wed, Oct 11, 2023 at 06:44:04PM CEST, [email protected] wrote:
Quoted 4 lines · On Wed, 11 Oct 2023 08:04:27 +0200 Jiri Pirko wrote:
Quoted 1 line

Still, I think this needs net.

It affects only userspace generated code, that's why I didn't bother. If you insist, I can send separate patch to net.

Yes, please.

Ok.

author maintainer
#33 lore raw

PATCH 6/10 devlink: make devlink_flash_overwrite enum named one

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

Since this enum is going to be used in generated userspace file, name it properly.

---
 include/uapi/linux/devlink.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/devlink.h +1 -1
index cd4b82458d1b..b3c8383d342d 100644
@@ -265,7 +265,7 @@ enum {
  * Documentation/networking/devlink/devlink-flash.rst
  *
  */
-enum {
+enum devlink_flash_overwrite {
 	DEVLINK_FLASH_OVERWRITE_SETTINGS_BIT,
 	DEVLINK_FLASH_OVERWRITE_IDENTIFIERS_BIT,
 
Signature · 1 line
2.41.0
author maintainer
#34 lore raw

PATCH 7/10 devlink: rename netlink callback to be aligned with the generated ones

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

All remaining doit and dumpit netlink callback functions are going to be used by generated split ops. They expect certain name format. Rename the callback to be aligned with generated names.

---
 net/devlink/dev.c           |  10 ++--
 net/devlink/devl_internal.h | 108 ++++++++++++++++++------------------
 net/devlink/dpipe.c         |  14 ++---
 net/devlink/health.c        |  24 ++++----
 net/devlink/linecard.c      |   3 +-
 net/devlink/netlink.c       |  82 +++++++++++++--------------
 net/devlink/param.c         |  14 ++---
 net/devlink/port.c          |  11 ++--
 net/devlink/rate.c          |   6 +-
 net/devlink/region.c        |   8 +--
 net/devlink/resource.c      |   4 +-
 net/devlink/sb.c            |  17 +++---
 net/devlink/trap.c          |   9 ++-
 13 files changed, 152 insertions(+), 158 deletions(-)
net/devlink/dev.c +5 -5
index dc8039ca2b38..4fc7adb32663 100644
@@ -492,7 +492,7 @@ devlink_nl_reload_actions_performed_snd(struct devlink *devlink, u32 actions_per
 	return -EMSGSIZE;
 }
 
-int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_reload_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	enum devlink_reload_action action;
@@ -658,7 +658,7 @@ static int devlink_nl_eswitch_fill(struct sk_buff *msg, struct devlink *devlink,
 	return err;
 }
 
-int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	struct sk_buff *msg;
@@ -679,7 +679,7 @@ int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info)
 	return genlmsg_reply(msg, info);
 }
 
-int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	const struct devlink_ops *ops = devlink->ops;
@@ -1108,7 +1108,7 @@ static int devlink_flash_component_get(struct devlink *devlink,
 	return 0;
 }
 
-int devlink_nl_cmd_flash_update(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_flash_update_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct nlattr *nla_overwrite_mask, *nla_file_name;
 	struct devlink_flash_update_params params = {};
@@ -1351,7 +1351,7 @@ static const struct nla_policy devlink_selftest_nl_policy[DEVLINK_ATTR_SELFTEST_
 	[DEVLINK_ATTR_SELFTEST_ID_FLASH] = { .type = NLA_FLAG },
 };
 
-int devlink_nl_cmd_selftests_run(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_selftests_run_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct nlattr *tb[DEVLINK_ATTR_SELFTEST_ID_MAX + 1];
 	struct devlink *devlink = info->user_ptr[0];
net/devlink/devl_internal.h +53 -55

118 lines not on this page · raw message

net/devlink/dpipe.c +7 -7
index 431227c412e5..a72a9292efc5 100644
@@ -289,7 +289,7 @@ static int devlink_dpipe_tables_fill(struct genl_info *info,
 	return err;
 }
 
-int devlink_nl_cmd_dpipe_table_get(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_dpipe_table_get_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	const char *table_name =  NULL;
@@ -562,8 +562,8 @@ static int devlink_dpipe_entries_fill(struct genl_info *info,
 	return genlmsg_reply(dump_ctx.skb, info);
 }
 
-int devlink_nl_cmd_dpipe_entries_get(struct sk_buff *skb,
-				     struct genl_info *info)
+int devlink_nl_dpipe_entries_get_doit(struct sk_buff *skb,
+				      struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	struct devlink_dpipe_table *table;
@@ -712,8 +712,8 @@ static int devlink_dpipe_headers_fill(struct genl_info *info,
 	return err;
 }
 
-int devlink_nl_cmd_dpipe_headers_get(struct sk_buff *skb,
-				     struct genl_info *info)
+int devlink_nl_dpipe_headers_get_doit(struct sk_buff *skb,
+				      struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 
@@ -746,8 +746,8 @@ static int devlink_dpipe_table_counters_set(struct devlink *devlink,
 	return 0;
 }
 
-int devlink_nl_cmd_dpipe_table_counters_set(struct sk_buff *skb,
-					    struct genl_info *info)
+int devlink_nl_dpipe_table_counters_set_doit(struct sk_buff *skb,
+					     struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	const char *table_name;
net/devlink/health.c +12 -12
index 638cad8d5c65..1a13a90cf5c7 100644
@@ -454,8 +454,8 @@ int devlink_nl_health_reporter_get_dumpit(struct sk_buff *skb,
 				 devlink_nl_health_reporter_get_dump_one);
 }
 
-int devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb,
-					    struct genl_info *info)
+int devlink_nl_health_reporter_set_doit(struct sk_buff *skb,
+					struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	struct devlink_health_reporter *reporter;
@@ -660,8 +660,8 @@ devlink_health_reporter_state_update(struct devlink_health_reporter *reporter,
 }
 EXPORT_SYMBOL_GPL(devlink_health_reporter_state_update);
 
-int devlink_nl_cmd_health_reporter_recover_doit(struct sk_buff *skb,
-						struct genl_info *info)
+int devlink_nl_health_reporter_recover_doit(struct sk_buff *skb,
+					    struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	struct devlink_health_reporter *reporter;
@@ -1222,8 +1222,8 @@ static int devlink_fmsg_dumpit(struct devlink_fmsg *fmsg, struct sk_buff *skb,
 	return err;
 }
 
-int devlink_nl_cmd_health_reporter_diagnose_doit(struct sk_buff *skb,
-						 struct genl_info *info)
+int devlink_nl_health_reporter_diagnose_doit(struct sk_buff *skb,
+					     struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	struct devlink_health_reporter *reporter;
@@ -1279,8 +1279,8 @@ devlink_health_reporter_get_from_cb(struct netlink_callback *cb)
 	return reporter;
 }
 
-int devlink_nl_cmd_health_reporter_dump_get_dumpit(struct sk_buff *skb,
-						   struct netlink_callback *cb)
+int devlink_nl_health_reporter_dump_get_dumpit(struct sk_buff *skb,
+					       struct netlink_callback *cb)
 {
 	struct devlink_nl_dump_state *state = devlink_dump_state(cb);
 	struct devlink_health_reporter *reporter;
@@ -1313,8 +1313,8 @@ int devlink_nl_cmd_health_reporter_dump_get_dumpit(struct sk_buff *skb,
 	return err;
 }
 
-int devlink_nl_cmd_health_reporter_dump_clear_doit(struct sk_buff *skb,
-						   struct genl_info *info)
+int devlink_nl_health_reporter_dump_clear_doit(struct sk_buff *skb,
+					       struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	struct devlink_health_reporter *reporter;
@@ -1332,8 +1332,8 @@ int devlink_nl_cmd_health_reporter_dump_clear_doit(struct sk_buff *skb,
 	return 0;
 }
 
-int devlink_nl_cmd_health_reporter_test_doit(struct sk_buff *skb,
-					     struct genl_info *info)
+int devlink_nl_health_reporter_test_doit(struct sk_buff *skb,
+					 struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	struct devlink_health_reporter *reporter;
net/devlink/linecard.c +1 -2
index 9ff1813f88c5..2f1c317b64cd 100644
@@ -369,8 +369,7 @@ static int devlink_linecard_type_unset(struct devlink_linecard *linecard,
 	return err;
 }
 
-int devlink_nl_cmd_linecard_set_doit(struct sk_buff *skb,
-				     struct genl_info *info)
+int devlink_nl_linecard_set_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct netlink_ext_ack *extack = info->extack;
 	struct devlink *devlink = info->user_ptr[0];
net/devlink/netlink.c +41 -41

288 lines not on this page · raw message

net/devlink/param.c +7 -7
index 31275f9d4cb7..d74df09311a9 100644
@@ -581,7 +581,7 @@ static int __devlink_nl_cmd_param_set_doit(struct devlink *devlink,
 	return 0;
 }
 
-int devlink_nl_cmd_param_set_doit(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_param_set_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 
@@ -589,22 +589,22 @@ int devlink_nl_cmd_param_set_doit(struct sk_buff *skb, struct genl_info *info)
 					       info, DEVLINK_CMD_PARAM_NEW);
 }
 
-int devlink_nl_cmd_port_param_get_dumpit(struct sk_buff *msg,
-					 struct netlink_callback *cb)
+int devlink_nl_port_param_get_dumpit(struct sk_buff *msg,
+				     struct netlink_callback *cb)
 {
 	NL_SET_ERR_MSG(cb->extack, "Port params are not supported");
 	return msg->len;
 }
 
-int devlink_nl_cmd_port_param_get_doit(struct sk_buff *skb,
-				       struct genl_info *info)
+int devlink_nl_port_param_get_doit(struct sk_buff *skb,
+				   struct genl_info *info)
 {
 	NL_SET_ERR_MSG(info->extack, "Port params are not supported");
 	return -EINVAL;
 }
 
-int devlink_nl_cmd_port_param_set_doit(struct sk_buff *skb,
-				       struct genl_info *info)
+int devlink_nl_port_param_set_doit(struct sk_buff *skb,
+				   struct genl_info *info)
 {
 	NL_SET_ERR_MSG(info->extack, "Port params are not supported");
 	return -EINVAL;
net/devlink/port.c +5 -6
index 4e9003242448..7634f187fa50 100644
@@ -772,7 +772,7 @@ static int devlink_port_function_set(struct devlink_port *port,
 	return err;
 }
 
-int devlink_nl_cmd_port_set_doit(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_port_set_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink_port *devlink_port = info->user_ptr[1];
 	int err;
@@ -798,7 +798,7 @@ int devlink_nl_cmd_port_set_doit(struct sk_buff *skb, struct genl_info *info)
 	return 0;
 }
 
-int devlink_nl_cmd_port_split_doit(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_port_split_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink_port *devlink_port = info->user_ptr[1];
 	struct devlink *devlink = info->user_ptr[0];
@@ -829,8 +829,7 @@ int devlink_nl_cmd_port_split_doit(struct sk_buff *skb, struct genl_info *info)
 					     info->extack);
 }
 
-int devlink_nl_cmd_port_unsplit_doit(struct sk_buff *skb,
-				     struct genl_info *info)
+int devlink_nl_port_unsplit_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink_port *devlink_port = info->user_ptr[1];
 	struct devlink *devlink = info->user_ptr[0];
@@ -840,7 +839,7 @@ int devlink_nl_cmd_port_unsplit_doit(struct sk_buff *skb,
 	return devlink_port->ops->port_unsplit(devlink, devlink_port, info->extack);
 }
 
-int devlink_nl_cmd_port_new_doit(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_port_new_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct netlink_ext_ack *extack = info->extack;
 	struct devlink_port_new_attrs new_attrs = {};
@@ -904,7 +903,7 @@ int devlink_nl_cmd_port_new_doit(struct sk_buff *skb, struct genl_info *info)
 	return err;
 }
 
-int devlink_nl_cmd_port_del_doit(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_port_del_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink_port *devlink_port = info->user_ptr[1];
 	struct netlink_ext_ack *extack = info->extack;
net/devlink/rate.c +3 -3
index dff1593b8406..94b289b93ff2 100644
@@ -458,7 +458,7 @@ static bool devlink_rate_set_ops_supported(const struct devlink_ops *ops,
 	return true;
 }
 
-int devlink_nl_cmd_rate_set_doit(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_rate_set_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	struct devlink_rate *devlink_rate;
@@ -480,7 +480,7 @@ int devlink_nl_cmd_rate_set_doit(struct sk_buff *skb, struct genl_info *info)
 	return err;
 }
 
-int devlink_nl_cmd_rate_new_doit(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_rate_new_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	struct devlink_rate *rate_node;
@@ -536,7 +536,7 @@ int devlink_nl_cmd_rate_new_doit(struct sk_buff *skb, struct genl_info *info)
 	return err;
 }
 
-int devlink_nl_cmd_rate_del_doit(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_rate_del_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	struct devlink_rate *rate_node;
net/devlink/region.c +4 -4
index d197cdb662db..0aab7b82d678 100644
@@ -588,7 +588,7 @@ int devlink_nl_region_get_dumpit(struct sk_buff *skb,
 	return devlink_nl_dumpit(skb, cb, devlink_nl_region_get_dump_one);
 }
 
-int devlink_nl_cmd_region_del(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_region_del_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	struct devlink_snapshot *snapshot;
@@ -633,7 +633,7 @@ int devlink_nl_cmd_region_del(struct sk_buff *skb, struct genl_info *info)
 	return 0;
 }
 
-int devlink_nl_cmd_region_new(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_region_new_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	struct devlink_snapshot *snapshot;
@@ -863,8 +863,8 @@ devlink_region_direct_fill(void *cb_priv, u8 *chunk, u32 chunk_size,
 				 curr_offset, chunk_size, chunk);
 }
 
-int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
-				      struct netlink_callback *cb)
+int devlink_nl_region_read_dumpit(struct sk_buff *skb,
+				  struct netlink_callback *cb)
 {
 	const struct genl_dumpit_info *info = genl_dumpit_info(cb);
 	struct devlink_nl_dump_state *state = devlink_dump_state(cb);
net/devlink/resource.c +2 -2
index c8b615e4c385..594c8aeb3bfa 100644
@@ -105,7 +105,7 @@ devlink_resource_validate_size(struct devlink_resource *resource, u64 size,
 	return err;
 }
 
-int devlink_nl_cmd_resource_set(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_resource_set_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	struct devlink_resource *resource;
@@ -285,7 +285,7 @@ static int devlink_resource_fill(struct genl_info *info,
 	return err;
 }
 
-int devlink_nl_cmd_resource_dump(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_resource_dump_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 
net/devlink/sb.c +8 -9
index bd677fff5ec8..0a76bb32502b 100644
@@ -413,7 +413,7 @@ static int devlink_sb_pool_set(struct devlink *devlink, unsigned int sb_index,
 	return -EOPNOTSUPP;
 }
 
-int devlink_nl_cmd_sb_pool_set_doit(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_sb_pool_set_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	enum devlink_sb_threshold_type threshold_type;
@@ -621,8 +621,8 @@ static int devlink_sb_port_pool_set(struct devlink_port *devlink_port,
 	return -EOPNOTSUPP;
 }
 
-int devlink_nl_cmd_sb_port_pool_set_doit(struct sk_buff *skb,
-					 struct genl_info *info)
+int devlink_nl_sb_port_pool_set_doit(struct sk_buff *skb,
+				     struct genl_info *info)
 {
 	struct devlink_port *devlink_port = info->user_ptr[1];
 	struct devlink *devlink = info->user_ptr[0];
@@ -861,8 +861,8 @@ static int devlink_sb_tc_pool_bind_set(struct devlink_port *devlink_port,
 	return -EOPNOTSUPP;
 }
 
-int devlink_nl_cmd_sb_tc_pool_bind_set_doit(struct sk_buff *skb,
-					    struct genl_info *info)
+int devlink_nl_sb_tc_pool_bind_set_doit(struct sk_buff *skb,
+					struct genl_info *info)
 {
 	struct devlink_port *devlink_port = info->user_ptr[1];
 	struct devlink *devlink = info->user_ptr[0];
@@ -900,8 +900,7 @@ int devlink_nl_cmd_sb_tc_pool_bind_set_doit(struct sk_buff *skb,
 					   pool_index, threshold, info->extack);
 }
 
-int devlink_nl_cmd_sb_occ_snapshot_doit(struct sk_buff *skb,
-					struct genl_info *info)
+int devlink_nl_sb_occ_snapshot_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	const struct devlink_ops *ops = devlink->ops;
@@ -916,8 +915,8 @@ int devlink_nl_cmd_sb_occ_snapshot_doit(struct sk_buff *skb,
 	return -EOPNOTSUPP;
 }
 
-int devlink_nl_cmd_sb_occ_max_clear_doit(struct sk_buff *skb,
-					 struct genl_info *info)
+int devlink_nl_sb_occ_max_clear_doit(struct sk_buff *skb,
+				     struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	const struct devlink_ops *ops = devlink->ops;
net/devlink/trap.c +4 -5
index c26bf9b29bca..c26313e7ca08 100644
@@ -414,7 +414,7 @@ static int devlink_trap_action_set(struct devlink *devlink,
 					 info->extack);
 }
 
-int devlink_nl_cmd_trap_set_doit(struct sk_buff *skb, struct genl_info *info)
+int devlink_nl_trap_set_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct netlink_ext_ack *extack = info->extack;
 	struct devlink *devlink = info->user_ptr[0];
@@ -684,8 +684,7 @@ static int devlink_trap_group_set(struct devlink *devlink,
 	return 0;
 }
 
-int devlink_nl_cmd_trap_group_set_doit(struct sk_buff *skb,
-				       struct genl_info *info)
+int devlink_nl_trap_group_set_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct netlink_ext_ack *extack = info->extack;
 	struct devlink *devlink = info->user_ptr[0];
@@ -926,8 +925,8 @@ devlink_trap_policer_set(struct devlink *devlink,
 	return 0;
 }
 
-int devlink_nl_cmd_trap_policer_set_doit(struct sk_buff *skb,
-					 struct genl_info *info)
+int devlink_nl_trap_policer_set_doit(struct sk_buff *skb,
+				     struct genl_info *info)
 {
 	struct devlink_trap_policer_item *policer_item;
 	struct netlink_ext_ack *extack = info->extack;
Signature · 1 line
2.41.0
author maintainer
#35 lore raw

PATCH 8/10 netlink: specs: devlink: add the remaining command to generate complete split_ops

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

Currently, some of the commands are not described in devlink yaml file and are manually filled in net/devlink/netlink.c in small_ops. To make all part of split_ops, add definitions of the rest of the commands alongside with needed attributes and enums.

Note that this focuses on the kernel side. The requests are fully described in order to generate split_op alongside with policies. Follow-up will describe the replies in order to make the userspace helpers complete.

---
 Documentation/netlink/specs/devlink.yaml | 1525 ++++++-
 net/devlink/netlink_gen.c                |  757 +++-
 net/devlink/netlink_gen.h                |   64 +-
 tools/net/ynl/generated/devlink-user.c   | 4877 +++++++++++++++++++---
 tools/net/ynl/generated/devlink-user.h   | 4191 ++++++++++++++++---
 5 files changed, 10340 insertions(+), 1074 deletions(-)
Documentation/netlink/specs/devlink.yaml +1473 -52
index dd035a8f5eb4..422d64d84767 100644
@@ -15,6 +15,161 @@ definitions:
         name: ingress
       -
         name: egress
+  -
+    type: enum
+    name: port-type
+    entries:
+      -
+        name: notset
+      -
+        name: auto
+      -
+        name: eth
+      -
+        name: ib
+  -
+    type: enum
+    name: port-flavour
+    entries:
+      -
+        name: physical
+      -
+        name: cpu
+      -
+        name: dsa
+      -
+        name: pci_pf
+      -
+        name: pci_vf
+      -
+        name: virtual
+      -
+        name: unused
+      -
+        name: pci_sf
+  -
+    type: enum
+    name: port-fn-state
+    entries:
+      -
+        name: inactive
+      -
+        name: active
+  -
+    type: enum
+    name: port-fn-opstate
+    entries:
+      -
+        name: detached
+      -
+        name: attached
+  -
+    type: enum
+    name: port-fn-attr-cap
+    entries:
+      -
+        name: roce-bit
+      -
+        name: migratable-bit
+  -
+    type: enum
+    name: sb-threshold-type
+    entries:
+      -
+        name: static
+      -
+        name: dynamic
+  -
+    type: enum
+    name: eswitch-mode
+    entries:
+      -
+        name: legacy
+      -
+        name: switchdev
+  -
+    type: enum
+    name: eswitch-inline-mode
+    entries:
+      -
+        name: none
+      -
+        name: link
+      -
+        name: network
+      -
+        name: transport
+  -
+    type: enum
+    name: eswitch-encap-mode
+    entries:
+      -
+        name: none
+      -
+        name: basic
+  -
+    type: enum
+    name: dpipe-match-type
+    entries:
+      -
+        name: field-exact
+  -
+    type: enum
+    name: dpipe-action-type
+    entries:
+      -
+        name: field-modify
+  -
+    type: enum
+    name: dpipe-field-mapping-type
+    entries:
+      -
+        name: none
+      -
+        name: ifindex
+  -
+    type: enum
+    name: resource-unit
+    entries:
+      -
+        name: entry
+  -
+    type: enum
+    name: reload-action
+    entries:
+      -
+        name: driver-reinit
+        value: 1
+      -
+        name: fw-activate
+  -
+    type: enum
+    name: param-cmode
+    entries:
+      -
+        name: runtime
+      -
+        name: driverinit
+      -
+        name: permanent
+  -
+    type: enum
+    name: flash-overwrite
+    entries:
+      -
+        name: settings-bit
+      -
+        name: identifiers-bit
+  -
+    type: enum
+    name: trap-action
+    entries:
+      -
+        name: drop
+      -
+        name: trap
+      -
+        name: mirror
 
 attribute-sets:
   -
@@ -31,6 +186,17 @@ attribute-sets:
       -
         name: port-index
         type: u32
+      -
+        name: port-type
+        type: u16
+        enum: port-type
+
+      # TODO: fill in the attributes in between
+
+      -
+        name: port-split-count
+        type: u32
+        value: 9
 
       # TODO: fill in the attributes in between
 
@@ -45,18 +211,224 @@ attribute-sets:
         name: sb-pool-index
         type: u16
         value: 17
-
       -
         name: sb-pool-type
         type: u8
         enum: sb-pool-type
+      -
+        name: sb-pool-size
+        type: u32
+      -
+        name: sb-pool-threshold-type
+        type: u8
+        enum: sb-threshold-type
+      -
+        name: sb-threshold
+        type: u32
+      -
+        name: sb-tc-index
+        type: u16
+        value: 22
 
       # TODO: fill in the attributes in between
 
       -
-        name: sb-tc-index
+        name: eswitch-mode
         type: u16
-        value: 22
+        value: 25
+        enum: eswitch-mode
+
+      -
+        name: eswitch-inline-mode
+        type: u16
+        enum: eswitch-inline-mode
+      -
+        name: dpipe-tables
+        type: nest
+        nested-attributes: dl-dpipe-tables
+      -
+        name: dpipe-table
+        type: nest
+        multi-attr: true
+        nested-attributes: dl-dpipe-table
+      -
+        name: dpipe-table-name
+        type: string
+      -
+        name: dpipe-table-size
+        type: u64
+      -
+        name: dpipe-table-matches
+        type: nest
+        nested-attributes: dl-dpipe-table-matches
+      -
+        name: dpipe-table-actions
+        type: nest
+        nested-attributes: dl-dpipe-table-actions
+      -
+        name: dpipe-table-counters-enabled
+        type: u8
+      -
+        name: dpipe-entries
+        type: nest
+        nested-attributes: dl-dpipe-entries
+      -
+        name: dpipe-entry
+        type: nest
+        multi-attr: true
+        nested-attributes: dl-dpipe-entry
+      -
+        name: dpipe-entry-index
+        type: u64
+      -
+        name: dpipe-entry-match-values
+        type: nest
+        nested-attributes: dl-dpipe-entry-match-values
+      -
+        name: dpipe-entry-action-values
+        type: nest
+        nested-attributes: dl-dpipe-entry-action-values
+      -
+        name: dpipe-entry-counter
+        type: u64
+      -
+        name: dpipe-match
+        type: nest
+        multi-attr: true
+        nested-attributes: dl-dpipe-match
+      -
+        name: dpipe-match-value
+        type: nest
+        multi-attr: true
+        nested-attributes: dl-dpipe-match-value
+      -
+        name: dpipe-match-type
+        type: u32
+        enum: dpipe-match-type
+      -
+        name: dpipe-action
+        type: nest
+        multi-attr: true
+        nested-attributes: dl-dpipe-action
+      -
+        name: dpipe-action-value
+        type: nest
+        multi-attr: true
+        nested-attributes: dl-dpipe-action-value
+      -
+        name: dpipe-action-type
+        type: u32
+        enum: dpipe-action-type
+      -
+        name: dpipe-value
+        type: binary
+      -
+        name: dpipe-value-mask
+        type: binary
+      -
+        name: dpipe-value-mapping
+        type: u32
+      -
+        name: dpipe-headers
+        type: nest
+        nested-attributes: dl-dpipe-headers
+      -
+        name: dpipe-header
+        type: nest
+        multi-attr: true
+        nested-attributes: dl-dpipe-header
+      -
+        name: dpipe-header-name
+        type: string
+      -
+        name: dpipe-header-id
+        type: u32
+      -
+        name: dpipe-header-fields
+        type: nest
+        nested-attributes: dl-dpipe-header-fields
+      -
+        name: dpipe-header-global
+        type: u8
+      -
+        name: dpipe-header-index
+        type: u32
+      -
+        name: dpipe-field
+        type: nest
+        multi-attr: true
+        nested-attributes: dl-dpipe-field
+      -
+        name: dpipe-field-name
+        type: string
+      -
+        name: dpipe-field-id
+        type: u32
+      -
+        name: dpipe-field-bitwidth
+        type: u32
+      -
+        name: dpipe-field-mapping-type
+        type: u32
+        enum: dpipe-field-mapping-type
+      -
+        name: pad
+        type: pad
+      -
+        name: eswitch-encap-mode
+        type: u8
+        value: 62
+        enum: eswitch-encap-mode
+      -
+        name: resource-list
+        type: nest
+        nested-attributes: dl-resource-list
+      -
+        name: resource
+        type: nest
+        multi-attr: true
+        nested-attributes: dl-resource
+      -
+        name: resource-name
+        type: string
+      -
+        name: resource-id
+        type: u64
+      -
+        name: resource-size
+        type: u64
+      -
+        name: resource-size-new
+        type: u64
+      -
+        name: resource-size-valid
+        type: u8
+      -
+        name: resource-size-min
+        type: u64
+      -
+        name: resource-size-max
+        type: u64
+      -
+        name: resource-size-gran
+        type: u64
+      -
+        name: resource-unit
+        type: u8
+        enum: resource-unit
+      -
+        name: resource-occ
+        type: u64
+      -
+        name: dpipe-table-resource-id
+        type: u64
+      -
+        name: dpipe-table-resource-units
+        type: u64
+      -
+        name: port-flavour
+        type: u16
+        enum: port-flavour
 
       # TODO: fill in the attributes in between
 
@@ -67,17 +439,41 @@ attribute-sets:
 
       # TODO: fill in the attributes in between
 
+      -
+        name: param-type
+        type: u8
+        value: 83
+
+      # TODO: fill in the attributes in between
+
+      -
+        name: param-value-cmode
+        type: u8
+        enum: param-cmode
+        value: 87
       -
         name: region-name
         type: string
-        value: 88
 
       # TODO: fill in the attributes in between
 
+      -
+        name: region-snapshot-id
+        type: u32
+        value: 92
+
+      # TODO: fill in the attributes in between
+
+      -
+        name: region-chunk-addr
+        type: u64
+        value: 96
+      -
+        name: region-chunk-len
+        type: u64
       -
         name: info-driver-name
         type: string
-        value: 98
       -
         name: info-serial-number
         type: string
@@ -105,6 +501,29 @@ attribute-sets:
 
       # TODO: fill in the attributes in between
 
+      -
+        name: fmsg
+        type: nest
+        nested-attributes: dl-fmsg
+        value: 106
+      -
+        name: fmsg-obj-nest-start
+        type: flag
+      -
+        name: fmsg-pair-nest-start
+        type: flag
+      -
+        name: fmsg-arr-nest-start
+        type: flag
+      -
+        name: fmsg-nest-end
+        type: flag
+      -
+        name: fmsg-obj-name
+        type: string
+
+      # TODO: fill in the attributes in between
+
       -
         name: health-reporter-name
         type: string
@@ -112,10 +531,37 @@ attribute-sets:
 
       # TODO: fill in the attributes in between
 
+      -
+        name: health-reporter-graceful-period
+        type: u64
+        value: 120
+      -
+        name: health-reporter-auto-recover
+        type: u8
+      -
+        name: flash-update-file-name
+        type: string
+      -
+        name: flash-update-component
+        type: string
+
+      # TODO: fill in the attributes in between
+
+      -
+        name: port-pci-pf-number
+        type: u16
+        value: 127
+
+      # TODO: fill in the attributes in between
+
       -
         name: trap-name
         type: string
         value: 130
+      -
+        name: trap-action
+        type: u8
+        enum: trap-action
 
       # TODO: fill in the attributes in between
 
@@ -131,23 +577,65 @@ attribute-sets:
       # TODO: fill in the attributes in between
 
       -
-        name: trap-policer-id
+        name: netns-fd
+        type: u32
+        value: 138
+      -
+        name: netns-pid
+        type: u32
+      -
+        name: netns-id
         type: u32
-        value: 142
 
       # TODO: fill in the attributes in between
 
       -
-        name: reload-action
+        name: health-reporter-auto-dump
         type: u8
-        value: 153
+        value: 141
+      -
+        name: trap-policer-id
+        type: u32
+      -
+        name: trap-policer-rate
+        type: u64
+      -
+        name: trap-policer-burst
+        type: u64
+      -
+        name: port-function
+        type: nest
+        nested-attributes: dl-port-function
+
+      # TODO: fill in the attributes in between
+
+      -
+        name: port-controller-number
+        type: u32
+        value: 150
 
       # TODO: fill in the attributes in between
 
+      -
+        name: flash-update-overwrite-mask
+        type: bitfield32
+        enum: flash-overwrite
+        value: 152
+      -
+        name: reload-action
+        type: u8
+        enum: reload-action
+      -
+        name: reload-actions-performed
+        type: bitfield32
+        enum: reload-action
+      -
+        name: reload-limits
+        type: bitfield32
+        enum: reload-action
       -
         name: dev-stats
         type: nest
-        value: 156
         nested-attributes: dl-dev-stats
       -
         name: reload-stats
@@ -181,10 +669,26 @@ attribute-sets:
 
       # TODO: fill in the attributes in between
 
+      -
+        name: port-pci-sf-number
+        type: u32
+        value: 164
+
+      # TODO: fill in the attributes in between
+
+      -
+        name: rate-tx-share
+        type: u64
+        value: 166
+      -
+        name: rate-tx-max
+        type: u64
       -
         name: rate-node-name
         type: string
-        value: 168
+      -
+        name: rate-parent-node-name
+        type: string
 
       # TODO: fill in the attributes in between
 
@@ -193,6 +697,30 @@ attribute-sets:
         type: u32
         value: 171
 
+      # TODO: fill in the attributes in between
+
+      -
+        name: linecard-type
+        type: string
+        value: 173
+
+      # TODO: fill in the attributes in between
+
+      -
+        name: selftests
+        type: nest
+        value: 176
+        nested-attributes: dl-selftest-id
+      -
+        name: rate-tx-priority
+        type: u32
+      -
+        name: rate-tx-weight
+        type: u32
+      -
+        name: region-direct
+        type: flag
+
   -
     name: dl-dev-stats
     subset-of: devlink
@@ -222,21 +750,274 @@ attribute-sets:
       -
         name: reload-stats-entry
   -
-    name: dl-reload-stats-entry
+    name: dl-reload-stats-entry
+    subset-of: devlink
+    attributes:
+      -
+        name: reload-stats-limit
+      -
+        name: reload-stats-value
+  -
+    name: dl-info-version
+    subset-of: devlink
+    attributes:
+      -
+        name: info-version-name
+      -
+        name: info-version-value
+  -
+    name: dl-port-function
+    name-prefix: devlink-port-fn-attr-
+    attr-max-name: devlink-port-function-attr-max
+    attributes:
+      -
+        name-prefix: devlink-port-function-attr-
+        name: hw-addr
+        type: binary
+        value: 1
+      -
+        name: state
+        type: u8
+        enum: port-fn-state
+      -
+        name: opstate
+        type: u8
+        enum: port-fn-opstate
+      -
+        name: caps
+        type: bitfield32
+        enum: port-fn-attr-cap
+
+  -
+    name: dl-dpipe-tables
+    subset-of: devlink
+    attributes:
+      -
+        name: dpipe-table
+
+  -
+    name: dl-dpipe-table
+    subset-of: devlink
+    attributes:
+      -
+        name: dpipe-table-name
+      -
+        name: dpipe-table-size
+      -
+        name: dpipe-table-name
+      -
+        name: dpipe-table-size
+      -
+        name: dpipe-table-matches
+      -
+        name: dpipe-table-actions
+      -
+        name: dpipe-table-counters-enabled
+      -
+        name: dpipe-table-resource-id
+      -
+        name: dpipe-table-resource-units
+
+  -
+    name: dl-dpipe-table-matches
+    subset-of: devlink
+    attributes:
+      -
+        name: dpipe-match
+
+  -
+    name: dl-dpipe-table-actions
+    subset-of: devlink
+    attributes:
+      -
+        name: dpipe-action
+
+  -
+    name: dl-dpipe-entries
+    subset-of: devlink
+    attributes:
+      -
+        name: dpipe-entry
+
+  -
+    name: dl-dpipe-entry
+    subset-of: devlink
+    attributes:
+      -
+        name: dpipe-entry-index
+      -
+        name: dpipe-entry-match-values
+      -
+        name: dpipe-entry-action-values
+      -
+        name: dpipe-entry-counter
+
+  -
+    name: dl-dpipe-entry-match-values
+    subset-of: devlink
+    attributes:
+      -
+        name: dpipe-match-value
+
+  -
+    name: dl-dpipe-entry-action-values
+    subset-of: devlink
+    attributes:
+      -
+        name: dpipe-action-value
+
+  -
+    name: dl-dpipe-match
+    subset-of: devlink
+    attributes:
+      -
+        name: dpipe-match-type
+      -
+        name: dpipe-header-id
+      -
+        name: dpipe-header-global
+      -
+        name: dpipe-header-index
+      -
+        name: dpipe-field-id
+
+  -
+    name: dl-dpipe-match-value
+    subset-of: devlink
+    attributes:
+      -
+        name: dpipe-match
+      -
+        name: dpipe-value
+      -
+        name: dpipe-value-mask
+      -
+        name: dpipe-value-mapping
+
+  -
+    name: dl-dpipe-action
+    subset-of: devlink
+    attributes:
+      -
+        name: dpipe-action-type
+      -
+        name: dpipe-header-id
+      -
+        name: dpipe-header-global
+      -
+        name: dpipe-header-index
+      -
+        name: dpipe-field-id
+
+  -
+    name: dl-dpipe-action-value
+    subset-of: devlink
+    attributes:
+      -
+        name: dpipe-action
+      -
+        name: dpipe-value
+      -
+        name: dpipe-value-mask
+      -
+        name: dpipe-value-mapping
+
+  -
+    name: dl-dpipe-headers
+    subset-of: devlink
+    attributes:
+      -
+        name: dpipe-header
+
+  -
+    name: dl-dpipe-header
+    subset-of: devlink
+    attributes:
+      -
+        name: dpipe-header-name
+      -
+        name: dpipe-header-id
+      -
+        name: dpipe-header-global
+      -
+        name: dpipe-header-fields
+
+  -
+    name: dl-dpipe-header-fields
+    subset-of: devlink
+    attributes:
+      -
+        name: dpipe-field
+
+  -
+    name: dl-dpipe-field
+    subset-of: devlink
+    attributes:
+      -
+        name: dpipe-field-name
+      -
+        name: dpipe-field-id
+      -
+        name: dpipe-field-bitwidth
+      -
+        name: dpipe-field-mapping-type
+
+  -
+    name: dl-resource-list
+    subset-of: devlink
+    attributes:
+      -
+        name: resource
+
+  -
+    name: dl-resource
+    subset-of: devlink
+    attributes:
+      -
+        name: resource-list
+      -
+        name: resource-name
+      -
+        name: resource-id
+      -
+        name: resource-size
+      -
+        name: resource-size-new
+      -
+        name: resource-size-valid
+      -
+        name: resource-size-min
+      -
+        name: resource-size-max
+      -
+        name: resource-size-gran
+      -
+        name: resource-unit
+      -
+        name: resource-occ
+
+  -
+    name: dl-fmsg
     subset-of: devlink
     attributes:
       -
-        name: reload-stats-limit
+        name: fmsg-obj-nest-start
       -
-        name: reload-stats-value
+        name: fmsg-pair-nest-start
+      -
+        name: fmsg-arr-nest-start
+      -
+        name: fmsg-nest-end
+      -
+        name: fmsg-obj-name
+
   -
-    name: dl-info-version
-    subset-of: devlink
+    name: dl-selftest-id
+    name-prefix: devlink-attr-selftest-id-
     attributes:
       -
-        name: info-version-name
-      -
-        name: info-version-value
+        name: flash
+        type: flag
 
 operations:
   enum-model: directional
@@ -287,8 +1068,84 @@ operations:
         reply:
           value: 3  # due to a bug, port dump returns DEVLINK_CMD_NEW
           attributes: *port-id-attrs
+    -
+      name: port-set
+      doc: Set devlink port instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit-port
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - port-index
+            - port-type
+            - port-function
+
+    -
+      name: port-new
+      doc: Create devlink port instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - port-index
+            - port-flavour
+            - port-pci-pf-number
+            - port-pci-sf-number
+            - port-controller-number
+        reply:
+          value: 7
+          attributes: *port-id-attrs
+
+    -
+      name: port-del
+      doc: Delete devlink port instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit-port
+        post: devlink-nl-post-doit
+        request:
+          attributes: *port-id-attrs
 
-      # TODO: fill in the operations in between
+    -
+      name: port-split
+      doc: Split devlink port instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit-port
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - port-index
+            - port-split-count
+
+    -
+      name: port-unsplit
+      doc: Unplit devlink port instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit-port
+        post: devlink-nl-post-doit
+        request:
+          attributes: *port-id-attrs
 
     -
       name: sb-get
@@ -312,8 +1169,6 @@ operations:
           attributes: *dev-id-attrs
         reply: *sb-get-reply
 
-      # TODO: fill in the operations in between
-
     -
       name: sb-pool-get
       doc: Get shared buffer pool instances.
@@ -337,7 +1192,23 @@ operations:
           attributes: *dev-id-attrs
         reply: *sb-pool-get-reply
 
-      # TODO: fill in the operations in between
+    -
+      name: sb-pool-set
+      doc: Set shared buffer pool instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - sb-index
+            - sb-pool-index
+            - sb-pool-threshold-type
+            - sb-pool-size
 
     -
       name: sb-port-pool-get
@@ -363,34 +1234,263 @@ operations:
           attributes: *dev-id-attrs
         reply: *sb-port-pool-get-reply
 
-      # TODO: fill in the operations in between
+    -
+      name: sb-port-pool-set
+      doc: Set shared buffer port-pool combinations and threshold.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit-port
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - port-index
+            - sb-index
+            - sb-pool-index
+            - sb-threshold
+
+    -
+      name: sb-tc-pool-bind-get
+      doc: Get shared buffer port-TC to pool bindings and threshold.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      do:
+        pre: devlink-nl-pre-doit-port
+        post: devlink-nl-post-doit
+        request:
+          value: 23
+          attributes: &sb-tc-pool-bind-id-attrs
+            - bus-name
+            - dev-name
+            - port-index
+            - sb-index
+            - sb-pool-type
+            - sb-tc-index
+        reply: &sb-tc-pool-bind-get-reply
+          value: 25
+          attributes: *sb-tc-pool-bind-id-attrs
+      dump:
+        request:
+          attributes: *dev-id-attrs
+        reply: *sb-tc-pool-bind-get-reply
+
+    -
+      name: sb-tc-pool-bind-set
+      doc: Set shared buffer port-TC to pool bindings and threshold.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit-port
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - port-index
+            - sb-index
+            - sb-pool-index
+            - sb-pool-type
+            - sb-tc-index
+            - sb-threshold
+
+    -
+      name: sb-occ-snapshot
+      doc: Take occupancy snapshot of shared buffer.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          value: 27
+          attributes:
+            - bus-name
+            - dev-name
+            - sb-index
+
+    -
+      name: sb-occ-max-clear
+      doc: Clear occupancy watermarks of shared buffer.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - sb-index
+
+    -
+      name: eswitch-get
+      doc: Get eswitch attributes.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes: *dev-id-attrs
+        reply:
+          value: 29
+          attributes: &eswitch-attrs
+            - bus-name
+            - dev-name
+            - eswitch-mode
+            - eswitch-inline-mode
+            - eswitch-encap-mode
+
+    -
+      name: eswitch-set
+      doc: Set eswitch attributes.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes: *eswitch-attrs
+
+    -
+      name: dpipe-table-get
+      doc: Get dpipe table attributes.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - dpipe-table-name
+        reply:
+          value: 31
+          attributes:
+            - bus-name
+            - dev-name
+            - dpipe-tables
+
+    -
+      name: dpipe-entries-get
+      doc: Get dpipe entries attributes.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - dpipe-table-name
+        reply:
+          attributes:
+            - bus-name
+            - dev-name
+            - dpipe-entries
+
+    -
+      name: dpipe-headers-get
+      doc: Get dpipe headers attributes.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+        reply:
+          attributes:
+            - bus-name
+            - dev-name
+            - dpipe-headers
+
+    -
+      name: dpipe-table-counters-set
+      doc: Set dpipe counter attributes.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - dpipe-table-name
+            - dpipe-table-counters-enabled
+
+    -
+      name: resource-set
+      doc: Set resource attributes.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - resource-id
+            - resource-size
+
+    -
+      name: resource-dump
+      doc: Get resource attributes.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+        reply:
+          value: 36
+          attributes:
+            - bus-name
+            - dev-name
+            - resource-list
 
     -
-      name: sb-tc-pool-bind-get
-      doc: Get shared buffer port-TC to pool bindings and threshold.
+      name: reload
+      doc: Reload devlink.
       attribute-set: devlink
       dont-validate: [ strict ]
+      flags: [ admin-perm ]
       do:
-        pre: devlink-nl-pre-doit-port
+        pre: devlink-nl-pre-doit
         post: devlink-nl-post-doit
         request:
-          value: 23
-          attributes: &sb-tc-pool-bind-id-attrs
+          attributes:
             - bus-name
             - dev-name
-            - port-index
-            - sb-index
-            - sb-pool-type
-            - sb-tc-index
-        reply: &sb-tc-pool-bind-get-reply
-          value: 25
-          attributes: *sb-tc-pool-bind-id-attrs
-      dump:
-        request:
-          attributes: *dev-id-attrs
-        reply: *sb-tc-pool-bind-get-reply
-
-      # TODO: fill in the operations in between
+            - reload-action
+            - reload-limits
+            - netns-pid
+            - netns-fd
+            - netns-id
+        reply:
+          attributes:
+            - bus-name
+            - dev-name
+            - reload-actions-performed
 
     -
       name: param-get
@@ -401,20 +1501,34 @@ operations:
         pre: devlink-nl-pre-doit
         post: devlink-nl-post-doit
         request:
-          value: 38
           attributes: &param-id-attrs
             - bus-name
             - dev-name
             - param-name
         reply: &param-get-reply
-          value: 38
           attributes: *param-id-attrs
       dump:
         request:
           attributes: *dev-id-attrs
         reply: *param-get-reply
 
-      # TODO: fill in the operations in between
+    -
+      name: param-set
+      doc: Set param instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - param-name
+            - param-type
+            # param-value-data is missing here as the type is variable
+            - param-value-cmode
 
     -
       name: region-get
@@ -439,7 +1553,91 @@ operations:
           attributes: *dev-id-attrs
         reply: *region-get-reply
 
-      # TODO: fill in the operations in between
+    -
+      name: region-new
+      doc: Create region snapshot.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit-port-optional
+        post: devlink-nl-post-doit
+        request:
+          value: 44
+          attributes: &region-snapshot-id-attrs
+            - bus-name
+            - dev-name
+            - port-index
+            - region-name
+            - region-snapshot-id
+        reply:
+          value: 44
+          attributes: *region-snapshot-id-attrs
+
+    -
+      name: region-del
+      doc: Delete region snapshot.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit-port-optional
+        post: devlink-nl-post-doit
+        request:
+          attributes: *region-snapshot-id-attrs
+
+    -
+      name: region-read
+      doc: Read region data.
+      attribute-set: devlink
+      dont-validate: [ dump-strict ]
+      flags: [ admin-perm ]
+      dump:
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - port-index
+            - region-name
+            - region-snapshot-id
+            - region-direct
+            - region-chunk-addr
+            - region-chunk-len
+        reply:
+          value: 46
+          attributes:
+            - bus-name
+            - dev-name
+            - port-index
+            - region-name
+
+    -
+      name: port-param-get
+      doc: Get port param instances.
+      attribute-set: devlink
+      dont-validate: [ strict, dump-strict ]
+      do:
+        pre: devlink-nl-pre-doit-port
+        post: devlink-nl-post-doit
+        request:
+          attributes: *port-id-attrs
+        reply:
+          attributes: *port-id-attrs
+      dump:
+        reply:
+          attributes: *port-id-attrs
+
+    -
+      name: port-param-set
+      doc: Set port param instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit-port
+        post: devlink-nl-post-doit
+        request:
+          attributes: *port-id-attrs
 
     -
       name: info-get
@@ -486,7 +1684,91 @@ operations:
           attributes: *port-id-attrs
         reply: *health-reporter-get-reply
 
-      # TODO: fill in the operations in between
+    -
+      name: health-reporter-set
+      doc: Set health reporter instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit-port-optional
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - port-index
+            - health-reporter-name
+            - health-reporter-graceful-period
+            - health-reporter-auto-recover
+            - health-reporter-auto-dump
+
+    -
+      name: health-reporter-recover
+      doc: Recover health reporter instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit-port-optional
+        post: devlink-nl-post-doit
+        request:
+          attributes: *health-reporter-id-attrs
+
+    -
+      name: health-reporter-diagnose
+      doc: Diagnose health reporter instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit-port-optional
+        post: devlink-nl-post-doit
+        request:
+          attributes: *health-reporter-id-attrs
+
+    -
+      name: health-reporter-dump-get
+      doc: Dump health reporter instances.
+      attribute-set: devlink
+      dont-validate: [ dump-strict ]
+      flags: [ admin-perm ]
+      dump:
+        request:
+          attributes: *health-reporter-id-attrs
+        reply:
+          value: 56
+          attributes:
+            - fmsg
+
+    -
+      name: health-reporter-dump-clear
+      doc: Clear dump of health reporter instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit-port-optional
+        post: devlink-nl-post-doit
+        request:
+          attributes: *health-reporter-id-attrs
+
+    -
+      name: flash-update
+      doc: Flash update devlink instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - flash-update-file-name
+            - flash-update-component
+            - flash-update-overwrite-mask
 
     -
       name: trap-get
@@ -510,7 +1792,21 @@ operations:
           attributes: *dev-id-attrs
         reply: *trap-get-reply
 
-      # TODO: fill in the operations in between
+    -
+      name: trap-set
+      doc: Set trap instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - trap-name
+            - trap-action
 
     -
       name: trap-group-get
@@ -534,7 +1830,22 @@ operations:
           attributes: *dev-id-attrs
         reply: *trap-group-get-reply
 
-      # TODO: fill in the operations in between
+    -
+      name: trap-group-set
+      doc: Set trap group instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - trap-group-name
+            - trap-action
+            - trap-policer-id
 
     -
       name: trap-policer-get
@@ -558,7 +1869,35 @@ operations:
           attributes: *dev-id-attrs
         reply: *trap-policer-get-reply
 
-      # TODO: fill in the operations in between
+    -
+      name: trap-policer-set
+      doc: Get trap policer instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - trap-policer-id
+            - trap-policer-rate
+            - trap-policer-burst
+
+    -
+      name: health-reporter-test
+      doc: Test health reporter instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit-port-optional
+        post: devlink-nl-post-doit
+        request:
+          value: 73
+          attributes: *health-reporter-id-attrs
 
     -
       name: rate-get
@@ -583,7 +1922,60 @@ operations:
           attributes: *dev-id-attrs
         reply: *rate-get-reply
 
-      # TODO: fill in the operations in between
+    -
+      name: rate-set
+      doc: Set rate instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - rate-node-name
+            - rate-tx-share
+            - rate-tx-max
+            - rate-tx-priority
+            - rate-tx-weight
+            - rate-parent-node-name
+
+    -
+      name: rate-new
+      doc: Create rate instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - rate-node-name
+            - rate-tx-share
+            - rate-tx-max
+            - rate-tx-priority
+            - rate-tx-weight
+            - rate-parent-node-name
+
+    -
+      name: rate-del
+      doc: Delete rate instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - rate-node-name
 
     -
       name: linecard-get
@@ -607,7 +1999,21 @@ operations:
           attributes: *dev-id-attrs
         reply: *linecard-get-reply
 
-      # TODO: fill in the operations in between
+    -
+      name: linecard-set
+      doc: Set line card instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - linecard-index
+            - linecard-type
 
     -
       name: selftests-get
@@ -625,3 +2031,18 @@ operations:
           attributes: *dev-id-attrs
       dump:
         reply: *selftests-get-reply
+
+    -
+      name: selftests-run
+      doc: Run device selftest instances.
+      attribute-set: devlink
+      dont-validate: [ strict ]
+      flags: [ admin-perm ]
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          attributes:
+            - bus-name
+            - dev-name
+            - selftests
net/devlink/netlink_gen.c +756 -1

918 lines not on this page · raw message

net/devlink/netlink_gen.h +63 -1

120 lines not on this page · raw message

tools/net/ynl/generated/devlink-user.c +4331 -546

237 lines not on this page · raw message

tools/net/ynl/generated/devlink-user.h +3717 -474

4,191 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.41.0

Part of the diff is not shown here. View the raw message.

author maintainer
#36 lore raw

PATCH 9/10 devlink: remove duplicated netlink callback prototypes

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

The prototypes are now generated, remove the old ones.

---
 net/devlink/devl_internal.h | 62 -------------------------------------
 1 file changed, 62 deletions(-)
net/devlink/devl_internal.h +0 -62
index daf4c696a618..183dbe3807ab 100644
@@ -227,65 +227,3 @@ int devlink_rate_nodes_check(struct devlink *devlink, u16 mode,
 
 /* Linecards */
 unsigned int devlink_linecard_index(struct devlink_linecard *linecard);
-
-/* Devlink nl cmds */
-int devlink_nl_reload_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_flash_update_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_selftests_run_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_port_set_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_port_split_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_port_unsplit_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_port_new_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_port_del_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_sb_pool_set_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_sb_port_pool_set_doit(struct sk_buff *skb,
-				     struct genl_info *info);
-int devlink_nl_sb_tc_pool_bind_set_doit(struct sk_buff *skb,
-					struct genl_info *info);
-int devlink_nl_sb_occ_snapshot_doit(struct sk_buff *skb,
-				    struct genl_info *info);
-int devlink_nl_sb_occ_max_clear_doit(struct sk_buff *skb,
-				     struct genl_info *info);
-int devlink_nl_dpipe_table_get_doit(struct sk_buff *skb,
-				    struct genl_info *info);
-int devlink_nl_dpipe_entries_get_doit(struct sk_buff *skb,
-				      struct genl_info *info);
-int devlink_nl_dpipe_headers_get_doit(struct sk_buff *skb,
-				      struct genl_info *info);
-int devlink_nl_dpipe_table_counters_set_doit(struct sk_buff *skb,
-					     struct genl_info *info);
-int devlink_nl_resource_set_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_resource_dump_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_param_set_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_port_param_get_dumpit(struct sk_buff *msg,
-				     struct netlink_callback *cb);
-int devlink_nl_port_param_get_doit(struct sk_buff *skb,
-				   struct genl_info *info);
-int devlink_nl_port_param_set_doit(struct sk_buff *skb,
-				   struct genl_info *info);
-int devlink_nl_region_new_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_region_del_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_region_read_dumpit(struct sk_buff *skb,
-				  struct netlink_callback *cb);
-int devlink_nl_health_reporter_set_doit(struct sk_buff *skb,
-					struct genl_info *info);
-int devlink_nl_health_reporter_recover_doit(struct sk_buff *skb,
-					    struct genl_info *info);
-int devlink_nl_health_reporter_diagnose_doit(struct sk_buff *skb,
-					     struct genl_info *info);
-int devlink_nl_health_reporter_dump_get_dumpit(struct sk_buff *skb,
-					       struct netlink_callback *cb);
-int devlink_nl_health_reporter_dump_clear_doit(struct sk_buff *skb,
-					       struct genl_info *info);
-int devlink_nl_health_reporter_test_doit(struct sk_buff *skb,
-					 struct genl_info *info);
-int devlink_nl_trap_set_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_trap_group_set_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_trap_policer_set_doit(struct sk_buff *skb,
-				     struct genl_info *info);
-int devlink_nl_rate_set_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_rate_new_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_rate_del_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_linecard_set_doit(struct sk_buff *skb, struct genl_info *info);
Signature · 1 line
2.41.0
author maintainer
#37 lore raw

PATCH 10/10 devlink: remove netlink small_ops

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

All commands are now covered by generated split_ops. Remove the small_ops entirely alongside with unified devlink netlink policy array.

---
 net/devlink/netlink.c | 328 +-----------------------------------------
 1 file changed, 1 insertion(+), 327 deletions(-)
net/devlink/netlink.c +1 -327
index ca63e59a5e92..d0b90ebc8b15 100644
@@ -13,75 +13,6 @@ static const struct genl_multicast_group devlink_nl_mcgrps[] = {
 	[DEVLINK_MCGRP_CONFIG] = { .name = DEVLINK_GENL_MCGRP_CONFIG_NAME },
 };
 
-static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = {
-	[DEVLINK_ATTR_UNSPEC] = { .strict_start_type =
-		DEVLINK_ATTR_TRAP_POLICER_ID },
-	[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING },
-	[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING },
-	[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32 },
-	[DEVLINK_ATTR_PORT_TYPE] = NLA_POLICY_RANGE(NLA_U16, DEVLINK_PORT_TYPE_AUTO,
-						    DEVLINK_PORT_TYPE_IB),
-	[DEVLINK_ATTR_PORT_SPLIT_COUNT] = { .type = NLA_U32 },
-	[DEVLINK_ATTR_SB_INDEX] = { .type = NLA_U32 },
-	[DEVLINK_ATTR_SB_POOL_INDEX] = { .type = NLA_U16 },
-	[DEVLINK_ATTR_SB_POOL_TYPE] = { .type = NLA_U8 },
-	[DEVLINK_ATTR_SB_POOL_SIZE] = { .type = NLA_U32 },
-	[DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE] = { .type = NLA_U8 },
-	[DEVLINK_ATTR_SB_THRESHOLD] = { .type = NLA_U32 },
-	[DEVLINK_ATTR_SB_TC_INDEX] = { .type = NLA_U16 },
-	[DEVLINK_ATTR_ESWITCH_MODE] = NLA_POLICY_RANGE(NLA_U16, DEVLINK_ESWITCH_MODE_LEGACY,
-						       DEVLINK_ESWITCH_MODE_SWITCHDEV),
-	[DEVLINK_ATTR_ESWITCH_INLINE_MODE] = { .type = NLA_U8 },
-	[DEVLINK_ATTR_ESWITCH_ENCAP_MODE] = { .type = NLA_U8 },
-	[DEVLINK_ATTR_DPIPE_TABLE_NAME] = { .type = NLA_NUL_STRING },
-	[DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED] = { .type = NLA_U8 },
-	[DEVLINK_ATTR_RESOURCE_ID] = { .type = NLA_U64},
-	[DEVLINK_ATTR_RESOURCE_SIZE] = { .type = NLA_U64},
-	[DEVLINK_ATTR_PARAM_NAME] = { .type = NLA_NUL_STRING },
-	[DEVLINK_ATTR_PARAM_TYPE] = { .type = NLA_U8 },
-	[DEVLINK_ATTR_PARAM_VALUE_CMODE] = { .type = NLA_U8 },
-	[DEVLINK_ATTR_REGION_NAME] = { .type = NLA_NUL_STRING },
-	[DEVLINK_ATTR_REGION_SNAPSHOT_ID] = { .type = NLA_U32 },
-	[DEVLINK_ATTR_REGION_CHUNK_ADDR] = { .type = NLA_U64 },
-	[DEVLINK_ATTR_REGION_CHUNK_LEN] = { .type = NLA_U64 },
-	[DEVLINK_ATTR_HEALTH_REPORTER_NAME] = { .type = NLA_NUL_STRING },
-	[DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD] = { .type = NLA_U64 },
-	[DEVLINK_ATTR_HEALTH_REPORTER_AUTO_RECOVER] = { .type = NLA_U8 },
-	[DEVLINK_ATTR_FLASH_UPDATE_FILE_NAME] = { .type = NLA_NUL_STRING },
-	[DEVLINK_ATTR_FLASH_UPDATE_COMPONENT] = { .type = NLA_NUL_STRING },
-	[DEVLINK_ATTR_FLASH_UPDATE_OVERWRITE_MASK] =
-		NLA_POLICY_BITFIELD32(DEVLINK_SUPPORTED_FLASH_OVERWRITE_SECTIONS),
-	[DEVLINK_ATTR_TRAP_NAME] = { .type = NLA_NUL_STRING },
-	[DEVLINK_ATTR_TRAP_ACTION] = { .type = NLA_U8 },
-	[DEVLINK_ATTR_TRAP_GROUP_NAME] = { .type = NLA_NUL_STRING },
-	[DEVLINK_ATTR_NETNS_PID] = { .type = NLA_U32 },
-	[DEVLINK_ATTR_NETNS_FD] = { .type = NLA_U32 },
-	[DEVLINK_ATTR_NETNS_ID] = { .type = NLA_U32 },
-	[DEVLINK_ATTR_HEALTH_REPORTER_AUTO_DUMP] = { .type = NLA_U8 },
-	[DEVLINK_ATTR_TRAP_POLICER_ID] = { .type = NLA_U32 },
-	[DEVLINK_ATTR_TRAP_POLICER_RATE] = { .type = NLA_U64 },
-	[DEVLINK_ATTR_TRAP_POLICER_BURST] = { .type = NLA_U64 },
-	[DEVLINK_ATTR_PORT_FUNCTION] = { .type = NLA_NESTED },
-	[DEVLINK_ATTR_RELOAD_ACTION] = NLA_POLICY_RANGE(NLA_U8, DEVLINK_RELOAD_ACTION_DRIVER_REINIT,
-							DEVLINK_RELOAD_ACTION_MAX),
-	[DEVLINK_ATTR_RELOAD_LIMITS] = NLA_POLICY_BITFIELD32(DEVLINK_RELOAD_LIMITS_VALID_MASK),
-	[DEVLINK_ATTR_PORT_FLAVOUR] = { .type = NLA_U16 },
-	[DEVLINK_ATTR_PORT_PCI_PF_NUMBER] = { .type = NLA_U16 },
-	[DEVLINK_ATTR_PORT_PCI_SF_NUMBER] = { .type = NLA_U32 },
-	[DEVLINK_ATTR_PORT_CONTROLLER_NUMBER] = { .type = NLA_U32 },
-	[DEVLINK_ATTR_RATE_TYPE] = { .type = NLA_U16 },
-	[DEVLINK_ATTR_RATE_TX_SHARE] = { .type = NLA_U64 },
-	[DEVLINK_ATTR_RATE_TX_MAX] = { .type = NLA_U64 },
-	[DEVLINK_ATTR_RATE_NODE_NAME] = { .type = NLA_NUL_STRING },
-	[DEVLINK_ATTR_RATE_PARENT_NODE_NAME] = { .type = NLA_NUL_STRING },
-	[DEVLINK_ATTR_LINECARD_INDEX] = { .type = NLA_U32 },
-	[DEVLINK_ATTR_LINECARD_TYPE] = { .type = NLA_NUL_STRING },
-	[DEVLINK_ATTR_SELFTESTS] = { .type = NLA_NESTED },
-	[DEVLINK_ATTR_RATE_TX_PRIORITY] = { .type = NLA_U32 },
-	[DEVLINK_ATTR_RATE_TX_WEIGHT] = { .type = NLA_U32 },
-	[DEVLINK_ATTR_REGION_DIRECT] = { .type = NLA_FLAG },
-};
-
 int devlink_nl_put_nested_handle(struct sk_buff *msg, struct net *net,
 				 struct devlink *devlink, int attrtype)
 {
@@ -191,7 +122,7 @@ static int __devlink_nl_pre_doit(struct sk_buff *skb, struct genl_info *info,
 int devlink_nl_pre_doit(const struct genl_split_ops *ops,
 			struct sk_buff *skb, struct genl_info *info)
 {
-	return __devlink_nl_pre_doit(skb, info, ops->internal_flags);
+	return __devlink_nl_pre_doit(skb, info, 0);
 }
 
 int devlink_nl_pre_doit_port(const struct genl_split_ops *ops,
@@ -287,269 +218,12 @@ int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
 		return devlink_nl_inst_iter_dumpit(msg, cb, flags, dump_one);
 }
 
-static const struct genl_small_ops devlink_nl_small_ops[40] = {
-	{
-		.cmd = DEVLINK_CMD_PORT_SET,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_port_set_doit,
-		.flags = GENL_ADMIN_PERM,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
-	},
-	{
-		.cmd = DEVLINK_CMD_RATE_SET,
-		.doit = devlink_nl_rate_set_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_RATE_NEW,
-		.doit = devlink_nl_rate_new_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_RATE_DEL,
-		.doit = devlink_nl_rate_del_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_PORT_SPLIT,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_port_split_doit,
-		.flags = GENL_ADMIN_PERM,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
-	},
-	{
-		.cmd = DEVLINK_CMD_PORT_UNSPLIT,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_port_unsplit_doit,
-		.flags = GENL_ADMIN_PERM,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
-	},
-	{
-		.cmd = DEVLINK_CMD_PORT_NEW,
-		.doit = devlink_nl_port_new_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_PORT_DEL,
-		.doit = devlink_nl_port_del_doit,
-		.flags = GENL_ADMIN_PERM,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
-	},
-
-	{
-		.cmd = DEVLINK_CMD_LINECARD_SET,
-		.doit = devlink_nl_linecard_set_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_SB_POOL_SET,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_sb_pool_set_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_SB_PORT_POOL_SET,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_sb_port_pool_set_doit,
-		.flags = GENL_ADMIN_PERM,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
-	},
-	{
-		.cmd = DEVLINK_CMD_SB_TC_POOL_BIND_SET,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_sb_tc_pool_bind_set_doit,
-		.flags = GENL_ADMIN_PERM,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
-	},
-	{
-		.cmd = DEVLINK_CMD_SB_OCC_SNAPSHOT,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_sb_occ_snapshot_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_SB_OCC_MAX_CLEAR,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_sb_occ_max_clear_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_ESWITCH_GET,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_eswitch_get_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_ESWITCH_SET,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_eswitch_set_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_DPIPE_TABLE_GET,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_dpipe_table_get_doit,
-		/* can be retrieved by unprivileged users */
-	},
-	{
-		.cmd = DEVLINK_CMD_DPIPE_ENTRIES_GET,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_dpipe_entries_get_doit,
-		/* can be retrieved by unprivileged users */
-	},
-	{
-		.cmd = DEVLINK_CMD_DPIPE_HEADERS_GET,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_dpipe_headers_get_doit,
-		/* can be retrieved by unprivileged users */
-	},
-	{
-		.cmd = DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_dpipe_table_counters_set_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_RESOURCE_SET,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_resource_set_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_RESOURCE_DUMP,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_resource_dump_doit,
-		/* can be retrieved by unprivileged users */
-	},
-	{
-		.cmd = DEVLINK_CMD_RELOAD,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_reload_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_PARAM_SET,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_param_set_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_PORT_PARAM_GET,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_port_param_get_doit,
-		.dumpit = devlink_nl_port_param_get_dumpit,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
-		/* can be retrieved by unprivileged users */
-	},
-	{
-		.cmd = DEVLINK_CMD_PORT_PARAM_SET,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_port_param_set_doit,
-		.flags = GENL_ADMIN_PERM,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
-	},
-	{
-		.cmd = DEVLINK_CMD_REGION_NEW,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_region_new_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_REGION_DEL,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_region_del_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_REGION_READ,
-		.validate = GENL_DONT_VALIDATE_STRICT |
-			    GENL_DONT_VALIDATE_DUMP_STRICT,
-		.dumpit = devlink_nl_region_read_dumpit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_HEALTH_REPORTER_SET,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_health_reporter_set_doit,
-		.flags = GENL_ADMIN_PERM,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
-	},
-	{
-		.cmd = DEVLINK_CMD_HEALTH_REPORTER_RECOVER,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_health_reporter_recover_doit,
-		.flags = GENL_ADMIN_PERM,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
-	},
-	{
-		.cmd = DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_health_reporter_diagnose_doit,
-		.flags = GENL_ADMIN_PERM,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
-	},
-	{
-		.cmd = DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET,
-		.validate = GENL_DONT_VALIDATE_STRICT |
-			    GENL_DONT_VALIDATE_DUMP_STRICT,
-		.dumpit = devlink_nl_health_reporter_dump_get_dumpit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_HEALTH_REPORTER_DUMP_CLEAR,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_health_reporter_dump_clear_doit,
-		.flags = GENL_ADMIN_PERM,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
-	},
-	{
-		.cmd = DEVLINK_CMD_HEALTH_REPORTER_TEST,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_health_reporter_test_doit,
-		.flags = GENL_ADMIN_PERM,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
-	},
-	{
-		.cmd = DEVLINK_CMD_FLASH_UPDATE,
-		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
-		.doit = devlink_nl_flash_update_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_TRAP_SET,
-		.doit = devlink_nl_trap_set_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_TRAP_GROUP_SET,
-		.doit = devlink_nl_trap_group_set_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_TRAP_POLICER_SET,
-		.doit = devlink_nl_trap_policer_set_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	{
-		.cmd = DEVLINK_CMD_SELFTESTS_RUN,
-		.doit = devlink_nl_selftests_run_doit,
-		.flags = GENL_ADMIN_PERM,
-	},
-	/* -- No new ops here! Use split ops going forward! -- */
-};
-
 struct genl_family devlink_nl_family __ro_after_init = {
 	.name		= DEVLINK_GENL_NAME,
 	.version	= DEVLINK_GENL_VERSION,
-	.maxattr	= DEVLINK_ATTR_MAX,
-	.policy		= devlink_nl_policy,
 	.netnsok	= true,
 	.parallel_ops	= true,
-	.pre_doit	= devlink_nl_pre_doit,
-	.post_doit	= devlink_nl_post_doit,
 	.module		= THIS_MODULE,
-	.small_ops	= devlink_nl_small_ops,
-	.n_small_ops	= ARRAY_SIZE(devlink_nl_small_ops),
 	.split_ops	= devlink_nl_ops,
 	.n_split_ops	= ARRAY_SIZE(devlink_nl_ops),
 	.resv_start_op	= DEVLINK_CMD_SELFTESTS_RUN + 1,
Signature · 1 line
2.41.0