@@ -147,8 +147,39 @@ static void pma_cnt_assign(struct ib_pma_portcounters *pma_cnt,
147
147
vl_15_dropped );
148
148
}
149
149
150
- static int query_ib_ppcnt (struct mlx5_core_dev * dev , u8 port_num , void * out ,
151
- size_t sz )
150
+ static void pma_cnt_ext_assign_ppcnt (struct ib_pma_portcounters_ext * cnt_ext ,
151
+ void * out )
152
+ {
153
+ void * out_pma = MLX5_ADDR_OF (ppcnt_reg , out ,
154
+ counter_set );
155
+
156
+ #define MLX5_GET_EXT_CNTR (counter_name ) \
157
+ MLX5_GET64(ib_ext_port_cntrs_grp_data_layout, \
158
+ out_pma, counter_name##_high)
159
+
160
+ cnt_ext -> port_xmit_data =
161
+ cpu_to_be64 (MLX5_GET_EXT_CNTR (port_xmit_data ) >> 2 );
162
+ cnt_ext -> port_rcv_data =
163
+ cpu_to_be64 (MLX5_GET_EXT_CNTR (port_rcv_data ) >> 2 );
164
+
165
+ cnt_ext -> port_xmit_packets =
166
+ cpu_to_be64 (MLX5_GET_EXT_CNTR (port_xmit_pkts ));
167
+ cnt_ext -> port_rcv_packets =
168
+ cpu_to_be64 (MLX5_GET_EXT_CNTR (port_rcv_pkts ));
169
+
170
+ cnt_ext -> port_unicast_xmit_packets =
171
+ cpu_to_be64 (MLX5_GET_EXT_CNTR (port_unicast_xmit_pkts ));
172
+ cnt_ext -> port_unicast_rcv_packets =
173
+ cpu_to_be64 (MLX5_GET_EXT_CNTR (port_unicast_rcv_pkts ));
174
+
175
+ cnt_ext -> port_multicast_xmit_packets =
176
+ cpu_to_be64 (MLX5_GET_EXT_CNTR (port_multicast_xmit_pkts ));
177
+ cnt_ext -> port_multicast_rcv_packets =
178
+ cpu_to_be64 (MLX5_GET_EXT_CNTR (port_multicast_rcv_pkts ));
179
+ }
180
+
181
+ static int query_ib_ppcnt (struct mlx5_core_dev * dev , u8 port_num , u8 plane_num ,
182
+ void * out , size_t sz , bool ext )
152
183
{
153
184
u32 * in ;
154
185
int err ;
@@ -160,8 +191,14 @@ static int query_ib_ppcnt(struct mlx5_core_dev *dev, u8 port_num, void *out,
160
191
}
161
192
162
193
MLX5_SET (ppcnt_reg , in , local_port , port_num );
163
-
164
- MLX5_SET (ppcnt_reg , in , grp , MLX5_INFINIBAND_PORT_COUNTERS_GROUP );
194
+ MLX5_SET (ppcnt_reg , in , plane_ind , plane_num );
195
+
196
+ if (ext )
197
+ MLX5_SET (ppcnt_reg , in , grp ,
198
+ MLX5_INFINIBAND_EXTENDED_PORT_COUNTERS_GROUP );
199
+ else
200
+ MLX5_SET (ppcnt_reg , in , grp ,
201
+ MLX5_INFINIBAND_PORT_COUNTERS_GROUP );
165
202
err = mlx5_core_access_reg (dev , in , sz , out ,
166
203
sz , MLX5_REG_PPCNT , 0 , 0 );
167
204
@@ -189,7 +226,8 @@ static int process_pma_cmd(struct mlx5_ib_dev *dev, u32 port_num,
189
226
mdev_port_num = 1 ;
190
227
}
191
228
if (MLX5_CAP_GEN (dev -> mdev , num_ports ) == 1 &&
192
- !mlx5_core_mp_enabled (mdev )) {
229
+ !mlx5_core_mp_enabled (mdev ) &&
230
+ dev -> ib_dev .type != RDMA_DEVICE_TYPE_SMI ) {
193
231
/* set local port to one for Function-Per-Port HCA. */
194
232
mdev = dev -> mdev ;
195
233
mdev_port_num = 1 ;
@@ -208,18 +246,27 @@ static int process_pma_cmd(struct mlx5_ib_dev *dev, u32 port_num,
208
246
if (in_mad -> mad_hdr .attr_id == IB_PMA_PORT_COUNTERS_EXT ) {
209
247
struct ib_pma_portcounters_ext * pma_cnt_ext =
210
248
(struct ib_pma_portcounters_ext * )(out_mad -> data + 40 );
211
- int sz = MLX5_ST_SZ_BYTES (query_vport_counter_out );
249
+ int sz = max (MLX5_ST_SZ_BYTES (query_vport_counter_out ),
250
+ MLX5_ST_SZ_BYTES (ppcnt_reg ));
212
251
213
252
out_cnt = kvzalloc (sz , GFP_KERNEL );
214
253
if (!out_cnt ) {
215
254
err = IB_MAD_RESULT_FAILURE ;
216
255
goto done ;
217
256
}
218
257
219
- err = mlx5_core_query_vport_counter (mdev , 0 , 0 , mdev_port_num ,
220
- out_cnt );
221
- if (!err )
222
- pma_cnt_ext_assign (pma_cnt_ext , out_cnt );
258
+ if (dev -> ib_dev .type == RDMA_DEVICE_TYPE_SMI ) {
259
+ err = query_ib_ppcnt (mdev , mdev_port_num ,
260
+ port_num , out_cnt , sz , 1 );
261
+ if (!err )
262
+ pma_cnt_ext_assign_ppcnt (pma_cnt_ext , out_cnt );
263
+ } else {
264
+ err = mlx5_core_query_vport_counter (mdev , 0 , 0 ,
265
+ mdev_port_num ,
266
+ out_cnt );
267
+ if (!err )
268
+ pma_cnt_ext_assign (pma_cnt_ext , out_cnt );
269
+ }
223
270
} else {
224
271
struct ib_pma_portcounters * pma_cnt =
225
272
(struct ib_pma_portcounters * )(out_mad -> data + 40 );
@@ -231,7 +278,7 @@ static int process_pma_cmd(struct mlx5_ib_dev *dev, u32 port_num,
231
278
goto done ;
232
279
}
233
280
234
- err = query_ib_ppcnt (mdev , mdev_port_num , out_cnt , sz );
281
+ err = query_ib_ppcnt (mdev , mdev_port_num , 0 , out_cnt , sz , 0 );
235
282
if (!err )
236
283
pma_cnt_assign (pma_cnt , out_cnt );
237
284
}
0 commit comments