headers: smp_lock.h redux
[safe/jmp/linux-2.6] / drivers / scsi / qla2xxx / qla_def.h
index 13ffeda..00aa48d 100644 (file)
@@ -24,7 +24,7 @@
 #include <linux/workqueue.h>
 #include <linux/firmware.h>
 #include <linux/aer.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_host.h>
@@ -93,6 +93,7 @@
 #define LSD(x) ((uint32_t)((uint64_t)(x)))
 #define MSD(x) ((uint32_t)((((uint64_t)(x)) >> 16) >> 16))
 
+#define MAKE_HANDLE(x, y) ((uint32_t)((((uint32_t)(x)) << 16) | (uint32_t)(y)))
 
 /*
  * I/O register
 /* ISP request and response entry counts (37-65535) */
 #define REQUEST_ENTRY_CNT_2100         128     /* Number of request entries. */
 #define REQUEST_ENTRY_CNT_2200         2048    /* Number of request entries. */
-#define REQUEST_ENTRY_CNT_2XXX_EXT_MEM 4096    /* Number of request entries. */
-#define REQUEST_ENTRY_CNT_24XX         4096    /* Number of request entries. */
+#define REQUEST_ENTRY_CNT_24XX         2048    /* Number of request entries. */
 #define RESPONSE_ENTRY_CNT_2100                64      /* Number of response entries.*/
 #define RESPONSE_ENTRY_CNT_2300                512     /* Number of response entries.*/
+#define RESPONSE_ENTRY_CNT_MQ          128     /* Number of response entries.*/
+
+struct req_que;
 
 /*
  * SCSI Request Block
  */
 typedef struct srb {
-       struct scsi_qla_host *ha;       /* HA the SP is queued on */
        struct fc_port *fcport;
 
        struct scsi_cmnd *cmd;          /* Linux SCSI command pkt */
 
        uint16_t flags;
 
-       /* Single transfer DMA context */
-       dma_addr_t dma_handle;
-
        uint32_t request_sense_length;
        uint8_t *request_sense_ptr;
 } srb_t;
@@ -202,20 +201,7 @@ typedef struct srb {
 /*
  * SRB flag definitions
  */
-#define SRB_TIMEOUT            BIT_0   /* Command timed out */
-#define SRB_DMA_VALID          BIT_1   /* Command sent to ISP */
-#define SRB_WATCHDOG           BIT_2   /* Command on watchdog list */
-#define SRB_ABORT_PENDING      BIT_3   /* Command abort sent to device */
-
-#define SRB_ABORTED            BIT_4   /* Command aborted command already */
-#define SRB_RETRY              BIT_5   /* Command needs retrying */
-#define SRB_GOT_SENSE          BIT_6   /* Command has sense data */
-#define SRB_FAILOVER           BIT_7   /* Command in failover state */
-
-#define SRB_BUSY               BIT_8   /* Command is in busy retry state */
-#define SRB_FO_CANCEL          BIT_9   /* Command don't need to do failover */
-#define SRB_IOCTL              BIT_10  /* IOCTL command. */
-#define SRB_TAPE               BIT_11  /* FCP2 (Tape) command. */
+#define SRB_DMA_VALID          BIT_0   /* Command sent to ISP */
 
 /*
  * ISP I/O Register Set structure definitions.
@@ -372,9 +358,17 @@ struct device_reg_2xxx {
        } u_end;
 };
 
+struct device_reg_25xxmq {
+       uint32_t req_q_in;
+       uint32_t req_q_out;
+       uint32_t rsp_q_in;
+       uint32_t rsp_q_out;
+};
+
 typedef union {
                struct device_reg_2xxx isp;
                struct device_reg_24xx isp24;
+               struct device_reg_25xxmq isp25mq;
 } device_reg_t;
 
 #define ISP_REQ_Q_IN(ha, reg) \
@@ -613,6 +607,7 @@ typedef struct {
 #define MBC_GET_TIMEOUT_PARAMS         0x22    /* Get FW timeouts. */
 #define MBC_TRACE_CONTROL              0x27    /* Trace control command. */
 #define MBC_GEN_SYSTEM_ERROR           0x2a    /* Generate System Error. */
+#define MBC_WRITE_SFP                  0x30    /* Write SFP Data. */
 #define MBC_READ_SFP                   0x31    /* Read SFP Data. */
 #define MBC_SET_TIMEOUT_PARAMS         0x32    /* Set FW timeouts. */
 #define MBC_MID_INITIALIZE_FIRMWARE    0x48    /* MID Initialize firmware. */
@@ -866,7 +861,8 @@ struct link_statistics {
        uint32_t prim_seq_err_cnt;
        uint32_t inval_xmit_word_cnt;
        uint32_t inval_crc_cnt;
-       uint32_t unused1[0x1b];
+       uint32_t lip_cnt;
+       uint32_t unused1[0x1a];
        uint32_t tx_frames;
        uint32_t rx_frames;
        uint32_t dumped_frames;
@@ -1526,7 +1522,7 @@ typedef struct {
  */
 typedef struct fc_port {
        struct list_head list;
-       struct scsi_qla_host *ha;
+       struct scsi_qla_host *vha;
 
        uint8_t node_name[WWN_SIZE];
        uint8_t port_name[WWN_SIZE];
@@ -1546,14 +1542,12 @@ typedef struct fc_port {
        int login_retry;
        atomic_t port_down_timer;
 
-       spinlock_t rport_lock;
        struct fc_rport *rport, *drport;
        u32 supported_classes;
 
        unsigned long last_queue_full;
        unsigned long last_ramp_up;
 
-       struct list_head vp_fcport;
        uint16_t vp_idx;
 } fc_port_t;
 
@@ -1564,39 +1558,13 @@ typedef struct fc_port {
 #define FCS_DEVICE_DEAD                2
 #define FCS_DEVICE_LOST                3
 #define FCS_ONLINE             4
-#define FCS_NOT_SUPPORTED      5
-#define FCS_FAILOVER           6
-#define FCS_FAILOVER_FAILED    7
 
 /*
  * FC port flags.
  */
 #define FCF_FABRIC_DEVICE      BIT_0
 #define FCF_LOGIN_NEEDED       BIT_1
-#define FCF_FO_MASKED          BIT_2
-#define FCF_FAILOVER_NEEDED    BIT_3
-#define FCF_RESET_NEEDED       BIT_4
-#define FCF_PERSISTENT_BOUND   BIT_5
-#define FCF_TAPE_PRESENT       BIT_6
-#define FCF_FARP_DONE          BIT_7
-#define FCF_FARP_FAILED                BIT_8
-#define FCF_FARP_REPLY_NEEDED  BIT_9
-#define FCF_AUTH_REQ           BIT_10
-#define FCF_SEND_AUTH_REQ      BIT_11
-#define FCF_RECEIVE_AUTH_REQ   BIT_12
-#define FCF_AUTH_SUCCESS       BIT_13
-#define FCF_RLC_SUPPORT                BIT_14
-#define FCF_CONFIG             BIT_15  /* Needed? */
-#define FCF_RESCAN_NEEDED      BIT_16
-#define FCF_XP_DEVICE          BIT_17
-#define FCF_MSA_DEVICE         BIT_18
-#define FCF_EVA_DEVICE         BIT_19
-#define FCF_MSA_PORT_ACTIVE    BIT_20
-#define FCF_FAILBACK_DISABLE   BIT_21
-#define FCF_FAILOVER_DISABLE   BIT_22
-#define FCF_DSXXX_DEVICE       BIT_23
-#define FCF_AA_EVA_DEVICE      BIT_24
-#define FCF_AA_MSA_DEVICE      BIT_25
+#define FCF_TAPE_PRESENT       BIT_2
 
 /* No loop ID flag. */
 #define FC_NO_LOOP_ID          0x1000
@@ -1611,6 +1579,7 @@ typedef struct fc_port {
 #define CT_ACCEPT_RESPONSE     0x8002
 #define CT_REASON_INVALID_COMMAND_CODE 0x01
 #define CT_REASON_CANNOT_PERFORM       0x09
+#define CT_REASON_COMMAND_UNSUPPORTED  0x0b
 #define CT_EXPL_ALREADY_REGISTERED     0x10
 
 #define NS_N_PORT_TYPE 0x01
@@ -2039,6 +2008,8 @@ typedef struct vport_params {
 #define VP_RET_CODE_NO_MEM             5
 #define VP_RET_CODE_NOT_FOUND          6
 
+struct qla_hw_data;
+struct rsp_que;
 /*
  * ISP operations
  */
@@ -2057,11 +2028,12 @@ struct isp_operations {
        char * (*fw_version_str) (struct scsi_qla_host *, char *);
 
        irq_handler_t intr_handler;
-       void (*enable_intrs) (struct scsi_qla_host *);
-       void (*disable_intrs) (struct scsi_qla_host *);
+       void (*enable_intrs) (struct qla_hw_data *);
+       void (*disable_intrs) (struct qla_hw_data *);
 
-       int (*abort_command) (struct scsi_qla_host *, srb_t *);
-       int (*abort_target) (struct fc_port *);
+       int (*abort_command) (srb_t *);
+       int (*target_reset) (struct fc_port *, unsigned int, int);
+       int (*lun_reset) (struct fc_port *, unsigned int, int);
        int (*fabric_login) (struct scsi_qla_host *, uint16_t, uint8_t,
                uint8_t, uint8_t, uint16_t *, uint8_t);
        int (*fabric_logout) (struct scsi_qla_host *, uint16_t, uint8_t,
@@ -2090,6 +2062,7 @@ struct isp_operations {
                uint32_t);
 
        int (*get_flash_version) (struct scsi_qla_host *, void *);
+       int (*start_scsi) (srb_t *);
 };
 
 /* MSI-X Support *************************************************************/
@@ -2101,16 +2074,17 @@ struct isp_operations {
 #define QLA_MSIX_DEFAULT       0x00
 #define QLA_MSIX_RSP_Q         0x01
 
-#define QLA_MSIX_ENTRIES       2
 #define QLA_MIDX_DEFAULT       0
 #define QLA_MIDX_RSP_Q         1
+#define QLA_PCI_MSIX_CONTROL   0xa2
 
 struct scsi_qla_host;
 
 struct qla_msix_entry {
        int have_irq;
-       uint16_t msix_vector;
-       uint16_t msix_entry;
+       uint32_t vector;
+       uint16_t entry;
+       struct rsp_que *rsp;
 };
 
 #define        WATCH_INTERVAL          1       /* number of seconds */
@@ -2118,7 +2092,7 @@ struct qla_msix_entry {
 /* Work events.  */
 enum qla_work_type {
        QLA_EVT_AEN,
-       QLA_EVT_HWE_LOG,
+       QLA_EVT_IDC_ACK,
 };
 
 
@@ -2134,207 +2108,175 @@ struct qla_work_evt {
                        u32 data;
                } aen;
                struct {
-                       uint16_t code;
-                       uint16_t d1, d2, d3;
-               } hwe;
+#define QLA_IDC_ACK_REGS       7
+                       uint16_t mb[QLA_IDC_ACK_REGS];
+               } idc_ack;
        } u;
 };
 
-/*
- * Linux Host Adapter structure
- */
-typedef struct scsi_qla_host {
+struct qla_chip_state_84xx {
        struct list_head list;
+       struct kref kref;
+
+       void *bus;
+       spinlock_t access_lock;
+       struct mutex fw_update_mutex;
+       uint32_t fw_update;
+       uint32_t op_fw_version;
+       uint32_t op_fw_size;
+       uint32_t op_fw_seq_size;
+       uint32_t diag_fw_version;
+       uint32_t gold_fw_version;
+};
 
-       /* Commonly used flags and state information. */
-       struct Scsi_Host *host;
-       struct pci_dev  *pdev;
+struct qla_statistics {
+       uint32_t total_isp_aborts;
+       uint64_t input_bytes;
+       uint64_t output_bytes;
+};
 
-       unsigned long   host_no;
-       unsigned long   instance;
+/* Multi queue support */
+#define MBC_INITIALIZE_MULTIQ 0x1f
+#define QLA_QUE_PAGE 0X1000
+#define QLA_MQ_SIZE 32
+#define QLA_MAX_QUEUES 256
+#define ISP_QUE_REG(ha, id) \
+       ((ha->mqenable) ? \
+       ((void *)(ha->mqiobase) +\
+       (QLA_QUE_PAGE * id)) :\
+       ((void *)(ha->iobase)))
+#define QLA_REQ_QUE_ID(tag) \
+       ((tag < QLA_MAX_QUEUES && tag > 0) ? tag : 0)
+#define QLA_DEFAULT_QUE_QOS 5
+#define QLA_PRECONFIG_VPORTS 32
+#define QLA_MAX_VPORTS_QLA24XX 128
+#define QLA_MAX_VPORTS_QLA25XX 256
+/* Response queue data structure */
+struct rsp_que {
+       dma_addr_t  dma;
+       response_t *ring;
+       response_t *ring_ptr;
+       uint32_t __iomem *rsp_q_in;     /* FWI2-capable only. */
+       uint32_t __iomem *rsp_q_out;
+       uint16_t  ring_index;
+       uint16_t  out_ptr;
+       uint16_t  length;
+       uint16_t  options;
+       uint16_t  rid;
+       uint16_t  id;
+       uint16_t  vp_idx;
+       struct qla_hw_data *hw;
+       struct qla_msix_entry *msix;
+       struct req_que *req;
+       srb_t *status_srb; /* status continuation entry */
+       struct work_struct q_work;
+};
+
+/* Request queue data structure */
+struct req_que {
+       dma_addr_t  dma;
+       request_t *ring;
+       request_t *ring_ptr;
+       uint32_t __iomem *req_q_in;     /* FWI2-capable only. */
+       uint32_t __iomem *req_q_out;
+       uint16_t  ring_index;
+       uint16_t  in_ptr;
+       uint16_t  cnt;
+       uint16_t  length;
+       uint16_t  options;
+       uint16_t  rid;
+       uint16_t  id;
+       uint16_t  qos;
+       uint16_t  vp_idx;
+       struct rsp_que *rsp;
+       srb_t *outstanding_cmds[MAX_OUTSTANDING_COMMANDS];
+       uint32_t current_outstanding_cmd;
+       int max_q_depth;
+};
+
+/*
+ * Qlogic host adapter specific data structure.
+*/
+struct qla_hw_data {
+       struct pci_dev  *pdev;
+       /* SRB cache. */
+#define SRB_MIN_REQ     128
+       mempool_t       *srb_mempool;
 
        volatile struct {
-               uint32_t        init_done               :1;
-               uint32_t        online                  :1;
                uint32_t        mbox_int                :1;
                uint32_t        mbox_busy               :1;
-               uint32_t        rscn_queue_overflow     :1;
-               uint32_t        reset_active            :1;
-
-               uint32_t        management_server_logged_in :1;
-                uint32_t       process_response_queue  :1;
 
                uint32_t        disable_risc_code_load  :1;
                uint32_t        enable_64bit_addressing :1;
                uint32_t        enable_lip_reset        :1;
-               uint32_t        enable_lip_full_login   :1;
                uint32_t        enable_target_reset     :1;
+               uint32_t        enable_lip_full_login   :1;
                uint32_t        enable_led_scheme       :1;
                uint32_t        inta_enabled            :1;
                uint32_t        msi_enabled             :1;
                uint32_t        msix_enabled            :1;
                uint32_t        disable_serdes          :1;
                uint32_t        gpsc_supported          :1;
-               uint32_t        vsan_enabled            :1;
                uint32_t        npiv_supported          :1;
                uint32_t        fce_enabled             :1;
-               uint32_t        hw_event_marker_found   :1;
+               uint32_t        fac_supported           :1;
+               uint32_t        chip_reset_done         :1;
+               uint32_t        port0                   :1;
+               uint32_t        running_gold_fw         :1;
        } flags;
 
-       atomic_t        loop_state;
-#define LOOP_TIMEOUT   1
-#define LOOP_DOWN      2
-#define LOOP_UP                3
-#define LOOP_UPDATE    4
-#define LOOP_READY     5
-#define LOOP_DEAD      6
-
-       unsigned long   dpc_flags;
-#define        RESET_MARKER_NEEDED     0       /* Send marker to ISP. */
-#define        RESET_ACTIVE            1
-#define        ISP_ABORT_NEEDED        2       /* Initiate ISP abort. */
-#define        ABORT_ISP_ACTIVE        3       /* ISP abort in progress. */
-#define        LOOP_RESYNC_NEEDED      4       /* Device Resync needed. */
-#define        LOOP_RESYNC_ACTIVE      5
-#define LOCAL_LOOP_UPDATE       6      /* Perform a local loop update. */
-#define RSCN_UPDATE             7      /* Perform an RSCN update. */
-#define MAILBOX_RETRY           8
-#define ISP_RESET_NEEDED        9      /* Initiate a ISP reset. */
-#define FAILOVER_EVENT_NEEDED   10
-#define FAILOVER_EVENT         11
-#define FAILOVER_NEEDED        12
-#define SCSI_RESTART_NEEDED    13      /* Processes SCSI retry queue. */
-#define PORT_RESTART_NEEDED    14      /* Processes Retry queue. */
-#define RESTART_QUEUES_NEEDED  15      /* Restarts the Lun queue. */
-#define ABORT_QUEUES_NEEDED    16
-#define RELOGIN_NEEDED         17
-#define LOGIN_RETRY_NEEDED     18      /* Initiate required fabric logins. */
-#define REGISTER_FC4_NEEDED    19      /* SNS FC4 registration required. */
-#define ISP_ABORT_RETRY         20      /* ISP aborted. */
-#define FCPORT_RESCAN_NEEDED   21      /* IO descriptor processing needed */
-#define IODESC_PROCESS_NEEDED  22      /* IO descriptor processing needed */
-#define IOCTL_ERROR_RECOVERY   23
-#define LOOP_RESET_NEEDED      24
-#define BEACON_BLINK_NEEDED    25
-#define REGISTER_FDMI_NEEDED   26
-#define FCPORT_UPDATE_NEEDED   27
-#define VP_DPC_NEEDED          28      /* wake up for VP dpc handling */
-
-       uint32_t        device_flags;
-#define DFLG_LOCAL_DEVICES             BIT_0
-#define DFLG_RETRY_LOCAL_DEVICES       BIT_1
-#define DFLG_FABRIC_DEVICES            BIT_2
-#define        SWITCH_FOUND                    BIT_3
-#define        DFLG_NO_CABLE                   BIT_4
-
-#define PCI_DEVICE_ID_QLOGIC_ISP2532   0x2532
-       uint32_t        device_type;
-#define DT_ISP2100                     BIT_0
-#define DT_ISP2200                     BIT_1
-#define DT_ISP2300                     BIT_2
-#define DT_ISP2312                     BIT_3
-#define DT_ISP2322                     BIT_4
-#define DT_ISP6312                     BIT_5
-#define DT_ISP6322                     BIT_6
-#define DT_ISP2422                     BIT_7
-#define DT_ISP2432                     BIT_8
-#define DT_ISP5422                     BIT_9
-#define DT_ISP5432                     BIT_10
-#define DT_ISP2532                     BIT_11
-#define DT_ISP_LAST                    (DT_ISP2532 << 1)
-
-#define DT_IIDMA                       BIT_26
-#define DT_FWI2                                BIT_27
-#define DT_ZIO_SUPPORTED               BIT_28
-#define DT_OEM_001                     BIT_29
-#define DT_ISP2200A                    BIT_30
-#define DT_EXTENDED_IDS                        BIT_31
-
-#define DT_MASK(ha)    ((ha)->device_type & (DT_ISP_LAST - 1))
-#define IS_QLA2100(ha) (DT_MASK(ha) & DT_ISP2100)
-#define IS_QLA2200(ha) (DT_MASK(ha) & DT_ISP2200)
-#define IS_QLA2300(ha) (DT_MASK(ha) & DT_ISP2300)
-#define IS_QLA2312(ha) (DT_MASK(ha) & DT_ISP2312)
-#define IS_QLA2322(ha) (DT_MASK(ha) & DT_ISP2322)
-#define IS_QLA6312(ha) (DT_MASK(ha) & DT_ISP6312)
-#define IS_QLA6322(ha) (DT_MASK(ha) & DT_ISP6322)
-#define IS_QLA2422(ha) (DT_MASK(ha) & DT_ISP2422)
-#define IS_QLA2432(ha) (DT_MASK(ha) & DT_ISP2432)
-#define IS_QLA5422(ha) (DT_MASK(ha) & DT_ISP5422)
-#define IS_QLA5432(ha) (DT_MASK(ha) & DT_ISP5432)
-#define IS_QLA2532(ha) (DT_MASK(ha) & DT_ISP2532)
-
-#define IS_QLA23XX(ha) (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \
-                        IS_QLA6312(ha) || IS_QLA6322(ha))
-#define IS_QLA24XX(ha) (IS_QLA2422(ha) || IS_QLA2432(ha))
-#define IS_QLA54XX(ha) (IS_QLA5422(ha) || IS_QLA5432(ha))
-#define IS_QLA25XX(ha) (IS_QLA2532(ha))
-
-#define IS_IIDMA_CAPABLE(ha)   ((ha)->device_type & DT_IIDMA)
-#define IS_FWI2_CAPABLE(ha)    ((ha)->device_type & DT_FWI2)
-#define IS_ZIO_SUPPORTED(ha)   ((ha)->device_type & DT_ZIO_SUPPORTED)
-#define IS_OEM_001(ha)         ((ha)->device_type & DT_OEM_001)
-#define HAS_EXTENDED_IDS(ha)   ((ha)->device_type & DT_EXTENDED_IDS)
-
-       /* SRB cache. */
-#define SRB_MIN_REQ    128
-       mempool_t       *srb_mempool;
-
        /* This spinlock is used to protect "io transactions", you must
-        * acquire it before doing any IO to the card, eg with RD_REG*() and
-        * WRT_REG*() for the duration of your entire commandtransaction.
-        *
-        * This spinlock is of lower priority than the io request lock.
-        */
-
-       spinlock_t              hardware_lock ____cacheline_aligned;
+       * acquire it before doing any IO to the card, eg with RD_REG*() and
+       * WRT_REG*() for the duration of your entire commandtransaction.
+       *
+       * This spinlock is of lower priority than the io request lock.
+       */
 
+       spinlock_t      hardware_lock ____cacheline_aligned;
        int             bars;
        int             mem_only;
-       device_reg_t __iomem *iobase;           /* Base I/O address */
+       device_reg_t __iomem *iobase;           /* Base I/O address */
        resource_size_t pio_address;
-#define MIN_IOBASE_LEN         0x100
-
-       /* ISP ring lock, rings, and indexes */
-       dma_addr_t      request_dma;        /* Physical address. */
-       request_t       *request_ring;      /* Base virtual address */
-       request_t       *request_ring_ptr;  /* Current address. */
-       uint16_t        req_ring_index;     /* Current index. */
-       uint16_t        req_q_cnt;          /* Number of available entries. */
-       uint16_t        request_q_length;
-
-       dma_addr_t      response_dma;       /* Physical address. */
-       response_t      *response_ring;     /* Base virtual address */
-       response_t      *response_ring_ptr; /* Current address. */
-       uint16_t        rsp_ring_index;     /* Current index. */
-       uint16_t        response_q_length;
 
-       struct isp_operations *isp_ops;
+#define MIN_IOBASE_LEN          0x100
+/* Multi queue data structs */
+       device_reg_t __iomem *mqiobase;
+       uint16_t        msix_count;
+       uint8_t         mqenable;
+       struct req_que **req_q_map;
+       struct rsp_que **rsp_q_map;
+       unsigned long req_qid_map[(QLA_MAX_QUEUES / 8) / sizeof(unsigned long)];
+       unsigned long rsp_qid_map[(QLA_MAX_QUEUES / 8) / sizeof(unsigned long)];
+       uint8_t         max_req_queues;
+       uint8_t         max_rsp_queues;
+       struct qla_npiv_entry *npiv_info;
+       uint16_t        nvram_npiv_size;
+
+       uint16_t        switch_cap;
+#define FLOGI_SEQ_DEL           BIT_8
+#define FLOGI_MID_SUPPORT       BIT_10
+#define FLOGI_VSAN_SUPPORT      BIT_12
+#define FLOGI_SP_SUPPORT        BIT_13
+
+       uint8_t         port_no;                /* Physical port of adapter */
 
-       /* Outstandings ISP commands. */
-       srb_t           *outstanding_cmds[MAX_OUTSTANDING_COMMANDS];
-       uint32_t        current_outstanding_cmd;
-       srb_t           *status_srb;    /* Status continuation entry. */
+       /* Timeout timers. */
+       uint8_t         loop_down_abort_time;    /* port down timer */
+       atomic_t        loop_down_timer;         /* loop down timer */
+       uint8_t         link_down_timeout;       /* link down timeout */
+       uint16_t        max_loop_id;
 
-       /* ISP configuration data. */
-       uint16_t        loop_id;                /* Host adapter loop id */
-       uint16_t        switch_cap;
-#define FLOGI_SEQ_DEL          BIT_8
-#define FLOGI_MID_SUPPORT      BIT_10
-#define FLOGI_VSAN_SUPPORT     BIT_12
-#define FLOGI_SP_SUPPORT       BIT_13
        uint16_t        fb_rev;
-
-       port_id_t       d_id;                   /* Host adapter port id */
-       uint16_t        max_public_loop_ids;
-       uint16_t        min_external_loopid;    /* First external loop Id */
+       uint16_t        min_external_loopid;    /* First external loop Id */
 
 #define PORT_SPEED_UNKNOWN 0xFFFF
-#define PORT_SPEED_1GB 0x00
-#define PORT_SPEED_2GB 0x01
-#define PORT_SPEED_4GB 0x03
-#define PORT_SPEED_8GB 0x04
-       uint16_t        link_data_rate;         /* F/W operating speed */
+#define PORT_SPEED_1GB  0x00
+#define PORT_SPEED_2GB  0x01
+#define PORT_SPEED_4GB  0x03
+#define PORT_SPEED_8GB  0x04
+#define PORT_SPEED_10GB        0x13
+       uint16_t        link_data_rate;         /* F/W operating speed */
 
        uint8_t         current_topology;
        uint8_t         prev_topology;
@@ -2343,15 +2285,77 @@ typedef struct scsi_qla_host {
 #define ISP_CFG_FL     4
 #define ISP_CFG_F      8
 
-       uint8_t         operating_mode;         /* F/W operating mode */
+       uint8_t         operating_mode;         /* F/W operating mode */
 #define LOOP      0
 #define P2P       1
 #define LOOP_P2P  2
 #define P2P_LOOP  3
-
-        uint8_t                marker_needed;
-
        uint8_t         interrupts_on;
+       uint32_t        isp_abort_cnt;
+
+#define PCI_DEVICE_ID_QLOGIC_ISP2532    0x2532
+#define PCI_DEVICE_ID_QLOGIC_ISP8432    0x8432
+#define PCI_DEVICE_ID_QLOGIC_ISP8001   0x8001
+       uint32_t        device_type;
+#define DT_ISP2100                      BIT_0
+#define DT_ISP2200                      BIT_1
+#define DT_ISP2300                      BIT_2
+#define DT_ISP2312                      BIT_3
+#define DT_ISP2322                      BIT_4
+#define DT_ISP6312                      BIT_5
+#define DT_ISP6322                      BIT_6
+#define DT_ISP2422                      BIT_7
+#define DT_ISP2432                      BIT_8
+#define DT_ISP5422                      BIT_9
+#define DT_ISP5432                      BIT_10
+#define DT_ISP2532                      BIT_11
+#define DT_ISP8432                      BIT_12
+#define DT_ISP8001                     BIT_13
+#define DT_ISP_LAST                    (DT_ISP8001 << 1)
+
+#define DT_IIDMA                        BIT_26
+#define DT_FWI2                         BIT_27
+#define DT_ZIO_SUPPORTED                BIT_28
+#define DT_OEM_001                      BIT_29
+#define DT_ISP2200A                     BIT_30
+#define DT_EXTENDED_IDS                 BIT_31
+#define DT_MASK(ha)     ((ha)->device_type & (DT_ISP_LAST - 1))
+#define IS_QLA2100(ha)  (DT_MASK(ha) & DT_ISP2100)
+#define IS_QLA2200(ha)  (DT_MASK(ha) & DT_ISP2200)
+#define IS_QLA2300(ha)  (DT_MASK(ha) & DT_ISP2300)
+#define IS_QLA2312(ha)  (DT_MASK(ha) & DT_ISP2312)
+#define IS_QLA2322(ha)  (DT_MASK(ha) & DT_ISP2322)
+#define IS_QLA6312(ha)  (DT_MASK(ha) & DT_ISP6312)
+#define IS_QLA6322(ha)  (DT_MASK(ha) & DT_ISP6322)
+#define IS_QLA2422(ha)  (DT_MASK(ha) & DT_ISP2422)
+#define IS_QLA2432(ha)  (DT_MASK(ha) & DT_ISP2432)
+#define IS_QLA5422(ha)  (DT_MASK(ha) & DT_ISP5422)
+#define IS_QLA5432(ha)  (DT_MASK(ha) & DT_ISP5432)
+#define IS_QLA2532(ha)  (DT_MASK(ha) & DT_ISP2532)
+#define IS_QLA8432(ha)  (DT_MASK(ha) & DT_ISP8432)
+#define IS_QLA8001(ha) (DT_MASK(ha) & DT_ISP8001)
+
+#define IS_QLA23XX(ha)  (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \
+                       IS_QLA6312(ha) || IS_QLA6322(ha))
+#define IS_QLA24XX(ha)  (IS_QLA2422(ha) || IS_QLA2432(ha))
+#define IS_QLA54XX(ha)  (IS_QLA5422(ha) || IS_QLA5432(ha))
+#define IS_QLA25XX(ha)  (IS_QLA2532(ha))
+#define IS_QLA84XX(ha)  (IS_QLA8432(ha))
+#define IS_QLA24XX_TYPE(ha)     (IS_QLA24XX(ha) || IS_QLA54XX(ha) || \
+                               IS_QLA84XX(ha))
+#define IS_QLA81XX(ha)         (IS_QLA8001(ha))
+#define IS_QLA2XXX_MIDTYPE(ha) (IS_QLA24XX(ha) || IS_QLA84XX(ha) || \
+                               IS_QLA25XX(ha) || IS_QLA81XX(ha))
+#define IS_NOPOLLING_TYPE(ha)  ((IS_QLA25XX(ha) || IS_QLA81XX(ha)) && \
+                               (ha)->flags.msix_enabled)
+#define IS_FAC_REQUIRED(ha)    (IS_QLA81XX(ha))
+#define IS_NOCACHE_VPD_TYPE(ha)        (IS_QLA81XX(ha))
+
+#define IS_IIDMA_CAPABLE(ha)    ((ha)->device_type & DT_IIDMA)
+#define IS_FWI2_CAPABLE(ha)     ((ha)->device_type & DT_FWI2)
+#define IS_ZIO_SUPPORTED(ha)    ((ha)->device_type & DT_ZIO_SUPPORTED)
+#define IS_OEM_001(ha)          ((ha)->device_type & DT_OEM_001)
+#define HAS_EXTENDED_IDS(ha)    ((ha)->device_type & DT_EXTENDED_IDS)
 
        /* HBA serial number */
        uint8_t         serial0;
@@ -2359,8 +2363,8 @@ typedef struct scsi_qla_host {
        uint8_t         serial2;
 
        /* NVRAM configuration data */
-#define MAX_NVRAM_SIZE 4096
-#define VPD_OFFSET     MAX_NVRAM_SIZE / 2
+#define MAX_NVRAM_SIZE  4096
+#define VPD_OFFSET      MAX_NVRAM_SIZE / 2
        uint16_t        nvram_size;
        uint16_t        nvram_base;
        void            *nvram;
@@ -2374,22 +2378,8 @@ typedef struct scsi_qla_host {
        uint16_t        r_a_tov;
        int             port_down_retry_count;
        uint8_t         mbx_count;
-       uint16_t        last_loop_id;
-       uint16_t        mgmt_svr_loop_id;
-
-        uint32_t       login_retry_count;
-       int             max_q_depth;
-
-       struct list_head        work_list;
-
-       /* Fibre Channel Device List. */
-       struct list_head        fcports;
-
-       /* RSCN queue. */
-       uint32_t rscn_queue[MAX_RSCN_COUNT];
-       uint8_t rscn_in_ptr;
-       uint8_t rscn_out_ptr;
 
+       uint32_t        login_retry_count;
        /* SNS command interfaces. */
        ms_iocb_entry_t         *ms_iocb;
        dma_addr_t              ms_iocb_dma;
@@ -2399,58 +2389,53 @@ typedef struct scsi_qla_host {
        struct sns_cmd_pkt      *sns_cmd;
        dma_addr_t              sns_cmd_dma;
 
-#define SFP_DEV_SIZE   256
-#define SFP_BLOCK_SIZE 64
-       void                    *sfp_data;
-       dma_addr_t              sfp_data_dma;
+#define SFP_DEV_SIZE    256
+#define SFP_BLOCK_SIZE  64
+       void            *sfp_data;
+       dma_addr_t      sfp_data_dma;
 
-       struct task_struct      *dpc_thread;
-       uint8_t dpc_active;                  /* DPC routine is active */
+       uint8_t         *edc_data;
+       dma_addr_t      edc_data_dma;
+       uint16_t        edc_data_len;
 
-       /* Timeout timers. */
-       uint8_t         loop_down_abort_time;    /* port down timer */
-       atomic_t        loop_down_timer;         /* loop down timer */
-       uint8_t         link_down_timeout;       /* link down timeout */
+#define XGMAC_DATA_SIZE        PAGE_SIZE
+       void            *xgmac_data;
+       dma_addr_t      xgmac_data_dma;
 
-       uint32_t        timer_active;
-       struct timer_list        timer;
+#define DCBX_TLV_DATA_SIZE PAGE_SIZE
+       void            *dcbx_tlv;
+       dma_addr_t      dcbx_tlv_dma;
+
+       struct task_struct      *dpc_thread;
+       uint8_t dpc_active;                  /* DPC routine is active */
 
        dma_addr_t      gid_list_dma;
        struct gid_list_info *gid_list;
        int             gid_list_info_size;
 
        /* Small DMA pool allocations -- maximum 256 bytes in length. */
-#define DMA_POOL_SIZE  256
+#define DMA_POOL_SIZE   256
        struct dma_pool *s_dma_pool;
 
        dma_addr_t      init_cb_dma;
        init_cb_t       *init_cb;
        int             init_cb_size;
+       dma_addr_t      ex_init_cb_dma;
+       struct ex_init_cb_81xx *ex_init_cb;
 
        /* These are used by mailbox operations. */
        volatile uint16_t mailbox_out[MAILBOX_REGISTER_COUNT];
 
        mbx_cmd_t       *mcp;
        unsigned long   mbx_cmd_flags;
-#define MBX_INTERRUPT  1
-#define MBX_INTR_WAIT  2
+#define MBX_INTERRUPT          1
+#define MBX_INTR_WAIT          2
 #define MBX_UPDATE_FLASH_ACTIVE        3
 
-       struct semaphore vport_sem;     /* Virtual port synchronization */
-       struct completion mbx_cmd_comp; /* Serialize mbx access */
+       struct mutex vport_lock;        /* Virtual port synchronization */
+       struct completion mbx_cmd_comp; /* Serialize mbx access */
        struct completion mbx_intr_comp;  /* Used for completion notification */
 
-       uint32_t        mbx_flags;
-#define  MBX_IN_PROGRESS       BIT_0
-#define  MBX_BUSY              BIT_1   /* Got the Access */
-#define  MBX_SLEEPING_ON_SEM   BIT_2
-#define  MBX_POLLING_FOR_COMP  BIT_3
-#define  MBX_COMPLETED         BIT_4
-#define  MBX_TIMEDOUT          BIT_5
-#define  MBX_ACCESS_TIMEDOUT   BIT_6
-
-       mbx_cmd_t       mc;
-
        /* Basic firmware related information. */
        uint16_t        fw_major_version;
        uint16_t        fw_minor_version;
@@ -2462,11 +2447,16 @@ typedef struct scsi_qla_host {
 #define RISC_START_ADDRESS_2100 0x1000
 #define RISC_START_ADDRESS_2300 0x800
 #define RISC_START_ADDRESS_2400 0x100000
+       uint16_t        fw_xcb_count;
 
-       uint16_t        fw_options[16];         /* slots: 1,2,3,10,11 */
+       uint16_t        fw_options[16];         /* slots: 1,2,3,10,11 */
        uint8_t         fw_seriallink_options[4];
        uint16_t        fw_seriallink_options24[4];
 
+       uint8_t         mpi_version[3];
+       uint32_t        mpi_capabilities;
+       uint8_t         phy_version[3];
+
        /* Firmware dump information. */
        struct qla2xxx_fw_dump *fw_dump;
        uint32_t        fw_dump_len;
@@ -2475,6 +2465,7 @@ typedef struct scsi_qla_host {
        dma_addr_t      eft_dma;
        void            *eft;
 
+       uint32_t        chain_offset;
        struct dentry *dfs_dir;
        struct dentry *dfs_fce;
        dma_addr_t      fce_dma;
@@ -2484,11 +2475,6 @@ typedef struct scsi_qla_host {
        uint64_t        fce_wr, fce_rd;
        struct mutex    fce_mutex;
 
-       uint32_t        hw_event_start;
-       uint32_t        hw_event_ptr;
-       uint32_t        hw_event_pause_errors;
-
-       uint8_t         host_str[16];
        uint32_t        pci_attr;
        uint16_t        chip_revision;
 
@@ -2496,14 +2482,9 @@ typedef struct scsi_qla_host {
 
        uint8_t         model_number[16+1];
 #define BINZERO                "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-       char            *model_desc;
+       char            model_desc[80];
        uint8_t         adapter_id[16+1];
 
-       uint8_t         *node_name;
-       uint8_t         *port_name;
-       uint8_t         fabric_node_name[WWN_SIZE];
-       uint32_t    isp_abort_cnt;
-
        /* Option ROM information. */
        char            *optrom_buffer;
        uint32_t        optrom_size;
@@ -2514,40 +2495,156 @@ typedef struct scsi_qla_host {
        uint32_t        optrom_region_start;
        uint32_t        optrom_region_size;
 
-        /* PCI expansion ROM image information. */
+/* PCI expansion ROM image information. */
 #define ROM_CODE_TYPE_BIOS     0
 #define ROM_CODE_TYPE_FCODE    1
 #define ROM_CODE_TYPE_EFI      3
-       uint8_t         bios_revision[2];
-       uint8_t         efi_revision[2];
-       uint8_t         fcode_revision[16];
+       uint8_t         bios_revision[2];
+       uint8_t         efi_revision[2];
+       uint8_t         fcode_revision[16];
        uint32_t        fw_revision[4];
 
+       /* Offsets for flash/nvram access (set to ~0 if not used). */
+       uint32_t        flash_conf_off;
+       uint32_t        flash_data_off;
+       uint32_t        nvram_conf_off;
+       uint32_t        nvram_data_off;
+
+       uint32_t        fdt_wrt_disable;
+       uint32_t        fdt_erase_cmd;
+       uint32_t        fdt_block_size;
+       uint32_t        fdt_unprotect_sec_cmd;
+       uint32_t        fdt_protect_sec_cmd;
+
+       uint32_t        flt_region_flt;
+       uint32_t        flt_region_fdt;
+       uint32_t        flt_region_boot;
+       uint32_t        flt_region_fw;
+       uint32_t        flt_region_vpd_nvram;
+       uint32_t        flt_region_vpd;
+       uint32_t        flt_region_nvram;
+       uint32_t        flt_region_npiv_conf;
+       uint32_t        flt_region_gold_fw;
+
        /* Needed for BEACON */
-       uint16_t        beacon_blink_led;
-       uint8_t         beacon_color_state;
+       uint16_t        beacon_blink_led;
+       uint8_t         beacon_color_state;
 #define QLA_LED_GRN_ON         0x01
 #define QLA_LED_YLW_ON         0x02
 #define QLA_LED_ABR_ON         0x04
 #define QLA_LED_ALL_ON         0x07    /* yellow, green, amber. */
                                        /* ISP2322: red, green, amber. */
-
-       uint16_t        zio_mode;
-       uint16_t        zio_timer;
+       uint16_t        zio_mode;
+       uint16_t        zio_timer;
        struct fc_host_statistics fc_host_stat;
 
-       struct qla_msix_entry msix_entries[QLA_MSIX_ENTRIES];
+       struct qla_msix_entry *msix_entries;
+
+       struct list_head        vp_list;        /* list of VP */
+       unsigned long   vp_idx_map[(MAX_MULTI_ID_FABRIC / 8) /
+                       sizeof(unsigned long)];
+       uint16_t        num_vhosts;     /* number of vports created */
+       uint16_t        num_vsans;      /* number of vsan created */
+       uint16_t        max_npiv_vports;        /* 63 or 125 per topoloty */
+       int             cur_vport_count;
+
+       struct qla_chip_state_84xx *cs84xx;
+       struct qla_statistics qla_stats;
+       struct isp_operations *isp_ops;
+       struct workqueue_struct *wq;
+};
+
+/*
+ * Qlogic scsi host structure
+ */
+typedef struct scsi_qla_host {
+       struct list_head list;
+       struct list_head vp_fcports;    /* list of fcports */
+       struct list_head work_list;
+       spinlock_t work_lock;
+
+       /* Commonly used flags and state information. */
+       struct Scsi_Host *host;
+       unsigned long   host_no;
+       uint8_t         host_str[16];
+
+       volatile struct {
+               uint32_t        init_done               :1;
+               uint32_t        online                  :1;
+               uint32_t        rscn_queue_overflow     :1;
+               uint32_t        reset_active            :1;
+
+               uint32_t        management_server_logged_in :1;
+               uint32_t        process_response_queue  :1;
+       } flags;
+
+       atomic_t        loop_state;
+#define LOOP_TIMEOUT   1
+#define LOOP_DOWN      2
+#define LOOP_UP                3
+#define LOOP_UPDATE    4
+#define LOOP_READY     5
+#define LOOP_DEAD      6
+
+       unsigned long   dpc_flags;
+#define RESET_MARKER_NEEDED    0       /* Send marker to ISP. */
+#define RESET_ACTIVE           1
+#define ISP_ABORT_NEEDED       2       /* Initiate ISP abort. */
+#define ABORT_ISP_ACTIVE       3       /* ISP abort in progress. */
+#define LOOP_RESYNC_NEEDED     4       /* Device Resync needed. */
+#define LOOP_RESYNC_ACTIVE     5
+#define LOCAL_LOOP_UPDATE      6       /* Perform a local loop update. */
+#define RSCN_UPDATE            7       /* Perform an RSCN update. */
+#define RELOGIN_NEEDED         8
+#define REGISTER_FC4_NEEDED    9       /* SNS FC4 registration required. */
+#define ISP_ABORT_RETRY                10      /* ISP aborted. */
+#define BEACON_BLINK_NEEDED    11
+#define REGISTER_FDMI_NEEDED   12
+#define FCPORT_UPDATE_NEEDED   13
+#define VP_DPC_NEEDED          14      /* wake up for VP dpc handling */
+#define UNLOADING              15
+#define NPIV_CONFIG_NEEDED     16
+
+       uint32_t        device_flags;
+#define SWITCH_FOUND           BIT_0
+#define DFLG_NO_CABLE          BIT_1
+
+       /* ISP configuration data. */
+       uint16_t        loop_id;                /* Host adapter loop id */
+
+       port_id_t       d_id;                   /* Host adapter port id */
+       uint8_t         marker_needed;
+       uint16_t        mgmt_svr_loop_id;
+
+
+
+       /* RSCN queue. */
+       uint32_t rscn_queue[MAX_RSCN_COUNT];
+       uint8_t rscn_in_ptr;
+       uint8_t rscn_out_ptr;
+
+       /* Timeout timers. */
+       uint8_t         loop_down_abort_time;    /* port down timer */
+       atomic_t        loop_down_timer;         /* loop down timer */
+       uint8_t         link_down_timeout;       /* link down timeout */
+
+       uint32_t        timer_active;
+       struct timer_list        timer;
+
+       uint8_t         node_name[WWN_SIZE];
+       uint8_t         port_name[WWN_SIZE];
+       uint8_t         fabric_node_name[WWN_SIZE];
+
+       uint16_t        fcoe_vlan_id;
+       uint16_t        fcoe_fcf_idx;
+       uint8_t         fcoe_vn_port_mac[6];
+
+       uint32_t        vp_abort_cnt;
 
-       struct list_head        vp_list;        /* list of VP */
        struct fc_vport *fc_vport;      /* holds fc_vport * for each vport */
-       unsigned long   vp_idx_map[(MAX_MULTI_ID_FABRIC / 8) / sizeof(unsigned long)];
-       uint16_t        num_vhosts;     /* number of vports created */
-       uint16_t        num_vsans;      /* number of vsan created */
        uint16_t        vp_idx;         /* vport ID */
 
-       struct scsi_qla_host    *parent;        /* holds pport */
        unsigned long           vp_flags;
-       struct list_head        vp_fcports;     /* list of fcports */
 #define VP_IDX_ACQUIRED                0       /* bit no 0 */
 #define VP_CREATE_NEEDED       1
 #define VP_BIND_NEEDED         2
@@ -2566,11 +2663,10 @@ typedef struct scsi_qla_host {
 #define VP_ERR_FAB_NORESOURCES 3
 #define VP_ERR_FAB_LOGOUT      4
 #define VP_ERR_ADAP_NORESOURCES        5
-       uint16_t        max_npiv_vports;        /* 63 or 125 per topoloty */
-       int             cur_vport_count;
+       struct qla_hw_data *hw;
+       struct req_que *req;
 } scsi_qla_host_t;
 
-
 /*
  * Macros to help code, maintain, etc.
  */
@@ -2620,16 +2716,12 @@ typedef struct scsi_qla_host {
 #define OPTROM_SIZE_2322       0x100000
 #define OPTROM_SIZE_24XX       0x100000
 #define OPTROM_SIZE_25XX       0x200000
+#define OPTROM_SIZE_81XX       0x400000
 
 #include "qla_gbl.h"
 #include "qla_dbg.h"
 #include "qla_inline.h"
 
 #define CMD_SP(Cmnd)           ((Cmnd)->SCp.ptr)
-#define CMD_COMPL_STATUS(Cmnd)  ((Cmnd)->SCp.this_residual)
-#define CMD_RESID_LEN(Cmnd)    ((Cmnd)->SCp.buffers_residual)
-#define CMD_SCSI_STATUS(Cmnd)  ((Cmnd)->SCp.Status)
-#define CMD_ACTUAL_SNSLEN(Cmnd)        ((Cmnd)->SCp.Message)
-#define CMD_ENTRY_STATUS(Cmnd) ((Cmnd)->SCp.have_data_in)
 
 #endif