net/mlx5e: Use helper API to get devlink port index for all port flavours
authorParav Pandit <parav@mellanox.com>
Fri, 3 Apr 2020 10:49:02 +0000 (05:49 -0500)
committerSaeed Mahameed <saeedm@mellanox.com>
Thu, 30 Apr 2020 17:10:42 +0000 (10:10 -0700)
Use existing helper API to get unique devlink port index for all
devlink port flavours.

Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c

index 55457f2..2de54d8 100644 (file)
@@ -2056,26 +2056,22 @@ static int register_devlink_port(struct mlx5_core_dev *dev,
                return 0;
 
        mlx5e_rep_get_port_parent_id(rpriv->netdev, &ppid);
+       dl_port_index = vport_to_devlink_port_index(dev, rep->vport);
        pfnum = PCI_FUNC(dev->pdev->devfn);
 
-       if (rep->vport == MLX5_VPORT_UPLINK) {
+       if (rep->vport == MLX5_VPORT_UPLINK)
                devlink_port_attrs_set(&rpriv->dl_port,
                                       DEVLINK_PORT_FLAVOUR_PHYSICAL,
                                       pfnum, false, 0,
                                       &ppid.id[0], ppid.id_len);
-               dl_port_index = vport_to_devlink_port_index(dev, rep->vport);
-       } else if (rep->vport == MLX5_VPORT_PF) {
+       else if (rep->vport == MLX5_VPORT_PF)
                devlink_port_attrs_pci_pf_set(&rpriv->dl_port,
                                              &ppid.id[0], ppid.id_len,
                                              pfnum);
-               dl_port_index = rep->vport;
-       } else if (mlx5_eswitch_is_vf_vport(dev->priv.eswitch,
-                                           rpriv->rep->vport)) {
+       else if (mlx5_eswitch_is_vf_vport(dev->priv.eswitch, rpriv->rep->vport))
                devlink_port_attrs_pci_vf_set(&rpriv->dl_port,
                                              &ppid.id[0], ppid.id_len,
                                              pfnum, rep->vport - 1);
-               dl_port_index = vport_to_devlink_port_index(dev, rep->vport);
-       }
 
        return devlink_port_register(devlink, &rpriv->dl_port, dl_port_index);
 }