Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Shay Drori <shayd@nvidia.com>
To: <netdev-bot+sashiko@kernel.org>, <tariqt@nvidia.com>
Cc: <andrew+netdev@lunn.ch>, <davem@davemloft.net>,
	<edumazet@kernel.org>, <kuba@kernel.org>,
	<netdev@vger.kernel.org>, <pabeni@redhat.com>,
	<agoldberger@nvidia.com>, <gal@nvidia.com>, <jgg@ziepe.ca>,
	<leon@kernel.org>, <linux-rdma@vger.kernel.org>,
	<mbloch@nvidia.com>, <moshe@nvidia.com>, <ohartoov@nvidia.com>,
	<saeedm@nvidia.com>
Subject: Re: [PATCH net-next V2 1/5] net/mlx5: E-switch, add match-metadata allocator for nested VF/SF eswitches
Date: Tue, 24 Nov 2026 12:39:23 +0200	[thread overview]
Message-ID: <82624f99-cfdd-43e5-bcef-522df8e1f16d@nvidia.com> (raw)
In-Reply-To: <179550916784.3135.15503627084704234984@kernel.org>



On 24/11/2026 10:32, netdev-bot+sashiko@kernel.org wrote:
> External email: Use caution opening links or attachments
> 
> 
> Thank you for your contribution! Sashiko AI review found 3 potential
> issue(s) to consider.
> 
> Critical: 0 · High: 0 · Medium: 2 · Low: 1
> 
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
> 
> - [Medium] The layout selector added in
>    mlx5_esw_match_metadata_alloc()/mlx5_esw_match_metadata_free() is…
> - [Medium] The nested layout makes LAG admission and the encodable range
>    disagree.
> - [Low] The nested layout cuts the per-eswitch vport id space from 4094
>    ids (2-4095) to 254 ids (2-255) (`vport_end_ida = (1 <<…
> 
> --
> 
> net/mlx5: E-switch, add match-metadata allocator for nested VF/SF eswitches
> 
> This patch adds a source-port match metadata allocator for nested (virt
> LAG) VF/SF eswitches. Its layout is 8 bits for the function's slot in the
> LAG xarray plus 8 bits for a per-eswitch vport id. The nested layout is
> used for any non-PF eswitch, except one that is virt LAG capable but not
> a LAG member.
> 
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
>> index 1323114ce7f93..3c1355f910906 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> 
> [ ... ]
> 
>> +static u32 mlx5_nested_esw_match_metadata_alloc(struct mlx5_eswitch *esw)
>> +{
>> +     u32 vport_end_ida = (1 << ESW_NESTED_VPORT_BITS) - 1;
>> +     u32 max_idx = (1 << ESW_NESTED_IDX_BITS) -
>> +                   (1 << (ESW_NESTED_IDX_BITS - ESW_PFNUM_BITS)) - 1;
>> +     int idx;
>> +     int id;
>> +
>> +     idx = mlx5_lag_get_member_idx(esw->dev);
>> +     if (idx < 0 || idx > max_idx)
>> +             return 0;
> 
> [Severity: Medium]
> Can a LAG member be given a slot that this check then rejects?
> 
> mlx5_ldev_add_mdev() hands out slots 0-254:
> 
>      err = xa_alloc(&ldev->fns, &idx, fn, XA_LIMIT(0, U8_MAX - 1),
>                     GFP_KERNEL);
> 
> but max_idx here comes out to 239. A virt LAG VF/SF that lands in slot
> 240-254 is still a full member. mlx5_virt_lag_nonmember() returns false
> for it, it passes the devcom pairing gate in
> mlx5_esw_offloads_devcom_init(), and it gets the nested layout.
> 
> For such a member, every metadata allocation on its eswitch returns 0
> here. esw_offloads_vport_metadata_setup() turns that 0 into -ENOSPC, so
> switchdev can never be enabled on that function, and nothing is logged.
> 
> The comment above says only slots 0-239 are usable. Should virt LAG
> admission stop at the encodable limit, or refuse such a joiner the same
> way a late joiner is refused? Then LAG membership and match capability
> would agree.

This is theoretical only; there is no such use case.

> 
>> +
>> +     /* Use only non-zero id's (2-255). */
>> +     id = ida_alloc_range(&esw->offloads.vport_metadata_ida,
>> +                          MLX5_ESW_METADATA_RSVD_UPLINK + 1,
>> +                          vport_end_ida, GFP_KERNEL);
>> +     if (id < 0)
>> +             return 0;
> 
> [Severity: Low]
> This shrinks the per-eswitch id space from 2-4095 to 2-255. Does anything
> make sure a nested eswitch has fewer vports than that needing metadata?
> 
> esw_offloads_metadata_init() allocates metadata up front for every vport,
> and unwinds on the first failure:
> 
>      mlx5_esw_for_each_vport(esw, i, vport) {
>          err = esw_offloads_vport_metadata_setup(esw, vport);
>          if (err)
>              goto metadata_err;
> 
> mlx5_esw_vports_init() creates SF vports from mlx5_sf_max_functions(dev),
> and that is not limited to PFs:
> 
>      for (i = 0; i < mlx5_sf_max_functions(dev); i++) {
>          err = mlx5_esw_vport_alloc(esw, idx, base_sf_num + i);
> 
> mlx5e_rep_bond_enslave() and the MPESW metadata take ids from the same
> ida.
> 
> Suppose a nested VF/SF eswitch manager reports around 254 or more SFs.
> The ida runs out, this function quietly returns 0, and switchdev enable
> fails with -ENOSPC.
> 
> Commit a5bfbdfebd53 describes a non-PF eswitch as just the manager plus
> uplink, so this may not be reachable today. Would it still be worth
> clamping the vport count, or warning when it doesn't fit the 8-bit field?
> 
>> +     id = (idx << ESW_NESTED_VPORT_BITS) | id;
>> +     return id;
>> +}
> 
> [ ... ]
> 
>>   u32 mlx5_esw_match_metadata_alloc(struct mlx5_eswitch *esw)
>>   {
>>        u32 vport_end_ida = (1 << ESW_VPORT_BITS) - 1;
>> @@ -3658,6 +3700,9 @@ u32 mlx5_esw_match_metadata_alloc(struct mlx5_eswitch *esw)
>>        int pf_num;
>>        int id;
>>
>> +     if (!mlx5_core_is_pf(esw->dev) && !mlx5_virt_lag_nonmember(esw->dev))
>> +             return mlx5_nested_esw_match_metadata_alloc(esw);
>> +
> 
> [Severity: Medium]
> Doesn't this condition also choose the nested layout for non-PF eswitches
> that have no virt LAG capability at all?
> 
> mlx5_virt_lag_nonmember() is:
> 
>      return mlx5_virt_lag_is_supported(dev) && !mlx5_lag_dev(dev);
> 
> Take a VF/SF eswitch manager without the virt LAG caps (no
> multi_uplink_eswitch/lag_master, or num_lag_ports >= 2). For it,
> mlx5_virt_lag_nonmember() returns false, so the condition above is true.
> 
> Such a device never gets an ldev, because mlx5_lag_add_mdev() returns
> early:
> 
>      if (!mlx5_lag_is_supported(dev))
>          return;
> 
> Later in the series this check becomes !mlx5_lag_is_supported(dev) &&
> !mlx5_virt_lag_is_supported(dev), which still excludes the device.
> 
> So the call chain would be:
> 
> esw_offloads_metadata_init()
>    esw_offloads_vport_metadata_setup()
>      mlx5_esw_match_metadata_alloc()
>        mlx5_nested_esw_match_metadata_alloc()
>          mlx5_lag_get_member_idx() returns -ENOENT
>        returns 0
>      returns -ENOSPC
> 
> Match metadata is on by default where it is supported. Would switchdev
> enable now fail on these devices?
> 
> Before this patch they used the PFNUM layout, where mlx5_sd_pf_num_get()
> falls back to mlx5_get_dev_index(), and that worked. Non-PF eswitch
> managers have been supported regardless of virt LAG caps since commit
> a5bfbdfebd53 ("net/mlx5: E-switch, disable host functions for a non PF
> e-switch manager").
> 
> The new comment in eswitch.h says this split is for a nested (virt LAG)
> VF/SF eswitch. Would a condition that requires LAG membership, such as
> !mlx5_core_is_pf(dev) && mlx5_lag_dev(dev), better match that intent?
> mlx5_esw_match_metadata_free() uses the same condition.
> 
> Separately, at this commit even virt LAG capable VFs/SFs cannot get an
> ldev. The later patch "net/mlx5: LAG, enable LAG over functions that do
> not represent a physical port" fixes that part. The non virt LAG case is
> still there at the end of the series.

A non-PF eswitch manager without virt LAG support doesn't exist at the
moment. FW doesn't expose such a VF/SF.

> 
> --
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120075959.2533702-1-tariqt%40nvidia.com


  reply	other threads:[~2026-11-24 10:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  7:59 [PATCH net-next V2 0/5] net/mlx5: LAG over VFs/SFs (virtual LAG) Tariq Toukan
2026-11-20  7:59 ` [PATCH net-next V2 1/5] net/mlx5: E-switch, add match-metadata allocator for nested VF/SF eswitches Tariq Toukan
2026-11-21  8:02   ` sashiko-bot
2026-11-24  8:32   ` netdev-bot+sashiko
2026-11-24 10:39     ` Shay Drori [this message]
2026-11-20  7:59 ` [PATCH net-next V2 2/5] net/mlx5: E-switch, match master egress rule by vport metadata Tariq Toukan
2026-11-20  7:59 ` [PATCH net-next V2 3/5] net/mlx5: E-switch, drop master egress rule under a SW vport LAG Tariq Toukan
2026-11-24  8:32   ` netdev-bot+sashiko
2026-11-24 10:51     ` Shay Drori
2026-11-20  7:59 ` [PATCH net-next V2 4/5] net/mlx5e: Register eswitch-manager VF/SF self-port with switch-id Tariq Toukan
2026-11-21  8:02   ` sashiko-bot
2026-11-24  8:32   ` netdev-bot+sashiko
2026-11-20  7:59 ` [PATCH net-next V2 5/5] net/mlx5: LAG, enable LAG over functions that do not represent a physical port Tariq Toukan
2026-11-21  8:02   ` sashiko-bot
2026-11-24  8:32   ` netdev-bot+sashiko
2026-11-24 11:06     ` Shay Drori
2026-11-21  8:02 ` [PATCH net-next V2 0/5] net/mlx5: LAG over VFs/SFs (virtual LAG) sashiko-bot

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=82624f99-cfdd-43e5-bcef-522df8e1f16d@nvidia.com \
    --to=shayd@nvidia.com \
    --cc=agoldberger@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=gal@nvidia.com \
    --cc=jgg@ziepe.ca \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=moshe@nvidia.com \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ohartoov@nvidia.com \
    --cc=pabeni@redhat.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