Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bnx2x_stats.h
Go to the documentation of this file.
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 <[email protected]>
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 
20 #include <linux/types.h>
21 
22 struct nig_stats {
41 };
42 
43 
50 };
51 
56 };
57 
77 
84 
161 
166 
171 
176 
181 
186 
188 
189  /* TPA */
196 
197  /* PFC */
202 
203  /* Recovery */
206  /* src: Clear-on-Read register; Will not survive PMF Migration */
208 };
209 
210 
242 
247 
252 
259 
260  /* TPA */
267 };
268 
272 };
273 
275  /* Fields to perserve over fw reset*/
290 
291  /* Fields to perserve last of */
310 
313 
318 };
319 
322 };
323 
329 };
330 
331 
332 /****************************************************************************
333 * Macros
334 ****************************************************************************/
335 
336 /* sum[hi:lo] += add[hi:lo] */
337 #define ADD_64(s_hi, a_hi, s_lo, a_lo) \
338  do { \
339  s_lo += a_lo; \
340  s_hi += a_hi + ((s_lo < a_lo) ? 1 : 0); \
341  } while (0)
342 
343 #define LE32_0 ((__force __le32) 0)
344 #define LE16_0 ((__force __le16) 0)
345 
346 /* The _force is for cases where high value is 0 */
347 #define ADD_64_LE(s_hi, a_hi_le, s_lo, a_lo_le) \
348  ADD_64(s_hi, le32_to_cpu(a_hi_le), \
349  s_lo, le32_to_cpu(a_lo_le))
350 
351 #define ADD_64_LE16(s_hi, a_hi_le, s_lo, a_lo_le) \
352  ADD_64(s_hi, le16_to_cpu(a_hi_le), \
353  s_lo, le16_to_cpu(a_lo_le))
354 
355 /* difference = minuend - subtrahend */
356 #define DIFF_64(d_hi, m_hi, s_hi, d_lo, m_lo, s_lo) \
357  do { \
358  if (m_lo < s_lo) { \
359  /* underflow */ \
360  d_hi = m_hi - s_hi; \
361  if (d_hi > 0) { \
362  /* we can 'loan' 1 */ \
363  d_hi--; \
364  d_lo = m_lo + (UINT_MAX - s_lo) + 1; \
365  } else { \
366  /* m_hi <= s_hi */ \
367  d_hi = 0; \
368  d_lo = 0; \
369  } \
370  } else { \
371  /* m_lo >= s_lo */ \
372  if (m_hi < s_hi) { \
373  d_hi = 0; \
374  d_lo = 0; \
375  } else { \
376  /* m_hi >= s_hi */ \
377  d_hi = m_hi - s_hi; \
378  d_lo = m_lo - s_lo; \
379  } \
380  } \
381  } while (0)
382 
383 #define UPDATE_STAT64(s, t) \
384  do { \
385  DIFF_64(diff.hi, new->s##_hi, pstats->mac_stx[0].t##_hi, \
386  diff.lo, new->s##_lo, pstats->mac_stx[0].t##_lo); \
387  pstats->mac_stx[0].t##_hi = new->s##_hi; \
388  pstats->mac_stx[0].t##_lo = new->s##_lo; \
389  ADD_64(pstats->mac_stx[1].t##_hi, diff.hi, \
390  pstats->mac_stx[1].t##_lo, diff.lo); \
391  } while (0)
392 
393 #define UPDATE_STAT64_NIG(s, t) \
394  do { \
395  DIFF_64(diff.hi, new->s##_hi, old->s##_hi, \
396  diff.lo, new->s##_lo, old->s##_lo); \
397  ADD_64(estats->t##_hi, diff.hi, \
398  estats->t##_lo, diff.lo); \
399  } while (0)
400 
401 /* sum[hi:lo] += add */
402 #define ADD_EXTEND_64(s_hi, s_lo, a) \
403  do { \
404  s_lo += a; \
405  s_hi += (s_lo < a) ? 1 : 0; \
406  } while (0)
407 
408 #define ADD_STAT64(diff, t) \
409  do { \
410  ADD_64(pstats->mac_stx[1].t##_hi, new->diff##_hi, \
411  pstats->mac_stx[1].t##_lo, new->diff##_lo); \
412  } while (0)
413 
414 #define UPDATE_EXTEND_STAT(s) \
415  do { \
416  ADD_EXTEND_64(pstats->mac_stx[1].s##_hi, \
417  pstats->mac_stx[1].s##_lo, \
418  new->s); \
419  } while (0)
420 
421 #define UPDATE_EXTEND_TSTAT(s, t) \
422  do { \
423  diff = le32_to_cpu(tclient->s) - le32_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_E_TSTAT(s, t) \
429  do { \
430  UPDATE_EXTEND_TSTAT(s, t); \
431  ADD_EXTEND_64(estats->t##_hi, estats->t##_lo, diff); \
432  } while (0)
433 
434 #define UPDATE_EXTEND_USTAT(s, t) \
435  do { \
436  diff = le32_to_cpu(uclient->s) - le32_to_cpu(old_uclient->s); \
437  old_uclient->s = uclient->s; \
438  ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \
439  } while (0)
440 
441 #define UPDATE_EXTEND_E_USTAT(s, t) \
442  do { \
443  UPDATE_EXTEND_USTAT(s, t); \
444  ADD_EXTEND_64(estats->t##_hi, estats->t##_lo, diff); \
445  } while (0)
446 
447 #define UPDATE_EXTEND_XSTAT(s, t) \
448  do { \
449  diff = le32_to_cpu(xclient->s) - le32_to_cpu(old_xclient->s); \
450  old_xclient->s = xclient->s; \
451  ADD_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \
452  } while (0)
453 
454 #define UPDATE_QSTAT(s, t) \
455  do { \
456  qstats->t##_hi = qstats_old->t##_hi + le32_to_cpu(s.hi); \
457  qstats->t##_lo = qstats_old->t##_lo + le32_to_cpu(s.lo); \
458  } while (0)
459 
460 #define UPDATE_QSTAT_OLD(f) \
461  do { \
462  qstats_old->f = qstats->f; \
463  } while (0)
464 
465 #define UPDATE_ESTAT_QSTAT_64(s) \
466  do { \
467  ADD_64(estats->s##_hi, qstats->s##_hi, \
468  estats->s##_lo, qstats->s##_lo); \
469  SUB_64(estats->s##_hi, qstats_old->s##_hi_old, \
470  estats->s##_lo, qstats_old->s##_lo_old); \
471  qstats_old->s##_hi_old = qstats->s##_hi; \
472  qstats_old->s##_lo_old = qstats->s##_lo; \
473  } while (0)
474 
475 #define UPDATE_ESTAT_QSTAT(s) \
476  do { \
477  estats->s += qstats->s; \
478  estats->s -= qstats_old->s##_old; \
479  qstats_old->s##_old = qstats->s; \
480  } while (0)
481 
482 #define UPDATE_FSTAT_QSTAT(s) \
483  do { \
484  ADD_64(fstats->s##_hi, qstats->s##_hi, \
485  fstats->s##_lo, qstats->s##_lo); \
486  SUB_64(fstats->s##_hi, qstats_old->s##_hi, \
487  fstats->s##_lo, qstats_old->s##_lo); \
488  estats->s##_hi = fstats->s##_hi; \
489  estats->s##_lo = fstats->s##_lo; \
490  qstats_old->s##_hi = qstats->s##_hi; \
491  qstats_old->s##_lo = qstats->s##_lo; \
492  } while (0)
493 
494 #define UPDATE_FW_STAT(s) \
495  do { \
496  estats->s = le32_to_cpu(tport->s) + fwstats->s; \
497  } while (0)
498 
499 #define UPDATE_FW_STAT_OLD(f) \
500  do { \
501  fwstats->f = estats->f; \
502  } while (0)
503 
504 #define UPDATE_ESTAT(s, t) \
505  do { \
506  SUB_64(estats->s##_hi, estats_old->t##_hi, \
507  estats->s##_lo, estats_old->t##_lo); \
508  ADD_64(estats->s##_hi, estats->t##_hi, \
509  estats->s##_lo, estats->t##_lo); \
510  estats_old->t##_hi = estats->t##_hi; \
511  estats_old->t##_lo = estats->t##_lo; \
512  } while (0)
513 
514 /* minuend -= subtrahend */
515 #define SUB_64(m_hi, s_hi, m_lo, s_lo) \
516  do { \
517  DIFF_64(m_hi, m_hi, s_hi, m_lo, m_lo, s_lo); \
518  } while (0)
519 
520 /* minuend[hi:lo] -= subtrahend */
521 #define SUB_EXTEND_64(m_hi, m_lo, s) \
522  do { \
523  SUB_64(m_hi, 0, m_lo, s); \
524  } while (0)
525 
526 #define SUB_EXTEND_USTAT(s, t) \
527  do { \
528  diff = le32_to_cpu(uclient->s) - le32_to_cpu(old_uclient->s); \
529  SUB_EXTEND_64(qstats->t##_hi, qstats->t##_lo, diff); \
530  } while (0)
531 
532 
533 /* forward */
534 struct bnx2x;
535 
536 void bnx2x_stats_init(struct bnx2x *bp);
537 
538 void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event);
539 
545 void bnx2x_save_statistics(struct bnx2x *bp);
546 
547 void bnx2x_afex_collect_stats(struct bnx2x *bp, void *void_afex_stats,
548  u32 stats_type);
549 #endif /* BNX2X_STATS_H */