]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/mlx5: Register devlink ports for satellite PFs
authorMoshe Shemesh <moshe@nvidia.com>
Thu, 21 May 2026 11:08:39 +0000 (14:08 +0300)
committerJakub Kicinski <kuba@kernel.org>
Mon, 25 May 2026 20:48:51 +0000 (13:48 -0700)
Include satellite PFs in mlx5_eswitch_is_pf_vf_vport() so they receive
the standard PF/VF devlink port operations. Update
mlx5_esw_devlink_port_supported() and devlink port attribute setup to
register SPF devlink ports with controller number and PF number.

Add mlx5_esw_spf_vport_to_idx() to look up the SPF array index by vport
number, and mlx5_esw_is_spf_vport() boolean wrapper to identify
satellite PF vports.

Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/20260521110843.367329-9-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/esw/devlink_port.c
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h

index fddb108bcbffe52e0e48ffadf8ce925da7760d18..05d89769b9178ff38eb4ab43b542814857f17744 100644 (file)
@@ -16,7 +16,8 @@ static bool mlx5_esw_devlink_port_supported(struct mlx5_eswitch *esw, u16 vport_
        return (mlx5_core_is_ecpf(esw->dev) &&
                vport_num == MLX5_VPORT_HOST_PF) ||
               mlx5_eswitch_is_vf_vport(esw, vport_num) ||
-              mlx5_core_is_ec_vf_vport(esw->dev, vport_num);
+              mlx5_core_is_ec_vf_vport(esw->dev, vport_num) ||
+              mlx5_esw_is_spf_vport(esw, vport_num);
 }
 
 static void mlx5_esw_offloads_pf_vf_devlink_port_attrs_set(struct mlx5_eswitch *esw,
@@ -64,6 +65,16 @@ static void mlx5_esw_offloads_pf_vf_devlink_port_attrs_set(struct mlx5_eswitch *
                dl_port->attrs.switch_id.id_len = ppid.id_len;
                devlink_port_attrs_pci_vf_set(dl_port, 0, pfnum,
                                              vport_num - base_vport, false);
+       } else if (mlx5_esw_is_spf_vport(esw, vport_num)) {
+               int spf_idx = mlx5_esw_spf_vport_to_idx(esw, vport_num);
+
+               controller_num = esw->esw_funcs.spfs[spf_idx].host_number + 1;
+               pfnum = esw->esw_funcs.spfs[spf_idx].pf_num;
+
+               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_pf_set(dl_port, controller_num, pfnum,
+                                             true);
        }
 }
 
index e1cdb473645219e0c3dc42cb0ab081e3fec99a04..a5b838821979c66d78c7583295407fe9ec9c2dd9 100644 (file)
@@ -2672,10 +2672,29 @@ bool mlx5_eswitch_is_vf_vport(struct mlx5_eswitch *esw, u16 vport_num)
        return mlx5_esw_check_port_type(esw, vport_num, MLX5_ESW_VPT_VF);
 }
 
+int mlx5_esw_spf_vport_to_idx(struct mlx5_eswitch *esw, u16 vport_num)
+{
+       struct mlx5_esw_functions *esw_funcs = &esw->esw_funcs;
+       int i;
+
+       for (i = 0; i < esw_funcs->num_spfs; i++) {
+               if (esw_funcs->spfs[i].vport_num == vport_num)
+                       return i;
+       }
+
+       return -ENOENT;
+}
+
+bool mlx5_esw_is_spf_vport(struct mlx5_eswitch *esw, u16 vport_num)
+{
+       return mlx5_esw_spf_vport_to_idx(esw, vport_num) >= 0;
+}
+
 bool mlx5_eswitch_is_pf_vf_vport(struct mlx5_eswitch *esw, u16 vport_num)
 {
        return vport_num == MLX5_VPORT_HOST_PF ||
-               mlx5_eswitch_is_vf_vport(esw, vport_num);
+               mlx5_eswitch_is_vf_vport(esw, vport_num) ||
+               mlx5_esw_is_spf_vport(esw, vport_num);
 }
 
 bool mlx5_esw_is_sf_vport(struct mlx5_eswitch *esw, u16 vport_num)
index 2b29b4e974c0412c408d05fca1911e80eccfda9e..1720afa3331a2acea33f642ecdbb6378b55e6782 100644 (file)
@@ -799,6 +799,8 @@ struct mlx5_vport *__must_check
 mlx5_eswitch_get_vport(struct mlx5_eswitch *esw, u16 vport_num);
 
 bool mlx5_eswitch_is_vf_vport(struct mlx5_eswitch *esw, u16 vport_num);
+int mlx5_esw_spf_vport_to_idx(struct mlx5_eswitch *esw, u16 vport_num);
+bool mlx5_esw_is_spf_vport(struct mlx5_eswitch *esw, u16 vport_num);
 bool mlx5_eswitch_is_pf_vf_vport(struct mlx5_eswitch *esw, u16 vport_num);
 bool mlx5_esw_is_sf_vport(struct mlx5_eswitch *esw, u16 vport_num);