netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v1] devlink: Notify eswitch mode changes to devlink monitor
@ 2025-11-19 16:59 Parav Pandit
  2025-11-20  1:56 ` Jakub Kicinski
  0 siblings, 1 reply; 10+ messages in thread
From: Parav Pandit @ 2025-11-19 16:59 UTC (permalink / raw)
  To: netdev; +Cc: davem, edumazet, kuba, pabeni, horms, Parav Pandit, Jiri Pirko

When eswitch mode changes, notify such change to the
devlink monitoring process.

After this notification, a devlink monitoring process
can see following output:

$ devlink mon
[eswitch,get] pci/0000:06:00.0: mode switchdev inline-mode none encap-mode basic
[eswitch,get] pci/0000:06:00.0: mode legacy inline-mode none encap-mode basic

Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Parav Pandit <parav@nvidia.com>
---
changelog:
v0->v1:
- addressed comment from Jakub
- fixed cmd action from SET to GET to match the usual get command
  with other responses
---
 net/devlink/dev.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/net/devlink/dev.c b/net/devlink/dev.c
index 02602704bdea..d0d77e6689c2 100644
--- a/net/devlink/dev.c
+++ b/net/devlink/dev.c
@@ -701,6 +701,30 @@ int devlink_nl_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info)
 	return genlmsg_reply(msg, info);
 }
 
+static void devlink_eswitch_notify(struct devlink *devlink)
+{
+	struct sk_buff *msg;
+	int err;
+
+	WARN_ON(!devl_is_registered(devlink));
+
+	if (!devlink_nl_notify_need(devlink))
+		return;
+
+	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+	if (!msg)
+		return;
+
+	err = devlink_nl_eswitch_fill(msg, devlink, DEVLINK_CMD_ESWITCH_GET,
+				      0, 0, 0);
+	if (err) {
+		nlmsg_free(msg);
+		return;
+	}
+
+	devlink_nl_notify_send(devlink, msg);
+}
+
 int devlink_nl_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink *devlink = info->user_ptr[0];
@@ -742,6 +766,7 @@ int devlink_nl_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info)
 			return err;
 	}
 
+	devlink_eswitch_notify(devlink);
 	return 0;
 }
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-11-25  4:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-19 16:59 [PATCH net-next v1] devlink: Notify eswitch mode changes to devlink monitor Parav Pandit
2025-11-20  1:56 ` Jakub Kicinski
2025-11-20 12:09   ` Jiri Pirko
2025-11-20 14:52     ` Jakub Kicinski
2025-11-20 14:56       ` Parav Pandit
2025-11-21  8:35       ` Jiri Pirko
2025-11-21  8:51         ` Parav Pandit
2025-11-21 14:48         ` Jakub Kicinski
2025-11-22  9:14           ` Jiri Pirko
2025-11-25  4:27             ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).