Commit | Line | Data |
---|---|---|
6c719d00 DK |
1 | /* bnx2x_stats.h: Broadcom Everest network driver. |
2 | * | |
247fa82b | 3 | * Copyright (c) 2007-2013 Broadcom Corporation |
6c719d00 DK |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation. | |
8 | * | |
9 | * Maintained by: Eilon Greenstein <eilong@broadcom.com> | |
10 | * Written by: Eliezer Tamir | |
11 | * Based on code from Michael Chan's bnx2 driver | |
f85582f8 DK |
12 | * UDP CSUM errata workaround by Arik Gendelman |
13 | * Slowpath and fastpath rework by Vladislav Zolotarov | |
14 | * Statistics and Link management by Yitchak Gertner | |
15 | * | |
6c719d00 | 16 | */ |
6c719d00 DK |
17 | #ifndef BNX2X_STATS_H |
18 | #define BNX2X_STATS_H | |
19 | ||
20 | #include <linux/types.h> | |
21 | ||
6c719d00 DK |
22 | struct nig_stats { |
23 | u32 brb_discard; | |
24 | u32 brb_packet; | |
25 | u32 brb_truncate; | |
26 | u32 flow_ctrl_discard; | |
27 | u32 flow_ctrl_octets; | |
28 | u32 flow_ctrl_packet; | |
29 | u32 mng_discard; | |
30 | u32 mng_octet_inp; | |
31 | u32 mng_octet_out; | |
32 | u32 mng_packet_inp; | |
33 | u32 mng_packet_out; | |
34 | u32 pbf_octets; | |
35 | u32 pbf_packet; | |
36 | u32 safc_inp; | |
37 | u32 egress_mac_pkt0_lo; | |
38 | u32 egress_mac_pkt0_hi; | |
39 | u32 egress_mac_pkt1_lo; | |
40 | u32 egress_mac_pkt1_hi; | |
41 | }; | |
42 | ||
43 | ||
44 | enum bnx2x_stats_event { | |
45 | STATS_EVENT_PMF = 0, | |
46 | STATS_EVENT_LINK_UP, | |
47 | STATS_EVENT_UPDATE, | |
48 | STATS_EVENT_STOP, | |
49 | STATS_EVENT_MAX | |
50 | }; | |
51 | ||
52 | enum bnx2x_stats_state { | |
53 | STATS_STATE_DISABLED = 0, | |
54 | STATS_STATE_ENABLED, | |
55 | STATS_STATE_MAX | |
56 | }; | |
57 | ||
58 | struct bnx2x_eth_stats { | |
59 | u32 total_bytes_received_hi; | |
60 | u32 total_bytes_received_lo; | |
61 | u32 total_bytes_transmitted_hi; | |
62 | u32 total_bytes_transmitted_lo; | |
63 | u32 total_unicast_packets_received_hi; | |
64 | u32 total_unicast_packets_received_lo; | |
65 | u32 total_multicast_packets_received_hi; | |
66 | u32 total_multicast_packets_received_lo; | |
67 | u32 total_broadcast_packets_received_hi; | |
68 | u32 total_broadcast_packets_received_lo; | |
69 | u32 total_unicast_packets_transmitted_hi; | |
70 | u32 total_unicast_packets_transmitted_lo; | |
71 | u32 total_multicast_packets_transmitted_hi; | |
72 | u32 total_multicast_packets_transmitted_lo; | |
73 | u32 total_broadcast_packets_transmitted_hi; | |
74 | u32 total_broadcast_packets_transmitted_lo; | |
75 | u32 valid_bytes_received_hi; | |
76 | u32 valid_bytes_received_lo; | |
77 | ||
78 | u32 error_bytes_received_hi; | |
79 | u32 error_bytes_received_lo; | |
80 | u32 etherstatsoverrsizepkts_hi; | |
81 | u32 etherstatsoverrsizepkts_lo; | |
82 | u32 no_buff_discard_hi; | |
83 | u32 no_buff_discard_lo; | |
84 | ||
85 | u32 rx_stat_ifhcinbadoctets_hi; | |
86 | u32 rx_stat_ifhcinbadoctets_lo; | |
87 | u32 tx_stat_ifhcoutbadoctets_hi; | |
88 | u32 tx_stat_ifhcoutbadoctets_lo; | |
89 | u32 rx_stat_dot3statsfcserrors_hi; | |
90 | u32 rx_stat_dot3statsfcserrors_lo; | |
91 | u32 rx_stat_dot3statsalignmenterrors_hi; | |
92 | u32 rx_stat_dot3statsalignmenterrors_lo; | |
93 | u32 rx_stat_dot3statscarriersenseerrors_hi; | |
94 | u32 rx_stat_dot3statscarriersenseerrors_lo; | |
95 | u32 rx_stat_falsecarriererrors_hi; | |
96 | u32 rx_stat_falsecarriererrors_lo; | |
97 | u32 rx_stat_etherstatsundersizepkts_hi; | |
98 | u32 rx_stat_etherstatsundersizepkts_lo; | |
99 | u32 rx_stat_dot3statsframestoolong_hi; | |
100 | u32 rx_stat_dot3statsframestoolong_lo; | |
101 | u32 rx_stat_etherstatsfragments_hi; | |
102 | u32 rx_stat_etherstatsfragments_lo; | |
103 | u32 rx_stat_etherstatsjabbers_hi; | |
104 | u32 rx_stat_etherstatsjabbers_lo; | |
105 | u32 rx_stat_maccontrolframesreceived_hi; | |
106 | u32 rx_stat_maccontrolframesreceived_lo; | |
107 | u32 rx_stat_bmac_xpf_hi; | |
108 | u32 rx_stat_bmac_xpf_lo; | |
109 | u32 rx_stat_bmac_xcf_hi; | |
110 | u32 rx_stat_bmac_xcf_lo; | |
111 | u32 rx_stat_xoffstateentered_hi; | |
112 | u32 rx_stat_xoffstateentered_lo; | |
113 | u32 rx_stat_xonpauseframesreceived_hi; | |
114 | u32 rx_stat_xonpauseframesreceived_lo; | |
115 | u32 rx_stat_xoffpauseframesreceived_hi; | |
116 | u32 rx_stat_xoffpauseframesreceived_lo; | |
117 | u32 tx_stat_outxonsent_hi; | |
118 | u32 tx_stat_outxonsent_lo; | |
119 | u32 tx_stat_outxoffsent_hi; | |
120 | u32 tx_stat_outxoffsent_lo; | |
121 | u32 tx_stat_flowcontroldone_hi; | |
122 | u32 tx_stat_flowcontroldone_lo; | |
123 | u32 tx_stat_etherstatscollisions_hi; | |
124 | u32 tx_stat_etherstatscollisions_lo; | |
125 | u32 tx_stat_dot3statssinglecollisionframes_hi; | |
126 | u32 tx_stat_dot3statssinglecollisionframes_lo; | |
127 | u32 tx_stat_dot3statsmultiplecollisionframes_hi; | |
128 | u32 tx_stat_dot3statsmultiplecollisionframes_lo; | |
129 | u32 tx_stat_dot3statsdeferredtransmissions_hi; | |
130 | u32 tx_stat_dot3statsdeferredtransmissions_lo; | |
131 | u32 tx_stat_dot3statsexcessivecollisions_hi; | |
132 | u32 tx_stat_dot3statsexcessivecollisions_lo; | |
133 | u32 tx_stat_dot3statslatecollisions_hi; | |
134 | u32 tx_stat_dot3statslatecollisions_lo; | |
135 | u32 tx_stat_etherstatspkts64octets_hi; | |
136 | u32 tx_stat_etherstatspkts64octets_lo; | |
137 | u32 tx_stat_etherstatspkts65octetsto127octets_hi; | |
138 | u32 tx_stat_etherstatspkts65octetsto127octets_lo; | |
139 | u32 tx_stat_etherstatspkts128octetsto255octets_hi; | |
140 | u32 tx_stat_etherstatspkts128octetsto255octets_lo; | |
141 | u32 tx_stat_etherstatspkts256octetsto511octets_hi; | |
142 | u32 tx_stat_etherstatspkts256octetsto511octets_lo; | |
143 | u32 tx_stat_etherstatspkts512octetsto1023octets_hi; | |
144 | u32 tx_stat_etherstatspkts512octetsto1023octets_lo; | |
145 | u32 tx_stat_etherstatspkts1024octetsto1522octets_hi; | |
146 | u32 tx_stat_etherstatspkts1024octetsto1522octets_lo; | |
147 | u32 tx_stat_etherstatspktsover1522octets_hi; | |
148 | u32 tx_stat_etherstatspktsover1522octets_lo; | |
149 | u32 tx_stat_bmac_2047_hi; | |
150 | u32 tx_stat_bmac_2047_lo; | |
151 | u32 tx_stat_bmac_4095_hi; | |
152 | u32 tx_stat_bmac_4095_lo; | |
153 | u32 tx_stat_bmac_9216_hi; | |
154 | u32 tx_stat_bmac_9216_lo; | |
155 | u32 tx_stat_bmac_16383_hi; | |
156 | u32 tx_stat_bmac_16383_lo; | |
157 | u32 tx_stat_dot3statsinternalmactransmiterrors_hi; | |
158 | u32 tx_stat_dot3statsinternalmactransmiterrors_lo; | |
159 | u32 tx_stat_bmac_ufl_hi; | |
160 | u32 tx_stat_bmac_ufl_lo; | |
161 | ||
162 | u32 pause_frames_received_hi; | |
163 | u32 pause_frames_received_lo; | |
164 | u32 pause_frames_sent_hi; | |
165 | u32 pause_frames_sent_lo; | |
166 | ||
167 | u32 etherstatspkts1024octetsto1522octets_hi; | |
168 | u32 etherstatspkts1024octetsto1522octets_lo; | |
169 | u32 etherstatspktsover1522octets_hi; | |
170 | u32 etherstatspktsover1522octets_lo; | |
171 | ||
172 | u32 brb_drop_hi; | |
173 | u32 brb_drop_lo; | |
174 | u32 brb_truncate_hi; | |
175 | u32 brb_truncate_lo; | |
176 | ||
177 | u32 mac_filter_discard; | |
619c5cb6 | 178 | u32 mf_tag_discard; |
6c719d00 DK |
179 | u32 brb_truncate_discard; |
180 | u32 mac_discard; | |
181 | ||
182 | u32 driver_xoff; | |
183 | u32 rx_err_discard_pkt; | |
184 | u32 rx_skb_alloc_failed; | |
185 | u32 hw_csum_err; | |
186 | ||
187 | u32 nig_timer_max; | |
619c5cb6 VZ |
188 | |
189 | /* TPA */ | |
190 | u32 total_tpa_aggregations_hi; | |
191 | u32 total_tpa_aggregations_lo; | |
192 | u32 total_tpa_aggregated_frames_hi; | |
193 | u32 total_tpa_aggregated_frames_lo; | |
194 | u32 total_tpa_bytes_hi; | |
195 | u32 total_tpa_bytes_lo; | |
0e898dd7 BW |
196 | |
197 | /* PFC */ | |
198 | u32 pfc_frames_received_hi; | |
199 | u32 pfc_frames_received_lo; | |
200 | u32 pfc_frames_sent_hi; | |
201 | u32 pfc_frames_sent_lo; | |
7a752993 AE |
202 | |
203 | /* Recovery */ | |
204 | u32 recoverable_error; | |
205 | u32 unrecoverable_error; | |
c96bdc0c | 206 | u32 driver_filtered_tx_pkt; |
c8c60d88 YM |
207 | /* src: Clear-on-Read register; Will not survive PMF Migration */ |
208 | u32 eee_tx_lpi; | |
619c5cb6 VZ |
209 | }; |
210 | ||
211 | ||
212 | struct bnx2x_eth_q_stats { | |
213 | u32 total_unicast_bytes_received_hi; | |
214 | u32 total_unicast_bytes_received_lo; | |
215 | u32 total_broadcast_bytes_received_hi; | |
216 | u32 total_broadcast_bytes_received_lo; | |
217 | u32 total_multicast_bytes_received_hi; | |
218 | u32 total_multicast_bytes_received_lo; | |
219 | u32 total_bytes_received_hi; | |
220 | u32 total_bytes_received_lo; | |
221 | u32 total_unicast_bytes_transmitted_hi; | |
222 | u32 total_unicast_bytes_transmitted_lo; | |
223 | u32 total_broadcast_bytes_transmitted_hi; | |
224 | u32 total_broadcast_bytes_transmitted_lo; | |
225 | u32 total_multicast_bytes_transmitted_hi; | |
226 | u32 total_multicast_bytes_transmitted_lo; | |
227 | u32 total_bytes_transmitted_hi; | |
228 | u32 total_bytes_transmitted_lo; | |
229 | u32 total_unicast_packets_received_hi; | |
230 | u32 total_unicast_packets_received_lo; | |
231 | u32 total_multicast_packets_received_hi; | |
232 | u32 total_multicast_packets_received_lo; | |
233 | u32 total_broadcast_packets_received_hi; | |
234 | u32 total_broadcast_packets_received_lo; | |
235 | u32 total_unicast_packets_transmitted_hi; | |
236 | u32 total_unicast_packets_transmitted_lo; | |
237 | u32 total_multicast_packets_transmitted_hi; | |
238 | u32 total_multicast_packets_transmitted_lo; | |
239 | u32 total_broadcast_packets_transmitted_hi; | |
240 | u32 total_broadcast_packets_transmitted_lo; | |
241 | u32 valid_bytes_received_hi; | |
242 | u32 valid_bytes_received_lo; | |
243 | ||
244 | u32 etherstatsoverrsizepkts_hi; | |
245 | u32 etherstatsoverrsizepkts_lo; | |
246 | u32 no_buff_discard_hi; | |
247 | u32 no_buff_discard_lo; | |
248 | ||
249 | u32 driver_xoff; | |
250 | u32 rx_err_discard_pkt; | |
251 | u32 rx_skb_alloc_failed; | |
252 | u32 hw_csum_err; | |
253 | ||
254 | u32 total_packets_received_checksum_discarded_hi; | |
255 | u32 total_packets_received_checksum_discarded_lo; | |
256 | u32 total_packets_received_ttl0_discarded_hi; | |
257 | u32 total_packets_received_ttl0_discarded_lo; | |
258 | u32 total_transmitted_dropped_packets_error_hi; | |
259 | u32 total_transmitted_dropped_packets_error_lo; | |
260 | ||
261 | /* TPA */ | |
262 | u32 total_tpa_aggregations_hi; | |
263 | u32 total_tpa_aggregations_lo; | |
264 | u32 total_tpa_aggregated_frames_hi; | |
265 | u32 total_tpa_aggregated_frames_lo; | |
266 | u32 total_tpa_bytes_hi; | |
267 | u32 total_tpa_bytes_lo; | |
c96bdc0c | 268 | u32 driver_filtered_tx_pkt; |
6c719d00 DK |
269 | }; |
270 | ||
1355b704 MY |
271 | struct bnx2x_eth_stats_old { |
272 | u32 rx_stat_dot3statsframestoolong_hi; | |
273 | u32 rx_stat_dot3statsframestoolong_lo; | |
274 | }; | |
275 | ||
276 | struct bnx2x_eth_q_stats_old { | |
277 | /* Fields to perserve over fw reset*/ | |
278 | u32 total_unicast_bytes_received_hi; | |
279 | u32 total_unicast_bytes_received_lo; | |
280 | u32 total_broadcast_bytes_received_hi; | |
281 | u32 total_broadcast_bytes_received_lo; | |
282 | u32 total_multicast_bytes_received_hi; | |
283 | u32 total_multicast_bytes_received_lo; | |
284 | u32 total_unicast_bytes_transmitted_hi; | |
285 | u32 total_unicast_bytes_transmitted_lo; | |
286 | u32 total_broadcast_bytes_transmitted_hi; | |
287 | u32 total_broadcast_bytes_transmitted_lo; | |
288 | u32 total_multicast_bytes_transmitted_hi; | |
289 | u32 total_multicast_bytes_transmitted_lo; | |
290 | u32 total_tpa_bytes_hi; | |
291 | u32 total_tpa_bytes_lo; | |
292 | ||
293 | /* Fields to perserve last of */ | |
294 | u32 total_bytes_received_hi; | |
295 | u32 total_bytes_received_lo; | |
296 | u32 total_bytes_transmitted_hi; | |
297 | u32 total_bytes_transmitted_lo; | |
298 | u32 total_unicast_packets_received_hi; | |
299 | u32 total_unicast_packets_received_lo; | |
300 | u32 total_multicast_packets_received_hi; | |
301 | u32 total_multicast_packets_received_lo; | |
302 | u32 total_broadcast_packets_received_hi; | |
303 | u32 total_broadcast_packets_received_lo; | |
304 | u32 total_unicast_packets_transmitted_hi; | |
305 | u32 total_unicast_packets_transmitted_lo; | |
306 | u32 total_multicast_packets_transmitted_hi; | |
307 | u32 total_multicast_packets_transmitted_lo; | |
308 | u32 total_broadcast_packets_transmitted_hi; | |
309 | u32 total_broadcast_packets_transmitted_lo; | |
310 | u32 valid_bytes_received_hi; | |
311 | u32 valid_bytes_received_lo; | |
312 | ||
313 | u32 total_tpa_bytes_hi_old; | |
314 | u32 total_tpa_bytes_lo_old; | |
315 | ||
316 | u32 driver_xoff_old; | |
317 | u32 rx_err_discard_pkt_old; | |
318 | u32 rx_skb_alloc_failed_old; | |
319 | u32 hw_csum_err_old; | |
c96bdc0c | 320 | u32 driver_filtered_tx_pkt_old; |
1355b704 MY |
321 | }; |
322 | ||
323 | struct bnx2x_net_stats_old { | |
324 | u32 rx_dropped; | |
325 | }; | |
326 | ||
327 | struct bnx2x_fw_port_stats_old { | |
328 | u32 mac_filter_discard; | |
329 | u32 mf_tag_discard; | |
330 | u32 brb_truncate_discard; | |
331 | u32 mac_discard; | |
332 | }; | |
333 | ||
334 | ||
619c5cb6 VZ |
335 | /**************************************************************************** |
336 | * Macros | |
337 | ****************************************************************************/ | |
338 | ||
339 | /* sum[hi:lo] += add[hi:lo] */ | |
340 | #define ADD_64(s_hi, a_hi, s_lo, a_lo) \ | |
341 | do { \ | |
342 | s_lo += a_lo; \ | |
343 | s_hi += a_hi + ((s_lo < a_lo) ? 1 : 0); \ | |
344 | } while (0) | |
345 | ||
a3348722 BW |
346 | #define LE32_0 ((__force __le32) 0) |
347 | #define LE16_0 ((__force __le16) 0) | |
348 | ||
349 | /* The _force is for cases where high value is 0 */ | |
350 | #define ADD_64_LE(s_hi, a_hi_le, s_lo, a_lo_le) \ | |
351 | ADD_64(s_hi, le32_to_cpu(a_hi_le), \ | |
352 | s_lo, le32_to_cpu(a_lo_le)) | |
353 | ||
354 | #define ADD_64_LE16(s_hi, a_hi_le, s_lo, a_lo_le) \ | |
355 | ADD_64(s_hi, le16_to_cpu(a_hi_le), \ | |
356 | s_lo, le16_to_cpu(a_lo_le)) | |
357 | ||
619c5cb6 VZ |
358 | /* difference = minuend - subtrahend */ |
359 | #define DIFF_64(d_hi, m_hi, s_hi, d_lo, m_lo, s_lo) \ | |
360 | do { \ | |
361 | if (m_lo < s_lo) { \ | |
362 | /* underflow */ \ | |
363 | d_hi = m_hi - s_hi; \ | |
364 | if (d_hi > 0) { \ | |
365 | /* we can 'loan' 1 */ \ | |
366 | d_hi--; \ | |
367 | d_lo = m_lo + (UINT_MAX - s_lo) + 1; \ | |
368 | } else { \ | |
369 | /* m_hi <= s_hi */ \ | |
370 | d_hi = 0; \ | |
371 | d_lo = 0; \ | |
372 | } \ | |
373 | } else { \ | |
374 | /* m_lo >= s_lo */ \ | |
375 | if (m_hi < s_hi) { \ | |
376 | d_hi = 0; \ | |
377 | d_lo = 0; \ | |
378 | } else { \ | |
379 | /* m_hi >= s_hi */ \ | |
380 | d_hi = m_hi - s_hi; \ | |
381 | d_lo = m_lo - s_lo; \ | |
382 | } \ | |
383 | } \ | |
384 | } while (0) | |
385 | ||
386 | #define UPDATE_STAT64(s, t) \ | |
387 | do { \ | |
388 | DIFF_64(diff.hi, new->s##_hi, pstats->mac_stx[0].t##_hi, \ | |
389 | diff.lo, new->s##_lo, pstats->mac_stx[0].t##_lo); \ | |
390 | pstats->mac_stx[0].t##_hi = new->s##_hi; \ | |
391 | pstats->mac_stx[0].t##_lo = new->s##_lo; \ | |
392 | ADD_64(pstats->mac_stx[1].t##_hi, diff.hi, \ | |
393 | pstats->mac_stx[1].t##_lo, diff.lo); \ | |
394 | } while (0) | |
395 | ||
396 | #define UPDATE_STAT64_NIG(s, t) \ | |
397 | do { \ | |
398 | DIFF_64(diff.hi, new->s##_hi, old->s##_hi, \ | |
399 | diff.lo, new->s##_lo, old->s##_lo); \ | |
400 | ADD_64(estats->t##_hi, diff.hi, \ | |
401 | estats->t##_lo, diff.lo); \ | |
402 | } while (0) | |
403 | ||
404 | /* sum[hi:lo] += add */ | |
405 | #define ADD_EXTEND_64(s_hi, s_lo, a) \ | |
406 | do { \ | |
407 | s_lo += a; \ | |
408 | s_hi += (s_lo < a) ? 1 : 0; \ | |
409 | } while (0) | |
410 | ||
411 | #define ADD_STAT64(diff, t) \ | |
412 | do { \ | |
413 | ADD_64(pstats->mac_stx[1].t##_hi, new->diff##_hi, \ | |
414 | pstats->mac_stx[1].t##_lo, new->diff##_lo); \ | |
415 | } while (0) | |
416 | ||
417 | #define UPDATE_EXTEND_STAT(s) \ | |
418 | do { \ | |
419 | ADD_EXTEND_64(pstats->mac_stx[1].s##_hi, \ | |
420 | pstats->mac_stx[1].s##_lo, \ | |
421 | new->s); \ | |
422 | } while (0) | |
423 | ||
86564c3f | 424 | #define UPDATE_EXTEND_TSTAT_X(s, t, size) \ |
619c5cb6 | 425 | do { \ |
86564c3f YM |
426 | diff = le##size##_to_cpu(tclient->s) - \ |
427 | le##size##_to_cpu(old_tclient->s); \ | |
619c5cb6 VZ |
428 | old_tclient->s = tclient->s; \ |
429 | ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \ | |
430 | } while (0) | |
431 | ||
86564c3f YM |
432 | #define UPDATE_EXTEND_TSTAT(s, t) UPDATE_EXTEND_TSTAT_X(s, t, 32) |
433 | ||
434 | #define UPDATE_EXTEND_E_TSTAT(s, t, size) \ | |
1355b704 | 435 | do { \ |
86564c3f | 436 | UPDATE_EXTEND_TSTAT_X(s, t, size); \ |
1355b704 MY |
437 | ADD_EXTEND_64(estats->t##_hi, estats->t##_lo, diff); \ |
438 | } while (0) | |
439 | ||
619c5cb6 VZ |
440 | #define UPDATE_EXTEND_USTAT(s, t) \ |
441 | do { \ | |
442 | diff = le32_to_cpu(uclient->s) - le32_to_cpu(old_uclient->s); \ | |
443 | old_uclient->s = uclient->s; \ | |
cb4dca27 | 444 | ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \ |
1355b704 MY |
445 | } while (0) |
446 | ||
447 | #define UPDATE_EXTEND_E_USTAT(s, t) \ | |
448 | do { \ | |
449 | UPDATE_EXTEND_USTAT(s, t); \ | |
450 | ADD_EXTEND_64(estats->t##_hi, estats->t##_lo, diff); \ | |
619c5cb6 VZ |
451 | } while (0) |
452 | ||
453 | #define UPDATE_EXTEND_XSTAT(s, t) \ | |
454 | do { \ | |
455 | diff = le32_to_cpu(xclient->s) - le32_to_cpu(old_xclient->s); \ | |
456 | old_xclient->s = xclient->s; \ | |
457 | ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \ | |
458 | } while (0) | |
459 | ||
1355b704 MY |
460 | #define UPDATE_QSTAT(s, t) \ |
461 | do { \ | |
1355b704 | 462 | qstats->t##_lo = qstats_old->t##_lo + le32_to_cpu(s.lo); \ |
b009aac1 MŻ |
463 | qstats->t##_hi = qstats_old->t##_hi + le32_to_cpu(s.hi) \ |
464 | + ((qstats->t##_lo < qstats_old->t##_lo) ? 1 : 0); \ | |
1355b704 MY |
465 | } while (0) |
466 | ||
467 | #define UPDATE_QSTAT_OLD(f) \ | |
468 | do { \ | |
469 | qstats_old->f = qstats->f; \ | |
470 | } while (0) | |
471 | ||
472 | #define UPDATE_ESTAT_QSTAT_64(s) \ | |
473 | do { \ | |
474 | ADD_64(estats->s##_hi, qstats->s##_hi, \ | |
475 | estats->s##_lo, qstats->s##_lo); \ | |
476 | SUB_64(estats->s##_hi, qstats_old->s##_hi_old, \ | |
477 | estats->s##_lo, qstats_old->s##_lo_old); \ | |
478 | qstats_old->s##_hi_old = qstats->s##_hi; \ | |
479 | qstats_old->s##_lo_old = qstats->s##_lo; \ | |
480 | } while (0) | |
481 | ||
482 | #define UPDATE_ESTAT_QSTAT(s) \ | |
483 | do { \ | |
484 | estats->s += qstats->s; \ | |
485 | estats->s -= qstats_old->s##_old; \ | |
486 | qstats_old->s##_old = qstats->s; \ | |
487 | } while (0) | |
488 | ||
489 | #define UPDATE_FSTAT_QSTAT(s) \ | |
490 | do { \ | |
491 | ADD_64(fstats->s##_hi, qstats->s##_hi, \ | |
492 | fstats->s##_lo, qstats->s##_lo); \ | |
493 | SUB_64(fstats->s##_hi, qstats_old->s##_hi, \ | |
494 | fstats->s##_lo, qstats_old->s##_lo); \ | |
495 | estats->s##_hi = fstats->s##_hi; \ | |
496 | estats->s##_lo = fstats->s##_lo; \ | |
497 | qstats_old->s##_hi = qstats->s##_hi; \ | |
498 | qstats_old->s##_lo = qstats->s##_lo; \ | |
499 | } while (0) | |
500 | ||
501 | #define UPDATE_FW_STAT(s) \ | |
502 | do { \ | |
503 | estats->s = le32_to_cpu(tport->s) + fwstats->s; \ | |
504 | } while (0) | |
505 | ||
506 | #define UPDATE_FW_STAT_OLD(f) \ | |
507 | do { \ | |
508 | fwstats->f = estats->f; \ | |
509 | } while (0) | |
510 | ||
511 | #define UPDATE_ESTAT(s, t) \ | |
512 | do { \ | |
513 | SUB_64(estats->s##_hi, estats_old->t##_hi, \ | |
514 | estats->s##_lo, estats_old->t##_lo); \ | |
515 | ADD_64(estats->s##_hi, estats->t##_hi, \ | |
516 | estats->s##_lo, estats->t##_lo); \ | |
517 | estats_old->t##_hi = estats->t##_hi; \ | |
518 | estats_old->t##_lo = estats->t##_lo; \ | |
519 | } while (0) | |
520 | ||
619c5cb6 VZ |
521 | /* minuend -= subtrahend */ |
522 | #define SUB_64(m_hi, s_hi, m_lo, s_lo) \ | |
523 | do { \ | |
524 | DIFF_64(m_hi, m_hi, s_hi, m_lo, m_lo, s_lo); \ | |
525 | } while (0) | |
526 | ||
527 | /* minuend[hi:lo] -= subtrahend */ | |
528 | #define SUB_EXTEND_64(m_hi, m_lo, s) \ | |
529 | do { \ | |
530 | SUB_64(m_hi, 0, m_lo, s); \ | |
531 | } while (0) | |
532 | ||
533 | #define SUB_EXTEND_USTAT(s, t) \ | |
534 | do { \ | |
535 | diff = le32_to_cpu(uclient->s) - le32_to_cpu(old_uclient->s); \ | |
536 | SUB_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \ | |
537 | } while (0) | |
538 | ||
6c719d00 | 539 | |
619c5cb6 | 540 | /* forward */ |
6c719d00 DK |
541 | struct bnx2x; |
542 | ||
6c719d00 DK |
543 | void bnx2x_stats_init(struct bnx2x *bp); |
544 | ||
619c5cb6 | 545 | void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event); |
6c719d00 | 546 | |
1355b704 MY |
547 | /** |
548 | * bnx2x_save_statistics - save statistics when unloading. | |
549 | * | |
550 | * @bp: driver handle | |
551 | */ | |
552 | void bnx2x_save_statistics(struct bnx2x *bp); | |
a3348722 BW |
553 | |
554 | void bnx2x_afex_collect_stats(struct bnx2x *bp, void *void_afex_stats, | |
555 | u32 stats_type); | |
6c719d00 | 556 | #endif /* BNX2X_STATS_H */ |