@@ -96,7 +96,7 @@ static struct notifier_block ibdev_lsm_nb = {
96
96
97
97
static int ib_device_check_mandatory (struct ib_device * device )
98
98
{
99
- #define IB_MANDATORY_FUNC (x ) { offsetof(struct ib_device , x), #x }
99
+ #define IB_MANDATORY_FUNC (x ) { offsetof(struct ib_device_ops , x), #x }
100
100
static const struct {
101
101
size_t offset ;
102
102
char * name ;
@@ -122,7 +122,8 @@ static int ib_device_check_mandatory(struct ib_device *device)
122
122
int i ;
123
123
124
124
for (i = 0 ; i < ARRAY_SIZE (mandatory_table ); ++ i ) {
125
- if (!* (void * * ) ((void * ) device + mandatory_table [i ].offset )) {
125
+ if (!* (void * * ) ((void * ) & device -> ops +
126
+ mandatory_table [i ].offset )) {
126
127
dev_warn (& device -> dev ,
127
128
"Device is missing mandatory function %s\n" ,
128
129
mandatory_table [i ].name );
@@ -373,8 +374,8 @@ static int read_port_immutable(struct ib_device *device)
373
374
return - ENOMEM ;
374
375
375
376
for (port = start_port ; port <= end_port ; ++ port ) {
376
- ret = device -> get_port_immutable (device , port ,
377
- & device -> port_immutable [port ]);
377
+ ret = device -> ops . get_port_immutable (
378
+ device , port , & device -> port_immutable [port ]);
378
379
if (ret )
379
380
return ret ;
380
381
@@ -386,8 +387,8 @@ static int read_port_immutable(struct ib_device *device)
386
387
387
388
void ib_get_device_fw_str (struct ib_device * dev , char * str )
388
389
{
389
- if (dev -> get_dev_fw_str )
390
- dev -> get_dev_fw_str (dev , str );
390
+ if (dev -> ops . get_dev_fw_str )
391
+ dev -> ops . get_dev_fw_str (dev , str );
391
392
else
392
393
str [0 ] = '\0' ;
393
394
}
@@ -536,7 +537,7 @@ static int setup_device(struct ib_device *device)
536
537
}
537
538
538
539
memset (& device -> attrs , 0 , sizeof (device -> attrs ));
539
- ret = device -> query_device (device , & device -> attrs , & uhw );
540
+ ret = device -> ops . query_device (device , & device -> attrs , & uhw );
540
541
if (ret ) {
541
542
dev_warn (& device -> dev ,
542
543
"Couldn't query the device attributes\n" );
@@ -923,14 +924,14 @@ int ib_query_port(struct ib_device *device,
923
924
return - EINVAL ;
924
925
925
926
memset (port_attr , 0 , sizeof (* port_attr ));
926
- err = device -> query_port (device , port_num , port_attr );
927
+ err = device -> ops . query_port (device , port_num , port_attr );
927
928
if (err || port_attr -> subnet_prefix )
928
929
return err ;
929
930
930
931
if (rdma_port_get_link_layer (device , port_num ) != IB_LINK_LAYER_INFINIBAND )
931
932
return 0 ;
932
933
933
- err = device -> query_gid (device , port_num , 0 , & gid );
934
+ err = device -> ops . query_gid (device , port_num , 0 , & gid );
934
935
if (err )
935
936
return err ;
936
937
@@ -964,8 +965,8 @@ void ib_enum_roce_netdev(struct ib_device *ib_dev,
964
965
if (rdma_protocol_roce (ib_dev , port )) {
965
966
struct net_device * idev = NULL ;
966
967
967
- if (ib_dev -> get_netdev )
968
- idev = ib_dev -> get_netdev (ib_dev , port );
968
+ if (ib_dev -> ops . get_netdev )
969
+ idev = ib_dev -> ops . get_netdev (ib_dev , port );
969
970
970
971
if (idev &&
971
972
idev -> reg_state >= NETREG_UNREGISTERED ) {
@@ -1045,7 +1046,7 @@ int ib_query_pkey(struct ib_device *device,
1045
1046
if (!rdma_is_port_valid (device , port_num ))
1046
1047
return - EINVAL ;
1047
1048
1048
- return device -> query_pkey (device , port_num , index , pkey );
1049
+ return device -> ops . query_pkey (device , port_num , index , pkey );
1049
1050
}
1050
1051
EXPORT_SYMBOL (ib_query_pkey );
1051
1052
@@ -1062,11 +1063,11 @@ int ib_modify_device(struct ib_device *device,
1062
1063
int device_modify_mask ,
1063
1064
struct ib_device_modify * device_modify )
1064
1065
{
1065
- if (!device -> modify_device )
1066
+ if (!device -> ops . modify_device )
1066
1067
return - ENOSYS ;
1067
1068
1068
- return device -> modify_device (device , device_modify_mask ,
1069
- device_modify );
1069
+ return device -> ops . modify_device (device , device_modify_mask ,
1070
+ device_modify );
1070
1071
}
1071
1072
EXPORT_SYMBOL (ib_modify_device );
1072
1073
@@ -1090,9 +1091,10 @@ int ib_modify_port(struct ib_device *device,
1090
1091
if (!rdma_is_port_valid (device , port_num ))
1091
1092
return - EINVAL ;
1092
1093
1093
- if (device -> modify_port )
1094
- rc = device -> modify_port (device , port_num , port_modify_mask ,
1095
- port_modify );
1094
+ if (device -> ops .modify_port )
1095
+ rc = device -> ops .modify_port (device , port_num ,
1096
+ port_modify_mask ,
1097
+ port_modify );
1096
1098
else
1097
1099
rc = rdma_protocol_roce (device , port_num ) ? 0 : - ENOSYS ;
1098
1100
return rc ;
@@ -1221,99 +1223,100 @@ EXPORT_SYMBOL(ib_get_net_dev_by_params);
1221
1223
1222
1224
void ib_set_device_ops (struct ib_device * dev , const struct ib_device_ops * ops )
1223
1225
{
1226
+ struct ib_device_ops * dev_ops = & dev -> ops ;
1224
1227
#define SET_DEVICE_OP (ptr , name ) \
1225
1228
do { \
1226
1229
if (ops->name) \
1227
1230
if (!((ptr)->name)) \
1228
1231
(ptr)->name = ops->name; \
1229
1232
} while (0)
1230
1233
1231
- SET_DEVICE_OP (dev , add_gid );
1232
- SET_DEVICE_OP (dev , alloc_dm );
1233
- SET_DEVICE_OP (dev , alloc_fmr );
1234
- SET_DEVICE_OP (dev , alloc_hw_stats );
1235
- SET_DEVICE_OP (dev , alloc_mr );
1236
- SET_DEVICE_OP (dev , alloc_mw );
1237
- SET_DEVICE_OP (dev , alloc_pd );
1238
- SET_DEVICE_OP (dev , alloc_rdma_netdev );
1239
- SET_DEVICE_OP (dev , alloc_ucontext );
1240
- SET_DEVICE_OP (dev , alloc_xrcd );
1241
- SET_DEVICE_OP (dev , attach_mcast );
1242
- SET_DEVICE_OP (dev , check_mr_status );
1243
- SET_DEVICE_OP (dev , create_ah );
1244
- SET_DEVICE_OP (dev , create_counters );
1245
- SET_DEVICE_OP (dev , create_cq );
1246
- SET_DEVICE_OP (dev , create_flow );
1247
- SET_DEVICE_OP (dev , create_flow_action_esp );
1248
- SET_DEVICE_OP (dev , create_qp );
1249
- SET_DEVICE_OP (dev , create_rwq_ind_table );
1250
- SET_DEVICE_OP (dev , create_srq );
1251
- SET_DEVICE_OP (dev , create_wq );
1252
- SET_DEVICE_OP (dev , dealloc_dm );
1253
- SET_DEVICE_OP (dev , dealloc_fmr );
1254
- SET_DEVICE_OP (dev , dealloc_mw );
1255
- SET_DEVICE_OP (dev , dealloc_pd );
1256
- SET_DEVICE_OP (dev , dealloc_ucontext );
1257
- SET_DEVICE_OP (dev , dealloc_xrcd );
1258
- SET_DEVICE_OP (dev , del_gid );
1259
- SET_DEVICE_OP (dev , dereg_mr );
1260
- SET_DEVICE_OP (dev , destroy_ah );
1261
- SET_DEVICE_OP (dev , destroy_counters );
1262
- SET_DEVICE_OP (dev , destroy_cq );
1263
- SET_DEVICE_OP (dev , destroy_flow );
1264
- SET_DEVICE_OP (dev , destroy_flow_action );
1265
- SET_DEVICE_OP (dev , destroy_qp );
1266
- SET_DEVICE_OP (dev , destroy_rwq_ind_table );
1267
- SET_DEVICE_OP (dev , destroy_srq );
1268
- SET_DEVICE_OP (dev , destroy_wq );
1269
- SET_DEVICE_OP (dev , detach_mcast );
1270
- SET_DEVICE_OP (dev , disassociate_ucontext );
1271
- SET_DEVICE_OP (dev , drain_rq );
1272
- SET_DEVICE_OP (dev , drain_sq );
1273
- SET_DEVICE_OP (dev , get_dev_fw_str );
1274
- SET_DEVICE_OP (dev , get_dma_mr );
1275
- SET_DEVICE_OP (dev , get_hw_stats );
1276
- SET_DEVICE_OP (dev , get_link_layer );
1277
- SET_DEVICE_OP (dev , get_netdev );
1278
- SET_DEVICE_OP (dev , get_port_immutable );
1279
- SET_DEVICE_OP (dev , get_vector_affinity );
1280
- SET_DEVICE_OP (dev , get_vf_config );
1281
- SET_DEVICE_OP (dev , get_vf_stats );
1282
- SET_DEVICE_OP (dev , map_mr_sg );
1283
- SET_DEVICE_OP (dev , map_phys_fmr );
1284
- SET_DEVICE_OP (dev , mmap );
1285
- SET_DEVICE_OP (dev , modify_ah );
1286
- SET_DEVICE_OP (dev , modify_cq );
1287
- SET_DEVICE_OP (dev , modify_device );
1288
- SET_DEVICE_OP (dev , modify_flow_action_esp );
1289
- SET_DEVICE_OP (dev , modify_port );
1290
- SET_DEVICE_OP (dev , modify_qp );
1291
- SET_DEVICE_OP (dev , modify_srq );
1292
- SET_DEVICE_OP (dev , modify_wq );
1293
- SET_DEVICE_OP (dev , peek_cq );
1294
- SET_DEVICE_OP (dev , poll_cq );
1295
- SET_DEVICE_OP (dev , post_recv );
1296
- SET_DEVICE_OP (dev , post_send );
1297
- SET_DEVICE_OP (dev , post_srq_recv );
1298
- SET_DEVICE_OP (dev , process_mad );
1299
- SET_DEVICE_OP (dev , query_ah );
1300
- SET_DEVICE_OP (dev , query_device );
1301
- SET_DEVICE_OP (dev , query_gid );
1302
- SET_DEVICE_OP (dev , query_pkey );
1303
- SET_DEVICE_OP (dev , query_port );
1304
- SET_DEVICE_OP (dev , query_qp );
1305
- SET_DEVICE_OP (dev , query_srq );
1306
- SET_DEVICE_OP (dev , rdma_netdev_get_params );
1307
- SET_DEVICE_OP (dev , read_counters );
1308
- SET_DEVICE_OP (dev , reg_dm_mr );
1309
- SET_DEVICE_OP (dev , reg_user_mr );
1310
- SET_DEVICE_OP (dev , req_ncomp_notif );
1311
- SET_DEVICE_OP (dev , req_notify_cq );
1312
- SET_DEVICE_OP (dev , rereg_user_mr );
1313
- SET_DEVICE_OP (dev , resize_cq );
1314
- SET_DEVICE_OP (dev , set_vf_guid );
1315
- SET_DEVICE_OP (dev , set_vf_link_state );
1316
- SET_DEVICE_OP (dev , unmap_fmr );
1234
+ SET_DEVICE_OP (dev_ops , add_gid );
1235
+ SET_DEVICE_OP (dev_ops , alloc_dm );
1236
+ SET_DEVICE_OP (dev_ops , alloc_fmr );
1237
+ SET_DEVICE_OP (dev_ops , alloc_hw_stats );
1238
+ SET_DEVICE_OP (dev_ops , alloc_mr );
1239
+ SET_DEVICE_OP (dev_ops , alloc_mw );
1240
+ SET_DEVICE_OP (dev_ops , alloc_pd );
1241
+ SET_DEVICE_OP (dev_ops , alloc_rdma_netdev );
1242
+ SET_DEVICE_OP (dev_ops , alloc_ucontext );
1243
+ SET_DEVICE_OP (dev_ops , alloc_xrcd );
1244
+ SET_DEVICE_OP (dev_ops , attach_mcast );
1245
+ SET_DEVICE_OP (dev_ops , check_mr_status );
1246
+ SET_DEVICE_OP (dev_ops , create_ah );
1247
+ SET_DEVICE_OP (dev_ops , create_counters );
1248
+ SET_DEVICE_OP (dev_ops , create_cq );
1249
+ SET_DEVICE_OP (dev_ops , create_flow );
1250
+ SET_DEVICE_OP (dev_ops , create_flow_action_esp );
1251
+ SET_DEVICE_OP (dev_ops , create_qp );
1252
+ SET_DEVICE_OP (dev_ops , create_rwq_ind_table );
1253
+ SET_DEVICE_OP (dev_ops , create_srq );
1254
+ SET_DEVICE_OP (dev_ops , create_wq );
1255
+ SET_DEVICE_OP (dev_ops , dealloc_dm );
1256
+ SET_DEVICE_OP (dev_ops , dealloc_fmr );
1257
+ SET_DEVICE_OP (dev_ops , dealloc_mw );
1258
+ SET_DEVICE_OP (dev_ops , dealloc_pd );
1259
+ SET_DEVICE_OP (dev_ops , dealloc_ucontext );
1260
+ SET_DEVICE_OP (dev_ops , dealloc_xrcd );
1261
+ SET_DEVICE_OP (dev_ops , del_gid );
1262
+ SET_DEVICE_OP (dev_ops , dereg_mr );
1263
+ SET_DEVICE_OP (dev_ops , destroy_ah );
1264
+ SET_DEVICE_OP (dev_ops , destroy_counters );
1265
+ SET_DEVICE_OP (dev_ops , destroy_cq );
1266
+ SET_DEVICE_OP (dev_ops , destroy_flow );
1267
+ SET_DEVICE_OP (dev_ops , destroy_flow_action );
1268
+ SET_DEVICE_OP (dev_ops , destroy_qp );
1269
+ SET_DEVICE_OP (dev_ops , destroy_rwq_ind_table );
1270
+ SET_DEVICE_OP (dev_ops , destroy_srq );
1271
+ SET_DEVICE_OP (dev_ops , destroy_wq );
1272
+ SET_DEVICE_OP (dev_ops , detach_mcast );
1273
+ SET_DEVICE_OP (dev_ops , disassociate_ucontext );
1274
+ SET_DEVICE_OP (dev_ops , drain_rq );
1275
+ SET_DEVICE_OP (dev_ops , drain_sq );
1276
+ SET_DEVICE_OP (dev_ops , get_dev_fw_str );
1277
+ SET_DEVICE_OP (dev_ops , get_dma_mr );
1278
+ SET_DEVICE_OP (dev_ops , get_hw_stats );
1279
+ SET_DEVICE_OP (dev_ops , get_link_layer );
1280
+ SET_DEVICE_OP (dev_ops , get_netdev );
1281
+ SET_DEVICE_OP (dev_ops , get_port_immutable );
1282
+ SET_DEVICE_OP (dev_ops , get_vector_affinity );
1283
+ SET_DEVICE_OP (dev_ops , get_vf_config );
1284
+ SET_DEVICE_OP (dev_ops , get_vf_stats );
1285
+ SET_DEVICE_OP (dev_ops , map_mr_sg );
1286
+ SET_DEVICE_OP (dev_ops , map_phys_fmr );
1287
+ SET_DEVICE_OP (dev_ops , mmap );
1288
+ SET_DEVICE_OP (dev_ops , modify_ah );
1289
+ SET_DEVICE_OP (dev_ops , modify_cq );
1290
+ SET_DEVICE_OP (dev_ops , modify_device );
1291
+ SET_DEVICE_OP (dev_ops , modify_flow_action_esp );
1292
+ SET_DEVICE_OP (dev_ops , modify_port );
1293
+ SET_DEVICE_OP (dev_ops , modify_qp );
1294
+ SET_DEVICE_OP (dev_ops , modify_srq );
1295
+ SET_DEVICE_OP (dev_ops , modify_wq );
1296
+ SET_DEVICE_OP (dev_ops , peek_cq );
1297
+ SET_DEVICE_OP (dev_ops , poll_cq );
1298
+ SET_DEVICE_OP (dev_ops , post_recv );
1299
+ SET_DEVICE_OP (dev_ops , post_send );
1300
+ SET_DEVICE_OP (dev_ops , post_srq_recv );
1301
+ SET_DEVICE_OP (dev_ops , process_mad );
1302
+ SET_DEVICE_OP (dev_ops , query_ah );
1303
+ SET_DEVICE_OP (dev_ops , query_device );
1304
+ SET_DEVICE_OP (dev_ops , query_gid );
1305
+ SET_DEVICE_OP (dev_ops , query_pkey );
1306
+ SET_DEVICE_OP (dev_ops , query_port );
1307
+ SET_DEVICE_OP (dev_ops , query_qp );
1308
+ SET_DEVICE_OP (dev_ops , query_srq );
1309
+ SET_DEVICE_OP (dev_ops , rdma_netdev_get_params );
1310
+ SET_DEVICE_OP (dev_ops , read_counters );
1311
+ SET_DEVICE_OP (dev_ops , reg_dm_mr );
1312
+ SET_DEVICE_OP (dev_ops , reg_user_mr );
1313
+ SET_DEVICE_OP (dev_ops , req_ncomp_notif );
1314
+ SET_DEVICE_OP (dev_ops , req_notify_cq );
1315
+ SET_DEVICE_OP (dev_ops , rereg_user_mr );
1316
+ SET_DEVICE_OP (dev_ops , resize_cq );
1317
+ SET_DEVICE_OP (dev_ops , set_vf_guid );
1318
+ SET_DEVICE_OP (dev_ops , set_vf_link_state );
1319
+ SET_DEVICE_OP (dev_ops , unmap_fmr );
1317
1320
}
1318
1321
EXPORT_SYMBOL (ib_set_device_ops );
1319
1322
0 commit comments