@@ -1012,14 +1012,14 @@ static int get_per_qp_prio(struct mlx5_ib_dev *dev,
10121012 return 0 ;
10131013}
10141014
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 )
10171017{
10181018 struct mlx5_per_qp_opfc * per_qp_opfc ;
10191019
10201020 * new = false;
10211021
1022- per_qp_opfc = xa_load (& mcounter -> qpn_opfc_xa , qp_num );
1022+ per_qp_opfc = xa_load (qpn_opfc_xa , qp_num );
10231023 if (per_qp_opfc )
10241024 return per_qp_opfc ;
10251025 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)
10321032}
10331033
10341034static 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 ,
10361037 struct mlx5_per_qp_opfc * per_qp_opfc ,
10371038 struct mlx5_ib_flow_prio * prio ,
10381039 enum mlx5_ib_optional_counter_type type ,
@@ -1055,7 +1056,7 @@ static int add_op_fc_rules(struct mlx5_ib_dev *dev,
10551056 return 0 ;
10561057 }
10571058
1058- opfc -> fc = mcounter -> fc [type ];
1059+ opfc -> fc = fc_arr [type ];
10591060
10601061 spec = kcalloc (MAX_OPFC_RULES , sizeof (* spec ), GFP_KERNEL );
10611062 if (!spec ) {
@@ -1148,8 +1149,7 @@ static int add_op_fc_rules(struct mlx5_ib_dev *dev,
11481149 }
11491150 prio -> refcount += spec_num ;
11501151
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 ));
11531153 if (err )
11541154 goto del_rules ;
11551155
@@ -1168,8 +1168,9 @@ static int add_op_fc_rules(struct mlx5_ib_dev *dev,
11681168 return err ;
11691169}
11701170
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 )
11731174{
11741175 u32 shared_fc_type ;
11751176
@@ -1190,32 +1191,31 @@ static bool is_fc_shared_and_in_use(struct mlx5_rdma_counter *mcounter,
11901191 return false;
11911192 }
11921193
1193- * fc = mcounter -> fc [shared_fc_type ];
1194+ * fc = fc_arr [shared_fc_type ];
11941195 if (!(* fc ))
11951196 return false;
11961197
11971198 return true;
11981199}
11991200
12001201void mlx5r_fs_destroy_fcs (struct mlx5_ib_dev * dev ,
1201- struct rdma_counter * counter )
1202+ struct mlx5_fc * fc_arr [ MLX5_IB_OPCOUNTER_MAX ] )
12021203{
1203- struct mlx5_rdma_counter * mcounter = to_mcounter (counter );
12041204 struct mlx5_fc * in_use_fc ;
12051205 int i ;
12061206
12071207 for (i = MLX5_IB_OPCOUNTER_CC_RX_CE_PKTS_PER_QP ;
12081208 i <= MLX5_IB_OPCOUNTER_RDMA_RX_BYTES_PER_QP ; i ++ ) {
1209- if (!mcounter -> fc [i ])
1209+ if (!fc_arr [i ])
12101210 continue ;
12111211
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 ;
12141214 continue ;
12151215 }
12161216
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 ;
12191219 }
12201220}
12211221
@@ -1359,16 +1359,15 @@ void mlx5_ib_fs_remove_op_fc(struct mlx5_ib_dev *dev,
13591359 put_per_qp_prio (dev , type );
13601360}
13611361
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 )
13631363{
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 );
13661365 struct mlx5_per_qp_opfc * per_qp_opfc ;
13671366 struct mlx5_ib_op_fc * in_use_opfc ;
13681367 struct mlx5_ib_flow_prio * prio ;
13691368 int i , j ;
13701369
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 );
13721371 if (!per_qp_opfc )
13731372 return ;
13741373
@@ -1394,13 +1393,13 @@ void mlx5r_fs_unbind_op_fc(struct ib_qp *qp, struct rdma_counter *counter)
13941393 }
13951394
13961395 kfree (per_qp_opfc );
1397- xa_erase (& mcounter -> qpn_opfc_xa , qp -> qp_num );
1396+ xa_erase (qpn_opfc_xa , qp -> qp_num );
13981397}
13991398
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 )
14021402{
1403- struct mlx5_rdma_counter * mcounter = to_mcounter (counter );
14041403 struct mlx5_ib_dev * dev = to_mdev (qp -> device );
14051404 struct mlx5_per_qp_opfc * per_qp_opfc ;
14061405 struct mlx5_ib_flow_prio * prio ;
@@ -1410,9 +1409,6 @@ int mlx5r_fs_bind_op_fc(struct ib_qp *qp, struct rdma_counter *counter,
14101409 int i , err , per_qp_type ;
14111410 bool new ;
14121411
1413- if (!counter -> mode .bind_opcnt )
1414- return 0 ;
1415-
14161412 cnts = & dev -> port [port - 1 ].cnts ;
14171413
14181414 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,
14241420 prio = get_opfc_prio (dev , per_qp_type );
14251421 WARN_ON (!prio -> flow_table );
14261422
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 ;
14291425
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 ]);
14351430 }
14361431
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 );
14381433 if (!per_qp_opfc ) {
14391434 err = - ENOMEM ;
14401435 goto free_fc ;
14411436 }
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 );
14441439 if (err )
14451440 goto del_rules ;
14461441 }
14471442
14481443 return 0 ;
14491444
14501445del_rules :
1451- mlx5r_fs_unbind_op_fc (qp , counter );
1446+ mlx5r_fs_unbind_op_fc (qp , qpn_opfc_xa );
14521447 if (new )
14531448 kfree (per_qp_opfc );
14541449free_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 );
14571452 return err ;
14581453}
14591454
0 commit comments