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