Skip to content

Commit 20a1ea6

Browse files
ogerlitzdavem330
authored andcommitted
net/mlx5e: Support VF vport link state control for SRIOV switchdev mode
Reflect the administative link changes done on the VF representor to the VF e-switch vport. This means that doing ip link set down/up commands on the VF rep will modify the e-switch vport state which in turn will make proper VF drivers to set their carrier accordingly. Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 370bad0 commit 20a1ea6

1 file changed

Lines changed: 31 additions & 2 deletions

File tree

  • drivers/net/ethernet/mellanox/mlx5/core

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,35 @@ void mlx5e_nic_rep_unload(struct mlx5_eswitch *esw,
236236
mlx5e_tc_init(priv);
237237
}
238238

239+
static int mlx5e_rep_open(struct net_device *dev)
240+
{
241+
struct mlx5e_priv *priv = netdev_priv(dev);
242+
struct mlx5_eswitch_rep *rep = priv->ppriv;
243+
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
244+
int err;
245+
246+
err = mlx5e_open(dev);
247+
if (err)
248+
return err;
249+
250+
err = mlx5_eswitch_set_vport_state(esw, rep->vport, MLX5_ESW_VPORT_ADMIN_STATE_UP);
251+
if (!err)
252+
netif_carrier_on(dev);
253+
254+
return 0;
255+
}
256+
257+
static int mlx5e_rep_close(struct net_device *dev)
258+
{
259+
struct mlx5e_priv *priv = netdev_priv(dev);
260+
struct mlx5_eswitch_rep *rep = priv->ppriv;
261+
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
262+
263+
(void)mlx5_eswitch_set_vport_state(esw, rep->vport, MLX5_ESW_VPORT_ADMIN_STATE_DOWN);
264+
265+
return mlx5e_close(dev);
266+
}
267+
239268
static int mlx5e_rep_get_phys_port_name(struct net_device *dev,
240269
char *buf, size_t len)
241270
{
@@ -349,8 +378,8 @@ static const struct switchdev_ops mlx5e_rep_switchdev_ops = {
349378
};
350379

351380
static const struct net_device_ops mlx5e_netdev_ops_rep = {
352-
.ndo_open = mlx5e_open,
353-
.ndo_stop = mlx5e_close,
381+
.ndo_open = mlx5e_rep_open,
382+
.ndo_stop = mlx5e_rep_close,
354383
.ndo_start_xmit = mlx5e_xmit,
355384
.ndo_get_phys_port_name = mlx5e_rep_get_phys_port_name,
356385
.ndo_setup_tc = mlx5e_rep_ndo_setup_tc,

0 commit comments

Comments
 (0)