@@ -4554,7 +4554,7 @@ static void mlx5_ib_cleanup_multiport_master(struct mlx5_ib_dev *dev)
4554
4554
mlx5_nic_vport_disable_roce (dev -> mdev );
4555
4555
}
4556
4556
4557
- static void mlx5_ib_stage_init_cleanup (struct mlx5_ib_dev * dev )
4557
+ void mlx5_ib_stage_init_cleanup (struct mlx5_ib_dev * dev )
4558
4558
{
4559
4559
mlx5_ib_cleanup_multiport_master (dev );
4560
4560
#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING
@@ -4563,7 +4563,7 @@ static void mlx5_ib_stage_init_cleanup(struct mlx5_ib_dev *dev)
4563
4563
kfree (dev -> port );
4564
4564
}
4565
4565
4566
- static int mlx5_ib_stage_init_init (struct mlx5_ib_dev * dev )
4566
+ int mlx5_ib_stage_init_init (struct mlx5_ib_dev * dev )
4567
4567
{
4568
4568
struct mlx5_core_dev * mdev = dev -> mdev ;
4569
4569
const char * name ;
@@ -4647,12 +4647,26 @@ static int mlx5_ib_stage_flow_db_init(struct mlx5_ib_dev *dev)
4647
4647
return 0 ;
4648
4648
}
4649
4649
4650
+ int mlx5_ib_stage_rep_flow_db_init (struct mlx5_ib_dev * dev )
4651
+ {
4652
+ struct mlx5_ib_dev * nic_dev ;
4653
+
4654
+ nic_dev = mlx5_ib_get_uplink_ibdev (dev -> mdev -> priv .eswitch );
4655
+
4656
+ if (!nic_dev )
4657
+ return - EINVAL ;
4658
+
4659
+ dev -> flow_db = nic_dev -> flow_db ;
4660
+
4661
+ return 0 ;
4662
+ }
4663
+
4650
4664
static void mlx5_ib_stage_flow_db_cleanup (struct mlx5_ib_dev * dev )
4651
4665
{
4652
4666
kfree (dev -> flow_db );
4653
4667
}
4654
4668
4655
- static int mlx5_ib_stage_caps_init (struct mlx5_ib_dev * dev )
4669
+ int mlx5_ib_stage_caps_init (struct mlx5_ib_dev * dev )
4656
4670
{
4657
4671
struct mlx5_core_dev * mdev = dev -> mdev ;
4658
4672
int err ;
@@ -4793,7 +4807,7 @@ static int mlx5_ib_stage_non_default_cb(struct mlx5_ib_dev *dev)
4793
4807
return 0 ;
4794
4808
}
4795
4809
4796
- static int mlx5_ib_stage_rep_non_default_cb (struct mlx5_ib_dev * dev )
4810
+ int mlx5_ib_stage_rep_non_default_cb (struct mlx5_ib_dev * dev )
4797
4811
{
4798
4812
dev -> ib_dev .get_port_immutable = mlx5_port_rep_immutable ;
4799
4813
dev -> ib_dev .query_port = mlx5_ib_rep_query_port ;
@@ -4905,12 +4919,12 @@ static void mlx5_ib_stage_roce_cleanup(struct mlx5_ib_dev *dev)
4905
4919
}
4906
4920
}
4907
4921
4908
- static int mlx5_ib_stage_dev_res_init (struct mlx5_ib_dev * dev )
4922
+ int mlx5_ib_stage_dev_res_init (struct mlx5_ib_dev * dev )
4909
4923
{
4910
4924
return create_dev_resources (& dev -> devr );
4911
4925
}
4912
4926
4913
- static void mlx5_ib_stage_dev_res_cleanup (struct mlx5_ib_dev * dev )
4927
+ void mlx5_ib_stage_dev_res_cleanup (struct mlx5_ib_dev * dev )
4914
4928
{
4915
4929
destroy_dev_resources (& dev -> devr );
4916
4930
}
@@ -4922,7 +4936,7 @@ static int mlx5_ib_stage_odp_init(struct mlx5_ib_dev *dev)
4922
4936
return mlx5_ib_odp_init_one (dev );
4923
4937
}
4924
4938
4925
- static int mlx5_ib_stage_counters_init (struct mlx5_ib_dev * dev )
4939
+ int mlx5_ib_stage_counters_init (struct mlx5_ib_dev * dev )
4926
4940
{
4927
4941
if (MLX5_CAP_GEN (dev -> mdev , max_qp_cnt )) {
4928
4942
dev -> ib_dev .get_hw_stats = mlx5_ib_get_hw_stats ;
@@ -4934,7 +4948,7 @@ static int mlx5_ib_stage_counters_init(struct mlx5_ib_dev *dev)
4934
4948
return 0 ;
4935
4949
}
4936
4950
4937
- static void mlx5_ib_stage_counters_cleanup (struct mlx5_ib_dev * dev )
4951
+ void mlx5_ib_stage_counters_cleanup (struct mlx5_ib_dev * dev )
4938
4952
{
4939
4953
if (MLX5_CAP_GEN (dev -> mdev , max_qp_cnt ))
4940
4954
mlx5_ib_dealloc_counters (dev );
@@ -4965,7 +4979,7 @@ static void mlx5_ib_stage_uar_cleanup(struct mlx5_ib_dev *dev)
4965
4979
mlx5_put_uars_page (dev -> mdev , dev -> mdev -> priv .uar );
4966
4980
}
4967
4981
4968
- static int mlx5_ib_stage_bfrag_init (struct mlx5_ib_dev * dev )
4982
+ int mlx5_ib_stage_bfrag_init (struct mlx5_ib_dev * dev )
4969
4983
{
4970
4984
int err ;
4971
4985
@@ -4980,28 +4994,28 @@ static int mlx5_ib_stage_bfrag_init(struct mlx5_ib_dev *dev)
4980
4994
return err ;
4981
4995
}
4982
4996
4983
- static void mlx5_ib_stage_bfrag_cleanup (struct mlx5_ib_dev * dev )
4997
+ void mlx5_ib_stage_bfrag_cleanup (struct mlx5_ib_dev * dev )
4984
4998
{
4985
4999
mlx5_free_bfreg (dev -> mdev , & dev -> fp_bfreg );
4986
5000
mlx5_free_bfreg (dev -> mdev , & dev -> bfreg );
4987
5001
}
4988
5002
4989
- static int mlx5_ib_stage_ib_reg_init (struct mlx5_ib_dev * dev )
5003
+ int mlx5_ib_stage_ib_reg_init (struct mlx5_ib_dev * dev )
4990
5004
{
4991
5005
return ib_register_device (& dev -> ib_dev , NULL );
4992
5006
}
4993
5007
4994
- static void mlx5_ib_stage_ib_reg_cleanup (struct mlx5_ib_dev * dev )
5008
+ void mlx5_ib_stage_ib_reg_cleanup (struct mlx5_ib_dev * dev )
4995
5009
{
4996
5010
ib_unregister_device (& dev -> ib_dev );
4997
5011
}
4998
5012
4999
- static int mlx5_ib_stage_umr_res_init (struct mlx5_ib_dev * dev )
5013
+ int mlx5_ib_stage_umr_res_init (struct mlx5_ib_dev * dev )
5000
5014
{
5001
5015
return create_umr_res (dev );
5002
5016
}
5003
5017
5004
- static void mlx5_ib_stage_umr_res_cleanup (struct mlx5_ib_dev * dev )
5018
+ void mlx5_ib_stage_umr_res_cleanup (struct mlx5_ib_dev * dev )
5005
5019
{
5006
5020
destroy_umrc_res (dev );
5007
5021
}
@@ -5018,7 +5032,7 @@ static void mlx5_ib_stage_delay_drop_cleanup(struct mlx5_ib_dev *dev)
5018
5032
cancel_delay_drop (dev );
5019
5033
}
5020
5034
5021
- static int mlx5_ib_stage_class_attr_init (struct mlx5_ib_dev * dev )
5035
+ int mlx5_ib_stage_class_attr_init (struct mlx5_ib_dev * dev )
5022
5036
{
5023
5037
int err ;
5024
5038
int i ;
@@ -5045,9 +5059,9 @@ static void mlx5_ib_stage_rep_reg_cleanup(struct mlx5_ib_dev *dev)
5045
5059
mlx5_ib_unregister_vport_reps (dev );
5046
5060
}
5047
5061
5048
- static void __mlx5_ib_remove (struct mlx5_ib_dev * dev ,
5049
- const struct mlx5_ib_profile * profile ,
5050
- int stage )
5062
+ void __mlx5_ib_remove (struct mlx5_ib_dev * dev ,
5063
+ const struct mlx5_ib_profile * profile ,
5064
+ int stage )
5051
5065
{
5052
5066
/* Number of stages to cleanup */
5053
5067
while (stage ) {
@@ -5061,23 +5075,14 @@ static void __mlx5_ib_remove(struct mlx5_ib_dev *dev,
5061
5075
5062
5076
static void * mlx5_ib_add_slave_port (struct mlx5_core_dev * mdev , u8 port_num );
5063
5077
5064
- static void * __mlx5_ib_add (struct mlx5_core_dev * mdev ,
5065
- const struct mlx5_ib_profile * profile )
5078
+ void * __mlx5_ib_add (struct mlx5_ib_dev * dev ,
5079
+ const struct mlx5_ib_profile * profile )
5066
5080
{
5067
- struct mlx5_ib_dev * dev ;
5068
5081
int err ;
5069
5082
int i ;
5070
5083
5071
5084
printk_once (KERN_INFO "%s" , mlx5_version );
5072
5085
5073
- dev = (struct mlx5_ib_dev * )ib_alloc_device (sizeof (* dev ));
5074
- if (!dev )
5075
- return NULL ;
5076
-
5077
- dev -> mdev = mdev ;
5078
- dev -> num_ports = max (MLX5_CAP_GEN (mdev , num_ports ),
5079
- MLX5_CAP_GEN (mdev , num_vhca_ports ));
5080
-
5081
5086
for (i = 0 ; i < MLX5_IB_STAGE_MAX ; i ++ ) {
5082
5087
if (profile -> stage [i ].init ) {
5083
5088
err = profile -> stage [i ].init (dev );
@@ -5145,6 +5150,48 @@ static const struct mlx5_ib_profile pf_profile = {
5145
5150
NULL ),
5146
5151
};
5147
5152
5153
+ static const struct mlx5_ib_profile nic_rep_profile = {
5154
+ STAGE_CREATE (MLX5_IB_STAGE_INIT ,
5155
+ mlx5_ib_stage_init_init ,
5156
+ mlx5_ib_stage_init_cleanup ),
5157
+ STAGE_CREATE (MLX5_IB_STAGE_FLOW_DB ,
5158
+ mlx5_ib_stage_flow_db_init ,
5159
+ mlx5_ib_stage_flow_db_cleanup ),
5160
+ STAGE_CREATE (MLX5_IB_STAGE_CAPS ,
5161
+ mlx5_ib_stage_caps_init ,
5162
+ NULL ),
5163
+ STAGE_CREATE (MLX5_IB_STAGE_NON_DEFAULT_CB ,
5164
+ mlx5_ib_stage_rep_non_default_cb ,
5165
+ NULL ),
5166
+ STAGE_CREATE (MLX5_IB_STAGE_ROCE ,
5167
+ mlx5_ib_stage_rep_roce_init ,
5168
+ mlx5_ib_stage_rep_roce_cleanup ),
5169
+ STAGE_CREATE (MLX5_IB_STAGE_DEVICE_RESOURCES ,
5170
+ mlx5_ib_stage_dev_res_init ,
5171
+ mlx5_ib_stage_dev_res_cleanup ),
5172
+ STAGE_CREATE (MLX5_IB_STAGE_COUNTERS ,
5173
+ mlx5_ib_stage_counters_init ,
5174
+ mlx5_ib_stage_counters_cleanup ),
5175
+ STAGE_CREATE (MLX5_IB_STAGE_UAR ,
5176
+ mlx5_ib_stage_uar_init ,
5177
+ mlx5_ib_stage_uar_cleanup ),
5178
+ STAGE_CREATE (MLX5_IB_STAGE_BFREG ,
5179
+ mlx5_ib_stage_bfrag_init ,
5180
+ mlx5_ib_stage_bfrag_cleanup ),
5181
+ STAGE_CREATE (MLX5_IB_STAGE_IB_REG ,
5182
+ mlx5_ib_stage_ib_reg_init ,
5183
+ mlx5_ib_stage_ib_reg_cleanup ),
5184
+ STAGE_CREATE (MLX5_IB_STAGE_UMR_RESOURCES ,
5185
+ mlx5_ib_stage_umr_res_init ,
5186
+ mlx5_ib_stage_umr_res_cleanup ),
5187
+ STAGE_CREATE (MLX5_IB_STAGE_CLASS_ATTR ,
5188
+ mlx5_ib_stage_class_attr_init ,
5189
+ NULL ),
5190
+ STAGE_CREATE (MLX5_IB_STAGE_REP_REG ,
5191
+ mlx5_ib_stage_rep_reg_init ,
5192
+ mlx5_ib_stage_rep_reg_cleanup ),
5193
+ };
5194
+
5148
5195
static void * mlx5_ib_add_slave_port (struct mlx5_core_dev * mdev , u8 port_num )
5149
5196
{
5150
5197
struct mlx5_ib_multiport_info * mpi ;
@@ -5190,8 +5237,11 @@ static void *mlx5_ib_add_slave_port(struct mlx5_core_dev *mdev, u8 port_num)
5190
5237
static void * mlx5_ib_add (struct mlx5_core_dev * mdev )
5191
5238
{
5192
5239
enum rdma_link_layer ll ;
5240
+ struct mlx5_ib_dev * dev ;
5193
5241
int port_type_cap ;
5194
5242
5243
+ printk_once (KERN_INFO "%s" , mlx5_version );
5244
+
5195
5245
port_type_cap = MLX5_CAP_GEN (mdev , port_type );
5196
5246
ll = mlx5_port_type_cap_to_rdma_ll (port_type_cap );
5197
5247
@@ -5201,7 +5251,22 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
5201
5251
return mlx5_ib_add_slave_port (mdev , port_num );
5202
5252
}
5203
5253
5204
- return __mlx5_ib_add (mdev , & pf_profile );
5254
+ dev = (struct mlx5_ib_dev * )ib_alloc_device (sizeof (* dev ));
5255
+ if (!dev )
5256
+ return NULL ;
5257
+
5258
+ dev -> mdev = mdev ;
5259
+ dev -> num_ports = max (MLX5_CAP_GEN (mdev , num_ports ),
5260
+ MLX5_CAP_GEN (mdev , num_vhca_ports ));
5261
+
5262
+ if (MLX5_VPORT_MANAGER (mdev ) &&
5263
+ mlx5_ib_eswitch_mode (mdev -> priv .eswitch ) == SRIOV_OFFLOADS ) {
5264
+ dev -> rep = mlx5_ib_vport_rep (mdev -> priv .eswitch , 0 );
5265
+
5266
+ return __mlx5_ib_add (dev , & nic_rep_profile );
5267
+ }
5268
+
5269
+ return __mlx5_ib_add (dev , & pf_profile );
5205
5270
}
5206
5271
5207
5272
static void mlx5_ib_remove (struct mlx5_core_dev * mdev , void * context )
0 commit comments