@@ -891,3 +891,70 @@ int mlx5_core_query_vport_counter(struct mlx5_core_dev *dev, u8 other_vport,
891
891
return err ;
892
892
}
893
893
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 );
0 commit comments