qla_mr.h 14 KB

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