2 * Copyright (c) 2007-2013 QLogic Corporation. All rights reserved.
4 * Eric Davis <edavis@broadcom.com>
5 * David Christensen <davidch@broadcom.com>
6 * Gary Zambrano <zambrano@broadcom.com>
8 * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of Broadcom Corporation nor the name of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written consent.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS'
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34 * THE POSSIBILITY OF SUCH DAMAGE.
40 #include <sys/types.h>
45 uint32_t brb_truncate;
46 uint32_t flow_ctrl_discard;
47 uint32_t flow_ctrl_octets;
48 uint32_t flow_ctrl_packet;
50 uint32_t mng_octet_inp;
51 uint32_t mng_octet_out;
52 uint32_t mng_packet_inp;
53 uint32_t mng_packet_out;
57 uint32_t egress_mac_pkt0_lo;
58 uint32_t egress_mac_pkt0_hi;
59 uint32_t egress_mac_pkt1_lo;
60 uint32_t egress_mac_pkt1_hi;
64 enum bnx2x_stats_event {
72 enum bnx2x_stats_state {
73 STATS_STATE_DISABLED = 0,
78 struct bnx2x_eth_stats {
79 uint32_t total_bytes_received_hi;
80 uint32_t total_bytes_received_lo;
81 uint32_t total_bytes_transmitted_hi;
82 uint32_t total_bytes_transmitted_lo;
83 uint32_t total_unicast_packets_received_hi;
84 uint32_t total_unicast_packets_received_lo;
85 uint32_t total_multicast_packets_received_hi;
86 uint32_t total_multicast_packets_received_lo;
87 uint32_t total_broadcast_packets_received_hi;
88 uint32_t total_broadcast_packets_received_lo;
89 uint32_t total_unicast_packets_transmitted_hi;
90 uint32_t total_unicast_packets_transmitted_lo;
91 uint32_t total_multicast_packets_transmitted_hi;
92 uint32_t total_multicast_packets_transmitted_lo;
93 uint32_t total_broadcast_packets_transmitted_hi;
94 uint32_t total_broadcast_packets_transmitted_lo;
95 uint32_t valid_bytes_received_hi;
96 uint32_t valid_bytes_received_lo;
98 uint32_t error_bytes_received_hi;
99 uint32_t error_bytes_received_lo;
100 uint32_t etherstatsoverrsizepkts_hi;
101 uint32_t etherstatsoverrsizepkts_lo;
102 uint32_t no_buff_discard_hi;
103 uint32_t no_buff_discard_lo;
105 uint32_t rx_stat_ifhcinbadoctets_hi;
106 uint32_t rx_stat_ifhcinbadoctets_lo;
107 uint32_t tx_stat_ifhcoutbadoctets_hi;
108 uint32_t tx_stat_ifhcoutbadoctets_lo;
109 uint32_t rx_stat_dot3statsfcserrors_hi;
110 uint32_t rx_stat_dot3statsfcserrors_lo;
111 uint32_t rx_stat_dot3statsalignmenterrors_hi;
112 uint32_t rx_stat_dot3statsalignmenterrors_lo;
113 uint32_t rx_stat_dot3statscarriersenseerrors_hi;
114 uint32_t rx_stat_dot3statscarriersenseerrors_lo;
115 uint32_t rx_stat_falsecarriererrors_hi;
116 uint32_t rx_stat_falsecarriererrors_lo;
117 uint32_t rx_stat_etherstatsundersizepkts_hi;
118 uint32_t rx_stat_etherstatsundersizepkts_lo;
119 uint32_t rx_stat_dot3statsframestoolong_hi;
120 uint32_t rx_stat_dot3statsframestoolong_lo;
121 uint32_t rx_stat_etherstatsfragments_hi;
122 uint32_t rx_stat_etherstatsfragments_lo;
123 uint32_t rx_stat_etherstatsjabbers_hi;
124 uint32_t rx_stat_etherstatsjabbers_lo;
125 uint32_t rx_stat_maccontrolframesreceived_hi;
126 uint32_t rx_stat_maccontrolframesreceived_lo;
127 uint32_t rx_stat_bmac_xpf_hi;
128 uint32_t rx_stat_bmac_xpf_lo;
129 uint32_t rx_stat_bmac_xcf_hi;
130 uint32_t rx_stat_bmac_xcf_lo;
131 uint32_t rx_stat_xoffstateentered_hi;
132 uint32_t rx_stat_xoffstateentered_lo;
133 uint32_t rx_stat_xonpauseframesreceived_hi;
134 uint32_t rx_stat_xonpauseframesreceived_lo;
135 uint32_t rx_stat_xoffpauseframesreceived_hi;
136 uint32_t rx_stat_xoffpauseframesreceived_lo;
137 uint32_t tx_stat_outxonsent_hi;
138 uint32_t tx_stat_outxonsent_lo;
139 uint32_t tx_stat_outxoffsent_hi;
140 uint32_t tx_stat_outxoffsent_lo;
141 uint32_t tx_stat_flowcontroldone_hi;
142 uint32_t tx_stat_flowcontroldone_lo;
143 uint32_t tx_stat_etherstatscollisions_hi;
144 uint32_t tx_stat_etherstatscollisions_lo;
145 uint32_t tx_stat_dot3statssinglecollisionframes_hi;
146 uint32_t tx_stat_dot3statssinglecollisionframes_lo;
147 uint32_t tx_stat_dot3statsmultiplecollisionframes_hi;
148 uint32_t tx_stat_dot3statsmultiplecollisionframes_lo;
149 uint32_t tx_stat_dot3statsdeferredtransmissions_hi;
150 uint32_t tx_stat_dot3statsdeferredtransmissions_lo;
151 uint32_t tx_stat_dot3statsexcessivecollisions_hi;
152 uint32_t tx_stat_dot3statsexcessivecollisions_lo;
153 uint32_t tx_stat_dot3statslatecollisions_hi;
154 uint32_t tx_stat_dot3statslatecollisions_lo;
155 uint32_t tx_stat_etherstatspkts64octets_hi;
156 uint32_t tx_stat_etherstatspkts64octets_lo;
157 uint32_t tx_stat_etherstatspkts65octetsto127octets_hi;
158 uint32_t tx_stat_etherstatspkts65octetsto127octets_lo;
159 uint32_t tx_stat_etherstatspkts128octetsto255octets_hi;
160 uint32_t tx_stat_etherstatspkts128octetsto255octets_lo;
161 uint32_t tx_stat_etherstatspkts256octetsto511octets_hi;
162 uint32_t tx_stat_etherstatspkts256octetsto511octets_lo;
163 uint32_t tx_stat_etherstatspkts512octetsto1023octets_hi;
164 uint32_t tx_stat_etherstatspkts512octetsto1023octets_lo;
165 uint32_t tx_stat_etherstatspkts1024octetsto1522octets_hi;
166 uint32_t tx_stat_etherstatspkts1024octetsto1522octets_lo;
167 uint32_t tx_stat_etherstatspktsover1522octets_hi;
168 uint32_t tx_stat_etherstatspktsover1522octets_lo;
169 uint32_t tx_stat_bmac_2047_hi;
170 uint32_t tx_stat_bmac_2047_lo;
171 uint32_t tx_stat_bmac_4095_hi;
172 uint32_t tx_stat_bmac_4095_lo;
173 uint32_t tx_stat_bmac_9216_hi;
174 uint32_t tx_stat_bmac_9216_lo;
175 uint32_t tx_stat_bmac_16383_hi;
176 uint32_t tx_stat_bmac_16383_lo;
177 uint32_t tx_stat_dot3statsinternalmactransmiterrors_hi;
178 uint32_t tx_stat_dot3statsinternalmactransmiterrors_lo;
179 uint32_t tx_stat_bmac_ufl_hi;
180 uint32_t tx_stat_bmac_ufl_lo;
182 uint32_t pause_frames_received_hi;
183 uint32_t pause_frames_received_lo;
184 uint32_t pause_frames_sent_hi;
185 uint32_t pause_frames_sent_lo;
187 uint32_t etherstatspkts1024octetsto1522octets_hi;
188 uint32_t etherstatspkts1024octetsto1522octets_lo;
189 uint32_t etherstatspktsover1522octets_hi;
190 uint32_t etherstatspktsover1522octets_lo;
192 uint32_t brb_drop_hi;
193 uint32_t brb_drop_lo;
194 uint32_t brb_truncate_hi;
195 uint32_t brb_truncate_lo;
197 uint32_t mac_filter_discard;
198 uint32_t mf_tag_discard;
199 uint32_t brb_truncate_discard;
200 uint32_t mac_discard;
202 uint32_t nig_timer_max;
205 uint32_t pfc_frames_received_hi;
206 uint32_t pfc_frames_received_lo;
207 uint32_t pfc_frames_sent_hi;
208 uint32_t pfc_frames_sent_lo;
211 uint32_t recoverable_error;
212 uint32_t unrecoverable_error;
214 /* src: Clear-on-Read register; Will not survive PMF Migration */
217 /* receive path driver statistics */
220 uint32_t rx_soft_errors;
221 uint32_t rx_hw_csum_errors;
222 uint32_t rx_ofld_frames_csum_ip;
223 uint32_t rx_ofld_frames_csum_tcp_udp;
224 uint32_t rx_budget_reached;
226 /* tx path driver statistics */
228 uint32_t tx_soft_errors;
229 uint32_t tx_ofld_frames_csum_ip;
230 uint32_t tx_ofld_frames_csum_tcp;
231 uint32_t tx_ofld_frames_csum_udp;
232 uint32_t tx_encap_failures;
233 uint32_t tx_hw_queue_full;
234 uint32_t tx_hw_max_queue_depth;
235 uint32_t tx_dma_mapping_failure;
236 uint32_t tx_max_drbr_queue_depth;
237 uint32_t tx_window_violation_std;
238 uint32_t tx_chain_lost_mbuf;
239 uint32_t tx_frames_deferred;
240 uint32_t tx_queue_xoff;
242 /* mbuf driver statistics */
243 uint32_t mbuf_defrag_attempts;
244 uint32_t mbuf_defrag_failures;
245 uint32_t mbuf_rx_bd_alloc_failed;
246 uint32_t mbuf_rx_bd_mapping_failed;
248 /* track the number of allocated mbufs */
249 uint32_t mbuf_alloc_tx;
250 uint32_t mbuf_alloc_rx;
254 struct bnx2x_eth_q_stats {
255 uint32_t total_unicast_bytes_received_hi;
256 uint32_t total_unicast_bytes_received_lo;
257 uint32_t total_broadcast_bytes_received_hi;
258 uint32_t total_broadcast_bytes_received_lo;
259 uint32_t total_multicast_bytes_received_hi;
260 uint32_t total_multicast_bytes_received_lo;
261 uint32_t total_bytes_received_hi;
262 uint32_t total_bytes_received_lo;
263 uint32_t total_unicast_bytes_transmitted_hi;
264 uint32_t total_unicast_bytes_transmitted_lo;
265 uint32_t total_broadcast_bytes_transmitted_hi;
266 uint32_t total_broadcast_bytes_transmitted_lo;
267 uint32_t total_multicast_bytes_transmitted_hi;
268 uint32_t total_multicast_bytes_transmitted_lo;
269 uint32_t total_bytes_transmitted_hi;
270 uint32_t total_bytes_transmitted_lo;
271 uint32_t total_unicast_packets_received_hi;
272 uint32_t total_unicast_packets_received_lo;
273 uint32_t total_multicast_packets_received_hi;
274 uint32_t total_multicast_packets_received_lo;
275 uint32_t total_broadcast_packets_received_hi;
276 uint32_t total_broadcast_packets_received_lo;
277 uint32_t total_unicast_packets_transmitted_hi;
278 uint32_t total_unicast_packets_transmitted_lo;
279 uint32_t total_multicast_packets_transmitted_hi;
280 uint32_t total_multicast_packets_transmitted_lo;
281 uint32_t total_broadcast_packets_transmitted_hi;
282 uint32_t total_broadcast_packets_transmitted_lo;
283 uint32_t valid_bytes_received_hi;
284 uint32_t valid_bytes_received_lo;
286 uint32_t etherstatsoverrsizepkts_hi;
287 uint32_t etherstatsoverrsizepkts_lo;
288 uint32_t no_buff_discard_hi;
289 uint32_t no_buff_discard_lo;
291 uint32_t total_packets_received_checksum_discarded_hi;
292 uint32_t total_packets_received_checksum_discarded_lo;
293 uint32_t total_packets_received_ttl0_discarded_hi;
294 uint32_t total_packets_received_ttl0_discarded_lo;
295 uint32_t total_transmitted_dropped_packets_error_hi;
296 uint32_t total_transmitted_dropped_packets_error_lo;
298 /* receive path driver statistics */
301 uint32_t rx_soft_errors;
302 uint32_t rx_hw_csum_errors;
303 uint32_t rx_ofld_frames_csum_ip;
304 uint32_t rx_ofld_frames_csum_tcp_udp;
305 uint32_t rx_budget_reached;
307 /* tx path driver statistics */
309 uint32_t tx_soft_errors;
310 uint32_t tx_ofld_frames_csum_ip;
311 uint32_t tx_ofld_frames_csum_tcp;
312 uint32_t tx_ofld_frames_csum_udp;
313 uint32_t tx_encap_failures;
314 uint32_t tx_hw_queue_full;
315 uint32_t tx_hw_max_queue_depth;
316 uint32_t tx_dma_mapping_failure;
317 uint32_t tx_max_drbr_queue_depth;
318 uint32_t tx_window_violation_std;
319 uint32_t tx_chain_lost_mbuf;
320 uint32_t tx_frames_deferred;
321 uint32_t tx_queue_xoff;
323 /* mbuf driver statistics */
324 uint32_t mbuf_defrag_attempts;
325 uint32_t mbuf_defrag_failures;
326 uint32_t mbuf_rx_bd_alloc_failed;
327 uint32_t mbuf_rx_bd_mapping_failed;
329 /* track the number of allocated mbufs */
330 uint32_t mbuf_alloc_tx;
331 uint32_t mbuf_alloc_rx;
334 struct bnx2x_eth_stats_old {
335 uint32_t rx_stat_dot3statsframestoolong_hi;
336 uint32_t rx_stat_dot3statsframestoolong_lo;
339 struct bnx2x_eth_q_stats_old {
340 /* Fields to perserve over fw reset*/
341 uint32_t total_unicast_bytes_received_hi;
342 uint32_t total_unicast_bytes_received_lo;
343 uint32_t total_broadcast_bytes_received_hi;
344 uint32_t total_broadcast_bytes_received_lo;
345 uint32_t total_multicast_bytes_received_hi;
346 uint32_t total_multicast_bytes_received_lo;
347 uint32_t total_unicast_bytes_transmitted_hi;
348 uint32_t total_unicast_bytes_transmitted_lo;
349 uint32_t total_broadcast_bytes_transmitted_hi;
350 uint32_t total_broadcast_bytes_transmitted_lo;
351 uint32_t total_multicast_bytes_transmitted_hi;
352 uint32_t total_multicast_bytes_transmitted_lo;
354 /* Fields to perserve last of */
355 uint32_t total_bytes_received_hi;
356 uint32_t total_bytes_received_lo;
357 uint32_t total_bytes_transmitted_hi;
358 uint32_t total_bytes_transmitted_lo;
359 uint32_t total_unicast_packets_received_hi;
360 uint32_t total_unicast_packets_received_lo;
361 uint32_t total_multicast_packets_received_hi;
362 uint32_t total_multicast_packets_received_lo;
363 uint32_t total_broadcast_packets_received_hi;
364 uint32_t total_broadcast_packets_received_lo;
365 uint32_t total_unicast_packets_transmitted_hi;
366 uint32_t total_unicast_packets_transmitted_lo;
367 uint32_t total_multicast_packets_transmitted_hi;
368 uint32_t total_multicast_packets_transmitted_lo;
369 uint32_t total_broadcast_packets_transmitted_hi;
370 uint32_t total_broadcast_packets_transmitted_lo;
371 uint32_t valid_bytes_received_hi;
372 uint32_t valid_bytes_received_lo;
374 /* receive path driver statistics */
375 uint32_t rx_calls_old;
376 uint32_t rx_pkts_old;
377 uint32_t rx_soft_errors_old;
378 uint32_t rx_hw_csum_errors_old;
379 uint32_t rx_ofld_frames_csum_ip_old;
380 uint32_t rx_ofld_frames_csum_tcp_udp_old;
381 uint32_t rx_budget_reached_old;
383 /* tx path driver statistics */
384 uint32_t tx_pkts_old;
385 uint32_t tx_soft_errors_old;
386 uint32_t tx_ofld_frames_csum_ip_old;
387 uint32_t tx_ofld_frames_csum_tcp_old;
388 uint32_t tx_ofld_frames_csum_udp_old;
389 uint32_t tx_encap_failures_old;
390 uint32_t tx_hw_queue_full_old;
391 uint32_t tx_hw_max_queue_depth_old;
392 uint32_t tx_dma_mapping_failure_old;
393 uint32_t tx_max_drbr_queue_depth_old;
394 uint32_t tx_window_violation_std_old;
395 uint32_t tx_chain_lost_mbuf_old;
396 uint32_t tx_frames_deferred_old;
397 uint32_t tx_queue_xoff_old;
399 /* mbuf driver statistics */
400 uint32_t mbuf_defrag_attempts_old;
401 uint32_t mbuf_defrag_failures_old;
402 uint32_t mbuf_rx_bd_alloc_failed_old;
403 uint32_t mbuf_rx_bd_mapping_failed_old;
405 /* track the number of allocated mbufs */
406 int mbuf_alloc_tx_old;
407 int mbuf_alloc_rx_old;
410 struct bnx2x_net_stats_old {
414 struct bnx2x_fw_port_stats_old {
415 uint32_t pfc_frames_tx_hi;
416 uint32_t pfc_frames_tx_lo;
417 uint32_t pfc_frames_rx_hi;
418 uint32_t pfc_frames_rx_lo;
420 uint32_t mac_filter_discard;
421 uint32_t mf_tag_discard;
422 uint32_t brb_truncate_discard;
423 uint32_t mac_discard;
426 /* sum[hi:lo] += add[hi:lo] */
427 #define ADD_64(s_hi, a_hi, s_lo, a_lo) \
430 s_hi += a_hi + ((s_lo < a_lo) ? 1 : 0); \
433 #define LE32_0 ((uint32_t) 0)
434 #define LE16_0 ((uint16_t) 0)
436 /* The _force is for cases where high value is 0 */
437 #define ADD_64_LE(s_hi, a_hi_le, s_lo, a_lo_le) \
438 ADD_64(s_hi, le32toh(a_hi_le), \
439 s_lo, le32toh(a_lo_le))
441 #define ADD_64_LE16(s_hi, a_hi_le, s_lo, a_lo_le) \
442 ADD_64(s_hi, le16toh(a_hi_le), \
443 s_lo, le16toh(a_lo_le))
445 /* difference = minuend - subtrahend */
446 #define DIFF_64(d_hi, m_hi, s_hi, d_lo, m_lo, s_lo) \
450 d_hi = m_hi - s_hi; \
452 /* we can 'loan' 1 */ \
454 d_lo = m_lo + (UINT_MAX - s_lo) + 1; \
467 d_hi = m_hi - s_hi; \
468 d_lo = m_lo - s_lo; \
473 #define UPDATE_STAT64(s, t) \
475 DIFF_64(diff.hi, new->s##_hi, pstats->mac_stx[0].t##_hi, \
476 diff.lo, new->s##_lo, pstats->mac_stx[0].t##_lo); \
477 pstats->mac_stx[0].t##_hi = new->s##_hi; \
478 pstats->mac_stx[0].t##_lo = new->s##_lo; \
479 ADD_64(pstats->mac_stx[1].t##_hi, diff.hi, \
480 pstats->mac_stx[1].t##_lo, diff.lo); \
483 #define UPDATE_STAT64_NIG(s, t) \
485 DIFF_64(diff.hi, new->s##_hi, old->s##_hi, \
486 diff.lo, new->s##_lo, old->s##_lo); \
487 ADD_64(estats->t##_hi, diff.hi, \
488 estats->t##_lo, diff.lo); \
491 /* sum[hi:lo] += add */
492 #define ADD_EXTEND_64(s_hi, s_lo, a) \
495 s_hi += (s_lo < a) ? 1 : 0; \
498 #define ADD_STAT64(diff, t) \
500 ADD_64(pstats->mac_stx[1].t##_hi, new->diff##_hi, \
501 pstats->mac_stx[1].t##_lo, new->diff##_lo); \
504 #define UPDATE_EXTEND_STAT(s) \
506 ADD_EXTEND_64(pstats->mac_stx[1].s##_hi, \
507 pstats->mac_stx[1].s##_lo, \
511 #define UPDATE_EXTEND_TSTAT_X(s, t, size) \
513 diff = le##size##toh(tclient->s) - \
514 le##size##toh(old_tclient->s); \
515 old_tclient->s = tclient->s; \
516 ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \
519 #define UPDATE_EXTEND_TSTAT(s, t) UPDATE_EXTEND_TSTAT_X(s, t, 32)
521 #define UPDATE_EXTEND_E_TSTAT(s, t, size) \
523 UPDATE_EXTEND_TSTAT_X(s, t, size); \
524 ADD_EXTEND_64(estats->t##_hi, estats->t##_lo, diff); \
527 #define UPDATE_EXTEND_USTAT(s, t) \
529 diff = le32toh(uclient->s) - le32toh(old_uclient->s); \
530 old_uclient->s = uclient->s; \
531 ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \
534 #define UPDATE_EXTEND_E_USTAT(s, t) \
536 UPDATE_EXTEND_USTAT(s, t); \
537 ADD_EXTEND_64(estats->t##_hi, estats->t##_lo, diff); \
540 #define UPDATE_EXTEND_XSTAT(s, t) \
542 diff = le32toh(xclient->s) - le32toh(old_xclient->s); \
543 old_xclient->s = xclient->s; \
544 ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \
547 #define UPDATE_QSTAT(s, t) \
549 qstats->t##_hi = qstats_old->t##_hi + le32toh(s.hi); \
550 qstats->t##_lo = qstats_old->t##_lo + le32toh(s.lo); \
553 #define UPDATE_QSTAT_OLD(f) \
555 qstats_old->f = qstats->f; \
558 #define UPDATE_ESTAT_QSTAT_64(s) \
560 ADD_64(estats->s##_hi, qstats->s##_hi, \
561 estats->s##_lo, qstats->s##_lo); \
562 SUB_64(estats->s##_hi, qstats_old->s##_hi_old, \
563 estats->s##_lo, qstats_old->s##_lo_old); \
564 qstats_old->s##_hi_old = qstats->s##_hi; \
565 qstats_old->s##_lo_old = qstats->s##_lo; \
568 #define UPDATE_ESTAT_QSTAT(s) \
570 estats->s += qstats->s; \
571 estats->s -= qstats_old->s##_old; \
572 qstats_old->s##_old = qstats->s; \
575 #define UPDATE_FSTAT_QSTAT(s) \
577 ADD_64(fstats->s##_hi, qstats->s##_hi, \
578 fstats->s##_lo, qstats->s##_lo); \
579 SUB_64(fstats->s##_hi, qstats_old->s##_hi, \
580 fstats->s##_lo, qstats_old->s##_lo); \
581 estats->s##_hi = fstats->s##_hi; \
582 estats->s##_lo = fstats->s##_lo; \
583 qstats_old->s##_hi = qstats->s##_hi; \
584 qstats_old->s##_lo = qstats->s##_lo; \
587 #define UPDATE_FW_STAT(s) \
589 estats->s = le32toh(tport->s) + fwstats->s; \
592 #define UPDATE_FW_STAT_OLD(f) \
594 fwstats->f = estats->f; \
597 #define UPDATE_ESTAT(s, t) \
599 SUB_64(estats->s##_hi, estats_old->t##_hi, \
600 estats->s##_lo, estats_old->t##_lo); \
601 ADD_64(estats->s##_hi, estats->t##_hi, \
602 estats->s##_lo, estats->t##_lo); \
603 estats_old->t##_hi = estats->t##_hi; \
604 estats_old->t##_lo = estats->t##_lo; \
607 /* minuend -= subtrahend */
608 #define SUB_64(m_hi, s_hi, m_lo, s_lo) \
610 DIFF_64(m_hi, m_hi, s_hi, m_lo, m_lo, s_lo); \
613 /* minuend[hi:lo] -= subtrahend */
614 #define SUB_EXTEND_64(m_hi, m_lo, s) \
617 SUB_64(m_hi, s_hi, m_lo, s); \
620 #define SUB_EXTEND_USTAT(s, t) \
622 diff = le32toh(uclient->s) - le32toh(old_uclient->s); \
623 SUB_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \
627 void bnx2x_stats_init(struct bnx2x_softc *sc);
628 void bnx2x_stats_handle(struct bnx2x_softc *sc, enum bnx2x_stats_event event);
629 void bnx2x_save_statistics(struct bnx2x_softc *sc);
630 void bnx2x_memset_stats(struct bnx2x_softc *sc);
632 #endif /* BNX2X_STATS_H */