All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Saeed Mahameed <saeed@kernel.org>, netdev@vger.kernel.org
Cc: stephen@networkplumber.org, Jiri Pirko <jiri@nvidia.com>,
	Saeed Mahameed <saeedm@nvidia.com>
Subject: Re: [PATCH iproute2] devlink: Support DEVLINK_ESWITCH_MODE_SWITCHDEV_INACTIVE
Date: Fri, 14 Nov 2025 18:22:01 -0700	[thread overview]
Message-ID: <296bed71-34b3-48df-8799-0701083712f4@gmail.com> (raw)
In-Reply-To: <20251107001435.160260-1-saeed@kernel.org>

On 11/6/25 5:14 PM, Saeed Mahameed wrote:
> From: Saeed Mahameed <saeedm@nvidia.com>
> 
> 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/20251107000831.157375-1-saeed@kernel.org/
> 
> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
> ---
>  devlink/devlink.c            | 7 ++++++-
>  include/uapi/linux/devlink.h | 1 +
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/devlink/devlink.c b/devlink/devlink.c
> index 35128083..fd9fac21 100644
> --- a/devlink/devlink.c
> +++ b/devlink/devlink.c
> @@ -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.

> @@ -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>";
>  	}
>  }
> diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
> index bcd5fde1..317c088b 100644
> --- a/include/uapi/linux/devlink.h
> +++ b/include/uapi/linux/devlink.h
> @@ -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.


      parent reply	other threads:[~2025-11-15  1:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-07  0:14 [PATCH iproute2] devlink: Support DEVLINK_ESWITCH_MODE_SWITCHDEV_INACTIVE Saeed Mahameed
2025-11-12 22:46 ` Saeed Mahameed
2025-11-12 22:53   ` David Ahern
2025-11-15  1:22 ` David Ahern [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=296bed71-34b3-48df-8799-0701083712f4@gmail.com \
    --to=dsahern@gmail.com \
    --cc=jiri@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeed@kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.