qla_mr.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. /*
  2. * QLogic Fibre Channel HBA Driver
  3. * Copyright (c) 2003-2013 QLogic Corporation
  4. *
  5. * See LICENSE.qla2xxx for copyright and licensing details.
  6. */
  7. #ifndef __QLA_MR_H
  8. #define __QLA_MR_H
  9. /*
  10. * The PCI VendorID and DeviceID for our board.
  11. */
  12. #define PCI_DEVICE_ID_QLOGIC_ISPF001 0xF001
  13. /* FX00 specific definitions */
  14. #define FX00_COMMAND_TYPE_7 0x07 /* Command Type 7 entry for 7XXX */
  15. struct cmd_type_7_fx00 {
  16. uint8_t entry_type; /* Entry type. */
  17. uint8_t entry_count; /* Entry count. */
  18. uint8_t sys_define; /* System defined. */
  19. uint8_t entry_status; /* Entry Status. */
  20. uint32_t handle; /* System handle. */
  21. uint32_t handle_hi;
  22. __le16 tgt_idx; /* Target Idx. */
  23. uint16_t timeout; /* Command timeout. */
  24. __le16 dseg_count; /* Data segment count. */
  25. uint16_t scsi_rsp_dsd_len;
  26. struct scsi_lun lun; /* LUN (LE). */
  27. uint8_t cntrl_flags;
  28. uint8_t task_mgmt_flags; /* Task management flags. */
  29. uint8_t task;
  30. uint8_t crn;
  31. uint8_t fcp_cdb[MAX_CMDSZ]; /* SCSI command words. */
  32. __le32 byte_count; /* Total byte count. */
  33. uint32_t dseg_0_address[2]; /* Data segment 0 address. */
  34. uint32_t dseg_0_len; /* Data segment 0 length. */
  35. };
  36. /*
  37. * ISP queue - marker entry structure definition.
  38. */
  39. struct mrk_entry_fx00 {
  40. uint8_t entry_type; /* Entry type. */
  41. uint8_t entry_count; /* Entry count. */
  42. uint8_t handle_count; /* Handle count. */
  43. uint8_t entry_status; /* Entry Status. */
  44. uint32_t handle; /* System handle. */
  45. uint32_t handle_hi; /* System handle. */
  46. uint16_t tgt_id; /* Target ID. */
  47. uint8_t modifier; /* Modifier (7-0). */
  48. uint8_t reserved_1;
  49. uint8_t reserved_2[5];
  50. uint8_t lun[8]; /* FCP LUN (BE). */
  51. uint8_t reserved_3[36];
  52. };
  53. #define STATUS_TYPE_FX00 0x01 /* Status entry. */
  54. struct sts_entry_fx00 {
  55. uint8_t entry_type; /* Entry type. */
  56. uint8_t entry_count; /* Entry count. */
  57. uint8_t sys_define; /* System defined. */
  58. uint8_t entry_status; /* Entry Status. */
  59. uint32_t handle; /* System handle. */
  60. uint32_t handle_hi; /* System handle. */
  61. __le16 comp_status; /* Completion status. */
  62. uint16_t reserved_0; /* OX_ID used by the firmware. */
  63. __le32 residual_len; /* FW calc residual transfer length. */
  64. uint16_t reserved_1;
  65. uint16_t state_flags; /* State flags. */
  66. uint16_t reserved_2;
  67. __le16 scsi_status; /* SCSI status. */
  68. uint32_t sense_len; /* FCP SENSE length. */
  69. uint8_t data[32]; /* FCP response/sense information. */
  70. };
  71. #define MAX_HANDLE_COUNT 15
  72. #define MULTI_STATUS_TYPE_FX00 0x0D
  73. struct multi_sts_entry_fx00 {
  74. uint8_t entry_type; /* Entry type. */
  75. uint8_t sys_define; /* System defined. */
  76. uint8_t handle_count;
  77. uint8_t entry_status;
  78. __le32 handles[MAX_HANDLE_COUNT];
  79. };
  80. #define TSK_MGMT_IOCB_TYPE_FX00 0x05
  81. struct tsk_mgmt_entry_fx00 {
  82. uint8_t entry_type; /* Entry type. */
  83. uint8_t entry_count; /* Entry count. */
  84. uint8_t sys_define;
  85. uint8_t entry_status; /* Entry Status. */
  86. __le32 handle; /* System handle. */
  87. uint32_t handle_hi; /* System handle. */
  88. __le16 tgt_id; /* Target Idx. */
  89. uint16_t reserved_1;
  90. uint16_t delay; /* Activity delay in seconds. */
  91. __le16 timeout; /* Command timeout. */
  92. struct scsi_lun lun; /* LUN (LE). */
  93. __le32 control_flags; /* Control Flags. */
  94. uint8_t reserved_2[32];
  95. };
  96. #define ABORT_IOCB_TYPE_FX00 0x08 /* Abort IOCB status. */
  97. struct abort_iocb_entry_fx00 {
  98. uint8_t entry_type; /* Entry type. */
  99. uint8_t entry_count; /* Entry count. */
  100. uint8_t sys_define; /* System defined. */
  101. uint8_t entry_status; /* Entry Status. */
  102. __le32 handle; /* System handle. */
  103. __le32 handle_hi; /* System handle. */
  104. __le16 tgt_id_sts; /* Completion status. */
  105. __le16 options;
  106. __le32 abort_handle; /* System handle. */
  107. __le32 abort_handle_hi; /* System handle. */
  108. __le16 req_que_no;
  109. uint8_t reserved_1[38];
  110. };
  111. #define IOCTL_IOSB_TYPE_FX00 0x0C
  112. struct ioctl_iocb_entry_fx00 {
  113. uint8_t entry_type; /* Entry type. */
  114. uint8_t entry_count; /* Entry count. */
  115. uint8_t sys_define; /* System defined. */
  116. uint8_t entry_status; /* Entry Status. */
  117. uint32_t handle; /* System handle. */
  118. uint32_t reserved_0; /* System handle. */
  119. uint16_t comp_func_num;
  120. __le16 fw_iotcl_flags;
  121. __le32 dataword_r; /* Data word returned */
  122. uint32_t adapid; /* Adapter ID */
  123. uint32_t adapid_hi; /* Adapter ID high */
  124. uint32_t reserved_1;
  125. __le32 seq_no;
  126. uint8_t reserved_2[20];
  127. uint32_t residuallen;
  128. __le32 status;
  129. };
  130. #define STATUS_CONT_TYPE_FX00 0x04
  131. #define FX00_IOCB_TYPE 0x0B
  132. struct fxdisc_entry_fx00 {
  133. uint8_t entry_type; /* Entry type. */
  134. uint8_t entry_count; /* Entry count. */
  135. uint8_t sys_define; /* System Defined. */
  136. uint8_t entry_status; /* Entry Status. */
  137. __le32 handle; /* System handle. */
  138. __le32 reserved_0; /* System handle. */
  139. __le16 func_num;
  140. __le16 req_xfrcnt;
  141. __le16 req_dsdcnt;
  142. __le16 rsp_xfrcnt;
  143. __le16 rsp_dsdcnt;
  144. uint8_t flags;
  145. uint8_t reserved_1;
  146. __le32 dseg_rq_address[2]; /* Data segment 0 address. */
  147. __le32 dseg_rq_len; /* Data segment 0 length. */
  148. __le32 dseg_rsp_address[2]; /* Data segment 1 address. */
  149. __le32 dseg_rsp_len; /* Data segment 1 length. */
  150. __le32 dataword;
  151. __le32 adapid;
  152. __le32 adapid_hi;
  153. __le32 dataword_extra;
  154. };
  155. struct qlafx00_tgt_node_info {
  156. uint8_t tgt_node_wwpn[WWN_SIZE];
  157. uint8_t tgt_node_wwnn[WWN_SIZE];
  158. uint32_t tgt_node_state;
  159. uint8_t reserved[128];
  160. uint32_t reserved_1[8];
  161. uint64_t reserved_2[4];
  162. } __packed;
  163. #define QLAFX00_TGT_NODE_INFO sizeof(struct qlafx00_tgt_node_info)
  164. #define QLAFX00_LINK_STATUS_DOWN 0x10
  165. #define QLAFX00_LINK_STATUS_UP 0x11
  166. #define QLAFX00_PORT_SPEED_2G 0x2
  167. #define QLAFX00_PORT_SPEED_4G 0x4
  168. #define QLAFX00_PORT_SPEED_8G 0x8
  169. #define QLAFX00_PORT_SPEED_10G 0xa
  170. struct port_info_data {
  171. uint8_t port_state;
  172. uint8_t port_type;
  173. uint16_t port_identifier;
  174. uint32_t up_port_state;
  175. uint8_t fw_ver_num[32];
  176. uint8_t portal_attrib;
  177. uint16_t host_option;
  178. uint8_t reset_delay;
  179. uint8_t pdwn_retry_cnt;
  180. uint16_t max_luns2tgt;
  181. uint8_t risc_ver;
  182. uint8_t pconn_option;
  183. uint16_t risc_option;
  184. uint16_t max_frame_len;
  185. uint16_t max_iocb_alloc;
  186. uint16_t exec_throttle;
  187. uint8_t retry_cnt;
  188. uint8_t retry_delay;
  189. uint8_t port_name[8];
  190. uint8_t port_id[3];
  191. uint8_t link_status;
  192. uint8_t plink_rate;
  193. uint32_t link_config;
  194. uint16_t adap_haddr;
  195. uint8_t tgt_disc;
  196. uint8_t log_tout;
  197. uint8_t node_name[8];
  198. uint16_t erisc_opt1;
  199. uint8_t resp_acc_tmr;
  200. uint8_t intr_del_tmr;
  201. uint8_t erisc_opt2;
  202. uint8_t alt_port_name[8];
  203. uint8_t alt_node_name[8];
  204. uint8_t link_down_tout;
  205. uint8_t conn_type;
  206. uint8_t fc_fw_mode;
  207. uint32_t uiReserved[48];
  208. } __packed;
  209. /* OS Type Designations */
  210. #define OS_TYPE_UNKNOWN 0
  211. #define OS_TYPE_LINUX 2
  212. /* Linux Info */
  213. #define SYSNAME_LENGTH 128
  214. #define NODENAME_LENGTH 64
  215. #define RELEASE_LENGTH 64
  216. #define VERSION_LENGTH 64
  217. #define MACHINE_LENGTH 64
  218. #define DOMNAME_LENGTH 64
  219. struct host_system_info {
  220. uint32_t os_type;
  221. char sysname[SYSNAME_LENGTH];
  222. char nodename[NODENAME_LENGTH];
  223. char release[RELEASE_LENGTH];
  224. char version[VERSION_LENGTH];
  225. char machine[MACHINE_LENGTH];
  226. char domainname[DOMNAME_LENGTH];
  227. char hostdriver[VERSION_LENGTH];
  228. uint32_t reserved[64];
  229. } __packed;
  230. struct register_host_info {
  231. struct host_system_info hsi; /* host system info */
  232. uint64_t utc; /* UTC (system time) */
  233. uint32_t reserved[64]; /* future additions */
  234. } __packed;
  235. #define QLAFX00_PORT_DATA_INFO (sizeof(struct port_info_data))
  236. #define QLAFX00_TGT_NODE_LIST_SIZE (sizeof(uint32_t) * 32)
  237. struct config_info_data {
  238. uint8_t product_name[256];
  239. uint8_t symbolic_name[64];
  240. uint8_t serial_num[32];
  241. uint8_t hw_version[16];
  242. uint8_t fw_version[16];
  243. uint8_t uboot_version[16];
  244. uint8_t fru_serial_num[32];
  245. uint8_t fc_port_count;
  246. uint8_t iscsi_port_count;
  247. uint8_t reserved1[2];
  248. uint8_t mode;
  249. uint8_t log_level;
  250. uint8_t reserved2[2];
  251. uint32_t log_size;
  252. uint8_t tgt_pres_mode;
  253. uint8_t iqn_flags;
  254. uint8_t lun_mapping;
  255. uint64_t adapter_id;
  256. uint32_t cluster_key_len;
  257. uint8_t cluster_key[10];
  258. uint64_t cluster_master_id;
  259. uint64_t cluster_slave_id;
  260. uint8_t cluster_flags;
  261. } __packed;
  262. #define FXDISC_GET_CONFIG_INFO 0x01
  263. #define FXDISC_GET_PORT_INFO 0x02
  264. #define FXDISC_GET_TGT_NODE_INFO 0x80
  265. #define FXDISC_GET_TGT_NODE_LIST 0x81
  266. #define FXDISC_REG_HOST_INFO 0x99
  267. #define QLAFX00_HBA_ICNTRL_REG 0x21B08
  268. #define QLAFX00_ICR_ENB_MASK 0x80000000
  269. #define QLAFX00_ICR_DIS_MASK 0x7fffffff
  270. #define QLAFX00_HST_RST_REG 0x18264
  271. #define QLAFX00_HST_TO_HBA_REG 0x20A04
  272. #define QLAFX00_HBA_TO_HOST_REG 0x21B70
  273. #define QLAFX00_HST_INT_STS_BITS 0x7
  274. #define QLAFX00_BAR1_BASE_ADDR_REG 0x40018
  275. #define QLAFX00_PEX0_WIN0_BASE_ADDR_REG 0x41824
  276. #define QLAFX00_INTR_MB_CMPLT 0x1
  277. #define QLAFX00_INTR_RSP_CMPLT 0x2
  278. #define QLAFX00_INTR_MB_RSP_CMPLT 0x3
  279. #define QLAFX00_INTR_ASYNC_CMPLT 0x4
  280. #define QLAFX00_INTR_MB_ASYNC_CMPLT 0x5
  281. #define QLAFX00_INTR_RSP_ASYNC_CMPLT 0x6
  282. #define QLAFX00_INTR_ALL_CMPLT 0x7
  283. #define QLAFX00_MBA_SYSTEM_ERR 0x8002
  284. #define QLAFX00_MBA_LINK_UP 0x8011
  285. #define QLAFX00_MBA_LINK_DOWN 0x8012
  286. #define QLAFX00_MBA_PORT_UPDATE 0x8014
  287. #define QLAFX00_MBA_SHUTDOWN_RQSTD 0x8062
  288. #define SOC_SW_RST_CONTROL_REG_CORE0 0x0020800
  289. #define SOC_FABRIC_RST_CONTROL_REG 0x0020840
  290. #define SOC_FABRIC_CONTROL_REG 0x0020200
  291. #define SOC_FABRIC_CONFIG_REG 0x0020204
  292. #define SOC_INTERRUPT_SOURCE_I_CONTROL_REG 0x0020B00
  293. #define SOC_CORE_TIMER_REG 0x0021850
  294. #define SOC_IRQ_ACK_REG 0x00218b4
  295. #define CONTINUE_A64_TYPE_FX00 0x03 /* Continuation entry. */
  296. #define QLAFX00_SET_HST_INTR(ha, value) \
  297. WRT_REG_DWORD((ha)->cregbase + QLAFX00_HST_TO_HBA_REG, \
  298. value)
  299. #define QLAFX00_CLR_HST_INTR(ha, value) \
  300. WRT_REG_DWORD((ha)->cregbase + QLAFX00_HBA_TO_HOST_REG, \
  301. ~value)
  302. #define QLAFX00_RD_INTR_REG(ha) \
  303. RD_REG_DWORD((ha)->cregbase + QLAFX00_HBA_TO_HOST_REG)
  304. #define QLAFX00_CLR_INTR_REG(ha, value) \
  305. WRT_REG_DWORD((ha)->cregbase + QLAFX00_HBA_TO_HOST_REG, \
  306. ~value)
  307. #define QLAFX00_SET_HBA_SOC_REG(ha, off, val)\
  308. WRT_REG_DWORD((ha)->cregbase + off, val)
  309. #define QLAFX00_GET_HBA_SOC_REG(ha, off)\
  310. RD_REG_DWORD((ha)->cregbase + off)
  311. #define QLAFX00_HBA_RST_REG(ha, val)\
  312. WRT_REG_DWORD((ha)->cregbase + QLAFX00_HST_RST_REG, val)
  313. #define QLAFX00_RD_ICNTRL_REG(ha) \
  314. RD_REG_DWORD((ha)->cregbase + QLAFX00_HBA_ICNTRL_REG)
  315. #define QLAFX00_ENABLE_ICNTRL_REG(ha) \
  316. WRT_REG_DWORD((ha)->cregbase + QLAFX00_HBA_ICNTRL_REG, \
  317. (QLAFX00_GET_HBA_SOC_REG(ha, QLAFX00_HBA_ICNTRL_REG) | \
  318. QLAFX00_ICR_ENB_MASK))
  319. #define QLAFX00_DISABLE_ICNTRL_REG(ha) \
  320. WRT_REG_DWORD((ha)->cregbase + QLAFX00_HBA_ICNTRL_REG, \
  321. (QLAFX00_GET_HBA_SOC_REG(ha, QLAFX00_HBA_ICNTRL_REG) & \
  322. QLAFX00_ICR_DIS_MASK))
  323. #define QLAFX00_RD_REG(ha, off) \
  324. RD_REG_DWORD((ha)->cregbase + off)
  325. #define QLAFX00_WR_REG(ha, off, val) \
  326. WRT_REG_DWORD((ha)->cregbase + off, val)
  327. struct qla_mt_iocb_rqst_fx00 {
  328. __le32 reserved_0;
  329. __le16 func_type;
  330. uint8_t flags;
  331. uint8_t reserved_1;
  332. __le32 dataword;
  333. __le32 adapid;
  334. __le32 adapid_hi;
  335. __le32 dataword_extra;
  336. __le32 req_len;
  337. __le32 rsp_len;
  338. };
  339. struct qla_mt_iocb_rsp_fx00 {
  340. uint32_t reserved_1;
  341. uint16_t func_type;
  342. __le16 ioctl_flags;
  343. __le32 ioctl_data;
  344. uint32_t adapid;
  345. uint32_t adapid_hi;
  346. uint32_t reserved_2;
  347. __le32 seq_number;
  348. uint8_t reserved_3[20];
  349. int32_t res_count;
  350. __le32 status;
  351. };
  352. #define MAILBOX_REGISTER_COUNT_FX00 16
  353. #define AEN_MAILBOX_REGISTER_COUNT_FX00 8
  354. #define MAX_FIBRE_DEVICES_FX00 512
  355. #define MAX_LUNS_FX00 0x1024
  356. #define MAX_TARGETS_FX00 MAX_ISA_DEVICES
  357. #define REQUEST_ENTRY_CNT_FX00 512 /* Number of request entries. */
  358. #define RESPONSE_ENTRY_CNT_FX00 256 /* Number of response entries.*/
  359. /*
  360. * Firmware state codes for QLAFX00 adapters
  361. */
  362. #define FSTATE_FX00_CONFIG_WAIT 0x0000 /* Waiting for driver to issue
  363. * Initialize FW Mbox cmd
  364. */
  365. #define FSTATE_FX00_INITIALIZED 0x1000 /* FW has been initialized by
  366. * the driver
  367. */
  368. #define FX00_DEF_RATOV 10
  369. struct mr_data_fx00 {
  370. uint8_t product_name[256];
  371. uint8_t symbolic_name[64];
  372. uint8_t serial_num[32];
  373. uint8_t hw_version[16];
  374. uint8_t fw_version[16];
  375. uint8_t uboot_version[16];
  376. uint8_t fru_serial_num[32];
  377. fc_port_t fcport; /* fcport used for requests
  378. * that are not linked
  379. * to a particular target
  380. */
  381. uint8_t fw_hbt_en;
  382. uint8_t fw_hbt_cnt;
  383. uint8_t fw_hbt_miss_cnt;
  384. uint32_t old_fw_hbt_cnt;
  385. uint16_t fw_reset_timer_tick;
  386. uint8_t fw_reset_timer_exp;
  387. uint32_t old_aenmbx0_state;
  388. };
  389. #define QLAFX00_LOOP_DOWN_TIME 615 /* 600 */
  390. #define QLAFX00_HEARTBEAT_INTERVAL 6 /* number of seconds */
  391. #define QLAFX00_HEARTBEAT_MISS_CNT 3 /* number of miss */
  392. #define QLAFX00_RESET_INTERVAL 120 /* number of seconds */
  393. #define QLAFX00_MAX_RESET_INTERVAL 600 /* number of seconds */
  394. #endif