David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 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 | |
Vikas Chaudhary | f4f5df23 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 36 | #include "ql4_dbg.h" |
| 37 | #include "ql4_nx.h" |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 38 | |
Lalit Chandivade | 2232be0 | 2010-07-30 14:38:47 +0530 | [diff] [blame] | 39 | #if defined(CONFIG_PCIEAER) |
| 40 | #include <linux/aer.h> |
| 41 | #else |
| 42 | /* AER releated */ |
| 43 | static inline int pci_enable_pcie_error_reporting(struct pci_dev *dev) |
| 44 | { |
| 45 | return -EINVAL; |
| 46 | } |
| 47 | static inline int pci_disable_pcie_error_reporting(struct pci_dev *dev) |
| 48 | { |
| 49 | return -EINVAL; |
| 50 | } |
| 51 | static inline int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev) |
| 52 | { |
| 53 | return -EINVAL; |
| 54 | } |
| 55 | #endif |
| 56 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 57 | #ifndef PCI_DEVICE_ID_QLOGIC_ISP4010 |
| 58 | #define PCI_DEVICE_ID_QLOGIC_ISP4010 0x4010 |
| 59 | #endif |
| 60 | |
| 61 | #ifndef PCI_DEVICE_ID_QLOGIC_ISP4022 |
| 62 | #define PCI_DEVICE_ID_QLOGIC_ISP4022 0x4022 |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 63 | #endif |
| 64 | |
| 65 | #ifndef PCI_DEVICE_ID_QLOGIC_ISP4032 |
| 66 | #define PCI_DEVICE_ID_QLOGIC_ISP4032 0x4032 |
| 67 | #endif |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 68 | |
Vikas Chaudhary | f4f5df23 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 69 | #ifndef PCI_DEVICE_ID_QLOGIC_ISP8022 |
| 70 | #define PCI_DEVICE_ID_QLOGIC_ISP8022 0x8022 |
| 71 | #endif |
| 72 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 73 | #define QLA_SUCCESS 0 |
| 74 | #define QLA_ERROR 1 |
| 75 | |
| 76 | /* |
| 77 | * Data bit definitions |
| 78 | */ |
| 79 | #define BIT_0 0x1 |
| 80 | #define BIT_1 0x2 |
| 81 | #define BIT_2 0x4 |
| 82 | #define BIT_3 0x8 |
| 83 | #define BIT_4 0x10 |
| 84 | #define BIT_5 0x20 |
| 85 | #define BIT_6 0x40 |
| 86 | #define BIT_7 0x80 |
| 87 | #define BIT_8 0x100 |
| 88 | #define BIT_9 0x200 |
| 89 | #define BIT_10 0x400 |
| 90 | #define BIT_11 0x800 |
| 91 | #define BIT_12 0x1000 |
| 92 | #define BIT_13 0x2000 |
| 93 | #define BIT_14 0x4000 |
| 94 | #define BIT_15 0x8000 |
| 95 | #define BIT_16 0x10000 |
| 96 | #define BIT_17 0x20000 |
| 97 | #define BIT_18 0x40000 |
| 98 | #define BIT_19 0x80000 |
| 99 | #define BIT_20 0x100000 |
| 100 | #define BIT_21 0x200000 |
| 101 | #define BIT_22 0x400000 |
| 102 | #define BIT_23 0x800000 |
| 103 | #define BIT_24 0x1000000 |
| 104 | #define BIT_25 0x2000000 |
| 105 | #define BIT_26 0x4000000 |
| 106 | #define BIT_27 0x8000000 |
| 107 | #define BIT_28 0x10000000 |
| 108 | #define BIT_29 0x20000000 |
| 109 | #define BIT_30 0x40000000 |
| 110 | #define BIT_31 0x80000000 |
| 111 | |
Vikas Chaudhary | f4f5df23 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 112 | /** |
| 113 | * Macros to help code, maintain, etc. |
| 114 | **/ |
| 115 | #define ql4_printk(level, ha, format, arg...) \ |
| 116 | dev_printk(level , &((ha)->pdev->dev) , format , ## arg) |
| 117 | |
| 118 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 119 | /* |
| 120 | * Host adapter default definitions |
| 121 | ***********************************/ |
| 122 | #define MAX_HBAS 16 |
| 123 | #define MAX_BUSES 1 |
Vikas Chaudhary | f4f5df23 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 124 | #define MAX_TARGETS MAX_DEV_DB_ENTRIES |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 125 | #define MAX_LUNS 0xffff |
| 126 | #define MAX_AEN_ENTRIES 256 /* should be > EXT_DEF_MAX_AEN_QUEUE */ |
Vikas Chaudhary | f4f5df23 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 127 | #define MAX_DDB_ENTRIES MAX_DEV_DB_ENTRIES |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 128 | #define MAX_PDU_ENTRIES 32 |
| 129 | #define INVALID_ENTRY 0xFFFF |
| 130 | #define MAX_CMDS_TO_RISC 1024 |
| 131 | #define MAX_SRBS MAX_CMDS_TO_RISC |
| 132 | #define MBOX_AEN_REG_COUNT 5 |
| 133 | #define MAX_INIT_RETRIES 5 |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 134 | |
| 135 | /* |
| 136 | * Buffer sizes |
| 137 | */ |
| 138 | #define REQUEST_QUEUE_DEPTH MAX_CMDS_TO_RISC |
| 139 | #define RESPONSE_QUEUE_DEPTH 64 |
| 140 | #define QUEUE_SIZE 64 |
| 141 | #define DMA_BUFFER_SIZE 512 |
| 142 | |
| 143 | /* |
| 144 | * Misc |
| 145 | */ |
| 146 | #define MAC_ADDR_LEN 6 /* in bytes */ |
| 147 | #define IP_ADDR_LEN 4 /* in bytes */ |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 148 | #define IPv6_ADDR_LEN 16 /* IPv6 address size */ |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 149 | #define DRIVER_NAME "qla4xxx" |
| 150 | |
| 151 | #define MAX_LINKED_CMDS_PER_LUN 3 |
Ravi Anand | dbaf82e | 2010-07-10 14:50:32 +0530 | [diff] [blame] | 152 | #define MAX_REQS_SERVICED_PER_INTR 1 |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 153 | |
| 154 | #define ISCSI_IPADDR_SIZE 4 /* IP address size */ |
Joe Perches | b1c1181 | 2008-02-03 17:28:22 +0200 | [diff] [blame] | 155 | #define ISCSI_ALIAS_SIZE 32 /* ISCSI Alias name size */ |
David C Somayajulu | 5c8bfc9 | 2007-05-23 17:50:55 -0700 | [diff] [blame] | 156 | #define ISCSI_NAME_SIZE 0xE0 /* ISCSI Name size */ |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 157 | |
Vikas Chaudhary | 3013cea | 2010-07-30 14:25:46 +0530 | [diff] [blame] | 158 | #define QL4_SESS_RECOVERY_TMO 30 /* iSCSI session */ |
| 159 | /* recovery timeout */ |
| 160 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 161 | #define LSDW(x) ((u32)((u64)(x))) |
| 162 | #define MSDW(x) ((u32)((((u64)(x)) >> 16) >> 16)) |
| 163 | |
| 164 | /* |
| 165 | * Retry & Timeout Values |
| 166 | */ |
| 167 | #define MBOX_TOV 60 |
| 168 | #define SOFT_RESET_TOV 30 |
| 169 | #define RESET_INTR_TOV 3 |
| 170 | #define SEMAPHORE_TOV 10 |
Vikas Chaudhary | f4f5df23 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 171 | #define ADAPTER_INIT_TOV 30 |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 172 | #define ADAPTER_RESET_TOV 180 |
| 173 | #define EXTEND_CMD_TOV 60 |
| 174 | #define WAIT_CMD_TOV 30 |
| 175 | #define EH_WAIT_CMD_TOV 120 |
| 176 | #define FIRMWARE_UP_TOV 60 |
| 177 | #define RESET_FIRMWARE_TOV 30 |
| 178 | #define LOGOUT_TOV 10 |
| 179 | #define IOCB_TOV_MARGIN 10 |
| 180 | #define RELOGIN_TOV 18 |
| 181 | #define ISNS_DEREG_TOV 5 |
Vikas Chaudhary | f581a3f | 2010-10-06 22:47:48 -0700 | [diff] [blame] | 182 | #define HBA_ONLINE_TOV 30 |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 183 | |
| 184 | #define MAX_RESET_HA_RETRIES 2 |
| 185 | |
Vikas Chaudhary | 5369887 | 2010-04-28 11:41:59 +0530 | [diff] [blame] | 186 | #define CMD_SP(Cmnd) ((Cmnd)->SCp.ptr) |
| 187 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 188 | /* |
| 189 | * SCSI Request Block structure (srb) that is placed |
| 190 | * on cmd->SCp location of every I/O [We have 22 bytes available] |
| 191 | */ |
| 192 | struct srb { |
| 193 | struct list_head list; /* (8) */ |
| 194 | struct scsi_qla_host *ha; /* HA the SP is queued on */ |
| 195 | struct ddb_entry *ddb; |
| 196 | uint16_t flags; /* (1) Status flags. */ |
| 197 | |
| 198 | #define SRB_DMA_VALID BIT_3 /* DMA Buffer mapped. */ |
| 199 | #define SRB_GOT_SENSE BIT_4 /* sense data recieved. */ |
| 200 | uint8_t state; /* (1) Status flags. */ |
| 201 | |
| 202 | #define SRB_NO_QUEUE_STATE 0 /* Request is in between states */ |
| 203 | #define SRB_FREE_STATE 1 |
| 204 | #define SRB_ACTIVE_STATE 3 |
| 205 | #define SRB_ACTIVE_TIMEOUT_STATE 4 |
| 206 | #define SRB_SUSPENDED_STATE 7 /* Request in suspended state */ |
| 207 | |
| 208 | struct scsi_cmnd *cmd; /* (4) SCSI command block */ |
| 209 | dma_addr_t dma_handle; /* (4) for unmap of single transfers */ |
Vikas Chaudhary | 09a0f71 | 2010-04-28 11:42:24 +0530 | [diff] [blame] | 210 | struct kref srb_ref; /* reference count for this srb */ |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 211 | uint32_t fw_ddb_index; |
| 212 | uint8_t err_id; /* error id */ |
| 213 | #define SRB_ERR_PORT 1 /* Request failed because "port down" */ |
| 214 | #define SRB_ERR_LOOP 2 /* Request failed because "loop down" */ |
| 215 | #define SRB_ERR_DEVICE 3 /* Request failed because "device error" */ |
| 216 | #define SRB_ERR_OTHER 4 |
| 217 | |
| 218 | uint16_t reserved; |
| 219 | uint16_t iocb_tov; |
| 220 | uint16_t iocb_cnt; /* Number of used iocbs */ |
| 221 | uint16_t cc_stat; |
Karen Higgins | 94bced3 | 2009-07-15 15:02:58 -0500 | [diff] [blame] | 222 | |
| 223 | /* Used for extended sense / status continuation */ |
| 224 | uint8_t *req_sense_ptr; |
| 225 | uint16_t req_sense_len; |
| 226 | uint16_t reserved2; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 227 | }; |
| 228 | |
David C Somayajulu | 5c8bfc9 | 2007-05-23 17:50:55 -0700 | [diff] [blame] | 229 | /* |
| 230 | * Asynchronous Event Queue structure |
| 231 | */ |
| 232 | struct aen { |
| 233 | uint32_t mbox_sts[MBOX_AEN_REG_COUNT]; |
| 234 | }; |
| 235 | |
| 236 | struct ql4_aen_log { |
| 237 | int count; |
| 238 | struct aen entry[MAX_AEN_ENTRIES]; |
| 239 | }; |
| 240 | |
| 241 | /* |
| 242 | * Device Database (DDB) structure |
| 243 | */ |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 244 | struct ddb_entry { |
| 245 | struct list_head list; /* ddb list */ |
| 246 | struct scsi_qla_host *ha; |
| 247 | struct iscsi_cls_session *sess; |
| 248 | struct iscsi_cls_conn *conn; |
| 249 | |
| 250 | atomic_t state; /* DDB State */ |
| 251 | |
| 252 | unsigned long flags; /* DDB Flags */ |
| 253 | |
| 254 | unsigned long dev_scan_wait_to_start_relogin; |
| 255 | unsigned long dev_scan_wait_to_complete_relogin; |
| 256 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 257 | uint16_t fw_ddb_index; /* DDB firmware index */ |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 258 | uint16_t options; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 259 | uint32_t fw_ddb_device_state; /* F/W Device State -- see ql4_fw.h */ |
| 260 | |
| 261 | uint32_t CmdSn; |
| 262 | uint16_t target_session_id; |
| 263 | uint16_t connection_id; |
| 264 | uint16_t exe_throttle; /* Max mumber of cmds outstanding |
| 265 | * simultaneously */ |
| 266 | uint16_t task_mgmt_timeout; /* Min time for task mgmt cmds to |
| 267 | * complete */ |
| 268 | uint16_t default_relogin_timeout; /* Max time to wait for |
| 269 | * relogin to complete */ |
| 270 | uint16_t tcp_source_port_num; |
| 271 | uint32_t default_time2wait; /* Default Min time between |
| 272 | * relogins (+aens) */ |
| 273 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 274 | atomic_t retry_relogin_timer; /* Min Time between relogins |
| 275 | * (4000 only) */ |
| 276 | atomic_t relogin_timer; /* Max Time to wait for relogin to complete */ |
| 277 | atomic_t relogin_retry_count; /* Num of times relogin has been |
| 278 | * retried */ |
| 279 | |
| 280 | uint16_t port; |
| 281 | uint32_t tpgt; |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 282 | uint8_t ip_addr[IP_ADDR_LEN]; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 283 | uint8_t iscsi_name[ISCSI_NAME_SIZE]; /* 72 x48 */ |
| 284 | uint8_t iscsi_alias[0x20]; |
Mike Christie | 41bbdbe | 2009-01-16 12:36:52 -0600 | [diff] [blame] | 285 | uint8_t isid[6]; |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 286 | uint16_t iscsi_max_burst_len; |
| 287 | uint16_t iscsi_max_outsnd_r2t; |
| 288 | uint16_t iscsi_first_burst_len; |
| 289 | uint16_t iscsi_max_rcv_data_seg_len; |
| 290 | uint16_t iscsi_max_snd_data_seg_len; |
| 291 | |
| 292 | struct in6_addr remote_ipv6_addr; |
| 293 | struct in6_addr link_local_ipv6_addr; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 294 | }; |
| 295 | |
| 296 | /* |
| 297 | * DDB states. |
| 298 | */ |
| 299 | #define DDB_STATE_DEAD 0 /* We can no longer talk to |
| 300 | * this device */ |
| 301 | #define DDB_STATE_ONLINE 1 /* Device ready to accept |
| 302 | * commands */ |
| 303 | #define DDB_STATE_MISSING 2 /* Device logged off, trying |
| 304 | * to re-login */ |
| 305 | |
| 306 | /* |
| 307 | * DDB flags. |
| 308 | */ |
| 309 | #define DF_RELOGIN 0 /* Relogin to device */ |
| 310 | #define DF_NO_RELOGIN 1 /* Do not relogin if IOCTL |
| 311 | * logged it out */ |
| 312 | #define DF_ISNS_DISCOVERED 2 /* Device was discovered via iSNS */ |
| 313 | #define DF_FO_MASKED 3 |
| 314 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 315 | |
| 316 | #include "ql4_fw.h" |
| 317 | #include "ql4_nvram.h" |
| 318 | |
Vikas Chaudhary | f4f5df23 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 319 | struct ql82xx_hw_data { |
| 320 | /* Offsets for flash/nvram access (set to ~0 if not used). */ |
| 321 | uint32_t flash_conf_off; |
| 322 | uint32_t flash_data_off; |
| 323 | |
| 324 | uint32_t fdt_wrt_disable; |
| 325 | uint32_t fdt_erase_cmd; |
| 326 | uint32_t fdt_block_size; |
| 327 | uint32_t fdt_unprotect_sec_cmd; |
| 328 | uint32_t fdt_protect_sec_cmd; |
| 329 | |
| 330 | uint32_t flt_region_flt; |
| 331 | uint32_t flt_region_fdt; |
| 332 | uint32_t flt_region_boot; |
| 333 | uint32_t flt_region_bootload; |
| 334 | uint32_t flt_region_fw; |
| 335 | uint32_t reserved; |
| 336 | }; |
| 337 | |
| 338 | struct qla4_8xxx_legacy_intr_set { |
| 339 | uint32_t int_vec_bit; |
| 340 | uint32_t tgt_status_reg; |
| 341 | uint32_t tgt_mask_reg; |
| 342 | uint32_t pci_int_reg; |
| 343 | }; |
| 344 | |
| 345 | /* MSI-X Support */ |
| 346 | |
| 347 | #define QLA_MSIX_DEFAULT 0x00 |
| 348 | #define QLA_MSIX_RSP_Q 0x01 |
| 349 | |
| 350 | #define QLA_MSIX_ENTRIES 2 |
| 351 | #define QLA_MIDX_DEFAULT 0 |
| 352 | #define QLA_MIDX_RSP_Q 1 |
| 353 | |
| 354 | struct ql4_msix_entry { |
| 355 | int have_irq; |
| 356 | uint16_t msix_vector; |
| 357 | uint16_t msix_entry; |
| 358 | }; |
| 359 | |
| 360 | /* |
| 361 | * ISP Operations |
| 362 | */ |
| 363 | struct isp_operations { |
| 364 | int (*iospace_config) (struct scsi_qla_host *ha); |
| 365 | void (*pci_config) (struct scsi_qla_host *); |
| 366 | void (*disable_intrs) (struct scsi_qla_host *); |
| 367 | void (*enable_intrs) (struct scsi_qla_host *); |
| 368 | int (*start_firmware) (struct scsi_qla_host *); |
| 369 | irqreturn_t (*intr_handler) (int , void *); |
| 370 | void (*interrupt_service_routine) (struct scsi_qla_host *, uint32_t); |
| 371 | int (*reset_chip) (struct scsi_qla_host *); |
| 372 | int (*reset_firmware) (struct scsi_qla_host *); |
| 373 | void (*queue_iocb) (struct scsi_qla_host *); |
| 374 | void (*complete_iocb) (struct scsi_qla_host *); |
| 375 | uint16_t (*rd_shdw_req_q_out) (struct scsi_qla_host *); |
| 376 | uint16_t (*rd_shdw_rsp_q_in) (struct scsi_qla_host *); |
| 377 | int (*get_sys_info) (struct scsi_qla_host *); |
| 378 | }; |
| 379 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 380 | /* |
| 381 | * Linux Host Adapter structure |
| 382 | */ |
| 383 | struct scsi_qla_host { |
| 384 | /* Linux adapter configuration data */ |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 385 | unsigned long flags; |
| 386 | |
David C Somayajulu | 5c8bfc9 | 2007-05-23 17:50:55 -0700 | [diff] [blame] | 387 | #define AF_ONLINE 0 /* 0x00000001 */ |
| 388 | #define AF_INIT_DONE 1 /* 0x00000002 */ |
| 389 | #define AF_MBOX_COMMAND 2 /* 0x00000004 */ |
| 390 | #define AF_MBOX_COMMAND_DONE 3 /* 0x00000008 */ |
Vikas Chaudhary | f4f5df23 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 391 | #define AF_DPC_SCHEDULED 5 /* 0x00000020 */ |
David C Somayajulu | 5c8bfc9 | 2007-05-23 17:50:55 -0700 | [diff] [blame] | 392 | #define AF_INTERRUPTS_ON 6 /* 0x00000040 */ |
| 393 | #define AF_GET_CRASH_RECORD 7 /* 0x00000080 */ |
| 394 | #define AF_LINK_UP 8 /* 0x00000100 */ |
| 395 | #define AF_IRQ_ATTACHED 10 /* 0x00000400 */ |
| 396 | #define AF_DISABLE_ACB_COMPLETE 11 /* 0x00000800 */ |
Vikas Chaudhary | f4f5df23 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 397 | #define AF_HBA_GOING_AWAY 12 /* 0x00001000 */ |
| 398 | #define AF_INTx_ENABLED 15 /* 0x00008000 */ |
| 399 | #define AF_MSI_ENABLED 16 /* 0x00010000 */ |
| 400 | #define AF_MSIX_ENABLED 17 /* 0x00020000 */ |
| 401 | #define AF_MBOX_COMMAND_NOPOLL 18 /* 0x00040000 */ |
Nilesh Javali | 2103363 | 2010-07-30 14:28:07 +0530 | [diff] [blame] | 402 | #define AF_FW_RECOVERY 19 /* 0x00080000 */ |
Lalit Chandivade | 2232be0 | 2010-07-30 14:38:47 +0530 | [diff] [blame] | 403 | #define AF_EEH_BUSY 20 /* 0x00100000 */ |
| 404 | #define AF_PCI_CHANNEL_IO_PERM_FAILURE 21 /* 0x00200000 */ |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 405 | |
| 406 | unsigned long dpc_flags; |
| 407 | |
David C Somayajulu | 5c8bfc9 | 2007-05-23 17:50:55 -0700 | [diff] [blame] | 408 | #define DPC_RESET_HA 1 /* 0x00000002 */ |
| 409 | #define DPC_RETRY_RESET_HA 2 /* 0x00000004 */ |
| 410 | #define DPC_RELOGIN_DEVICE 3 /* 0x00000008 */ |
Vikas Chaudhary | f4f5df23 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 411 | #define DPC_RESET_HA_FW_CONTEXT 4 /* 0x00000010 */ |
David C Somayajulu | 5c8bfc9 | 2007-05-23 17:50:55 -0700 | [diff] [blame] | 412 | #define DPC_RESET_HA_INTR 5 /* 0x00000020 */ |
| 413 | #define DPC_ISNS_RESTART 7 /* 0x00000080 */ |
| 414 | #define DPC_AEN 9 /* 0x00000200 */ |
| 415 | #define DPC_GET_DHCP_IP_ADDR 15 /* 0x00008000 */ |
Vikas Chaudhary | 065aa1b | 2010-04-28 11:38:11 +0530 | [diff] [blame] | 416 | #define DPC_LINK_CHANGED 18 /* 0x00040000 */ |
Vikas Chaudhary | f4f5df23 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 417 | #define DPC_RESET_ACTIVE 20 /* 0x00040000 */ |
| 418 | #define DPC_HA_UNRECOVERABLE 21 /* 0x00080000 ISP-82xx only*/ |
| 419 | #define DPC_HA_NEED_QUIESCENT 22 /* 0x00100000 ISP-82xx only*/ |
| 420 | |
David C Somayajulu | 5c8bfc9 | 2007-05-23 17:50:55 -0700 | [diff] [blame] | 421 | |
| 422 | struct Scsi_Host *host; /* pointer to host data */ |
| 423 | uint32_t tot_ddbs; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 424 | |
Vikas Chaudhary | f4f5df23 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 425 | uint16_t iocb_cnt; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 426 | |
| 427 | /* SRB cache. */ |
| 428 | #define SRB_MIN_REQ 128 |
| 429 | mempool_t *srb_mempool; |
| 430 | |
| 431 | /* pci information */ |
| 432 | struct pci_dev *pdev; |
| 433 | |
| 434 | struct isp_reg __iomem *reg; /* Base I/O address */ |
| 435 | unsigned long pio_address; |
| 436 | unsigned long pio_length; |
| 437 | #define MIN_IOBASE_LEN 0x100 |
| 438 | |
| 439 | uint16_t req_q_count; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 440 | |
| 441 | unsigned long host_no; |
| 442 | |
| 443 | /* NVRAM registers */ |
| 444 | struct eeprom_data *nvram; |
| 445 | spinlock_t hardware_lock ____cacheline_aligned; |
Vikas Chaudhary | f4f5df23 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 446 | uint32_t eeprom_cmd_data; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 447 | |
| 448 | /* Counters for general statistics */ |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 449 | uint64_t isr_count; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 450 | uint64_t adapter_error_count; |
| 451 | uint64_t device_error_count; |
| 452 | uint64_t total_io_count; |
| 453 | uint64_t total_mbytes_xferred; |
| 454 | uint64_t link_failure_count; |
| 455 | uint64_t invalid_crc_count; |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 456 | uint32_t bytes_xfered; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 457 | uint32_t spurious_int_count; |
| 458 | uint32_t aborted_io_count; |
| 459 | uint32_t io_timeout_count; |
| 460 | uint32_t mailbox_timeout_count; |
| 461 | uint32_t seconds_since_last_intr; |
| 462 | uint32_t seconds_since_last_heartbeat; |
| 463 | uint32_t mac_index; |
| 464 | |
| 465 | /* Info Needed for Management App */ |
| 466 | /* --- From GetFwVersion --- */ |
| 467 | uint32_t firmware_version[2]; |
| 468 | uint32_t patch_number; |
| 469 | uint32_t build_number; |
David C Somayajulu | 5c8bfc9 | 2007-05-23 17:50:55 -0700 | [diff] [blame] | 470 | uint32_t board_id; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 471 | |
| 472 | /* --- From Init_FW --- */ |
| 473 | /* init_cb_t *init_cb; */ |
| 474 | uint16_t firmware_options; |
| 475 | uint16_t tcp_options; |
| 476 | uint8_t ip_address[IP_ADDR_LEN]; |
| 477 | uint8_t subnet_mask[IP_ADDR_LEN]; |
| 478 | uint8_t gateway[IP_ADDR_LEN]; |
| 479 | uint8_t alias[32]; |
| 480 | uint8_t name_string[256]; |
| 481 | uint8_t heartbeat_interval; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 482 | |
| 483 | /* --- From FlashSysInfo --- */ |
| 484 | uint8_t my_mac[MAC_ADDR_LEN]; |
| 485 | uint8_t serial_number[16]; |
| 486 | |
| 487 | /* --- From GetFwState --- */ |
| 488 | uint32_t firmware_state; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 489 | uint32_t addl_fw_state; |
| 490 | |
| 491 | /* Linux kernel thread */ |
| 492 | struct workqueue_struct *dpc_thread; |
| 493 | struct work_struct dpc_work; |
| 494 | |
| 495 | /* Linux timer thread */ |
| 496 | struct timer_list timer; |
| 497 | uint32_t timer_active; |
| 498 | |
| 499 | /* Recovery Timers */ |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 500 | uint32_t discovery_wait; |
| 501 | atomic_t check_relogin_timeouts; |
| 502 | uint32_t retry_reset_ha_cnt; |
| 503 | uint32_t isp_reset_timer; /* reset test timer */ |
| 504 | uint32_t nic_reset_timer; /* simulated nic reset test timer */ |
| 505 | int eh_start; |
| 506 | struct list_head free_srb_q; |
| 507 | uint16_t free_srb_q_count; |
| 508 | uint16_t num_srbs_allocated; |
| 509 | |
| 510 | /* DMA Memory Block */ |
| 511 | void *queues; |
| 512 | dma_addr_t queues_dma; |
| 513 | unsigned long queues_len; |
| 514 | |
| 515 | #define MEM_ALIGN_VALUE \ |
| 516 | ((max(REQUEST_QUEUE_DEPTH, RESPONSE_QUEUE_DEPTH)) * \ |
| 517 | sizeof(struct queue_entry)) |
| 518 | /* request and response queue variables */ |
| 519 | dma_addr_t request_dma; |
| 520 | struct queue_entry *request_ring; |
| 521 | struct queue_entry *request_ptr; |
| 522 | dma_addr_t response_dma; |
| 523 | struct queue_entry *response_ring; |
| 524 | struct queue_entry *response_ptr; |
| 525 | dma_addr_t shadow_regs_dma; |
| 526 | struct shadow_regs *shadow_regs; |
| 527 | uint16_t request_in; /* Current indexes. */ |
| 528 | uint16_t request_out; |
| 529 | uint16_t response_in; |
| 530 | uint16_t response_out; |
| 531 | |
| 532 | /* aen queue variables */ |
| 533 | uint16_t aen_q_count; /* Number of available aen_q entries */ |
| 534 | uint16_t aen_in; /* Current indexes */ |
| 535 | uint16_t aen_out; |
| 536 | struct aen aen_q[MAX_AEN_ENTRIES]; |
| 537 | |
David C Somayajulu | 5c8bfc9 | 2007-05-23 17:50:55 -0700 | [diff] [blame] | 538 | struct ql4_aen_log aen_log;/* tracks all aens */ |
| 539 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 540 | /* This mutex protects several threads to do mailbox commands |
| 541 | * concurrently. |
| 542 | */ |
| 543 | struct mutex mbox_sem; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 544 | |
| 545 | /* temporary mailbox status registers */ |
| 546 | volatile uint8_t mbox_status_count; |
| 547 | volatile uint32_t mbox_status[MBOX_REG_COUNT]; |
| 548 | |
| 549 | /* local device database list (contains internal ddb entries) */ |
| 550 | struct list_head ddb_list; |
| 551 | |
| 552 | /* Map ddb_list entry by FW ddb index */ |
| 553 | struct ddb_entry *fw_ddb_index_map[MAX_DDB_ENTRIES]; |
| 554 | |
Karen Higgins | 94bced3 | 2009-07-15 15:02:58 -0500 | [diff] [blame] | 555 | /* Saved srb for status continuation entry processing */ |
| 556 | struct srb *status_srb; |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 557 | |
| 558 | /* IPv6 support info from InitFW */ |
| 559 | uint8_t acb_version; |
| 560 | uint8_t ipv4_addr_state; |
| 561 | uint16_t ipv4_options; |
| 562 | |
| 563 | uint32_t resvd2; |
| 564 | uint32_t ipv6_options; |
| 565 | uint32_t ipv6_addl_options; |
| 566 | uint8_t ipv6_link_local_state; |
| 567 | uint8_t ipv6_addr0_state; |
| 568 | uint8_t ipv6_addr1_state; |
| 569 | uint8_t ipv6_default_router_state; |
| 570 | struct in6_addr ipv6_link_local_addr; |
| 571 | struct in6_addr ipv6_addr0; |
| 572 | struct in6_addr ipv6_addr1; |
| 573 | struct in6_addr ipv6_default_router_addr; |
Vikas Chaudhary | f4f5df23 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 574 | |
| 575 | /* qla82xx specific fields */ |
| 576 | struct device_reg_82xx __iomem *qla4_8xxx_reg; /* Base I/O address */ |
| 577 | unsigned long nx_pcibase; /* Base I/O address */ |
| 578 | uint8_t *nx_db_rd_ptr; /* Doorbell read pointer */ |
| 579 | unsigned long nx_db_wr_ptr; /* Door bell write pointer */ |
| 580 | unsigned long first_page_group_start; |
| 581 | unsigned long first_page_group_end; |
| 582 | |
| 583 | uint32_t crb_win; |
| 584 | uint32_t curr_window; |
| 585 | uint32_t ddr_mn_window; |
| 586 | unsigned long mn_win_crb; |
| 587 | unsigned long ms_win_crb; |
| 588 | int qdr_sn_window; |
| 589 | rwlock_t hw_lock; |
| 590 | uint16_t func_num; |
| 591 | int link_width; |
| 592 | |
| 593 | struct qla4_8xxx_legacy_intr_set nx_legacy_intr; |
| 594 | u32 nx_crb_mask; |
| 595 | |
| 596 | uint8_t revision_id; |
| 597 | uint32_t fw_heartbeat_counter; |
| 598 | |
| 599 | struct isp_operations *isp_ops; |
| 600 | struct ql82xx_hw_data hw; |
| 601 | |
| 602 | struct ql4_msix_entry msix_entries[QLA_MSIX_ENTRIES]; |
| 603 | |
| 604 | uint32_t nx_dev_init_timeout; |
| 605 | uint32_t nx_reset_timeout; |
| 606 | |
| 607 | struct completion mbx_intr_comp; |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 608 | }; |
| 609 | |
Vikas Chaudhary | 2a49a78 | 2010-04-28 11:37:07 +0530 | [diff] [blame] | 610 | static inline int is_ipv4_enabled(struct scsi_qla_host *ha) |
| 611 | { |
| 612 | return ((ha->ipv4_options & IPOPT_IPv4_PROTOCOL_ENABLE) != 0); |
| 613 | } |
| 614 | |
| 615 | static inline int is_ipv6_enabled(struct scsi_qla_host *ha) |
| 616 | { |
| 617 | return ((ha->ipv6_options & IPV6_OPT_IPV6_PROTOCOL_ENABLE) != 0); |
| 618 | } |
| 619 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 620 | static inline int is_qla4010(struct scsi_qla_host *ha) |
| 621 | { |
| 622 | return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4010; |
| 623 | } |
| 624 | |
| 625 | static inline int is_qla4022(struct scsi_qla_host *ha) |
| 626 | { |
| 627 | return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4022; |
| 628 | } |
| 629 | |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 630 | static inline int is_qla4032(struct scsi_qla_host *ha) |
| 631 | { |
| 632 | return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4032; |
| 633 | } |
| 634 | |
Vikas Chaudhary | f4f5df23 | 2010-07-28 15:53:44 +0530 | [diff] [blame] | 635 | static inline int is_qla8022(struct scsi_qla_host *ha) |
| 636 | { |
| 637 | return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8022; |
| 638 | } |
| 639 | |
Lalit Chandivade | 2232be0 | 2010-07-30 14:38:47 +0530 | [diff] [blame] | 640 | /* Note: Currently AER/EEH is now supported only for 8022 cards |
| 641 | * This function needs to be updated when AER/EEH is enabled |
| 642 | * for other cards. |
| 643 | */ |
| 644 | static inline int is_aer_supported(struct scsi_qla_host *ha) |
| 645 | { |
| 646 | return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8022; |
| 647 | } |
| 648 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 649 | static inline int adapter_up(struct scsi_qla_host *ha) |
| 650 | { |
| 651 | return (test_bit(AF_ONLINE, &ha->flags) != 0) && |
| 652 | (test_bit(AF_LINK_UP, &ha->flags) != 0); |
| 653 | } |
| 654 | |
| 655 | static inline struct scsi_qla_host* to_qla_host(struct Scsi_Host *shost) |
| 656 | { |
| 657 | return (struct scsi_qla_host *)shost->hostdata; |
| 658 | } |
| 659 | |
| 660 | static inline void __iomem* isp_semaphore(struct scsi_qla_host *ha) |
| 661 | { |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 662 | return (is_qla4010(ha) ? |
| 663 | &ha->reg->u1.isp4010.nvram : |
| 664 | &ha->reg->u1.isp4022.semaphore); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | static inline void __iomem* isp_nvram(struct scsi_qla_host *ha) |
| 668 | { |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 669 | return (is_qla4010(ha) ? |
| 670 | &ha->reg->u1.isp4010.nvram : |
| 671 | &ha->reg->u1.isp4022.nvram); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | static inline void __iomem* isp_ext_hw_conf(struct scsi_qla_host *ha) |
| 675 | { |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 676 | return (is_qla4010(ha) ? |
| 677 | &ha->reg->u2.isp4010.ext_hw_conf : |
| 678 | &ha->reg->u2.isp4022.p0.ext_hw_conf); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | static inline void __iomem* isp_port_status(struct scsi_qla_host *ha) |
| 682 | { |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 683 | return (is_qla4010(ha) ? |
| 684 | &ha->reg->u2.isp4010.port_status : |
| 685 | &ha->reg->u2.isp4022.p0.port_status); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 686 | } |
| 687 | |
| 688 | static inline void __iomem* isp_port_ctrl(struct scsi_qla_host *ha) |
| 689 | { |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 690 | return (is_qla4010(ha) ? |
| 691 | &ha->reg->u2.isp4010.port_ctrl : |
| 692 | &ha->reg->u2.isp4022.p0.port_ctrl); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 693 | } |
| 694 | |
| 695 | static inline void __iomem* isp_port_error_status(struct scsi_qla_host *ha) |
| 696 | { |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 697 | return (is_qla4010(ha) ? |
| 698 | &ha->reg->u2.isp4010.port_err_status : |
| 699 | &ha->reg->u2.isp4022.p0.port_err_status); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 700 | } |
| 701 | |
| 702 | static inline void __iomem * isp_gp_out(struct scsi_qla_host *ha) |
| 703 | { |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 704 | return (is_qla4010(ha) ? |
| 705 | &ha->reg->u2.isp4010.gp_out : |
| 706 | &ha->reg->u2.isp4022.p0.gp_out); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | static inline int eeprom_ext_hw_conf_offset(struct scsi_qla_host *ha) |
| 710 | { |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 711 | return (is_qla4010(ha) ? |
| 712 | offsetof(struct eeprom_data, isp4010.ext_hw_conf) / 2 : |
| 713 | offsetof(struct eeprom_data, isp4022.ext_hw_conf) / 2); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | int ql4xxx_sem_spinlock(struct scsi_qla_host * ha, u32 sem_mask, u32 sem_bits); |
| 717 | void ql4xxx_sem_unlock(struct scsi_qla_host * ha, u32 sem_mask); |
| 718 | int ql4xxx_sem_lock(struct scsi_qla_host * ha, u32 sem_mask, u32 sem_bits); |
| 719 | |
| 720 | static inline int ql4xxx_lock_flash(struct scsi_qla_host *a) |
| 721 | { |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 722 | if (is_qla4010(a)) |
| 723 | return ql4xxx_sem_spinlock(a, QL4010_FLASH_SEM_MASK, |
| 724 | QL4010_FLASH_SEM_BITS); |
| 725 | else |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 726 | return ql4xxx_sem_spinlock(a, QL4022_FLASH_SEM_MASK, |
| 727 | (QL4022_RESOURCE_BITS_BASE_CODE | |
| 728 | (a->mac_index)) << 13); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 729 | } |
| 730 | |
| 731 | static inline void ql4xxx_unlock_flash(struct scsi_qla_host *a) |
| 732 | { |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 733 | if (is_qla4010(a)) |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 734 | ql4xxx_sem_unlock(a, QL4010_FLASH_SEM_MASK); |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 735 | else |
| 736 | ql4xxx_sem_unlock(a, QL4022_FLASH_SEM_MASK); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 737 | } |
| 738 | |
| 739 | static inline int ql4xxx_lock_nvram(struct scsi_qla_host *a) |
| 740 | { |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 741 | if (is_qla4010(a)) |
| 742 | return ql4xxx_sem_spinlock(a, QL4010_NVRAM_SEM_MASK, |
| 743 | QL4010_NVRAM_SEM_BITS); |
| 744 | else |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 745 | return ql4xxx_sem_spinlock(a, QL4022_NVRAM_SEM_MASK, |
| 746 | (QL4022_RESOURCE_BITS_BASE_CODE | |
| 747 | (a->mac_index)) << 10); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 748 | } |
| 749 | |
| 750 | static inline void ql4xxx_unlock_nvram(struct scsi_qla_host *a) |
| 751 | { |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 752 | if (is_qla4010(a)) |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 753 | ql4xxx_sem_unlock(a, QL4010_NVRAM_SEM_MASK); |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 754 | else |
| 755 | ql4xxx_sem_unlock(a, QL4022_NVRAM_SEM_MASK); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 756 | } |
| 757 | |
| 758 | static inline int ql4xxx_lock_drvr(struct scsi_qla_host *a) |
| 759 | { |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 760 | if (is_qla4010(a)) |
| 761 | return ql4xxx_sem_lock(a, QL4010_DRVR_SEM_MASK, |
| 762 | QL4010_DRVR_SEM_BITS); |
| 763 | else |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 764 | return ql4xxx_sem_lock(a, QL4022_DRVR_SEM_MASK, |
| 765 | (QL4022_RESOURCE_BITS_BASE_CODE | |
| 766 | (a->mac_index)) << 1); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | static inline void ql4xxx_unlock_drvr(struct scsi_qla_host *a) |
| 770 | { |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 771 | if (is_qla4010(a)) |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 772 | ql4xxx_sem_unlock(a, QL4010_DRVR_SEM_MASK); |
David C Somayajulu | d915058 | 2006-11-15 17:38:40 -0800 | [diff] [blame] | 773 | else |
| 774 | ql4xxx_sem_unlock(a, QL4022_DRVR_SEM_MASK); |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 775 | } |
| 776 | |
| 777 | /*---------------------------------------------------------------------------*/ |
| 778 | |
| 779 | /* Defines for qla4xxx_initialize_adapter() and qla4xxx_recover_adapter() */ |
| 780 | #define PRESERVE_DDB_LIST 0 |
| 781 | #define REBUILD_DDB_LIST 1 |
| 782 | |
| 783 | /* Defines for process_aen() */ |
| 784 | #define PROCESS_ALL_AENS 0 |
| 785 | #define FLUSH_DDB_CHANGED_AENS 1 |
| 786 | #define RELOGIN_DDB_CHANGED_AENS 2 |
| 787 | |
David Somayajulu | afaf5a2 | 2006-09-19 10:28:00 -0700 | [diff] [blame] | 788 | #endif /*_QLA4XXX_H */ |