bfa_plog.h 4.1 KB

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