net/mlx5: Move helper to eswitch layer
authorParav Pandit <parav@mellanox.com>
Fri, 19 Jun 2020 03:32:52 +0000 (03:32 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 22 Jun 2020 22:29:19 +0000 (15:29 -0700)
To use port number to port index conversion at eswitch level, move it to
eswitch header.

Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h

index 006807e04eda330f8e73a87d607db0b5604aed87..20ff8526d21261c3c5b74c52b9b8220a3eea4984 100644 (file)
@@ -1181,12 +1181,6 @@ is_devlink_port_supported(const struct mlx5_core_dev *dev,
               mlx5_eswitch_is_vf_vport(dev->priv.eswitch, rpriv->rep->vport);
 }
 
-static unsigned int
-vport_to_devlink_port_index(const struct mlx5_core_dev *dev, u16 vport_num)
-{
-       return (MLX5_CAP_GEN(dev, vhca_id) << 16) | vport_num;
-}
-
 static int register_devlink_port(struct mlx5_core_dev *dev,
                                 struct mlx5e_rep_priv *rpriv)
 {
@@ -1200,7 +1194,7 @@ 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);
+       dl_port_index = mlx5_esw_vport_to_devlink_port_index(dev, rep->vport);
        pfnum = PCI_FUNC(dev->pdev->devfn);
 
        if (rep->vport == MLX5_VPORT_UPLINK)
index dde5a36fee9d58d2dadb663bb93da4eff9fb2a77..8f537183e9774890d754786267de29230a6bc8c6 100644 (file)
@@ -565,6 +565,13 @@ static inline u16 mlx5_eswitch_index_to_vport_num(struct mlx5_eswitch *esw,
        return index;
 }
 
+static inline unsigned int
+mlx5_esw_vport_to_devlink_port_index(const struct mlx5_core_dev *dev,
+                                    u16 vport_num)
+{
+       return (MLX5_CAP_GEN(dev, vhca_id) << 16) | vport_num;
+}
+
 /* TODO: This mlx5e_tc function shouldn't be called by eswitch */
 void mlx5e_tc_clean_fdb_peer_flows(struct mlx5_eswitch *esw);