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