bnx2x_stats.h 15 KB

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