Skip to content

Commit 556b9d1

Browse files
ayalevin123Saeed Mahameed
authored andcommitted
net/mlx5: Clear VF's configuration on disabling SRIOV
When setting number of VFs to 0 (disable SRIOV), clear VF's configuration. Signed-off-by: Aya Levin <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 32680da commit 556b9d1

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

drivers/net/ethernet/mellanox/mlx5/core/eswitch.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1831,6 +1831,15 @@ static void mlx5_eswitch_event_handlers_unregister(struct mlx5_eswitch *esw)
18311831
flush_workqueue(esw->work_queue);
18321832
}
18331833

1834+
static void mlx5_eswitch_clear_vf_vports_info(struct mlx5_eswitch *esw)
1835+
{
1836+
struct mlx5_vport *vport;
1837+
int i;
1838+
1839+
mlx5_esw_for_each_vf_vport(esw, i, vport, esw->esw_funcs.num_vfs)
1840+
memset(&vport->info, 0, sizeof(vport->info));
1841+
}
1842+
18341843
/* Public E-Switch API */
18351844
#define ESW_ALLOWED(esw) ((esw) && MLX5_ESWITCH_MANAGER((esw)->dev))
18361845

@@ -1923,7 +1932,7 @@ int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int mode)
19231932
return err;
19241933
}
19251934

1926-
void mlx5_eswitch_disable(struct mlx5_eswitch *esw)
1935+
void mlx5_eswitch_disable(struct mlx5_eswitch *esw, bool clear_vf)
19271936
{
19281937
int old_mode;
19291938

@@ -1952,6 +1961,8 @@ void mlx5_eswitch_disable(struct mlx5_eswitch *esw)
19521961
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
19531962
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);
19541963
}
1964+
if (clear_vf)
1965+
mlx5_eswitch_clear_vf_vports_info(esw);
19551966
}
19561967

19571968
int mlx5_eswitch_init(struct mlx5_core_dev *dev)

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ int mlx5_esw_modify_vport_rate(struct mlx5_eswitch *esw, u16 vport_num,
270270
int mlx5_eswitch_init(struct mlx5_core_dev *dev);
271271
void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw);
272272
int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int mode);
273-
void mlx5_eswitch_disable(struct mlx5_eswitch *esw);
273+
void mlx5_eswitch_disable(struct mlx5_eswitch *esw, bool clear_vf);
274274
int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
275275
u16 vport, u8 mac[ETH_ALEN]);
276276
int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw,
@@ -603,7 +603,7 @@ void mlx5_eswitch_disable_pf_vf_vports(struct mlx5_eswitch *esw);
603603
static inline int mlx5_eswitch_init(struct mlx5_core_dev *dev) { return 0; }
604604
static inline void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw) {}
605605
static inline int mlx5_eswitch_enable(struct mlx5_eswitch *esw, int mode) { return 0; }
606-
static inline void mlx5_eswitch_disable(struct mlx5_eswitch *esw) {}
606+
static inline void mlx5_eswitch_disable(struct mlx5_eswitch *esw, bool clear_vf) {}
607607
static inline bool mlx5_esw_lag_prereq(struct mlx5_core_dev *dev0, struct mlx5_core_dev *dev1) { return true; }
608608
static inline bool mlx5_eswitch_is_funcs_handler(struct mlx5_core_dev *dev) { return false; }
609609
static inline const u32 *mlx5_esw_query_functions(struct mlx5_core_dev *dev)

drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ static int esw_offloads_start(struct mlx5_eswitch *esw,
13701370
return -EINVAL;
13711371
}
13721372

1373-
mlx5_eswitch_disable(esw);
1373+
mlx5_eswitch_disable(esw, false);
13741374
mlx5_eswitch_update_num_of_vfs(esw, esw->dev->priv.sriov.num_vfs);
13751375
err = mlx5_eswitch_enable(esw, MLX5_ESWITCH_OFFLOADS);
13761376
if (err) {
@@ -2196,7 +2196,7 @@ static int esw_offloads_stop(struct mlx5_eswitch *esw,
21962196
{
21972197
int err, err1;
21982198

2199-
mlx5_eswitch_disable(esw);
2199+
mlx5_eswitch_disable(esw, false);
22002200
err = mlx5_eswitch_enable(esw, MLX5_ESWITCH_LEGACY);
22012201
if (err) {
22022202
NL_SET_ERR_MSG_MOD(extack, "Failed setting eswitch to legacy");

drivers/net/ethernet/mellanox/mlx5/core/sriov.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static int mlx5_device_enable_sriov(struct mlx5_core_dev *dev, int num_vfs)
108108
return 0;
109109
}
110110

111-
static void mlx5_device_disable_sriov(struct mlx5_core_dev *dev)
111+
static void mlx5_device_disable_sriov(struct mlx5_core_dev *dev, bool clear_vf)
112112
{
113113
struct mlx5_core_sriov *sriov = &dev->priv.sriov;
114114
int num_vfs = pci_num_vf(dev->pdev);
@@ -127,7 +127,7 @@ static void mlx5_device_disable_sriov(struct mlx5_core_dev *dev)
127127
}
128128

129129
if (MLX5_ESWITCH_MANAGER(dev))
130-
mlx5_eswitch_disable(dev->priv.eswitch);
130+
mlx5_eswitch_disable(dev->priv.eswitch, clear_vf);
131131

132132
if (mlx5_wait_for_pages(dev, &dev->priv.vfs_pages))
133133
mlx5_core_warn(dev, "timeout reclaiming VFs pages\n");
@@ -147,7 +147,7 @@ static int mlx5_sriov_enable(struct pci_dev *pdev, int num_vfs)
147147
err = pci_enable_sriov(pdev, num_vfs);
148148
if (err) {
149149
mlx5_core_warn(dev, "pci_enable_sriov failed : %d\n", err);
150-
mlx5_device_disable_sriov(dev);
150+
mlx5_device_disable_sriov(dev, true);
151151
}
152152
return err;
153153
}
@@ -157,7 +157,7 @@ static void mlx5_sriov_disable(struct pci_dev *pdev)
157157
struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
158158

159159
pci_disable_sriov(pdev);
160-
mlx5_device_disable_sriov(dev);
160+
mlx5_device_disable_sriov(dev, true);
161161
}
162162

163163
int mlx5_core_sriov_configure(struct pci_dev *pdev, int num_vfs)
@@ -192,7 +192,7 @@ void mlx5_sriov_detach(struct mlx5_core_dev *dev)
192192
if (!mlx5_core_is_pf(dev))
193193
return;
194194

195-
mlx5_device_disable_sriov(dev);
195+
mlx5_device_disable_sriov(dev, false);
196196
}
197197

198198
static u16 mlx5_get_max_vfs(struct mlx5_core_dev *dev)

0 commit comments

Comments
 (0)