{IB, net}/mlx5: E-Switch, Use index of rep for vport to IB port mapping
authorBodong Wang <bodong@mellanox.com>
Fri, 28 Jun 2019 22:35:53 +0000 (22:35 +0000)
committerSaeed Mahameed <saeedm@mellanox.com>
Mon, 1 Jul 2019 23:40:30 +0000 (16:40 -0700)
In the single IB device mode, the mapping between vport number and
rep relies on a counter. However for dynamic vport allocation, it is
desired to keep consistent map of eswitch vport and IB port.

Hence, simplify code to remove the free running counter and instead
use the available vport index during load/unload sequence from the
eswitch.

Signed-off-by: Bodong Wang <bodong@mellanox.com>
Suggested-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/infiniband/hw/mlx5/ib_rep.c
drivers/infiniband/hw/mlx5/mlx5_ib.h
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
include/linux/mlx5/eswitch.h

index 22e651cb553466266bd18a3e1281bdb5f27aac9f..1de16a93fc64ecb8bc9d91f39f80d0d2474fb4f8 100644 (file)
@@ -14,7 +14,7 @@ mlx5_ib_set_vport_rep(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
        int vport_index;
 
        ibdev = mlx5_ib_get_uplink_ibdev(dev->priv.eswitch);
-       vport_index = ibdev->free_port++;
+       vport_index = rep->vport_index;
 
        ibdev->port[vport_index].rep = rep;
        write_lock(&ibdev->port[vport_index].roce.netdev_lock);
@@ -50,7 +50,7 @@ mlx5_ib_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
        }
 
        ibdev->is_rep = true;
-       vport_index = ibdev->free_port++;
+       vport_index = rep->vport_index;
        ibdev->port[vport_index].rep = rep;
        ibdev->port[vport_index].roce.netdev =
                mlx5_ib_get_rep_netdev(dev->priv.eswitch, rep->vport);
index 1c205c2bd48678d853e7b41ab7e9fd71ed8e5680..ee73dc122d28e476979674c2a065ca44c963f321 100644 (file)
@@ -978,7 +978,6 @@ struct mlx5_ib_dev {
        u16                     devx_whitelist_uid;
        struct mlx5_srq_table   srq_table;
        struct mlx5_async_ctx   async_ctx;
-       int                     free_port;
 };
 
 static inline struct mlx5_ib_cq *to_mibcq(struct mlx5_core_cq *mcq)
index bc639a8467147d18d6b747747e3d02bc97c54e09..24af2744453b92a009d29b6e61a8dfc0aa6f8ae2 100644 (file)
@@ -1411,6 +1411,7 @@ int esw_offloads_init_reps(struct mlx5_eswitch *esw)
 
        mlx5_esw_for_all_reps(esw, vport_index, rep) {
                rep->vport = mlx5_eswitch_index_to_vport_num(esw, vport_index);
+               rep->vport_index = vport_index;
                ether_addr_copy(rep->hw_id, hw_id);
 
                for (rep_type = 0; rep_type < NUM_REP_TYPES; rep_type++)
index aece3ae1902d53929617eb59a35e763cc60b57ca..36cb641188b041b799d42edc355994762aaffdcf 100644 (file)
@@ -46,6 +46,8 @@ struct mlx5_eswitch_rep {
        u16                    vport;
        u8                     hw_id[ETH_ALEN];
        u16                    vlan;
+       /* Only IB rep is using vport_index */
+       u16                    vport_index;
        u32                    vlan_refcount;
 };