Skip to contentSkip to conversation

devlink: introduce selective dumps

PATCH Applied Jiri Pirko 3 participants 16 messages Aug 11, 2023 – Aug 14, 2023

Subsystems (4)
lore
Share & tools
lore

Jiri Pirko

author maintainer
#0 lore raw

v4 cover devlink: introduce selective dumps

From: Jiri Pirko <[email protected]>

Motivation:

For SFs, one devlink instance per SF is created. There might be thousands of these on a single host. When a user needs to know port handle for specific SF, he needs to dump all devlink ports on the host which does not scale good.

Solution:

Allow user to pass devlink handle (and possibly other attributes) alongside the dump command and dump only objects which are matching the selection.

Use split ops to generate policies for dump callbacks acccording to the attributes used for selection.

The userspace can use ctrl genetlink GET_POLICY command to find out if the selective dumps are supported by kernel for particular command.

Example:

$ devlink port show
auxiliary/mlx5_core.eth.0/65535: type eth netdev eth2 flavour physical port 0 splittable false
auxiliary/mlx5_core.eth.1/131071: type eth netdev eth3 flavour physical port 1 splittable false
$ devlink port show auxiliary/mlx5_core.eth.0
auxiliary/mlx5_core.eth.0/65535: type eth netdev eth2 flavour physical port 0 splittable false
$ devlink port show auxiliary/mlx5_core.eth.1
auxiliary/mlx5_core.eth.1/131071: type eth netdev eth3 flavour physical port 1 splittable false

Extension:

patches #12 and #13 extends selection attributes by port index for health reporter dumping.

---
v3->v4:
- fixed NLM_F_DUMP_FILTERED flag handling
v2->v3:
- redid the whole thing using generated split ops and removed nested selector attribute as suggested by Jakub. More in individual patches.
v1->v2:
- the original single patch (patch #10) was extended to a patchset

Jiri Pirko (13):
devlink: parse linecard attr in doit() callbacks
devlink: parse rate attrs in doit() callbacks
devlink: introduce devlink_nl_pre_doit_port*() helper functions
devlink: rename doit callbacks for per-instance dump commands
devlink: introduce dumpit callbacks for split ops
devlink: pass flags as an arg of dump_one() callback
netlink: specs: devlink: add commands that do per-instance dump
devlink: remove duplicate temporary netlink callback prototypes
devlink: remove converted commands from small ops
devlink: allow user to narrow per-instance dumps by passing handle
attrs
netlink: specs: devlink: extend per-instance dump commands to accept
instance attributes
devlink: extend health reporter dump selector by port index
netlink: specs: devlink: extend health reporter dump attributes by
port index

 Documentation/netlink/specs/devlink.yaml |  457 +++-
 net/devlink/dev.c                        |   29 +-
 net/devlink/devl_internal.h              |   44 +-
 net/devlink/health.c                     |   40 +-
 net/devlink/leftover.c                   |  419 ++--
 net/devlink/netlink.c                    |  110 +-
 net/devlink/netlink_gen.c                |  424 +++-
 net/devlink/netlink_gen.h                |   52 +-
 tools/net/ynl/generated/devlink-user.c   | 2434 +++++++++++++++++++++-
 tools/net/ynl/generated/devlink-user.h   | 1824 +++++++++++++++-
 10 files changed, 5327 insertions(+), 506 deletions(-)
Signature · 1 line
2.41.0
author maintainer
#1 lore raw

PATCH v4 1/13 devlink: parse linecard attr in doit() callbacks

From: Jiri Pirko <[email protected]>

No need to give the linecards any special treatment in netlink attribute parsing, as unlike for ports, there is only a couple of commands benefiting from that.

Remove DEVLINK_NL_FLAG_NEED_LINECARD, make pre_doit() callback simpler by moving the linecard attribute parsing to linecard_[gs]et_doit() ops.

---
 net/devlink/devl_internal.h |  7 -------
 net/devlink/leftover.c      | 19 +++++++++++++------
 net/devlink/netlink.c       |  8 --------
 3 files changed, 13 insertions(+), 21 deletions(-)
net/devlink/devl_internal.h +0 -7
index 7fdd956ff992..3bbecebf192d 100644
@@ -94,7 +94,6 @@ static inline bool devl_is_registered(struct devlink *devlink)
 #define DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT	BIT(1)
 #define DEVLINK_NL_FLAG_NEED_RATE		BIT(2)
 #define DEVLINK_NL_FLAG_NEED_RATE_NODE		BIT(3)
-#define DEVLINK_NL_FLAG_NEED_LINECARD		BIT(4)
 
 enum devlink_multicast_groups {
 	DEVLINK_MCGRP_CONFIG,
@@ -203,12 +202,6 @@ int devlink_resources_validate(struct devlink *devlink,
 			       struct devlink_resource *resource,
 			       struct genl_info *info);
 
-/* Line cards */
-struct devlink_linecard;
-
-struct devlink_linecard *
-devlink_linecard_get_from_info(struct devlink *devlink, struct genl_info *info);
-
 /* Rates */
 int devlink_rate_nodes_check(struct devlink *devlink, u16 mode,
 			     struct netlink_ext_ack *extack);
net/devlink/leftover.c +13 -6
index e7900d9fa205..46cdd5d88583 100644
@@ -285,7 +285,7 @@ devlink_linecard_get_from_attrs(struct devlink *devlink, struct nlattr **attrs)
 	return ERR_PTR(-EINVAL);
 }
 
-struct devlink_linecard *
+static struct devlink_linecard *
 devlink_linecard_get_from_info(struct devlink *devlink, struct genl_info *info)
 {
 	return devlink_linecard_get_from_attrs(devlink, info->attrs);
@@ -1814,11 +1814,15 @@ static void devlink_linecard_notify(struct devlink_linecard *linecard,
 static int devlink_nl_cmd_linecard_get_doit(struct sk_buff *skb,
 					    struct genl_info *info)
 {
-	struct devlink_linecard *linecard = info->user_ptr[1];
-	struct devlink *devlink = linecard->devlink;
+	struct devlink *devlink = info->user_ptr[0];
+	struct devlink_linecard *linecard;
 	struct sk_buff *msg;
 	int err;
 
+	linecard = devlink_linecard_get_from_info(devlink, info);
+	if (IS_ERR(linecard))
+		return PTR_ERR(linecard);
+
 	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
 	if (!msg)
 		return -ENOMEM;
@@ -2008,10 +2012,15 @@ static int devlink_linecard_type_unset(struct devlink_linecard *linecard,
 static int devlink_nl_cmd_linecard_set_doit(struct sk_buff *skb,
 					    struct genl_info *info)
 {
-	struct devlink_linecard *linecard = info->user_ptr[1];
 	struct netlink_ext_ack *extack = info->extack;
+	struct devlink *devlink = info->user_ptr[0];
+	struct devlink_linecard *linecard;
 	int err;
 
+	linecard = devlink_linecard_get_from_info(devlink, info);
+	if (IS_ERR(linecard))
+		return PTR_ERR(linecard);
+
 	if (info->attrs[DEVLINK_ATTR_LINECARD_TYPE]) {
 		const char *type;
 
@@ -6347,14 +6356,12 @@ const struct genl_small_ops devlink_nl_small_ops[54] = {
 		.cmd = DEVLINK_CMD_LINECARD_GET,
 		.doit = devlink_nl_cmd_linecard_get_doit,
 		.dumpit = devlink_nl_instance_iter_dumpit,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_LINECARD,
 		/* can be retrieved by unprivileged users */
 	},
 	{
 		.cmd = DEVLINK_CMD_LINECARD_SET,
 		.doit = devlink_nl_cmd_linecard_set_doit,
 		.flags = GENL_ADMIN_PERM,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_LINECARD,
 	},
 	{
 		.cmd = DEVLINK_CMD_SB_GET,
net/devlink/netlink.c +0 -8
index bada2819827b..9fd683f38a53 100644
@@ -112,7 +112,6 @@ devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs)
 int devlink_nl_pre_doit(const struct genl_split_ops *ops,
 			struct sk_buff *skb, struct genl_info *info)
 {
-	struct devlink_linecard *linecard;
 	struct devlink_port *devlink_port;
 	struct devlink *devlink;
 	int err;
@@ -151,13 +150,6 @@ int devlink_nl_pre_doit(const struct genl_split_ops *ops,
 			goto unlock;
 		}
 		info->user_ptr[1] = rate_node;
-	} else if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_LINECARD) {
-		linecard = devlink_linecard_get_from_info(devlink, info);
-		if (IS_ERR(linecard)) {
-			err = PTR_ERR(linecard);
-			goto unlock;
-		}
-		info->user_ptr[1] = linecard;
 	}
 	return 0;
 
Signature · 1 line
2.41.0
author maintainer
#2 lore raw

PATCH v4 2/13 devlink: parse rate attrs in doit() callbacks

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

No need to give the rate any special treatment in netlink attributes parsing, as unlike for ports, there is only a couple of commands benefiting from that.

Remove DEVLINK_NL_FLAG_NEED_RATE*, make pre_doit() callback simpler by moving the rate attributes parsing to rate_*_doit() ops.

---
 net/devlink/devl_internal.h |  8 +-------
 net/devlink/leftover.c      | 37 ++++++++++++++++++++++++-------------
 net/devlink/netlink.c       | 18 ------------------
 3 files changed, 25 insertions(+), 38 deletions(-)
net/devlink/devl_internal.h +1 -7
index 3bbecebf192d..ca04e4ee9427 100644
@@ -92,8 +92,6 @@ static inline bool devl_is_registered(struct devlink *devlink)
 /* Netlink */
 #define DEVLINK_NL_FLAG_NEED_PORT		BIT(0)
 #define DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT	BIT(1)
-#define DEVLINK_NL_FLAG_NEED_RATE		BIT(2)
-#define DEVLINK_NL_FLAG_NEED_RATE_NODE		BIT(3)
 
 enum devlink_multicast_groups {
 	DEVLINK_MCGRP_CONFIG,
@@ -205,11 +203,7 @@ int devlink_resources_validate(struct devlink *devlink,
 /* Rates */
 int devlink_rate_nodes_check(struct devlink *devlink, u16 mode,
 			     struct netlink_ext_ack *extack);
-struct devlink_rate *
-devlink_rate_get_from_info(struct devlink *devlink, struct genl_info *info);
-struct devlink_rate *
-devlink_rate_node_get_from_info(struct devlink *devlink,
-				struct genl_info *info);
+
 /* Devlink nl cmds */
 int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info);
 int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info);
net/devlink/leftover.c +24 -13
index 46cdd5d88583..b7b6850e26d8 100644
@@ -232,13 +232,13 @@ devlink_rate_node_get_from_attrs(struct devlink *devlink, struct nlattr **attrs)
 	return devlink_rate_node_get_by_name(devlink, rate_node_name);
 }
 
-struct devlink_rate *
+static struct devlink_rate *
 devlink_rate_node_get_from_info(struct devlink *devlink, struct genl_info *info)
 {
 	return devlink_rate_node_get_from_attrs(devlink, info->attrs);
 }
 
-struct devlink_rate *
+static struct devlink_rate *
 devlink_rate_get_from_info(struct devlink *devlink, struct genl_info *info)
 {
 	struct nlattr **attrs = info->attrs;
@@ -1041,10 +1041,15 @@ const struct devlink_cmd devl_cmd_rate_get = {
 static int devlink_nl_cmd_rate_get_doit(struct sk_buff *skb,
 					struct genl_info *info)
 {
-	struct devlink_rate *devlink_rate = info->user_ptr[1];
+	struct devlink *devlink = info->user_ptr[0];
+	struct devlink_rate *devlink_rate;
 	struct sk_buff *msg;
 	int err;
 
+	devlink_rate = devlink_rate_get_from_info(devlink, info);
+	if (IS_ERR(devlink_rate))
+		return PTR_ERR(devlink_rate);
+
 	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
 	if (!msg)
 		return -ENOMEM;
@@ -1629,11 +1634,16 @@ static bool devlink_rate_set_ops_supported(const struct devlink_ops *ops,
 static int devlink_nl_cmd_rate_set_doit(struct sk_buff *skb,
 					struct genl_info *info)
 {
-	struct devlink_rate *devlink_rate = info->user_ptr[1];
-	struct devlink *devlink = devlink_rate->devlink;
-	const struct devlink_ops *ops = devlink->ops;
+	struct devlink *devlink = info->user_ptr[0];
+	struct devlink_rate *devlink_rate;
+	const struct devlink_ops *ops;
 	int err;
 
+	devlink_rate = devlink_rate_get_from_info(devlink, info);
+	if (IS_ERR(devlink_rate))
+		return PTR_ERR(devlink_rate);
+
+	ops = devlink->ops;
 	if (!ops || !devlink_rate_set_ops_supported(ops, info, devlink_rate->type))
 		return -EOPNOTSUPP;
 
@@ -1704,18 +1714,22 @@ static int devlink_nl_cmd_rate_new_doit(struct sk_buff *skb,
 static int devlink_nl_cmd_rate_del_doit(struct sk_buff *skb,
 					struct genl_info *info)
 {
-	struct devlink_rate *rate_node = info->user_ptr[1];
-	struct devlink *devlink = rate_node->devlink;
-	const struct devlink_ops *ops = devlink->ops;
+	struct devlink *devlink = info->user_ptr[0];
+	struct devlink_rate *rate_node;
 	int err;
 
+	rate_node = devlink_rate_node_get_from_info(devlink, info);
+	if (IS_ERR(rate_node))
+		return PTR_ERR(rate_node);
+
 	if (refcount_read(&rate_node->refcnt) > 1) {
 		NL_SET_ERR_MSG(info->extack, "Node has children. Cannot delete node.");
 		return -EBUSY;
 	}
 
 	devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_DEL);
-	err = ops->rate_node_del(rate_node, rate_node->priv, info->extack);
+	err = devlink->ops->rate_node_del(rate_node, rate_node->priv,
+					  info->extack);
 	if (rate_node->parent)
 		refcount_dec(&rate_node->parent->refcnt);
 	list_del(&rate_node->list);
@@ -6307,14 +6321,12 @@ const struct genl_small_ops devlink_nl_small_ops[54] = {
 		.cmd = DEVLINK_CMD_RATE_GET,
 		.doit = devlink_nl_cmd_rate_get_doit,
 		.dumpit = devlink_nl_instance_iter_dumpit,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_RATE,
 		/* can be retrieved by unprivileged users */
 	},
 	{
 		.cmd = DEVLINK_CMD_RATE_SET,
 		.doit = devlink_nl_cmd_rate_set_doit,
 		.flags = GENL_ADMIN_PERM,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_RATE,
 	},
 	{
 		.cmd = DEVLINK_CMD_RATE_NEW,
@@ -6325,7 +6337,6 @@ const struct genl_small_ops devlink_nl_small_ops[54] = {
 		.cmd = DEVLINK_CMD_RATE_DEL,
 		.doit = devlink_nl_cmd_rate_del_doit,
 		.flags = GENL_ADMIN_PERM,
-		.internal_flags = DEVLINK_NL_FLAG_NEED_RATE_NODE,
 	},
 	{
 		.cmd = DEVLINK_CMD_PORT_SPLIT,
net/devlink/netlink.c +0 -18
index 9fd683f38a53..96cf8a1b8bce 100644
@@ -132,24 +132,6 @@ int devlink_nl_pre_doit(const struct genl_split_ops *ops,
 		devlink_port = devlink_port_get_from_info(devlink, info);
 		if (!IS_ERR(devlink_port))
 			info->user_ptr[1] = devlink_port;
-	} else if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_RATE) {
-		struct devlink_rate *devlink_rate;
-
-		devlink_rate = devlink_rate_get_from_info(devlink, info);
-		if (IS_ERR(devlink_rate)) {
-			err = PTR_ERR(devlink_rate);
-			goto unlock;
-		}
-		info->user_ptr[1] = devlink_rate;
-	} else if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_RATE_NODE) {
-		struct devlink_rate *rate_node;
-
-		rate_node = devlink_rate_node_get_from_info(devlink, info);
-		if (IS_ERR(rate_node)) {
-			err = PTR_ERR(rate_node);
-			goto unlock;
-		}
-		info->user_ptr[1] = rate_node;
 	}
 	return 0;
 
Signature · 1 line
2.41.0
author maintainer
#3 lore raw

PATCH v4 3/13 devlink: introduce devlink_nl_pre_doit_port*() helper functions

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

Define port handling helpers what don't rely on internal_flags. Have __devlink_nl_pre_doit() to accept the flags as a function arg and make devlink_nl_pre_doit() a wrapper helper function calling it. Introduce new helpers devlink_nl_pre_doit_port() and devlink_nl_pre_doit_port_optional() to be used by split ops in follow-up patch.

Note that the function prototypes are temporary until the generated ones will replace them in a follow-up patch.

---
v1->v2:
- added devlink_nl_pre_doit_port_*() functions definition
- adjusted patch name and description

---
 net/devlink/devl_internal.h |  5 +++++
 net/devlink/netlink.c       | 27 +++++++++++++++++++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)
net/devlink/devl_internal.h +5 -0
index ca04e4ee9427..9851fd48ab59 100644
@@ -205,6 +205,11 @@ int devlink_rate_nodes_check(struct devlink *devlink, u16 mode,
 			     struct netlink_ext_ack *extack);
 
 /* Devlink nl cmds */
+int devlink_nl_pre_doit_port(const struct genl_split_ops *ops,
+			     struct sk_buff *skb, struct genl_info *info);
+int devlink_nl_pre_doit_port_optional(const struct genl_split_ops *ops,
+				      struct sk_buff *skb,
+				      struct genl_info *info);
 int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info);
 int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info);
 int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info);
net/devlink/netlink.c +23 -4
index 96cf8a1b8bce..3c59b9c49150 100644
@@ -109,8 +109,8 @@ devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs)
 	return ERR_PTR(-ENODEV);
 }
 
-int devlink_nl_pre_doit(const struct genl_split_ops *ops,
-			struct sk_buff *skb, struct genl_info *info)
+static int __devlink_nl_pre_doit(struct sk_buff *skb, struct genl_info *info,
+				 u8 flags)
 {
 	struct devlink_port *devlink_port;
 	struct devlink *devlink;
@@ -121,14 +121,14 @@ int devlink_nl_pre_doit(const struct genl_split_ops *ops,
 		return PTR_ERR(devlink);
 
 	info->user_ptr[0] = devlink;
-	if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_PORT) {
+	if (flags & DEVLINK_NL_FLAG_NEED_PORT) {
 		devlink_port = devlink_port_get_from_info(devlink, info);
 		if (IS_ERR(devlink_port)) {
 			err = PTR_ERR(devlink_port);
 			goto unlock;
 		}
 		info->user_ptr[1] = devlink_port;
-	} else if (ops->internal_flags & DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT) {
+	} else if (flags & DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT) {
 		devlink_port = devlink_port_get_from_info(devlink, info);
 		if (!IS_ERR(devlink_port))
 			info->user_ptr[1] = devlink_port;
@@ -141,6 +141,25 @@ int devlink_nl_pre_doit(const struct genl_split_ops *ops,
 	return err;
 }
 
+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);
+}
+
+int devlink_nl_pre_doit_port(const struct genl_split_ops *ops,
+			     struct sk_buff *skb, struct genl_info *info)
+{
+	return __devlink_nl_pre_doit(skb, info, DEVLINK_NL_FLAG_NEED_PORT);
+}
+
+int devlink_nl_pre_doit_port_optional(const struct genl_split_ops *ops,
+				      struct sk_buff *skb,
+				      struct genl_info *info)
+{
+	return __devlink_nl_pre_doit(skb, info, DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT);
+}
+
 void devlink_nl_post_doit(const struct genl_split_ops *ops,
 			  struct sk_buff *skb, struct genl_info *info)
 {
Signature · 1 line
2.41.0
author maintainer
#4 lore raw

PATCH v4 4/13 devlink: rename doit callbacks for per-instance dump commands

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

Rename netlink doit callback functions for the commands that do implement per-instance dump to match the generated names that are going to be introduce in the follow-up patch.

Note that the function prototypes are temporary until the generated ones will replace them in a follow-up patch.

---
v2->v3:
- new patch

---
 net/devlink/dev.c           |  3 +-
 net/devlink/devl_internal.h | 22 ++++++++++--
 net/devlink/health.c        |  4 +--
 net/devlink/leftover.c      | 68 ++++++++++++++++---------------------
 4 files changed, 52 insertions(+), 45 deletions(-)
net/devlink/dev.c +1 -2
index 5dfba2248b90..167fe6188d21 100644
@@ -1206,8 +1206,7 @@ devlink_nl_selftests_fill(struct sk_buff *msg, struct devlink *devlink,
 	return err;
 }
 
-int devlink_nl_cmd_selftests_get_doit(struct sk_buff *skb,
-				      struct genl_info *info)
+int devlink_nl_selftests_get_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	struct sk_buff *msg;
net/devlink/devl_internal.h +19 -3
index 9851fd48ab59..f29ec0bfc559 100644
@@ -214,10 +214,22 @@ int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info);
 int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info);
 int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info);
 int devlink_nl_cmd_flash_update(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_cmd_selftests_get_doit(struct sk_buff *skb, struct genl_info *info);
+int devlink_nl_selftests_get_doit(struct sk_buff *skb, struct genl_info *info);
 int devlink_nl_cmd_selftests_run(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_cmd_health_reporter_get_doit(struct sk_buff *skb,
-					    struct genl_info *info);
+int devlink_nl_port_get_doit(struct sk_buff *skb, struct genl_info *info);
+int devlink_nl_rate_get_doit(struct sk_buff *skb, struct genl_info *info);
+int devlink_nl_linecard_get_doit(struct sk_buff *skb, struct genl_info *info);
+int devlink_nl_sb_get_doit(struct sk_buff *skb, struct genl_info *info);
+int devlink_nl_sb_pool_get_doit(struct sk_buff *skb, struct genl_info *info);
+int devlink_nl_sb_port_pool_get_doit(struct sk_buff *skb,
+				     struct genl_info *info);
+int devlink_nl_sb_tc_pool_bind_get_doit(struct sk_buff *skb,
+					struct genl_info *info);
+int devlink_nl_param_get_doit(struct sk_buff *skb,
+			      struct genl_info *info);
+int devlink_nl_region_get_doit(struct sk_buff *skb, struct genl_info *info);
+int devlink_nl_health_reporter_get_doit(struct sk_buff *skb,
+					struct genl_info *info);
 int devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb,
 					    struct genl_info *info);
 int devlink_nl_cmd_health_reporter_recover_doit(struct sk_buff *skb,
@@ -230,3 +242,7 @@ int devlink_nl_cmd_health_reporter_dump_clear_doit(struct sk_buff *skb,
 						   struct genl_info *info);
 int devlink_nl_cmd_health_reporter_test_doit(struct sk_buff *skb,
 					     struct genl_info *info);
+int devlink_nl_trap_get_doit(struct sk_buff *skb, struct genl_info *info);
+int devlink_nl_trap_group_get_doit(struct sk_buff *skb, struct genl_info *info);
+int devlink_nl_trap_policer_get_doit(struct sk_buff *skb,
+				     struct genl_info *info);
net/devlink/health.c +2 -2
index 194340a8bb86..6df4e343d8c2 100644
@@ -356,8 +356,8 @@ devlink_health_reporter_get_from_info(struct devlink *devlink,
 	return devlink_health_reporter_get_from_attrs(devlink, info->attrs);
 }
 
-int devlink_nl_cmd_health_reporter_get_doit(struct sk_buff *skb,
-					    struct genl_info *info)
+int devlink_nl_health_reporter_get_doit(struct sk_buff *skb,
+					struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
 	struct devlink_health_reporter *reporter;
net/devlink/leftover.c +30 -38

224 lines not on this page · raw message

Signature · 1 line
2.41.0
author maintainer
#5 lore raw

PATCH v4 5/13 devlink: introduce dumpit callbacks for split ops

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

Introduce dumpit callbacks for generated split ops. Have them as a thin wrapper around iteration function and allow to pass dump_one() function pointer directly without need to store in devlink_cmd structs.

Note that the function prototypes are temporary until the generated ones will replace them in a follow-up patch.

---
v2->v3:
- new patch

---
 net/devlink/dev.c           |  15 +--
 net/devlink/devl_internal.h |  45 +++++----
 net/devlink/health.c        |  16 +--
 net/devlink/leftover.c      | 189 ++++++++++++++++++++----------------
 net/devlink/netlink.c       |  26 -----
 5 files changed, 144 insertions(+), 147 deletions(-)
net/devlink/dev.c +8 -7
index 167fe6188d21..22e8ab3eaaa2 100644
@@ -1229,10 +1229,9 @@ int devlink_nl_selftests_get_doit(struct sk_buff *skb, struct genl_info *info)
 	return genlmsg_reply(msg, info);
 }
 
-static int
-devlink_nl_cmd_selftests_get_dump_one(struct sk_buff *msg,
-				      struct devlink *devlink,
-				      struct netlink_callback *cb)
+static int devlink_nl_selftests_get_dump_one(struct sk_buff *msg,
+					     struct devlink *devlink,
+					     struct netlink_callback *cb)
 {
 	if (!devlink->ops->selftest_check)
 		return 0;
@@ -1243,9 +1242,11 @@ devlink_nl_cmd_selftests_get_dump_one(struct sk_buff *msg,
 					 cb->extack);
 }
 
-const struct devlink_cmd devl_cmd_selftests_get = {
-	.dump_one		= devlink_nl_cmd_selftests_get_dump_one,
-};
+int devlink_nl_selftests_get_dumpit(struct sk_buff *skb,
+				    struct netlink_callback *cb)
+{
+	return devlink_nl_dumpit(skb, cb, devlink_nl_selftests_get_dump_one);
+}
 
 static int devlink_selftest_result_put(struct sk_buff *skb, unsigned int id,
 				       enum devlink_selftest_status test_status)
net/devlink/devl_internal.h +24 -21

90 lines not on this page · raw message

net/devlink/health.c +9 -7
index 6df4e343d8c2..dbe2d6a1df3b 100644
@@ -384,10 +384,9 @@ int devlink_nl_health_reporter_get_doit(struct sk_buff *skb,
 	return genlmsg_reply(msg, info);
 }
 
-static int
-devlink_nl_cmd_health_reporter_get_dump_one(struct sk_buff *msg,
-					    struct devlink *devlink,
-					    struct netlink_callback *cb)
+static int devlink_nl_health_reporter_get_dump_one(struct sk_buff *msg,
+						   struct devlink *devlink,
+						   struct netlink_callback *cb)
 {
 	struct devlink_nl_dump_state *state = devlink_dump_state(cb);
 	struct devlink_health_reporter *reporter;
@@ -434,9 +433,12 @@ devlink_nl_cmd_health_reporter_get_dump_one(struct sk_buff *msg,
 	return 0;
 }
 
-const struct devlink_cmd devl_cmd_health_reporter_get = {
-	.dump_one		= devlink_nl_cmd_health_reporter_get_dump_one,
-};
+int devlink_nl_health_reporter_get_dumpit(struct sk_buff *skb,
+					  struct netlink_callback *cb)
+{
+	return devlink_nl_dumpit(skb, cb,
+				 devlink_nl_health_reporter_get_dump_one);
+}
 
 int devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb,
 					    struct genl_info *info)
net/devlink/leftover.c +103 -86

417 lines not on this page · raw message

net/devlink/netlink.c +0 -26
index 3c59b9c49150..13388665f319 100644
@@ -170,23 +170,6 @@ void devlink_nl_post_doit(const struct genl_split_ops *ops,
 	devlink_put(devlink);
 }
 
-static const struct devlink_cmd *devl_cmds[] = {
-	[DEVLINK_CMD_PORT_GET]		= &devl_cmd_port_get,
-	[DEVLINK_CMD_SB_GET]		= &devl_cmd_sb_get,
-	[DEVLINK_CMD_SB_POOL_GET]	= &devl_cmd_sb_pool_get,
-	[DEVLINK_CMD_SB_PORT_POOL_GET]	= &devl_cmd_sb_port_pool_get,
-	[DEVLINK_CMD_SB_TC_POOL_BIND_GET] = &devl_cmd_sb_tc_pool_bind_get,
-	[DEVLINK_CMD_PARAM_GET]		= &devl_cmd_param_get,
-	[DEVLINK_CMD_REGION_GET]	= &devl_cmd_region_get,
-	[DEVLINK_CMD_HEALTH_REPORTER_GET] = &devl_cmd_health_reporter_get,
-	[DEVLINK_CMD_TRAP_GET]		= &devl_cmd_trap_get,
-	[DEVLINK_CMD_TRAP_GROUP_GET]	= &devl_cmd_trap_group_get,
-	[DEVLINK_CMD_TRAP_POLICER_GET]	= &devl_cmd_trap_policer_get,
-	[DEVLINK_CMD_RATE_GET]		= &devl_cmd_rate_get,
-	[DEVLINK_CMD_LINECARD_GET]	= &devl_cmd_linecard_get,
-	[DEVLINK_CMD_SELFTESTS_GET]	= &devl_cmd_selftests_get,
-};
-
 int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
 		      devlink_nl_dump_one_func_t *dump_one)
 {
@@ -220,15 +203,6 @@ int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
 	return msg->len;
 }
 
-int devlink_nl_instance_iter_dumpit(struct sk_buff *msg,
-				    struct netlink_callback *cb)
-{
-	const struct genl_dumpit_info *info = genl_dumpit_info(cb);
-	const struct devlink_cmd *cmd = devl_cmds[info->op.cmd];
-
-	return devlink_nl_dumpit(msg, cb, cmd->dump_one);
-}
-
 struct genl_family devlink_nl_family __ro_after_init = {
 	.name		= DEVLINK_GENL_NAME,
 	.version	= DEVLINK_GENL_VERSION,
Signature · 1 line
2.41.0
author maintainer
#6 lore raw

PATCH v4 6/13 devlink: pass flags as an arg of dump_one() callback

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

In order to easily set NLM_F_DUMP_FILTERED for partial dumps, pass the flags as an arg of dump_one() callback. Currently, it is always NLM_F_MULTI.

---
v2->v3:
- new patch

---
 net/devlink/dev.c           | 13 +++---
 net/devlink/devl_internal.h |  3 +-
 net/devlink/health.c        |  7 +--
 net/devlink/leftover.c      | 87 ++++++++++++++++++-------------------
 net/devlink/netlink.c       |  2 +-
 5 files changed, 56 insertions(+), 56 deletions(-)
net/devlink/dev.c +7 -6
index 22e8ab3eaaa2..abf3393a7a17 100644
@@ -218,11 +218,11 @@ int devlink_nl_get_doit(struct sk_buff *skb, struct genl_info *info)
 
 static int
 devlink_nl_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
-			struct netlink_callback *cb)
+			struct netlink_callback *cb, int flags)
 {
 	return devlink_nl_fill(msg, devlink, DEVLINK_CMD_NEW,
 			       NETLINK_CB(cb->skb).portid,
-			       cb->nlh->nlmsg_seq, NLM_F_MULTI);
+			       cb->nlh->nlmsg_seq, flags);
 }
 
 int devlink_nl_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
@@ -828,13 +828,13 @@ int devlink_nl_info_get_doit(struct sk_buff *skb, struct genl_info *info)
 
 static int
 devlink_nl_info_get_dump_one(struct sk_buff *msg, struct devlink *devlink,
-			     struct netlink_callback *cb)
+			     struct netlink_callback *cb, int flags)
 {
 	int err;
 
 	err = devlink_nl_info_fill(msg, devlink, DEVLINK_CMD_INFO_GET,
 				   NETLINK_CB(cb->skb).portid,
-				   cb->nlh->nlmsg_seq, NLM_F_MULTI,
+				   cb->nlh->nlmsg_seq, flags,
 				   cb->extack);
 	if (err == -EOPNOTSUPP)
 		err = 0;
@@ -1231,14 +1231,15 @@ int devlink_nl_selftests_get_doit(struct sk_buff *skb, struct genl_info *info)
 
 static int devlink_nl_selftests_get_dump_one(struct sk_buff *msg,
 					     struct devlink *devlink,
-					     struct netlink_callback *cb)
+					     struct netlink_callback *cb,
+					     int flags)
 {
 	if (!devlink->ops->selftest_check)
 		return 0;
 
 	return devlink_nl_selftests_fill(msg, devlink,
 					 NETLINK_CB(cb->skb).portid,
-					 cb->nlh->nlmsg_seq, NLM_F_MULTI,
+					 cb->nlh->nlmsg_seq, flags,
 					 cb->extack);
 }
 
net/devlink/devl_internal.h +2 -1
index 500c91c61b2d..f8af6ffdbb3a 100644
@@ -115,7 +115,8 @@ struct devlink_nl_dump_state {
 
 typedef int devlink_nl_dump_one_func_t(struct sk_buff *msg,
 				       struct devlink *devlink,
-				       struct netlink_callback *cb);
+				       struct netlink_callback *cb,
+				       int flags);
 
 extern const struct genl_small_ops devlink_nl_small_ops[54];
 
net/devlink/health.c +4 -3
index dbe2d6a1df3b..b9b3e68d9043 100644
@@ -386,7 +386,8 @@ int devlink_nl_health_reporter_get_doit(struct sk_buff *skb,
 
 static int devlink_nl_health_reporter_get_dump_one(struct sk_buff *msg,
 						   struct devlink *devlink,
-						   struct netlink_callback *cb)
+						   struct netlink_callback *cb,
+						   int flags)
 {
 	struct devlink_nl_dump_state *state = devlink_dump_state(cb);
 	struct devlink_health_reporter *reporter;
@@ -404,7 +405,7 @@ static int devlink_nl_health_reporter_get_dump_one(struct sk_buff *msg,
 						      DEVLINK_CMD_HEALTH_REPORTER_GET,
 						      NETLINK_CB(cb->skb).portid,
 						      cb->nlh->nlmsg_seq,
-						      NLM_F_MULTI);
+						      flags);
 		if (err) {
 			state->idx = idx;
 			return err;
@@ -421,7 +422,7 @@ static int devlink_nl_health_reporter_get_dump_one(struct sk_buff *msg,
 							      DEVLINK_CMD_HEALTH_REPORTER_GET,
 							      NETLINK_CB(cb->skb).portid,
 							      cb->nlh->nlmsg_seq,
-							      NLM_F_MULTI);
+							      flags);
 			if (err) {
 				state->idx = idx;
 				return err;
net/devlink/leftover.c +42 -45

291 lines not on this page · raw message

net/devlink/netlink.c +1 -1
index 13388665f319..47e44fb45815 100644
@@ -182,7 +182,7 @@ int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
 		devl_lock(devlink);
 
 		if (devl_is_registered(devlink))
-			err = dump_one(msg, devlink, cb);
+			err = dump_one(msg, devlink, cb, NLM_F_MULTI);
 		else
 			err = 0;
 
Signature · 1 line
2.41.0
author maintainer
#7 lore raw

PATCH v4 7/13 netlink: specs: devlink: add commands that do per-instance dump

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

Add the definitions for the commands that do per-instance dump and re-generate the related code.

---
v2->v3:
- new patch

---
 Documentation/netlink/specs/devlink.yaml |  444 +++-
 net/devlink/netlink_gen.c                |  332 ++-
 net/devlink/netlink_gen.h                |   52 +-
 tools/net/ynl/generated/devlink-user.c   | 2341 ++++++++++++++++++++--
 tools/net/ynl/generated/devlink-user.h   | 1295 +++++++++++-
 5 files changed, 4319 insertions(+), 145 deletions(-)
Documentation/netlink/specs/devlink.yaml +443 -1
index f6df0b3fd502..4f2aa48017a7 100644
@@ -6,6 +6,16 @@ protocol: genetlink-legacy
 
 doc: Partial family for Devlink.
 
+definitions:
+  -
+    type: enum
+    name: sb-pool-type
+    entries:
+      -
+        name: ingress
+      -
+        name: egress
+
 attribute-sets:
   -
     name: devlink
@@ -24,6 +34,46 @@ attribute-sets:
 
       # TODO: fill in the attributes in between
 
+      -
+        name: sb-index
+        type: u32
+        value: 11
+
+      # TODO: fill in the attributes in between
+
+      -
+        name: sb-pool-index
+        type: u16
+        value: 17
+
+      -
+        name: sb-pool-type
+        type: u8
+        enum: sb-pool-type
+
+      # TODO: fill in the attributes in between
+
+      -
+        name: sb-tc-index
+        type: u16
+        value: 22
+
+      # TODO: fill in the attributes in between
+
+      -
+        name: param-name
+        type: string
+        value: 81
+
+      # TODO: fill in the attributes in between
+
+      -
+        name: region-name
+        type: string
+        value: 88
+
+      # TODO: fill in the attributes in between
+
       -
         name: info-driver-name
         type: string
@@ -55,10 +105,35 @@ attribute-sets:
 
       # TODO: fill in the attributes in between
 
+      -
+        name: health-reporter-name
+        type: string
+        value: 115
+
+      # TODO: fill in the attributes in between
+
+      -
+        name: trap-name
+        type: string
+        value: 130
+
+      # TODO: fill in the attributes in between
+
+      -
+        name: trap-group-name
+        type: string
+        value: 135
+
       -
         name: reload-failed
         type: u8
-        value: 136
+
+      # TODO: fill in the attributes in between
+
+      -
+        name: trap-policer-id
+        type: u32
+        value: 142
 
       # TODO: fill in the attributes in between
 
@@ -103,6 +178,21 @@ attribute-sets:
         type: nest
         multi-attr: true
         nested-attributes: dl-reload-act-stats
+
+      # TODO: fill in the attributes in between
+
+      -
+        name: rate-node-name
+        type: string
+        value: 168
+
+      # TODO: fill in the attributes in between
+
+      -
+        name: linecard-index
+        type: u32
+        value: 171
+
   -
     name: dl-dev-stats
     subset-of: devlink
@@ -188,6 +278,188 @@ operations:
       dump:
         reply: *get-reply
 
+    -
+      name: port-get
+      doc: Get devlink port instances.
+      attribute-set: devlink
+      dont-validate:
+        - strict
+        - dump
+
+      do:
+        pre: devlink-nl-pre-doit-port
+        post: devlink-nl-post-doit
+        request:
+          value: 5
+          attributes: &port-id-attrs
+            - bus-name
+            - dev-name
+            - port-index
+        reply:
+          value: 7
+          attributes: *port-id-attrs
+      dump:
+        reply:
+          value: 3  # due to a bug, port dump returns DEVLINK_CMD_NEW
+          attributes: *port-id-attrs
+
+      # TODO: fill in the operations in between
+
+    -
+      name: sb-get
+      doc: Get shared buffer instances.
+      attribute-set: devlink
+      dont-validate:
+        - strict
+        - dump
+
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          value: 11
+          attributes: &sb-id-attrs
+            - bus-name
+            - dev-name
+            - sb-index
+        reply: &sb-get-reply
+          value: 11
+          attributes: *sb-id-attrs
+      dump:
+        reply: *sb-get-reply
+
+      # TODO: fill in the operations in between
+
+    -
+      name: sb-pool-get
+      doc: Get shared buffer pool instances.
+      attribute-set: devlink
+      dont-validate:
+        - strict
+        - dump
+
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          value: 15
+          attributes: &sb-pool-id-attrs
+            - bus-name
+            - dev-name
+            - sb-index
+            - sb-pool-index
+        reply: &sb-pool-get-reply
+          value: 15
+          attributes: *sb-pool-id-attrs
+      dump:
+        reply: *sb-pool-get-reply
+
+      # TODO: fill in the operations in between
+
+    -
+      name: sb-port-pool-get
+      doc: Get shared buffer port-pool combinations and threshold.
+      attribute-set: devlink
+      dont-validate:
+        - strict
+        - dump
+
+      do:
+        pre: devlink-nl-pre-doit-port
+        post: devlink-nl-post-doit
+        request:
+          value: 19
+          attributes: &sb-port-pool-id-attrs
+            - bus-name
+            - dev-name
+            - port-index
+            - sb-index
+            - sb-pool-index
+        reply: &sb-port-pool-get-reply
+          value: 19
+          attributes: *sb-port-pool-id-attrs
+      dump:
+        reply: *sb-port-pool-get-reply
+
+      # TODO: fill in the operations in between
+
+    -
+      name: sb-tc-pool-bind-get
+      doc: Get shared buffer port-TC to pool bindings and threshold.
+      attribute-set: devlink
+      dont-validate:
+        - strict
+        - dump
+
+      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: 23
+          attributes: *sb-tc-pool-bind-id-attrs
+      dump:
+        reply: *sb-tc-pool-bind-get-reply
+
+      # TODO: fill in the operations in between
+
+    -
+      name: param-get
+      doc: Get param instances.
+      attribute-set: devlink
+      dont-validate:
+        - strict
+        - dump
+
+      do:
+        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:
+        reply: *param-get-reply
+
+      # TODO: fill in the operations in between
+
+    -
+      name: region-get
+      doc: Get region instances.
+      attribute-set: devlink
+      dont-validate:
+        - strict
+        - dump
+
+      do:
+        pre: devlink-nl-pre-doit-port-optional
+        post: devlink-nl-post-doit
+        request:
+          value: 42
+          attributes: &region-id-attrs
+            - bus-name
+            - dev-name
+            - port-index
+            - region-name
+        reply: &region-get-reply
+          value: 42
+          attributes: *region-id-attrs
+      dump:
+        reply: *region-get-reply
+
       # TODO: fill in the operations in between
 
     -
@@ -216,3 +488,173 @@ operations:
             - info-version-stored
       dump:
         reply: *info-get-reply
+
+    -
+      name: health-reporter-get
+      doc: Get health reporter instances.
+      attribute-set: devlink
+      dont-validate:
+        - strict
+        - dump
+
+      do:
+        pre: devlink-nl-pre-doit-port-optional
+        post: devlink-nl-post-doit
+        request:
+          attributes: &health-reporter-id-attrs
+            - bus-name
+            - dev-name
+            - port-index
+            - health-reporter-name
+        reply: &health-reporter-get-reply
+          attributes: *health-reporter-id-attrs
+      dump:
+        reply: *health-reporter-get-reply
+
+      # TODO: fill in the operations in between
+
+    -
+      name: trap-get
+      doc: Get trap instances.
+      attribute-set: devlink
+      dont-validate:
+        - strict
+        - dump
+
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          value: 61
+          attributes: &trap-id-attrs
+            - bus-name
+            - dev-name
+            - trap-name
+        reply: &trap-get-reply
+          value: 61
+          attributes: *trap-id-attrs
+      dump:
+        reply: *trap-get-reply
+
+      # TODO: fill in the operations in between
+
+    -
+      name: trap-group-get
+      doc: Get trap group instances.
+      attribute-set: devlink
+      dont-validate:
+        - strict
+        - dump
+
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          value: 65
+          attributes: &trap-group-id-attrs
+            - bus-name
+            - dev-name
+            - trap-group-name
+        reply: &trap-group-get-reply
+          value: 65
+          attributes: *trap-group-id-attrs
+      dump:
+        reply: *trap-group-get-reply
+
+      # TODO: fill in the operations in between
+
+    -
+      name: trap-policer-get
+      doc: Get trap policer instances.
+      attribute-set: devlink
+      dont-validate:
+        - strict
+        - dump
+
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          value: 69
+          attributes: &trap-policer-id-attrs
+            - bus-name
+            - dev-name
+            - trap-policer-id
+        reply: &trap-policer-get-reply
+          value: 69
+          attributes: *trap-policer-id-attrs
+      dump:
+        reply: *trap-policer-get-reply
+
+      # TODO: fill in the operations in between
+
+    -
+      name: rate-get
+      doc: Get rate instances.
+      attribute-set: devlink
+      dont-validate:
+        - strict
+        - dump
+
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          value: 74
+          attributes: &rate-id-attrs
+            - bus-name
+            - dev-name
+            - port-index
+            - rate-node-name
+        reply: &rate-get-reply
+          value: 74
+          attributes: *rate-id-attrs
+      dump:
+        reply: *rate-get-reply
+
+      # TODO: fill in the operations in between
+
+    -
+      name: linecard-get
+      doc: Get line card instances.
+      attribute-set: devlink
+      dont-validate:
+        - strict
+        - dump
+
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          value: 78
+          attributes: &linecard-id-attrs
+            - bus-name
+            - dev-name
+            - linecard-index
+        reply: &linecard-get-reply
+          value: 78
+          attributes: *linecard-id-attrs
+      dump:
+        reply: *linecard-get-reply
+
+      # TODO: fill in the operations in between
+
+    -
+      name: selftests-get
+      doc: Get device selftest instances.
+      attribute-set: devlink
+      dont-validate:
+        - strict
+        - dump
+
+      do:
+        pre: devlink-nl-pre-doit
+        post: devlink-nl-post-doit
+        request:
+          value: 82
+          attributes: *dev-id-attrs
+        reply: &selftests-get-reply
+          value: 82
+          attributes: *dev-id-attrs
+      dump:
+        reply: *selftests-get-reply
net/devlink/netlink_gen.c +331 -1

355 lines not on this page · raw message

net/devlink/netlink_gen.h +51 -1

69 lines not on this page · raw message

tools/net/ynl/generated/devlink-user.c +2225 -116

2,096 lines not on this page · raw message

tools/net/ynl/generated/devlink-user.h +1269 -26

1,295 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
#8 lore raw

PATCH v4 8/13 devlink: remove duplicate temporary netlink callback prototypes

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

Remove the duplicate temporary netlink callback prototype as the generated ones are already in place.

---
v2->v3:
- new patch

---
 net/devlink/devl_internal.h | 48 -------------------------------------
 1 file changed, 48 deletions(-)
net/devlink/devl_internal.h +0 -48
index f8af6ffdbb3a..7caa385703de 100644
@@ -185,50 +185,11 @@ int devlink_rate_nodes_check(struct devlink *devlink, u16 mode,
 			     struct netlink_ext_ack *extack);
 
 /* Devlink nl cmds */
-int devlink_nl_pre_doit_port(const struct genl_split_ops *ops,
-			     struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_pre_doit_port_optional(const struct genl_split_ops *ops,
-				      struct sk_buff *skb,
-				      struct genl_info *info);
 int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info);
 int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info);
 int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info);
 int devlink_nl_cmd_flash_update(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_selftests_get_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_selftests_get_dumpit(struct sk_buff *skb,
-				    struct netlink_callback *cb);
 int devlink_nl_cmd_selftests_run(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_port_get_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_port_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
-int devlink_nl_rate_get_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_rate_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
-int devlink_nl_linecard_get_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_linecard_get_dumpit(struct sk_buff *skb,
-				   struct netlink_callback *cb);
-int devlink_nl_sb_get_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_sb_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
-int devlink_nl_sb_pool_get_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_sb_pool_get_dumpit(struct sk_buff *skb,
-				  struct netlink_callback *cb);
-int devlink_nl_sb_port_pool_get_doit(struct sk_buff *skb,
-				     struct genl_info *info);
-int devlink_nl_sb_port_pool_get_dumpit(struct sk_buff *skb,
-				       struct netlink_callback *cb);
-int devlink_nl_sb_tc_pool_bind_get_doit(struct sk_buff *skb,
-					struct genl_info *info);
-int devlink_nl_sb_tc_pool_bind_get_dumpit(struct sk_buff *skb,
-					  struct netlink_callback *cb);
-int devlink_nl_param_get_doit(struct sk_buff *skb,
-			      struct genl_info *info);
-int devlink_nl_param_get_dumpit(struct sk_buff *skb,
-				struct netlink_callback *cb);
-int devlink_nl_region_get_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_region_get_dumpit(struct sk_buff *skb,
-				 struct netlink_callback *cb);
-int devlink_nl_health_reporter_get_doit(struct sk_buff *skb,
-					struct genl_info *info);
-int devlink_nl_health_reporter_get_dumpit(struct sk_buff *skb,
-					  struct netlink_callback *cb);
 int devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb,
 					    struct genl_info *info);
 int devlink_nl_cmd_health_reporter_recover_doit(struct sk_buff *skb,
@@ -241,12 +202,3 @@ int devlink_nl_cmd_health_reporter_dump_clear_doit(struct sk_buff *skb,
 						   struct genl_info *info);
 int devlink_nl_cmd_health_reporter_test_doit(struct sk_buff *skb,
 					     struct genl_info *info);
-int devlink_nl_trap_get_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_trap_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
-int devlink_nl_trap_group_get_dumpit(struct sk_buff *skb,
-				     struct netlink_callback *cb);
-int devlink_nl_trap_group_get_doit(struct sk_buff *skb, struct genl_info *info);
-int devlink_nl_trap_policer_get_doit(struct sk_buff *skb,
-				     struct genl_info *info);
-int devlink_nl_trap_policer_get_dumpit(struct sk_buff *skb,
-				       struct netlink_callback *cb);
Signature · 1 line
2.41.0
author maintainer
#9 lore raw

PATCH v4 9/13 devlink: remove converted commands from small ops

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

As the commands are already defined in split ops, remove them from small ops.

---
v2->v3:
- new patch

---
 net/devlink/devl_internal.h |  2 +-
 net/devlink/leftover.c      | 99 +------------------------------------
 2 files changed, 3 insertions(+), 98 deletions(-)
net/devlink/devl_internal.h +1 -1
index 7caa385703de..eb1d5066c73f 100644
@@ -118,7 +118,7 @@ typedef int devlink_nl_dump_one_func_t(struct sk_buff *msg,
 				       struct netlink_callback *cb,
 				       int flags);
 
-extern const struct genl_small_ops devlink_nl_small_ops[54];
+extern const struct genl_small_ops devlink_nl_small_ops[40];
 
 struct devlink *
 devlink_get_from_attrs_lock(struct net *net, struct nlattr **attrs);
net/devlink/leftover.c +2 -97

173 lines not on this page · raw message

Signature · 1 line
2.41.0
author maintainer
#10 lore raw

PATCH v4 10/13 devlink: allow user to narrow per-instance dumps by passing handle attrs

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

For SFs, one devlink instance per SF is created. There might be thousands of these on a single host. When a user needs to know port handle for specific SF, he needs to dump all devlink ports on the host which does not scale good.

Allow user to pass devlink handle attributes alongside the dump command and dump only objects which are under selected devlink instance.

Example:

$ devlink port show
auxiliary/mlx5_core.eth.0/65535: type eth netdev eth2 flavour physical port 0 splittable false
auxiliary/mlx5_core.eth.1/131071: type eth netdev eth3 flavour physical port 1 splittable false
$ devlink port show auxiliary/mlx5_core.eth.0
auxiliary/mlx5_core.eth.0/65535: type eth netdev eth2 flavour physical port 0 splittable false
$ devlink port show auxiliary/mlx5_core.eth.1
auxiliary/mlx5_core.eth.1/131071: type eth netdev eth3 flavour physical port 1 splittable false

---
v3->v4:
- fixed NLM_F_DUMP_FILTERED setting
v2->v3:
- rebased on top of the generated split ops changes
- removed SELECTOR nested attr
- rebased on top of flags arg propagation, added NLM_F_DUMP_FILTERED
- removed no longer needed start() and done() dump callbacks
- adjusted patch subject and description to better match what the patch does now
v1->v2:
- extended to patch that covers all dumpit commands
- used start() and done() callback to parse the selector attr
- changed the selector attr netlink policy to be created on fly
- changed patch description accordingly

---
 net/devlink/netlink.c | 43 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 40 insertions(+), 3 deletions(-)
net/devlink/netlink.c +40 -3
index 47e44fb45815..a9b43b0c5959 100644
@@ -170,8 +170,30 @@ void devlink_nl_post_doit(const struct genl_split_ops *ops,
 	devlink_put(devlink);
 }
 
-int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
-		      devlink_nl_dump_one_func_t *dump_one)
+static int devlink_nl_inst_single_dumpit(struct sk_buff *msg,
+					 struct netlink_callback *cb, int flags,
+					 devlink_nl_dump_one_func_t *dump_one,
+					 struct nlattr **attrs)
+{
+	struct devlink *devlink;
+	int err;
+
+	devlink = devlink_get_from_attrs_lock(sock_net(msg->sk), attrs);
+	if (IS_ERR(devlink))
+		return PTR_ERR(devlink);
+	err = dump_one(msg, devlink, cb, flags | NLM_F_DUMP_FILTERED);
+
+	devl_unlock(devlink);
+	devlink_put(devlink);
+
+	if (err != -EMSGSIZE)
+		return err;
+	return msg->len;
+}
+
+static int devlink_nl_inst_iter_dumpit(struct sk_buff *msg,
+				       struct netlink_callback *cb, int flags,
+				       devlink_nl_dump_one_func_t *dump_one)
 {
 	struct devlink_nl_dump_state *state = devlink_dump_state(cb);
 	struct devlink *devlink;
@@ -182,7 +204,7 @@ int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
 		devl_lock(devlink);
 
 		if (devl_is_registered(devlink))
-			err = dump_one(msg, devlink, cb, NLM_F_MULTI);
+			err = dump_one(msg, devlink, cb, flags);
 		else
 			err = 0;
 
@@ -203,6 +225,21 @@ int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
 	return msg->len;
 }
 
+int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
+		      devlink_nl_dump_one_func_t *dump_one)
+{
+	const struct genl_dumpit_info *info = genl_dumpit_info(cb);
+	struct nlattr **attrs = info->attrs;
+	int flags = NLM_F_MULTI;
+
+	if (attrs &&
+	    (attrs[DEVLINK_ATTR_BUS_NAME] || attrs[DEVLINK_ATTR_DEV_NAME]))
+		return devlink_nl_inst_single_dumpit(msg, cb, flags, dump_one,
+						     attrs);
+	else
+		return devlink_nl_inst_iter_dumpit(msg, cb, flags, dump_one);
+}
+
 struct genl_family devlink_nl_family __ro_after_init = {
 	.name		= DEVLINK_GENL_NAME,
 	.version	= DEVLINK_GENL_VERSION,
Signature · 1 line
2.41.0
author maintainer
#11 lore raw

PATCH v4 11/13 netlink: specs: devlink: extend per-instance dump commands to accept instance attributes

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

Extend per-instance dump command definitions to accept instance attributes. Allow parsing of devlink handle attributes so they could be used for instance selection.

Re-generate the related code.

---
v2->v3:
- new patch

---
 Documentation/netlink/specs/devlink.yaml |  39 +-
 net/devlink/netlink_gen.c                | 169 +++++--
 tools/net/ynl/generated/devlink-user.c   | 123 ++++-
 tools/net/ynl/generated/devlink-user.h   | 546 ++++++++++++++++++++++-
 4 files changed, 799 insertions(+), 78 deletions(-)
Documentation/netlink/specs/devlink.yaml +26 -13
index 4f2aa48017a7..6dbebeebd63e 100644
@@ -284,7 +284,6 @@ operations:
       attribute-set: devlink
       dont-validate:
         - strict
-        - dump
 
       do:
         pre: devlink-nl-pre-doit-port
@@ -299,6 +298,8 @@ operations:
           value: 7
           attributes: *port-id-attrs
       dump:
+        request:
+          attributes: *dev-id-attrs
         reply:
           value: 3  # due to a bug, port dump returns DEVLINK_CMD_NEW
           attributes: *port-id-attrs
@@ -311,7 +312,6 @@ operations:
       attribute-set: devlink
       dont-validate:
         - strict
-        - dump
 
       do:
         pre: devlink-nl-pre-doit
@@ -326,6 +326,8 @@ operations:
           value: 11
           attributes: *sb-id-attrs
       dump:
+        request:
+          attributes: *dev-id-attrs
         reply: *sb-get-reply
 
       # TODO: fill in the operations in between
@@ -336,7 +338,6 @@ operations:
       attribute-set: devlink
       dont-validate:
         - strict
-        - dump
 
       do:
         pre: devlink-nl-pre-doit
@@ -352,6 +353,8 @@ operations:
           value: 15
           attributes: *sb-pool-id-attrs
       dump:
+        request:
+          attributes: *dev-id-attrs
         reply: *sb-pool-get-reply
 
       # TODO: fill in the operations in between
@@ -362,7 +365,6 @@ operations:
       attribute-set: devlink
       dont-validate:
         - strict
-        - dump
 
       do:
         pre: devlink-nl-pre-doit-port
@@ -379,6 +381,8 @@ operations:
           value: 19
           attributes: *sb-port-pool-id-attrs
       dump:
+        request:
+          attributes: *dev-id-attrs
         reply: *sb-port-pool-get-reply
 
       # TODO: fill in the operations in between
@@ -389,7 +393,6 @@ operations:
       attribute-set: devlink
       dont-validate:
         - strict
-        - dump
 
       do:
         pre: devlink-nl-pre-doit-port
@@ -407,6 +410,8 @@ operations:
           value: 23
           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
@@ -417,7 +422,6 @@ operations:
       attribute-set: devlink
       dont-validate:
         - strict
-        - dump
 
       do:
         pre: devlink-nl-pre-doit
@@ -432,6 +436,8 @@ operations:
           value: 38
           attributes: *param-id-attrs
       dump:
+        request:
+          attributes: *dev-id-attrs
         reply: *param-get-reply
 
       # TODO: fill in the operations in between
@@ -442,7 +448,6 @@ operations:
       attribute-set: devlink
       dont-validate:
         - strict
-        - dump
 
       do:
         pre: devlink-nl-pre-doit-port-optional
@@ -458,6 +463,8 @@ operations:
           value: 42
           attributes: *region-id-attrs
       dump:
+        request:
+          attributes: *dev-id-attrs
         reply: *region-get-reply
 
       # TODO: fill in the operations in between
@@ -495,7 +502,6 @@ operations:
       attribute-set: devlink
       dont-validate:
         - strict
-        - dump
 
       do:
         pre: devlink-nl-pre-doit-port-optional
@@ -509,6 +515,8 @@ operations:
         reply: &health-reporter-get-reply
           attributes: *health-reporter-id-attrs
       dump:
+        request:
+          attributes: *dev-id-attrs
         reply: *health-reporter-get-reply
 
       # TODO: fill in the operations in between
@@ -519,7 +527,6 @@ operations:
       attribute-set: devlink
       dont-validate:
         - strict
-        - dump
 
       do:
         pre: devlink-nl-pre-doit
@@ -534,6 +541,8 @@ operations:
           value: 61
           attributes: *trap-id-attrs
       dump:
+        request:
+          attributes: *dev-id-attrs
         reply: *trap-get-reply
 
       # TODO: fill in the operations in between
@@ -544,7 +553,6 @@ operations:
       attribute-set: devlink
       dont-validate:
         - strict
-        - dump
 
       do:
         pre: devlink-nl-pre-doit
@@ -559,6 +567,8 @@ operations:
           value: 65
           attributes: *trap-group-id-attrs
       dump:
+        request:
+          attributes: *dev-id-attrs
         reply: *trap-group-get-reply
 
       # TODO: fill in the operations in between
@@ -569,7 +579,6 @@ operations:
       attribute-set: devlink
       dont-validate:
         - strict
-        - dump
 
       do:
         pre: devlink-nl-pre-doit
@@ -584,6 +593,8 @@ operations:
           value: 69
           attributes: *trap-policer-id-attrs
       dump:
+        request:
+          attributes: *dev-id-attrs
         reply: *trap-policer-get-reply
 
       # TODO: fill in the operations in between
@@ -594,7 +605,6 @@ operations:
       attribute-set: devlink
       dont-validate:
         - strict
-        - dump
 
       do:
         pre: devlink-nl-pre-doit
@@ -610,6 +620,8 @@ operations:
           value: 74
           attributes: *rate-id-attrs
       dump:
+        request:
+          attributes: *dev-id-attrs
         reply: *rate-get-reply
 
       # TODO: fill in the operations in between
@@ -620,7 +632,6 @@ operations:
       attribute-set: devlink
       dont-validate:
         - strict
-        - dump
 
       do:
         pre: devlink-nl-pre-doit
@@ -635,6 +646,8 @@ operations:
           value: 78
           attributes: *linecard-id-attrs
       dump:
+        request:
+          attributes: *dev-id-attrs
         reply: *linecard-get-reply
 
       # TODO: fill in the operations in between
net/devlink/netlink_gen.c +130 -39

419 lines not on this page · raw message

tools/net/ynl/generated/devlink-user.c +110 -13

279 lines not on this page · raw message

tools/net/ynl/generated/devlink-user.h +533 -13

702 lines not on this page · raw message

Signature · 1 line
2.41.0
author maintainer
#12 lore raw

PATCH v4 12/13 devlink: extend health reporter dump selector by port index

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

Introduce a possibility for devlink object to expose attributes it supports for selection of dumped objects.

Use this by health reporter to indicate it supports port index based selection of dump objects. Implement this selection mechanism in devlink_nl_cmd_health_reporter_get_dump_one()

Example:

$ devlink health
pci/0000:08:00.0:
  reporter fw
    state healthy error 0 recover 0 auto_dump true
  reporter fw_fatal
    state healthy error 0 recover 0 grace_period 60000 auto_recover true auto_dump true
  reporter vnic
    state healthy error 0 recover 0
pci/0000:08:00.0/32768:
  reporter vnic
    state healthy error 0 recover 0
pci/0000:08:00.0/32769:
  reporter vnic
    state healthy error 0 recover 0
pci/0000:08:00.0/32770:
  reporter vnic
    state healthy error 0 recover 0
pci/0000:08:00.1:
  reporter fw
    state healthy error 0 recover 0 auto_dump true
  reporter fw_fatal
    state healthy error 0 recover 0 grace_period 60000 auto_recover true auto_dump true
  reporter vnic
    state healthy error 0 recover 0
pci/0000:08:00.1/98304:
  reporter vnic
    state healthy error 0 recover 0
pci/0000:08:00.1/98305:
  reporter vnic
    state healthy error 0 recover 0
pci/0000:08:00.1/98306:
  reporter vnic
    state healthy error 0 recover 0
$ devlink health show pci/0000:08:00.0
pci/0000:08:00.0:
  reporter fw
    state healthy error 0 recover 0 auto_dump true
  reporter fw_fatal
    state healthy error 0 recover 0 grace_period 60000 auto_recover true auto_dump true
  reporter vnic
    state healthy error 0 recover 0
pci/0000:08:00.0/32768:
  reporter vnic
    state healthy error 0 recover 0
pci/0000:08:00.0/32769:
  reporter vnic
    state healthy error 0 recover 0
pci/0000:08:00.0/32770:
  reporter vnic
    state healthy error 0 recover 0
$ devlink health show pci/0000:08:00.0/32768
pci/0000:08:00.0/32768:
  reporter vnic
    state healthy error 0 recover 0

The last command is possible because of this patch.

---
v3->v4:
- fixed NLM_F_DUMP_FILTERED setting
v2->v3:
- rebased on top of generated split ops and policies
- rebased on top of selector attr removal

---
 net/devlink/health.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
net/devlink/health.c +14 -1
index b9b3e68d9043..a85bdec34801 100644
@@ -390,12 +390,23 @@ static int devlink_nl_health_reporter_get_dump_one(struct sk_buff *msg,
 						   int flags)
 {
 	struct devlink_nl_dump_state *state = devlink_dump_state(cb);
+	const struct genl_dumpit_info *info = genl_dumpit_info(cb);
 	struct devlink_health_reporter *reporter;
+	unsigned long port_index_end = ULONG_MAX;
+	struct nlattr **attrs = info->attrs;
+	unsigned long port_index_start = 0;
 	struct devlink_port *port;
 	unsigned long port_index;
 	int idx = 0;
 	int err;
 
+	if (attrs && attrs[DEVLINK_ATTR_PORT_INDEX]) {
+		port_index_start = nla_get_u32(attrs[DEVLINK_ATTR_PORT_INDEX]);
+		port_index_end = port_index_start;
+		flags |= NLM_F_DUMP_FILTERED;
+		goto per_port_dump;
+	}
+
 	list_for_each_entry(reporter, &devlink->reporter_list, list) {
 		if (idx < state->idx) {
 			idx++;
@@ -412,7 +423,9 @@ static int devlink_nl_health_reporter_get_dump_one(struct sk_buff *msg,
 		}
 		idx++;
 	}
-	xa_for_each(&devlink->ports, port_index, port) {
+per_port_dump:
+	xa_for_each_range(&devlink->ports, port_index, port,
+			  port_index_start, port_index_end) {
 		list_for_each_entry(reporter, &port->reporter_list, list) {
 			if (idx < state->idx) {
 				idx++;
Signature · 1 line
2.41.0
author maintainer
#13 lore raw

PATCH v4 13/13 netlink: specs: devlink: extend health reporter dump attributes by port index

In reply to Jiri Pirko

From: Jiri Pirko <[email protected]>

Allow user to pass port index for health reporter dump request.

Re-generate the related code.

---
v2->v3:
- new patch

---
 Documentation/netlink/specs/devlink.yaml | 2 +-
 net/devlink/netlink_gen.c                | 5 +++--
 tools/net/ynl/generated/devlink-user.c   | 2 ++
 tools/net/ynl/generated/devlink-user.h   | 9 +++++++++
 4 files changed, 15 insertions(+), 3 deletions(-)
Documentation/netlink/specs/devlink.yaml +1 -1
index 6dbebeebd63e..d1ebcd927149 100644
@@ -516,7 +516,7 @@ operations:
           attributes: *health-reporter-id-attrs
       dump:
         request:
-          attributes: *dev-id-attrs
+          attributes: *port-id-attrs
         reply: *health-reporter-get-reply
 
       # TODO: fill in the operations in between
net/devlink/netlink_gen.c +3 -2
index 5f3e980c6a7c..467b7a431de1 100644
@@ -129,9 +129,10 @@ static const struct nla_policy devlink_health_reporter_get_do_nl_policy[DEVLINK_
 };
 
 /* DEVLINK_CMD_HEALTH_REPORTER_GET - dump */
-static const struct nla_policy devlink_health_reporter_get_dump_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
+static const struct nla_policy devlink_health_reporter_get_dump_nl_policy[DEVLINK_ATTR_PORT_INDEX + 1] = {
 	[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
 	[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
+	[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
 };
 
 /* DEVLINK_CMD_TRAP_GET - do */
@@ -373,7 +374,7 @@ const struct genl_split_ops devlink_nl_ops[32] = {
 		.cmd		= DEVLINK_CMD_HEALTH_REPORTER_GET,
 		.dumpit		= devlink_nl_health_reporter_get_dumpit,
 		.policy		= devlink_health_reporter_get_dump_nl_policy,
-		.maxattr	= DEVLINK_ATTR_DEV_NAME,
+		.maxattr	= DEVLINK_ATTR_PORT_INDEX,
 		.flags		= GENL_CMD_CAP_DUMP,
 	},
 	{
tools/net/ynl/generated/devlink-user.c +2 -0
index 80ee9d24eb16..3a8d8499fab6 100644
@@ -2079,6 +2079,8 @@ devlink_health_reporter_get_dump(struct ynl_sock *ys,
 		mnl_attr_put_strz(nlh, DEVLINK_ATTR_BUS_NAME, req->bus_name);
 	if (req->_present.dev_name_len)
 		mnl_attr_put_strz(nlh, DEVLINK_ATTR_DEV_NAME, req->dev_name);
+	if (req->_present.port_index)
+		mnl_attr_put_u32(nlh, DEVLINK_ATTR_PORT_INDEX, req->port_index);
 
 	err = ynl_exec_dump(ys, nlh, &yds);
 	if (err < 0)
tools/net/ynl/generated/devlink-user.h +9 -0
index 12530f1795ca..4b686d147613 100644
@@ -1242,10 +1242,12 @@ struct devlink_health_reporter_get_req_dump {
 	struct {
 		__u32 bus_name_len;
 		__u32 dev_name_len;
+		__u32 port_index:1;
 	} _present;
 
 	char *bus_name;
 	char *dev_name;
+	__u32 port_index;
 };
 
 static inline struct devlink_health_reporter_get_req_dump *
@@ -1276,6 +1278,13 @@ devlink_health_reporter_get_req_dump_set_dev_name(struct devlink_health_reporter
 	memcpy(req->dev_name, dev_name, req->_present.dev_name_len);
 	req->dev_name[req->_present.dev_name_len] = 0;
 }
+static inline void
+devlink_health_reporter_get_req_dump_set_port_index(struct devlink_health_reporter_get_req_dump *req,
+						    __u32 port_index)
+{
+	req->_present.port_index = 1;
+	req->port_index = port_index;
+}
 
 struct devlink_health_reporter_get_list {
 	struct devlink_health_reporter_get_list *next;
Signature · 1 line
2.41.0
maintainer Acked-by on the v4 series
#14 lore raw
In reply to Jiri Pirko
Quoted 4 lines · On Fri, 11 Aug 2023 17:57:01 +0200 Jiri Pirko wrote:

For SFs, one devlink instance per SF is created. There might be thousands of these on a single host. When a user needs to know port handle for specific SF, he needs to dump all devlink ports on the host which does not scale good.

#15 lore raw
In reply to Jiri Pirko
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 10 lines · On Fri, 11 Aug 2023 17:57:01 +0200 you wrote:

From: Jiri Pirko <[email protected]>

Motivation:

For SFs, one devlink instance per SF is created. There might be thousands of these on a single host. When a user needs to know port handle for specific SF, he needs to dump all devlink ports on the host which does not scale good.

[...]

Here is the summary with links:
- [net-next,v4,01/13] devlink: parse linecard attr in doit() callbacks

    https://git.kernel.org/netdev/net-next/c/63618463cb94
  - [net-next,v4,02/13] devlink: parse rate attrs in doit() callbacks
    https://git.kernel.org/netdev/net-next/c/41a1d4d1399a
  - [net-next,v4,03/13] devlink: introduce devlink_nl_pre_doit_port*() helper functions
    https://git.kernel.org/netdev/net-next/c/ee6d78ac28c7
  - [net-next,v4,04/13] devlink: rename doit callbacks for per-instance dump commands
    https://git.kernel.org/netdev/net-next/c/8fa995ad1f7f
  - [net-next,v4,05/13] devlink: introduce dumpit callbacks for split ops
    https://git.kernel.org/netdev/net-next/c/24c8e56d4f98
  - [net-next,v4,06/13] devlink: pass flags as an arg of dump_one() callback
    https://git.kernel.org/netdev/net-next/c/7d3c6fec6135
  - [net-next,v4,07/13] netlink: specs: devlink: add commands that do per-instance dump
    https://git.kernel.org/netdev/net-next/c/7199c86247e9
  - [net-next,v4,08/13] devlink: remove duplicate temporary netlink callback prototypes
    https://git.kernel.org/netdev/net-next/c/ddff283280ba
  - [net-next,v4,09/13] devlink: remove converted commands from small ops
    https://git.kernel.org/netdev/net-next/c/833e479d330c
  - [net-next,v4,10/13] devlink: allow user to narrow per-instance dumps by passing handle attrs
    https://git.kernel.org/netdev/net-next/c/4a1b5aa8b5c7
  - [net-next,v4,11/13] netlink: specs: devlink: extend per-instance dump commands to accept instance attributes
    https://git.kernel.org/netdev/net-next/c/34493336e7d3
  - [net-next,v4,12/13] devlink: extend health reporter dump selector by port index
    https://git.kernel.org/netdev/net-next/c/b03f13cb67a5
  - [net-next,v4,13/13] netlink: specs: devlink: extend health reporter dump attributes by port index
    https://git.kernel.org/netdev/net-next/c/0149bca17262

You are awesome, thank you!

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