net/mlx5: Use correct vport when restoring GUIDs
authorDaniel Jurgens <danielj@nvidia.com>
Tue, 7 Mar 2023 17:06:58 +0000 (19:06 +0200)
committerSaeed Mahameed <saeedm@nvidia.com>
Sat, 10 Jun 2023 01:40:52 +0000 (18:40 -0700)
Prior to enabling EC VF functionality the vport number and function ID
were always the same. That's not the case now. Use the correct vport
number to modify the HCA vport context.

Signed-off-by: Daniel Jurgens <danielj@nvidia.com>
Reviewed-by: William Tu <witu@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/sriov.c

index f07d009..c2463a1 100644 (file)
@@ -37,7 +37,7 @@
 #include "mlx5_irq.h"
 #include "eswitch.h"
 
-static int sriov_restore_guids(struct mlx5_core_dev *dev, int vf)
+static int sriov_restore_guids(struct mlx5_core_dev *dev, int vf, u16 func_id)
 {
        struct mlx5_core_sriov *sriov = &dev->priv.sriov;
        struct mlx5_hca_vport_context *in;
@@ -59,7 +59,7 @@ static int sriov_restore_guids(struct mlx5_core_dev *dev, int vf)
                        !!(in->node_guid) * MLX5_HCA_VPORT_SEL_NODE_GUID |
                        !!(in->policy) * MLX5_HCA_VPORT_SEL_STATE_POLICY;
 
-               err = mlx5_core_modify_hca_vport_context(dev, 1, 1, vf + 1, in);
+               err = mlx5_core_modify_hca_vport_context(dev, 1, 1, func_id, in);
                if (err)
                        mlx5_core_warn(dev, "modify vport context failed, unable to restore VF %d settings\n", vf);
 
@@ -73,6 +73,7 @@ static int mlx5_device_enable_sriov(struct mlx5_core_dev *dev, int num_vfs)
 {
        struct mlx5_core_sriov *sriov = &dev->priv.sriov;
        int err, vf, num_msix_count;
+       int vport_num;
 
        err = mlx5_eswitch_enable(dev->priv.eswitch, num_vfs);
        if (err) {
@@ -104,7 +105,10 @@ static int mlx5_device_enable_sriov(struct mlx5_core_dev *dev, int num_vfs)
 
                sriov->vfs_ctx[vf].enabled = 1;
                if (MLX5_CAP_GEN(dev, port_type) == MLX5_CAP_PORT_TYPE_IB) {
-                       err = sriov_restore_guids(dev, vf);
+                       vport_num = mlx5_core_ec_sriov_enabled(dev) ?
+                                       mlx5_core_ec_vf_vport_base(dev) + vf
+                                       : vf + 1;
+                       err = sriov_restore_guids(dev, vf, vport_num);
                        if (err) {
                                mlx5_core_warn(dev,
                                               "failed to restore VF %d settings, err %d\n",