11 #include <linux/kernel.h>
13 #include <linux/types.h>
14 #include <linux/module.h>
15 #include <linux/list.h>
16 #include <linux/pci.h>
18 #include <linux/sched.h>
19 #include <linux/slab.h>
31 #include <scsi/scsi.h>
47 #ifndef PCI_DEVICE_ID_QLOGIC_ISP4010
48 #define PCI_DEVICE_ID_QLOGIC_ISP4010 0x4010
51 #ifndef PCI_DEVICE_ID_QLOGIC_ISP4022
52 #define PCI_DEVICE_ID_QLOGIC_ISP4022 0x4022
55 #ifndef PCI_DEVICE_ID_QLOGIC_ISP4032
56 #define PCI_DEVICE_ID_QLOGIC_ISP4032 0x4032
59 #ifndef PCI_DEVICE_ID_QLOGIC_ISP8022
60 #define PCI_DEVICE_ID_QLOGIC_ISP8022 0x8022
63 #ifndef PCI_DEVICE_ID_QLOGIC_ISP8324
64 #define PCI_DEVICE_ID_QLOGIC_ISP8324 0x8032
67 #define ISP4XXX_PCI_FN_1 0x1
68 #define ISP4XXX_PCI_FN_2 0x3
92 #define BIT_16 0x10000
93 #define BIT_17 0x20000
94 #define BIT_18 0x40000
95 #define BIT_19 0x80000
96 #define BIT_20 0x100000
97 #define BIT_21 0x200000
98 #define BIT_22 0x400000
99 #define BIT_23 0x800000
100 #define BIT_24 0x1000000
101 #define BIT_25 0x2000000
102 #define BIT_26 0x4000000
103 #define BIT_27 0x8000000
104 #define BIT_28 0x10000000
105 #define BIT_29 0x20000000
106 #define BIT_30 0x40000000
107 #define BIT_31 0x80000000
112 #define ql4_printk(level, ha, format, arg...) \
113 dev_printk(level , &((ha)->pdev->dev) , format , ## arg)
121 #define MAX_TARGETS MAX_DEV_DB_ENTRIES
122 #define MAX_LUNS 0xffff
123 #define MAX_AEN_ENTRIES MAX_DEV_DB_ENTRIES
124 #define MAX_DDB_ENTRIES MAX_DEV_DB_ENTRIES
125 #define MAX_PDU_ENTRIES 32
126 #define INVALID_ENTRY 0xFFFF
127 #define MAX_CMDS_TO_RISC 1024
128 #define MAX_SRBS MAX_CMDS_TO_RISC
129 #define MBOX_AEN_REG_COUNT 8
130 #define MAX_INIT_RETRIES 5
135 #define REQUEST_QUEUE_DEPTH MAX_CMDS_TO_RISC
136 #define RESPONSE_QUEUE_DEPTH 64
137 #define QUEUE_SIZE 64
138 #define DMA_BUFFER_SIZE 512
143 #define MAC_ADDR_LEN 6
144 #define IP_ADDR_LEN 4
145 #define IPv6_ADDR_LEN 16
146 #define DRIVER_NAME "qla4xxx"
148 #define MAX_LINKED_CMDS_PER_LUN 3
149 #define MAX_REQS_SERVICED_PER_INTR 1
151 #define ISCSI_IPADDR_SIZE 4
152 #define ISCSI_ALIAS_SIZE 32
153 #define ISCSI_NAME_SIZE 0xE0
155 #define QL4_SESS_RECOVERY_TMO 120
158 #define LSDW(x) ((u32)((u64)(x)))
159 #define MSDW(x) ((u32)((((u64)(x)) >> 16) >> 16))
165 #define SOFT_RESET_TOV 30
166 #define RESET_INTR_TOV 3
167 #define SEMAPHORE_TOV 10
168 #define ADAPTER_INIT_TOV 30
169 #define ADAPTER_RESET_TOV 180
170 #define EXTEND_CMD_TOV 60
171 #define WAIT_CMD_TOV 30
172 #define EH_WAIT_CMD_TOV 120
173 #define FIRMWARE_UP_TOV 60
174 #define RESET_FIRMWARE_TOV 30
175 #define LOGOUT_TOV 10
176 #define IOCB_TOV_MARGIN 10
177 #define RELOGIN_TOV 18
178 #define ISNS_DEREG_TOV 5
179 #define HBA_ONLINE_TOV 30
180 #define DISABLE_ACB_TOV 30
181 #define IP_CONFIG_TOV 30
184 #define MAX_RESET_HA_RETRIES 2
185 #define FW_ALIVE_WAIT_TOV 3
187 #define CMD_SP(Cmnd) ((Cmnd)->SCp.ptr)
199 #define SRB_DMA_VALID BIT_3
200 #define SRB_GOT_SENSE BIT_4
203 #define SRB_NO_QUEUE_STATE 0
204 #define SRB_FREE_STATE 1
205 #define SRB_ACTIVE_STATE 3
206 #define SRB_ACTIVE_TIMEOUT_STATE 4
207 #define SRB_SUSPENDED_STATE 7
213 #define SRB_ERR_PORT 1
214 #define SRB_ERR_LOOP 2
215 #define SRB_ERR_DEVICE 3
216 #define SRB_ERR_OTHER 4
261 #define FLASH_DDB 0x01
290 #define DDB_IPADDR_LEN 64
298 #define DDB_OPT_IPV6 0x0e0e
299 #define DDB_OPT_IPV4 0x0f0f
306 #define DDB_STATE_DEAD 0
308 #define DDB_STATE_ONLINE 1
310 #define DDB_STATE_MISSING 2
317 #define DF_ISNS_DISCOVERED 2
318 #define DF_FO_MASKED 3
374 #define QLA_MSIX_DEFAULT 0x00
375 #define QLA_MSIX_RSP_Q 0x01
377 #define QLA_MSIX_ENTRIES 2
378 #define QLA_MIDX_DEFAULT 0
379 #define QLA_MIDX_RSP_Q 1
453 #define QL4_CHAP_MAX_NAME_LEN 256
454 #define QL4_CHAP_MAX_SECRET_LEN 100
498 #define AF_INIT_DONE 1
499 #define AF_MBOX_COMMAND 2
500 #define AF_MBOX_COMMAND_DONE 3
501 #define AF_INTERRUPTS_ON 6
502 #define AF_GET_CRASH_RECORD 7
504 #define AF_IRQ_ATTACHED 10
505 #define AF_DISABLE_ACB_COMPLETE 11
506 #define AF_HA_REMOVAL 12
507 #define AF_INTx_ENABLED 15
508 #define AF_MSI_ENABLED 16
509 #define AF_MSIX_ENABLED 17
510 #define AF_MBOX_COMMAND_NOPOLL 18
511 #define AF_FW_RECOVERY 19
512 #define AF_EEH_BUSY 20
513 #define AF_PCI_CHANNEL_IO_PERM_FAILURE 21
514 #define AF_BUILD_DDB_LIST 22
515 #define AF_82XX_FW_DUMPED 24
516 #define AF_8XXX_RST_OWNER 25
517 #define AF_82XX_DUMP_READING 26
518 #define AF_83XX_NO_FW_DUMP 27
522 #define DPC_RESET_HA 1
523 #define DPC_RETRY_RESET_HA 2
524 #define DPC_RELOGIN_DEVICE 3
525 #define DPC_RESET_HA_FW_CONTEXT 4
526 #define DPC_RESET_HA_INTR 5
527 #define DPC_ISNS_RESTART 7
529 #define DPC_GET_DHCP_IP_ADDR 15
530 #define DPC_LINK_CHANGED 18
531 #define DPC_RESET_ACTIVE 20
532 #define DPC_HA_UNRECOVERABLE 21
533 #define DPC_HA_NEED_QUIESCENT 22
534 #define DPC_POST_IDC_ACK 23
542 #define SRB_MIN_REQ 128
551 #define MIN_IOBASE_LEN 0x100
624 #define MEM_ALIGN_VALUE \
625 ((max(REQUEST_QUEUE_DEPTH, RESPONSE_QUEUE_DEPTH)) * \
626 sizeof(struct queue_entry))
720 #define QLFLASH_WAITING 0
721 #define QLFLASH_READING 1
722 #define QLFLASH_WRITING 2
727 #define CHAP_DMA_BLOCK_SIZE 512
730 #define SYSFS_FLAG_FW_SEL_BOOT 2
739 #define DDB_DMA_BLOCK_SIZE 512
814 return is_qla4032(ha) || is_qla4022(ha) || is_qla4010(ha);
829 return is_qla8022(ha) || is_qla8032(ha);
851 return (is_qla4010(ha) ?
852 &ha->
reg->u1.isp4010.nvram :
853 &ha->
reg->u1.isp4022.semaphore);
858 return (is_qla4010(ha) ?
859 &ha->
reg->u1.isp4010.nvram :
860 &ha->
reg->u1.isp4022.nvram);
865 return (is_qla4010(ha) ?
866 &ha->
reg->u2.isp4010.ext_hw_conf :
867 &ha->
reg->u2.isp4022.p0.ext_hw_conf);
872 return (is_qla4010(ha) ?
873 &ha->
reg->u2.isp4010.port_status :
874 &ha->
reg->u2.isp4022.p0.port_status);
879 return (is_qla4010(ha) ?
880 &ha->
reg->u2.isp4010.port_ctrl :
881 &ha->
reg->u2.isp4022.p0.port_ctrl);
886 return (is_qla4010(ha) ?
887 &ha->
reg->u2.isp4010.port_err_status :
888 &ha->
reg->u2.isp4022.p0.port_err_status);
893 return (is_qla4010(ha) ?
894 &ha->
reg->u2.isp4010.gp_out :
895 &ha->
reg->u2.isp4022.p0.gp_out);
898 static inline int eeprom_ext_hw_conf_offset(
struct scsi_qla_host *ha)
900 return (is_qla4010(ha) ?
920 static inline void ql4xxx_unlock_flash(
struct scsi_qla_host *a)
939 static inline void ql4xxx_unlock_nvram(
struct scsi_qla_host *a)
958 static inline void ql4xxx_unlock_drvr(
struct scsi_qla_host *a)
966 static inline int ql4xxx_reset_active(
struct scsi_qla_host *ha)
977 static inline int qla4_8xxx_rd_direct(
struct scsi_qla_host *ha,
983 static inline void qla4_8xxx_wr_direct(
struct scsi_qla_host *ha,
994 #define INIT_ADAPTER 0
995 #define RESET_ADAPTER 1
997 #define PRESERVE_DDB_LIST 0
998 #define REBUILD_DDB_LIST 1
1001 #define PROCESS_ALL_AENS 0
1002 #define FLUSH_DDB_CHANGED_AENS 1
1005 #define QL4_UEVENT_CODE_FW_DUMP 0