Skip to content

Commit aec002f

Browse files
ogerlitzSaeed Mahameed
authored andcommitted
net/mlx5e: Uninstantiate esw manager vport netdev on switchdev mode
Now, when we have a dedicated uplink representor, the netdev instance set over the esw manager vport (PF) is of no-use. As such, remove it once we're on switchdev mode and get it back to life when off switchdev. This is done by reloading the Ethernet interface as well (we already do that for the IB interface) from the eswitch code while going in/out of switchdev mode. The Eth add/remove entries are modified to act differently when called in switchdev mode. In this case we only deal with registration of the eth vport representors. The rep netdevices are created from the eswitch call to load the registered eth representors. Signed-off-by: Or Gerlitz <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 13e509a commit aec002f

File tree

4 files changed

+42
-21
lines changed

4 files changed

+42
-21
lines changed

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4894,9 +4894,6 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
48944894
if (mlx5e_monitor_counter_supported(priv))
48954895
mlx5e_monitor_counter_init(priv);
48964896

4897-
if (MLX5_ESWITCH_MANAGER(priv->mdev))
4898-
mlx5e_rep_register_vport_reps(priv);
4899-
49004897
if (netdev->reg_state != NETREG_REGISTERED)
49014898
return;
49024899
#ifdef CONFIG_MLX5_CORE_EN_DCB
@@ -4929,9 +4926,6 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)
49294926

49304927
queue_work(priv->wq, &priv->set_rx_mode_work);
49314928

4932-
if (MLX5_ESWITCH_MANAGER(priv->mdev))
4933-
mlx5e_rep_unregister_vport_reps(priv);
4934-
49354929
if (mlx5e_monitor_counter_supported(priv))
49364930
mlx5e_monitor_counter_cleanup(priv);
49374931

@@ -5138,6 +5132,14 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)
51385132
if (err)
51395133
return NULL;
51405134

5135+
#ifdef CONFIG_MLX5_ESWITCH
5136+
if (MLX5_ESWITCH_MANAGER(mdev) &&
5137+
mlx5_eswitch_mode(mdev->priv.eswitch) == SRIOV_OFFLOADS) {
5138+
mlx5e_rep_register_vport_reps(mdev);
5139+
return mdev;
5140+
}
5141+
#endif
5142+
51415143
nch = mlx5e_get_max_num_channels(mdev);
51425144
netdev = mlx5e_create_netdev(mdev, &mlx5e_nic_profile, nch, NULL);
51435145
if (!netdev) {
@@ -5173,9 +5175,15 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)
51735175

51745176
static void mlx5e_remove(struct mlx5_core_dev *mdev, void *vpriv)
51755177
{
5176-
struct mlx5e_priv *priv = vpriv;
5177-
void *ppriv = priv->ppriv;
5178+
struct mlx5e_priv *priv;
51785179

5180+
#ifdef CONFIG_MLX5_ESWITCH
5181+
if (MLX5_ESWITCH_MANAGER(mdev) && vpriv == mdev) {
5182+
mlx5e_rep_unregister_vport_reps(mdev);
5183+
return;
5184+
}
5185+
#endif
5186+
priv = vpriv;
51795187
#ifdef CONFIG_MLX5_CORE_EN_DCB
51805188
mlx5e_dcbnl_delete_app(priv);
51815189
#endif

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,11 +1562,17 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
15621562
rep->rep_if[REP_ETH].priv = rpriv;
15631563
INIT_LIST_HEAD(&rpriv->vport_sqs_list);
15641564

1565+
if (rep->vport == FDB_UPLINK_VPORT) {
1566+
err = mlx5e_create_mdev_resources(dev);
1567+
if (err)
1568+
goto err_destroy_netdev;
1569+
}
1570+
15651571
err = mlx5e_attach_netdev(netdev_priv(netdev));
15661572
if (err) {
15671573
pr_warn("Failed to attach representor netdev for vport %d\n",
15681574
rep->vport);
1569-
goto err_destroy_netdev;
1575+
goto err_destroy_mdev_resources;
15701576
}
15711577

15721578
err = mlx5e_rep_neigh_init(rpriv);
@@ -1591,6 +1597,10 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
15911597
err_detach_netdev:
15921598
mlx5e_detach_netdev(netdev_priv(netdev));
15931599

1600+
err_destroy_mdev_resources:
1601+
if (rep->vport == FDB_UPLINK_VPORT)
1602+
mlx5e_destroy_mdev_resources(dev);
1603+
15941604
err_destroy_netdev:
15951605
mlx5e_destroy_netdev(netdev_priv(netdev));
15961606
kfree(rpriv);
@@ -1608,6 +1618,8 @@ mlx5e_vport_rep_unload(struct mlx5_eswitch_rep *rep)
16081618
unregister_netdev(netdev);
16091619
mlx5e_rep_neigh_cleanup(rpriv);
16101620
mlx5e_detach_netdev(priv);
1621+
if (rep->vport == FDB_UPLINK_VPORT)
1622+
mlx5e_destroy_mdev_resources(priv->mdev);
16111623
mlx5e_destroy_netdev(priv);
16121624
kfree(ppriv); /* mlx5e_rep_priv */
16131625
}
@@ -1621,10 +1633,9 @@ static void *mlx5e_vport_rep_get_proto_dev(struct mlx5_eswitch_rep *rep)
16211633
return rpriv->netdev;
16221634
}
16231635

1624-
void mlx5e_rep_register_vport_reps(struct mlx5e_priv *priv)
1636+
void mlx5e_rep_register_vport_reps(struct mlx5_core_dev *mdev)
16251637
{
1626-
struct mlx5_core_dev *mdev = priv->mdev;
1627-
struct mlx5_eswitch *esw = mdev->priv.eswitch;
1638+
struct mlx5_eswitch *esw = mdev->priv.eswitch;
16281639
int total_vfs = MLX5_TOTAL_VPORTS(mdev);
16291640
int vport;
16301641

@@ -1638,9 +1649,8 @@ void mlx5e_rep_register_vport_reps(struct mlx5e_priv *priv)
16381649
}
16391650
}
16401651

1641-
void mlx5e_rep_unregister_vport_reps(struct mlx5e_priv *priv)
1652+
void mlx5e_rep_unregister_vport_reps(struct mlx5_core_dev *mdev)
16421653
{
1643-
struct mlx5_core_dev *mdev = priv->mdev;
16441654
struct mlx5_eswitch *esw = mdev->priv.eswitch;
16451655
int total_vfs = MLX5_TOTAL_VPORTS(mdev);
16461656
int vport;

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ struct mlx5e_rep_sq {
162162
};
163163

164164
void *mlx5e_alloc_nic_rep_priv(struct mlx5_core_dev *mdev);
165-
void mlx5e_rep_register_vport_reps(struct mlx5e_priv *priv);
166-
void mlx5e_rep_unregister_vport_reps(struct mlx5e_priv *priv);
165+
void mlx5e_rep_register_vport_reps(struct mlx5_core_dev *mdev);
166+
void mlx5e_rep_unregister_vport_reps(struct mlx5_core_dev *mdev);
167167
bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv);
168168
int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv);
169169
void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv);
@@ -177,8 +177,6 @@ void mlx5e_rep_encap_entry_detach(struct mlx5e_priv *priv,
177177

178178
void mlx5e_rep_queue_neigh_stats_work(struct mlx5e_priv *priv);
179179
#else /* CONFIG_MLX5_ESWITCH */
180-
static inline void mlx5e_rep_register_vport_reps(struct mlx5e_priv *priv) {}
181-
static inline void mlx5e_rep_unregister_vport_reps(struct mlx5e_priv *priv) {}
182180
static inline bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv) { return false; }
183181
static inline int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv) { return 0; }
184182
static inline void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv) {}

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,15 +1630,16 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode)
16301630
esw_warn(esw->dev, "E-Switch engress ACL is not supported by FW\n");
16311631

16321632
esw_info(esw->dev, "E-Switch enable SRIOV: nvfs(%d) mode (%d)\n", nvfs, mode);
1633+
16331634
esw->mode = mode;
16341635

16351636
mlx5_lag_update(esw->dev);
16361637

16371638
if (mode == SRIOV_LEGACY) {
16381639
err = esw_create_legacy_fdb_table(esw);
16391640
} else {
1641+
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);
16401642
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
1641-
16421643
err = esw_offloads_init(esw, nvfs + 1);
16431644
}
16441645

@@ -1669,8 +1670,10 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode)
16691670
abort:
16701671
esw->mode = SRIOV_NONE;
16711672

1672-
if (mode == SRIOV_OFFLOADS)
1673+
if (mode == SRIOV_OFFLOADS) {
16731674
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
1675+
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);
1676+
}
16741677

16751678
return err;
16761679
}
@@ -1712,8 +1715,10 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw)
17121715

17131716
mlx5_lag_update(esw->dev);
17141717

1715-
if (old_mode == SRIOV_OFFLOADS)
1718+
if (old_mode == SRIOV_OFFLOADS) {
17161719
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
1720+
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);
1721+
}
17171722
}
17181723

17191724
int mlx5_eswitch_init(struct mlx5_core_dev *dev)

0 commit comments

Comments
 (0)