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