Skip to content

Commit

Permalink
net/mlx5: E-switch, Read controller number from device
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Parav Pandit authored and David S. Miller committed Sep 9, 2020
1 parent 6b5472d commit a53cf94
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
22 changes: 22 additions & 0 deletions drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit a53cf94

Please sign in to comment.