Skip to content

Commit bded747

Browse files
Huy Nguyendledford
authored andcommitted
net/mlx5: Add raw ethernet local loopback firmware command
Add support for raw ethernet local loopback firmware command. Signed-off-by: Huy Nguyen <huyn@mellanox.com> Reviewed-by: Daniel Jurgens <danielj@mellanox.com> Signed-off-by: Leon Romanovsky <leon@kernel.org> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 520eccd commit bded747

File tree

3 files changed

+72
-4
lines changed

3 files changed

+72
-4
lines changed

drivers/net/ethernet/mellanox/mlx5/core/vport.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,68 @@ int mlx5_modify_nic_vport_promisc(struct mlx5_core_dev *mdev,
897897
}
898898
EXPORT_SYMBOL_GPL(mlx5_modify_nic_vport_promisc);
899899

900+
enum {
901+
UC_LOCAL_LB,
902+
MC_LOCAL_LB
903+
};
904+
905+
int mlx5_nic_vport_update_local_lb(struct mlx5_core_dev *mdev, bool enable)
906+
{
907+
int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in);
908+
void *in;
909+
int err;
910+
911+
mlx5_core_dbg(mdev, "%s local_lb\n", enable ? "enable" : "disable");
912+
in = kvzalloc(inlen, GFP_KERNEL);
913+
if (!in)
914+
return -ENOMEM;
915+
916+
MLX5_SET(modify_nic_vport_context_in, in,
917+
field_select.disable_mc_local_lb, 1);
918+
MLX5_SET(modify_nic_vport_context_in, in,
919+
nic_vport_context.disable_mc_local_lb, !enable);
920+
921+
MLX5_SET(modify_nic_vport_context_in, in,
922+
field_select.disable_uc_local_lb, 1);
923+
MLX5_SET(modify_nic_vport_context_in, in,
924+
nic_vport_context.disable_uc_local_lb, !enable);
925+
926+
err = mlx5_modify_nic_vport_context(mdev, in, inlen);
927+
928+
kvfree(in);
929+
return err;
930+
}
931+
EXPORT_SYMBOL_GPL(mlx5_nic_vport_update_local_lb);
932+
933+
int mlx5_nic_vport_query_local_lb(struct mlx5_core_dev *mdev, bool *status)
934+
{
935+
int outlen = MLX5_ST_SZ_BYTES(query_nic_vport_context_out);
936+
u32 *out;
937+
int value;
938+
int err;
939+
940+
out = kzalloc(outlen, GFP_KERNEL);
941+
if (!out)
942+
return -ENOMEM;
943+
944+
err = mlx5_query_nic_vport_context(mdev, 0, out, outlen);
945+
if (err)
946+
goto out;
947+
948+
value = MLX5_GET(query_nic_vport_context_out, out,
949+
nic_vport_context.disable_mc_local_lb) << MC_LOCAL_LB;
950+
951+
value |= MLX5_GET(query_nic_vport_context_out, out,
952+
nic_vport_context.disable_uc_local_lb) << UC_LOCAL_LB;
953+
954+
*status = !value;
955+
956+
out:
957+
kfree(out);
958+
return err;
959+
}
960+
EXPORT_SYMBOL_GPL(mlx5_nic_vport_query_local_lb);
961+
900962
enum mlx5_vport_roce_state {
901963
MLX5_VPORT_ROCE_DISABLED = 0,
902964
MLX5_VPORT_ROCE_ENABLED = 1,

include/linux/mlx5/mlx5_ifc.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,8 @@ struct mlx5_ifc_cmd_hca_cap_bits {
10161016
u8 log_max_wq_sz[0x5];
10171017

10181018
u8 nic_vport_change_event[0x1];
1019-
u8 reserved_at_3e1[0xa];
1019+
u8 disable_local_lb[0x1];
1020+
u8 reserved_at_3e2[0x9];
10201021
u8 log_max_vlan_list[0x5];
10211022
u8 reserved_at_3f0[0x3];
10221023
u8 log_max_current_mc_list[0x5];
@@ -2562,7 +2563,9 @@ struct mlx5_ifc_rmpc_bits {
25622563
struct mlx5_ifc_nic_vport_context_bits {
25632564
u8 reserved_at_0[0x5];
25642565
u8 min_wqe_inline_mode[0x3];
2565-
u8 reserved_at_8[0x17];
2566+
u8 reserved_at_8[0x15];
2567+
u8 disable_mc_local_lb[0x1];
2568+
u8 disable_uc_local_lb[0x1];
25662569
u8 roce_en[0x1];
25672570

25682571
u8 arm_change_event[0x1];
@@ -5229,7 +5232,9 @@ struct mlx5_ifc_modify_nic_vport_context_out_bits {
52295232
};
52305233

52315234
struct mlx5_ifc_modify_nic_vport_field_select_bits {
5232-
u8 reserved_at_0[0x16];
5235+
u8 reserved_at_0[0x14];
5236+
u8 disable_uc_local_lb[0x1];
5237+
u8 disable_mc_local_lb[0x1];
52335238
u8 node_guid[0x1];
52345239
u8 port_guid[0x1];
52355240
u8 min_inline[0x1];

include/linux/mlx5/vport.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,6 @@ int mlx5_core_modify_hca_vport_context(struct mlx5_core_dev *dev,
114114
u8 other_vport, u8 port_num,
115115
int vf,
116116
struct mlx5_hca_vport_context *req);
117-
117+
int mlx5_nic_vport_update_local_lb(struct mlx5_core_dev *mdev, bool enable);
118+
int mlx5_nic_vport_query_local_lb(struct mlx5_core_dev *mdev, bool *status);
118119
#endif /* __MLX5_VPORT_H__ */

0 commit comments

Comments
 (0)