[SCSI] qla2xxx: Add ISP25XX support.
[safe/jmp/linux-2.6] / drivers / scsi / qla2xxx / qla_def.h
index bad066e..0c9f36c 100644 (file)
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_transport_fc.h>
 
-#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE)
-#if defined(CONFIG_SCSI_QLA21XX) || defined(CONFIG_SCSI_QLA21XX_MODULE)
-#define IS_QLA2100(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2100)
-#else
-#define IS_QLA2100(ha) 0
-#endif
-
-#if defined(CONFIG_SCSI_QLA22XX) || defined(CONFIG_SCSI_QLA22XX_MODULE)
-#define IS_QLA2200(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2200)
-#else
-#define IS_QLA2200(ha) 0
-#endif
-
-#if defined(CONFIG_SCSI_QLA2300) || defined(CONFIG_SCSI_QLA2300_MODULE)
-#define IS_QLA2300(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2300)
-#define IS_QLA2312(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2312)
-#else
-#define IS_QLA2300(ha) 0
-#define IS_QLA2312(ha) 0
-#endif
-
-#if defined(CONFIG_SCSI_QLA2322) || defined(CONFIG_SCSI_QLA2322_MODULE)
-#define IS_QLA2322(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2322)
-#else
-#define IS_QLA2322(ha) 0
-#endif
-
-#if defined(CONFIG_SCSI_QLA6312) || defined(CONFIG_SCSI_QLA6312_MODULE)
-#define IS_QLA6312(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP6312)
-#define IS_QLA6322(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP6322)
-#else
-#define IS_QLA6312(ha) 0
-#define IS_QLA6322(ha) 0
-#endif
-
-#if defined(CONFIG_SCSI_QLA24XX) || defined(CONFIG_SCSI_QLA24XX_MODULE)
-#define IS_QLA2422(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422)
-#define IS_QLA2432(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432)
-#else
-#define IS_QLA2422(ha) 0
-#define IS_QLA2432(ha) 0
-#endif
-
-#if defined(CONFIG_SCSI_QLA25XX) || defined(CONFIG_SCSI_QLA25XX_MODULE)
-#define IS_QLA2512(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2512)
-#define IS_QLA2522(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2522)
-#else
-#define IS_QLA2512(ha) 0
-#define IS_QLA2522(ha) 0
-#endif
-
-#else  /* !defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) */
-
-#define IS_QLA2100(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2100)
-#define IS_QLA2200(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2200)
-#define IS_QLA2300(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2300)
-#define IS_QLA2312(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2312)
-#define IS_QLA2322(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2322)
-#define IS_QLA6312(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP6312)
-#define IS_QLA6322(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP6322)
-#define IS_QLA2422(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422)
-#define IS_QLA2432(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432)
-#define IS_QLA2512(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2512)
-#define IS_QLA2522(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2522)
-#endif
-
-#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_QLA25XX(ha) (IS_QLA2512(ha) || IS_QLA2522(ha))
-
-/*
- * Only non-ISP2[12]00 have extended addressing support in the firmware.
- */
-#define HAS_EXTENDED_IDS(ha)   (!IS_QLA2100(ha) && !IS_QLA2200(ha))
+#define QLA2XXX_DRIVER_NAME  "qla2xxx"
 
 /*
  * We have MAILBOX_REGISTER_COUNT sized arrays in a few places,
 #define WRT_REG_DWORD(addr, data)      writel(data,addr)
 
 /*
+ * The ISP2312 v2 chip cannot access the FLASH/GPIO registers via MMIO in an
+ * 133Mhz slot.
+ */
+#define RD_REG_WORD_PIO(addr)          (inw((unsigned long)addr))
+#define WRT_REG_WORD_PIO(addr, data)   (outw(data,(unsigned long)addr))
+
+/*
  * Fibre Channel device definitions.
  */
 #define WWN_SIZE               8       /* Size of WWPN, WWN & WWNN */
@@ -257,22 +191,13 @@ typedef struct srb {
 
        struct scsi_cmnd *cmd;          /* Linux SCSI command pkt */
 
-       struct timer_list timer;        /* Command timer */
-       atomic_t ref_count;     /* Reference count for this structure */
        uint16_t flags;
 
-       /* Request state */
-       uint16_t state;
-
        /* Single transfer DMA context */
        dma_addr_t dma_handle;
 
        uint32_t request_sense_length;
        uint8_t *request_sense_ptr;
-
-       /* SRB magic number */
-       uint16_t magic;
-#define SRB_MAGIC       0x10CB
 } srb_t;
 
 /*
@@ -294,21 +219,6 @@ typedef struct srb {
 #define SRB_TAPE               BIT_11  /* FCP2 (Tape) command. */
 
 /*
- * SRB state definitions
- */
-#define SRB_FREE_STATE         0       /*   returned back */
-#define SRB_PENDING_STATE      1       /*   queued in LUN Q */
-#define SRB_ACTIVE_STATE       2       /*   in Active Array */
-#define SRB_DONE_STATE         3       /*   queued in Done Queue */
-#define SRB_RETRY_STATE                4       /*   in Retry Queue */
-#define SRB_SUSPENDED_STATE    5       /*   in suspended state */
-#define SRB_NO_QUEUE_STATE     6       /*   is in between states */
-#define SRB_ACTIVE_TIMEOUT_STATE 7     /*   in Active Array but timed out */
-#define SRB_FAILOVER_STATE     8       /*   in Failover Queue */
-#define SRB_SCSI_RETRY_STATE   9       /*   in Scsi Retry Queue */
-
-
-/*
  * ISP I/O Register Set structure definitions.
  */
 struct device_reg_2xxx {
@@ -338,6 +248,8 @@ struct device_reg_2xxx {
 #define NVR_SELECT             BIT_1
 #define NVR_CLOCK              BIT_0
 
+#define NVR_WAIT_CNT           20000
+
        union {
                struct {
                        uint16_t mailbox0;
@@ -432,6 +344,9 @@ struct device_reg_2xxx {
 #define GPIO_LED_GREEN_ON_AMBER_OFF    0x0040
 #define GPIO_LED_GREEN_OFF_AMBER_ON    0x0080
 #define GPIO_LED_GREEN_ON_AMBER_ON     0x00C0
+#define GPIO_LED_ALL_OFF               0x0000
+#define GPIO_LED_RED_ON_OTHER_OFF      0x0001  /* isp2322 */
+#define GPIO_LED_RGA_ON                        0x00C1  /* isp2322: red green amber */
 
        union {
                struct {
@@ -572,6 +487,7 @@ typedef struct {
 #define MBA_IP_RCV_BUFFER_EMPTY 0x8026 /* IP receive buffer queue empty. */
 #define MBA_IP_HDR_DATA_SPLIT  0x8027  /* IP header/data splitting feature */
                                        /* used. */
+#define MBA_TRACE_NOTIFICATION 0x8028  /* Trace/Diagnostic notification. */
 #define MBA_POINT_TO_POINT     0x8030  /* Point to point mode. */
 #define MBA_CMPLT_1_16BIT      0x8031  /* Completion 1 16bit IOSB. */
 #define MBA_CMPLT_2_16BIT      0x8032  /* Completion 2 16bit IOSB. */
@@ -692,8 +608,11 @@ typedef struct {
  */
 #define MBC_SERDES_PARAMS              0x10    /* Serdes Tx Parameters. */
 #define MBC_GET_IOCB_STATUS            0x12    /* Get IOCB status command. */
+#define MBC_PORT_PARAMS                        0x1A    /* Port iDMA Parameters. */
 #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_READ_SFP                   0x31    /* Read SFP Data. */
 #define MBC_SET_TIMEOUT_PARAMS         0x32    /* Set FW timeouts. */
 #define MBC_MID_INITIALIZE_FIRMWARE    0x48    /* MID Initialize firmware. */
 #define MBC_MID_GET_VP_DATABASE                0x49    /* MID Get VP Database. */
@@ -703,6 +622,9 @@ typedef struct {
 #define MBC_GET_LINK_PRIV_STATS                0x6d    /* Get link & private data. */
 #define MBC_SET_VENDOR_ID              0x76    /* Set Vendor ID. */
 
+#define TC_ENABLE                      4
+#define TC_DISABLE                     5
+
 /* Firmware return data sizes */
 #define FCAL_MAP_SIZE  128
 
@@ -827,7 +749,6 @@ typedef struct {
 #define PD_STATE_WAIT_PORT_LOGOUT_ACK          11
 
 
-#define QLA_ZIO_MODE_5         (BIT_2 | BIT_0)
 #define QLA_ZIO_MODE_6         (BIT_2 | BIT_1)
 #define QLA_ZIO_DISABLED       0
 #define QLA_ZIO_DEFAULT_TIMER  2
@@ -1557,14 +1478,17 @@ typedef union {
        uint32_t b24 : 24;
 
        struct {
-               uint8_t d_id[3];
-               uint8_t rsvd_1;
-       } r;
-
-       struct {
+#ifdef __BIG_ENDIAN
+               uint8_t domain;
+               uint8_t area;
+               uint8_t al_pa;
+#elif __LITTLE_ENDIAN
                uint8_t al_pa;
                uint8_t area;
                uint8_t domain;
+#else
+#error "__BIG_ENDIAN or __LITTLE_ENDIAN must be defined!"
+#endif
                uint8_t rsvd_1;
        } b;
 } port_id_t;
@@ -1577,65 +1501,12 @@ typedef struct {
        port_id_t d_id;
        uint8_t node_name[WWN_SIZE];
        uint8_t port_name[WWN_SIZE];
+       uint8_t fabric_port_name[WWN_SIZE];
+       uint16_t fp_speeds;
+       uint16_t fp_speed;
 } sw_info_t;
 
 /*
- * Inquiry command structure.
- */
-#define INQ_DATA_SIZE  36
-
-/*
- * Inquiry mailbox IOCB packet definition.
- */
-typedef struct {
-       union {
-               cmd_a64_entry_t cmd;
-               sts_entry_t rsp;
-               struct cmd_type_7 cmd24;
-               struct sts_entry_24xx rsp24;
-       } p;
-       uint8_t inq[INQ_DATA_SIZE];
-} inq_cmd_rsp_t;
-
-/*
- * Report LUN command structure.
- */
-#define CHAR_TO_SHORT(a, b)    (uint16_t)((uint8_t)b << 8 | (uint8_t)a)
-
-typedef struct {
-       uint32_t len;
-       uint32_t rsrv;
-} rpt_hdr_t;
-
-typedef struct {
-       struct {
-               uint8_t b : 6;
-               uint8_t address_method : 2;
-       } msb;
-       uint8_t lsb;
-       uint8_t unused[6];
-} rpt_lun_t;
-
-typedef struct {
-       rpt_hdr_t hdr;
-       rpt_lun_t lst[MAX_LUNS];
-} rpt_lun_lst_t;
-
-/*
- * Report Lun mailbox IOCB packet definition.
- */
-typedef struct {
-       union {
-               cmd_a64_entry_t cmd;
-               sts_entry_t rsp;
-               struct cmd_type_7 cmd24;
-               struct sts_entry_24xx rsp24;
-       } p;
-       rpt_lun_lst_t list;
-} rpt_lun_cmd_rsp_t;
-
-
-/*
  * Fibre channel port type.
  */
  typedef enum {
@@ -1653,7 +1524,6 @@ typedef struct {
 typedef struct fc_port {
        struct list_head list;
        struct scsi_qla_host *ha;
-       struct scsi_qla_host *vis_ha;   /* only used when suspending lun */
 
        uint8_t node_name[WWN_SIZE];
        uint8_t port_name[WWN_SIZE];
@@ -1661,6 +1531,9 @@ typedef struct fc_port {
        uint16_t loop_id;
        uint16_t old_loop_id;
 
+       uint8_t fabric_port_name[WWN_SIZE];
+       uint16_t fp_speed;
+
        fc_port_type_t port_type;
 
        atomic_t state;
@@ -1668,23 +1541,19 @@ typedef struct fc_port {
 
        unsigned int os_target_id;
 
-       uint16_t iodesc_idx_sent;
-
        int port_login_retry_count;
        int login_retry;
        atomic_t port_down_timer;
 
-       uint8_t device_type;
-       uint8_t unused;
-
-       uint8_t mp_byte;                /* multi-path byte (not used) */
-       uint8_t cur_path;               /* current path id */
-
        spinlock_t rport_lock;
        struct fc_rport *rport, *drport;
        u32 supported_classes;
-       struct work_struct rport_add_work;
-       struct work_struct rport_del_work;
+
+       unsigned long last_queue_full;
+       unsigned long last_ramp_up;
+
+       struct list_head vp_fcport;
+       uint16_t vp_idx;
 } fc_port_t;
 
 /*
@@ -1739,6 +1608,7 @@ typedef struct fc_port {
 
 #define CT_REJECT_RESPONSE     0x8001
 #define CT_ACCEPT_RESPONSE     0x8002
+#define CT_REASON_INVALID_COMMAND_CODE 0x01
 #define CT_REASON_CANNOT_PERFORM       0x09
 #define CT_EXPL_ALREADY_REGISTERED     0x10
 
@@ -1782,6 +1652,15 @@ typedef struct fc_port {
 #define        RSNN_NN_REQ_SIZE (16 + 8 + 1 + 255)
 #define        RSNN_NN_RSP_SIZE 16
 
+#define        GFPN_ID_CMD     0x11C
+#define        GFPN_ID_REQ_SIZE (16 + 4)
+#define        GFPN_ID_RSP_SIZE (16 + 8)
+
+#define        GPSC_CMD        0x127
+#define        GPSC_REQ_SIZE   (16 + 8)
+#define        GPSC_RSP_SIZE   (16 + 2 + 2)
+
+
 /*
  * HBA attribute types.
  */
@@ -1832,6 +1711,14 @@ struct ct_fdmi_hba_attributes {
 #define FDMI_PORT_OS_DEVICE_NAME       5
 #define FDMI_PORT_HOST_NAME            6
 
+#define FDMI_PORT_SPEED_1GB            0x1
+#define FDMI_PORT_SPEED_2GB            0x2
+#define FDMI_PORT_SPEED_10GB           0x4
+#define FDMI_PORT_SPEED_4GB            0x8
+#define FDMI_PORT_SPEED_8GB            0x10
+#define FDMI_PORT_SPEED_16GB           0x20
+#define FDMI_PORT_SPEED_UNKNOWN                0x8000
+
 struct ct_fdmi_port_attr {
        uint16_t type;
        uint16_t len;
@@ -1895,7 +1782,7 @@ struct ct_sns_req {
        uint8_t reserved[3];
 
        union {
-               /* GA_NXT, GPN_ID, GNN_ID, GFT_ID */
+               /* GA_NXT, GPN_ID, GNN_ID, GFT_ID, GFPN_ID */
                struct {
                        uint8_t reserved;
                        uint8_t port_id[3];
@@ -1970,6 +1857,10 @@ struct ct_sns_req {
                struct {
                        uint8_t port_name[8];
                } dpa;
+
+               struct {
+                       uint8_t port_name[8];
+               } gpsc;
        } req;
 };
 
@@ -2033,6 +1924,15 @@ struct ct_sns_rsp {
                        uint8_t port_name[8];
                        struct ct_fdmi_hba_attributes attrs;
                } ghat;
+
+               struct {
+                       uint8_t port_name[8];
+               } gfpn_id;
+
+               struct {
+                       uint16_t speeds;
+                       uint16_t speed;
+               } gpsc;
        } rsp;
 };
 
@@ -2093,54 +1993,6 @@ struct sns_cmd_pkt {
        } p;
 };
 
-/* IO descriptors */
-#define MAX_IO_DESCRIPTORS     32
-
-#define ABORT_IOCB_CB          0
-#define ADISC_PORT_IOCB_CB     1
-#define LOGOUT_PORT_IOCB_CB    2
-#define LOGIN_PORT_IOCB_CB     3
-#define LAST_IOCB_CB           4
-
-#define IODESC_INVALID_INDEX   0xFFFF
-#define IODESC_ADISC_NEEDED    0xFFFE
-#define IODESC_LOGIN_NEEDED    0xFFFD
-
-struct io_descriptor {
-       uint16_t used:1;
-       uint16_t idx:11;
-       uint16_t cb_idx:4;
-
-       struct timer_list timer;
-
-       struct scsi_qla_host *ha;
-
-       port_id_t d_id;
-       fc_port_t *remote_fcport;
-
-       uint32_t signature;
-};
-
-struct qla_fw_info {
-       unsigned short addressing;      /* addressing method used to load fw */
-#define FW_INFO_ADDR_NORMAL    0
-#define FW_INFO_ADDR_EXTENDED  1
-#define FW_INFO_ADDR_NOMORE    0xffff
-       unsigned short *fwcode;         /* pointer to FW array */
-       unsigned short *fwlen;          /* number of words in array */
-       unsigned short *fwstart;        /* start address for F/W */
-       unsigned long *lfwstart;        /* start address (long) for F/W */
-};
-
-struct qla_board_info {
-       char *drv_name;
-
-       char isp_name[8];
-       struct qla_fw_info *fw_info;
-       char *fw_fname;
-       struct scsi_host_template *sht;
-};
-
 struct fw_blob {
        char *name;
        uint32_t segs[4];
@@ -2158,6 +2010,36 @@ struct gid_list_info {
 };
 #define GID_LIST_SIZE (sizeof(struct gid_list_info) * MAX_FIBRE_DEVICES)
 
+/* NPIV */
+typedef struct vport_info {
+       uint8_t         port_name[WWN_SIZE];
+       uint8_t         node_name[WWN_SIZE];
+       int             vp_id;
+       uint16_t        loop_id;
+       unsigned long   host_no;
+       uint8_t         port_id[3];
+       int             loop_state;
+} vport_info_t;
+
+typedef struct vport_params {
+       uint8_t         port_name[WWN_SIZE];
+       uint8_t         node_name[WWN_SIZE];
+       uint32_t        options;
+#define        VP_OPTS_RETRY_ENABLE    BIT_0
+#define        VP_OPTS_VP_DISABLE      BIT_1
+} vport_params_t;
+
+/* NPIV - return codes of VP create and modify */
+#define VP_RET_CODE_OK                 0
+#define VP_RET_CODE_FATAL              1
+#define VP_RET_CODE_WRONG_ID           2
+#define VP_RET_CODE_WWPN               3
+#define VP_RET_CODE_RESOURCES          4
+#define VP_RET_CODE_NO_MEM             5
+#define VP_RET_CODE_NOT_FOUND          6
+
+#define to_qla_parent(x) (((x)->parent) ? (x)->parent : (x))
+
 /*
  * ISP operations
  */
@@ -2175,7 +2057,7 @@ struct isp_operations {
        char * (*pci_info_str) (struct scsi_qla_host *, char *);
        char * (*fw_version_str) (struct scsi_qla_host *, char *);
 
-       irqreturn_t (*intr_handler) (int, void *, struct pt_regs *);
+       irq_handler_t intr_handler;
        void (*enable_intrs) (struct scsi_qla_host *);
        void (*disable_intrs) (struct scsi_qla_host *);
 
@@ -2198,9 +2080,50 @@ struct isp_operations {
                uint32_t);
 
        void (*fw_dump) (struct scsi_qla_host *, int);
-       void (*ascii_fw_dump) (struct scsi_qla_host *);
+
+       int (*beacon_on) (struct scsi_qla_host *);
+       int (*beacon_off) (struct scsi_qla_host *);
+       void (*beacon_blink) (struct scsi_qla_host *);
+
+       uint8_t * (*read_optrom) (struct scsi_qla_host *, uint8_t *,
+               uint32_t, uint32_t);
+       int (*write_optrom) (struct scsi_qla_host *, uint8_t *, uint32_t,
+               uint32_t);
+
+       int (*get_flash_version) (struct scsi_qla_host *, void *);
 };
 
+/* MSI-X Support *************************************************************/
+
+#define QLA_MSIX_CHIP_REV_24XX 3
+#define QLA_MSIX_FW_MODE(m)    (((m) & (BIT_7|BIT_8|BIT_9)) >> 7)
+#define QLA_MSIX_FW_MODE_1(m)  (QLA_MSIX_FW_MODE(m) == 1)
+
+#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
+
+struct scsi_qla_host;
+
+struct qla_msix_entry {
+       int have_irq;
+       uint16_t msix_vector;
+       uint16_t msix_entry;
+};
+
+#define        WATCH_INTERVAL          1       /* number of seconds */
+
+/* NPIV */
+#define MAX_MULTI_ID_LOOP                     126
+#define MAX_MULTI_ID_FABRIC                    64
+#define MAX_NUM_VPORT_LOOP                      (MAX_MULTI_ID_LOOP - 1)
+#define MAX_NUM_VPORT_FABRIC                    (MAX_MULTI_ID_FABRIC - 1)
+#define MAX_NUM_VHBA_LOOP                       (MAX_MULTI_ID_LOOP - 1)
+#define MAX_NUM_VHBA_FABRIC                     (MAX_MULTI_ID_FABRIC - 1)
+
 /*
  * Linux Host Adapter structure
  */
@@ -2231,8 +2154,13 @@ typedef struct scsi_qla_host {
                uint32_t        enable_lip_full_login   :1;
                uint32_t        enable_target_reset     :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;
        } flags;
 
        atomic_t        loop_state;
@@ -2272,6 +2200,7 @@ typedef struct scsi_qla_host {
 #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
@@ -2280,12 +2209,61 @@ typedef struct scsi_qla_host {
 #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
-        * aquire it before doing any IO to the card, eg with RD_REG*() and
+        * 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.
@@ -2312,24 +2290,31 @@ typedef struct scsi_qla_host {
        uint16_t        rsp_ring_index;     /* Current index. */
        uint16_t        response_q_length;
 
-       struct isp_operations isp_ops;
+       struct isp_operations *isp_ops;
 
        /* Outstandings ISP commands. */
        srb_t           *outstanding_cmds[MAX_OUTSTANDING_COMMANDS];
        uint32_t        current_outstanding_cmd;
        srb_t           *status_srb;    /* Status continuation entry. */
 
-       uint16_t           revision;
-       uint8_t           ports;
-
        /* 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 */
 
+#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 */
 
        uint8_t         current_topology;
@@ -2357,6 +2342,8 @@ typedef struct scsi_qla_host {
        /* NVRAM configuration data */
        uint16_t        nvram_size;
        uint16_t        nvram_base;
+       uint16_t        vpd_size;
+       uint16_t        vpd_base;
 
        uint16_t        loop_reset_delay;
        uint8_t         retry_count;
@@ -2368,13 +2355,10 @@ typedef struct scsi_qla_host {
        uint16_t        mgmt_svr_loop_id;
 
         uint32_t       login_retry_count;
+       int             max_q_depth;
 
        /* Fibre Channel Device List. */
        struct list_head        fcports;
-       struct list_head        rscn_fcports;
-
-       struct io_descriptor    io_descriptors[MAX_IO_DESCRIPTORS];
-       uint16_t                iodesc_signature;
 
        /* RSCN queue. */
        uint32_t rscn_queue[MAX_RSCN_COUNT];
@@ -2390,11 +2374,12 @@ typedef struct scsi_qla_host {
        struct sns_cmd_pkt      *sns_cmd;
        dma_addr_t              sns_cmd_dma;
 
-       pid_t                   dpc_pid;
-       int                     dpc_should_die;
-       struct completion       dpc_inited;
-       struct completion       dpc_exited;
-       struct semaphore        *dpc_wait;
+#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 */
 
        /* Timeout timers. */
@@ -2409,9 +2394,6 @@ typedef struct scsi_qla_host {
        struct gid_list_info *gid_list;
        int             gid_list_info_size;
 
-       dma_addr_t      rlc_rsp_dma;
-       rpt_lun_cmd_rsp_t *rlc_rsp;
-
        /* Small DMA pool allocations -- maximum 256 bytes in length. */
 #define DMA_POOL_SIZE  256
        struct dma_pool *s_dma_pool;
@@ -2420,9 +2402,6 @@ typedef struct scsi_qla_host {
        init_cb_t       *init_cb;
        int             init_cb_size;
 
-       dma_addr_t      iodesc_pd_dma;
-       port_database_t *iodesc_pd;
-
        /* These are used by mailbox operations. */
        volatile uint16_t mailbox_out[MAILBOX_REGISTER_COUNT];
 
@@ -2432,9 +2411,8 @@ typedef struct scsi_qla_host {
 #define MBX_INTR_WAIT  2
 #define MBX_UPDATE_FLASH_ACTIVE        3
 
-       spinlock_t      mbx_reg_lock;   /* Mbx Cmd Register Lock */
-
        struct semaphore mbx_cmd_sem;   /* Serialialize mbx access */
+       struct semaphore vport_sem;     /* Virtual port synchronization */
        struct semaphore mbx_intr_sem;  /* Used for completion notification */
 
        uint32_t        mbx_flags;
@@ -2449,31 +2427,32 @@ typedef struct scsi_qla_host {
        mbx_cmd_t       mc;
 
        /* Basic firmware related information. */
-       struct qla_board_info   *brd_info;
        uint16_t        fw_major_version;
        uint16_t        fw_minor_version;
        uint16_t        fw_subminor_version;
        uint16_t        fw_attributes;
        uint32_t        fw_memory_size;
        uint32_t        fw_transfer_size;
+       uint32_t        fw_srisc_address;
+#define RISC_START_ADDRESS_2100 0x1000
+#define RISC_START_ADDRESS_2300 0x800
+#define RISC_START_ADDRESS_2400 0x100000
 
        uint16_t        fw_options[16];         /* slots: 1,2,3,10,11 */
        uint8_t         fw_seriallink_options[4];
        uint16_t        fw_seriallink_options24[4];
 
        /* Firmware dump information. */
-       void            *fw_dump;
-       int             fw_dump_order;
-       int             fw_dump_reading;
-       char            *fw_dump_buffer;
-       int             fw_dump_buffer_len;
-
+       struct qla2xxx_fw_dump *fw_dump;
+       uint32_t        fw_dump_len;
        int             fw_dumped;
-       void            *fw_dump24;
-       int             fw_dump24_len;
+       int             fw_dump_reading;
+       dma_addr_t      eft_dma;
+       void            *eft;
 
        uint8_t         host_str[16];
        uint32_t        pci_attr;
+       uint16_t        chip_revision;
 
        uint16_t        product_id[4];
 
@@ -2484,14 +2463,71 @@ typedef struct scsi_qla_host {
 
        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;
+       int             optrom_state;
+#define QLA_SWAITING   0
+#define QLA_SREADING   1
+#define QLA_SWRITING   2
+
+        /* 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];
+       uint32_t        fw_revision[4];
+
        /* Needed for BEACON */
        uint16_t        beacon_blink_led;
-       uint16_t        beacon_green_on;
+       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;
+       struct fc_host_statistics fc_host_stat;
+
+       struct qla_msix_entry msix_entries[QLA_MSIX_ENTRIES];
+
+       struct list_head        vp_list;        /* list of VP */
+       struct fc_vport *fc_vport;      /* holds fc_vport * for each vport */
+       uint8_t         vp_idx_map[16];
+       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
+#define VP_DELETE_NEEDED       3
+#define VP_SCR_NEEDED          4       /* State Change Request registration */
+       atomic_t                vp_state;
+#define VP_OFFLINE             0
+#define VP_ACTIVE              1
+#define VP_FAILED              2
+// #define VP_DISABLE          3
+       uint16_t        vp_err_state;
+       uint16_t        vp_prev_err_state;
+#define VP_ERR_UNKWN           0
+#define VP_ERR_PORTDWN         1
+#define VP_ERR_FAB_UNSUPPORTED 2
+#define VP_ERR_FAB_NORESOURCES 3
+#define VP_ERR_FAB_LOGOUT      4
+#define VP_ERR_ADAP_NORESOURCES        5
+       int             max_npiv_vports;        /* 63 or 125 per topoloty */
+       int             cur_vport_count;
 } scsi_qla_host_t;
 
 
@@ -2503,8 +2539,6 @@ typedef struct scsi_qla_host {
         test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) || \
         atomic_read(&ha->loop_state) == LOOP_DOWN)
 
-#define TGT_Q(ha, t) (ha->otgt[t])
-
 #define to_qla_host(x)         ((scsi_qla_host_t *) (x)->hostdata)
 
 #define qla_printk(level, ha, format, arg...) \
@@ -2537,19 +2571,6 @@ typedef struct scsi_qla_host {
 #define QLA_RSCNS_HANDLED              0x108
 #define QLA_ALREADY_REGISTERED         0x109
 
-/*
-* Stat info for all adpaters
-*/
-struct _qla2x00stats  {
-        unsigned long   mboxtout;            /* mailbox timeouts */
-        unsigned long   mboxerr;             /* mailbox errors */
-        unsigned long   ispAbort;            /* ISP aborts */
-        unsigned long   debugNo;
-        unsigned long   loop_resync;
-        unsigned long   outarray_full;
-        unsigned long   retry_q_cnt;
-};
-
 #define NVRAM_DELAY()          udelay(10)
 
 #define INVALID_HANDLE (MAX_OUTSTANDING_COMMANDS+1)
@@ -2557,18 +2578,15 @@ struct _qla2x00stats  {
 /*
  * Flash support definitions
  */
-#define FLASH_IMAGE_SIZE       131072
+#define OPTROM_SIZE_2300       0x20000
+#define OPTROM_SIZE_2322       0x100000
+#define OPTROM_SIZE_24XX       0x100000
+#define OPTROM_SIZE_25XX       0x200000
 
 #include "qla_gbl.h"
 #include "qla_dbg.h"
 #include "qla_inline.h"
 
-/*
-* String arrays
-*/
-#define LINESIZE    256
-#define MAXARGS      26
-
 #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)