net/mlx5: Base ECVF devlink port attrs from 0
authorDaniel Jurgens <danielj@nvidia.com>
Wed, 20 Aug 2025 13:32:02 +0000 (16:32 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 21 Aug 2025 14:58:30 +0000 (07:58 -0700)
Adjust the vport number by the base ECVF vport number so the port
attributes start at 0. Previously the port attributes would start 1
after the maximum number of host VFs.

Fixes: dc13180824b7 ("net/mlx5: Enable devlink port for embedded cpu VF vports")
Signed-off-by: Daniel Jurgens <danielj@nvidia.com>
Reviewed-by: Parav Pandit <parav@nvidia.com>
Reviewed-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Link: https://patch.msgid.link/20250820133209.389065-2-mbloch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c

index b7102e14d23d3b44fc41763d28907613d7d734d8..c33accadae0f01f68f6e4982dca954c281cd9e9f 100644 (file)
@@ -47,10 +47,12 @@ static void mlx5_esw_offloads_pf_vf_devlink_port_attrs_set(struct mlx5_eswitch *
                devlink_port_attrs_pci_vf_set(dl_port, controller_num, pfnum,
                                              vport_num - 1, external);
        }  else if (mlx5_core_is_ec_vf_vport(esw->dev, vport_num)) {
+               u16 base_vport = mlx5_core_ec_vf_vport_base(dev);
+
                memcpy(dl_port->attrs.switch_id.id, ppid.id, ppid.id_len);
                dl_port->attrs.switch_id.id_len = ppid.id_len;
                devlink_port_attrs_pci_vf_set(dl_port, 0, pfnum,
-                                             vport_num - 1, false);
+                                             vport_num - base_vport, false);
        }
 }