ql4_def.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. /*
  2. * QLogic iSCSI HBA Driver
  3. * Copyright (c) 2003-2006 QLogic Corporation
  4. *
  5. * See LICENSE.qla4xxx for copyright and licensing details.
  6. */
  7. #ifndef __QL4_DEF_H
  8. #define __QL4_DEF_H
  9. #include <linux/kernel.h>
  10. #include <linux/init.h>
  11. #include <linux/types.h>
  12. #include <linux/module.h>
  13. #include <linux/list.h>
  14. #include <linux/pci.h>
  15. #include <linux/dma-mapping.h>
  16. #include <linux/sched.h>
  17. #include <linux/slab.h>
  18. #include <linux/dmapool.h>
  19. #include <linux/mempool.h>
  20. #include <linux/spinlock.h>
  21. #include <linux/workqueue.h>
  22. #include <linux/delay.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/mutex.h>
  25. #include <net/tcp.h>
  26. #include <scsi/scsi.h>
  27. #include <scsi/scsi_host.h>
  28. #include <scsi/scsi_device.h>
  29. #include <scsi/scsi_cmnd.h>
  30. #include <scsi/scsi_transport.h>
  31. #include <scsi/scsi_transport_iscsi.h>
  32. #ifndef PCI_DEVICE_ID_QLOGIC_ISP4010
  33. #define PCI_DEVICE_ID_QLOGIC_ISP4010 0x4010
  34. #endif
  35. #ifndef PCI_DEVICE_ID_QLOGIC_ISP4022
  36. #define PCI_DEVICE_ID_QLOGIC_ISP4022 0x4022
  37. #endif
  38. #ifndef PCI_DEVICE_ID_QLOGIC_ISP4032
  39. #define PCI_DEVICE_ID_QLOGIC_ISP4032 0x4032
  40. #endif
  41. #define QLA_SUCCESS 0
  42. #define QLA_ERROR 1
  43. /*
  44. * Data bit definitions
  45. */
  46. #define BIT_0 0x1
  47. #define BIT_1 0x2
  48. #define BIT_2 0x4
  49. #define BIT_3 0x8
  50. #define BIT_4 0x10
  51. #define BIT_5 0x20
  52. #define BIT_6 0x40
  53. #define BIT_7 0x80
  54. #define BIT_8 0x100
  55. #define BIT_9 0x200
  56. #define BIT_10 0x400
  57. #define BIT_11 0x800
  58. #define BIT_12 0x1000
  59. #define BIT_13 0x2000
  60. #define BIT_14 0x4000
  61. #define BIT_15 0x8000
  62. #define BIT_16 0x10000
  63. #define BIT_17 0x20000
  64. #define BIT_18 0x40000
  65. #define BIT_19 0x80000
  66. #define BIT_20 0x100000
  67. #define BIT_21 0x200000
  68. #define BIT_22 0x400000
  69. #define BIT_23 0x800000
  70. #define BIT_24 0x1000000
  71. #define BIT_25 0x2000000
  72. #define BIT_26 0x4000000
  73. #define BIT_27 0x8000000
  74. #define BIT_28 0x10000000
  75. #define BIT_29 0x20000000
  76. #define BIT_30 0x40000000
  77. #define BIT_31 0x80000000
  78. /*
  79. * Host adapter default definitions
  80. ***********************************/
  81. #define MAX_HBAS 16
  82. #define MAX_BUSES 1
  83. #define MAX_TARGETS (MAX_PRST_DEV_DB_ENTRIES + MAX_DEV_DB_ENTRIES)
  84. #define MAX_LUNS 0xffff
  85. #define MAX_AEN_ENTRIES 256 /* should be > EXT_DEF_MAX_AEN_QUEUE */
  86. #define MAX_DDB_ENTRIES (MAX_PRST_DEV_DB_ENTRIES + MAX_DEV_DB_ENTRIES)
  87. #define MAX_PDU_ENTRIES 32
  88. #define INVALID_ENTRY 0xFFFF
  89. #define MAX_CMDS_TO_RISC 1024
  90. #define MAX_SRBS MAX_CMDS_TO_RISC
  91. #define MBOX_AEN_REG_COUNT 5
  92. #define MAX_INIT_RETRIES 5
  93. /*
  94. * Buffer sizes
  95. */
  96. #define REQUEST_QUEUE_DEPTH MAX_CMDS_TO_RISC
  97. #define RESPONSE_QUEUE_DEPTH 64
  98. #define QUEUE_SIZE 64
  99. #define DMA_BUFFER_SIZE 512
  100. /*
  101. * Misc
  102. */
  103. #define MAC_ADDR_LEN 6 /* in bytes */
  104. #define IP_ADDR_LEN 4 /* in bytes */
  105. #define IPv6_ADDR_LEN 16 /* IPv6 address size */
  106. #define DRIVER_NAME "qla4xxx"
  107. #define MAX_LINKED_CMDS_PER_LUN 3
  108. #define MAX_REQS_SERVICED_PER_INTR 16
  109. #define ISCSI_IPADDR_SIZE 4 /* IP address size */
  110. #define ISCSI_ALIAS_SIZE 32 /* ISCSI Alias name size */
  111. #define ISCSI_NAME_SIZE 0xE0 /* ISCSI Name size */
  112. #define LSDW(x) ((u32)((u64)(x)))
  113. #define MSDW(x) ((u32)((((u64)(x)) >> 16) >> 16))
  114. /*
  115. * Retry & Timeout Values
  116. */
  117. #define MBOX_TOV 60
  118. #define SOFT_RESET_TOV 30
  119. #define RESET_INTR_TOV 3
  120. #define SEMAPHORE_TOV 10
  121. #define ADAPTER_INIT_TOV 120
  122. #define ADAPTER_RESET_TOV 180
  123. #define EXTEND_CMD_TOV 60
  124. #define WAIT_CMD_TOV 30
  125. #define EH_WAIT_CMD_TOV 120
  126. #define FIRMWARE_UP_TOV 60
  127. #define RESET_FIRMWARE_TOV 30
  128. #define LOGOUT_TOV 10
  129. #define IOCB_TOV_MARGIN 10
  130. #define RELOGIN_TOV 18
  131. #define ISNS_DEREG_TOV 5
  132. #define MAX_RESET_HA_RETRIES 2
  133. #define CMD_SP(Cmnd) ((Cmnd)->SCp.ptr)
  134. /*
  135. * SCSI Request Block structure (srb) that is placed
  136. * on cmd->SCp location of every I/O [We have 22 bytes available]
  137. */
  138. struct srb {
  139. struct list_head list; /* (8) */
  140. struct scsi_qla_host *ha; /* HA the SP is queued on */
  141. struct ddb_entry *ddb;
  142. uint16_t flags; /* (1) Status flags. */
  143. #define SRB_DMA_VALID BIT_3 /* DMA Buffer mapped. */
  144. #define SRB_GOT_SENSE BIT_4 /* sense data recieved. */
  145. uint8_t state; /* (1) Status flags. */
  146. #define SRB_NO_QUEUE_STATE 0 /* Request is in between states */
  147. #define SRB_FREE_STATE 1
  148. #define SRB_ACTIVE_STATE 3
  149. #define SRB_ACTIVE_TIMEOUT_STATE 4
  150. #define SRB_SUSPENDED_STATE 7 /* Request in suspended state */
  151. struct scsi_cmnd *cmd; /* (4) SCSI command block */
  152. dma_addr_t dma_handle; /* (4) for unmap of single transfers */
  153. struct kref srb_ref; /* reference count for this srb */
  154. uint32_t fw_ddb_index;
  155. uint8_t err_id; /* error id */
  156. #define SRB_ERR_PORT 1 /* Request failed because "port down" */
  157. #define SRB_ERR_LOOP 2 /* Request failed because "loop down" */
  158. #define SRB_ERR_DEVICE 3 /* Request failed because "device error" */
  159. #define SRB_ERR_OTHER 4
  160. uint16_t reserved;
  161. uint16_t iocb_tov;
  162. uint16_t iocb_cnt; /* Number of used iocbs */
  163. uint16_t cc_stat;
  164. u_long r_start; /* Time we recieve a cmd from OS */
  165. u_long u_start; /* Time when we handed the cmd to F/W */
  166. /* Used for extended sense / status continuation */
  167. uint8_t *req_sense_ptr;
  168. uint16_t req_sense_len;
  169. uint16_t reserved2;
  170. };
  171. /*
  172. * Asynchronous Event Queue structure
  173. */
  174. struct aen {
  175. uint32_t mbox_sts[MBOX_AEN_REG_COUNT];
  176. };
  177. struct ql4_aen_log {
  178. int count;
  179. struct aen entry[MAX_AEN_ENTRIES];
  180. };
  181. /*
  182. * Device Database (DDB) structure
  183. */
  184. struct ddb_entry {
  185. struct list_head list; /* ddb list */
  186. struct scsi_qla_host *ha;
  187. struct iscsi_cls_session *sess;
  188. struct iscsi_cls_conn *conn;
  189. atomic_t state; /* DDB State */
  190. unsigned long flags; /* DDB Flags */
  191. unsigned long dev_scan_wait_to_start_relogin;
  192. unsigned long dev_scan_wait_to_complete_relogin;
  193. uint16_t os_target_id; /* Target ID */
  194. uint16_t fw_ddb_index; /* DDB firmware index */
  195. uint16_t options;
  196. uint32_t fw_ddb_device_state; /* F/W Device State -- see ql4_fw.h */
  197. uint32_t CmdSn;
  198. uint16_t target_session_id;
  199. uint16_t connection_id;
  200. uint16_t exe_throttle; /* Max mumber of cmds outstanding
  201. * simultaneously */
  202. uint16_t task_mgmt_timeout; /* Min time for task mgmt cmds to
  203. * complete */
  204. uint16_t default_relogin_timeout; /* Max time to wait for
  205. * relogin to complete */
  206. uint16_t tcp_source_port_num;
  207. uint32_t default_time2wait; /* Default Min time between
  208. * relogins (+aens) */
  209. atomic_t port_down_timer; /* Device connection timer */
  210. atomic_t retry_relogin_timer; /* Min Time between relogins
  211. * (4000 only) */
  212. atomic_t relogin_timer; /* Max Time to wait for relogin to complete */
  213. atomic_t relogin_retry_count; /* Num of times relogin has been
  214. * retried */
  215. uint16_t port;
  216. uint32_t tpgt;
  217. uint8_t ip_addr[IP_ADDR_LEN];
  218. uint8_t iscsi_name[ISCSI_NAME_SIZE]; /* 72 x48 */
  219. uint8_t iscsi_alias[0x20];
  220. uint8_t isid[6];
  221. uint16_t iscsi_max_burst_len;
  222. uint16_t iscsi_max_outsnd_r2t;
  223. uint16_t iscsi_first_burst_len;
  224. uint16_t iscsi_max_rcv_data_seg_len;
  225. uint16_t iscsi_max_snd_data_seg_len;
  226. struct in6_addr remote_ipv6_addr;
  227. struct in6_addr link_local_ipv6_addr;
  228. };
  229. /*
  230. * DDB states.
  231. */
  232. #define DDB_STATE_DEAD 0 /* We can no longer talk to
  233. * this device */
  234. #define DDB_STATE_ONLINE 1 /* Device ready to accept
  235. * commands */
  236. #define DDB_STATE_MISSING 2 /* Device logged off, trying
  237. * to re-login */
  238. /*
  239. * DDB flags.
  240. */
  241. #define DF_RELOGIN 0 /* Relogin to device */
  242. #define DF_NO_RELOGIN 1 /* Do not relogin if IOCTL
  243. * logged it out */
  244. #define DF_ISNS_DISCOVERED 2 /* Device was discovered via iSNS */
  245. #define DF_FO_MASKED 3
  246. #include "ql4_fw.h"
  247. #include "ql4_nvram.h"
  248. /*
  249. * Linux Host Adapter structure
  250. */
  251. struct scsi_qla_host {
  252. /* Linux adapter configuration data */
  253. unsigned long flags;
  254. #define AF_ONLINE 0 /* 0x00000001 */
  255. #define AF_INIT_DONE 1 /* 0x00000002 */
  256. #define AF_MBOX_COMMAND 2 /* 0x00000004 */
  257. #define AF_MBOX_COMMAND_DONE 3 /* 0x00000008 */
  258. #define AF_INTERRUPTS_ON 6 /* 0x00000040 */
  259. #define AF_GET_CRASH_RECORD 7 /* 0x00000080 */
  260. #define AF_LINK_UP 8 /* 0x00000100 */
  261. #define AF_IRQ_ATTACHED 10 /* 0x00000400 */
  262. #define AF_DISABLE_ACB_COMPLETE 11 /* 0x00000800 */
  263. unsigned long dpc_flags;
  264. #define DPC_RESET_HA 1 /* 0x00000002 */
  265. #define DPC_RETRY_RESET_HA 2 /* 0x00000004 */
  266. #define DPC_RELOGIN_DEVICE 3 /* 0x00000008 */
  267. #define DPC_RESET_HA_DESTROY_DDB_LIST 4 /* 0x00000010 */
  268. #define DPC_RESET_HA_INTR 5 /* 0x00000020 */
  269. #define DPC_ISNS_RESTART 7 /* 0x00000080 */
  270. #define DPC_AEN 9 /* 0x00000200 */
  271. #define DPC_GET_DHCP_IP_ADDR 15 /* 0x00008000 */
  272. #define DPC_LINK_CHANGED 18 /* 0x00040000 */
  273. struct Scsi_Host *host; /* pointer to host data */
  274. uint32_t tot_ddbs;
  275. uint16_t iocb_cnt;
  276. /* SRB cache. */
  277. #define SRB_MIN_REQ 128
  278. mempool_t *srb_mempool;
  279. /* pci information */
  280. struct pci_dev *pdev;
  281. struct isp_reg __iomem *reg; /* Base I/O address */
  282. unsigned long pio_address;
  283. unsigned long pio_length;
  284. #define MIN_IOBASE_LEN 0x100
  285. uint16_t req_q_count;
  286. uint8_t rsvd1[2];
  287. unsigned long host_no;
  288. /* NVRAM registers */
  289. struct eeprom_data *nvram;
  290. spinlock_t hardware_lock ____cacheline_aligned;
  291. uint32_t eeprom_cmd_data;
  292. /* Counters for general statistics */
  293. uint64_t isr_count;
  294. uint64_t adapter_error_count;
  295. uint64_t device_error_count;
  296. uint64_t total_io_count;
  297. uint64_t total_mbytes_xferred;
  298. uint64_t link_failure_count;
  299. uint64_t invalid_crc_count;
  300. uint32_t bytes_xfered;
  301. uint32_t spurious_int_count;
  302. uint32_t aborted_io_count;
  303. uint32_t io_timeout_count;
  304. uint32_t mailbox_timeout_count;
  305. uint32_t seconds_since_last_intr;
  306. uint32_t seconds_since_last_heartbeat;
  307. uint32_t mac_index;
  308. /* Info Needed for Management App */
  309. /* --- From GetFwVersion --- */
  310. uint32_t firmware_version[2];
  311. uint32_t patch_number;
  312. uint32_t build_number;
  313. uint32_t board_id;
  314. /* --- From Init_FW --- */
  315. /* init_cb_t *init_cb; */
  316. uint16_t firmware_options;
  317. uint16_t tcp_options;
  318. uint8_t ip_address[IP_ADDR_LEN];
  319. uint8_t subnet_mask[IP_ADDR_LEN];
  320. uint8_t gateway[IP_ADDR_LEN];
  321. uint8_t alias[32];
  322. uint8_t name_string[256];
  323. uint8_t heartbeat_interval;
  324. uint8_t rsvd;
  325. /* --- From FlashSysInfo --- */
  326. uint8_t my_mac[MAC_ADDR_LEN];
  327. uint8_t serial_number[16];
  328. /* --- From GetFwState --- */
  329. uint32_t firmware_state;
  330. uint32_t addl_fw_state;
  331. /* Linux kernel thread */
  332. struct workqueue_struct *dpc_thread;
  333. struct work_struct dpc_work;
  334. /* Linux timer thread */
  335. struct timer_list timer;
  336. uint32_t timer_active;
  337. /* Recovery Timers */
  338. uint32_t port_down_retry_count;
  339. uint32_t discovery_wait;
  340. atomic_t check_relogin_timeouts;
  341. uint32_t retry_reset_ha_cnt;
  342. uint32_t isp_reset_timer; /* reset test timer */
  343. uint32_t nic_reset_timer; /* simulated nic reset test timer */
  344. int eh_start;
  345. struct list_head free_srb_q;
  346. uint16_t free_srb_q_count;
  347. uint16_t num_srbs_allocated;
  348. /* DMA Memory Block */
  349. void *queues;
  350. dma_addr_t queues_dma;
  351. unsigned long queues_len;
  352. #define MEM_ALIGN_VALUE \
  353. ((max(REQUEST_QUEUE_DEPTH, RESPONSE_QUEUE_DEPTH)) * \
  354. sizeof(struct queue_entry))
  355. /* request and response queue variables */
  356. dma_addr_t request_dma;
  357. struct queue_entry *request_ring;
  358. struct queue_entry *request_ptr;
  359. dma_addr_t response_dma;
  360. struct queue_entry *response_ring;
  361. struct queue_entry *response_ptr;
  362. dma_addr_t shadow_regs_dma;
  363. struct shadow_regs *shadow_regs;
  364. uint16_t request_in; /* Current indexes. */
  365. uint16_t request_out;
  366. uint16_t response_in;
  367. uint16_t response_out;
  368. /* aen queue variables */
  369. uint16_t aen_q_count; /* Number of available aen_q entries */
  370. uint16_t aen_in; /* Current indexes */
  371. uint16_t aen_out;
  372. struct aen aen_q[MAX_AEN_ENTRIES];
  373. struct ql4_aen_log aen_log;/* tracks all aens */
  374. /* This mutex protects several threads to do mailbox commands
  375. * concurrently.
  376. */
  377. struct mutex mbox_sem;
  378. /* temporary mailbox status registers */
  379. volatile uint8_t mbox_status_count;
  380. volatile uint32_t mbox_status[MBOX_REG_COUNT];
  381. /* local device database list (contains internal ddb entries) */
  382. struct list_head ddb_list;
  383. /* Map ddb_list entry by FW ddb index */
  384. struct ddb_entry *fw_ddb_index_map[MAX_DDB_ENTRIES];
  385. /* Saved srb for status continuation entry processing */
  386. struct srb *status_srb;
  387. /* IPv6 support info from InitFW */
  388. uint8_t acb_version;
  389. uint8_t ipv4_addr_state;
  390. uint16_t ipv4_options;
  391. uint32_t resvd2;
  392. uint32_t ipv6_options;
  393. uint32_t ipv6_addl_options;
  394. uint8_t ipv6_link_local_state;
  395. uint8_t ipv6_addr0_state;
  396. uint8_t ipv6_addr1_state;
  397. uint8_t ipv6_default_router_state;
  398. struct in6_addr ipv6_link_local_addr;
  399. struct in6_addr ipv6_addr0;
  400. struct in6_addr ipv6_addr1;
  401. struct in6_addr ipv6_default_router_addr;
  402. };
  403. static inline int is_ipv4_enabled(struct scsi_qla_host *ha)
  404. {
  405. return ((ha->ipv4_options & IPOPT_IPv4_PROTOCOL_ENABLE) != 0);
  406. }
  407. static inline int is_ipv6_enabled(struct scsi_qla_host *ha)
  408. {
  409. return ((ha->ipv6_options & IPV6_OPT_IPV6_PROTOCOL_ENABLE) != 0);
  410. }
  411. static inline int is_qla4010(struct scsi_qla_host *ha)
  412. {
  413. return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4010;
  414. }
  415. static inline int is_qla4022(struct scsi_qla_host *ha)
  416. {
  417. return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4022;
  418. }
  419. static inline int is_qla4032(struct scsi_qla_host *ha)
  420. {
  421. return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4032;
  422. }
  423. static inline int adapter_up(struct scsi_qla_host *ha)
  424. {
  425. return (test_bit(AF_ONLINE, &ha->flags) != 0) &&
  426. (test_bit(AF_LINK_UP, &ha->flags) != 0);
  427. }
  428. static inline struct scsi_qla_host* to_qla_host(struct Scsi_Host *shost)
  429. {
  430. return (struct scsi_qla_host *)shost->hostdata;
  431. }
  432. static inline void __iomem* isp_semaphore(struct scsi_qla_host *ha)
  433. {
  434. return (is_qla4010(ha) ?
  435. &ha->reg->u1.isp4010.nvram :
  436. &ha->reg->u1.isp4022.semaphore);
  437. }
  438. static inline void __iomem* isp_nvram(struct scsi_qla_host *ha)
  439. {
  440. return (is_qla4010(ha) ?
  441. &ha->reg->u1.isp4010.nvram :
  442. &ha->reg->u1.isp4022.nvram);
  443. }
  444. static inline void __iomem* isp_ext_hw_conf(struct scsi_qla_host *ha)
  445. {
  446. return (is_qla4010(ha) ?
  447. &ha->reg->u2.isp4010.ext_hw_conf :
  448. &ha->reg->u2.isp4022.p0.ext_hw_conf);
  449. }
  450. static inline void __iomem* isp_port_status(struct scsi_qla_host *ha)
  451. {
  452. return (is_qla4010(ha) ?
  453. &ha->reg->u2.isp4010.port_status :
  454. &ha->reg->u2.isp4022.p0.port_status);
  455. }
  456. static inline void __iomem* isp_port_ctrl(struct scsi_qla_host *ha)
  457. {
  458. return (is_qla4010(ha) ?
  459. &ha->reg->u2.isp4010.port_ctrl :
  460. &ha->reg->u2.isp4022.p0.port_ctrl);
  461. }
  462. static inline void __iomem* isp_port_error_status(struct scsi_qla_host *ha)
  463. {
  464. return (is_qla4010(ha) ?
  465. &ha->reg->u2.isp4010.port_err_status :
  466. &ha->reg->u2.isp4022.p0.port_err_status);
  467. }
  468. static inline void __iomem * isp_gp_out(struct scsi_qla_host *ha)
  469. {
  470. return (is_qla4010(ha) ?
  471. &ha->reg->u2.isp4010.gp_out :
  472. &ha->reg->u2.isp4022.p0.gp_out);
  473. }
  474. static inline int eeprom_ext_hw_conf_offset(struct scsi_qla_host *ha)
  475. {
  476. return (is_qla4010(ha) ?
  477. offsetof(struct eeprom_data, isp4010.ext_hw_conf) / 2 :
  478. offsetof(struct eeprom_data, isp4022.ext_hw_conf) / 2);
  479. }
  480. int ql4xxx_sem_spinlock(struct scsi_qla_host * ha, u32 sem_mask, u32 sem_bits);
  481. void ql4xxx_sem_unlock(struct scsi_qla_host * ha, u32 sem_mask);
  482. int ql4xxx_sem_lock(struct scsi_qla_host * ha, u32 sem_mask, u32 sem_bits);
  483. static inline int ql4xxx_lock_flash(struct scsi_qla_host *a)
  484. {
  485. if (is_qla4010(a))
  486. return ql4xxx_sem_spinlock(a, QL4010_FLASH_SEM_MASK,
  487. QL4010_FLASH_SEM_BITS);
  488. else
  489. return ql4xxx_sem_spinlock(a, QL4022_FLASH_SEM_MASK,
  490. (QL4022_RESOURCE_BITS_BASE_CODE |
  491. (a->mac_index)) << 13);
  492. }
  493. static inline void ql4xxx_unlock_flash(struct scsi_qla_host *a)
  494. {
  495. if (is_qla4010(a))
  496. ql4xxx_sem_unlock(a, QL4010_FLASH_SEM_MASK);
  497. else
  498. ql4xxx_sem_unlock(a, QL4022_FLASH_SEM_MASK);
  499. }
  500. static inline int ql4xxx_lock_nvram(struct scsi_qla_host *a)
  501. {
  502. if (is_qla4010(a))
  503. return ql4xxx_sem_spinlock(a, QL4010_NVRAM_SEM_MASK,
  504. QL4010_NVRAM_SEM_BITS);
  505. else
  506. return ql4xxx_sem_spinlock(a, QL4022_NVRAM_SEM_MASK,
  507. (QL4022_RESOURCE_BITS_BASE_CODE |
  508. (a->mac_index)) << 10);
  509. }
  510. static inline void ql4xxx_unlock_nvram(struct scsi_qla_host *a)
  511. {
  512. if (is_qla4010(a))
  513. ql4xxx_sem_unlock(a, QL4010_NVRAM_SEM_MASK);
  514. else
  515. ql4xxx_sem_unlock(a, QL4022_NVRAM_SEM_MASK);
  516. }
  517. static inline int ql4xxx_lock_drvr(struct scsi_qla_host *a)
  518. {
  519. if (is_qla4010(a))
  520. return ql4xxx_sem_lock(a, QL4010_DRVR_SEM_MASK,
  521. QL4010_DRVR_SEM_BITS);
  522. else
  523. return ql4xxx_sem_lock(a, QL4022_DRVR_SEM_MASK,
  524. (QL4022_RESOURCE_BITS_BASE_CODE |
  525. (a->mac_index)) << 1);
  526. }
  527. static inline void ql4xxx_unlock_drvr(struct scsi_qla_host *a)
  528. {
  529. if (is_qla4010(a))
  530. ql4xxx_sem_unlock(a, QL4010_DRVR_SEM_MASK);
  531. else
  532. ql4xxx_sem_unlock(a, QL4022_DRVR_SEM_MASK);
  533. }
  534. /*---------------------------------------------------------------------------*/
  535. /* Defines for qla4xxx_initialize_adapter() and qla4xxx_recover_adapter() */
  536. #define PRESERVE_DDB_LIST 0
  537. #define REBUILD_DDB_LIST 1
  538. /* Defines for process_aen() */
  539. #define PROCESS_ALL_AENS 0
  540. #define FLUSH_DDB_CHANGED_AENS 1
  541. #define RELOGIN_DDB_CHANGED_AENS 2
  542. #endif /*_QLA4XXX_H */