qla_dbg.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. /*
  2. * QLogic Fibre Channel HBA Driver
  3. * Copyright (c) 2003-2014 QLogic Corporation
  4. *
  5. * See LICENSE.qla2xxx for copyright and licensing details.
  6. */
  7. #include "qla_def.h"
  8. /*
  9. * Firmware Dump structure definition
  10. */
  11. struct qla2300_fw_dump {
  12. uint16_t hccr;
  13. uint16_t pbiu_reg[8];
  14. uint16_t risc_host_reg[8];
  15. uint16_t mailbox_reg[32];
  16. uint16_t resp_dma_reg[32];
  17. uint16_t dma_reg[48];
  18. uint16_t risc_hdw_reg[16];
  19. uint16_t risc_gp0_reg[16];
  20. uint16_t risc_gp1_reg[16];
  21. uint16_t risc_gp2_reg[16];
  22. uint16_t risc_gp3_reg[16];
  23. uint16_t risc_gp4_reg[16];
  24. uint16_t risc_gp5_reg[16];
  25. uint16_t risc_gp6_reg[16];
  26. uint16_t risc_gp7_reg[16];
  27. uint16_t frame_buf_hdw_reg[64];
  28. uint16_t fpm_b0_reg[64];
  29. uint16_t fpm_b1_reg[64];
  30. uint16_t risc_ram[0xf800];
  31. uint16_t stack_ram[0x1000];
  32. uint16_t data_ram[1];
  33. };
  34. struct qla2100_fw_dump {
  35. uint16_t hccr;
  36. uint16_t pbiu_reg[8];
  37. uint16_t mailbox_reg[32];
  38. uint16_t dma_reg[48];
  39. uint16_t risc_hdw_reg[16];
  40. uint16_t risc_gp0_reg[16];
  41. uint16_t risc_gp1_reg[16];
  42. uint16_t risc_gp2_reg[16];
  43. uint16_t risc_gp3_reg[16];
  44. uint16_t risc_gp4_reg[16];
  45. uint16_t risc_gp5_reg[16];
  46. uint16_t risc_gp6_reg[16];
  47. uint16_t risc_gp7_reg[16];
  48. uint16_t frame_buf_hdw_reg[16];
  49. uint16_t fpm_b0_reg[64];
  50. uint16_t fpm_b1_reg[64];
  51. uint16_t risc_ram[0xf000];
  52. };
  53. struct qla24xx_fw_dump {
  54. uint32_t host_status;
  55. uint32_t host_reg[32];
  56. uint32_t shadow_reg[7];
  57. uint16_t mailbox_reg[32];
  58. uint32_t xseq_gp_reg[128];
  59. uint32_t xseq_0_reg[16];
  60. uint32_t xseq_1_reg[16];
  61. uint32_t rseq_gp_reg[128];
  62. uint32_t rseq_0_reg[16];
  63. uint32_t rseq_1_reg[16];
  64. uint32_t rseq_2_reg[16];
  65. uint32_t cmd_dma_reg[16];
  66. uint32_t req0_dma_reg[15];
  67. uint32_t resp0_dma_reg[15];
  68. uint32_t req1_dma_reg[15];
  69. uint32_t xmt0_dma_reg[32];
  70. uint32_t xmt1_dma_reg[32];
  71. uint32_t xmt2_dma_reg[32];
  72. uint32_t xmt3_dma_reg[32];
  73. uint32_t xmt4_dma_reg[32];
  74. uint32_t xmt_data_dma_reg[16];
  75. uint32_t rcvt0_data_dma_reg[32];
  76. uint32_t rcvt1_data_dma_reg[32];
  77. uint32_t risc_gp_reg[128];
  78. uint32_t lmc_reg[112];
  79. uint32_t fpm_hdw_reg[192];
  80. uint32_t fb_hdw_reg[176];
  81. uint32_t code_ram[0x2000];
  82. uint32_t ext_mem[1];
  83. };
  84. struct qla25xx_fw_dump {
  85. uint32_t host_status;
  86. uint32_t host_risc_reg[32];
  87. uint32_t pcie_regs[4];
  88. uint32_t host_reg[32];
  89. uint32_t shadow_reg[11];
  90. uint32_t risc_io_reg;
  91. uint16_t mailbox_reg[32];
  92. uint32_t xseq_gp_reg[128];
  93. uint32_t xseq_0_reg[48];
  94. uint32_t xseq_1_reg[16];
  95. uint32_t rseq_gp_reg[128];
  96. uint32_t rseq_0_reg[32];
  97. uint32_t rseq_1_reg[16];
  98. uint32_t rseq_2_reg[16];
  99. uint32_t aseq_gp_reg[128];
  100. uint32_t aseq_0_reg[32];
  101. uint32_t aseq_1_reg[16];
  102. uint32_t aseq_2_reg[16];
  103. uint32_t cmd_dma_reg[16];
  104. uint32_t req0_dma_reg[15];
  105. uint32_t resp0_dma_reg[15];
  106. uint32_t req1_dma_reg[15];
  107. uint32_t xmt0_dma_reg[32];
  108. uint32_t xmt1_dma_reg[32];
  109. uint32_t xmt2_dma_reg[32];
  110. uint32_t xmt3_dma_reg[32];
  111. uint32_t xmt4_dma_reg[32];
  112. uint32_t xmt_data_dma_reg[16];
  113. uint32_t rcvt0_data_dma_reg[32];
  114. uint32_t rcvt1_data_dma_reg[32];
  115. uint32_t risc_gp_reg[128];
  116. uint32_t lmc_reg[128];
  117. uint32_t fpm_hdw_reg[192];
  118. uint32_t fb_hdw_reg[192];
  119. uint32_t code_ram[0x2000];
  120. uint32_t ext_mem[1];
  121. };
  122. struct qla81xx_fw_dump {
  123. uint32_t host_status;
  124. uint32_t host_risc_reg[32];
  125. uint32_t pcie_regs[4];
  126. uint32_t host_reg[32];
  127. uint32_t shadow_reg[11];
  128. uint32_t risc_io_reg;
  129. uint16_t mailbox_reg[32];
  130. uint32_t xseq_gp_reg[128];
  131. uint32_t xseq_0_reg[48];
  132. uint32_t xseq_1_reg[16];
  133. uint32_t rseq_gp_reg[128];
  134. uint32_t rseq_0_reg[32];
  135. uint32_t rseq_1_reg[16];
  136. uint32_t rseq_2_reg[16];
  137. uint32_t aseq_gp_reg[128];
  138. uint32_t aseq_0_reg[32];
  139. uint32_t aseq_1_reg[16];
  140. uint32_t aseq_2_reg[16];
  141. uint32_t cmd_dma_reg[16];
  142. uint32_t req0_dma_reg[15];
  143. uint32_t resp0_dma_reg[15];
  144. uint32_t req1_dma_reg[15];
  145. uint32_t xmt0_dma_reg[32];
  146. uint32_t xmt1_dma_reg[32];
  147. uint32_t xmt2_dma_reg[32];
  148. uint32_t xmt3_dma_reg[32];
  149. uint32_t xmt4_dma_reg[32];
  150. uint32_t xmt_data_dma_reg[16];
  151. uint32_t rcvt0_data_dma_reg[32];
  152. uint32_t rcvt1_data_dma_reg[32];
  153. uint32_t risc_gp_reg[128];
  154. uint32_t lmc_reg[128];
  155. uint32_t fpm_hdw_reg[224];
  156. uint32_t fb_hdw_reg[208];
  157. uint32_t code_ram[0x2000];
  158. uint32_t ext_mem[1];
  159. };
  160. struct qla83xx_fw_dump {
  161. uint32_t host_status;
  162. uint32_t host_risc_reg[48];
  163. uint32_t pcie_regs[4];
  164. uint32_t host_reg[32];
  165. uint32_t shadow_reg[11];
  166. uint32_t risc_io_reg;
  167. uint16_t mailbox_reg[32];
  168. uint32_t xseq_gp_reg[256];
  169. uint32_t xseq_0_reg[48];
  170. uint32_t xseq_1_reg[16];
  171. uint32_t xseq_2_reg[16];
  172. uint32_t rseq_gp_reg[256];
  173. uint32_t rseq_0_reg[32];
  174. uint32_t rseq_1_reg[16];
  175. uint32_t rseq_2_reg[16];
  176. uint32_t rseq_3_reg[16];
  177. uint32_t aseq_gp_reg[256];
  178. uint32_t aseq_0_reg[32];
  179. uint32_t aseq_1_reg[16];
  180. uint32_t aseq_2_reg[16];
  181. uint32_t aseq_3_reg[16];
  182. uint32_t cmd_dma_reg[64];
  183. uint32_t req0_dma_reg[15];
  184. uint32_t resp0_dma_reg[15];
  185. uint32_t req1_dma_reg[15];
  186. uint32_t xmt0_dma_reg[32];
  187. uint32_t xmt1_dma_reg[32];
  188. uint32_t xmt2_dma_reg[32];
  189. uint32_t xmt3_dma_reg[32];
  190. uint32_t xmt4_dma_reg[32];
  191. uint32_t xmt_data_dma_reg[16];
  192. uint32_t rcvt0_data_dma_reg[32];
  193. uint32_t rcvt1_data_dma_reg[32];
  194. uint32_t risc_gp_reg[128];
  195. uint32_t lmc_reg[128];
  196. uint32_t fpm_hdw_reg[256];
  197. uint32_t rq0_array_reg[256];
  198. uint32_t rq1_array_reg[256];
  199. uint32_t rp0_array_reg[256];
  200. uint32_t rp1_array_reg[256];
  201. uint32_t queue_control_reg[16];
  202. uint32_t fb_hdw_reg[432];
  203. uint32_t at0_array_reg[128];
  204. uint32_t code_ram[0x2400];
  205. uint32_t ext_mem[1];
  206. };
  207. #define EFT_NUM_BUFFERS 4
  208. #define EFT_BYTES_PER_BUFFER 0x4000
  209. #define EFT_SIZE ((EFT_BYTES_PER_BUFFER) * (EFT_NUM_BUFFERS))
  210. #define FCE_NUM_BUFFERS 64
  211. #define FCE_BYTES_PER_BUFFER 0x400
  212. #define FCE_SIZE ((FCE_BYTES_PER_BUFFER) * (FCE_NUM_BUFFERS))
  213. #define fce_calc_size(b) ((FCE_BYTES_PER_BUFFER) * (b))
  214. struct qla2xxx_fce_chain {
  215. uint32_t type;
  216. uint32_t chain_size;
  217. uint32_t size;
  218. uint32_t addr_l;
  219. uint32_t addr_h;
  220. uint32_t eregs[8];
  221. };
  222. /* used by exchange off load and extended login offload */
  223. struct qla2xxx_offld_chain {
  224. uint32_t type;
  225. uint32_t chain_size;
  226. uint32_t size;
  227. u64 addr;
  228. };
  229. struct qla2xxx_mq_chain {
  230. uint32_t type;
  231. uint32_t chain_size;
  232. uint32_t count;
  233. uint32_t qregs[4 * QLA_MQ_SIZE];
  234. };
  235. struct qla2xxx_mqueue_header {
  236. uint32_t queue;
  237. #define TYPE_REQUEST_QUEUE 0x1
  238. #define TYPE_RESPONSE_QUEUE 0x2
  239. #define TYPE_ATIO_QUEUE 0x3
  240. uint32_t number;
  241. uint32_t size;
  242. };
  243. struct qla2xxx_mqueue_chain {
  244. uint32_t type;
  245. uint32_t chain_size;
  246. };
  247. #define DUMP_CHAIN_VARIANT 0x80000000
  248. #define DUMP_CHAIN_FCE 0x7FFFFAF0
  249. #define DUMP_CHAIN_MQ 0x7FFFFAF1
  250. #define DUMP_CHAIN_QUEUE 0x7FFFFAF2
  251. #define DUMP_CHAIN_EXLOGIN 0x7FFFFAF3
  252. #define DUMP_CHAIN_EXCHG 0x7FFFFAF4
  253. #define DUMP_CHAIN_LAST 0x80000000
  254. struct qla2xxx_fw_dump {
  255. uint8_t signature[4];
  256. uint32_t version;
  257. uint32_t fw_major_version;
  258. uint32_t fw_minor_version;
  259. uint32_t fw_subminor_version;
  260. uint32_t fw_attributes;
  261. uint32_t vendor;
  262. uint32_t device;
  263. uint32_t subsystem_vendor;
  264. uint32_t subsystem_device;
  265. uint32_t fixed_size;
  266. uint32_t mem_size;
  267. uint32_t req_q_size;
  268. uint32_t rsp_q_size;
  269. uint32_t eft_size;
  270. uint32_t eft_addr_l;
  271. uint32_t eft_addr_h;
  272. uint32_t header_size;
  273. union {
  274. struct qla2100_fw_dump isp21;
  275. struct qla2300_fw_dump isp23;
  276. struct qla24xx_fw_dump isp24;
  277. struct qla25xx_fw_dump isp25;
  278. struct qla81xx_fw_dump isp81;
  279. struct qla83xx_fw_dump isp83;
  280. } isp;
  281. };
  282. #define QL_MSGHDR "qla2xxx"
  283. #define QL_DBG_DEFAULT1_MASK 0x1e400000
  284. #define ql_log_fatal 0 /* display fatal errors */
  285. #define ql_log_warn 1 /* display critical errors */
  286. #define ql_log_info 2 /* display all recovered errors */
  287. #define ql_log_all 3 /* This value is only used by ql_errlev.
  288. * No messages will use this value.
  289. * This should be always highest value
  290. * as compared to other log levels.
  291. */
  292. extern int ql_errlev;
  293. void __attribute__((format (printf, 4, 5)))
  294. ql_dbg(uint32_t, scsi_qla_host_t *vha, int32_t, const char *fmt, ...);
  295. void __attribute__((format (printf, 4, 5)))
  296. ql_dbg_pci(uint32_t, struct pci_dev *pdev, int32_t, const char *fmt, ...);
  297. void __attribute__((format (printf, 4, 5)))
  298. ql_dbg_qp(uint32_t, struct qla_qpair *, int32_t, const char *fmt, ...);
  299. void __attribute__((format (printf, 4, 5)))
  300. ql_log(uint32_t, scsi_qla_host_t *vha, int32_t, const char *fmt, ...);
  301. void __attribute__((format (printf, 4, 5)))
  302. ql_log_pci(uint32_t, struct pci_dev *pdev, int32_t, const char *fmt, ...);
  303. void __attribute__((format (printf, 4, 5)))
  304. ql_log_qp(uint32_t, struct qla_qpair *, int32_t, const char *fmt, ...);
  305. /* Debug Levels */
  306. /* The 0x40000000 is the max value any debug level can have
  307. * as ql2xextended_error_logging is of type signed int
  308. */
  309. #define ql_dbg_init 0x40000000 /* Init Debug */
  310. #define ql_dbg_mbx 0x20000000 /* MBX Debug */
  311. #define ql_dbg_disc 0x10000000 /* Device Discovery Debug */
  312. #define ql_dbg_io 0x08000000 /* IO Tracing Debug */
  313. #define ql_dbg_dpc 0x04000000 /* DPC Thead Debug */
  314. #define ql_dbg_async 0x02000000 /* Async events Debug */
  315. #define ql_dbg_timer 0x01000000 /* Timer Debug */
  316. #define ql_dbg_user 0x00800000 /* User Space Interations Debug */
  317. #define ql_dbg_taskm 0x00400000 /* Task Management Debug */
  318. #define ql_dbg_aer 0x00200000 /* AER/EEH Debug */
  319. #define ql_dbg_multiq 0x00100000 /* MultiQ Debug */
  320. #define ql_dbg_p3p 0x00080000 /* P3P specific Debug */
  321. #define ql_dbg_vport 0x00040000 /* Virtual Port Debug */
  322. #define ql_dbg_buffer 0x00020000 /* For dumping the buffer/regs */
  323. #define ql_dbg_misc 0x00010000 /* For dumping everything that is not
  324. * not covered by upper categories
  325. */
  326. #define ql_dbg_verbose 0x00008000 /* More verbosity for each level
  327. * This is to be used with other levels where
  328. * more verbosity is required. It might not
  329. * be applicable to all the levels.
  330. */
  331. #define ql_dbg_tgt 0x00004000 /* Target mode */
  332. #define ql_dbg_tgt_mgt 0x00002000 /* Target mode management */
  333. #define ql_dbg_tgt_tmr 0x00001000 /* Target mode task management */
  334. #define ql_dbg_tgt_dif 0x00000800 /* Target mode dif */
  335. extern int qla27xx_dump_mpi_ram(struct qla_hw_data *, uint32_t, uint32_t *,
  336. uint32_t, void **);
  337. extern int qla24xx_dump_ram(struct qla_hw_data *, uint32_t, uint32_t *,
  338. uint32_t, void **);
  339. extern void qla24xx_pause_risc(struct device_reg_24xx __iomem *,
  340. struct qla_hw_data *);
  341. extern int qla24xx_soft_reset(struct qla_hw_data *);
  342. static inline int
  343. ql_mask_match(uint level)
  344. {
  345. return (level & ql2xextended_error_logging) == level;
  346. }