bfa_plog.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
  3. * Copyright (c) 2014- QLogic Corporation.
  4. * All rights reserved
  5. * www.qlogic.com
  6. *
  7. * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License (GPL) Version 2 as
  11. * published by the Free Software Foundation
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. */
  18. #ifndef __BFA_PORTLOG_H__
  19. #define __BFA_PORTLOG_H__
  20. #include "bfa_fc.h"
  21. #include "bfa_defs.h"
  22. #define BFA_PL_NLOG_ENTS 256
  23. #define BFA_PL_LOG_REC_INCR(_x) ((_x)++, (_x) %= BFA_PL_NLOG_ENTS)
  24. #define BFA_PL_STRING_LOG_SZ 32 /* number of chars in string log */
  25. #define BFA_PL_INT_LOG_SZ 8 /* number of integers in the integer log */
  26. enum bfa_plog_log_type {
  27. BFA_PL_LOG_TYPE_INVALID = 0,
  28. BFA_PL_LOG_TYPE_INT = 1,
  29. BFA_PL_LOG_TYPE_STRING = 2,
  30. };
  31. /*
  32. * the (fixed size) record format for each entry in the portlog
  33. */
  34. struct bfa_plog_rec_s {
  35. u64 tv; /* timestamp */
  36. u8 port; /* Source port that logged this entry */
  37. u8 mid; /* module id */
  38. u8 eid; /* indicates Rx, Tx, IOCTL, etc. bfa_plog_eid */
  39. u8 log_type; /* string/integer log, bfa_plog_log_type_t */
  40. u8 log_num_ints;
  41. /*
  42. * interpreted only if log_type is INT_LOG. indicates number of
  43. * integers in the int_log[] (0-PL_INT_LOG_SZ).
  44. */
  45. u8 rsvd;
  46. u16 misc; /* can be used to indicate fc frame length */
  47. union {
  48. char string_log[BFA_PL_STRING_LOG_SZ];
  49. u32 int_log[BFA_PL_INT_LOG_SZ];
  50. } log_entry;
  51. };
  52. /*
  53. * the following #defines will be used by the logging entities to indicate
  54. * their module id. BFAL will convert the integer value to string format
  55. *
  56. * process to be used while changing the following #defines:
  57. * - Always add new entries at the end
  58. * - define corresponding string in BFAL
  59. * - Do not remove any entry or rearrange the order.
  60. */
  61. enum bfa_plog_mid {
  62. BFA_PL_MID_INVALID = 0,
  63. BFA_PL_MID_DEBUG = 1,
  64. BFA_PL_MID_DRVR = 2,
  65. BFA_PL_MID_HAL = 3,
  66. BFA_PL_MID_HAL_FCXP = 4,
  67. BFA_PL_MID_HAL_UF = 5,
  68. BFA_PL_MID_FCS = 6,
  69. BFA_PL_MID_LPS = 7,
  70. BFA_PL_MID_MAX = 8
  71. };
  72. #define BFA_PL_MID_STRLEN 8
  73. struct bfa_plog_mid_strings_s {
  74. char m_str[BFA_PL_MID_STRLEN];
  75. };
  76. /*
  77. * the following #defines will be used by the logging entities to indicate
  78. * their event type. BFAL will convert the integer value to string format
  79. *
  80. * process to be used while changing the following #defines:
  81. * - Always add new entries at the end
  82. * - define corresponding string in BFAL
  83. * - Do not remove any entry or rearrange the order.
  84. */
  85. enum bfa_plog_eid {
  86. BFA_PL_EID_INVALID = 0,
  87. BFA_PL_EID_IOC_DISABLE = 1,
  88. BFA_PL_EID_IOC_ENABLE = 2,
  89. BFA_PL_EID_PORT_DISABLE = 3,
  90. BFA_PL_EID_PORT_ENABLE = 4,
  91. BFA_PL_EID_PORT_ST_CHANGE = 5,
  92. BFA_PL_EID_TX = 6,
  93. BFA_PL_EID_TX_ACK1 = 7,
  94. BFA_PL_EID_TX_RJT = 8,
  95. BFA_PL_EID_TX_BSY = 9,
  96. BFA_PL_EID_RX = 10,
  97. BFA_PL_EID_RX_ACK1 = 11,
  98. BFA_PL_EID_RX_RJT = 12,
  99. BFA_PL_EID_RX_BSY = 13,
  100. BFA_PL_EID_CT_IN = 14,
  101. BFA_PL_EID_CT_OUT = 15,
  102. BFA_PL_EID_DRIVER_START = 16,
  103. BFA_PL_EID_RSCN = 17,
  104. BFA_PL_EID_DEBUG = 18,
  105. BFA_PL_EID_MISC = 19,
  106. BFA_PL_EID_FIP_FCF_DISC = 20,
  107. BFA_PL_EID_FIP_FCF_CVL = 21,
  108. BFA_PL_EID_LOGIN = 22,
  109. BFA_PL_EID_LOGO = 23,
  110. BFA_PL_EID_TRUNK_SCN = 24,
  111. BFA_PL_EID_MAX
  112. };
  113. #define BFA_PL_ENAME_STRLEN 8
  114. struct bfa_plog_eid_strings_s {
  115. char e_str[BFA_PL_ENAME_STRLEN];
  116. };
  117. #define BFA_PL_SIG_LEN 8
  118. #define BFA_PL_SIG_STR "12pl123"
  119. /*
  120. * per port circular log buffer
  121. */
  122. struct bfa_plog_s {
  123. char plog_sig[BFA_PL_SIG_LEN]; /* Start signature */
  124. u8 plog_enabled;
  125. u8 rsvd[7];
  126. u32 ticks;
  127. u16 head;
  128. u16 tail;
  129. struct bfa_plog_rec_s plog_recs[BFA_PL_NLOG_ENTS];
  130. };
  131. void bfa_plog_init(struct bfa_plog_s *plog);
  132. void bfa_plog_str(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
  133. enum bfa_plog_eid event, u16 misc, char *log_str);
  134. void bfa_plog_intarr(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
  135. enum bfa_plog_eid event, u16 misc,
  136. u32 *intarr, u32 num_ints);
  137. void bfa_plog_fchdr(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
  138. enum bfa_plog_eid event, u16 misc, struct fchs_s *fchdr);
  139. void bfa_plog_fchdr_and_pl(struct bfa_plog_s *plog, enum bfa_plog_mid mid,
  140. enum bfa_plog_eid event, u16 misc,
  141. struct fchs_s *fchdr, u32 pld_w0);
  142. #endif /* __BFA_PORTLOG_H__ */