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