]> git.proxmox.com Git - ceph.git/blob - ceph/src/dpdk/drivers/net/bnx2x/bnx2x_stats.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / dpdk / drivers / net / bnx2x / bnx2x_stats.h
1 /*-
2 * Copyright (c) 2007-2013 QLogic Corporation. All rights reserved.
3 *
4 * Eric Davis <edavis@broadcom.com>
5 * David Christensen <davidch@broadcom.com>
6 * Gary Zambrano <zambrano@broadcom.com>
7 *
8 * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
9 * Copyright (c) 2015 QLogic Corporation.
10 * All rights reserved.
11 * www.qlogic.com
12 *
13 * See LICENSE.bnx2x_pmd for copyright and licensing details.
14 */
15
16 #ifndef BNX2X_STATS_H
17 #define BNX2X_STATS_H
18
19 #include <sys/types.h>
20
21 struct nig_stats {
22 uint32_t brb_discard;
23 uint32_t brb_packet;
24 uint32_t brb_truncate;
25 uint32_t flow_ctrl_discard;
26 uint32_t flow_ctrl_octets;
27 uint32_t flow_ctrl_packet;
28 uint32_t mng_discard;
29 uint32_t mng_octet_inp;
30 uint32_t mng_octet_out;
31 uint32_t mng_packet_inp;
32 uint32_t mng_packet_out;
33 uint32_t pbf_octets;
34 uint32_t pbf_packet;
35 uint32_t safc_inp;
36 uint32_t egress_mac_pkt0_lo;
37 uint32_t egress_mac_pkt0_hi;
38 uint32_t egress_mac_pkt1_lo;
39 uint32_t egress_mac_pkt1_hi;
40 };
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 nig_timer_max;
182
183 /* PFC */
184 uint32_t pfc_frames_received_hi;
185 uint32_t pfc_frames_received_lo;
186 uint32_t pfc_frames_sent_hi;
187 uint32_t pfc_frames_sent_lo;
188
189 /* Recovery */
190 uint32_t recoverable_error;
191 uint32_t unrecoverable_error;
192
193 /* src: Clear-on-Read register; Will not survive PMF Migration */
194 uint32_t eee_tx_lpi;
195
196 /* receive path driver statistics */
197 uint32_t rx_calls;
198 uint32_t rx_pkts;
199 uint32_t rx_soft_errors;
200 uint32_t rx_hw_csum_errors;
201 uint32_t rx_ofld_frames_csum_ip;
202 uint32_t rx_ofld_frames_csum_tcp_udp;
203 uint32_t rx_budget_reached;
204
205 /* tx path driver statistics */
206 uint32_t tx_pkts;
207 uint32_t tx_soft_errors;
208 uint32_t tx_ofld_frames_csum_ip;
209 uint32_t tx_ofld_frames_csum_tcp;
210 uint32_t tx_ofld_frames_csum_udp;
211 uint32_t tx_encap_failures;
212 uint32_t tx_hw_queue_full;
213 uint32_t tx_hw_max_queue_depth;
214 uint32_t tx_dma_mapping_failure;
215 uint32_t tx_max_drbr_queue_depth;
216 uint32_t tx_window_violation_std;
217 uint32_t tx_chain_lost_mbuf;
218 uint32_t tx_frames_deferred;
219 uint32_t tx_queue_xoff;
220
221 /* mbuf driver statistics */
222 uint32_t mbuf_defrag_attempts;
223 uint32_t mbuf_defrag_failures;
224 uint32_t mbuf_rx_bd_alloc_failed;
225 uint32_t mbuf_rx_bd_mapping_failed;
226
227 /* track the number of allocated mbufs */
228 uint32_t mbuf_alloc_tx;
229 uint32_t mbuf_alloc_rx;
230 };
231
232
233 struct bnx2x_eth_q_stats {
234 uint32_t total_unicast_bytes_received_hi;
235 uint32_t total_unicast_bytes_received_lo;
236 uint32_t total_broadcast_bytes_received_hi;
237 uint32_t total_broadcast_bytes_received_lo;
238 uint32_t total_multicast_bytes_received_hi;
239 uint32_t total_multicast_bytes_received_lo;
240 uint32_t total_bytes_received_hi;
241 uint32_t total_bytes_received_lo;
242 uint32_t total_unicast_bytes_transmitted_hi;
243 uint32_t total_unicast_bytes_transmitted_lo;
244 uint32_t total_broadcast_bytes_transmitted_hi;
245 uint32_t total_broadcast_bytes_transmitted_lo;
246 uint32_t total_multicast_bytes_transmitted_hi;
247 uint32_t total_multicast_bytes_transmitted_lo;
248 uint32_t total_bytes_transmitted_hi;
249 uint32_t total_bytes_transmitted_lo;
250 uint32_t total_unicast_packets_received_hi;
251 uint32_t total_unicast_packets_received_lo;
252 uint32_t total_multicast_packets_received_hi;
253 uint32_t total_multicast_packets_received_lo;
254 uint32_t total_broadcast_packets_received_hi;
255 uint32_t total_broadcast_packets_received_lo;
256 uint32_t total_unicast_packets_transmitted_hi;
257 uint32_t total_unicast_packets_transmitted_lo;
258 uint32_t total_multicast_packets_transmitted_hi;
259 uint32_t total_multicast_packets_transmitted_lo;
260 uint32_t total_broadcast_packets_transmitted_hi;
261 uint32_t total_broadcast_packets_transmitted_lo;
262 uint32_t valid_bytes_received_hi;
263 uint32_t valid_bytes_received_lo;
264
265 uint32_t etherstatsoverrsizepkts_hi;
266 uint32_t etherstatsoverrsizepkts_lo;
267 uint32_t no_buff_discard_hi;
268 uint32_t no_buff_discard_lo;
269
270 uint32_t total_packets_received_checksum_discarded_hi;
271 uint32_t total_packets_received_checksum_discarded_lo;
272 uint32_t total_packets_received_ttl0_discarded_hi;
273 uint32_t total_packets_received_ttl0_discarded_lo;
274 uint32_t total_transmitted_dropped_packets_error_hi;
275 uint32_t total_transmitted_dropped_packets_error_lo;
276
277 /* receive path driver statistics */
278 uint32_t rx_calls;
279 uint32_t rx_pkts;
280 uint32_t rx_soft_errors;
281 uint32_t rx_hw_csum_errors;
282 uint32_t rx_ofld_frames_csum_ip;
283 uint32_t rx_ofld_frames_csum_tcp_udp;
284 uint32_t rx_budget_reached;
285
286 /* tx path driver statistics */
287 uint32_t tx_pkts;
288 uint32_t tx_soft_errors;
289 uint32_t tx_ofld_frames_csum_ip;
290 uint32_t tx_ofld_frames_csum_tcp;
291 uint32_t tx_ofld_frames_csum_udp;
292 uint32_t tx_encap_failures;
293 uint32_t tx_hw_queue_full;
294 uint32_t tx_hw_max_queue_depth;
295 uint32_t tx_dma_mapping_failure;
296 uint32_t tx_max_drbr_queue_depth;
297 uint32_t tx_window_violation_std;
298 uint32_t tx_chain_lost_mbuf;
299 uint32_t tx_frames_deferred;
300 uint32_t tx_queue_xoff;
301
302 /* mbuf driver statistics */
303 uint32_t mbuf_defrag_attempts;
304 uint32_t mbuf_defrag_failures;
305 uint32_t mbuf_rx_bd_alloc_failed;
306 uint32_t mbuf_rx_bd_mapping_failed;
307
308 /* track the number of allocated mbufs */
309 uint32_t mbuf_alloc_tx;
310 uint32_t mbuf_alloc_rx;
311 };
312
313 struct bnx2x_eth_stats_old {
314 uint32_t rx_stat_dot3statsframestoolong_hi;
315 uint32_t rx_stat_dot3statsframestoolong_lo;
316 };
317
318 struct bnx2x_eth_q_stats_old {
319 /* Fields to perserve over fw reset*/
320 uint32_t total_unicast_bytes_received_hi;
321 uint32_t total_unicast_bytes_received_lo;
322 uint32_t total_broadcast_bytes_received_hi;
323 uint32_t total_broadcast_bytes_received_lo;
324 uint32_t total_multicast_bytes_received_hi;
325 uint32_t total_multicast_bytes_received_lo;
326 uint32_t total_unicast_bytes_transmitted_hi;
327 uint32_t total_unicast_bytes_transmitted_lo;
328 uint32_t total_broadcast_bytes_transmitted_hi;
329 uint32_t total_broadcast_bytes_transmitted_lo;
330 uint32_t total_multicast_bytes_transmitted_hi;
331 uint32_t total_multicast_bytes_transmitted_lo;
332
333 /* Fields to perserve last of */
334 uint32_t total_bytes_received_hi;
335 uint32_t total_bytes_received_lo;
336 uint32_t total_bytes_transmitted_hi;
337 uint32_t total_bytes_transmitted_lo;
338 uint32_t total_unicast_packets_received_hi;
339 uint32_t total_unicast_packets_received_lo;
340 uint32_t total_multicast_packets_received_hi;
341 uint32_t total_multicast_packets_received_lo;
342 uint32_t total_broadcast_packets_received_hi;
343 uint32_t total_broadcast_packets_received_lo;
344 uint32_t total_unicast_packets_transmitted_hi;
345 uint32_t total_unicast_packets_transmitted_lo;
346 uint32_t total_multicast_packets_transmitted_hi;
347 uint32_t total_multicast_packets_transmitted_lo;
348 uint32_t total_broadcast_packets_transmitted_hi;
349 uint32_t total_broadcast_packets_transmitted_lo;
350 uint32_t valid_bytes_received_hi;
351 uint32_t valid_bytes_received_lo;
352
353 /* receive path driver statistics */
354 uint32_t rx_calls_old;
355 uint32_t rx_pkts_old;
356 uint32_t rx_soft_errors_old;
357 uint32_t rx_hw_csum_errors_old;
358 uint32_t rx_ofld_frames_csum_ip_old;
359 uint32_t rx_ofld_frames_csum_tcp_udp_old;
360 uint32_t rx_budget_reached_old;
361
362 /* tx path driver statistics */
363 uint32_t tx_pkts_old;
364 uint32_t tx_soft_errors_old;
365 uint32_t tx_ofld_frames_csum_ip_old;
366 uint32_t tx_ofld_frames_csum_tcp_old;
367 uint32_t tx_ofld_frames_csum_udp_old;
368 uint32_t tx_encap_failures_old;
369 uint32_t tx_hw_queue_full_old;
370 uint32_t tx_hw_max_queue_depth_old;
371 uint32_t tx_dma_mapping_failure_old;
372 uint32_t tx_max_drbr_queue_depth_old;
373 uint32_t tx_window_violation_std_old;
374 uint32_t tx_chain_lost_mbuf_old;
375 uint32_t tx_frames_deferred_old;
376 uint32_t tx_queue_xoff_old;
377
378 /* mbuf driver statistics */
379 uint32_t mbuf_defrag_attempts_old;
380 uint32_t mbuf_defrag_failures_old;
381 uint32_t mbuf_rx_bd_alloc_failed_old;
382 uint32_t mbuf_rx_bd_mapping_failed_old;
383
384 /* track the number of allocated mbufs */
385 int mbuf_alloc_tx_old;
386 int mbuf_alloc_rx_old;
387 };
388
389 struct bnx2x_net_stats_old {
390 uint32_t rx_dropped;
391 };
392
393 struct bnx2x_fw_port_stats_old {
394 uint32_t pfc_frames_tx_hi;
395 uint32_t pfc_frames_tx_lo;
396 uint32_t pfc_frames_rx_hi;
397 uint32_t pfc_frames_rx_lo;
398
399 uint32_t mac_filter_discard;
400 uint32_t mf_tag_discard;
401 uint32_t brb_truncate_discard;
402 uint32_t mac_discard;
403 };
404
405 /* sum[hi:lo] += add[hi:lo] */
406 #define ADD_64(s_hi, a_hi, s_lo, a_lo) \
407 do { \
408 s_lo += a_lo; \
409 s_hi += a_hi + ((s_lo < a_lo) ? 1 : 0); \
410 } while (0)
411
412 #define LE32_0 ((uint32_t) 0)
413 #define LE16_0 ((uint16_t) 0)
414
415 /* The _force is for cases where high value is 0 */
416 #define ADD_64_LE(s_hi, a_hi_le, s_lo, a_lo_le) \
417 ADD_64(s_hi, le32toh(a_hi_le), \
418 s_lo, le32toh(a_lo_le))
419
420 #define ADD_64_LE16(s_hi, a_hi_le, s_lo, a_lo_le) \
421 ADD_64(s_hi, le16toh(a_hi_le), \
422 s_lo, le16toh(a_lo_le))
423
424 /* difference = minuend - subtrahend */
425 #define DIFF_64(d_hi, m_hi, s_hi, d_lo, m_lo, s_lo) \
426 do { \
427 if (m_lo < s_lo) { \
428 /* underflow */ \
429 d_hi = m_hi - s_hi; \
430 if (d_hi > 0) { \
431 /* we can 'loan' 1 */ \
432 d_hi--; \
433 d_lo = m_lo + (UINT_MAX - s_lo) + 1; \
434 } else { \
435 /* m_hi <= s_hi */ \
436 d_hi = 0; \
437 d_lo = 0; \
438 } \
439 } else { \
440 /* m_lo >= s_lo */ \
441 if (m_hi < s_hi) { \
442 d_hi = 0; \
443 d_lo = 0; \
444 } else { \
445 /* m_hi >= s_hi */ \
446 d_hi = m_hi - s_hi; \
447 d_lo = m_lo - s_lo; \
448 } \
449 } \
450 } while (0)
451
452 #define UPDATE_STAT64(s, t) \
453 do { \
454 DIFF_64(diff.hi, new->s##_hi, pstats->mac_stx[0].t##_hi, \
455 diff.lo, new->s##_lo, pstats->mac_stx[0].t##_lo); \
456 pstats->mac_stx[0].t##_hi = new->s##_hi; \
457 pstats->mac_stx[0].t##_lo = new->s##_lo; \
458 ADD_64(pstats->mac_stx[1].t##_hi, diff.hi, \
459 pstats->mac_stx[1].t##_lo, diff.lo); \
460 } while (0)
461
462 #define UPDATE_STAT64_NIG(s, t) \
463 do { \
464 DIFF_64(diff.hi, new->s##_hi, old->s##_hi, \
465 diff.lo, new->s##_lo, old->s##_lo); \
466 ADD_64(estats->t##_hi, diff.hi, \
467 estats->t##_lo, diff.lo); \
468 } while (0)
469
470 /* sum[hi:lo] += add */
471 #define ADD_EXTEND_64(s_hi, s_lo, a) \
472 do { \
473 s_lo += a; \
474 s_hi += (s_lo < a) ? 1 : 0; \
475 } while (0)
476
477 #define ADD_STAT64(diff, t) \
478 do { \
479 ADD_64(pstats->mac_stx[1].t##_hi, new->diff##_hi, \
480 pstats->mac_stx[1].t##_lo, new->diff##_lo); \
481 } while (0)
482
483 #define UPDATE_EXTEND_STAT(s) \
484 do { \
485 ADD_EXTEND_64(pstats->mac_stx[1].s##_hi, \
486 pstats->mac_stx[1].s##_lo, \
487 new->s); \
488 } while (0)
489
490 #define UPDATE_EXTEND_TSTAT_X(s, t, size) \
491 do { \
492 diff = le##size##toh(tclient->s) - \
493 le##size##toh(old_tclient->s); \
494 old_tclient->s = tclient->s; \
495 ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \
496 } while (0)
497
498 #define UPDATE_EXTEND_TSTAT(s, t) UPDATE_EXTEND_TSTAT_X(s, t, 32)
499
500 #define UPDATE_EXTEND_E_TSTAT(s, t, size) \
501 do { \
502 UPDATE_EXTEND_TSTAT_X(s, t, size); \
503 ADD_EXTEND_64(estats->t##_hi, estats->t##_lo, diff); \
504 } while (0)
505
506 #define UPDATE_EXTEND_USTAT(s, t) \
507 do { \
508 diff = le32toh(uclient->s) - le32toh(old_uclient->s); \
509 old_uclient->s = uclient->s; \
510 ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \
511 } while (0)
512
513 #define UPDATE_EXTEND_E_USTAT(s, t) \
514 do { \
515 UPDATE_EXTEND_USTAT(s, t); \
516 ADD_EXTEND_64(estats->t##_hi, estats->t##_lo, diff); \
517 } while (0)
518
519 #define UPDATE_EXTEND_XSTAT(s, t) \
520 do { \
521 diff = le32toh(xclient->s) - le32toh(old_xclient->s); \
522 old_xclient->s = xclient->s; \
523 ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \
524 } while (0)
525
526 #define UPDATE_QSTAT(s, t) \
527 do { \
528 qstats->t##_hi = qstats_old->t##_hi + le32toh(s.hi); \
529 qstats->t##_lo = qstats_old->t##_lo + le32toh(s.lo); \
530 } while (0)
531
532 #define UPDATE_QSTAT_OLD(f) \
533 do { \
534 qstats_old->f = qstats->f; \
535 } while (0)
536
537 #define UPDATE_ESTAT_QSTAT_64(s) \
538 do { \
539 ADD_64(estats->s##_hi, qstats->s##_hi, \
540 estats->s##_lo, qstats->s##_lo); \
541 SUB_64(estats->s##_hi, qstats_old->s##_hi_old, \
542 estats->s##_lo, qstats_old->s##_lo_old); \
543 qstats_old->s##_hi_old = qstats->s##_hi; \
544 qstats_old->s##_lo_old = qstats->s##_lo; \
545 } while (0)
546
547 #define UPDATE_ESTAT_QSTAT(s) \
548 do { \
549 estats->s += qstats->s; \
550 estats->s -= qstats_old->s##_old; \
551 qstats_old->s##_old = qstats->s; \
552 } while (0)
553
554 #define UPDATE_FSTAT_QSTAT(s) \
555 do { \
556 ADD_64(fstats->s##_hi, qstats->s##_hi, \
557 fstats->s##_lo, qstats->s##_lo); \
558 SUB_64(fstats->s##_hi, qstats_old->s##_hi, \
559 fstats->s##_lo, qstats_old->s##_lo); \
560 estats->s##_hi = fstats->s##_hi; \
561 estats->s##_lo = fstats->s##_lo; \
562 qstats_old->s##_hi = qstats->s##_hi; \
563 qstats_old->s##_lo = qstats->s##_lo; \
564 } while (0)
565
566 #define UPDATE_FW_STAT(s) \
567 do { \
568 estats->s = le32toh(tport->s) + fwstats->s; \
569 } while (0)
570
571 #define UPDATE_FW_STAT_OLD(f) \
572 do { \
573 fwstats->f = estats->f; \
574 } while (0)
575
576 #define UPDATE_ESTAT(s, t) \
577 do { \
578 SUB_64(estats->s##_hi, estats_old->t##_hi, \
579 estats->s##_lo, estats_old->t##_lo); \
580 ADD_64(estats->s##_hi, estats->t##_hi, \
581 estats->s##_lo, estats->t##_lo); \
582 estats_old->t##_hi = estats->t##_hi; \
583 estats_old->t##_lo = estats->t##_lo; \
584 } while (0)
585
586 /* minuend -= subtrahend */
587 #define SUB_64(m_hi, s_hi, m_lo, s_lo) \
588 do { \
589 DIFF_64(m_hi, m_hi, s_hi, m_lo, m_lo, s_lo); \
590 } while (0)
591
592 /* minuend[hi:lo] -= subtrahend */
593 #define SUB_EXTEND_64(m_hi, m_lo, s) \
594 do { \
595 uint32_t s_hi = 0; \
596 SUB_64(m_hi, s_hi, m_lo, s); \
597 } while (0)
598
599 #define SUB_EXTEND_USTAT(s, t) \
600 do { \
601 diff = le32toh(uclient->s) - le32toh(old_uclient->s); \
602 SUB_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \
603 } while (0)
604
605 struct bnx2x_softc;
606 void bnx2x_stats_init(struct bnx2x_softc *sc);
607 void bnx2x_stats_handle(struct bnx2x_softc *sc, enum bnx2x_stats_event event);
608 void bnx2x_save_statistics(struct bnx2x_softc *sc);
609 void bnx2x_memset_stats(struct bnx2x_softc *sc);
610
611 #endif /* BNX2X_STATS_H */