net/mlx5: E-switch, Read controller number from device
authorParav Pandit <parav@nvidia.com>
Wed, 9 Sep 2020 04:50:33 +0000 (07:50 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 9 Sep 2020 21:19:55 +0000 (14:19 -0700)
ECPF supports one external host controller. Read controller number
from the device.

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

index 867d8120b8a5eafac31cec677c2abbb8d973798a..7455fbd21a0a61755fbba930732ebeb5b05bd610 100644 (file)
@@ -217,6 +217,7 @@ struct mlx5_esw_offload {
        atomic64_t num_flows;
        enum devlink_eswitch_encap_mode encap;
        struct ida vport_metadata_ida;
+       unsigned int host_number; /* ECPF supports one external host */
 };
 
 /* E-Switch MC FDB table hash node */
index d2516922d8678b1678a454b71e9487f5ac607e6b..b381cbca5852cd96c3fd02656bf97b806ca3db2d 100644 (file)
@@ -2110,6 +2110,24 @@ int mlx5_esw_funcs_changed_handler(struct notifier_block *nb, unsigned long type
        return NOTIFY_OK;
 }
 
+static int mlx5_esw_host_number_init(struct mlx5_eswitch *esw)
+{
+       const u32 *query_host_out;
+
+       if (!mlx5_core_is_ecpf_esw_manager(esw->dev))
+               return 0;
+
+       query_host_out = mlx5_esw_query_functions(esw->dev);
+       if (IS_ERR(query_host_out))
+               return PTR_ERR(query_host_out);
+
+       /* Mark non local controller with non zero controller number. */
+       esw->offloads.host_number = MLX5_GET(query_esw_functions_out, query_host_out,
+                                            host_params_context.host_number);
+       kvfree(query_host_out);
+       return 0;
+}
+
 int esw_offloads_enable(struct mlx5_eswitch *esw)
 {
        struct mlx5_vport *vport;
@@ -2124,6 +2142,10 @@ int esw_offloads_enable(struct mlx5_eswitch *esw)
        mutex_init(&esw->offloads.termtbl_mutex);
        mlx5_rdma_enable_roce(esw->dev);
 
+       err = mlx5_esw_host_number_init(esw);
+       if (err)
+               goto err_vport_metadata;
+
        err = esw_set_passing_vport_metadata(esw, true);
        if (err)
                goto err_vport_metadata;