Skip to contentSkip to conversation

devlink: Support DEVLINK_ESWITCH_MODE_SWITCHDEV_INACTIVE

PATCH In review Saeed Mahameed 2 participants 4 messages Nov 7, 2025 – Nov 15, 2025

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

PATCH 1/1 devlink: Support DEVLINK_ESWITCH_MODE_SWITCHDEV_INACTIVE

From: Saeed Mahameed <[email protected]>

Add support for the new inactive switchdev mode [1].

A user can start the eswitch in switchdev or switchdev_inactive mode.

Active: Traffic is enabled on this eswitch FDB.
Inactive: Traffic is ignored/dropped on this eswitch FDB.

An example use case:

$ devlink dev eswitch set pci/0000:08:00.1 mode switchdev_inactive
Setup FDB pipeline and netdev representors
...
Once ready to start receiving traffic
$ devlink dev eswitch set pci/0000:08:00.1 mode switchdev

[1] https://lore.kernel.org/all/[email protected]/

---
 devlink/devlink.c            | 7 ++++++-
 include/uapi/linux/devlink.h | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)
devlink/devlink.c +6 -1
index 35128083..fd9fac21 100644
@@ -45,6 +45,7 @@
 
 #define ESWITCH_MODE_LEGACY "legacy"
 #define ESWITCH_MODE_SWITCHDEV "switchdev"
+#define ESWITCH_MODE_SWITCHDEV_INACTIVE "switchdev_inactive"
 #define ESWITCH_INLINE_MODE_NONE "none"
 #define ESWITCH_INLINE_MODE_LINK "link"
 #define ESWITCH_INLINE_MODE_NETWORK "network"
@@ -1428,6 +1429,8 @@ static int eswitch_mode_get(const char *typestr,
 		*p_mode = DEVLINK_ESWITCH_MODE_LEGACY;
 	} else if (strcmp(typestr, ESWITCH_MODE_SWITCHDEV) == 0) {
 		*p_mode = DEVLINK_ESWITCH_MODE_SWITCHDEV;
+	} else if (strcmp(typestr, ESWITCH_MODE_SWITCHDEV_INACTIVE) == 0) {
+		*p_mode = DEVLINK_ESWITCH_MODE_SWITCHDEV_INACTIVE;
 	} else {
 		pr_err("Unknown eswitch mode \"%s\"\n", typestr);
 		return -EINVAL;
@@ -2848,7 +2851,7 @@ static bool dl_dump_filter(struct dl *dl, struct nlattr **tb)
 static void cmd_dev_help(void)
 {
 	pr_err("Usage: devlink dev show [ DEV ]\n");
-	pr_err("       devlink dev eswitch set DEV [ mode { legacy | switchdev } ]\n");
+	pr_err("       devlink dev eswitch set DEV [ mode { legacy | switchdev | switchdev_inactive } ]\n");
 	pr_err("                               [ inline-mode { none | link | network | transport } ]\n");
 	pr_err("                               [ encap-mode { none | basic } ]\n");
 	pr_err("       devlink dev eswitch show DEV\n");
@@ -3284,6 +3287,8 @@ static const char *eswitch_mode_name(uint32_t mode)
 	switch (mode) {
 	case DEVLINK_ESWITCH_MODE_LEGACY: return ESWITCH_MODE_LEGACY;
 	case DEVLINK_ESWITCH_MODE_SWITCHDEV: return ESWITCH_MODE_SWITCHDEV;
+	case DEVLINK_ESWITCH_MODE_SWITCHDEV_INACTIVE:
+		return ESWITCH_MODE_SWITCHDEV_INACTIVE;
 	default: return "<unknown mode>";
 	}
 }
include/uapi/linux/devlink.h +1 -0
index bcd5fde1..317c088b 100644
@@ -181,6 +181,7 @@ enum devlink_sb_threshold_type {
 enum devlink_eswitch_mode {
 	DEVLINK_ESWITCH_MODE_LEGACY,
 	DEVLINK_ESWITCH_MODE_SWITCHDEV,
+	DEVLINK_ESWITCH_MODE_SWITCHDEV_INACTIVE,
 };
 
 enum devlink_eswitch_inline_mode {
Signature · 1 line
2.51.1
#1 lore raw
Quoted 9 lines · Saeed Mahameed

From: Saeed Mahameed <[email protected]>

Add support for the new inactive switchdev mode [1].

A user can start the eswitch in switchdev or switchdev_inactive mode.

Active: Traffic is enabled on this eswitch FDB.
Inactive: Traffic is ignored/dropped on this eswitch FDB.

Quoted 9 lines

An example use case:

$ devlink dev eswitch set pci/0000:08:00.1 mode switchdev_inactive
Setup FDB pipeline and netdev representors
...
Once ready to start receiving traffic
$ devlink dev eswitch set pci/0000:08:00.1 mode switchdev

[1] https://lore.kernel.org/all/[email protected]/

Hi, this was supposed to be marked for -next, do you want me to repost ?

The kernel part was applied to net-next:
https://lore.kernel.org/all/176286361051.3417146.8495442358677824245.git-patchwork-notify@kernel.org/

#3 lore raw
In reply to Saeed Mahameed
Quoted 29 lines · Saeed Mahameed

From: Saeed Mahameed <[email protected]>

Add support for the new inactive switchdev mode [1].

A user can start the eswitch in switchdev or switchdev_inactive mode.

Active: Traffic is enabled on this eswitch FDB.
Inactive: Traffic is ignored/dropped on this eswitch FDB.

An example use case:

$ devlink dev eswitch set pci/0000:08:00.1 mode switchdev_inactive
Setup FDB pipeline and netdev representors
...
Once ready to start receiving traffic
$ devlink dev eswitch set pci/0000:08:00.1 mode switchdev

[1] https://lore.kernel.org/all/[email protected]/

---
 devlink/devlink.c            | 7 ++++++-
 include/uapi/linux/devlink.h | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)
devlink/devlink.c +0 -0
index 35128083..fd9fac21 100644

devlink/devlink.c line 51

Quoted 7 lines
devlink/devlink.c +1 -0
@@ -45,6 +45,7 @@
 
 #define ESWITCH_MODE_LEGACY "legacy"
 #define ESWITCH_MODE_SWITCHDEV "switchdev"
+#define ESWITCH_MODE_SWITCHDEV_INACTIVE "switchdev_inactive"
 #define ESWITCH_INLINE_MODE_NONE "none"
 #define ESWITCH_INLINE_MODE_LINK "link"
 #define ESWITCH_INLINE_MODE_NETWORK "network"

These modes really should be an array that is used for both set and show. Then eswitch_mode_get and eswitch_mode_get would not need to be touched; just update arrays and the new entries take effect.

Quoted 32 lines
devlink/devlink.c +5 -1
@@ -1428,6 +1429,8 @@ static int eswitch_mode_get(const char *typestr,
 		*p_mode = DEVLINK_ESWITCH_MODE_LEGACY;
 	} else if (strcmp(typestr, ESWITCH_MODE_SWITCHDEV) == 0) {
 		*p_mode = DEVLINK_ESWITCH_MODE_SWITCHDEV;
+	} else if (strcmp(typestr, ESWITCH_MODE_SWITCHDEV_INACTIVE) == 0) {
+		*p_mode = DEVLINK_ESWITCH_MODE_SWITCHDEV_INACTIVE;
 	} else {
 		pr_err("Unknown eswitch mode \"%s\"\n", typestr);
 		return -EINVAL;
@@ -2848,7 +2851,7 @@ static bool dl_dump_filter(struct dl *dl, struct nlattr **tb)
 static void cmd_dev_help(void)
 {
 	pr_err("Usage: devlink dev show [ DEV ]\n");
-	pr_err("       devlink dev eswitch set DEV [ mode { legacy | switchdev } ]\n");
+	pr_err("       devlink dev eswitch set DEV [ mode { legacy | switchdev | switchdev_inactive } ]\n");
 	pr_err("                               [ inline-mode { none | link | network | transport } ]\n");
 	pr_err("                               [ encap-mode { none | basic } ]\n");
 	pr_err("       devlink dev eswitch show DEV\n");
@@ -3284,6 +3287,8 @@ static const char *eswitch_mode_name(uint32_t mode)
 	switch (mode) {
 	case DEVLINK_ESWITCH_MODE_LEGACY: return ESWITCH_MODE_LEGACY;
 	case DEVLINK_ESWITCH_MODE_SWITCHDEV: return ESWITCH_MODE_SWITCHDEV;
+	case DEVLINK_ESWITCH_MODE_SWITCHDEV_INACTIVE:
+		return ESWITCH_MODE_SWITCHDEV_INACTIVE;
 	default: return "<unknown mode>";
 	}
 }
include/uapi/linux/devlink.h +0 -0
index bcd5fde1..317c088b 100644

include/uapi/linux/devlink.h enum devlink_sb_threshold_type { · line 187

Quoted 7 lines
include/uapi/linux/devlink.h +1 -0
@@ -181,6 +181,7 @@ enum devlink_sb_threshold_type {
 enum devlink_eswitch_mode {
 	DEVLINK_ESWITCH_MODE_LEGACY,
 	DEVLINK_ESWITCH_MODE_SWITCHDEV,
+	DEVLINK_ESWITCH_MODE_SWITCHDEV_INACTIVE,
 };
 
 enum devlink_eswitch_inline_mode {

uapi changes should be a separate patch that I can drop when applying the rest of the changes.

Requests for future patches; i applied this one to iproute2-next.