Back to home page

OSCL-LXR

 
 

    


0001 /* bnx2x_stats.h: QLogic Everest network driver.
0002  *
0003  * Copyright (c) 2007-2013 Broadcom Corporation
0004  * Copyright (c) 2014 QLogic Corporation
0005  * All rights reserved
0006  *
0007  * This program is free software; you can redistribute it and/or modify
0008  * it under the terms of the GNU General Public License as published by
0009  * the Free Software Foundation.
0010  *
0011  * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
0012  * Written by: Eliezer Tamir
0013  * Based on code from Michael Chan's bnx2 driver
0014  * UDP CSUM errata workaround by Arik Gendelman
0015  * Slowpath and fastpath rework by Vladislav Zolotarov
0016  * Statistics and Link management by Yitchak Gertner
0017  *
0018  */
0019 #ifndef BNX2X_STATS_H
0020 #define BNX2X_STATS_H
0021 
0022 #include <linux/types.h>
0023 
0024 struct nig_stats {
0025     u32 brb_discard;
0026     u32 brb_packet;
0027     u32 brb_truncate;
0028     u32 flow_ctrl_discard;
0029     u32 flow_ctrl_octets;
0030     u32 flow_ctrl_packet;
0031     u32 mng_discard;
0032     u32 mng_octet_inp;
0033     u32 mng_octet_out;
0034     u32 mng_packet_inp;
0035     u32 mng_packet_out;
0036     u32 pbf_octets;
0037     u32 pbf_packet;
0038     u32 safc_inp;
0039     struct_group(egress_mac_pkt0,
0040         u32 egress_mac_pkt0_lo;
0041         u32 egress_mac_pkt0_hi;
0042     );
0043     struct_group(egress_mac_pkt1,
0044         u32 egress_mac_pkt1_lo;
0045         u32 egress_mac_pkt1_hi;
0046     );
0047 };
0048 
0049 enum bnx2x_stats_event {
0050     STATS_EVENT_PMF = 0,
0051     STATS_EVENT_LINK_UP,
0052     STATS_EVENT_UPDATE,
0053     STATS_EVENT_STOP,
0054     STATS_EVENT_MAX
0055 };
0056 
0057 enum bnx2x_stats_state {
0058     STATS_STATE_DISABLED = 0,
0059     STATS_STATE_ENABLED,
0060     STATS_STATE_MAX
0061 };
0062 
0063 struct bnx2x_eth_stats {
0064     u32 total_bytes_received_hi;
0065     u32 total_bytes_received_lo;
0066     u32 total_bytes_transmitted_hi;
0067     u32 total_bytes_transmitted_lo;
0068     u32 total_unicast_packets_received_hi;
0069     u32 total_unicast_packets_received_lo;
0070     u32 total_multicast_packets_received_hi;
0071     u32 total_multicast_packets_received_lo;
0072     u32 total_broadcast_packets_received_hi;
0073     u32 total_broadcast_packets_received_lo;
0074     u32 total_unicast_packets_transmitted_hi;
0075     u32 total_unicast_packets_transmitted_lo;
0076     u32 total_multicast_packets_transmitted_hi;
0077     u32 total_multicast_packets_transmitted_lo;
0078     u32 total_broadcast_packets_transmitted_hi;
0079     u32 total_broadcast_packets_transmitted_lo;
0080     u32 valid_bytes_received_hi;
0081     u32 valid_bytes_received_lo;
0082 
0083     u32 error_bytes_received_hi;
0084     u32 error_bytes_received_lo;
0085     u32 etherstatsoverrsizepkts_hi;
0086     u32 etherstatsoverrsizepkts_lo;
0087     u32 no_buff_discard_hi;
0088     u32 no_buff_discard_lo;
0089 
0090     struct_group(shared,
0091     u32 rx_stat_ifhcinbadoctets_hi;
0092     u32 rx_stat_ifhcinbadoctets_lo;
0093     u32 tx_stat_ifhcoutbadoctets_hi;
0094     u32 tx_stat_ifhcoutbadoctets_lo;
0095     u32 rx_stat_dot3statsfcserrors_hi;
0096     u32 rx_stat_dot3statsfcserrors_lo;
0097     u32 rx_stat_dot3statsalignmenterrors_hi;
0098     u32 rx_stat_dot3statsalignmenterrors_lo;
0099     u32 rx_stat_dot3statscarriersenseerrors_hi;
0100     u32 rx_stat_dot3statscarriersenseerrors_lo;
0101     u32 rx_stat_falsecarriererrors_hi;
0102     u32 rx_stat_falsecarriererrors_lo;
0103     u32 rx_stat_etherstatsundersizepkts_hi;
0104     u32 rx_stat_etherstatsundersizepkts_lo;
0105     u32 rx_stat_dot3statsframestoolong_hi;
0106     u32 rx_stat_dot3statsframestoolong_lo;
0107     u32 rx_stat_etherstatsfragments_hi;
0108     u32 rx_stat_etherstatsfragments_lo;
0109     u32 rx_stat_etherstatsjabbers_hi;
0110     u32 rx_stat_etherstatsjabbers_lo;
0111     u32 rx_stat_maccontrolframesreceived_hi;
0112     u32 rx_stat_maccontrolframesreceived_lo;
0113     u32 rx_stat_bmac_xpf_hi;
0114     u32 rx_stat_bmac_xpf_lo;
0115     u32 rx_stat_bmac_xcf_hi;
0116     u32 rx_stat_bmac_xcf_lo;
0117     u32 rx_stat_xoffstateentered_hi;
0118     u32 rx_stat_xoffstateentered_lo;
0119     u32 rx_stat_xonpauseframesreceived_hi;
0120     u32 rx_stat_xonpauseframesreceived_lo;
0121     u32 rx_stat_xoffpauseframesreceived_hi;
0122     u32 rx_stat_xoffpauseframesreceived_lo;
0123     u32 tx_stat_outxonsent_hi;
0124     u32 tx_stat_outxonsent_lo;
0125     u32 tx_stat_outxoffsent_hi;
0126     u32 tx_stat_outxoffsent_lo;
0127     u32 tx_stat_flowcontroldone_hi;
0128     u32 tx_stat_flowcontroldone_lo;
0129     u32 tx_stat_etherstatscollisions_hi;
0130     u32 tx_stat_etherstatscollisions_lo;
0131     u32 tx_stat_dot3statssinglecollisionframes_hi;
0132     u32 tx_stat_dot3statssinglecollisionframes_lo;
0133     u32 tx_stat_dot3statsmultiplecollisionframes_hi;
0134     u32 tx_stat_dot3statsmultiplecollisionframes_lo;
0135     u32 tx_stat_dot3statsdeferredtransmissions_hi;
0136     u32 tx_stat_dot3statsdeferredtransmissions_lo;
0137     u32 tx_stat_dot3statsexcessivecollisions_hi;
0138     u32 tx_stat_dot3statsexcessivecollisions_lo;
0139     u32 tx_stat_dot3statslatecollisions_hi;
0140     u32 tx_stat_dot3statslatecollisions_lo;
0141     u32 tx_stat_etherstatspkts64octets_hi;
0142     u32 tx_stat_etherstatspkts64octets_lo;
0143     u32 tx_stat_etherstatspkts65octetsto127octets_hi;
0144     u32 tx_stat_etherstatspkts65octetsto127octets_lo;
0145     u32 tx_stat_etherstatspkts128octetsto255octets_hi;
0146     u32 tx_stat_etherstatspkts128octetsto255octets_lo;
0147     u32 tx_stat_etherstatspkts256octetsto511octets_hi;
0148     u32 tx_stat_etherstatspkts256octetsto511octets_lo;
0149     u32 tx_stat_etherstatspkts512octetsto1023octets_hi;
0150     u32 tx_stat_etherstatspkts512octetsto1023octets_lo;
0151     u32 tx_stat_etherstatspkts1024octetsto1522octets_hi;
0152     u32 tx_stat_etherstatspkts1024octetsto1522octets_lo;
0153     u32 tx_stat_etherstatspktsover1522octets_hi;
0154     u32 tx_stat_etherstatspktsover1522octets_lo;
0155     u32 tx_stat_bmac_2047_hi;
0156     u32 tx_stat_bmac_2047_lo;
0157     u32 tx_stat_bmac_4095_hi;
0158     u32 tx_stat_bmac_4095_lo;
0159     u32 tx_stat_bmac_9216_hi;
0160     u32 tx_stat_bmac_9216_lo;
0161     u32 tx_stat_bmac_16383_hi;
0162     u32 tx_stat_bmac_16383_lo;
0163     u32 tx_stat_dot3statsinternalmactransmiterrors_hi;
0164     u32 tx_stat_dot3statsinternalmactransmiterrors_lo;
0165     u32 tx_stat_bmac_ufl_hi;
0166     u32 tx_stat_bmac_ufl_lo;
0167     );
0168 
0169     u32 pause_frames_received_hi;
0170     u32 pause_frames_received_lo;
0171     u32 pause_frames_sent_hi;
0172     u32 pause_frames_sent_lo;
0173 
0174     u32 etherstatspkts1024octetsto1522octets_hi;
0175     u32 etherstatspkts1024octetsto1522octets_lo;
0176     u32 etherstatspktsover1522octets_hi;
0177     u32 etherstatspktsover1522octets_lo;
0178 
0179     u32 brb_drop_hi;
0180     u32 brb_drop_lo;
0181     u32 brb_truncate_hi;
0182     u32 brb_truncate_lo;
0183 
0184     u32 mac_filter_discard;
0185     u32 mf_tag_discard;
0186     u32 brb_truncate_discard;
0187     u32 mac_discard;
0188 
0189     u32 driver_xoff;
0190     u32 rx_err_discard_pkt;
0191     u32 rx_skb_alloc_failed;
0192     u32 hw_csum_err;
0193 
0194     u32 nig_timer_max;
0195 
0196     /* TPA */
0197     u32 total_tpa_aggregations_hi;
0198     u32 total_tpa_aggregations_lo;
0199     u32 total_tpa_aggregated_frames_hi;
0200     u32 total_tpa_aggregated_frames_lo;
0201     u32 total_tpa_bytes_hi;
0202     u32 total_tpa_bytes_lo;
0203 
0204     /* PFC */
0205     u32 pfc_frames_received_hi;
0206     u32 pfc_frames_received_lo;
0207     u32 pfc_frames_sent_hi;
0208     u32 pfc_frames_sent_lo;
0209 
0210     /* Recovery */
0211     u32 recoverable_error;
0212     u32 unrecoverable_error;
0213     u32 driver_filtered_tx_pkt;
0214     /* src: Clear-on-Read register; Will not survive PMF Migration */
0215     u32 eee_tx_lpi;
0216 
0217     /* PTP */
0218     u32 ptp_skip_tx_ts;
0219 };
0220 
0221 struct bnx2x_eth_q_stats {
0222     u32 total_unicast_bytes_received_hi;
0223     u32 total_unicast_bytes_received_lo;
0224     u32 total_broadcast_bytes_received_hi;
0225     u32 total_broadcast_bytes_received_lo;
0226     u32 total_multicast_bytes_received_hi;
0227     u32 total_multicast_bytes_received_lo;
0228     u32 total_bytes_received_hi;
0229     u32 total_bytes_received_lo;
0230     u32 total_unicast_bytes_transmitted_hi;
0231     u32 total_unicast_bytes_transmitted_lo;
0232     u32 total_broadcast_bytes_transmitted_hi;
0233     u32 total_broadcast_bytes_transmitted_lo;
0234     u32 total_multicast_bytes_transmitted_hi;
0235     u32 total_multicast_bytes_transmitted_lo;
0236     u32 total_bytes_transmitted_hi;
0237     u32 total_bytes_transmitted_lo;
0238     u32 total_unicast_packets_received_hi;
0239     u32 total_unicast_packets_received_lo;
0240     u32 total_multicast_packets_received_hi;
0241     u32 total_multicast_packets_received_lo;
0242     u32 total_broadcast_packets_received_hi;
0243     u32 total_broadcast_packets_received_lo;
0244     u32 total_unicast_packets_transmitted_hi;
0245     u32 total_unicast_packets_transmitted_lo;
0246     u32 total_multicast_packets_transmitted_hi;
0247     u32 total_multicast_packets_transmitted_lo;
0248     u32 total_broadcast_packets_transmitted_hi;
0249     u32 total_broadcast_packets_transmitted_lo;
0250     u32 valid_bytes_received_hi;
0251     u32 valid_bytes_received_lo;
0252 
0253     u32 etherstatsoverrsizepkts_hi;
0254     u32 etherstatsoverrsizepkts_lo;
0255     u32 no_buff_discard_hi;
0256     u32 no_buff_discard_lo;
0257 
0258     u32 driver_xoff;
0259     u32 rx_err_discard_pkt;
0260     u32 rx_skb_alloc_failed;
0261     u32 hw_csum_err;
0262 
0263     u32 total_packets_received_checksum_discarded_hi;
0264     u32 total_packets_received_checksum_discarded_lo;
0265     u32 total_packets_received_ttl0_discarded_hi;
0266     u32 total_packets_received_ttl0_discarded_lo;
0267     u32 total_transmitted_dropped_packets_error_hi;
0268     u32 total_transmitted_dropped_packets_error_lo;
0269 
0270     /* TPA */
0271     u32 total_tpa_aggregations_hi;
0272     u32 total_tpa_aggregations_lo;
0273     u32 total_tpa_aggregated_frames_hi;
0274     u32 total_tpa_aggregated_frames_lo;
0275     u32 total_tpa_bytes_hi;
0276     u32 total_tpa_bytes_lo;
0277     u32 driver_filtered_tx_pkt;
0278 };
0279 
0280 struct bnx2x_eth_stats_old {
0281     u32 rx_stat_dot3statsframestoolong_hi;
0282     u32 rx_stat_dot3statsframestoolong_lo;
0283 };
0284 
0285 struct bnx2x_eth_q_stats_old {
0286     /* Fields to perserve over fw reset*/
0287     u32 total_unicast_bytes_received_hi;
0288     u32 total_unicast_bytes_received_lo;
0289     u32 total_broadcast_bytes_received_hi;
0290     u32 total_broadcast_bytes_received_lo;
0291     u32 total_multicast_bytes_received_hi;
0292     u32 total_multicast_bytes_received_lo;
0293     u32 total_unicast_bytes_transmitted_hi;
0294     u32 total_unicast_bytes_transmitted_lo;
0295     u32 total_broadcast_bytes_transmitted_hi;
0296     u32 total_broadcast_bytes_transmitted_lo;
0297     u32 total_multicast_bytes_transmitted_hi;
0298     u32 total_multicast_bytes_transmitted_lo;
0299     u32 total_tpa_bytes_hi;
0300     u32 total_tpa_bytes_lo;
0301 
0302     /* Fields to perserve last of */
0303     u32 total_bytes_received_hi;
0304     u32 total_bytes_received_lo;
0305     u32 total_bytes_transmitted_hi;
0306     u32 total_bytes_transmitted_lo;
0307     u32 total_unicast_packets_received_hi;
0308     u32 total_unicast_packets_received_lo;
0309     u32 total_multicast_packets_received_hi;
0310     u32 total_multicast_packets_received_lo;
0311     u32 total_broadcast_packets_received_hi;
0312     u32 total_broadcast_packets_received_lo;
0313     u32 total_unicast_packets_transmitted_hi;
0314     u32 total_unicast_packets_transmitted_lo;
0315     u32 total_multicast_packets_transmitted_hi;
0316     u32 total_multicast_packets_transmitted_lo;
0317     u32 total_broadcast_packets_transmitted_hi;
0318     u32 total_broadcast_packets_transmitted_lo;
0319     u32 valid_bytes_received_hi;
0320     u32 valid_bytes_received_lo;
0321 
0322     u32 total_tpa_bytes_hi_old;
0323     u32 total_tpa_bytes_lo_old;
0324 
0325     u32 driver_xoff_old;
0326     u32 rx_err_discard_pkt_old;
0327     u32 rx_skb_alloc_failed_old;
0328     u32 hw_csum_err_old;
0329     u32 driver_filtered_tx_pkt_old;
0330 };
0331 
0332 struct bnx2x_net_stats_old {
0333      u32 rx_dropped;
0334 };
0335 
0336 struct bnx2x_fw_port_stats_old {
0337      u32 mac_filter_discard;
0338      u32 mf_tag_discard;
0339      u32 brb_truncate_discard;
0340      u32 mac_discard;
0341 };
0342 
0343 /****************************************************************************
0344 * Macros
0345 ****************************************************************************/
0346 
0347 /* sum[hi:lo] += add[hi:lo] */
0348 #define ADD_64(s_hi, a_hi, s_lo, a_lo) \
0349     do { \
0350         s_lo += a_lo; \
0351         s_hi += a_hi + ((s_lo < a_lo) ? 1 : 0); \
0352     } while (0)
0353 
0354 #define LE32_0 ((__force __le32) 0)
0355 #define LE16_0 ((__force __le16) 0)
0356 
0357 /* The _force is for cases where high value is 0 */
0358 #define ADD_64_LE(s_hi, a_hi_le, s_lo, a_lo_le) \
0359         ADD_64(s_hi, le32_to_cpu(a_hi_le), \
0360                s_lo, le32_to_cpu(a_lo_le))
0361 
0362 #define ADD_64_LE16(s_hi, a_hi_le, s_lo, a_lo_le) \
0363         ADD_64(s_hi, le16_to_cpu(a_hi_le), \
0364                s_lo, le16_to_cpu(a_lo_le))
0365 
0366 /* difference = minuend - subtrahend */
0367 #define DIFF_64(d_hi, m_hi, s_hi, d_lo, m_lo, s_lo) \
0368     do { \
0369         if (m_lo < s_lo) { \
0370             /* underflow */ \
0371             d_hi = m_hi - s_hi; \
0372             if (d_hi > 0) { \
0373                 /* we can 'loan' 1 */ \
0374                 d_hi--; \
0375                 d_lo = m_lo + (UINT_MAX - s_lo) + 1; \
0376             } else { \
0377                 /* m_hi <= s_hi */ \
0378                 d_hi = 0; \
0379                 d_lo = 0; \
0380             } \
0381         } else { \
0382             /* m_lo >= s_lo */ \
0383             if (m_hi < s_hi) { \
0384                 d_hi = 0; \
0385                 d_lo = 0; \
0386             } else { \
0387                 /* m_hi >= s_hi */ \
0388                 d_hi = m_hi - s_hi; \
0389                 d_lo = m_lo - s_lo; \
0390             } \
0391         } \
0392     } while (0)
0393 
0394 #define UPDATE_STAT64(s, t) \
0395     do { \
0396         DIFF_64(diff.hi, new->s##_hi, pstats->mac_stx[0].t##_hi, \
0397             diff.lo, new->s##_lo, pstats->mac_stx[0].t##_lo); \
0398         pstats->mac_stx[0].t##_hi = new->s##_hi; \
0399         pstats->mac_stx[0].t##_lo = new->s##_lo; \
0400         ADD_64(pstats->mac_stx[1].t##_hi, diff.hi, \
0401                pstats->mac_stx[1].t##_lo, diff.lo); \
0402     } while (0)
0403 
0404 #define UPDATE_STAT64_NIG(s, t) \
0405     do { \
0406         DIFF_64(diff.hi, new->s##_hi, old->s##_hi, \
0407             diff.lo, new->s##_lo, old->s##_lo); \
0408         ADD_64(estats->t##_hi, diff.hi, \
0409                estats->t##_lo, diff.lo); \
0410     } while (0)
0411 
0412 /* sum[hi:lo] += add */
0413 #define ADD_EXTEND_64(s_hi, s_lo, a) \
0414     do { \
0415         s_lo += a; \
0416         s_hi += (s_lo < a) ? 1 : 0; \
0417     } while (0)
0418 
0419 #define ADD_STAT64(diff, t) \
0420     do { \
0421         ADD_64(pstats->mac_stx[1].t##_hi, new->diff##_hi, \
0422                pstats->mac_stx[1].t##_lo, new->diff##_lo); \
0423     } while (0)
0424 
0425 #define UPDATE_EXTEND_STAT(s) \
0426     do { \
0427         ADD_EXTEND_64(pstats->mac_stx[1].s##_hi, \
0428                   pstats->mac_stx[1].s##_lo, \
0429                   new->s); \
0430     } while (0)
0431 
0432 #define UPDATE_EXTEND_TSTAT_X(s, t, size) \
0433     do { \
0434         diff = le##size##_to_cpu(tclient->s) - \
0435                le##size##_to_cpu(old_tclient->s); \
0436         old_tclient->s = tclient->s; \
0437         ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \
0438     } while (0)
0439 
0440 #define UPDATE_EXTEND_TSTAT(s, t) UPDATE_EXTEND_TSTAT_X(s, t, 32)
0441 
0442 #define UPDATE_EXTEND_E_TSTAT(s, t, size) \
0443     do { \
0444         UPDATE_EXTEND_TSTAT_X(s, t, size); \
0445         ADD_EXTEND_64(estats->t##_hi, estats->t##_lo, diff); \
0446     } while (0)
0447 
0448 #define UPDATE_EXTEND_USTAT(s, t) \
0449     do { \
0450         diff = le32_to_cpu(uclient->s) - le32_to_cpu(old_uclient->s); \
0451         old_uclient->s = uclient->s; \
0452         ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \
0453     } while (0)
0454 
0455 #define UPDATE_EXTEND_E_USTAT(s, t) \
0456     do { \
0457         UPDATE_EXTEND_USTAT(s, t); \
0458         ADD_EXTEND_64(estats->t##_hi, estats->t##_lo, diff); \
0459     } while (0)
0460 
0461 #define UPDATE_EXTEND_XSTAT(s, t) \
0462     do { \
0463         diff = le32_to_cpu(xclient->s) - le32_to_cpu(old_xclient->s); \
0464         old_xclient->s = xclient->s; \
0465         ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \
0466     } while (0)
0467 
0468 #define UPDATE_QSTAT(s, t) \
0469     do { \
0470         qstats->t##_lo = qstats_old->t##_lo + le32_to_cpu(s.lo); \
0471         qstats->t##_hi = qstats_old->t##_hi + le32_to_cpu(s.hi) \
0472             + ((qstats->t##_lo < qstats_old->t##_lo) ? 1 : 0); \
0473     } while (0)
0474 
0475 #define UPDATE_QSTAT_OLD(f) \
0476     do { \
0477         qstats_old->f = qstats->f; \
0478     } while (0)
0479 
0480 #define UPDATE_ESTAT_QSTAT_64(s) \
0481     do { \
0482         ADD_64(estats->s##_hi, qstats->s##_hi, \
0483                estats->s##_lo, qstats->s##_lo); \
0484         SUB_64(estats->s##_hi, qstats_old->s##_hi_old, \
0485                estats->s##_lo, qstats_old->s##_lo_old); \
0486         qstats_old->s##_hi_old = qstats->s##_hi; \
0487         qstats_old->s##_lo_old = qstats->s##_lo; \
0488     } while (0)
0489 
0490 #define UPDATE_ESTAT_QSTAT(s) \
0491     do { \
0492         estats->s += qstats->s; \
0493         estats->s -= qstats_old->s##_old; \
0494         qstats_old->s##_old = qstats->s; \
0495     } while (0)
0496 
0497 #define UPDATE_FSTAT_QSTAT(s) \
0498     do { \
0499         ADD_64(fstats->s##_hi, qstats->s##_hi, \
0500                fstats->s##_lo, qstats->s##_lo); \
0501         SUB_64(fstats->s##_hi, qstats_old->s##_hi, \
0502                fstats->s##_lo, qstats_old->s##_lo); \
0503         estats->s##_hi = fstats->s##_hi; \
0504         estats->s##_lo = fstats->s##_lo; \
0505         qstats_old->s##_hi = qstats->s##_hi; \
0506         qstats_old->s##_lo = qstats->s##_lo; \
0507     } while (0)
0508 
0509 #define UPDATE_FW_STAT(s) \
0510     do { \
0511         estats->s = le32_to_cpu(tport->s) + fwstats->s; \
0512     } while (0)
0513 
0514 #define UPDATE_FW_STAT_OLD(f) \
0515     do { \
0516         fwstats->f = estats->f; \
0517     } while (0)
0518 
0519 #define UPDATE_ESTAT(s, t) \
0520     do { \
0521         SUB_64(estats->s##_hi, estats_old->t##_hi, \
0522                estats->s##_lo, estats_old->t##_lo); \
0523         ADD_64(estats->s##_hi, estats->t##_hi, \
0524                estats->s##_lo, estats->t##_lo); \
0525         estats_old->t##_hi = estats->t##_hi; \
0526         estats_old->t##_lo = estats->t##_lo; \
0527     } while (0)
0528 
0529 /* minuend -= subtrahend */
0530 #define SUB_64(m_hi, s_hi, m_lo, s_lo) \
0531     do { \
0532         DIFF_64(m_hi, m_hi, s_hi, m_lo, m_lo, s_lo); \
0533     } while (0)
0534 
0535 /* minuend[hi:lo] -= subtrahend */
0536 #define SUB_EXTEND_64(m_hi, m_lo, s) \
0537     do { \
0538         SUB_64(m_hi, 0, m_lo, s); \
0539     } while (0)
0540 
0541 #define SUB_EXTEND_USTAT(s, t) \
0542     do { \
0543         diff = le32_to_cpu(uclient->s) - le32_to_cpu(old_uclient->s); \
0544         SUB_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \
0545     } while (0)
0546 
0547 /* forward */
0548 struct bnx2x;
0549 
0550 void bnx2x_memset_stats(struct bnx2x *bp);
0551 void bnx2x_stats_init(struct bnx2x *bp);
0552 void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event);
0553 int bnx2x_stats_safe_exec(struct bnx2x *bp,
0554               void (func_to_exec)(void *cookie),
0555               void *cookie);
0556 
0557 /**
0558  * bnx2x_save_statistics - save statistics when unloading.
0559  *
0560  * @bp:     driver handle
0561  */
0562 void bnx2x_save_statistics(struct bnx2x *bp);
0563 
0564 void bnx2x_afex_collect_stats(struct bnx2x *bp, void *void_afex_stats,
0565                   u32 stats_type);
0566 #endif /* BNX2X_STATS_H */