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