@@ -1012,14 +1012,14 @@ static int get_per_qp_prio(struct mlx5_ib_dev *dev,
1012
1012
return 0 ;
1013
1013
}
1014
1014
1015
- static struct mlx5_per_qp_opfc *
1016
- get_per_qp_opfc ( struct mlx5_rdma_counter * mcounter , u32 qp_num , bool * new )
1015
+ static struct mlx5_per_qp_opfc * get_per_qp_opfc ( struct xarray * qpn_opfc_xa ,
1016
+ u32 qp_num , bool * new )
1017
1017
{
1018
1018
struct mlx5_per_qp_opfc * per_qp_opfc ;
1019
1019
1020
1020
* new = false;
1021
1021
1022
- per_qp_opfc = xa_load (& mcounter -> qpn_opfc_xa , qp_num );
1022
+ per_qp_opfc = xa_load (qpn_opfc_xa , qp_num );
1023
1023
if (per_qp_opfc )
1024
1024
return per_qp_opfc ;
1025
1025
per_qp_opfc = kzalloc (sizeof (* per_qp_opfc ), GFP_KERNEL );
@@ -1032,7 +1032,8 @@ get_per_qp_opfc(struct mlx5_rdma_counter *mcounter, u32 qp_num, bool *new)
1032
1032
}
1033
1033
1034
1034
static int add_op_fc_rules (struct mlx5_ib_dev * dev ,
1035
- struct mlx5_rdma_counter * mcounter ,
1035
+ struct mlx5_fc * fc_arr [MLX5_IB_OPCOUNTER_MAX ],
1036
+ struct xarray * qpn_opfc_xa ,
1036
1037
struct mlx5_per_qp_opfc * per_qp_opfc ,
1037
1038
struct mlx5_ib_flow_prio * prio ,
1038
1039
enum mlx5_ib_optional_counter_type type ,
@@ -1055,7 +1056,7 @@ static int add_op_fc_rules(struct mlx5_ib_dev *dev,
1055
1056
return 0 ;
1056
1057
}
1057
1058
1058
- opfc -> fc = mcounter -> fc [type ];
1059
+ opfc -> fc = fc_arr [type ];
1059
1060
1060
1061
spec = kcalloc (MAX_OPFC_RULES , sizeof (* spec ), GFP_KERNEL );
1061
1062
if (!spec ) {
@@ -1148,8 +1149,7 @@ static int add_op_fc_rules(struct mlx5_ib_dev *dev,
1148
1149
}
1149
1150
prio -> refcount += spec_num ;
1150
1151
1151
- err = xa_err (xa_store (& mcounter -> qpn_opfc_xa , qp_num , per_qp_opfc ,
1152
- GFP_KERNEL ));
1152
+ err = xa_err (xa_store (qpn_opfc_xa , qp_num , per_qp_opfc , GFP_KERNEL ));
1153
1153
if (err )
1154
1154
goto del_rules ;
1155
1155
@@ -1168,8 +1168,9 @@ static int add_op_fc_rules(struct mlx5_ib_dev *dev,
1168
1168
return err ;
1169
1169
}
1170
1170
1171
- static bool is_fc_shared_and_in_use (struct mlx5_rdma_counter * mcounter ,
1172
- u32 type , struct mlx5_fc * * fc )
1171
+ static bool
1172
+ is_fc_shared_and_in_use (struct mlx5_fc * fc_arr [MLX5_IB_OPCOUNTER_MAX ], u32 type ,
1173
+ struct mlx5_fc * * fc )
1173
1174
{
1174
1175
u32 shared_fc_type ;
1175
1176
@@ -1190,32 +1191,31 @@ static bool is_fc_shared_and_in_use(struct mlx5_rdma_counter *mcounter,
1190
1191
return false;
1191
1192
}
1192
1193
1193
- * fc = mcounter -> fc [shared_fc_type ];
1194
+ * fc = fc_arr [shared_fc_type ];
1194
1195
if (!(* fc ))
1195
1196
return false;
1196
1197
1197
1198
return true;
1198
1199
}
1199
1200
1200
1201
void mlx5r_fs_destroy_fcs (struct mlx5_ib_dev * dev ,
1201
- struct rdma_counter * counter )
1202
+ struct mlx5_fc * fc_arr [ MLX5_IB_OPCOUNTER_MAX ] )
1202
1203
{
1203
- struct mlx5_rdma_counter * mcounter = to_mcounter (counter );
1204
1204
struct mlx5_fc * in_use_fc ;
1205
1205
int i ;
1206
1206
1207
1207
for (i = MLX5_IB_OPCOUNTER_CC_RX_CE_PKTS_PER_QP ;
1208
1208
i <= MLX5_IB_OPCOUNTER_RDMA_RX_BYTES_PER_QP ; i ++ ) {
1209
- if (!mcounter -> fc [i ])
1209
+ if (!fc_arr [i ])
1210
1210
continue ;
1211
1211
1212
- if (is_fc_shared_and_in_use (mcounter , i , & in_use_fc )) {
1213
- mcounter -> fc [i ] = NULL ;
1212
+ if (is_fc_shared_and_in_use (fc_arr , i , & in_use_fc )) {
1213
+ fc_arr [i ] = NULL ;
1214
1214
continue ;
1215
1215
}
1216
1216
1217
- mlx5_fc_destroy (dev -> mdev , mcounter -> fc [i ]);
1218
- mcounter -> fc [i ] = NULL ;
1217
+ mlx5_fc_destroy (dev -> mdev , fc_arr [i ]);
1218
+ fc_arr [i ] = NULL ;
1219
1219
}
1220
1220
}
1221
1221
@@ -1359,16 +1359,15 @@ void mlx5_ib_fs_remove_op_fc(struct mlx5_ib_dev *dev,
1359
1359
put_per_qp_prio (dev , type );
1360
1360
}
1361
1361
1362
- void mlx5r_fs_unbind_op_fc (struct ib_qp * qp , struct rdma_counter * counter )
1362
+ void mlx5r_fs_unbind_op_fc (struct ib_qp * qp , struct xarray * qpn_opfc_xa )
1363
1363
{
1364
- struct mlx5_rdma_counter * mcounter = to_mcounter (counter );
1365
- struct mlx5_ib_dev * dev = to_mdev (counter -> device );
1364
+ struct mlx5_ib_dev * dev = to_mdev (qp -> device );
1366
1365
struct mlx5_per_qp_opfc * per_qp_opfc ;
1367
1366
struct mlx5_ib_op_fc * in_use_opfc ;
1368
1367
struct mlx5_ib_flow_prio * prio ;
1369
1368
int i , j ;
1370
1369
1371
- per_qp_opfc = xa_load (& mcounter -> qpn_opfc_xa , qp -> qp_num );
1370
+ per_qp_opfc = xa_load (qpn_opfc_xa , qp -> qp_num );
1372
1371
if (!per_qp_opfc )
1373
1372
return ;
1374
1373
@@ -1394,13 +1393,13 @@ void mlx5r_fs_unbind_op_fc(struct ib_qp *qp, struct rdma_counter *counter)
1394
1393
}
1395
1394
1396
1395
kfree (per_qp_opfc );
1397
- xa_erase (& mcounter -> qpn_opfc_xa , qp -> qp_num );
1396
+ xa_erase (qpn_opfc_xa , qp -> qp_num );
1398
1397
}
1399
1398
1400
- int mlx5r_fs_bind_op_fc (struct ib_qp * qp , struct rdma_counter * counter ,
1401
- u32 port )
1399
+ int mlx5r_fs_bind_op_fc (struct ib_qp * qp ,
1400
+ struct mlx5_fc * fc_arr [MLX5_IB_OPCOUNTER_MAX ],
1401
+ struct xarray * qpn_opfc_xa , u32 port )
1402
1402
{
1403
- struct mlx5_rdma_counter * mcounter = to_mcounter (counter );
1404
1403
struct mlx5_ib_dev * dev = to_mdev (qp -> device );
1405
1404
struct mlx5_per_qp_opfc * per_qp_opfc ;
1406
1405
struct mlx5_ib_flow_prio * prio ;
@@ -1410,9 +1409,6 @@ int mlx5r_fs_bind_op_fc(struct ib_qp *qp, struct rdma_counter *counter,
1410
1409
int i , err , per_qp_type ;
1411
1410
bool new ;
1412
1411
1413
- if (!counter -> mode .bind_opcnt )
1414
- return 0 ;
1415
-
1416
1412
cnts = & dev -> port [port - 1 ].cnts ;
1417
1413
1418
1414
for (i = 0 ; i <= MLX5_IB_OPCOUNTER_RDMA_RX_BYTES ; i ++ ) {
@@ -1424,36 +1420,35 @@ int mlx5r_fs_bind_op_fc(struct ib_qp *qp, struct rdma_counter *counter,
1424
1420
prio = get_opfc_prio (dev , per_qp_type );
1425
1421
WARN_ON (!prio -> flow_table );
1426
1422
1427
- if (is_fc_shared_and_in_use (mcounter , per_qp_type , & in_use_fc ))
1428
- mcounter -> fc [per_qp_type ] = in_use_fc ;
1423
+ if (is_fc_shared_and_in_use (fc_arr , per_qp_type , & in_use_fc ))
1424
+ fc_arr [per_qp_type ] = in_use_fc ;
1429
1425
1430
- if (!mcounter -> fc [per_qp_type ]) {
1431
- mcounter -> fc [per_qp_type ] = mlx5_fc_create (dev -> mdev ,
1432
- false);
1433
- if (IS_ERR (mcounter -> fc [per_qp_type ]))
1434
- return PTR_ERR (mcounter -> fc [per_qp_type ]);
1426
+ if (!fc_arr [per_qp_type ]) {
1427
+ fc_arr [per_qp_type ] = mlx5_fc_create (dev -> mdev , false);
1428
+ if (IS_ERR (fc_arr [per_qp_type ]))
1429
+ return PTR_ERR (fc_arr [per_qp_type ]);
1435
1430
}
1436
1431
1437
- per_qp_opfc = get_per_qp_opfc (mcounter , qp -> qp_num , & new );
1432
+ per_qp_opfc = get_per_qp_opfc (qpn_opfc_xa , qp -> qp_num , & new );
1438
1433
if (!per_qp_opfc ) {
1439
1434
err = - ENOMEM ;
1440
1435
goto free_fc ;
1441
1436
}
1442
- err = add_op_fc_rules (dev , mcounter , per_qp_opfc , prio ,
1443
- per_qp_type , qp -> qp_num , port );
1437
+ err = add_op_fc_rules (dev , fc_arr , qpn_opfc_xa , per_qp_opfc ,
1438
+ prio , per_qp_type , qp -> qp_num , port );
1444
1439
if (err )
1445
1440
goto del_rules ;
1446
1441
}
1447
1442
1448
1443
return 0 ;
1449
1444
1450
1445
del_rules :
1451
- mlx5r_fs_unbind_op_fc (qp , counter );
1446
+ mlx5r_fs_unbind_op_fc (qp , qpn_opfc_xa );
1452
1447
if (new )
1453
1448
kfree (per_qp_opfc );
1454
1449
free_fc :
1455
- if (xa_empty (& mcounter -> qpn_opfc_xa ))
1456
- mlx5r_fs_destroy_fcs (dev , counter );
1450
+ if (xa_empty (qpn_opfc_xa ))
1451
+ mlx5r_fs_destroy_fcs (dev , fc_arr );
1457
1452
return err ;
1458
1453
}
1459
1454
0 commit comments