From: Saeed Mahameed <saeed@kernel.org>
To: Jiri Pirko <jiri@resnulli.us>
Cc: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.com>,
Saeed Mahameed <saeedm@nvidia.com>,
netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
Gal Pressman <gal@nvidia.com>,
Leon Romanovsky <leonro@nvidia.com>,
mbloch@nvidia.com, Parav Pandit <parav@nvidia.com>,
Adithya Jayachandran <ajayachandra@nvidia.com>
Subject: Re: [PATCH net-next 1/3] devlink: Introduce devlink eswitch state
Date: Thu, 16 Oct 2025 10:34:04 -0700 [thread overview]
Message-ID: <aPEsjG-mFIx-IqtV@x130> (raw)
In-Reply-To: <6uzvaczuh6vpflpwnyknmq32ogcw52u35djzab7yd7jlgwasdc@paq2c2yznfti>
On 16 Oct 11:16, Jiri Pirko wrote:
>Thu, Oct 16, 2025 at 03:36:16AM +0200, saeed@kernel.org wrote:
>>From: Parav Pandit <parav@nvidia.com>
>
>[...]
>
>
>>@@ -722,6 +734,24 @@ int devlink_nl_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info)
>> return err;
>> }
>>
>>+ state = DEVLINK_ESWITCH_STATE_ACTIVE;
>>+ if (info->attrs[DEVLINK_ATTR_ESWITCH_STATE]) {
>>+ if (!ops->eswitch_state_set)
>>+ return -EOPNOTSUPP;
>>+ state = nla_get_u8(info->attrs[DEVLINK_ATTR_ESWITCH_STATE]);
>>+ }
>>+ /* If user did not supply the state attribute, the default is
>>+ * active state. If the state was not explicitly set, set the default
>>+ * state for drivers that support eswitch state.
>>+ * Keep this after mode-set as state handling can be dependent on
>>+ * the eswitch mode.
>>+ */
>>+ if (ops->eswitch_state_set) {
>>+ err = ops->eswitch_state_set(devlink, state, info->extack);
>
>Calling state_set() upon every DEVLINK_CMD_ESWITCH_SET call,
>even if STATE attr is not present, is plain wrong. Don't do it.
>I don't really understand why you do so.
>
I don't get the "plain wrong" part? Please explain.
Here's is what we are trying to solve and why I think this way is the best
way to solve it, unless you have a better idea.
We want to preserve backwards compatibility, think of:
- old devlink iproute2 (doesn't provide STATE attr).
- new kernel (expects new STATE attr).
Upon your request we split mode and state handling into separate callbacks,
meaning, you set mode first and then state in DEVLINK_CMD_ESWITCH_SET.
ops->mode_set(); doesn't have information on state, so a drivers that
implement state_set() will expect state_set() to be called after
mode_set(), otherwise, state will remain inactive for that driver.
If state attr is not provided (e.g. old devlink userspace) but the user
expects state to be active, then if we do what you ask for, we don't
call state_set() and after mode_set() we will be in an inactive state,
while user expects active (default behavior) for backward compatibility.
To solve this we always default state = ACTIVE (if state attr wasn't
provided) and call state_set();
Let me know if you have better ideas, on how to solve this problem.
Otherwise, this patch's way of preserving backward compatibility is
not "plain wrong".
We can optimize to call set_state() only if (mode || state) attr was
provided. Let me know if that works for you.
- Saeed.
next prev parent reply other threads:[~2025-10-16 17:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-16 1:36 [PATCH net-next 0/3] devlink eswitch active/inactive state Saeed Mahameed
2025-10-16 1:36 ` [PATCH net-next 1/3] devlink: Introduce devlink eswitch state Saeed Mahameed
2025-10-16 9:16 ` Jiri Pirko
2025-10-16 17:34 ` Saeed Mahameed [this message]
2025-10-17 8:06 ` Jiri Pirko
2025-10-16 1:36 ` [PATCH net-next 2/3] net/mlx5: MPFS, add support for dynamic enable/disable Saeed Mahameed
2025-10-16 19:28 ` kernel test robot
2025-10-16 21:35 ` kernel test robot
2025-10-18 7:42 ` kernel test robot
2025-10-16 1:36 ` [PATCH net-next 3/3] net/mlx5: E-Switch, support eswitch state Saeed Mahameed
2025-10-16 14:54 ` Jakub Kicinski
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=aPEsjG-mFIx-IqtV@x130 \
--to=saeed@kernel.org \
--cc=ajayachandra@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=leonro@nvidia.com \
--cc=mbloch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=parav@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.com \
/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 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).