Skip to content

Commit 1f324bf

Browse files
Eli Cohendledford
authored andcommitted
net/mlx5_core: Implement modify HCA vport command
Implement the modify HCA vport commands used to modify the parameters of virtual HCA's ports. Signed-off-by: Eli Cohen <eli@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 2a4826f commit 1f324bf

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,12 @@ static int mlx5_internal_err_ret_value(struct mlx5_core_dev *dev, u16 op,
407407
const char *mlx5_command_str(int command)
408408
{
409409
switch (command) {
410+
case MLX5_CMD_OP_QUERY_HCA_VPORT_CONTEXT:
411+
return "QUERY_HCA_VPORT_CONTEXT";
412+
413+
case MLX5_CMD_OP_MODIFY_HCA_VPORT_CONTEXT:
414+
return "MODIFY_HCA_VPORT_CONTEXT";
415+
410416
case MLX5_CMD_OP_QUERY_HCA_CAP:
411417
return "QUERY_HCA_CAP";
412418

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

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,3 +891,70 @@ int mlx5_core_query_vport_counter(struct mlx5_core_dev *dev, u8 other_vport,
891891
return err;
892892
}
893893
EXPORT_SYMBOL_GPL(mlx5_core_query_vport_counter);
894+
895+
int mlx5_core_modify_hca_vport_context(struct mlx5_core_dev *dev,
896+
u8 other_vport, u8 port_num,
897+
int vf,
898+
struct mlx5_hca_vport_context *req)
899+
{
900+
int in_sz = MLX5_ST_SZ_BYTES(modify_hca_vport_context_in);
901+
u8 out[MLX5_ST_SZ_BYTES(modify_hca_vport_context_out)];
902+
int is_group_manager;
903+
void *in;
904+
int err;
905+
void *ctx;
906+
907+
mlx5_core_dbg(dev, "vf %d\n", vf);
908+
is_group_manager = MLX5_CAP_GEN(dev, vport_group_manager);
909+
in = kzalloc(in_sz, GFP_KERNEL);
910+
if (!in)
911+
return -ENOMEM;
912+
913+
memset(out, 0, sizeof(out));
914+
MLX5_SET(modify_hca_vport_context_in, in, opcode, MLX5_CMD_OP_MODIFY_HCA_VPORT_CONTEXT);
915+
if (other_vport) {
916+
if (is_group_manager) {
917+
MLX5_SET(modify_hca_vport_context_in, in, other_vport, 1);
918+
MLX5_SET(modify_hca_vport_context_in, in, vport_number, vf);
919+
} else {
920+
err = -EPERM;
921+
goto ex;
922+
}
923+
}
924+
925+
if (MLX5_CAP_GEN(dev, num_ports) > 1)
926+
MLX5_SET(modify_hca_vport_context_in, in, port_num, port_num);
927+
928+
ctx = MLX5_ADDR_OF(modify_hca_vport_context_in, in, hca_vport_context);
929+
MLX5_SET(hca_vport_context, ctx, field_select, req->field_select);
930+
MLX5_SET(hca_vport_context, ctx, sm_virt_aware, req->sm_virt_aware);
931+
MLX5_SET(hca_vport_context, ctx, has_smi, req->has_smi);
932+
MLX5_SET(hca_vport_context, ctx, has_raw, req->has_raw);
933+
MLX5_SET(hca_vport_context, ctx, vport_state_policy, req->policy);
934+
MLX5_SET(hca_vport_context, ctx, port_physical_state, req->phys_state);
935+
MLX5_SET(hca_vport_context, ctx, vport_state, req->vport_state);
936+
MLX5_SET64(hca_vport_context, ctx, port_guid, req->port_guid);
937+
MLX5_SET64(hca_vport_context, ctx, node_guid, req->node_guid);
938+
MLX5_SET(hca_vport_context, ctx, cap_mask1, req->cap_mask1);
939+
MLX5_SET(hca_vport_context, ctx, cap_mask1_field_select, req->cap_mask1_perm);
940+
MLX5_SET(hca_vport_context, ctx, cap_mask2, req->cap_mask2);
941+
MLX5_SET(hca_vport_context, ctx, cap_mask2_field_select, req->cap_mask2_perm);
942+
MLX5_SET(hca_vport_context, ctx, lid, req->lid);
943+
MLX5_SET(hca_vport_context, ctx, init_type_reply, req->init_type_reply);
944+
MLX5_SET(hca_vport_context, ctx, lmc, req->lmc);
945+
MLX5_SET(hca_vport_context, ctx, subnet_timeout, req->subnet_timeout);
946+
MLX5_SET(hca_vport_context, ctx, sm_lid, req->sm_lid);
947+
MLX5_SET(hca_vport_context, ctx, sm_sl, req->sm_sl);
948+
MLX5_SET(hca_vport_context, ctx, qkey_violation_counter, req->qkey_violation_counter);
949+
MLX5_SET(hca_vport_context, ctx, pkey_violation_counter, req->pkey_violation_counter);
950+
err = mlx5_cmd_exec(dev, in, in_sz, out, sizeof(out));
951+
if (err)
952+
goto ex;
953+
954+
err = mlx5_cmd_status_to_err_v2(out);
955+
956+
ex:
957+
kfree(in);
958+
return err;
959+
}
960+
EXPORT_SYMBOL_GPL(mlx5_core_modify_hca_vport_context);

include/linux/mlx5/vport.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,9 @@ int mlx5_nic_vport_disable_roce(struct mlx5_core_dev *mdev);
9595
int mlx5_core_query_vport_counter(struct mlx5_core_dev *dev, u8 other_vport,
9696
int vf, u8 port_num, void *out,
9797
size_t out_sz);
98+
int mlx5_core_modify_hca_vport_context(struct mlx5_core_dev *dev,
99+
u8 other_vport, u8 port_num,
100+
int vf,
101+
struct mlx5_hca_vport_context *req);
98102

99103
#endif /* __MLX5_VPORT_H__ */

0 commit comments

Comments
 (0)