]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | /* SPDX-License-Identifier: BSD-3-Clause |
2 | * Copyright(c) 2014-2018 Broadcom | |
3 | * All rights reserved. | |
4 | */ | |
5 | ||
6 | #include <inttypes.h> | |
7 | ||
9f95a23c | 8 | #include <rte_string_fns.h> |
11fdf7f2 TL |
9 | #include <rte_byteorder.h> |
10 | ||
11 | #include "bnxt.h" | |
12 | #include "bnxt_cpr.h" | |
f67539c2 | 13 | #include "bnxt_filter.h" |
11fdf7f2 TL |
14 | #include "bnxt_hwrm.h" |
15 | #include "bnxt_rxq.h" | |
16 | #include "bnxt_stats.h" | |
17 | #include "bnxt_txq.h" | |
f67539c2 | 18 | #include "bnxt_vnic.h" |
11fdf7f2 TL |
19 | #include "hsi_struct_def_dpdk.h" |
20 | ||
21 | static const struct bnxt_xstats_name_off bnxt_rx_stats_strings[] = { | |
22 | {"rx_64b_frames", offsetof(struct rx_port_stats, | |
23 | rx_64b_frames)}, | |
24 | {"rx_65b_127b_frames", offsetof(struct rx_port_stats, | |
25 | rx_65b_127b_frames)}, | |
26 | {"rx_128b_255b_frames", offsetof(struct rx_port_stats, | |
27 | rx_128b_255b_frames)}, | |
28 | {"rx_256b_511b_frames", offsetof(struct rx_port_stats, | |
29 | rx_256b_511b_frames)}, | |
30 | {"rx_512b_1023b_frames", offsetof(struct rx_port_stats, | |
31 | rx_512b_1023b_frames)}, | |
9f95a23c TL |
32 | {"rx_1024b_1518b_frames", offsetof(struct rx_port_stats, |
33 | rx_1024b_1518b_frames)}, | |
11fdf7f2 TL |
34 | {"rx_good_vlan_frames", offsetof(struct rx_port_stats, |
35 | rx_good_vlan_frames)}, | |
36 | {"rx_1519b_2047b_frames", offsetof(struct rx_port_stats, | |
37 | rx_1519b_2047b_frames)}, | |
38 | {"rx_2048b_4095b_frames", offsetof(struct rx_port_stats, | |
39 | rx_2048b_4095b_frames)}, | |
40 | {"rx_4096b_9216b_frames", offsetof(struct rx_port_stats, | |
41 | rx_4096b_9216b_frames)}, | |
42 | {"rx_9217b_16383b_frames", offsetof(struct rx_port_stats, | |
43 | rx_9217b_16383b_frames)}, | |
44 | {"rx_total_frames", offsetof(struct rx_port_stats, | |
45 | rx_total_frames)}, | |
46 | {"rx_ucast_frames", offsetof(struct rx_port_stats, | |
47 | rx_ucast_frames)}, | |
48 | {"rx_mcast_frames", offsetof(struct rx_port_stats, | |
49 | rx_mcast_frames)}, | |
50 | {"rx_bcast_frames", offsetof(struct rx_port_stats, | |
51 | rx_bcast_frames)}, | |
52 | {"rx_fcs_err_frames", offsetof(struct rx_port_stats, | |
53 | rx_fcs_err_frames)}, | |
54 | {"rx_ctrl_frames", offsetof(struct rx_port_stats, | |
55 | rx_ctrl_frames)}, | |
56 | {"rx_pause_frames", offsetof(struct rx_port_stats, | |
57 | rx_pause_frames)}, | |
58 | {"rx_pfc_frames", offsetof(struct rx_port_stats, | |
59 | rx_pfc_frames)}, | |
f67539c2 TL |
60 | {"rx_unsupported_opcode_frames", offsetof(struct rx_port_stats, |
61 | rx_unsupported_opcode_frames)}, | |
62 | {"rx_unsupported_da_pausepfc_frames", offsetof(struct rx_port_stats, | |
63 | rx_unsupported_da_pausepfc_frames)}, | |
64 | {"rx_wrong_sa_frames", offsetof(struct rx_port_stats, | |
65 | rx_wrong_sa_frames)}, | |
11fdf7f2 TL |
66 | {"rx_align_err_frames", offsetof(struct rx_port_stats, |
67 | rx_align_err_frames)}, | |
f67539c2 TL |
68 | {"rx_oor_len_frames", offsetof(struct rx_port_stats, |
69 | rx_oor_len_frames)}, | |
70 | {"rx_code_err_frames", offsetof(struct rx_port_stats, | |
71 | rx_code_err_frames)}, | |
72 | {"rx_false_carrier_frames", offsetof(struct rx_port_stats, | |
73 | rx_false_carrier_frames)}, | |
11fdf7f2 TL |
74 | {"rx_ovrsz_frames", offsetof(struct rx_port_stats, |
75 | rx_ovrsz_frames)}, | |
76 | {"rx_jbr_frames", offsetof(struct rx_port_stats, | |
77 | rx_jbr_frames)}, | |
78 | {"rx_mtu_err_frames", offsetof(struct rx_port_stats, | |
79 | rx_mtu_err_frames)}, | |
f67539c2 TL |
80 | {"rx_match_crc_frames", offsetof(struct rx_port_stats, |
81 | rx_match_crc_frames)}, | |
82 | {"rx_promiscuous_frames", offsetof(struct rx_port_stats, | |
83 | rx_promiscuous_frames)}, | |
11fdf7f2 TL |
84 | {"rx_tagged_frames", offsetof(struct rx_port_stats, |
85 | rx_tagged_frames)}, | |
86 | {"rx_double_tagged_frames", offsetof(struct rx_port_stats, | |
87 | rx_double_tagged_frames)}, | |
f67539c2 TL |
88 | {"rx_trunc_frames", offsetof(struct rx_port_stats, |
89 | rx_trunc_frames)}, | |
11fdf7f2 TL |
90 | {"rx_good_frames", offsetof(struct rx_port_stats, |
91 | rx_good_frames)}, | |
f67539c2 TL |
92 | {"rx_sch_crc_err_frames", offsetof(struct rx_port_stats, |
93 | rx_sch_crc_err_frames)}, | |
11fdf7f2 TL |
94 | {"rx_undrsz_frames", offsetof(struct rx_port_stats, |
95 | rx_undrsz_frames)}, | |
f67539c2 TL |
96 | {"rx_frag_frames", offsetof(struct rx_port_stats, |
97 | rx_frag_frames)}, | |
11fdf7f2 TL |
98 | {"rx_eee_lpi_events", offsetof(struct rx_port_stats, |
99 | rx_eee_lpi_events)}, | |
100 | {"rx_eee_lpi_duration", offsetof(struct rx_port_stats, | |
101 | rx_eee_lpi_duration)}, | |
f67539c2 TL |
102 | {"rx_llfc_physical_msgs", offsetof(struct rx_port_stats, |
103 | rx_llfc_physical_msgs)}, | |
104 | {"rx_llfc_logical_msgs", offsetof(struct rx_port_stats, | |
105 | rx_llfc_logical_msgs)}, | |
106 | {"rx_llfc_msgs_with_crc_err", offsetof(struct rx_port_stats, | |
107 | rx_llfc_msgs_with_crc_err)}, | |
108 | {"rx_hcfc_msgs", offsetof(struct rx_port_stats, | |
109 | rx_hcfc_msgs)}, | |
110 | {"rx_hcfc_msgs_with_crc_err", offsetof(struct rx_port_stats, | |
111 | rx_hcfc_msgs_with_crc_err)}, | |
11fdf7f2 TL |
112 | {"rx_bytes", offsetof(struct rx_port_stats, |
113 | rx_bytes)}, | |
114 | {"rx_runt_bytes", offsetof(struct rx_port_stats, | |
115 | rx_runt_bytes)}, | |
116 | {"rx_runt_frames", offsetof(struct rx_port_stats, | |
117 | rx_runt_frames)}, | |
f67539c2 TL |
118 | {"rx_pfc_xon2xoff_frames_pri0", offsetof(struct rx_port_stats, |
119 | rx_pfc_xon2xoff_frames_pri0)}, | |
120 | {"rx_pfc_xon2xoff_frames_pri1", offsetof(struct rx_port_stats, | |
121 | rx_pfc_xon2xoff_frames_pri1)}, | |
122 | {"rx_pfc_xon2xoff_frames_pri2", offsetof(struct rx_port_stats, | |
123 | rx_pfc_xon2xoff_frames_pri2)}, | |
124 | {"rx_pfc_xon2xoff_frames_pri3", offsetof(struct rx_port_stats, | |
125 | rx_pfc_xon2xoff_frames_pri3)}, | |
126 | {"rx_pfc_xon2xoff_frames_pri4", offsetof(struct rx_port_stats, | |
127 | rx_pfc_xon2xoff_frames_pri4)}, | |
128 | {"rx_pfc_xon2xoff_frames_pri5", offsetof(struct rx_port_stats, | |
129 | rx_pfc_xon2xoff_frames_pri5)}, | |
130 | {"rx_pfc_xon2xoff_frames_pri6", offsetof(struct rx_port_stats, | |
131 | rx_pfc_xon2xoff_frames_pri6)}, | |
132 | {"rx_pfc_xon2xoff_frames_pri7", offsetof(struct rx_port_stats, | |
133 | rx_pfc_xon2xoff_frames_pri7)}, | |
134 | {"rx_pfc_ena_frames_pri0", offsetof(struct rx_port_stats, | |
135 | rx_pfc_ena_frames_pri0)}, | |
136 | {"rx_pfc_ena_frames_pri1", offsetof(struct rx_port_stats, | |
137 | rx_pfc_ena_frames_pri1)}, | |
138 | {"rx_pfc_ena_frames_pri2", offsetof(struct rx_port_stats, | |
139 | rx_pfc_ena_frames_pri2)}, | |
140 | {"rx_pfc_ena_frames_pri3", offsetof(struct rx_port_stats, | |
141 | rx_pfc_ena_frames_pri3)}, | |
142 | {"rx_pfc_ena_frames_pri4", offsetof(struct rx_port_stats, | |
143 | rx_pfc_ena_frames_pri4)}, | |
144 | {"rx_pfc_ena_frames_pri5", offsetof(struct rx_port_stats, | |
145 | rx_pfc_ena_frames_pri5)}, | |
146 | {"rx_pfc_ena_frames_pri6", offsetof(struct rx_port_stats, | |
147 | rx_pfc_ena_frames_pri6)}, | |
148 | {"rx_pfc_ena_frames_pri7", offsetof(struct rx_port_stats, | |
149 | rx_pfc_ena_frames_pri7)}, | |
150 | {"rx_stat_discard", offsetof(struct rx_port_stats, | |
151 | rx_stat_discard)}, | |
152 | {"rx_stat_err", offsetof(struct rx_port_stats, | |
153 | rx_stat_err)}, | |
11fdf7f2 TL |
154 | }; |
155 | ||
156 | static const struct bnxt_xstats_name_off bnxt_tx_stats_strings[] = { | |
157 | {"tx_64b_frames", offsetof(struct tx_port_stats, | |
158 | tx_64b_frames)}, | |
159 | {"tx_65b_127b_frames", offsetof(struct tx_port_stats, | |
160 | tx_65b_127b_frames)}, | |
161 | {"tx_128b_255b_frames", offsetof(struct tx_port_stats, | |
162 | tx_128b_255b_frames)}, | |
163 | {"tx_256b_511b_frames", offsetof(struct tx_port_stats, | |
164 | tx_256b_511b_frames)}, | |
165 | {"tx_512b_1023b_frames", offsetof(struct tx_port_stats, | |
166 | tx_512b_1023b_frames)}, | |
9f95a23c TL |
167 | {"tx_1024b_1518b_frames", offsetof(struct tx_port_stats, |
168 | tx_1024b_1518b_frames)}, | |
11fdf7f2 TL |
169 | {"tx_good_vlan_frames", offsetof(struct tx_port_stats, |
170 | tx_good_vlan_frames)}, | |
9f95a23c TL |
171 | {"tx_1519b_2047b_frames", offsetof(struct tx_port_stats, |
172 | tx_1519b_2047b_frames)}, | |
11fdf7f2 TL |
173 | {"tx_2048b_4095b_frames", offsetof(struct tx_port_stats, |
174 | tx_2048b_4095b_frames)}, | |
175 | {"tx_4096b_9216b_frames", offsetof(struct tx_port_stats, | |
176 | tx_4096b_9216b_frames)}, | |
177 | {"tx_9217b_16383b_frames", offsetof(struct tx_port_stats, | |
178 | tx_9217b_16383b_frames)}, | |
179 | {"tx_good_frames", offsetof(struct tx_port_stats, | |
180 | tx_good_frames)}, | |
181 | {"tx_total_frames", offsetof(struct tx_port_stats, | |
182 | tx_total_frames)}, | |
183 | {"tx_ucast_frames", offsetof(struct tx_port_stats, | |
184 | tx_ucast_frames)}, | |
185 | {"tx_mcast_frames", offsetof(struct tx_port_stats, | |
186 | tx_mcast_frames)}, | |
187 | {"tx_bcast_frames", offsetof(struct tx_port_stats, | |
188 | tx_bcast_frames)}, | |
189 | {"tx_pause_frames", offsetof(struct tx_port_stats, | |
190 | tx_pause_frames)}, | |
191 | {"tx_pfc_frames", offsetof(struct tx_port_stats, | |
192 | tx_pfc_frames)}, | |
193 | {"tx_jabber_frames", offsetof(struct tx_port_stats, | |
194 | tx_jabber_frames)}, | |
195 | {"tx_fcs_err_frames", offsetof(struct tx_port_stats, | |
196 | tx_fcs_err_frames)}, | |
f67539c2 TL |
197 | {"tx_control_frames", offsetof(struct tx_port_stats, |
198 | tx_control_frames)}, | |
199 | {"tx_oversz_frames", offsetof(struct tx_port_stats, | |
200 | tx_oversz_frames)}, | |
201 | {"tx_single_dfrl_frames", offsetof(struct tx_port_stats, | |
202 | tx_single_dfrl_frames)}, | |
203 | {"tx_multi_dfrl_frames", offsetof(struct tx_port_stats, | |
204 | tx_multi_dfrl_frames)}, | |
205 | {"tx_single_coll_frames", offsetof(struct tx_port_stats, | |
206 | tx_single_coll_frames)}, | |
207 | {"tx_multi_coll_frames", offsetof(struct tx_port_stats, | |
208 | tx_multi_coll_frames)}, | |
209 | {"tx_late_coll_frames", offsetof(struct tx_port_stats, | |
210 | tx_late_coll_frames)}, | |
211 | {"tx_excessive_coll_frames", offsetof(struct tx_port_stats, | |
212 | tx_excessive_coll_frames)}, | |
213 | {"tx_frag_frames", offsetof(struct tx_port_stats, | |
214 | tx_frag_frames)}, | |
11fdf7f2 TL |
215 | {"tx_err", offsetof(struct tx_port_stats, |
216 | tx_err)}, | |
f67539c2 TL |
217 | {"tx_tagged_frames", offsetof(struct tx_port_stats, |
218 | tx_tagged_frames)}, | |
219 | {"tx_dbl_tagged_frames", offsetof(struct tx_port_stats, | |
220 | tx_dbl_tagged_frames)}, | |
221 | {"tx_runt_frames", offsetof(struct tx_port_stats, | |
222 | tx_runt_frames)}, | |
11fdf7f2 TL |
223 | {"tx_fifo_underruns", offsetof(struct tx_port_stats, |
224 | tx_fifo_underruns)}, | |
225 | {"tx_eee_lpi_events", offsetof(struct tx_port_stats, | |
226 | tx_eee_lpi_events)}, | |
227 | {"tx_eee_lpi_duration", offsetof(struct tx_port_stats, | |
228 | tx_eee_lpi_duration)}, | |
229 | {"tx_total_collisions", offsetof(struct tx_port_stats, | |
230 | tx_total_collisions)}, | |
231 | {"tx_bytes", offsetof(struct tx_port_stats, | |
232 | tx_bytes)}, | |
f67539c2 TL |
233 | {"tx_pfc_ena_frames_pri0", offsetof(struct tx_port_stats, |
234 | tx_pfc_ena_frames_pri0)}, | |
235 | {"tx_pfc_ena_frames_pri1", offsetof(struct tx_port_stats, | |
236 | tx_pfc_ena_frames_pri1)}, | |
237 | {"tx_pfc_ena_frames_pri2", offsetof(struct tx_port_stats, | |
238 | tx_pfc_ena_frames_pri2)}, | |
239 | {"tx_pfc_ena_frames_pri3", offsetof(struct tx_port_stats, | |
240 | tx_pfc_ena_frames_pri3)}, | |
241 | {"tx_pfc_ena_frames_pri4", offsetof(struct tx_port_stats, | |
242 | tx_pfc_ena_frames_pri4)}, | |
243 | {"tx_pfc_ena_frames_pri5", offsetof(struct tx_port_stats, | |
244 | tx_pfc_ena_frames_pri5)}, | |
245 | {"tx_pfc_ena_frames_pri6", offsetof(struct tx_port_stats, | |
246 | tx_pfc_ena_frames_pri6)}, | |
247 | {"tx_pfc_ena_frames_pri7", offsetof(struct tx_port_stats, | |
248 | tx_pfc_ena_frames_pri7)}, | |
249 | {"tx_llfc_logical_msgs", offsetof(struct tx_port_stats, | |
250 | tx_llfc_logical_msgs)}, | |
251 | {"tx_hcfc_msgs", offsetof(struct tx_port_stats, | |
252 | tx_hcfc_msgs)}, | |
253 | {"tx_xthol_frames", offsetof(struct tx_port_stats, | |
254 | tx_xthol_frames)}, | |
255 | {"tx_stat_discard", offsetof(struct tx_port_stats, | |
256 | tx_stat_discard)}, | |
257 | {"tx_stat_error", offsetof(struct tx_port_stats, | |
258 | tx_stat_error)}, | |
11fdf7f2 TL |
259 | }; |
260 | ||
261 | static const struct bnxt_xstats_name_off bnxt_func_stats_strings[] = { | |
262 | {"tx_ucast_pkts", offsetof(struct hwrm_func_qstats_output, | |
263 | tx_ucast_pkts)}, | |
264 | {"tx_mcast_pkts", offsetof(struct hwrm_func_qstats_output, | |
265 | tx_mcast_pkts)}, | |
266 | {"tx_bcast_pkts", offsetof(struct hwrm_func_qstats_output, | |
267 | tx_bcast_pkts)}, | |
268 | {"tx_discard_pkts", offsetof(struct hwrm_func_qstats_output, | |
269 | tx_discard_pkts)}, | |
270 | {"tx_drop_pkts", offsetof(struct hwrm_func_qstats_output, | |
271 | tx_drop_pkts)}, | |
272 | {"tx_ucast_bytes", offsetof(struct hwrm_func_qstats_output, | |
273 | tx_ucast_bytes)}, | |
274 | {"tx_mcast_bytes", offsetof(struct hwrm_func_qstats_output, | |
275 | tx_mcast_bytes)}, | |
276 | {"tx_bcast_bytes", offsetof(struct hwrm_func_qstats_output, | |
277 | tx_bcast_bytes)}, | |
278 | {"rx_ucast_pkts", offsetof(struct hwrm_func_qstats_output, | |
279 | rx_ucast_pkts)}, | |
280 | {"rx_mcast_pkts", offsetof(struct hwrm_func_qstats_output, | |
281 | rx_mcast_pkts)}, | |
282 | {"rx_bcast_pkts", offsetof(struct hwrm_func_qstats_output, | |
283 | rx_bcast_pkts)}, | |
284 | {"rx_discard_pkts", offsetof(struct hwrm_func_qstats_output, | |
285 | rx_discard_pkts)}, | |
286 | {"rx_drop_pkts", offsetof(struct hwrm_func_qstats_output, | |
287 | rx_drop_pkts)}, | |
288 | {"rx_ucast_bytes", offsetof(struct hwrm_func_qstats_output, | |
289 | rx_ucast_bytes)}, | |
290 | {"rx_mcast_bytes", offsetof(struct hwrm_func_qstats_output, | |
291 | rx_mcast_bytes)}, | |
292 | {"rx_bcast_bytes", offsetof(struct hwrm_func_qstats_output, | |
293 | rx_bcast_bytes)}, | |
294 | {"rx_agg_pkts", offsetof(struct hwrm_func_qstats_output, | |
295 | rx_agg_pkts)}, | |
296 | {"rx_agg_bytes", offsetof(struct hwrm_func_qstats_output, | |
297 | rx_agg_bytes)}, | |
298 | {"rx_agg_events", offsetof(struct hwrm_func_qstats_output, | |
299 | rx_agg_events)}, | |
300 | {"rx_agg_aborts", offsetof(struct hwrm_func_qstats_output, | |
301 | rx_agg_aborts)}, | |
302 | }; | |
303 | ||
f67539c2 | 304 | |
9f95a23c TL |
305 | static const struct bnxt_xstats_name_off bnxt_rx_ext_stats_strings[] = { |
306 | {"link_down_events", offsetof(struct rx_port_stats_ext, | |
307 | link_down_events)}, | |
308 | {"continuous_pause_events", offsetof(struct rx_port_stats_ext, | |
309 | continuous_pause_events)}, | |
310 | {"resume_pause_events", offsetof(struct rx_port_stats_ext, | |
311 | resume_pause_events)}, | |
312 | {"continuous_roce_pause_events", offsetof(struct rx_port_stats_ext, | |
313 | continuous_roce_pause_events)}, | |
314 | {"resume_roce_pause_events", offsetof(struct rx_port_stats_ext, | |
315 | resume_roce_pause_events)}, | |
316 | {"rx_bytes_cos0", offsetof(struct rx_port_stats_ext, | |
317 | rx_bytes_cos0)}, | |
318 | {"rx_bytes_cos1", offsetof(struct rx_port_stats_ext, | |
319 | rx_bytes_cos1)}, | |
320 | {"rx_bytes_cos2", offsetof(struct rx_port_stats_ext, | |
321 | rx_bytes_cos2)}, | |
322 | {"rx_bytes_cos3", offsetof(struct rx_port_stats_ext, | |
323 | rx_bytes_cos3)}, | |
324 | {"rx_bytes_cos4", offsetof(struct rx_port_stats_ext, | |
325 | rx_bytes_cos4)}, | |
326 | {"rx_bytes_cos5", offsetof(struct rx_port_stats_ext, | |
327 | rx_bytes_cos5)}, | |
328 | {"rx_bytes_cos6", offsetof(struct rx_port_stats_ext, | |
329 | rx_bytes_cos6)}, | |
330 | {"rx_bytes_cos7", offsetof(struct rx_port_stats_ext, | |
331 | rx_bytes_cos7)}, | |
332 | {"rx_packets_cos0", offsetof(struct rx_port_stats_ext, | |
333 | rx_packets_cos0)}, | |
334 | {"rx_packets_cos1", offsetof(struct rx_port_stats_ext, | |
335 | rx_packets_cos1)}, | |
336 | {"rx_packets_cos2", offsetof(struct rx_port_stats_ext, | |
337 | rx_packets_cos2)}, | |
338 | {"rx_packets_cos3", offsetof(struct rx_port_stats_ext, | |
339 | rx_packets_cos3)}, | |
340 | {"rx_packets_cos4", offsetof(struct rx_port_stats_ext, | |
341 | rx_packets_cos4)}, | |
342 | {"rx_packets_cos5", offsetof(struct rx_port_stats_ext, | |
343 | rx_packets_cos5)}, | |
344 | {"rx_packets_cos6", offsetof(struct rx_port_stats_ext, | |
345 | rx_packets_cos6)}, | |
346 | {"rx_packets_cos7", offsetof(struct rx_port_stats_ext, | |
347 | rx_packets_cos7)}, | |
348 | {"pfc_pri0_rx_duration_us", offsetof(struct rx_port_stats_ext, | |
349 | pfc_pri0_rx_duration_us)}, | |
350 | {"pfc_pri0_rx_transitions", offsetof(struct rx_port_stats_ext, | |
351 | pfc_pri0_rx_transitions)}, | |
352 | {"pfc_pri1_rx_duration_us", offsetof(struct rx_port_stats_ext, | |
353 | pfc_pri1_rx_duration_us)}, | |
354 | {"pfc_pri1_rx_transitions", offsetof(struct rx_port_stats_ext, | |
355 | pfc_pri1_rx_transitions)}, | |
356 | {"pfc_pri2_rx_duration_us", offsetof(struct rx_port_stats_ext, | |
357 | pfc_pri2_rx_duration_us)}, | |
358 | {"pfc_pri2_rx_transitions", offsetof(struct rx_port_stats_ext, | |
359 | pfc_pri2_rx_transitions)}, | |
360 | {"pfc_pri3_rx_duration_us", offsetof(struct rx_port_stats_ext, | |
361 | pfc_pri3_rx_duration_us)}, | |
362 | {"pfc_pri3_rx_transitions", offsetof(struct rx_port_stats_ext, | |
363 | pfc_pri3_rx_transitions)}, | |
364 | {"pfc_pri4_rx_duration_us", offsetof(struct rx_port_stats_ext, | |
365 | pfc_pri4_rx_duration_us)}, | |
366 | {"pfc_pri4_rx_transitions", offsetof(struct rx_port_stats_ext, | |
367 | pfc_pri4_rx_transitions)}, | |
368 | {"pfc_pri5_rx_duration_us", offsetof(struct rx_port_stats_ext, | |
369 | pfc_pri5_rx_duration_us)}, | |
370 | {"pfc_pri5_rx_transitions", offsetof(struct rx_port_stats_ext, | |
371 | pfc_pri5_rx_transitions)}, | |
372 | {"pfc_pri6_rx_duration_us", offsetof(struct rx_port_stats_ext, | |
373 | pfc_pri6_rx_duration_us)}, | |
374 | {"pfc_pri6_rx_transitions", offsetof(struct rx_port_stats_ext, | |
375 | pfc_pri6_rx_transitions)}, | |
376 | {"pfc_pri7_rx_duration_us", offsetof(struct rx_port_stats_ext, | |
377 | pfc_pri7_rx_duration_us)}, | |
378 | {"pfc_pri7_rx_transitions", offsetof(struct rx_port_stats_ext, | |
379 | pfc_pri7_rx_transitions)}, | |
f67539c2 TL |
380 | {"rx_bits", offsetof(struct rx_port_stats_ext, |
381 | rx_bits)}, | |
382 | {"rx_buffer_passed_threshold", offsetof(struct rx_port_stats_ext, | |
383 | rx_buffer_passed_threshold)}, | |
384 | {"rx_pcs_symbol_err", offsetof(struct rx_port_stats_ext, | |
385 | rx_pcs_symbol_err)}, | |
386 | {"rx_corrected_bits", offsetof(struct rx_port_stats_ext, | |
387 | rx_corrected_bits)}, | |
388 | {"rx_discard_bytes_cos0", offsetof(struct rx_port_stats_ext, | |
389 | rx_discard_bytes_cos0)}, | |
390 | {"rx_discard_bytes_cos1", offsetof(struct rx_port_stats_ext, | |
391 | rx_discard_bytes_cos1)}, | |
392 | {"rx_discard_bytes_cos2", offsetof(struct rx_port_stats_ext, | |
393 | rx_discard_bytes_cos2)}, | |
394 | {"rx_discard_bytes_cos3", offsetof(struct rx_port_stats_ext, | |
395 | rx_discard_bytes_cos3)}, | |
396 | {"rx_discard_bytes_cos4", offsetof(struct rx_port_stats_ext, | |
397 | rx_discard_bytes_cos4)}, | |
398 | {"rx_discard_bytes_cos5", offsetof(struct rx_port_stats_ext, | |
399 | rx_discard_bytes_cos5)}, | |
400 | {"rx_discard_bytes_cos6", offsetof(struct rx_port_stats_ext, | |
401 | rx_discard_bytes_cos6)}, | |
402 | {"rx_discard_bytes_cos7", offsetof(struct rx_port_stats_ext, | |
403 | rx_discard_bytes_cos7)}, | |
404 | {"rx_discard_packets_cos0", offsetof(struct rx_port_stats_ext, | |
405 | rx_discard_packets_cos0)}, | |
406 | {"rx_discard_packets_cos1", offsetof(struct rx_port_stats_ext, | |
407 | rx_discard_packets_cos1)}, | |
408 | {"rx_discard_packets_cos2", offsetof(struct rx_port_stats_ext, | |
409 | rx_discard_packets_cos2)}, | |
410 | {"rx_discard_packets_cos3", offsetof(struct rx_port_stats_ext, | |
411 | rx_discard_packets_cos3)}, | |
412 | {"rx_discard_packets_cos4", offsetof(struct rx_port_stats_ext, | |
413 | rx_discard_packets_cos4)}, | |
414 | {"rx_discard_packets_cos5", offsetof(struct rx_port_stats_ext, | |
415 | rx_discard_packets_cos5)}, | |
416 | {"rx_discard_packets_cos6", offsetof(struct rx_port_stats_ext, | |
417 | rx_discard_packets_cos6)}, | |
418 | {"rx_discard_packets_cos7", offsetof(struct rx_port_stats_ext, | |
419 | rx_discard_packets_cos7)}, | |
9f95a23c TL |
420 | }; |
421 | ||
422 | static const struct bnxt_xstats_name_off bnxt_tx_ext_stats_strings[] = { | |
423 | {"tx_bytes_cos0", offsetof(struct tx_port_stats_ext, | |
424 | tx_bytes_cos0)}, | |
425 | {"tx_bytes_cos1", offsetof(struct tx_port_stats_ext, | |
426 | tx_bytes_cos1)}, | |
427 | {"tx_bytes_cos2", offsetof(struct tx_port_stats_ext, | |
428 | tx_bytes_cos2)}, | |
429 | {"tx_bytes_cos3", offsetof(struct tx_port_stats_ext, | |
430 | tx_bytes_cos3)}, | |
431 | {"tx_bytes_cos4", offsetof(struct tx_port_stats_ext, | |
432 | tx_bytes_cos4)}, | |
433 | {"tx_bytes_cos5", offsetof(struct tx_port_stats_ext, | |
434 | tx_bytes_cos5)}, | |
435 | {"tx_bytes_cos6", offsetof(struct tx_port_stats_ext, | |
436 | tx_bytes_cos6)}, | |
437 | {"tx_bytes_cos7", offsetof(struct tx_port_stats_ext, | |
438 | tx_bytes_cos7)}, | |
439 | {"tx_packets_cos0", offsetof(struct tx_port_stats_ext, | |
440 | tx_packets_cos0)}, | |
441 | {"tx_packets_cos1", offsetof(struct tx_port_stats_ext, | |
442 | tx_packets_cos1)}, | |
443 | {"tx_packets_cos2", offsetof(struct tx_port_stats_ext, | |
444 | tx_packets_cos2)}, | |
445 | {"tx_packets_cos3", offsetof(struct tx_port_stats_ext, | |
446 | tx_packets_cos3)}, | |
447 | {"tx_packets_cos4", offsetof(struct tx_port_stats_ext, | |
448 | tx_packets_cos4)}, | |
449 | {"tx_packets_cos5", offsetof(struct tx_port_stats_ext, | |
450 | tx_packets_cos5)}, | |
451 | {"tx_packets_cos6", offsetof(struct tx_port_stats_ext, | |
452 | tx_packets_cos6)}, | |
453 | {"tx_packets_cos7", offsetof(struct tx_port_stats_ext, | |
454 | tx_packets_cos7)}, | |
455 | {"pfc_pri0_tx_duration_us", offsetof(struct tx_port_stats_ext, | |
456 | pfc_pri0_tx_duration_us)}, | |
457 | {"pfc_pri0_tx_transitions", offsetof(struct tx_port_stats_ext, | |
458 | pfc_pri0_tx_transitions)}, | |
459 | {"pfc_pri1_tx_duration_us", offsetof(struct tx_port_stats_ext, | |
460 | pfc_pri1_tx_duration_us)}, | |
461 | {"pfc_pri1_tx_transitions", offsetof(struct tx_port_stats_ext, | |
462 | pfc_pri1_tx_transitions)}, | |
463 | {"pfc_pri2_tx_duration_us", offsetof(struct tx_port_stats_ext, | |
464 | pfc_pri2_tx_duration_us)}, | |
465 | {"pfc_pri2_tx_transitions", offsetof(struct tx_port_stats_ext, | |
466 | pfc_pri2_tx_transitions)}, | |
467 | {"pfc_pri3_tx_duration_us", offsetof(struct tx_port_stats_ext, | |
468 | pfc_pri3_tx_duration_us)}, | |
469 | {"pfc_pri3_tx_transitions", offsetof(struct tx_port_stats_ext, | |
470 | pfc_pri3_tx_transitions)}, | |
471 | {"pfc_pri4_tx_duration_us", offsetof(struct tx_port_stats_ext, | |
472 | pfc_pri4_tx_duration_us)}, | |
473 | {"pfc_pri4_tx_transitions", offsetof(struct tx_port_stats_ext, | |
474 | pfc_pri4_tx_transitions)}, | |
475 | {"pfc_pri5_tx_duration_us", offsetof(struct tx_port_stats_ext, | |
476 | pfc_pri5_tx_duration_us)}, | |
477 | {"pfc_pri5_tx_transitions", offsetof(struct tx_port_stats_ext, | |
478 | pfc_pri5_tx_transitions)}, | |
479 | {"pfc_pri6_tx_duration_us", offsetof(struct tx_port_stats_ext, | |
480 | pfc_pri6_tx_duration_us)}, | |
481 | {"pfc_pri6_tx_transitions", offsetof(struct tx_port_stats_ext, | |
482 | pfc_pri6_tx_transitions)}, | |
483 | {"pfc_pri7_tx_duration_us", offsetof(struct tx_port_stats_ext, | |
484 | pfc_pri7_tx_duration_us)}, | |
485 | {"pfc_pri7_tx_transitions", offsetof(struct tx_port_stats_ext, | |
486 | pfc_pri7_tx_transitions)}, | |
487 | }; | |
488 | ||
11fdf7f2 TL |
489 | /* |
490 | * Statistics functions | |
491 | */ | |
492 | ||
493 | void bnxt_free_stats(struct bnxt *bp) | |
494 | { | |
495 | int i; | |
496 | ||
497 | for (i = 0; i < (int)bp->tx_cp_nr_rings; i++) { | |
498 | struct bnxt_tx_queue *txq = bp->tx_queues[i]; | |
499 | ||
500 | bnxt_free_txq_stats(txq); | |
501 | } | |
502 | for (i = 0; i < (int)bp->rx_cp_nr_rings; i++) { | |
503 | struct bnxt_rx_queue *rxq = bp->rx_queues[i]; | |
504 | ||
505 | bnxt_free_rxq_stats(rxq); | |
506 | } | |
507 | } | |
508 | ||
509 | int bnxt_stats_get_op(struct rte_eth_dev *eth_dev, | |
510 | struct rte_eth_stats *bnxt_stats) | |
511 | { | |
512 | int rc = 0; | |
513 | unsigned int i; | |
514 | struct bnxt *bp = eth_dev->data->dev_private; | |
f67539c2 | 515 | unsigned int num_q_stats; |
11fdf7f2 | 516 | |
f67539c2 TL |
517 | rc = is_bnxt_in_error(bp); |
518 | if (rc) | |
519 | return rc; | |
11fdf7f2 | 520 | |
f67539c2 TL |
521 | if (!eth_dev->data->dev_started) |
522 | return -EIO; | |
523 | ||
524 | num_q_stats = RTE_MIN(bp->rx_cp_nr_rings, | |
525 | (unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS); | |
526 | ||
527 | for (i = 0; i < num_q_stats; i++) { | |
11fdf7f2 TL |
528 | struct bnxt_rx_queue *rxq = bp->rx_queues[i]; |
529 | struct bnxt_cp_ring_info *cpr = rxq->cp_ring; | |
530 | ||
531 | rc = bnxt_hwrm_ctx_qstats(bp, cpr->hw_stats_ctx_id, i, | |
532 | bnxt_stats, 1); | |
533 | if (unlikely(rc)) | |
534 | return rc; | |
535 | bnxt_stats->rx_nombuf += | |
536 | rte_atomic64_read(&rxq->rx_mbuf_alloc_fail); | |
537 | } | |
538 | ||
f67539c2 TL |
539 | num_q_stats = RTE_MIN(bp->tx_cp_nr_rings, |
540 | (unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS); | |
541 | ||
542 | for (i = 0; i < num_q_stats; i++) { | |
11fdf7f2 TL |
543 | struct bnxt_tx_queue *txq = bp->tx_queues[i]; |
544 | struct bnxt_cp_ring_info *cpr = txq->cp_ring; | |
545 | ||
546 | rc = bnxt_hwrm_ctx_qstats(bp, cpr->hw_stats_ctx_id, i, | |
547 | bnxt_stats, 0); | |
548 | if (unlikely(rc)) | |
549 | return rc; | |
550 | } | |
f67539c2 TL |
551 | |
552 | rc = bnxt_hwrm_func_qstats(bp, 0xffff, bnxt_stats, NULL); | |
11fdf7f2 TL |
553 | return rc; |
554 | } | |
555 | ||
f67539c2 | 556 | int bnxt_stats_reset_op(struct rte_eth_dev *eth_dev) |
11fdf7f2 | 557 | { |
f67539c2 | 558 | struct bnxt *bp = eth_dev->data->dev_private; |
11fdf7f2 | 559 | unsigned int i; |
f67539c2 | 560 | int ret; |
11fdf7f2 | 561 | |
f67539c2 TL |
562 | ret = is_bnxt_in_error(bp); |
563 | if (ret) | |
564 | return ret; | |
565 | ||
566 | if (!eth_dev->data->dev_started) { | |
11fdf7f2 | 567 | PMD_DRV_LOG(ERR, "Device Initialization not complete!\n"); |
f67539c2 | 568 | return -EINVAL; |
11fdf7f2 TL |
569 | } |
570 | ||
f67539c2 | 571 | ret = bnxt_clear_all_hwrm_stat_ctxs(bp); |
11fdf7f2 TL |
572 | for (i = 0; i < bp->rx_cp_nr_rings; i++) { |
573 | struct bnxt_rx_queue *rxq = bp->rx_queues[i]; | |
574 | ||
575 | rte_atomic64_clear(&rxq->rx_mbuf_alloc_fail); | |
576 | } | |
f67539c2 TL |
577 | |
578 | return ret; | |
11fdf7f2 TL |
579 | } |
580 | ||
581 | int bnxt_dev_xstats_get_op(struct rte_eth_dev *eth_dev, | |
582 | struct rte_eth_xstat *xstats, unsigned int n) | |
583 | { | |
f67539c2 | 584 | struct bnxt *bp = eth_dev->data->dev_private; |
11fdf7f2 | 585 | unsigned int count, i; |
9f95a23c TL |
586 | unsigned int rx_port_stats_ext_cnt; |
587 | unsigned int tx_port_stats_ext_cnt; | |
588 | unsigned int stat_size = sizeof(uint64_t); | |
f67539c2 | 589 | struct hwrm_func_qstats_output func_qstats = {0}; |
9f95a23c | 590 | unsigned int stat_count; |
f67539c2 TL |
591 | int rc; |
592 | ||
593 | rc = is_bnxt_in_error(bp); | |
594 | if (rc) | |
595 | return rc; | |
11fdf7f2 | 596 | |
f67539c2 TL |
597 | if (xstats == NULL) |
598 | return 0; | |
599 | ||
600 | memset(xstats, 0, sizeof(*xstats)); | |
601 | ||
602 | bnxt_hwrm_func_qstats(bp, 0xffff, NULL, &func_qstats); | |
11fdf7f2 | 603 | bnxt_hwrm_port_qstats(bp); |
9f95a23c | 604 | bnxt_hwrm_ext_port_qstats(bp); |
f67539c2 TL |
605 | rx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_rx_ext_stats_strings), |
606 | (bp->fw_rx_port_stats_ext_size / | |
607 | stat_size)); | |
608 | tx_port_stats_ext_cnt = RTE_MIN(RTE_DIM(bnxt_tx_ext_stats_strings), | |
609 | (bp->fw_tx_port_stats_ext_size / | |
610 | stat_size)); | |
11fdf7f2 TL |
611 | |
612 | count = RTE_DIM(bnxt_rx_stats_strings) + | |
f67539c2 TL |
613 | RTE_DIM(bnxt_tx_stats_strings) + |
614 | RTE_DIM(bnxt_func_stats_strings) + | |
9f95a23c | 615 | RTE_DIM(bnxt_rx_ext_stats_strings) + |
f67539c2 TL |
616 | RTE_DIM(bnxt_tx_ext_stats_strings) + |
617 | bnxt_flow_stats_cnt(bp); | |
618 | ||
9f95a23c | 619 | stat_count = count; |
11fdf7f2 TL |
620 | |
621 | if (n < count) | |
622 | return count; | |
623 | ||
624 | count = 0; | |
625 | for (i = 0; i < RTE_DIM(bnxt_rx_stats_strings); i++) { | |
626 | uint64_t *rx_stats = (uint64_t *)bp->hw_rx_port_stats; | |
627 | xstats[count].id = count; | |
628 | xstats[count].value = rte_le_to_cpu_64( | |
629 | *(uint64_t *)((char *)rx_stats + | |
630 | bnxt_rx_stats_strings[i].offset)); | |
631 | count++; | |
632 | } | |
633 | ||
634 | for (i = 0; i < RTE_DIM(bnxt_tx_stats_strings); i++) { | |
635 | uint64_t *tx_stats = (uint64_t *)bp->hw_tx_port_stats; | |
636 | xstats[count].id = count; | |
637 | xstats[count].value = rte_le_to_cpu_64( | |
638 | *(uint64_t *)((char *)tx_stats + | |
639 | bnxt_tx_stats_strings[i].offset)); | |
640 | count++; | |
641 | } | |
642 | ||
f67539c2 TL |
643 | for (i = 0; i < RTE_DIM(bnxt_func_stats_strings); i++) { |
644 | xstats[count].id = count; | |
645 | xstats[count].value = | |
646 | rte_le_to_cpu_64(((uint64_t *)&func_qstats)[i]); | |
647 | count++; | |
648 | } | |
649 | ||
650 | ||
651 | for (i = 0; i < rx_port_stats_ext_cnt; i++) { | |
652 | uint64_t *rx_stats_ext = (uint64_t *)bp->hw_rx_port_stats_ext; | |
653 | ||
654 | xstats[count].value = rte_le_to_cpu_64 | |
655 | (*(uint64_t *)((char *)rx_stats_ext + | |
656 | bnxt_rx_ext_stats_strings[i].offset)); | |
657 | ||
658 | count++; | |
659 | } | |
11fdf7f2 | 660 | |
9f95a23c TL |
661 | for (i = 0; i < tx_port_stats_ext_cnt; i++) { |
662 | uint64_t *tx_stats_ext = (uint64_t *)bp->hw_tx_port_stats_ext; | |
663 | ||
664 | xstats[count].value = rte_le_to_cpu_64 | |
665 | (*(uint64_t *)((char *)tx_stats_ext + | |
666 | bnxt_tx_ext_stats_strings[i].offset)); | |
9f95a23c TL |
667 | count++; |
668 | } | |
669 | ||
f67539c2 TL |
670 | if (bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_COUNTERS && |
671 | bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_MGMT && | |
672 | BNXT_FLOW_XSTATS_EN(bp)) { | |
673 | int j; | |
9f95a23c | 674 | |
f67539c2 TL |
675 | i = 0; |
676 | for (j = 0; j < bp->max_vnics; j++) { | |
677 | struct bnxt_filter_info *filter; | |
678 | struct bnxt_vnic_info *vnic; | |
679 | struct rte_flow *flow; | |
9f95a23c | 680 | |
f67539c2 TL |
681 | vnic = &bp->vnic_info[j]; |
682 | if (vnic && vnic->fw_vnic_id == INVALID_VNIC_ID) | |
683 | continue; | |
684 | ||
685 | if (STAILQ_EMPTY(&vnic->flow_list)) | |
686 | continue; | |
687 | ||
688 | STAILQ_FOREACH(flow, &vnic->flow_list, next) { | |
689 | if (!flow || !flow->filter) | |
690 | continue; | |
691 | ||
692 | filter = flow->filter; | |
693 | xstats[count].id = count; | |
694 | xstats[count].value = | |
695 | filter->hw_stats.bytes; | |
696 | count++; | |
697 | xstats[count].id = count; | |
698 | xstats[count].value = | |
699 | filter->hw_stats.packets; | |
700 | count++; | |
701 | if (++i > bp->max_l2_ctx) | |
702 | break; | |
703 | } | |
704 | if (i > bp->max_l2_ctx) | |
705 | break; | |
706 | } | |
9f95a23c TL |
707 | } |
708 | ||
709 | return stat_count; | |
11fdf7f2 TL |
710 | } |
711 | ||
f67539c2 TL |
712 | int bnxt_flow_stats_cnt(struct bnxt *bp) |
713 | { | |
714 | if (bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_COUNTERS && | |
715 | bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_MGMT && | |
716 | BNXT_FLOW_XSTATS_EN(bp)) { | |
717 | struct bnxt_xstats_name_off flow_bytes[bp->max_l2_ctx]; | |
718 | struct bnxt_xstats_name_off flow_pkts[bp->max_l2_ctx]; | |
719 | ||
720 | return RTE_DIM(flow_bytes) + RTE_DIM(flow_pkts); | |
721 | } | |
722 | ||
723 | return 0; | |
724 | } | |
725 | ||
726 | int bnxt_dev_xstats_get_names_op(struct rte_eth_dev *eth_dev, | |
727 | struct rte_eth_xstat_name *xstats_names, | |
728 | __rte_unused unsigned int limit) | |
11fdf7f2 | 729 | { |
f67539c2 | 730 | struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; |
11fdf7f2 | 731 | const unsigned int stat_cnt = RTE_DIM(bnxt_rx_stats_strings) + |
f67539c2 TL |
732 | RTE_DIM(bnxt_tx_stats_strings) + |
733 | RTE_DIM(bnxt_func_stats_strings) + | |
9f95a23c | 734 | RTE_DIM(bnxt_rx_ext_stats_strings) + |
f67539c2 TL |
735 | RTE_DIM(bnxt_tx_ext_stats_strings) + |
736 | bnxt_flow_stats_cnt(bp); | |
737 | unsigned int i, count = 0; | |
738 | int rc; | |
739 | ||
740 | rc = is_bnxt_in_error(bp); | |
741 | if (rc) | |
742 | return rc; | |
11fdf7f2 TL |
743 | |
744 | if (xstats_names != NULL) { | |
745 | count = 0; | |
746 | ||
747 | for (i = 0; i < RTE_DIM(bnxt_rx_stats_strings); i++) { | |
9f95a23c TL |
748 | strlcpy(xstats_names[count].name, |
749 | bnxt_rx_stats_strings[i].name, | |
750 | sizeof(xstats_names[count].name)); | |
11fdf7f2 TL |
751 | count++; |
752 | } | |
753 | ||
754 | for (i = 0; i < RTE_DIM(bnxt_tx_stats_strings); i++) { | |
9f95a23c TL |
755 | strlcpy(xstats_names[count].name, |
756 | bnxt_tx_stats_strings[i].name, | |
757 | sizeof(xstats_names[count].name)); | |
11fdf7f2 TL |
758 | count++; |
759 | } | |
760 | ||
f67539c2 TL |
761 | for (i = 0; i < RTE_DIM(bnxt_func_stats_strings); i++) { |
762 | strlcpy(xstats_names[count].name, | |
763 | bnxt_func_stats_strings[i].name, | |
764 | sizeof(xstats_names[count].name)); | |
765 | count++; | |
766 | } | |
9f95a23c TL |
767 | |
768 | for (i = 0; i < RTE_DIM(bnxt_rx_ext_stats_strings); i++) { | |
769 | strlcpy(xstats_names[count].name, | |
770 | bnxt_rx_ext_stats_strings[i].name, | |
771 | sizeof(xstats_names[count].name)); | |
772 | ||
773 | count++; | |
774 | } | |
775 | ||
776 | for (i = 0; i < RTE_DIM(bnxt_tx_ext_stats_strings); i++) { | |
777 | strlcpy(xstats_names[count].name, | |
778 | bnxt_tx_ext_stats_strings[i].name, | |
779 | sizeof(xstats_names[count].name)); | |
780 | ||
781 | count++; | |
782 | } | |
783 | ||
f67539c2 TL |
784 | if (bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_COUNTERS && |
785 | bp->fw_cap & BNXT_FW_CAP_ADV_FLOW_MGMT && | |
786 | BNXT_FLOW_XSTATS_EN(bp)) { | |
787 | for (i = 0; i < bp->max_l2_ctx; i++) { | |
788 | char buf[RTE_ETH_XSTATS_NAME_SIZE]; | |
789 | ||
790 | sprintf(buf, "flow_%d_bytes", i); | |
791 | strlcpy(xstats_names[count].name, buf, | |
792 | sizeof(xstats_names[count].name)); | |
793 | count++; | |
794 | ||
795 | sprintf(buf, "flow_%d_packets", i); | |
796 | strlcpy(xstats_names[count].name, buf, | |
797 | sizeof(xstats_names[count].name)); | |
798 | ||
799 | count++; | |
800 | } | |
801 | } | |
11fdf7f2 | 802 | } |
f67539c2 | 803 | |
11fdf7f2 TL |
804 | return stat_cnt; |
805 | } | |
806 | ||
f67539c2 | 807 | int bnxt_dev_xstats_reset_op(struct rte_eth_dev *eth_dev) |
11fdf7f2 | 808 | { |
f67539c2 TL |
809 | struct bnxt *bp = eth_dev->data->dev_private; |
810 | int ret; | |
11fdf7f2 | 811 | |
f67539c2 TL |
812 | ret = is_bnxt_in_error(bp); |
813 | if (ret) | |
814 | return ret; | |
11fdf7f2 | 815 | |
f67539c2 TL |
816 | if (BNXT_VF(bp) || !BNXT_SINGLE_PF(bp) || |
817 | !(bp->flags & BNXT_FLAG_PORT_STATS)) { | |
11fdf7f2 | 818 | PMD_DRV_LOG(ERR, "Operation not supported\n"); |
f67539c2 TL |
819 | return -ENOTSUP; |
820 | } | |
821 | ||
822 | ret = bnxt_hwrm_port_clr_stats(bp); | |
823 | if (ret != 0) | |
824 | PMD_DRV_LOG(ERR, "Failed to reset xstats: %s\n", | |
825 | strerror(-ret)); | |
826 | ||
827 | return ret; | |
11fdf7f2 TL |
828 | } |
829 | ||
830 | int bnxt_dev_xstats_get_by_id_op(struct rte_eth_dev *dev, const uint64_t *ids, | |
831 | uint64_t *values, unsigned int limit) | |
832 | { | |
f67539c2 | 833 | struct bnxt *bp = dev->data->dev_private; |
11fdf7f2 | 834 | const unsigned int stat_cnt = RTE_DIM(bnxt_rx_stats_strings) + |
f67539c2 TL |
835 | RTE_DIM(bnxt_tx_stats_strings) + |
836 | RTE_DIM(bnxt_func_stats_strings) + | |
9f95a23c | 837 | RTE_DIM(bnxt_rx_ext_stats_strings) + |
f67539c2 TL |
838 | RTE_DIM(bnxt_tx_ext_stats_strings) + |
839 | bnxt_flow_stats_cnt(bp); | |
11fdf7f2 TL |
840 | struct rte_eth_xstat xstats[stat_cnt]; |
841 | uint64_t values_copy[stat_cnt]; | |
842 | uint16_t i; | |
f67539c2 TL |
843 | int rc; |
844 | ||
845 | rc = is_bnxt_in_error(bp); | |
846 | if (rc) | |
847 | return rc; | |
11fdf7f2 TL |
848 | |
849 | if (!ids) | |
850 | return bnxt_dev_xstats_get_op(dev, xstats, stat_cnt); | |
851 | ||
852 | bnxt_dev_xstats_get_by_id_op(dev, NULL, values_copy, stat_cnt); | |
853 | for (i = 0; i < limit; i++) { | |
854 | if (ids[i] >= stat_cnt) { | |
855 | PMD_DRV_LOG(ERR, "id value isn't valid"); | |
f67539c2 | 856 | return -EINVAL; |
11fdf7f2 TL |
857 | } |
858 | values[i] = values_copy[ids[i]]; | |
859 | } | |
860 | return stat_cnt; | |
861 | } | |
862 | ||
863 | int bnxt_dev_xstats_get_names_by_id_op(struct rte_eth_dev *dev, | |
864 | struct rte_eth_xstat_name *xstats_names, | |
865 | const uint64_t *ids, unsigned int limit) | |
866 | { | |
f67539c2 | 867 | struct bnxt *bp = dev->data->dev_private; |
11fdf7f2 | 868 | const unsigned int stat_cnt = RTE_DIM(bnxt_rx_stats_strings) + |
f67539c2 TL |
869 | RTE_DIM(bnxt_tx_stats_strings) + |
870 | RTE_DIM(bnxt_func_stats_strings) + | |
9f95a23c | 871 | RTE_DIM(bnxt_rx_ext_stats_strings) + |
f67539c2 TL |
872 | RTE_DIM(bnxt_tx_ext_stats_strings) + |
873 | bnxt_flow_stats_cnt(bp); | |
11fdf7f2 TL |
874 | struct rte_eth_xstat_name xstats_names_copy[stat_cnt]; |
875 | uint16_t i; | |
f67539c2 TL |
876 | int rc; |
877 | ||
878 | rc = is_bnxt_in_error(bp); | |
879 | if (rc) | |
880 | return rc; | |
11fdf7f2 TL |
881 | |
882 | if (!ids) | |
883 | return bnxt_dev_xstats_get_names_op(dev, xstats_names, | |
884 | stat_cnt); | |
885 | bnxt_dev_xstats_get_names_by_id_op(dev, xstats_names_copy, NULL, | |
886 | stat_cnt); | |
887 | ||
888 | for (i = 0; i < limit; i++) { | |
889 | if (ids[i] >= stat_cnt) { | |
890 | PMD_DRV_LOG(ERR, "id value isn't valid"); | |
f67539c2 | 891 | return -EINVAL; |
11fdf7f2 TL |
892 | } |
893 | strcpy(xstats_names[i].name, | |
894 | xstats_names_copy[ids[i]].name); | |
895 | } | |
896 | return stat_cnt; | |
897 | } | |
f67539c2 TL |
898 | |
899 | /* Update the input context memory with the flow counter IDs | |
900 | * of the flows that we are interested in. | |
901 | * Also, update the output tables with the current local values | |
902 | * since that is what will be used by FW to accumulate | |
903 | */ | |
904 | static void bnxt_update_fc_pre_qstat(uint32_t *in_tbl, | |
905 | uint64_t *out_tbl, | |
906 | struct bnxt_filter_info *filter, | |
907 | uint32_t *ptbl_cnt) | |
908 | { | |
909 | uint32_t in_tbl_cnt = *ptbl_cnt; | |
910 | ||
911 | in_tbl[in_tbl_cnt] = filter->flow_id; | |
912 | out_tbl[2 * in_tbl_cnt] = filter->hw_stats.packets; | |
913 | out_tbl[2 * in_tbl_cnt + 1] = filter->hw_stats.bytes; | |
914 | in_tbl_cnt++; | |
915 | *ptbl_cnt = in_tbl_cnt; | |
916 | } | |
917 | ||
918 | /* Post issuing counter_qstats cmd, update the driver's local stat | |
919 | * entries with the values DMA-ed by FW in the output table | |
920 | */ | |
921 | static void bnxt_update_fc_post_qstat(struct bnxt_filter_info *filter, | |
922 | uint64_t *out_tbl, | |
923 | uint32_t out_tbl_idx) | |
924 | { | |
925 | filter->hw_stats.packets = out_tbl[2 * out_tbl_idx]; | |
926 | filter->hw_stats.bytes = out_tbl[(2 * out_tbl_idx) + 1]; | |
927 | } | |
928 | ||
929 | static int bnxt_update_fc_tbl(struct bnxt *bp, uint16_t ctr, | |
930 | struct bnxt_filter_info *en_tbl[], | |
931 | uint16_t in_flow_cnt) | |
932 | { | |
933 | uint32_t *in_rx_tbl; | |
934 | uint64_t *out_rx_tbl; | |
935 | uint32_t in_rx_tbl_cnt = 0; | |
936 | uint32_t out_rx_tbl_cnt = 0; | |
937 | int i, rc = 0; | |
938 | ||
939 | in_rx_tbl = (uint32_t *)bp->flow_stat->rx_fc_in_tbl.va; | |
940 | out_rx_tbl = (uint64_t *)bp->flow_stat->rx_fc_out_tbl.va; | |
941 | ||
942 | for (i = 0; i < in_flow_cnt; i++) { | |
943 | if (!en_tbl[i]) | |
944 | continue; | |
945 | ||
946 | /* Currently only ingress/Rx flows are supported anyway. */ | |
947 | bnxt_update_fc_pre_qstat(in_rx_tbl, out_rx_tbl, | |
948 | en_tbl[i], &in_rx_tbl_cnt); | |
949 | } | |
950 | ||
951 | /* Currently only ingress/Rx flows are supported */ | |
952 | if (in_rx_tbl_cnt) { | |
953 | rc = bnxt_hwrm_cfa_counter_qstats(bp, BNXT_DIR_RX, ctr, | |
954 | in_rx_tbl_cnt); | |
955 | if (rc) | |
956 | return rc; | |
957 | } | |
958 | ||
959 | for (i = 0; i < in_flow_cnt; i++) { | |
960 | if (!en_tbl[i]) | |
961 | continue; | |
962 | ||
963 | /* Currently only ingress/Rx flows are supported */ | |
964 | bnxt_update_fc_post_qstat(en_tbl[i], out_rx_tbl, | |
965 | out_rx_tbl_cnt); | |
966 | out_rx_tbl_cnt++; | |
967 | } | |
968 | ||
969 | return rc; | |
970 | } | |
971 | ||
972 | /* Walks through the list which has all the flows | |
973 | * requesting for explicit flow counters. | |
974 | */ | |
975 | int bnxt_flow_stats_req(struct bnxt *bp) | |
976 | { | |
977 | int i; | |
978 | int rc = 0; | |
979 | struct rte_flow *flow; | |
980 | uint16_t in_flow_tbl_cnt = 0; | |
981 | struct bnxt_vnic_info *vnic = NULL; | |
982 | struct bnxt_filter_info *valid_en_tbl[bp->flow_stat->max_fc]; | |
983 | uint16_t counter_type = CFA_COUNTER_CFG_IN_COUNTER_TYPE_FC; | |
984 | ||
985 | bnxt_acquire_flow_lock(bp); | |
986 | for (i = 0; i < bp->max_vnics; i++) { | |
987 | vnic = &bp->vnic_info[i]; | |
988 | if (vnic && vnic->fw_vnic_id == INVALID_VNIC_ID) | |
989 | continue; | |
990 | ||
991 | if (STAILQ_EMPTY(&vnic->flow_list)) | |
992 | continue; | |
993 | ||
994 | STAILQ_FOREACH(flow, &vnic->flow_list, next) { | |
995 | if (!flow || !flow->filter) | |
996 | continue; | |
997 | ||
998 | valid_en_tbl[in_flow_tbl_cnt++] = flow->filter; | |
999 | if (in_flow_tbl_cnt >= bp->flow_stat->max_fc) { | |
1000 | rc = bnxt_update_fc_tbl(bp, counter_type, | |
1001 | valid_en_tbl, | |
1002 | in_flow_tbl_cnt); | |
1003 | if (rc) | |
1004 | goto err; | |
1005 | in_flow_tbl_cnt = 0; | |
1006 | continue; | |
1007 | } | |
1008 | } | |
1009 | } | |
1010 | ||
1011 | if (!in_flow_tbl_cnt) | |
1012 | goto out; | |
1013 | ||
1014 | rc = bnxt_update_fc_tbl(bp, counter_type, valid_en_tbl, | |
1015 | in_flow_tbl_cnt); | |
1016 | if (!rc) { | |
1017 | bnxt_release_flow_lock(bp); | |
1018 | return 0; | |
1019 | } | |
1020 | ||
1021 | err: | |
1022 | /* If cmd fails once, no need of | |
1023 | * invoking again every second | |
1024 | */ | |
1025 | bnxt_release_flow_lock(bp); | |
1026 | bnxt_cancel_fc_thread(bp); | |
1027 | out: | |
1028 | return rc; | |
1029 | } |