bnx2x_stats.h 16 KB

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