Skip to content

Commit 0de60af

Browse files
Achiad Shochatdledford
authored andcommitted
net/mlx5_core: Introduce access functions to enable/disable RoCE
A mlx5 Ethernet port must be explicitly enabled for RoCE. When RoCE is not enabled on the port, the NIC will refuse to create QPs attached to it and incoming RoCE packets will be considered by the NIC as plain Ethernet packets. Signed-off-by: Achiad Shochat <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent e5f6175 commit 0de60af

File tree

2 files changed

+55
-0
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core
  • include/linux/mlx5

2 files changed

+55
-0
lines changed

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ static int mlx5_query_nic_vport_context(struct mlx5_core_dev *mdev, u32 *out,
7070
return mlx5_cmd_exec_check_status(mdev, in, sizeof(in), out, outlen);
7171
}
7272

73+
static int mlx5_modify_nic_vport_context(struct mlx5_core_dev *mdev, void *in,
74+
int inlen)
75+
{
76+
u32 out[MLX5_ST_SZ_DW(modify_nic_vport_context_out)];
77+
78+
MLX5_SET(modify_nic_vport_context_in, in, opcode,
79+
MLX5_CMD_OP_MODIFY_NIC_VPORT_CONTEXT);
80+
81+
return mlx5_cmd_exec_check_status(mdev, in, inlen, out, sizeof(out));
82+
}
83+
7384
void mlx5_query_nic_vport_mac_address(struct mlx5_core_dev *mdev, u8 *addr)
7485
{
7586
u32 *out;
@@ -350,3 +361,44 @@ int mlx5_query_hca_vport_node_guid(struct mlx5_core_dev *dev,
350361
return err;
351362
}
352363
EXPORT_SYMBOL_GPL(mlx5_query_hca_vport_node_guid);
364+
365+
enum mlx5_vport_roce_state {
366+
MLX5_VPORT_ROCE_DISABLED = 0,
367+
MLX5_VPORT_ROCE_ENABLED = 1,
368+
};
369+
370+
static int mlx5_nic_vport_update_roce_state(struct mlx5_core_dev *mdev,
371+
enum mlx5_vport_roce_state state)
372+
{
373+
void *in;
374+
int inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in);
375+
int err;
376+
377+
in = mlx5_vzalloc(inlen);
378+
if (!in) {
379+
mlx5_core_warn(mdev, "failed to allocate inbox\n");
380+
return -ENOMEM;
381+
}
382+
383+
MLX5_SET(modify_nic_vport_context_in, in, field_select.roce_en, 1);
384+
MLX5_SET(modify_nic_vport_context_in, in, nic_vport_context.roce_en,
385+
state);
386+
387+
err = mlx5_modify_nic_vport_context(mdev, in, inlen);
388+
389+
kvfree(in);
390+
391+
return err;
392+
}
393+
394+
int mlx5_nic_vport_enable_roce(struct mlx5_core_dev *mdev)
395+
{
396+
return mlx5_nic_vport_update_roce_state(mdev, MLX5_VPORT_ROCE_ENABLED);
397+
}
398+
EXPORT_SYMBOL_GPL(mlx5_nic_vport_enable_roce);
399+
400+
int mlx5_nic_vport_disable_roce(struct mlx5_core_dev *mdev)
401+
{
402+
return mlx5_nic_vport_update_roce_state(mdev, MLX5_VPORT_ROCE_DISABLED);
403+
}
404+
EXPORT_SYMBOL_GPL(mlx5_nic_vport_disable_roce);

include/linux/mlx5/vport.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,7 @@ int mlx5_query_hca_vport_system_image_guid(struct mlx5_core_dev *dev,
5252
int mlx5_query_hca_vport_node_guid(struct mlx5_core_dev *dev,
5353
u64 *node_guid);
5454

55+
int mlx5_nic_vport_enable_roce(struct mlx5_core_dev *mdev);
56+
int mlx5_nic_vport_disable_roce(struct mlx5_core_dev *mdev);
57+
5558
#endif /* __MLX5_VPORT_H__ */

0 commit comments

Comments
 (0)