diff options
author | Hans Petter Selasky <hselasky@FreeBSD.org> | 2017-11-10 13:56:11 +0000 |
---|---|---|
committer | Hans Petter Selasky <hselasky@FreeBSD.org> | 2017-11-10 13:56:11 +0000 |
commit | f4554f78304303330f8c8b61e019cb727ca4d2c1 (patch) | |
tree | 40580463aa2169638f6ad8e3ee7eb9d63eed889d /sys | |
parent | 2fd90b8297ee9b87716400c2e8aa0e584002cfc3 (diff) | |
download | src-f4554f78304303330f8c8b61e019cb727ca4d2c1.tar.gz src-f4554f78304303330f8c8b61e019cb727ca4d2c1.zip |
Add API functions to query and modify local loopback of multicast and
unicast traffic in mlx5 core.
Sponsored by: Mellanox Technologies
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=325656
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/mlx5/mlx5_core/mlx5_vport.c | 66 | ||||
-rw-r--r-- | sys/dev/mlx5/vport.h | 10 |
2 files changed, 76 insertions, 0 deletions
diff --git a/sys/dev/mlx5/mlx5_core/mlx5_vport.c b/sys/dev/mlx5/mlx5_core/mlx5_vport.c index 8a2810894b78..448e16fdb4f1 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_vport.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_vport.c @@ -1485,6 +1485,72 @@ int mlx5_modify_nic_vport_promisc(struct mlx5_core_dev *mdev, } EXPORT_SYMBOL_GPL(mlx5_modify_nic_vport_promisc); +int mlx5_nic_vport_modify_local_lb(struct mlx5_core_dev *mdev, + enum mlx5_local_lb_selection selection, + u8 value) +{ + void *in; + int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in); + int err; + + in = mlx5_vzalloc(inlen); + if (!in) { + mlx5_core_warn(mdev, "failed to allocate inbox\n"); + return -ENOMEM; + } + + MLX5_SET(modify_nic_vport_context_in, in, vport_number, 0); + + if (selection == MLX5_LOCAL_MC_LB) { + MLX5_SET(modify_nic_vport_context_in, in, + field_select.disable_mc_local_lb, 1); + MLX5_SET(modify_nic_vport_context_in, in, + nic_vport_context.disable_mc_local_lb, + value); + } else { + MLX5_SET(modify_nic_vport_context_in, in, + field_select.disable_uc_local_lb, 1); + MLX5_SET(modify_nic_vport_context_in, in, + nic_vport_context.disable_uc_local_lb, + value); + } + + err = mlx5_modify_nic_vport_context(mdev, in, inlen); + + kvfree(in); + return err; +} +EXPORT_SYMBOL_GPL(mlx5_nic_vport_modify_local_lb); + +int mlx5_nic_vport_query_local_lb(struct mlx5_core_dev *mdev, + enum mlx5_local_lb_selection selection, + u8 *value) +{ + void *out; + int outlen = MLX5_ST_SZ_BYTES(query_nic_vport_context_out); + int err; + + out = kzalloc(outlen, GFP_KERNEL); + if (!out) + return -ENOMEM; + + err = mlx5_query_nic_vport_context(mdev, 0, out, outlen); + if (err) + goto done; + + if (selection == MLX5_LOCAL_MC_LB) + *value = MLX5_GET(query_nic_vport_context_out, out, + nic_vport_context.disable_mc_local_lb); + else + *value = MLX5_GET(query_nic_vport_context_out, out, + nic_vport_context.disable_uc_local_lb); + +done: + kfree(out); + return err; +} +EXPORT_SYMBOL_GPL(mlx5_nic_vport_query_local_lb); + int mlx5_query_vport_counter(struct mlx5_core_dev *dev, u8 port_num, u16 vport_num, void *out, int out_size) diff --git a/sys/dev/mlx5/vport.h b/sys/dev/mlx5/vport.h index 07fa5b7d8772..32cfaaeb7da3 100644 --- a/sys/dev/mlx5/vport.h +++ b/sys/dev/mlx5/vport.h @@ -41,7 +41,17 @@ int mlx5_vport_query_q_counter(struct mlx5_core_dev *mdev, int mlx5_vport_query_out_of_rx_buffer(struct mlx5_core_dev *mdev, u16 counter_set_id, u32 *out_of_rx_buffer); +enum mlx5_local_lb_selection { + MLX5_LOCAL_MC_LB, + MLX5_LOCAL_UC_LB +}; +int mlx5_nic_vport_query_local_lb(struct mlx5_core_dev *mdev, + enum mlx5_local_lb_selection selection, + u8 *value); +int mlx5_nic_vport_modify_local_lb(struct mlx5_core_dev *mdev, + enum mlx5_local_lb_selection selection, + u8 value); u8 mlx5_query_vport_state(struct mlx5_core_dev *mdev, u8 opmod, u16 vport); u8 mlx5_query_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod, u16 vport); |