* [PATCH net-next V2 0/5] net/mlx5: LAG over VFs/SFs (virtual LAG)
@ 2026-11-20 7:59 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
` (5 more replies)
0 siblings, 6 replies; 17+ messages in thread
From: Tariq Toukan @ 2026-11-20 7:59 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
netdev, Paolo Abeni
Cc: Akiva Goldberger, Gal Pressman, Jason Gunthorpe, Leon Romanovsky,
linux-rdma, Mark Bloch, Moshe Shemesh, Or Har-Toov,
Saeed Mahameed, Shay Drory, Tariq Toukan
This is V2 of the top patches submitted previously here [1].
This series by Shay enables a LAG over functions that do not represent a
physical port - a "virtual LAG" (virt LAG) of VFs or SFs acting as
nested e-switch managers. New FW lets a VF/SF front the physical uplinks
through a multi-uplink e-switch; such a function reports num_lag_ports <
2 and drives port selection via the e-switch (port_select_eswitch)
rather than the HW port-selection flow table. A virt LAG is therefore a
software-managed, shared-FDB MPESW LAG: the driver builds the LAG demux
and vport-LAG in software.
It depends on [2] which prepared the LAG core.
The patches fall into two parts.
E-switch and representors (patches 1, 2, 3, 4)
- A dedicated match-metadata allocator for nested VF/SF e-switches, so
VFs/SFs sharing an FDB get unique source-port metadata.
- Match the master egress bounce rule by vport metadata.
- Drop the master egress rule while a software vport LAG is installed:
the SW emulation is a rule in the slave's egress ACL and cannot act
on a packet the master egress rule redirects after the FDB. Restore
it when the vport LAG is removed.
- Register a VF/SF e-switch-manager self-port with a switch-id so it
groups with the representors it manages.
Virtual LAG enablement (patch 5)
- Enable LAG over functions that do not represent a physical port -
the gate that admits a virt LAG.
Regards,
Tariq
[1] https://lore.kernel.org/all/20261103171009.563034-1-tariqt@nvidia.com/
[2] https://lore.kernel.org/all/20261116103010.1129666-1-tariqt@nvidia.com/
V2:
- Split the patch set to ease the review: this is v1 patches 11-15; v1
patches 1-10 are sent as "net/mlx5: LAG, preparations for LAG over
VFs/SFs", which this series depends on.
- Patch 1: commit message describes which non-PF eswitches take the
nested metadata layout, and no longer implies a PF may have the virt
LAG capabilities. The reg_c_0 comment in include/linux/mlx5/eswitch.h
describes the nested layout (Sashiko).
- Patch 3: commit message names the field ldev->max_fns, not
ldev->max_funcs (Sashiko).
- Patch 5: do not assign an RDMA TX port affinity on a virt LAG capable
function, and do not register the multipath FIB notifier for a virt
LAG (Sashiko).
V1:
https://lore.kernel.org/all/20261103171009.563034-1-tariqt@nvidia.com/
Answers to sashiko comments on v1:
net/mlx5: E-switch, add match-metadata allocator for nested VF/SF eswitches
> + if (!mlx5_core_is_pf(esw->dev) && !mlx5_virt_lag_nonmember(esw->dev))
> + return mlx5_nested_esw_match_metadata_alloc(esw);
Q: mlx5_virt_lag_nonmember() is false when virt LAG is unsupported, so a
standalone non-PF eswitch without virt LAG support takes the nested path
and fails switchdev with -ENOSPC. Could it keep the PFNUM allocator?
[SD] A non-PF eswitch manager without virt LAG support doesn't exist at
the moment. FW doesn't expose such a VF/SF.
Q: The nested allocator gives each eswitch 254 ids (2-255), yet a
nested eswitch can enumerate up to max_num_sf SF vports, each taking an
id. Also, LAG admission accepts slots 0-254, while the allocator gives
no metadata to slots above 239. Can switchdev fail with -ENOSPC in
either case?
[SD] Both are theoretical only; there is no such use case.
net/mlx5: E-switch, match master egress rule by vport metadata
Q: Is mlx5_virt_lag_is_supported() enough to decide on reg_c_0 matching
here? Outside MPESW both uplinks share MLX5_ESW_METADATA_RSVD_UPLINK. A
PF that reports the virt LAG capability bits and also supports SD would
create a shared FDB with only the reserved uplink metadata in place. The
commit "add match-metadata allocator for nested VF/SF eswitches" says
PFs may have virt LAG capabilities.
[SD] This is not correct, PFs cannot have virt LAG caps; FW exposes
them only on VF/SF nested eswitch managers. The misleading wording in
the "add match-metadata allocator" commit message is fixed in v2.
net/mlx5: E-switch, drop master egress rule under a SW vport LAG
Q: If restoring the master egress rule fails in
mlx5_eswitch_offloads_vport_lag_del_one(), only a warning is printed
and the slave rule is removed anyway, so the slave loses forwarding.
Should the error be propagated?
[SD] If restoring fails, FW is dead, and the lost traffic is not the
real problem at that point.
net/mlx5e: Register eswitch-manager VF/SF self-port with switch-id
Q: The only condition here is MLX5_ESWITCH_MANAGER(mdev), but
mlx5_query_nic_sw_system_image_guid() makes a VF/SF id differ from the
PF's only when virt LAG is supported. Can a VF/SF eswitch manager without
the virt LAG caps give its uplink netdev the same phys_switch_id as its
parent PF's switch? Should this branch set the switch_id only when the
resulting GUID differs from the PF's?
[SD] A VF/SF eswitch manager without the virt LAG caps doesn't exist. New
FW will let a VF/SF be an eswitch manager only as a nested eswitch
manager, and such a function reports multi_uplink_eswitch, lag_master and
num_lag_ports < 2, so mlx5_query_nic_sw_system_image_guid() gives it the
VF/SF marker and its switch_id differs from its PF's.
Q: If the system image GUID query fails, the self-port is registered
with an empty switch id, and nothing fixes it later. Should the error
be propagated?
[SD] This is the same behavior as the existing PF self-port path.
net/mlx5: LAG, enable LAG over functions that do not represent a physical port
> - if (group_id)
> + if (group_id || ldev->virt_lag)
> return 0;
Q: mlx5_lag_set_vports_agg_speed() iterates ports only, so a virt LAG gets
no aggregate vport speed, and its members skip the port-change notifier.
Is there an alternative virt LAG speed policy?
[SD] This is on purpose.
Q: members_show() uses mlx5_ldev_for_each(), so the debugfs members file
is empty for a virt LAG. Could it list all members?
[SD] Left as is for now, since all VFs in the system share the LAG.
> - if (!mlx5_lag_is_supported(dev))
> + if (!mlx5_lag_is_supported(dev) && !mlx5_virt_lag_is_supported(dev))
> return;
Q: mlx5_virt_lag_is_supported() checks multi_uplink_eswitch, lag_master and
num_lag_ports < 2, but it does not exclude PFs with mlx5_core_is_pf(). Can
a PF with these caps also get here? Such a PF would keep the plain PF
devcom key and get an ldev with virt_lag = true. Should this gate exclude
PFs as well?
[SD] No PF has these caps. FW exposes multi_uplink_eswitch together with
lag_master and num_lag_ports < 2 only on the VF/SF that acts as a nested
eswitch manager, so mlx5_virt_lag_is_supported() is a pure capability
check on purpose, with no is_vf()/is_sf() in it. The !mlx5_core_is_pf()
tests in eswitch_offloads.c select an id layout for non-PF eswitches;
they don't mean a PF can be virt-capable.
> + err = xa_alloc(&ldev->fns, &idx, fn, XA_LIMIT(0, U8_MAX - 1),
> + GFP_KERNEL);
Q: mlx5_virt_lag_is_supported() has no limit on the number of members.
Once 255 fns exist, the next xa_alloc() returns -EBUSY, and
mlx5_lag_add_mdev() only bails out on -EOPNOTSUPP. Can the 256th
function keep retrying inside mlx5_load() forever?
[SD] The retry loop is pre-existing: mlx5_lag_add_mdev() retried every
error before this series as well, and no HW exposes this yet; -EBUSY can
only be returned by future HW. The fix will be sent to net as a separate
patch.
Q: mlx5_ib_modify_dct() picks the DCT port with get_tx_affinity_rr()
whenever mlx5_lag_is_active(), bypassing
mlx5_ib_lag_should_assign_affinity(). If mlx5_eth_lag_init() left
lag_active unset, e.g. without a LAG flow namespace, the divisor is
num_lag_ports, which is 0 on such a function. Can this divide by zero?
[SD] This is theoretical only; there is no such setup.
Q: end_flow_index is inclusive, so the master egress group spans
max_fns + 1 entries in a table created with max_fte = max_fns. With
max_fns == 128 the table is exactly 128 entries. Can the group creation
fail?
[SD] This is theoretical only; there is no such use case.
Shay Drory (5):
net/mlx5: E-switch, add match-metadata allocator for nested VF/SF
eswitches
net/mlx5: E-switch, match master egress rule by vport metadata
net/mlx5: E-switch, drop master egress rule under a SW vport LAG
net/mlx5e: Register eswitch-manager VF/SF self-port with switch-id
net/mlx5: LAG, enable LAG over functions that do not represent a
physical port
drivers/infiniband/hw/mlx5/mlx5_ib.h | 3 +
.../ethernet/mellanox/mlx5/core/en/devlink.c | 5 +
.../net/ethernet/mellanox/mlx5/core/eswitch.h | 3 +-
.../mellanox/mlx5/core/eswitch_offloads.c | 150 +++++++++++++++---
.../net/ethernet/mellanox/mlx5/core/lag/lag.c | 49 ++++--
.../ethernet/mellanox/mlx5/core/lag/mpesw.c | 4 +-
.../mellanox/mlx5/core/lag/shared_fdb.c | 6 +-
.../ethernet/mellanox/mlx5/core/mlx5_core.h | 1 +
include/linux/mlx5/eswitch.h | 4 +
9 files changed, 185 insertions(+), 40 deletions(-)
base-commit: 2208ab00f4f213ade91ab775e7f8c4dacdcc856e
--
2.44.0
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH net-next V2 1/5] net/mlx5: E-switch, add match-metadata allocator for nested VF/SF eswitches
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 ` 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 2/5] net/mlx5: E-switch, match master egress rule by vport metadata Tariq Toukan
` (4 subsequent siblings)
5 siblings, 2 replies; 17+ messages in thread
From: Tariq Toukan @ 2026-11-20 7:59 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
netdev, Paolo Abeni
Cc: Akiva Goldberger, Gal Pressman, Jason Gunthorpe, Leon Romanovsky,
linux-rdma, Mark Bloch, Moshe Shemesh, Or Har-Toov,
Saeed Mahameed, Shay Drory, Tariq Toukan
From: Shay Drory <shayd@nvidia.com>
The eswitch source-port match metadata is laid out as 4 bits of PFNUM
and 12 bits of a unique id (ESW_SOURCE_PORT_METADATA_BITS). PFNUM is the
native_port_num reported in HCA_CAP, so all VFs/SFs of the same PF share
a single PFNUM. Each VF/SF eswitch allocates its id from its own
vport_metadata_ida, restarting from the lowest value, so two VFs/SFs of
the same PF can end up with identical metadata. Once their eswitches
share an FDB (virt LAG), that metadata no longer uniquely identifies the
source port.
Add a dedicated allocator for nested (virt LAG) eswitches that replaces
the PFNUM field with the VF/SF's slot in the LAG (its xarray index in
ldev->fns). That index is unique per function within the LAG, so
combined with a per-VF/SF id it yields unique metadata regardless of
which PF the VFs/SFs belong to. The split is 8 bits for the virt LAG
index - which fits the U8_MAX cap on the LAG xarray - and the remaining
8 bits for the id; the two still sum to ESW_SOURCE_PORT_METADATA_BITS,
so nothing downstream of the match changes. Describe the nested layout
next to the reg_c_0 layout in include/linux/mlx5/eswitch.h.
The PFNUM value 0xf is reserved for internal port offload, which stamps
it into reg_c_0 and matches it with the same mask used for vport
metadata. That offload is gated on switchdev mode only, so it can be
used on a nested eswitch as well. Cap the LAG index accordingly.
Select the nested layout for a non-PF eswitch, unless it is virt LAG
capable but not a LAG member, e.g. one refused as a late joiner and left
standalone. Such a device keeps the PFNUM layout: it does not pair with
the eswitches of the LAG members, so its metadata is never compared
against theirs. PFs, which never report the virt LAG capabilities, keep
the PFNUM layout.
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
.../mellanox/mlx5/core/eswitch_offloads.c | 48 +++++++++++++++++++
.../net/ethernet/mellanox/mlx5/core/lag/lag.c | 17 +++++++
.../ethernet/mellanox/mlx5/core/mlx5_core.h | 1 +
include/linux/mlx5/eswitch.h | 4 ++
4 files changed, 70 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 1323114ce7f9..3c1355f91090 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -3650,6 +3650,48 @@ static u32 mlx5_esw_match_metadata_reserved(struct mlx5_eswitch *esw)
return MLX5_ESW_METADATA_RSVD_UPLINK;
}
+/* Nested (virt LAG) source-port metadata layout: the upper ESW_NESTED_IDX_BITS
+ * hold the VF/SF's slot in the LAG and the lower ESW_NESTED_VPORT_BITS hold a
+ * vport id unique within its eswitch. The two fields still sum to
+ * ESW_SOURCE_PORT_METADATA_BITS. The LAG slot (0-254, per the xa_alloc() limit
+ * in mlx5_ldev_add_mdev()) fits in ESW_NESTED_IDX_BITS; slots 0xf0 and up would
+ * drive the PFNUM bits to the 0xf reserved by internal port offload, so only
+ * 0-239 are used.
+ */
+#define ESW_NESTED_VPORT_BITS 8
+#define ESW_NESTED_IDX_BITS (ESW_SOURCE_PORT_METADATA_BITS - ESW_NESTED_VPORT_BITS)
+
+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;
+
+ /* 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;
+ id = (idx << ESW_NESTED_VPORT_BITS) | id;
+ return id;
+}
+
+static void mlx5_nested_esw_match_metadata_free(struct mlx5_eswitch *esw,
+ u32 metadata)
+{
+ u32 vport_bit_mask = (1 << ESW_NESTED_VPORT_BITS) - 1;
+
+ /* Metadata holds only ESW_NESTED_VPORT_BITS of actual ida id. */
+ ida_free(&esw->offloads.vport_metadata_ida, metadata & vport_bit_mask);
+}
+
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);
+
/* Only 4 bits of pf_num */
pf_num = mlx5_sd_pf_num_get(esw->dev);
if (pf_num < 0 || pf_num > max_pf_num)
@@ -3678,6 +3723,9 @@ void mlx5_esw_match_metadata_free(struct mlx5_eswitch *esw, u32 metadata)
{
u32 vport_bit_mask = (1 << ESW_VPORT_BITS) - 1;
+ if (!mlx5_core_is_pf(esw->dev) && !mlx5_virt_lag_nonmember(esw->dev))
+ return mlx5_nested_esw_match_metadata_free(esw, metadata);
+
/* Metadata contains only 12 bits of actual ida id */
ida_free(&esw->offloads.vport_metadata_ida, metadata & vport_bit_mask);
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
index abcab76fced0..193fbe47fef1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
@@ -516,6 +516,23 @@ int mlx5_lag_get_dev_seq(struct mlx5_core_dev *dev)
}
EXPORT_SYMBOL(mlx5_lag_get_dev_seq);
+int mlx5_lag_get_member_idx(struct mlx5_core_dev *dev)
+{
+ struct mlx5_lag *ldev = mlx5_lag_dev(dev);
+ struct lag_fn *fn;
+ int idx;
+
+ if (!ldev)
+ return -ENOENT;
+
+ xa_lock(&ldev->fns);
+ fn = mlx5_lag_fn_by_dev(ldev, dev);
+ idx = fn ? fn->idx : -ENOENT;
+ xa_unlock(&ldev->fns);
+
+ return idx;
+}
+
/* seq 0 = master, then all remaining devices */
static int mlx5_lag_get_dev_index_by_seq_all(struct mlx5_lag *ldev, int seq)
{
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
index d84d0424d04e..f5f105762d88 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
@@ -275,6 +275,7 @@ void mlx5_lag_add_mdev(struct mlx5_core_dev *dev);
void mlx5_lag_remove_mdev(struct mlx5_core_dev *dev);
void mlx5_lag_disable_change(struct mlx5_core_dev *dev);
void mlx5_lag_enable_change(struct mlx5_core_dev *dev);
+int mlx5_lag_get_member_idx(struct mlx5_core_dev *dev);
int mlx5_events_init(struct mlx5_core_dev *dev);
void mlx5_events_cleanup(struct mlx5_core_dev *dev);
diff --git a/include/linux/mlx5/eswitch.h b/include/linux/mlx5/eswitch.h
index 03d3620141c8..06d7d634de0d 100644
--- a/include/linux/mlx5/eswitch.h
+++ b/include/linux/mlx5/eswitch.h
@@ -95,6 +95,10 @@ bool mlx5_eswitch_vport_match_metadata_enabled(const struct mlx5_eswitch *esw);
* unique non-zero vport id (range 1-4095). The rest (lowest 16 bits) is left
* for user data objects managed by a common mapping context.
* PFNUM + VPORT comprise the SOURCE_PORT matching.
+ *
+ * A nested (virt LAG) VF/SF eswitch splits the SOURCE_PORT bits differently:
+ * the highest 8 bits are its slot in the LAG (range 0-239) and the next 8
+ * bits are a unique non-zero vport id (range 2-255).
*/
#define ESW_VPORT_BITS 12
#define ESW_PFNUM_BITS 4
--
2.44.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH net-next V2 2/5] net/mlx5: E-switch, match master egress rule by vport metadata
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-20 7:59 ` 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
` (3 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: Tariq Toukan @ 2026-11-20 7:59 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
netdev, Paolo Abeni
Cc: Akiva Goldberger, Gal Pressman, Jason Gunthorpe, Leon Romanovsky,
linux-rdma, Mark Bloch, Moshe Shemesh, Or Har-Toov,
Saeed Mahameed, Shay Drory, Tariq Toukan
From: Shay Drory <shayd@nvidia.com>
The master egress-ACL bounce group and rule matched the slave uplink by
source_port + source_eswitch_owner_vhca_id. Virt LAG master cannot match
that way; it must match by vport metadata (reg_c_0).
Virt LAG only supports MPESW, where every uplink has a unique metadata.
Hence, use metadata matching when LAG is virt LAG, and keep the
source_port + source_eswitch_owner_vhca_id match otherwise.
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Akiva Goldberger <agoldberger@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
.../mellanox/mlx5/core/eswitch_offloads.c | 78 +++++++++++++------
1 file changed, 55 insertions(+), 23 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 3c1355f91090..57f58e79478e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -2999,6 +2999,26 @@ static int esw_set_slave_root_fdb(struct mlx5_core_dev *master,
return err;
}
+static void mlx5_esw_set_spec_source_port_vhca(struct mlx5_flow_spec *spec,
+ u16 vport, u16 vhca_id)
+{
+ void *misc;
+
+ spec->match_criteria_enable = MLX5_MATCH_MISC_PARAMETERS;
+
+ misc = MLX5_ADDR_OF(fte_match_param, spec->match_value,
+ misc_parameters);
+ MLX5_SET(fte_match_set_misc, misc, source_port, vport);
+ MLX5_SET(fte_match_set_misc, misc, source_eswitch_owner_vhca_id,
+ vhca_id);
+
+ misc = MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
+ misc_parameters);
+ MLX5_SET_TO_ONES(fte_match_set_misc, misc, source_port);
+ MLX5_SET_TO_ONES(fte_match_set_misc, misc,
+ source_eswitch_owner_vhca_id);
+}
+
static int __esw_set_master_egress_rule(struct mlx5_core_dev *master,
struct mlx5_core_dev *slave,
struct mlx5_vport *vport,
@@ -3010,22 +3030,22 @@ static int __esw_set_master_egress_rule(struct mlx5_core_dev *master,
struct mlx5_flow_act flow_act = {};
struct mlx5_flow_spec *spec;
int err = 0;
- void *misc;
+
+ if (mlx5_virt_lag_is_supported(master) &&
+ !mlx5_eswitch_vport_match_metadata_enabled(slave->priv.eswitch))
+ return -EINVAL;
spec = kvzalloc_obj(*spec);
if (!spec)
return -ENOMEM;
- spec->match_criteria_enable = MLX5_MATCH_MISC_PARAMETERS;
- misc = MLX5_ADDR_OF(fte_match_param, spec->match_value,
- misc_parameters);
- MLX5_SET(fte_match_set_misc, misc, source_port, MLX5_VPORT_UPLINK);
- MLX5_SET(fte_match_set_misc, misc, source_eswitch_owner_vhca_id, slave_index);
-
- misc = MLX5_ADDR_OF(fte_match_param, spec->match_criteria, misc_parameters);
- MLX5_SET_TO_ONES(fte_match_set_misc, misc, source_port);
- MLX5_SET_TO_ONES(fte_match_set_misc, misc,
- source_eswitch_owner_vhca_id);
+ if (mlx5_virt_lag_is_supported(master) &&
+ mlx5_eswitch_vport_match_metadata_enabled(slave->priv.eswitch))
+ mlx5_esw_set_spec_source_port(slave->priv.eswitch,
+ MLX5_VPORT_UPLINK, spec);
+ else
+ mlx5_esw_set_spec_source_port_vhca(spec, MLX5_VPORT_UPLINK,
+ slave_index);
flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
dest.type = MLX5_FLOW_DESTINATION_TYPE_VPORT;
@@ -3178,6 +3198,21 @@ static void esw_unset_slave_egress_rule(struct mlx5_core_dev *master,
esw_slave_egress_destroy_resources(slave_vport);
}
+static void mlx5_esw_set_flow_group_source_port_vhca(u32 *flow_group_in)
+{
+ void *match_criteria = MLX5_ADDR_OF(create_flow_group_in,
+ flow_group_in, match_criteria);
+
+ MLX5_SET_TO_ONES(fte_match_param, match_criteria,
+ misc_parameters.source_port);
+ MLX5_SET_TO_ONES(fte_match_param, match_criteria,
+ misc_parameters.source_eswitch_owner_vhca_id);
+ MLX5_SET(create_flow_group_in, flow_group_in,
+ match_criteria_enable, MLX5_MATCH_MISC_PARAMETERS);
+ MLX5_SET(create_flow_group_in, flow_group_in,
+ source_eswitch_owner_vhca_id_valid, 1);
+}
+
static int esw_master_egress_create_resources(struct mlx5_eswitch *esw,
struct mlx5_flow_namespace *egress_ns,
struct mlx5_vport *vport, size_t count)
@@ -3188,13 +3223,16 @@ static int esw_master_egress_create_resources(struct mlx5_eswitch *esw,
};
struct mlx5_flow_table *acl;
struct mlx5_flow_group *g;
- void *match_criteria;
u32 *flow_group_in;
int err;
if (vport->egress.acl)
return 0;
+ if (mlx5_virt_lag_is_supported(esw->dev) &&
+ !mlx5_eswitch_vport_match_metadata_enabled(esw))
+ return -EINVAL;
+
flow_group_in = kvzalloc(inlen, GFP_KERNEL);
if (!flow_group_in)
return -ENOMEM;
@@ -3208,17 +3246,11 @@ static int esw_master_egress_create_resources(struct mlx5_eswitch *esw,
goto out;
}
- match_criteria = MLX5_ADDR_OF(create_flow_group_in, flow_group_in,
- match_criteria);
- MLX5_SET_TO_ONES(fte_match_param, match_criteria,
- misc_parameters.source_port);
- MLX5_SET_TO_ONES(fte_match_param, match_criteria,
- misc_parameters.source_eswitch_owner_vhca_id);
- MLX5_SET(create_flow_group_in, flow_group_in, match_criteria_enable,
- MLX5_MATCH_MISC_PARAMETERS);
-
- MLX5_SET(create_flow_group_in, flow_group_in,
- source_eswitch_owner_vhca_id_valid, 1);
+ if (mlx5_virt_lag_is_supported(esw->dev) &&
+ mlx5_eswitch_vport_match_metadata_enabled(esw))
+ mlx5_esw_set_flow_group_source_port(esw, flow_group_in, 0);
+ else
+ mlx5_esw_set_flow_group_source_port_vhca(flow_group_in);
MLX5_SET(create_flow_group_in, flow_group_in, start_flow_index, 0);
MLX5_SET(create_flow_group_in, flow_group_in, end_flow_index, count);
--
2.44.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH net-next V2 3/5] net/mlx5: E-switch, drop master egress rule under a SW vport LAG
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-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 ` Tariq Toukan
2026-11-24 8:32 ` netdev-bot+sashiko
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
` (2 subsequent siblings)
5 siblings, 1 reply; 17+ messages in thread
From: Tariq Toukan @ 2026-11-20 7:59 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
netdev, Paolo Abeni
Cc: Akiva Goldberger, Gal Pressman, Jason Gunthorpe, Leon Romanovsky,
linux-rdma, Mark Bloch, Moshe Shemesh, Or Har-Toov,
Saeed Mahameed, Shay Drory, Tariq Toukan
From: Shay Drory <shayd@nvidia.com>
VPORT_LAG steers all traffic of a LAG slave to the LAG master. The
eswitch master egress rule does the opposite direction: it bounces
traffic that reached the master's manager vport into the slave eswitch.
With a FW vport LAG the FW steers that bounced packet to the LAG master,
so the two coexist.
The software vport LAG emulation cannot. It is a catch-all rule in the
slave eswitch's egress ACL that forwards to the master's manager vport,
while the master egress rule redirects the packet after the FDB - past
the point where the slave egress rule is evaluated - so the bounced
packet never reaches it.
The two therefore cannot coexist: drop the master egress rule when the
software vport LAG is installed, and restore it when it is removed. Both
rules are keyed by the peer vhca_id, so each slave swaps its own pair
independently. Restoring needs the ACL size, so pass ldev->max_fns down
to mlx5_eswitch_offloads_vport_lag_del_one(), as the single FDB path
already does.
Also, release the MPESW metadata after the shared FDB is destroyed,
mirroring the creation order. Releasing it first makes all slaves fall
back to the same default uplink metadata, so the restored master egress
rules collide.
Note that vport LAG on its own only gets traffic to the LAG master; the
distribution to the other slaves esw managers, which was managed by
master egress rules, is done by the LAG demux.
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/eswitch.h | 3 ++-
.../mellanox/mlx5/core/eswitch_offloads.c | 24 +++++++++++++++++--
.../ethernet/mellanox/mlx5/core/lag/mpesw.c | 2 +-
.../mellanox/mlx5/core/lag/shared_fdb.c | 6 +++--
4 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index 48eb6acc1e87..bcf053b0a38d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -958,7 +958,8 @@ bool mlx5_esw_offloads_controller_valid(const struct mlx5_eswitch *esw, u32 cont
int mlx5_eswitch_offloads_vport_lag_add_one(struct mlx5_eswitch *master_esw,
struct mlx5_eswitch *slave_esw);
void mlx5_eswitch_offloads_vport_lag_del_one(struct mlx5_eswitch *master_esw,
- struct mlx5_eswitch *slave_esw);
+ struct mlx5_eswitch *slave_esw,
+ int max_slaves);
int mlx5_eswitch_offloads_single_fdb_add_one(struct mlx5_eswitch *master_esw,
struct mlx5_eswitch *slave_esw, int max_slaves);
void mlx5_eswitch_offloads_single_fdb_del_one(struct mlx5_eswitch *master_esw,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
index 57f58e79478e..2072921c1fff 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -3380,12 +3380,32 @@ void mlx5_eswitch_offloads_single_fdb_del_one(struct mlx5_eswitch *master_esw,
int mlx5_eswitch_offloads_vport_lag_add_one(struct mlx5_eswitch *master_esw,
struct mlx5_eswitch *slave_esw)
{
- return esw_set_slave_egress_rule(master_esw->dev, slave_esw->dev);
+ int err;
+
+ err = esw_set_slave_egress_rule(master_esw->dev, slave_esw->dev);
+ if (err)
+ return err;
+
+ esw_unset_master_egress_rule(master_esw->dev, slave_esw->dev);
+
+ return 0;
}
void mlx5_eswitch_offloads_vport_lag_del_one(struct mlx5_eswitch *master_esw,
- struct mlx5_eswitch *slave_esw)
+ struct mlx5_eswitch *slave_esw,
+ int max_slaves)
{
+ int err;
+
+ if (mlx5_sd_is_primary(slave_esw->dev)) {
+ err = esw_set_master_egress_rule(master_esw->dev,
+ slave_esw->dev, max_slaves);
+ if (err)
+ esw_warn(master_esw->dev,
+ "Failed to restore master egress rule (%d)\n",
+ err);
+ }
+
esw_unset_slave_egress_rule(master_esw->dev, slave_esw->dev);
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c
index 8a867a04916a..2d3e61541d8a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c
@@ -208,10 +208,10 @@ void mlx5_lag_disable_mpesw(struct mlx5_lag *ldev)
if (ldev->mode != MLX5_LAG_MODE_MPESW)
return;
- mlx5_mpesw_metadata_cleanup(ldev);
mlx5_lag_shared_fdb_destroy(ldev, MLX5_LAG_FILTER_ALL);
if (mlx5_lag_has_sd_group(ldev))
mlx5_mpesw_restore_sd_fdb(ldev);
+ mlx5_mpesw_metadata_cleanup(ldev);
/* Pair with the master mark taken at MPESW create for VFs. */
if (ldev->virt_lag)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/shared_fdb.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/shared_fdb.c
index 404278a15ef7..90209e4b99f7 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/shared_fdb.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/shared_fdb.c
@@ -126,7 +126,8 @@ int mlx5_lag_create_vport_lag(struct mlx5_lag *ldev, u32 group_id)
if (j == master_idx)
continue;
slave_esw = mlx5_lag_fn(ldev, j)->dev->priv.eswitch;
- mlx5_eswitch_offloads_vport_lag_del_one(master_esw, slave_esw);
+ mlx5_eswitch_offloads_vport_lag_del_one(master_esw, slave_esw,
+ ldev->max_fns);
}
return err;
}
@@ -153,7 +154,8 @@ int mlx5_lag_destroy_vport_lag(struct mlx5_lag *ldev, u32 group_id)
continue;
dev = mlx5_lag_fn(ldev, i)->dev;
mlx5_eswitch_offloads_vport_lag_del_one(master_esw,
- dev->priv.eswitch);
+ dev->priv.eswitch,
+ ldev->max_fns);
}
return 0;
}
--
2.44.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH net-next V2 4/5] net/mlx5e: Register eswitch-manager VF/SF self-port with switch-id
2026-11-20 7:59 [PATCH net-next V2 0/5] net/mlx5: LAG over VFs/SFs (virtual LAG) Tariq Toukan
` (2 preceding siblings ...)
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-20 7:59 ` 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 ` [PATCH net-next V2 0/5] net/mlx5: LAG over VFs/SFs (virtual LAG) sashiko-bot
5 siblings, 2 replies; 17+ messages in thread
From: Tariq Toukan @ 2026-11-20 7:59 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
netdev, Paolo Abeni
Cc: Akiva Goldberger, Gal Pressman, Jason Gunthorpe, Leon Romanovsky,
linux-rdma, Mark Bloch, Moshe Shemesh, Or Har-Toov,
Saeed Mahameed, Shay Drory, Tariq Toukan
From: Shay Drory <shayd@nvidia.com>
A non-PF function's self-port (its own uplink netdev) was always
registered with DEVLINK_PORT_FLAVOUR_VIRTUAL, which doesn't carries
switch_id. Consequently a function that acts as an eswitch manager - a
VF (or SF) running its own nested eswitch - exposed no phys_switch_id on
its uplink netdev, so it could not be grouped with the representors it
manages.
When the function is an eswitch manager, register its self-port with the
switch_id taken from the system image guid. The uplink netdev is already
bound to this devlink port, so phys_switch_id is derived by the core,
and the managed representors - which stamp the same switch_id - group
with it.
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c
index 8818f65d1fbc..79adb1ecc450 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c
@@ -63,6 +63,11 @@ int mlx5e_devlink_port_register(struct mlx5e_dev *mlx5e_dev,
dl_port_index = mlx5_esw_vport_to_devlink_port_index(mdev,
MLX5_VPORT_UPLINK);
} else {
+ if (MLX5_ESWITCH_MANAGER(mdev)) {
+ mlx5e_devlink_get_port_parent_id(mdev, &ppid);
+ memcpy(attrs.switch_id.id, ppid.id, ppid.id_len);
+ attrs.switch_id.id_len = ppid.id_len;
+ }
attrs.flavour = DEVLINK_PORT_FLAVOUR_VIRTUAL;
dl_port_index = mlx5_esw_vport_to_devlink_port_index(mdev, 0);
}
--
2.44.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH net-next V2 5/5] net/mlx5: LAG, enable LAG over functions that do not represent a physical port
2026-11-20 7:59 [PATCH net-next V2 0/5] net/mlx5: LAG over VFs/SFs (virtual LAG) Tariq Toukan
` (3 preceding siblings ...)
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-20 7:59 ` Tariq Toukan
2026-11-21 8:02 ` sashiko-bot
2026-11-24 8:32 ` netdev-bot+sashiko
2026-11-21 8:02 ` [PATCH net-next V2 0/5] net/mlx5: LAG over VFs/SFs (virtual LAG) sashiko-bot
5 siblings, 2 replies; 17+ messages in thread
From: Tariq Toukan @ 2026-11-20 7:59 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
netdev, Paolo Abeni
Cc: Akiva Goldberger, Gal Pressman, Jason Gunthorpe, Leon Romanovsky,
linux-rdma, Mark Bloch, Moshe Shemesh, Or Har-Toov,
Saeed Mahameed, Shay Drory, Tariq Toukan
From: Shay Drory <shayd@nvidia.com>
LAG membership assumes every member represents a physical port.
A nested LAG of VFs/SFs does not fit that assumption; its member
functions sit behind a multi_uplink_eswitch and each reports
num_lag_ports < 2, so they do not represent a physical port.
Detect this with mlx5_virt_lag_is_supported(): let such a function join
the LAG in mlx5_lag_add_mdev(), and skip the MLX5_LAG_XA_MARK_PORT mark
and the PORT_CHANGE event notifier in mlx5_ldev_add_mdev(), since it is
not a physical port.
These function only support MPESW, and netdevs addition to LAG is only
needed for linux bond. Hence, don't allow such a lag to add netdevs to
itself. For the same reason, don't register the LAG netdev notifier for
it. Multipath LAG is not supported either, so skip mlx5_lag_mp_init()
and do not register the FIB notifier for it.
Such a function may report num_lag_ports == 0, which ldev->ports keeps
as is. Report at least one port from mlx5_lag_get_num_ports(), so user
would avoid divide by 0.
Such a function selects the uplink through port_select_eswitch, not
through a TX port affinity. Yet once its LAG is active, RDMA sets
lag_active, and mlx5_ib_lag_should_assign_affinity() then assigns a TX
port affinity to every QP, bypassing the num_lag_ports > 1 and
lag_tx_port_affinity capability checks. Make
mlx5_ib_lag_should_assign_affinity() return false for such a function.
Signed-off-by: Shay Drory <shayd@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
drivers/infiniband/hw/mlx5/mlx5_ib.h | 3 ++
.../net/ethernet/mellanox/mlx5/core/lag/lag.c | 32 +++++++++++++------
.../ethernet/mellanox/mlx5/core/lag/mpesw.c | 2 +-
3 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index 4a6ee14ffd7d..494b7036321b 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -1612,6 +1612,9 @@ static inline void mlx5r_deref_wait_odp_mkey(struct mlx5_ib_mkey *mmkey)
static inline bool mlx5_ib_lag_should_assign_affinity(struct mlx5_ib_dev *dev)
{
+ if (dev->lag_active && mlx5_virt_lag_is_supported(dev->mdev))
+ return 0;
+
/*
* If the driver is in hash mode and the port_select_flow_table_bypass cap
* is supported, it means that the driver no longer needs to assign the port
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
index 193fbe47fef1..2cd2319f9318 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
@@ -366,6 +366,7 @@ static struct mlx5_lag *mlx5_lag_dev_alloc(struct mlx5_core_dev *dev)
ldev->ports = MLX5_CAP_GEN(dev, num_lag_ports);
ldev->buckets = 1;
+ ldev->virt_lag = mlx5_virt_lag_is_supported(dev);
ldev->v2p_map = kcalloc(ldev->ports * MLX5_LAG_MAX_HASH_BUCKETS,
sizeof(*ldev->v2p_map), GFP_KERNEL);
if (!ldev->v2p_map)
@@ -381,7 +382,7 @@ static struct mlx5_lag *mlx5_lag_dev_alloc(struct mlx5_core_dev *dev)
INIT_DELAYED_WORK(&ldev->bond_work, mlx5_do_bond_work);
INIT_WORK(&ldev->speed_update_work, mlx5_mpesw_speed_update_work);
- if (!mlx5_sd_is_supported(dev)) {
+ if (!mlx5_sd_is_supported(dev) && !ldev->virt_lag) {
ldev->nb.notifier_call = mlx5_lag_netdev_event;
write_pnet(&ldev->net, mlx5_core_net(dev));
if (register_netdevice_notifier_net(read_pnet(&ldev->net),
@@ -392,10 +393,13 @@ static struct mlx5_lag *mlx5_lag_dev_alloc(struct mlx5_core_dev *dev)
}
ldev->mode = MLX5_LAG_MODE_NONE;
- err = mlx5_lag_mp_init(ldev);
- if (err)
- mlx5_core_err(dev, "Failed to init multipath lag err=%d\n",
- err);
+ if (!ldev->virt_lag) {
+ err = mlx5_lag_mp_init(ldev);
+ if (err)
+ mlx5_core_err(dev,
+ "Failed to init multipath lag err=%d\n",
+ err);
+ }
ldev->max_fns = ldev->ports;
return ldev;
@@ -468,7 +472,9 @@ int mlx5_lag_get_dev_index_by_seq(struct mlx5_lag *ldev, int seq)
/* Return the appropriate iterator filter for a device in LAG:
* - SD shared FDB active: iterate only the device's SD group
* - SD group exists but shared FDB not active: iterate all devices
- * - No SD: iterate ports only
+ * - Virt LAG: iterate all devices, since its members are not marked as
+ * ports, as they do not represent a physical port
+ * - Otherwise: iterate ports only
*/
static u32 mlx5_lag_get_filter(struct mlx5_lag *ldev, struct mlx5_core_dev *dev)
{
@@ -476,7 +482,7 @@ static u32 mlx5_lag_get_filter(struct mlx5_lag *ldev, struct mlx5_core_dev *dev)
if (fn && fn->sd_fdb_active)
return fn->group_id;
- if (fn && fn->group_id)
+ if (fn && (fn->group_id || ldev->virt_lag))
return MLX5_LAG_FILTER_ALL;
return MLX5_LAG_FILTER_PORTS;
}
@@ -2398,7 +2404,7 @@ int mlx5_ldev_add_mdev(struct mlx5_lag *ldev,
fn->group_id = group_id;
dev->priv.lag = ldev;
- if (group_id)
+ if (group_id || ldev->virt_lag)
return 0;
xa_set_mark(&ldev->fns, idx, MLX5_LAG_XA_MARK_PORT);
@@ -2547,7 +2553,7 @@ void mlx5_lag_add_mdev(struct mlx5_core_dev *dev)
{
int err;
- if (!mlx5_lag_is_supported(dev))
+ if (!mlx5_lag_is_supported(dev) && !mlx5_virt_lag_is_supported(dev))
return;
if (mlx5_lag_register_hca_devcom_comp(dev))
@@ -2582,6 +2588,9 @@ void mlx5_lag_remove_netdev(struct mlx5_core_dev *dev,
if (!ldev)
return;
+ if (ldev->virt_lag)
+ return;
+
mutex_lock(&ldev->lock);
mlx5_ldev_remove_netdev(ldev, netdev);
clear_bit(MLX5_LAG_FLAG_NDEVS_READY, &ldev->state_flags);
@@ -2603,6 +2612,9 @@ void mlx5_lag_add_netdev(struct mlx5_core_dev *dev,
if (!ldev)
return;
+ if (ldev->virt_lag)
+ return;
+
mutex_lock(&ldev->lock);
mlx5_ldev_add_netdev(ldev, dev, netdev);
num = mlx5_lag_num_netdevs(ldev);
@@ -2886,7 +2898,7 @@ u8 mlx5_lag_get_num_ports(struct mlx5_core_dev *dev)
if (!ldev)
return 0;
- return ldev->ports;
+ return max_t(u8, ldev->ports, 1);
}
EXPORT_SYMBOL(mlx5_lag_get_num_ports);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c
index 2d3e61541d8a..0ef2d13d0096 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c
@@ -336,7 +336,7 @@ bool mlx5_lag_is_mpesw(struct mlx5_core_dev *dev)
struct mlx5_lag *ldev = mlx5_lag_dev(dev);
return ldev && ldev->mode == MLX5_LAG_MODE_MPESW &&
- __mlx5_lag_dev_is_port(ldev, dev);
+ (ldev->virt_lag || __mlx5_lag_dev_is_port(ldev, dev));
}
EXPORT_SYMBOL(mlx5_lag_is_mpesw);
--
2.44.0
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH net-next V2 1/5] net/mlx5: E-switch, add match-metadata allocator for nested VF/SF eswitches
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
1 sibling, 0 replies; 17+ messages in thread
From: sashiko-bot @ 2026-11-21 8:02 UTC (permalink / raw)
To: Tariq Toukan; +Cc: linux-rdma
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] net/mlx5: inverted virt-LAG check in
mlx5_esw_match_metadata_alloc()
--
commit a97c2078b8815e78906668a4a9a37e37bc914d39
Author: Shay Drory <shayd@nvidia.com>
net/mlx5: E-switch, add match-metadata allocator for nested VF/SF eswitches
This commit adds a match-metadata allocator for nested (virt LAG) VF/SF
eswitches that splits the source-port metadata into an 8-bit LAG slot
index and an 8-bit vport ID.
> 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
> @@ -3650,6 +3650,48 @@ static u32 mlx5_esw_match_metadata_reserved(struct mlx5_eswitch *esw)
> return MLX5_ESW_METADATA_RSVD_UPLINK;
> }
>
> +/* Nested (virt LAG) source-port metadata layout: the upper ESW_NESTED_IDX_BITS
> + * hold the VF/SF's slot in the LAG and the lower ESW_NESTED_VPORT_BITS hold a
> + * vport id unique within its eswitch. The two fields still sum to
> + * ESW_SOURCE_PORT_METADATA_BITS. The LAG slot (0-254, per the xa_alloc() limit
> + * in mlx5_ldev_add_mdev()) fits in ESW_NESTED_IDX_BITS; slots 0xf0 and up would
> + * drive the PFNUM bits to the 0xf reserved by internal port offload, so only
> + * 0-239 are used.
> + */
> +#define ESW_NESTED_VPORT_BITS 8
> +#define ESW_NESTED_IDX_BITS (ESW_SOURCE_PORT_METADATA_BITS - ESW_NESTED_VPORT_BITS)
> +
> +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;
> +
> + /* 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;
> + id = (idx << ESW_NESTED_VPORT_BITS) | id;
> + return id;
> +}
> +
> +static void mlx5_nested_esw_match_metadata_free(struct mlx5_eswitch *esw,
> + u32 metadata)
> +{
> + u32 vport_bit_mask = (1 << ESW_NESTED_VPORT_BITS) - 1;
> +
> + /* Metadata holds only ESW_NESTED_VPORT_BITS of actual ida id. */
> + ida_free(&esw->offloads.vport_metadata_ida, metadata & vport_bit_mask);
> +}
> +
> 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);
> +
> /* Only 4 bits of pf_num */
> pf_num = mlx5_sd_pf_num_get(esw->dev);
> if (pf_num < 0 || pf_num > max_pf_num)
> @@ -3678,6 +3723,9 @@ void mlx5_esw_match_metadata_free(struct mlx5_eswitch *esw, u32 metadata)
> {
> u32 vport_bit_mask = (1 << ESW_VPORT_BITS) - 1;
>
> + if (!mlx5_core_is_pf(esw->dev) && !mlx5_virt_lag_nonmember(esw->dev))
> + return mlx5_nested_esw_match_metadata_free(esw, metadata);
> +
> /* Metadata contains only 12 bits of actual ida id */
> ida_free(&esw->offloads.vport_metadata_ida, metadata & vport_bit_mask);
> }
[Severity: High]
As reported by Shay Drory on v1 [1], does negating
mlx5_virt_lag_nonmember(esw->dev) route non-PF eswitches that do not
support virt LAG into mlx5_nested_esw_match_metadata_alloc()?
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.h:mlx5_virt_lag_nonmember() {
return mlx5_virt_lag_is_supported(dev) && !mlx5_lag_dev(dev);
}
When mlx5_virt_lag_is_supported(esw->dev) is false on a standalone VF or
SF eswitch manager, mlx5_lag_dev(esw->dev) is NULL and
mlx5_virt_lag_nonmember(esw->dev) returns false. That dispatches
mlx5_esw_match_metadata_alloc() to mlx5_nested_esw_match_metadata_alloc(),
where mlx5_lag_get_member_idx(esw->dev) returns -ENOENT and metadata
allocation returns 0, causing esw_offloads_vport_metadata_setup() to fail
with -ENOSPC when enabling switchdev mode.
Should mlx5_esw_match_metadata_alloc() and mlx5_esw_match_metadata_free()
check mlx5_lag_dev(esw->dev) instead of !mlx5_virt_lag_nonmember(esw->dev)?
[1] https://lore.kernel.org/r/20261110093136.377962-1-shayd@nvidia.com
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120075959.2533702-1-tariqt@nvidia.com?part=1
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH net-next V2 4/5] net/mlx5e: Register eswitch-manager VF/SF self-port with switch-id
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
1 sibling, 0 replies; 17+ messages in thread
From: sashiko-bot @ 2026-11-21 8:02 UTC (permalink / raw)
To: Tariq Toukan; +Cc: linux-rdma
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] net/mlx5e: duplicated switch_id setup in
mlx5e_devlink_port_register()
--
commit a4fbc34804738e4b1300b56b57462bb3c5135774
Author: Shay Drory <shayd@nvidia.com>
net/mlx5e: Register eswitch-manager VF/SF self-port with switch-id
This commit populates attrs.switch_id from the system image GUID when
registering the self-port of a non-PF eswitch manager function.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c
> index 8818f65d1fbc4..79adb1ecc4506 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c
> @@ -63,6 +63,11 @@ int mlx5e_devlink_port_register(struct mlx5e_dev *mlx5e_dev,
> dl_port_index = mlx5_esw_vport_to_devlink_port_index(mdev,
> MLX5_VPORT_UPLINK);
> } else {
> + if (MLX5_ESWITCH_MANAGER(mdev)) {
> + mlx5e_devlink_get_port_parent_id(mdev, &ppid);
> + memcpy(attrs.switch_id.id, ppid.id, ppid.id_len);
> + attrs.switch_id.id_len = ppid.id_len;
> + }
> attrs.flavour = DEVLINK_PORT_FLAVOUR_VIRTUAL;
> dl_port_index = mlx5_esw_vport_to_devlink_port_index(mdev, 0);
> }
[Severity: Low]
This isn't a bug, but the mlx5_core_is_pf(mdev) branch right above already
contains this exact if (MLX5_ESWITCH_MANAGER(mdev)) block to populate
attrs.switch_id. Could it be moved outside the if/else to avoid duplicating
it in both branches?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120075959.2533702-1-tariqt@nvidia.com?part=4
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH net-next V2 5/5] net/mlx5: LAG, enable LAG over functions that do not represent a physical port
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
1 sibling, 0 replies; 17+ messages in thread
From: sashiko-bot @ 2026-11-21 8:02 UTC (permalink / raw)
To: Tariq Toukan; +Cc: linux-rdma
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net/mlx5: LAG, empty debugfs member list in members_show()
for virt_lag
--
commit 7460886c7aaf474929cb486d03267be648beb73f
Author: Shay Drory <shayd@nvidia.com>
net/mlx5: LAG, enable LAG over functions that do not represent a physical port
This commit enables LAG over virtual functions (such as VFs or SFs) that
sit behind a multi-uplink e-switch and do not represent a physical port.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
> index 193fbe47fef15..2cd2319f93189 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
[ ... ]
> @@ -2398,7 +2404,7 @@ int mlx5_ldev_add_mdev(struct mlx5_lag *ldev,
> fn->group_id = group_id;
> dev->priv.lag = ldev;
>
> - if (group_id)
> + if (group_id || ldev->virt_lag)
> return 0;
>
> xa_set_mark(&ldev->fns, idx, MLX5_LAG_XA_MARK_PORT);
[Severity: Medium]
Does skipping MLX5_LAG_XA_MARK_PORT here leave the lag/members debugfs
file empty for virt_lag devices?
mlx5_lag_add_mdev() calls mlx5_ldev_add_debugfs(), which registers the
members file backed by members_show():
drivers/net/ethernet/mellanox/mlx5/core/lag/debugfs.c:members_show() {
...
mutex_lock(&ldev->lock);
mlx5_ldev_for_each(i, 0, ldev)
seq_printf(file, "%s\n",
dev_name(mlx5_lag_fn(ldev, i)->dev->device));
mutex_unlock(&ldev->lock);
...
}
Because mlx5_ldev_for_each() iterates with MLX5_LAG_FILTER_PORTS, which
only visits entries in ldev->fns marked with MLX5_LAG_XA_MARK_PORT,
reading lag/members on a virt_lag device will print nothing.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120075959.2533702-1-tariqt@nvidia.com?part=5
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH net-next V2 0/5] net/mlx5: LAG over VFs/SFs (virtual LAG)
2026-11-20 7:59 [PATCH net-next V2 0/5] net/mlx5: LAG over VFs/SFs (virtual LAG) Tariq Toukan
` (4 preceding siblings ...)
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
5 siblings, 0 replies; 17+ messages in thread
From: sashiko-bot @ 2026-11-21 8:02 UTC (permalink / raw)
To: Tariq Toukan; +Cc: linux-rdma
Sashiko has finished reviewing this 5-patch series:
- Patches 2 and 3: no issues found.
- Patch 1 ("net/mlx5: E-switch, add match-metadata allocator for..."): 1
potential issue (1 High)
- Patch 4 ("net/mlx5e: Register eswitch-manager VF/SF self-port..."): 1
potential issue (1 Low)
- Patch 5 ("net/mlx5: LAG, enable LAG over functions that do not..."): 1
potential issue (1 Medium)
Detailed reviews have been sent as separate replies to patches 1, 4, and
5.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120075959.2533702-1-tariqt@nvidia.com
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH net-next V2 1/5] net/mlx5: E-switch, add match-metadata allocator for nested VF/SF eswitches
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
1 sibling, 1 reply; 17+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 8:32 UTC (permalink / raw)
To: tariqt
Cc: andrew+netdev, davem, edumazet, kuba, netdev, pabeni, agoldberger,
gal, jgg, leon, linux-rdma, mbloch, moshe, ohartoov, saeedm,
shayd
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.
> +
> + /* 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.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120075959.2533702-1-tariqt%40nvidia.com
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH net-next V2 3/5] net/mlx5: E-switch, drop master egress rule under a SW vport LAG
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
0 siblings, 1 reply; 17+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 8:32 UTC (permalink / raw)
To: tariqt
Cc: andrew+netdev, davem, edumazet, kuba, netdev, pabeni, agoldberger,
gal, jgg, leon, linux-rdma, mbloch, moshe, ohartoov, saeedm,
shayd
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · 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] mlx5_eswitch_offloads_vport_lag_del_one() calls
esw_set_master_egress_rule() for every slave that passes…
- [Low] The commit message describes the conflict as a general property
of the software vport LAG: the master egress rule redirects the…
--
net/mlx5: E-switch, drop master egress rule under a SW vport LAG
This commit removes a slave's eswitch master egress rule when the
software vport LAG slave egress rule is installed. It restores the rule
when the vport LAG is removed. It also moves the MPESW metadata cleanup
in mlx5_lag_disable_mpesw() to after the shared FDB is destroyed.
> The software vport LAG emulation cannot. It is a catch-all rule in the
> slave eswitch's egress ACL that forwards to the master's manager vport,
> while the master egress rule redirects the packet after the FDB - past
> the point where the slave egress rule is evaluated - so the bounced
> packet never reaches it.
>
> The two therefore cannot coexist: drop the master egress rule when the
> software vport LAG is installed, and restore it when it is removed.
[Severity: Low]
Is this conflict already present in shipped kernels for MPESW over SD
groups?
Before this patch, MPESW over SD appears to install both rules for the
other SD primary:
mlx5_lag_enable_mpesw()
mlx5_mpesw_teardown_sd_fdb() /* clears fn->sd_fdb_active */
mlx5_lag_shared_fdb_create(FILTER_ALL)
mlx5_activate_lag()
mlx5_create_lag()
mlx5_lag_create_single_fdb()
mlx5_eswitch_offloads_single_fdb_add_one()
/* master egress rule for each SD-primary slave */
Then mlx5_ib loads on the master:
mlx5_eth_lag_init()
mlx5_cmd_create_vport_lag() /* sw path, group_id != 0 */
mlx5_lag_create_vport_lag() /* FILTER_ALL */
mlx5_eswitch_offloads_vport_lag_add_one()
esw_set_slave_egress_rule() /* only this, pre-patch */
Following the commit message's own reasoning, that pair of rules
misdelivers traffic.
The software vport LAG came from 98d56915eef5 ("net/mlx5: LAG, introduce
software vport LAG implementation"). MPESW over SD came from
de464720489c ("net/mlx5: LAG, add MPESW over SD LAG support").
Could the commit message say that the existing MPESW over SD
configuration is affected, and add the matching Fixes: tag?
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> index 57f58e79478e4..2072921c1fffa 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
> @@ -3380,12 +3380,32 @@ void mlx5_eswitch_offloads_single_fdb_del_one(struct mlx5_eswitch *master_esw,
> int mlx5_eswitch_offloads_vport_lag_add_one(struct mlx5_eswitch *master_esw,
> struct mlx5_eswitch *slave_esw)
> {
> - return esw_set_slave_egress_rule(master_esw->dev, slave_esw->dev);
> + int err;
> +
> + err = esw_set_slave_egress_rule(master_esw->dev, slave_esw->dev);
> + if (err)
> + return err;
> +
> + esw_unset_master_egress_rule(master_esw->dev, slave_esw->dev);
> +
> + return 0;
> }
>
> void mlx5_eswitch_offloads_vport_lag_del_one(struct mlx5_eswitch *master_esw,
> - struct mlx5_eswitch *slave_esw)
> + struct mlx5_eswitch *slave_esw,
> + int max_slaves)
> {
> + int err;
> +
> + if (mlx5_sd_is_primary(slave_esw->dev)) {
> + err = esw_set_master_egress_rule(master_esw->dev,
> + slave_esw->dev, max_slaves);
[Severity: Medium]
Is this restore correct when no master egress rule existed before
mlx5_eswitch_offloads_vport_lag_add_one() ran?
On the add side, esw_unset_master_egress_rule() returns early when
vport->egress.acl is NULL and does not record whether it removed
anything. Here the rule is recreated for any SD-primary slave. The two
sides only match when a shared FDB installed the rule beforehand.
mlx5_eth_lag_init() creates the vport LAG whenever mlx5_lag_is_active()
and mlx5_lag_is_sw_managed() are true. Neither checks the shared FDB
state. With an active LAG that has no MLX5_LAG_MODE_FLAG_SHARED_FDB
(ROCE, or SRIOV with shared_fdb false), the sequence would be:
mlx5_do_bond() /* no shared FDB */
mlx5_eth_lag_init()
mlx5_cmd_create_vport_lag()
mlx5_eswitch_offloads_vport_lag_add_one()
esw_unset_master_egress_rule() /* no-op, egress.acl NULL */
mlx5_eth_lag_cleanup()
mlx5_cmd_destroy_vport_lag()
mlx5_eswitch_offloads_vport_lag_del_one()
esw_set_master_egress_rule() /* new ACL, group, bounce rule */
Does this leak the egress ACL table, flow group and bounce rule on the
master's manager vport? mlx5_deactivate_lag() only tears down master
egress state for a shared FDB:
if (test_bit(MLX5_LAG_MODE_FLAG_SHARED_FDB, &flags)) {
mlx5_lag_destroy_single_fdb(ldev);
The leftover bounce rule would also redirect traffic that reaches the
master's manager vport into the slave eswitch. On a later shared FDB
activation, esw_set_master_egress_rule() would find the stale entry:
if (xa_load(&vport->egress.offloads.bounce_rules, slave_index))
return -EINVAL;
so mlx5_lag_create_single_fdb_filter() would keep failing until the
driver is reloaded.
A non shared FDB LAG from mlx5_do_bond() needs the netdev notifier.
mlx5_lag_dev_alloc() registers that notifier only when the allocating
device is not SD capable. So this path seems to need an SD primary in
the same ldev as a function that is not SD capable. It is not clear
from the code that such an ldev can exist.
Would it be safer for add_one to record whether it actually removed a
master egress rule, and for del_one to restore it only in that case?
> + if (err)
> + esw_warn(master_esw->dev,
> + "Failed to restore master egress rule (%d)\n",
> + err);
> + }
> +
> esw_unset_slave_egress_rule(master_esw->dev, slave_esw->dev);
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120075959.2533702-1-tariqt%40nvidia.com
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH net-next V2 4/5] net/mlx5e: Register eswitch-manager VF/SF self-port with switch-id
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
1 sibling, 0 replies; 17+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 8:32 UTC (permalink / raw)
To: tariqt
Cc: andrew+netdev, davem, edumazet, kuba, netdev, pabeni, agoldberger,
gal, jgg, leon, linux-rdma, mbloch, moshe, ohartoov, saeedm,
shayd
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In mlx5e_devlink_port_register()
(drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c, new lines…
- [Low] The commit message says the self-port 'was always registered with
DEVLINK_PORT_FLAVOUR_VIRTUAL, which doesn't carries switch_id' (also a…
--
net/mlx5e: Register eswitch-manager VF/SF self-port with switch-id
This patch makes a non-PF function (VF or SF) that is an eswitch manager
register its self-port with a switch_id. The switch_id comes from the SW
system image GUID. As a result, the uplink netdev reports a
phys_switch_id and can be grouped with the representors it manages.
> A non-PF function's self-port (its own uplink netdev) was always
> registered with DEVLINK_PORT_FLAVOUR_VIRTUAL, which doesn't carries
> switch_id.
[Severity: Low]
Is this description accurate? In net/devlink/port.c, switch_port depends
only on whether a switch_id was supplied. The port flavour plays no part:
net/devlink/port.c:__devlink_port_attrs_set() {
...
if (attrs->switch_id.id_len) {
devlink_port->switch_port = true;
...
} else {
devlink_port->switch_port = false;
}
}
devlink_compat_switch_id_get() checks only switch_port. A VIRTUAL port
can carry a switch_id, and this patch relies on that: it keeps
DEVLINK_PORT_FLAVOUR_VIRTUAL and only fills attrs.switch_id.
The phys_switch_id was missing because mlx5e_devlink_port_register()
never filled attrs.switch_id for non-PF functions. The flavour was not
the cause.
The message also mentions only grouping with representors. Could it say
that the uplink netdev now passes netdev_port_same_parent_id() checks it
used to fail? Examples are tc_act_can_offload_mirred(),
tc_act_parse_mirred() and the check in en/tc_tun.c.
There is also a grammar slip: "doesn't carries" should be
"doesn't carry".
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c
> index 8818f65d1fbc4..79adb1ecc4506 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/devlink.c
> @@ -63,6 +63,11 @@ int mlx5e_devlink_port_register(struct mlx5e_dev *mlx5e_dev,
> dl_port_index = mlx5_esw_vport_to_devlink_port_index(mdev,
> MLX5_VPORT_UPLINK);
> } else {
> + if (MLX5_ESWITCH_MANAGER(mdev)) {
> + mlx5e_devlink_get_port_parent_id(mdev, &ppid);
> + memcpy(attrs.switch_id.id, ppid.id, ppid.id_len);
> + attrs.switch_id.id_len = ppid.id_len;
> + }
[Severity: Low]
Is this switch_id unique to the nested eswitch? The value comes from
mlx5_query_nic_sw_system_image_guid(). That is the device-wide FW GUID
followed by capability-only bytes, with trailing zero bytes trimmed:
drivers/net/ethernet/mellanox/mlx5/core/vport.c:
static u8 mlx5_sw_guid_sf(const struct mlx5_core_dev *mdev)
{
return mlx5_core_is_sf(mdev) && mlx5_virt_lag_is_supported(mdev);
}
static u8 mlx5_sw_guid_vf(const struct mlx5_core_dev *mdev)
{
return mlx5_core_is_vf(mdev) && mlx5_virt_lag_is_supported(mdev);
}
mlx5_query_nic_sw_system_image_guid() {
...
for (i = 0; i < ARRAY_SIZE(mlx5_sw_guid_fields); i++) {
u8 val = mlx5_sw_guid_fields[i](mdev);
buf[(*len)++] = val;
if (val)
trim_len = *len;
}
*len = trim_len;
}
Commit c25049685e16 ("Distinguish VFs/SFs in the SW system image
GUID...") says a PF and its VFs/SFs share the same FW system image GUID.
It also says a VF/SF that cannot join a virt LAG "keeps its current key
and is still identified as the same HW as its PF". This leads to two
cases.
In the first case, a VF/SF eswitch manager lacks the virt-LAG caps
(multi_uplink_eswitch, lag_master, num_lag_ports < 2). It then gets
exactly the PF's switch_id. The PF uplink carries that same ID, and so
do the PF-eswitch PCI_VF/PCI_SF representors set up by
mlx5_esw_offloads_pf_vf_devlink_port_attrs_set(), including the
representor of this VF/SF itself.
In the second case, every virt-LAG-capable VF (or SF) eswitch manager on
one HCA gets the same ID, whether or not they share an FDB. That
includes a standalone late joiner that mlx5_esw_offloads_devcom_init()
refuses to pair.
After this patch, devlink_compat_switch_id_get() reports this ID as the
phys_switch_id of the VF/SF uplink netdev.
Documentation/networking/switchdev.rst says the switch ID must be unique
between switches on the same system.
The nested-eswitch representors already used this ID before the patch,
and the PF uplinks of one HCA already share a switch_id. The in-kernel
mlx5 TC forwarding path re-checks the real eswitch/LAG relationship in
mlx5e_is_valid_eswitch_fwd_dev(). What changes is that the uplink netdev
itself now reports the colliding ID.
Should this check also require mlx5_virt_lag_is_supported(), or the
nested-eswitch condition used elsewhere in the series, rather than only
MLX5_ESWITCH_MANAGER(mdev)? If not, should the limitation be documented?
> attrs.flavour = DEVLINK_PORT_FLAVOUR_VIRTUAL;
> dl_port_index = mlx5_esw_vport_to_devlink_port_index(mdev, 0);
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120075959.2533702-1-tariqt%40nvidia.com
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH net-next V2 5/5] net/mlx5: LAG, enable LAG over functions that do not represent a physical port
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
1 sibling, 1 reply; 17+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 8:32 UTC (permalink / raw)
To: tariqt
Cc: andrew+netdev, davem, edumazet, kuba, netdev, pabeni, agoldberger,
gal, jgg, leon, linux-rdma, mbloch, moshe, ohartoov, saeedm,
shayd
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 2
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] mlx5_lag_add_mdev() now lets any VF/SF that passes
mlx5_virt_lag_is_supported() into the LAG, and nothing caps how many…
- [Medium] net/mlx5: LAG, empty debugfs member list in members_show() for
virt_lag
- [Low] For a virt LAG, vport speed aggregation does nothing at all.
- [Low] The commit message does not mention that the exported
mlx5_lag_is_mpesw() changes meaning.
--
net/mlx5: LAG, enable LAG over functions that do not represent a physical port
This patch lets VF/SF functions that sit behind a multi_uplink_eswitch
(num_lag_ports < 2) join a LAG, using mlx5_virt_lag_is_supported() to
detect them. Such members are not marked as ports. They do not register
the PORT_CHANGE, netdev or multipath FIB notifiers, and they do not add
netdevs to the LAG.
The patch also widens mlx5_lag_get_filter() and mlx5_lag_is_mpesw() for
virt LAG, makes mlx5_lag_get_num_ports() return at least 1, and stops
RDMA from assigning a TX port affinity for these functions.
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
> index 193fbe47fef15..2cd2319f93189 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
[ ... ]
> @@ -2398,7 +2404,7 @@ int mlx5_ldev_add_mdev(struct mlx5_lag *ldev,
> fn->group_id = group_id;
> dev->priv.lag = ldev;
>
> - if (group_id)
> + if (group_id || ldev->virt_lag)
> return 0;
>
> xa_set_mark(&ldev->fns, idx, MLX5_LAG_XA_MARK_PORT);
[Severity: Medium]
Does this early return also leave the lag/members debugfs file empty
for every virt LAG device?
mlx5_lag_add_mdev() now lets virt-LAG capable functions through. On
success it calls mlx5_ldev_add_debugfs(dev), which creates the lag
directory, including the members file.
members_show() in lag/debugfs.c lists the members with:
mlx5_ldev_for_each(i, 0, ldev)
seq_printf(file, "%s\n",
dev_name(mlx5_lag_fn(ldev, i)->dev->device));
mlx5_ldev_for_each() uses MLX5_LAG_FILTER_PORTS, so
mlx5_get_next_lag_func() only walks entries marked with
MLX5_LAG_XA_MARK_PORT. A virt-LAG member returns here before
xa_set_mark() runs, so no entry in ldev->fns carries the mark.
Reading lag/members on such a device then always prints nothing, even
when the LAG has members.
This patch already switched mlx5_lag_get_filter() to
MLX5_LAG_FILTER_ALL for virt LAG because its members are not marked
as ports. Should members_show() use the same per-device filter, or
MLX5_LAG_FILTER_ALL when ldev->virt_lag is set, so the file reports
the real members? Or is the members file not meant to exist for a
virt LAG?
[Severity: Low]
Because of this early return for virt_lag, no virt-LAG member ever gets
MLX5_LAG_XA_MARK_PORT or the PORT_CHANGE notifier. Does that leave vport
speed aggregation doing nothing for a virt LAG?
mlx5_lag_enable_mpesw() calls mlx5_lag_shared_fdb_create() with
MLX5_LAG_FILTER_ALL, and that function then does:
if (filter == MLX5_LAG_FILTER_PORTS || filter == MLX5_LAG_FILTER_ALL)
mlx5_lag_set_vports_agg_speed(ldev);
mlx5_lag_set_vports_agg_speed(), mlx5_lag_get_devices_oper_speed() and
mlx5_lag_get_devices_max_speed() all iterate with mlx5_ldev_for_each(),
which only visits PORT-marked entries. For a virt LAG the summed speed
is 0, and the loop that calls mlx5_lag_modify_device_vports_speed() runs
zero times.
The skipped notifier, mlx5_lag_mpesw_port_change_event(), is the only
place that queues speed_update_work. So nothing would refresh the speed
later either.
Other virt-LAG paths in this series were moved to MLX5_LAG_FILTER_ALL
(for example mlx5_lag_get_devcom_comp()). If speed aggregation is not
meant to apply to virt LAG, should mlx5_lag_shared_fdb_create() skip the
call explicitly? If it is meant to apply, should the speed helpers and
the refresh trigger cover all members?
> @@ -2547,7 +2553,7 @@ void mlx5_lag_add_mdev(struct mlx5_core_dev *dev)
> {
> int err;
>
> - if (!mlx5_lag_is_supported(dev))
> + if (!mlx5_lag_is_supported(dev) && !mlx5_virt_lag_is_supported(dev))
> return;
>
> if (mlx5_lag_register_hca_devcom_comp(dev))
[Severity: Medium]
Can the retry loop below this check spin forever once a virt LAG has 255
members?
mlx5_lag_add_mdev() gives up only on -EOPNOTSUPP:
if (err == -EOPNOTSUPP) {
mlx5_lag_unregister_hca_devcom_comp(dev);
return;
}
if (err) {
msleep(100);
goto recheck;
}
The devcom match key comes from mlx5_query_nic_sw_system_image_guid().
It is the system image GUID plus the load_balance_id and VF/SF flag
bytes. So every virt-LAG capable SF (or VF) of the same NIC in the same
netns would join the same ldev through __mlx5_lag_dev_add_mdev().
mlx5_ldev_add_mdev() allocates the slot with:
err = xa_alloc(&ldev->fns, &idx, fn, XA_LIMIT(0, U8_MAX - 1),
GFP_KERNEL);
After 255 members this returns -EBUSY, and __mlx5_lag_dev_add_mdev()
passes it back unchanged. This happens when MPESW is not yet active;
otherwise the late-joiner -EOPNOTSUPP check returns first. The xarray
stays full between iterations, so mlx5_load() for the 256th function
would sleep and retry until some other member unloads.
An earlier patch in this series ("net/mlx5: E-switch, add match-metadata
allocator for nested VF/SF eswitches") already mentions the 0-254 slot
limit from this xa_alloc(). Before this patch, only vport_group_manager
PFs with 2..MLX5_MAX_PORTS lag ports reached this path, so the limit
could not be hit.
Should a permanent capacity error end the LAG join the same way
-EOPNOTSUPP does, instead of being retried like a transient error?
[ ... ]
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c
> index 2d3e61541d8a1..0ef2d13d00968 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c
> @@ -336,7 +336,7 @@ bool mlx5_lag_is_mpesw(struct mlx5_core_dev *dev)
> struct mlx5_lag *ldev = mlx5_lag_dev(dev);
>
> return ldev && ldev->mode == MLX5_LAG_MODE_MPESW &&
> - __mlx5_lag_dev_is_port(ldev, dev);
> + (ldev->virt_lag || __mlx5_lag_dev_is_port(ldev, dev));
> }
> EXPORT_SYMBOL(mlx5_lag_is_mpesw);
[Severity: Low]
This isn't a bug, but the commit message does not say that the exported
mlx5_lag_is_mpesw() now returns true for every virt-LAG member, not only
for port-marked ones.
It also does not mention the change in mlx5_lag_get_filter():
if (fn && (fn->group_id || ldev->virt_lag))
return MLX5_LAG_FILTER_ALL;
With this change, mlx5_lag_get_dev_seq(), mlx5_lag_get_next_peer_mdev()
and the related helpers walk all members of a virt LAG.
Several places call mlx5_lag_is_mpesw():
- eswitch_offloads.c (uplink destination type)
- en_tc.c
- en/tc_tun.c
- ib_rep.c
- a devlink parameter getter in eswitch.c, which reports the value to
user space
Their behavior for VF/SF functions now changes. Could the commit message
describe these two changes?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120075959.2533702-1-tariqt%40nvidia.com
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH net-next V2 1/5] net/mlx5: E-switch, add match-metadata allocator for nested VF/SF eswitches
2026-11-24 8:32 ` netdev-bot+sashiko
@ 2026-11-24 10:39 ` Shay Drori
0 siblings, 0 replies; 17+ messages in thread
From: Shay Drori @ 2026-11-24 10:39 UTC (permalink / raw)
To: netdev-bot+sashiko, tariqt
Cc: andrew+netdev, davem, edumazet, kuba, netdev, pabeni, agoldberger,
gal, jgg, leon, linux-rdma, mbloch, moshe, ohartoov, saeedm
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
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH net-next V2 3/5] net/mlx5: E-switch, drop master egress rule under a SW vport LAG
2026-11-24 8:32 ` netdev-bot+sashiko
@ 2026-11-24 10:51 ` Shay Drori
0 siblings, 0 replies; 17+ messages in thread
From: Shay Drori @ 2026-11-24 10:51 UTC (permalink / raw)
To: netdev-bot+sashiko, tariqt
Cc: andrew+netdev, davem, edumazet, kuba, netdev, pabeni, agoldberger,
gal, jgg, leon, linux-rdma, mbloch, moshe, ohartoov, saeedm
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 2 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · 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] mlx5_eswitch_offloads_vport_lag_del_one() calls
> esw_set_master_egress_rule() for every slave that passes…
> - [Low] The commit message describes the conflict as a general property
> of the software vport LAG: the master egress rule redirects the…
>
> --
>
> net/mlx5: E-switch, drop master egress rule under a SW vport LAG
>
> This commit removes a slave's eswitch master egress rule when the
> software vport LAG slave egress rule is installed. It restores the rule
> when the vport LAG is removed. It also moves the MPESW metadata cleanup
> in mlx5_lag_disable_mpesw() to after the shared FDB is destroyed.
>
>> The software vport LAG emulation cannot. It is a catch-all rule in the
>> slave eswitch's egress ACL that forwards to the master's manager vport,
>> while the master egress rule redirects the packet after the FDB - past
>> the point where the slave egress rule is evaluated - so the bounced
>> packet never reaches it.
>>
>> The two therefore cannot coexist: drop the master egress rule when the
>> software vport LAG is installed, and restore it when it is removed.
>
> [Severity: Low]
> Is this conflict already present in shipped kernels for MPESW over SD
> groups?
>
> Before this patch, MPESW over SD appears to install both rules for the
> other SD primary:
>
> mlx5_lag_enable_mpesw()
> mlx5_mpesw_teardown_sd_fdb() /* clears fn->sd_fdb_active */
> mlx5_lag_shared_fdb_create(FILTER_ALL)
> mlx5_activate_lag()
> mlx5_create_lag()
> mlx5_lag_create_single_fdb()
> mlx5_eswitch_offloads_single_fdb_add_one()
> /* master egress rule for each SD-primary slave */
>
> Then mlx5_ib loads on the master:
>
> mlx5_eth_lag_init()
> mlx5_cmd_create_vport_lag() /* sw path, group_id != 0 */
> mlx5_lag_create_vport_lag() /* FILTER_ALL */
> mlx5_eswitch_offloads_vport_lag_add_one()
> esw_set_slave_egress_rule() /* only this, pre-patch */
>
> Following the commit message's own reasoning, that pair of rules
> misdelivers traffic.
>
> The software vport LAG came from 98d56915eef5 ("net/mlx5: LAG, introduce
> software vport LAG implementation"). MPESW over SD came from
> de464720489c ("net/mlx5: LAG, add MPESW over SD LAG support").
>
> Could the commit message say that the existing MPESW over SD
> configuration is affected, and add the matching Fixes: tag?
>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
>> index 57f58e79478e4..2072921c1fffa 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
>> @@ -3380,12 +3380,32 @@ void mlx5_eswitch_offloads_single_fdb_del_one(struct mlx5_eswitch *master_esw,
>> int mlx5_eswitch_offloads_vport_lag_add_one(struct mlx5_eswitch *master_esw,
>> struct mlx5_eswitch *slave_esw)
>> {
>> - return esw_set_slave_egress_rule(master_esw->dev, slave_esw->dev);
>> + int err;
>> +
>> + err = esw_set_slave_egress_rule(master_esw->dev, slave_esw->dev);
>> + if (err)
>> + return err;
>> +
>> + esw_unset_master_egress_rule(master_esw->dev, slave_esw->dev);
>> +
>> + return 0;
>> }
>>
>> void mlx5_eswitch_offloads_vport_lag_del_one(struct mlx5_eswitch *master_esw,
>> - struct mlx5_eswitch *slave_esw)
>> + struct mlx5_eswitch *slave_esw,
>> + int max_slaves)
>> {
>> + int err;
>> +
>> + if (mlx5_sd_is_primary(slave_esw->dev)) {
>> + err = esw_set_master_egress_rule(master_esw->dev,
>> + slave_esw->dev, max_slaves);
>
> [Severity: Medium]
> Is this restore correct when no master egress rule existed before
> mlx5_eswitch_offloads_vport_lag_add_one() ran?
>
> On the add side, esw_unset_master_egress_rule() returns early when
> vport->egress.acl is NULL and does not record whether it removed
> anything. Here the rule is recreated for any SD-primary slave. The two
> sides only match when a shared FDB installed the rule beforehand.
>
> mlx5_eth_lag_init() creates the vport LAG whenever mlx5_lag_is_active()
> and mlx5_lag_is_sw_managed() are true. Neither checks the shared FDB
> state. With an active LAG that has no MLX5_LAG_MODE_FLAG_SHARED_FDB
> (ROCE, or SRIOV with shared_fdb false), the sequence would be:
>
> mlx5_do_bond() /* no shared FDB */
> mlx5_eth_lag_init()
> mlx5_cmd_create_vport_lag()
> mlx5_eswitch_offloads_vport_lag_add_one()
> esw_unset_master_egress_rule() /* no-op, egress.acl NULL */
> mlx5_eth_lag_cleanup()
> mlx5_cmd_destroy_vport_lag()
> mlx5_eswitch_offloads_vport_lag_del_one()
> esw_set_master_egress_rule() /* new ACL, group, bounce rule */
>
> Does this leak the egress ACL table, flow group and bounce rule on the
> master's manager vport? mlx5_deactivate_lag() only tears down master
> egress state for a shared FDB:
>
> if (test_bit(MLX5_LAG_MODE_FLAG_SHARED_FDB, &flags)) {
> mlx5_lag_destroy_single_fdb(ldev);
>
> The leftover bounce rule would also redirect traffic that reaches the
> master's manager vport into the slave eswitch. On a later shared FDB
> activation, esw_set_master_egress_rule() would find the stale entry:
>
> if (xa_load(&vport->egress.offloads.bounce_rules, slave_index))
> return -EINVAL;
>
> so mlx5_lag_create_single_fdb_filter() would keep failing until the
> driver is reloaded.
>
> A non shared FDB LAG from mlx5_do_bond() needs the netdev notifier.
> mlx5_lag_dev_alloc() registers that notifier only when the allocating
> device is not SD capable. So this path seems to need an SD primary in
> the same ldev as a function that is not SD capable. It is not clear
> from the code that such an ldev can exist.
>
> Would it be safer for add_one to record whether it actually removed a
> master egress rule, and for del_one to restore it only in that case?
No. vport_lag_del_one() is reached only for a SW-managed (SD or virt)
LAG, and such a LAG is only ever active with a shared FDB.
>
>> + if (err)
>> + esw_warn(master_esw->dev,
>> + "Failed to restore master egress rule (%d)\n",
>> + err);
>> + }
>> +
>> esw_unset_slave_egress_rule(master_esw->dev, slave_esw->dev);
>> }
>
> [ ... ]
>
> --
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120075959.2533702-1-tariqt%40nvidia.com
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH net-next V2 5/5] net/mlx5: LAG, enable LAG over functions that do not represent a physical port
2026-11-24 8:32 ` netdev-bot+sashiko
@ 2026-11-24 11:06 ` Shay Drori
0 siblings, 0 replies; 17+ messages in thread
From: Shay Drori @ 2026-11-24 11:06 UTC (permalink / raw)
To: netdev-bot+sashiko, tariqt
Cc: andrew+netdev, davem, edumazet, kuba, netdev, pabeni, agoldberger,
gal, jgg, leon, linux-rdma, mbloch, moshe, ohartoov, saeedm
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 4 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 2 · Low: 2
>
> 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] mlx5_lag_add_mdev() now lets any VF/SF that passes
> mlx5_virt_lag_is_supported() into the LAG, and nothing caps how many…
> - [Medium] net/mlx5: LAG, empty debugfs member list in members_show() for
> virt_lag
> - [Low] For a virt LAG, vport speed aggregation does nothing at all.
> - [Low] The commit message does not mention that the exported
> mlx5_lag_is_mpesw() changes meaning.
>
> --
>
> net/mlx5: LAG, enable LAG over functions that do not represent a physical port
>
> This patch lets VF/SF functions that sit behind a multi_uplink_eswitch
> (num_lag_ports < 2) join a LAG, using mlx5_virt_lag_is_supported() to
> detect them. Such members are not marked as ports. They do not register
> the PORT_CHANGE, netdev or multipath FIB notifiers, and they do not add
> netdevs to the LAG.
>
> The patch also widens mlx5_lag_get_filter() and mlx5_lag_is_mpesw() for
> virt LAG, makes mlx5_lag_get_num_ports() return at least 1, and stops
> RDMA from assigning a TX port affinity for these functions.
>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
>> index 193fbe47fef15..2cd2319f93189 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
>
> [ ... ]
>
>> @@ -2398,7 +2404,7 @@ int mlx5_ldev_add_mdev(struct mlx5_lag *ldev,
>> fn->group_id = group_id;
>> dev->priv.lag = ldev;
>>
>> - if (group_id)
>> + if (group_id || ldev->virt_lag)
>> return 0;
>>
>> xa_set_mark(&ldev->fns, idx, MLX5_LAG_XA_MARK_PORT);
>
> [Severity: Medium]
> Does this early return also leave the lag/members debugfs file empty
> for every virt LAG device?
>
> mlx5_lag_add_mdev() now lets virt-LAG capable functions through. On
> success it calls mlx5_ldev_add_debugfs(dev), which creates the lag
> directory, including the members file.
>
> members_show() in lag/debugfs.c lists the members with:
>
> mlx5_ldev_for_each(i, 0, ldev)
> seq_printf(file, "%s\n",
> dev_name(mlx5_lag_fn(ldev, i)->dev->device));
>
> mlx5_ldev_for_each() uses MLX5_LAG_FILTER_PORTS, so
> mlx5_get_next_lag_func() only walks entries marked with
> MLX5_LAG_XA_MARK_PORT. A virt-LAG member returns here before
> xa_set_mark() runs, so no entry in ldev->fns carries the mark.
> Reading lag/members on such a device then always prints nothing, even
> when the LAG has members.
>
> This patch already switched mlx5_lag_get_filter() to
> MLX5_LAG_FILTER_ALL for virt LAG because its members are not marked
> as ports. Should members_show() use the same per-device filter, or
> MLX5_LAG_FILTER_ALL when ldev->virt_lag is set, so the file reports
> the real members? Or is the members file not meant to exist for a
> virt LAG?
Left as is for now, since all VFs in the system share the LAG.
>
> [Severity: Low]
> Because of this early return for virt_lag, no virt-LAG member ever gets
> MLX5_LAG_XA_MARK_PORT or the PORT_CHANGE notifier. Does that leave vport
> speed aggregation doing nothing for a virt LAG?
>
> mlx5_lag_enable_mpesw() calls mlx5_lag_shared_fdb_create() with
> MLX5_LAG_FILTER_ALL, and that function then does:
>
> if (filter == MLX5_LAG_FILTER_PORTS || filter == MLX5_LAG_FILTER_ALL)
> mlx5_lag_set_vports_agg_speed(ldev);
>
> mlx5_lag_set_vports_agg_speed(), mlx5_lag_get_devices_oper_speed() and
> mlx5_lag_get_devices_max_speed() all iterate with mlx5_ldev_for_each(),
> which only visits PORT-marked entries. For a virt LAG the summed speed
> is 0, and the loop that calls mlx5_lag_modify_device_vports_speed() runs
> zero times.
>
> The skipped notifier, mlx5_lag_mpesw_port_change_event(), is the only
> place that queues speed_update_work. So nothing would refresh the speed
> later either.
>
> Other virt-LAG paths in this series were moved to MLX5_LAG_FILTER_ALL
> (for example mlx5_lag_get_devcom_comp()). If speed aggregation is not
> meant to apply to virt LAG, should mlx5_lag_shared_fdb_create() skip the
> call explicitly? If it is meant to apply, should the speed helpers and
> the refresh trigger cover all members?
Right, for a virt LAG mlx5_lag_shared_fdb_create() should skip
mlx5_lag_set_vports_agg_speed() explicitly. Today the call has no
effect: virt LAG members are not PORT-marked, so no vport speed is
modified.
I think the explicit skip can be a follow-up cleanup rather than
respin.
>
>> @@ -2547,7 +2553,7 @@ void mlx5_lag_add_mdev(struct mlx5_core_dev *dev)
>> {
>> int err;
>>
>> - if (!mlx5_lag_is_supported(dev))
>> + if (!mlx5_lag_is_supported(dev) && !mlx5_virt_lag_is_supported(dev))
>> return;
>>
>> if (mlx5_lag_register_hca_devcom_comp(dev))
>
> [Severity: Medium]
> Can the retry loop below this check spin forever once a virt LAG has 255
> members?
>
> mlx5_lag_add_mdev() gives up only on -EOPNOTSUPP:
>
> if (err == -EOPNOTSUPP) {
> mlx5_lag_unregister_hca_devcom_comp(dev);
> return;
> }
> if (err) {
> msleep(100);
> goto recheck;
> }
>
> The devcom match key comes from mlx5_query_nic_sw_system_image_guid().
> It is the system image GUID plus the load_balance_id and VF/SF flag
> bytes. So every virt-LAG capable SF (or VF) of the same NIC in the same
> netns would join the same ldev through __mlx5_lag_dev_add_mdev().
>
> mlx5_ldev_add_mdev() allocates the slot with:
>
> err = xa_alloc(&ldev->fns, &idx, fn, XA_LIMIT(0, U8_MAX - 1),
> GFP_KERNEL);
>
> After 255 members this returns -EBUSY, and __mlx5_lag_dev_add_mdev()
> passes it back unchanged. This happens when MPESW is not yet active;
> otherwise the late-joiner -EOPNOTSUPP check returns first. The xarray
> stays full between iterations, so mlx5_load() for the 256th function
> would sleep and retry until some other member unloads.
>
> An earlier patch in this series ("net/mlx5: E-switch, add match-metadata
> allocator for nested VF/SF eswitches") already mentions the 0-254 slot
> limit from this xa_alloc(). Before this patch, only vport_group_manager
> PFs with 2..MLX5_MAX_PORTS lag ports reached this path, so the limit
> could not be hit.
>
> Should a permanent capacity error end the LAG join the same way
> -EOPNOTSUPP does, instead of being retried like a transient error?
The retry loop is pre-existing: mlx5_lag_add_mdev() retried every error
before this series as well, and no HW exposes this yet; -EBUSY can only
be returned by future HW. The fix will be sent to net as a separate
patch.
>
> [ ... ]
>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c b/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c
>> index 2d3e61541d8a1..0ef2d13d00968 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c
>> @@ -336,7 +336,7 @@ bool mlx5_lag_is_mpesw(struct mlx5_core_dev *dev)
>> struct mlx5_lag *ldev = mlx5_lag_dev(dev);
>>
>> return ldev && ldev->mode == MLX5_LAG_MODE_MPESW &&
>> - __mlx5_lag_dev_is_port(ldev, dev);
>> + (ldev->virt_lag || __mlx5_lag_dev_is_port(ldev, dev));
>> }
>> EXPORT_SYMBOL(mlx5_lag_is_mpesw);
>
> [Severity: Low]
> This isn't a bug, but the commit message does not say that the exported
> mlx5_lag_is_mpesw() now returns true for every virt-LAG member, not only
> for port-marked ones.
>
> It also does not mention the change in mlx5_lag_get_filter():
>
> if (fn && (fn->group_id || ldev->virt_lag))
> return MLX5_LAG_FILTER_ALL;
>
> With this change, mlx5_lag_get_dev_seq(), mlx5_lag_get_next_peer_mdev()
> and the related helpers walk all members of a virt LAG.
>
> Several places call mlx5_lag_is_mpesw():
>
> - eswitch_offloads.c (uplink destination type)
> - en_tc.c
> - en/tc_tun.c
> - ib_rep.c
> - a devlink parameter getter in eswitch.c, which reports the value to
> user space
>
> Their behavior for VF/SF functions now changes. Could the commit message
> describe these two changes?
>
> --
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120075959.2533702-1-tariqt%40nvidia.com
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2026-11-24 11:06 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox