Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  qla_def.h   Sprache: C

 
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * QLogic Fibre Channel HBA Driver
 * Copyright (c)  2003-2014 QLogic Corporation
 */

#ifndef __QLA_DEF_H
#define __QLA_DEF_H

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/module.h>
#include <linux/list.h>
#include <linux/pci.h>
#include <linux/dma-mapping.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/dmapool.h>
#include <linux/mempool.h>
#include <linux/spinlock.h>
#include <linux/completion.h>
#include <linux/interrupt.h>
#include <linux/workqueue.h>
#include <linux/firmware.h>
#include <linux/mutex.h>
#include <linux/btree.h>

#include <scsi/scsi.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_device.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_transport_fc.h>
#include <scsi/scsi_bsg_fc.h>

#include <uapi/scsi/fc/fc_els.h>

#define QLA_DFS_DEFINE_DENTRY(_debugfs_file_name) \
 struct dentry *dfs_##_debugfs_file_name
#define QLA_DFS_ROOT_DEFINE_DENTRY(_debugfs_file_name) \
 struct dentry *qla_dfs_##_debugfs_file_name

/* Big endian Fibre Channel S_ID (source ID) or D_ID (destination ID). */
typedef struct {
 uint8_t domain;
 uint8_t area;
 uint8_t al_pa;
} be_id_t;

/* Little endian Fibre Channel S_ID (source ID) or D_ID (destination ID). */
typedef struct {
 uint8_t al_pa;
 uint8_t area;
 uint8_t domain;
} le_id_t;

/*
 * 24 bit port ID type definition.
 */

typedef union {
 uint32_t b24 : 24;
 struct {
#ifdef __BIG_ENDIAN
  uint8_t domain;
  uint8_t area;
  uint8_t al_pa;
#elif defined(__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;
#define INVALID_PORT_ID 0xFFFFFF

#include "qla_bsg.h"
#include "qla_dsd.h"
#include "qla_nx.h"
#include "qla_nx2.h"
#include "qla_nvme.h"
#define QLA2XXX_DRIVER_NAME "qla2xxx"
#define QLA2XXX_APIDEV  "ql2xapidev"
#define QLA2XXX_MANUFACTURER "Marvell"

/*
 * We have MAILBOX_REGISTER_COUNT sized arrays in a few places,
 * but that's fine as we don't look at the last 24 ones for
 * ISP2100 HBAs.
 */

#define MAILBOX_REGISTER_COUNT_2100 8
#define MAILBOX_REGISTER_COUNT_2200 24
#define MAILBOX_REGISTER_COUNT  32

#define QLA2200A_RISC_ROM_VER 4
#define FPM_2300  6
#define FPM_2310  7

#include "qla_settings.h"

#define MODE_DUAL (MODE_TARGET | MODE_INITIATOR)

/*
 * Data bit definitions
 */

#define BIT_0 0x1
#define BIT_1 0x2
#define BIT_2 0x4
#define BIT_3 0x8
#define BIT_4 0x10
#define BIT_5 0x20
#define BIT_6 0x40
#define BIT_7 0x80
#define BIT_8 0x100
#define BIT_9 0x200
#define BIT_10 0x400
#define BIT_11 0x800
#define BIT_12 0x1000
#define BIT_13 0x2000
#define BIT_14 0x4000
#define BIT_15 0x8000
#define BIT_16 0x10000
#define BIT_17 0x20000
#define BIT_18 0x40000
#define BIT_19 0x80000
#define BIT_20 0x100000
#define BIT_21 0x200000
#define BIT_22 0x400000
#define BIT_23 0x800000
#define BIT_24 0x1000000
#define BIT_25 0x2000000
#define BIT_26 0x4000000
#define BIT_27 0x8000000
#define BIT_28 0x10000000
#define BIT_29 0x20000000
#define BIT_30 0x40000000
#define BIT_31 0x80000000

#define LSB(x) ((uint8_t)(x))
#define MSB(x) ((uint8_t)((uint16_t)(x) >> 8))

#define LSW(x) ((uint16_t)(x))
#define MSW(x) ((uint16_t)((uint32_t)(x) >> 16))

#define LSD(x) ((uint32_t)((uint64_t)(x)))
#define MSD(x) ((uint32_t)((((uint64_t)(x)) >> 16) >> 16))

static inline uint32_t make_handle(uint16_t x, uint16_t y)
{
 return ((uint32_t)x << 16) | y;
}

/*
 * I/O register
*/


static inline u8 rd_reg_byte(const volatile u8 __iomem *addr)
{
 return readb(addr);
}

static inline u16 rd_reg_word(const volatile __le16 __iomem *addr)
{
 return readw(addr);
}

static inline u32 rd_reg_dword(const volatile __le32 __iomem *addr)
{
 return readl(addr);
}

static inline u8 rd_reg_byte_relaxed(const volatile u8 __iomem *addr)
{
 return readb_relaxed(addr);
}

static inline u16 rd_reg_word_relaxed(const volatile __le16 __iomem *addr)
{
 return readw_relaxed(addr);
}

static inline u32 rd_reg_dword_relaxed(const volatile __le32 __iomem *addr)
{
 return readl_relaxed(addr);
}

static inline void wrt_reg_byte(volatile u8 __iomem *addr, u8 data)
{
 return writeb(data, addr);
}

static inline void wrt_reg_word(volatile __le16 __iomem *addr, u16 data)
{
 return writew(data, addr);
}

static inline void wrt_reg_dword(volatile __le32 __iomem *addr, u32 data)
{
 return writel(data, addr);
}

/*
 * ISP83XX specific remote register addresses
 */

#define QLA83XX_LED_PORT0   0x00201320
#define QLA83XX_LED_PORT1   0x00201328
#define QLA83XX_IDC_DEV_STATE  0x22102384
#define QLA83XX_IDC_MAJOR_VERSION 0x22102380
#define QLA83XX_IDC_MINOR_VERSION 0x22102398
#define QLA83XX_IDC_DRV_PRESENCE 0x22102388
#define QLA83XX_IDC_DRIVER_ACK  0x2210238c
#define QLA83XX_IDC_CONTROL   0x22102390
#define QLA83XX_IDC_AUDIT   0x22102394
#define QLA83XX_IDC_LOCK_RECOVERY 0x2210239c
#define QLA83XX_DRIVER_LOCKID  0x22102104
#define QLA83XX_DRIVER_LOCK   0x8111c028
#define QLA83XX_DRIVER_UNLOCK  0x8111c02c
#define QLA83XX_FLASH_LOCKID  0x22102100
#define QLA83XX_FLASH_LOCK   0x8111c010
#define QLA83XX_FLASH_UNLOCK  0x8111c014
#define QLA83XX_DEV_PARTINFO1  0x221023e0
#define QLA83XX_DEV_PARTINFO2  0x221023e4
#define QLA83XX_FW_HEARTBEAT  0x221020b0
#define QLA83XX_PEG_HALT_STATUS1 0x221020a8
#define QLA83XX_PEG_HALT_STATUS2 0x221020ac

/* 83XX: Macros defining 8200 AEN Reason codes */
#define IDC_DEVICE_STATE_CHANGE BIT_0
#define IDC_PEG_HALT_STATUS_CHANGE BIT_1
#define IDC_NIC_FW_REPORTED_FAILURE BIT_2
#define IDC_HEARTBEAT_FAILURE BIT_3

/* 83XX: Macros defining 8200 AEN Error-levels */
#define ERR_LEVEL_NON_FATAL 0x1
#define ERR_LEVEL_RECOVERABLE_FATAL 0x2
#define ERR_LEVEL_UNRECOVERABLE_FATAL 0x4

/* 83XX: Macros for IDC Version */
#define QLA83XX_SUPP_IDC_MAJOR_VERSION 0x01
#define QLA83XX_SUPP_IDC_MINOR_VERSION 0x0

/* 83XX: Macros for scheduling dpc tasks */
#define QLA83XX_NIC_CORE_RESET 0x1
#define QLA83XX_IDC_STATE_HANDLER 0x2
#define QLA83XX_NIC_CORE_UNRECOVERABLE 0x3

/* 83XX: Macros for defining IDC-Control bits */
#define QLA83XX_IDC_RESET_DISABLED BIT_0
#define QLA83XX_IDC_GRACEFUL_RESET BIT_1

/* 83XX: Macros for different timeouts */
#define QLA83XX_IDC_INITIALIZATION_TIMEOUT 30
#define QLA83XX_IDC_RESET_ACK_TIMEOUT 10
#define QLA83XX_MAX_LOCK_RECOVERY_WAIT (2 * HZ)

/* 83XX: Macros for defining class in DEV-Partition Info register */
#define QLA83XX_CLASS_TYPE_NONE  0x0
#define QLA83XX_CLASS_TYPE_NIC  0x1
#define QLA83XX_CLASS_TYPE_FCOE  0x2
#define QLA83XX_CLASS_TYPE_ISCSI 0x3

/* 83XX: Macros for IDC Lock-Recovery stages */
#define IDC_LOCK_RECOVERY_STAGE1 0x1 /* Stage1: Intent for
     * lock-recovery
     */

#define IDC_LOCK_RECOVERY_STAGE2 0x2 /* Stage2: Perform lock-recovery */

/* 83XX: Macros for IDC Audit type */
#define IDC_AUDIT_TIMESTAMP  0x0 /* IDC-AUDIT: Record timestamp of
     * dev-state change to NEED-RESET
     * or NEED-QUIESCENT
     */

#define IDC_AUDIT_COMPLETION  0x1 /* IDC-AUDIT: Record duration of
     * reset-recovery completion is
     * second
     */

/* ISP2031: Values for laser on/off */
#define PORT_0_2031 0x00201340
#define PORT_1_2031 0x00201350
#define LASER_ON_2031 0x01800100
#define LASER_OFF_2031 0x01800180

/*
 * 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 */
#define MAX_FIBRE_DEVICES_2100 512
#define MAX_FIBRE_DEVICES_2400 2048
#define MAX_FIBRE_DEVICES_LOOP 128
#define MAX_FIBRE_DEVICES_MAX MAX_FIBRE_DEVICES_2400
#define LOOPID_MAP_SIZE  (ha->max_fibre_devices)
#define MAX_FIBRE_LUNS   0xFFFF
#define MAX_HOST_COUNT  16

/*
 * Host adapter default definitions.
 */

#define MAX_BUSES  1  /* We only have one bus today */
#define MIN_LUNS  8
#define MAX_LUNS  MAX_FIBRE_LUNS
#define MAX_CMDS_PER_LUN 255

/*
 * Fibre Channel device definitions.
 */

#define SNS_LAST_LOOP_ID_2100 0xfe
#define SNS_LAST_LOOP_ID_2300 0x7ff

#define LAST_LOCAL_LOOP_ID 0x7d
#define SNS_FL_PORT  0x7e
#define FABRIC_CONTROLLER 0x7f
#define SIMPLE_NAME_SERVER 0x80
#define SNS_FIRST_LOOP_ID 0x81
#define MANAGEMENT_SERVER 0xfe
#define BROADCAST  0xff

/*
 * There is no correspondence between an N-PORT id and an AL_PA.  Therefore the
 * valid range of an N-PORT id is 0 through 0x7ef.
 */

#define NPH_LAST_HANDLE  0x7ee
#define NPH_MGMT_SERVER  0x7ef  /*  FFFFEF */
#define NPH_SNS   0x7fc  /*  FFFFFC */
#define NPH_FABRIC_CONTROLLER 0x7fd  /*  FFFFFD */
#define NPH_F_PORT  0x7fe  /*  FFFFFE */
#define NPH_IP_BROADCAST 0x7ff  /*  FFFFFF */

#define NPH_SNS_LID(ha) (IS_FWI2_CAPABLE(ha) ? NPH_SNS : SIMPLE_NAME_SERVER)

#define MAX_CMDSZ 16  /* SCSI maximum CDB size. */
#include "qla_fw.h"

struct name_list_extended {
 struct get_name_list_extended *l;
 dma_addr_t  ldma;
 struct list_head fcports;
 u32   size;
 u8   sent;
};

struct qla_nvme_fc_rjt {
 struct fcnvme_ls_rjt *c;
 dma_addr_t  cdma;
 u16 size;
};

struct els_reject {
 struct fc_els_ls_rjt *c;
 dma_addr_t  cdma;
 u16 size;
};

/*
 * Timeout timer counts in seconds
 */

#define PORT_RETRY_TIME   1
#define LOOP_DOWN_TIMEOUT  60
#define LOOP_DOWN_TIME   255 /* 240 */
#define LOOP_DOWN_RESET   (LOOP_DOWN_TIME - 30)

#define DEFAULT_OUTSTANDING_COMMANDS 4096
#define MIN_OUTSTANDING_COMMANDS 128

/* 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_24XX  2048 /* Number of request entries. */
#define REQUEST_ENTRY_CNT_83XX  8192 /* Number of request entries. */
#define RESPONSE_ENTRY_CNT_83XX  4096 /* Number of response 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.*/
#define ATIO_ENTRY_CNT_24XX  4096 /* Number of ATIO entries. */
#define RESPONSE_ENTRY_CNT_FX00  256     /* Number of response entries.*/
#define FW_DEF_EXCHANGES_CNT 2048
#define FW_MAX_EXCHANGES_CNT (32 * 1024)
#define REDUCE_EXCHANGES_CNT  (8 * 1024)

#define SET_DID_STATUS(stat_var, status) (stat_var = status << 16)

struct req_que;
struct qla_tgt_sess;

struct qla_buf_dsc {
 u16 tag;
#define TAG_FREED 0xffff
 void *buf;
 dma_addr_t buf_dma;
};

/*
 * SCSI Request Block
 */

struct srb_cmd {
 struct scsi_cmnd *cmd;  /* Linux SCSI command pkt */
 uint32_t request_sense_length;
 uint32_t fw_sense_length;
 uint8_t *request_sense_ptr;
 struct crc_context *crc_ctx;
 struct ct6_dsd ct6_ctx;
 struct qla_buf_dsc buf_dsc;
};

/*
 * SRB flag definitions
 */

#define SRB_DMA_VALID   BIT_0 /* Command sent to ISP */
#define SRB_GOT_BUF   BIT_1
#define SRB_FCP_CMND_DMA_VALID  BIT_12 /* DIF: DSD List valid */
#define SRB_CRC_CTX_DMA_VALID  BIT_2 /* DIF: context DMA valid */
#define SRB_CRC_PROT_DMA_VALID  BIT_4 /* DIF: prot DMA valid */
#define SRB_CRC_CTX_DSD_VALID  BIT_5 /* DIF: dsd_list valid */
#define SRB_WAKEUP_ON_COMP  BIT_6
#define SRB_DIF_BUNDL_DMA_VALID  BIT_7   /* DIF: DMA list valid */
#define SRB_EDIF_CLEANUP_DELETE  BIT_9

/* To identify if a srb is of T10-CRC type. @sp => srb_t pointer */
#define IS_PROT_IO(sp) (sp->flags & SRB_CRC_CTX_DSD_VALID)
#define ISP_REG16_DISCONNECT 0xFFFF

static inline le_id_t be_id_to_le(be_id_t id)
{
 le_id_t res;

 res.domain = id.domain;
 res.area   = id.area;
 res.al_pa  = id.al_pa;

 return res;
}

static inline be_id_t le_id_to_be(le_id_t id)
{
 be_id_t res;

 res.domain = id.domain;
 res.area   = id.area;
 res.al_pa  = id.al_pa;

 return res;
}

static inline port_id_t be_to_port_id(be_id_t id)
{
 port_id_t res;

 res.b.domain = id.domain;
 res.b.area   = id.area;
 res.b.al_pa  = id.al_pa;
 res.b.rsvd_1 = 0;

 return res;
}

static inline be_id_t port_id_to_be_id(port_id_t port_id)
{
 be_id_t res;

 res.domain = port_id.b.domain;
 res.area   = port_id.b.area;
 res.al_pa  = port_id.b.al_pa;

 return res;
}

struct tmf_arg {
 struct list_head tmf_elem;
 struct qla_qpair *qpair;
 struct fc_port *fcport;
 struct scsi_qla_host *vha;
 u64 lun;
 u32 flags;
 uint8_t modifier;
};

struct els_logo_payload {
 uint8_t opcode;
 uint8_t rsvd[3];
 uint8_t s_id[3];
 uint8_t rsvd1[1];
 uint8_t wwpn[WWN_SIZE];
};

struct els_plogi_payload {
 uint8_t opcode;
 uint8_t rsvd[3];
 __be32 data[112 / 4];
};

struct ct_arg {
 void  *iocb;
 u16  nport_handle;
 dma_addr_t req_dma;
 dma_addr_t rsp_dma;
 u32  req_size;
 u32  rsp_size;
 u32  req_allocated_size;
 u32  rsp_allocated_size;
 void  *req;
 void  *rsp;
 port_id_t id;
};

struct qla_nvme_lsrjt_pt_arg {
 struct fc_port *fcport;
 u8 opcode;
 u8 vp_idx;
 u8 reason;
 u8 explanation;
 __le16 nport_handle;
 u16 control_flags;
 __le16 ox_id;
 __le32 xchg_address;
 u32 tx_byte_count, rx_byte_count;
 dma_addr_t tx_addr, rx_addr;
};

/*
 * SRB extensions.
 */

struct srb_iocb {
 union {
  struct {
   uint16_t flags;
#define SRB_LOGIN_RETRIED BIT_0
#define SRB_LOGIN_COND_PLOGI BIT_1
#define SRB_LOGIN_SKIP_PRLI BIT_2
#define SRB_LOGIN_NVME_PRLI BIT_3
#define SRB_LOGIN_PRLI_ONLY BIT_4
#define SRB_LOGIN_FCSP  BIT_5
   uint16_t data[2];
   u32 iop[2];
  } logio;
  struct {
#define ELS_DCMD_TIMEOUT 20
#define ELS_DCMD_LOGO 0x5
   uint32_t flags;
   uint32_t els_cmd;
   struct completion comp;
   struct els_logo_payload *els_logo_pyld;
   dma_addr_t els_logo_pyld_dma;
  } els_logo;
  struct els_plogi {
#define ELS_DCMD_PLOGI 0x3
   uint32_t flags;
   uint32_t els_cmd;
   struct completion comp;
   struct els_plogi_payload *els_plogi_pyld;
   struct els_plogi_payload *els_resp_pyld;
   u32 tx_size;
   u32 rx_size;
   dma_addr_t els_plogi_pyld_dma;
   dma_addr_t els_resp_pyld_dma;
   __le32 fw_status[3];
   __le16 comp_status;
   __le16 len;
  } els_plogi;
  struct {
   /*
 * Values for flags field below are as
 * defined in tsk_mgmt_entry struct
 * for control_flags field in qla_fw.h.
 */

   uint64_t lun;
   uint32_t flags;
   uint32_t data;
   struct completion comp;
   __le16 comp_status;

   uint8_t modifier;
   uint8_t vp_index;
   uint16_t loop_id;
  } tmf;
  struct {
#define SRB_FXDISC_REQ_DMA_VALID BIT_0
#define SRB_FXDISC_RESP_DMA_VALID BIT_1
#define SRB_FXDISC_REQ_DWRD_VALID BIT_2
#define SRB_FXDISC_RSP_DWRD_VALID BIT_3
#define FXDISC_TIMEOUT 20
   uint8_t flags;
   uint32_t req_len;
   uint32_t rsp_len;
   void *req_addr;
   void *rsp_addr;
   dma_addr_t req_dma_handle;
   dma_addr_t rsp_dma_handle;
   __le32 adapter_id;
   __le32 adapter_id_hi;
   __le16 req_func_type;
   __le32 req_data;
   __le32 req_data_extra;
   __le32 result;
   __le32 seq_number;
   __le16 fw_flags;
   struct completion fxiocb_comp;
   __le32 reserved_0;
   uint8_t reserved_1;
  } fxiocb;
  struct {
   uint32_t cmd_hndl;
   __le16 comp_status;
   __le16 req_que_no;
   struct completion comp;
  } abt;
  struct ct_arg ctarg;
#define MAX_IOCB_MB_REG 28
#define SIZEOF_IOCB_MB_REG (MAX_IOCB_MB_REG * sizeof(uint16_t))
  struct {
   u16 in_mb[MAX_IOCB_MB_REG]; /* from FW */
   u16 out_mb[MAX_IOCB_MB_REG]; /* to FW */
   void *out, *in;
   dma_addr_t out_dma, in_dma;
   struct completion comp;
   int rc;
  } mbx;
  struct {
   struct imm_ntfy_from_isp *ntfy;
  } nack;
  struct {
   __le16 comp_status;
   __le16 rsp_pyld_len;
   uint8_t aen_op;
   void *desc;

   /* These are only used with ls4 requests */
   __le32 cmd_len;
   __le32 rsp_len;
   dma_addr_t cmd_dma;
   dma_addr_t rsp_dma;
   enum nvmefc_fcp_datadir dir;
   uint32_t dl;
   uint32_t timeout_sec;
   __le32 exchange_address;
   __le16 nport_handle;
   __le16 ox_id;
   struct list_head   entry;
  } nvme;
  struct {
   u16 cmd;
   u16 vp_index;
  } ctrlvp;
  struct {
   struct edif_sa_ctl *sa_ctl;
   struct qla_sa_update_frame sa_frame;
  } sa_update;
 } u;

 struct timer_list timer;
 void (*timeout)(void *);
};

/* Values for srb_ctx type */
#define SRB_LOGIN_CMD 1
#define SRB_LOGOUT_CMD 2
#define SRB_ELS_CMD_RPT 3
#define SRB_ELS_CMD_HST 4
#define SRB_CT_CMD 5
#define SRB_ADISC_CMD 6
#define SRB_TM_CMD 7
#define SRB_SCSI_CMD 8
#define SRB_BIDI_CMD 9
#define SRB_FXIOCB_DCMD 10
#define SRB_FXIOCB_BCMD 11
#define SRB_ABT_CMD 12
#define SRB_ELS_DCMD 13
#define SRB_MB_IOCB 14
#define SRB_CT_PTHRU_CMD 15
#define SRB_NACK_PLOGI 16
#define SRB_NACK_PRLI 17
#define SRB_NACK_LOGO 18
#define SRB_NVME_CMD 19
#define SRB_NVME_LS 20
#define SRB_PRLI_CMD 21
#define SRB_CTRL_VP 22
#define SRB_PRLO_CMD 23
#define SRB_SA_UPDATE 25
#define SRB_ELS_CMD_HST_NOLOGIN 26
#define SRB_SA_REPLACE 27
#define SRB_MARKER 28

struct qla_els_pt_arg {
 u8 els_opcode;
 u8 vp_idx;
 __le16 nport_handle;
 u16 control_flags, ox_id;
 __le32 rx_xchg_address;
 port_id_t did, sid;
 u32 tx_len, tx_byte_count, rx_len, rx_byte_count;
 dma_addr_t tx_addr, rx_addr;

};

enum {
 TYPE_SRB,
 TYPE_TGT_CMD,
 TYPE_TGT_TMCMD,  /* task management */
};

struct iocb_resource {
 u8 res_type;
 u8  exch_cnt;
 u16 iocb_cnt;
};

struct bsg_cmd {
 struct bsg_job *bsg_job;
 union {
  struct qla_els_pt_arg els_arg;
 } u;
};

typedef struct srb {
 /*
 * Do not move cmd_type field, it needs to
 * line up with qla_tgt_cmd->cmd_type
 */

 uint8_t cmd_type;
 uint8_t pad[3];
 struct iocb_resource iores;
 struct kref cmd_kref; /* need to migrate ref_count over to this */
 void *priv;
 struct fc_port *fcport;
 struct scsi_qla_host *vha;
 unsigned int start_timer:1;
 unsigned int abort:1;
 unsigned int aborted:1;
 unsigned int completed:1;
 unsigned int unsol_rsp:1;

 uint32_t handle;
 uint16_t flags;
 uint16_t type;
 const char *name;
 int iocbs;
 struct qla_qpair *qpair;
 struct srb *cmd_sp;
 struct list_head elem;
 u32 gen1; /* scratch */
 u32 gen2; /* scratch */
 int rc;
 int retry_count;
 struct completion *comp;
 union {
  struct srb_iocb iocb_cmd;
  struct bsg_job *bsg_job;
  struct srb_cmd scmd;
  struct bsg_cmd bsg_cmd;
 } u;
 struct {
  bool remapped;
  struct {
   dma_addr_t dma;
   void *buf;
   uint len;
  } req;
  struct {
   dma_addr_t dma;
   void *buf;
   uint len;
  } rsp;
 } remap;
 /*
 * Report completion status @res and call sp_put(@sp). @res is
 * an NVMe status code, a SCSI result (e.g. DID_OK << 16) or a
 * QLA_* status value.
 */

 void (*done)(struct srb *sp, int res);
 /* Stop the timer and free @sp. Only used by the FCP code. */
 void (*free)(struct srb *sp);
 /*
 * Call nvme_private->fd->done() and free @sp. Only used by the NVMe
 * code.
 */

 void (*put_fn)(struct kref *kref);

 /*
 * Report completion for asynchronous commands.
 */

 void (*async_done)(struct srb *sp, int res);
} srb_t;

#define GET_CMD_SP(sp) (sp->u.scmd.cmd)

#define GET_CMD_SENSE_LEN(sp) \
 (sp->u.scmd.request_sense_length)
#define SET_CMD_SENSE_LEN(sp, len) \
 (sp->u.scmd.request_sense_length = len)
#define GET_CMD_SENSE_PTR(sp) \
 (sp->u.scmd.request_sense_ptr)
#define SET_CMD_SENSE_PTR(sp, ptr) \
 (sp->u.scmd.request_sense_ptr = ptr)
#define GET_FW_SENSE_LEN(sp) \
 (sp->u.scmd.fw_sense_length)
#define SET_FW_SENSE_LEN(sp, len) \
 (sp->u.scmd.fw_sense_length = len)

struct msg_echo_lb {
 dma_addr_t send_dma;
 dma_addr_t rcv_dma;
 uint16_t req_sg_cnt;
 uint16_t rsp_sg_cnt;
 uint16_t options;
 uint32_t transfer_size;
 uint32_t iteration_count;
};

/*
 * ISP I/O Register Set structure definitions.
 */

struct device_reg_2xxx {
 __le16 flash_address;  /* Flash BIOS address */
 __le16 flash_data;  /* Flash BIOS data */
 __le16 unused_1[1];  /* Gap */
 __le16 ctrl_status;  /* Control/Status */
#define CSR_FLASH_64K_BANK BIT_3 /* Flash upper 64K bank select */
#define CSR_FLASH_ENABLE BIT_1 /* Flash BIOS Read/Write enable */
#define CSR_ISP_SOFT_RESET BIT_0 /* ISP soft reset */

 __le16 ictrl;   /* Interrupt control */
#define ICR_EN_INT  BIT_15 /* ISP enable interrupts. */
#define ICR_EN_RISC  BIT_3 /* ISP enable RISC interrupts. */

 __le16 istatus;  /* Interrupt status */
#define ISR_RISC_INT  BIT_3 /* RISC interrupt */

 __le16 semaphore;  /* Semaphore */
 __le16 nvram;   /* NVRAM register. */
#define NVR_DESELECT  0
#define NVR_BUSY  BIT_15
#define NVR_WRT_ENABLE  BIT_14 /* Write enable */
#define NVR_PR_ENABLE  BIT_13 /* Protection register enable */
#define NVR_DATA_IN  BIT_3
#define NVR_DATA_OUT  BIT_2
#define NVR_SELECT  BIT_1
#define NVR_CLOCK  BIT_0

#define NVR_WAIT_CNT  20000

 union {
  struct {
   __le16 mailbox0;
   __le16 mailbox1;
   __le16 mailbox2;
   __le16 mailbox3;
   __le16 mailbox4;
   __le16 mailbox5;
   __le16 mailbox6;
   __le16 mailbox7;
   __le16 unused_2[59]; /* Gap */
  } __attribute__((packed)) isp2100;
  struct {
      /* Request Queue */
   __le16 req_q_in; /*  In-Pointer */
   __le16 req_q_out; /*  Out-Pointer */
      /* Response Queue */
   __le16 rsp_q_in; /*  In-Pointer */
   __le16 rsp_q_out; /*  Out-Pointer */

      /* RISC to Host Status */
   __le32 host_status;
#define HSR_RISC_INT  BIT_15 /* RISC interrupt */
#define HSR_RISC_PAUSED  BIT_8 /* RISC Paused */

     /* Host to Host Semaphore */
   __le16 host_semaphore;
   __le16 unused_3[17]; /* Gap */
   __le16 mailbox0;
   __le16 mailbox1;
   __le16 mailbox2;
   __le16 mailbox3;
   __le16 mailbox4;
   __le16 mailbox5;
   __le16 mailbox6;
   __le16 mailbox7;
   __le16 mailbox8;
   __le16 mailbox9;
   __le16 mailbox10;
   __le16 mailbox11;
   __le16 mailbox12;
   __le16 mailbox13;
   __le16 mailbox14;
   __le16 mailbox15;
   __le16 mailbox16;
   __le16 mailbox17;
   __le16 mailbox18;
   __le16 mailbox19;
   __le16 mailbox20;
   __le16 mailbox21;
   __le16 mailbox22;
   __le16 mailbox23;
   __le16 mailbox24;
   __le16 mailbox25;
   __le16 mailbox26;
   __le16 mailbox27;
   __le16 mailbox28;
   __le16 mailbox29;
   __le16 mailbox30;
   __le16 mailbox31;
   __le16 fb_cmd;
   __le16 unused_4[10]; /* Gap */
  } __attribute__((packed)) isp2300;
 } u;

 __le16 fpm_diag_config;
 __le16 unused_5[0x4];  /* Gap */
 __le16 risc_hw;
 __le16 unused_5_1;  /* Gap */
 __le16 pcr;   /* Processor Control Register. */
 __le16 unused_6[0x5];  /* Gap */
 __le16 mctr;   /* Memory Configuration and Timing. */
 __le16 unused_7[0x3];  /* Gap */
 __le16 fb_cmd_2100;  /* Unused on 23XX */
 __le16 unused_8[0x3];  /* Gap */
 __le16 hccr;   /* Host command & control register. */
#define HCCR_HOST_INT  BIT_7 /* Host interrupt bit */
#define HCCR_RISC_PAUSE  BIT_5 /* Pause mode bit */
     /* HCCR commands */
#define HCCR_RESET_RISC  0x1000 /* Reset RISC */
#define HCCR_PAUSE_RISC  0x2000 /* Pause RISC */
#define HCCR_RELEASE_RISC 0x3000 /* Release RISC from reset. */
#define HCCR_SET_HOST_INT 0x5000 /* Set host interrupt */
#define HCCR_CLR_HOST_INT 0x6000 /* Clear HOST interrupt */
#define HCCR_CLR_RISC_INT 0x7000 /* Clear RISC interrupt */
#define HCCR_DISABLE_PARITY_PAUSE 0x4001 /* Disable parity error RISC pause. */
#define HCCR_ENABLE_PARITY 0xA000 /* Enable PARITY interrupt */

 __le16 unused_9[5];  /* Gap */
 __le16 gpiod;   /* GPIO Data register. */
 __le16 gpioe;   /* GPIO Enable register. */
#define GPIO_LED_MASK   0x00C0
#define GPIO_LED_GREEN_OFF_AMBER_OFF 0x0000
#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 {
   __le16 unused_10[8]; /* Gap */
   __le16 mailbox8;
   __le16 mailbox9;
   __le16 mailbox10;
   __le16 mailbox11;
   __le16 mailbox12;
   __le16 mailbox13;
   __le16 mailbox14;
   __le16 mailbox15;
   __le16 mailbox16;
   __le16 mailbox17;
   __le16 mailbox18;
   __le16 mailbox19;
   __le16 mailbox20;
   __le16 mailbox21;
   __le16 mailbox22;
   __le16 mailbox23; /* Also probe reg. */
  } __attribute__((packed)) isp2200;
 } u_end;
};

struct device_reg_25xxmq {
 __le32 req_q_in;
 __le32 req_q_out;
 __le32 rsp_q_in;
 __le32 rsp_q_out;
 __le32 atio_q_in;
 __le32 atio_q_out;
};


struct device_reg_fx00 {
 __le32 mailbox0;  /* 00 */
 __le32 mailbox1;  /* 04 */
 __le32 mailbox2;  /* 08 */
 __le32 mailbox3;  /* 0C */
 __le32 mailbox4;  /* 10 */
 __le32 mailbox5;  /* 14 */
 __le32 mailbox6;  /* 18 */
 __le32 mailbox7;  /* 1C */
 __le32 mailbox8;  /* 20 */
 __le32 mailbox9;  /* 24 */
 __le32 mailbox10;  /* 28 */
 __le32 mailbox11;
 __le32 mailbox12;
 __le32 mailbox13;
 __le32 mailbox14;
 __le32 mailbox15;
 __le32 mailbox16;
 __le32 mailbox17;
 __le32 mailbox18;
 __le32 mailbox19;
 __le32 mailbox20;
 __le32 mailbox21;
 __le32 mailbox22;
 __le32 mailbox23;
 __le32 mailbox24;
 __le32 mailbox25;
 __le32 mailbox26;
 __le32 mailbox27;
 __le32 mailbox28;
 __le32 mailbox29;
 __le32 mailbox30;
 __le32 mailbox31;
 __le32 aenmailbox0;
 __le32 aenmailbox1;
 __le32 aenmailbox2;
 __le32 aenmailbox3;
 __le32 aenmailbox4;
 __le32 aenmailbox5;
 __le32 aenmailbox6;
 __le32 aenmailbox7;
 /* Request Queue. */
 __le32 req_q_in;  /* A0 - Request Queue In-Pointer */
 __le32 req_q_out;  /* A4 - Request Queue Out-Pointer */
 /* Response Queue. */
 __le32 rsp_q_in;  /* A8 - Response Queue In-Pointer */
 __le32 rsp_q_out;  /* AC - Response Queue Out-Pointer */
 /* Init values shadowed on FW Up Event */
 __le32 initval0;  /* B0 */
 __le32 initval1;  /* B4 */
 __le32 initval2;  /* B8 */
 __le32 initval3;  /* BC */
 __le32 initval4;  /* C0 */
 __le32 initval5;  /* C4 */
 __le32 initval6;  /* C8 */
 __le32 initval7;  /* CC */
 __le32 fwheartbeat;  /* D0 */
 __le32 pseudoaen;  /* D4 */
};



typedef union {
  struct device_reg_2xxx isp;
  struct device_reg_24xx isp24;
  struct device_reg_25xxmq isp25mq;
  struct device_reg_82xx isp82;
  struct device_reg_fx00 ispfx00;
} __iomem device_reg_t;

#define ISP_REQ_Q_IN(ha, reg) \
 (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  &(reg)->u.isp2100.mailbox4 : \
  &(reg)->u.isp2300.req_q_in)
#define ISP_REQ_Q_OUT(ha, reg) \
 (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  &(reg)->u.isp2100.mailbox4 : \
  &(reg)->u.isp2300.req_q_out)
#define ISP_RSP_Q_IN(ha, reg) \
 (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  &(reg)->u.isp2100.mailbox5 : \
  &(reg)->u.isp2300.rsp_q_in)
#define ISP_RSP_Q_OUT(ha, reg) \
 (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  &(reg)->u.isp2100.mailbox5 : \
  &(reg)->u.isp2300.rsp_q_out)

#define ISP_ATIO_Q_IN(vha) (vha->hw->tgt.atio_q_in)
#define ISP_ATIO_Q_OUT(vha) (vha->hw->tgt.atio_q_out)

#define MAILBOX_REG(ha, reg, num) \
 (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  (num < 8 ? \
   &(reg)->u.isp2100.mailbox0 + (num) : \
   &(reg)->u_end.isp2200.mailbox8 + (num) - 8) : \
  &(reg)->u.isp2300.mailbox0 + (num))
#define RD_MAILBOX_REG(ha, reg, num) \
 rd_reg_word(MAILBOX_REG(ha, reg, num))
#define WRT_MAILBOX_REG(ha, reg, num, data) \
 wrt_reg_word(MAILBOX_REG(ha, reg, num), data)

#define FB_CMD_REG(ha, reg) \
 (IS_QLA2100(ha) || IS_QLA2200(ha) ? \
  &(reg)->fb_cmd_2100 : \
  &(reg)->u.isp2300.fb_cmd)
#define RD_FB_CMD_REG(ha, reg) \
 rd_reg_word(FB_CMD_REG(ha, reg))
#define WRT_FB_CMD_REG(ha, reg, data) \
 wrt_reg_word(FB_CMD_REG(ha, reg), data)

typedef struct {
 uint32_t out_mb;  /* outbound from driver */
 uint32_t in_mb;   /* Incoming from RISC */
 uint16_t mb[MAILBOX_REGISTER_COUNT];
 long  buf_size;
 void  *bufp;
 uint32_t tov;
 uint8_t  flags;
#define MBX_DMA_IN BIT_0
#define MBX_DMA_OUT BIT_1
#define IOCTL_CMD BIT_2
} mbx_cmd_t;

struct mbx_cmd_32 {
 uint32_t out_mb;  /* outbound from driver */
 uint32_t in_mb;   /* Incoming from RISC */
 uint32_t mb[MAILBOX_REGISTER_COUNT];
 long  buf_size;
 void  *bufp;
 uint32_t tov;
 uint8_t  flags;
#define MBX_DMA_IN BIT_0
#define MBX_DMA_OUT BIT_1
#define IOCTL_CMD BIT_2
};


#define MBX_TOV_SECONDS 30

/*
 *  ISP product identification definitions in mailboxes after reset.
 */

#define PROD_ID_1  0x4953
#define PROD_ID_2  0x0000
#define PROD_ID_2a  0x5020
#define PROD_ID_3  0x2020

/*
 * ISP mailbox Self-Test status codes
 */

#define MBS_FRM_ALIVE  0 /* Firmware Alive. */
#define MBS_CHKSUM_ERR  1 /* Checksum Error. */
#define MBS_BUSY  4 /* Busy. */

/*
 * ISP mailbox command complete status codes
 */

#define MBS_COMMAND_COMPLETE  0x4000
#define MBS_INVALID_COMMAND  0x4001
#define MBS_HOST_INTERFACE_ERROR 0x4002
#define MBS_TEST_FAILED   0x4003
#define MBS_COMMAND_ERROR  0x4005
#define MBS_COMMAND_PARAMETER_ERROR 0x4006
#define MBS_PORT_ID_USED  0x4007
#define MBS_LOOP_ID_USED  0x4008
#define MBS_ALL_IDS_IN_USE  0x4009
#define MBS_NOT_LOGGED_IN  0x400A
#define MBS_LINK_DOWN_ERROR  0x400B
#define MBS_DIAG_ECHO_TEST_ERROR 0x400C

static inline bool qla2xxx_is_valid_mbs(unsigned int mbs)
{
 return MBS_COMMAND_COMPLETE <= mbs && mbs <= MBS_DIAG_ECHO_TEST_ERROR;
}

/*
 * ISP mailbox asynchronous event status codes
 */

#define MBA_ASYNC_EVENT  0x8000 /* Asynchronous event. */
#define MBA_RESET  0x8001 /* Reset Detected. */
#define MBA_SYSTEM_ERR  0x8002 /* System Error. */
#define MBA_REQ_TRANSFER_ERR 0x8003 /* Request Transfer Error. */
#define MBA_RSP_TRANSFER_ERR 0x8004 /* Response Transfer Error. */
#define MBA_WAKEUP_THRES 0x8005 /* Request Queue Wake-up. */
#define MBA_LIP_OCCURRED 0x8010 /* Loop Initialization Procedure */
     /* occurred. */
#define MBA_LOOP_UP  0x8011 /* FC Loop UP. */
#define MBA_LOOP_DOWN  0x8012 /* FC Loop Down. */
#define MBA_LIP_RESET  0x8013 /* LIP reset occurred. */
#define MBA_PORT_UPDATE  0x8014 /* Port Database update. */
#define MBA_RSCN_UPDATE  0x8015 /* Register State Chg Notification. */
#define MBA_LIP_F8  0x8016 /* Received a LIP F8. */
#define MBA_LOOP_INIT_ERR 0x8017 /* Loop Initialization Error. */
#define MBA_FABRIC_AUTH_REQ 0x801b /* Fabric Authentication Required. */
#define MBA_CONGN_NOTI_RECV 0x801e /* Congestion Notification Received */
#define MBA_SCSI_COMPLETION 0x8020 /* SCSI Command Complete. */
#define MBA_CTIO_COMPLETION 0x8021 /* CTIO Complete. */
#define MBA_IP_COMPLETION 0x8022 /* IP Transmit Command Complete. */
#define MBA_IP_RECEIVE  0x8023 /* IP Received. */
#define MBA_IP_BROADCAST 0x8024 /* IP Broadcast Received. */
#define MBA_IP_LOW_WATER_MARK 0x8025 /* IP Low Water Mark reached. */
#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. */
#define MBA_CMPLT_3_16BIT 0x8033 /* Completion 3 16bit IOSB. */
#define MBA_CMPLT_4_16BIT 0x8034 /* Completion 4 16bit IOSB. */
#define MBA_CMPLT_5_16BIT 0x8035 /* Completion 5 16bit IOSB. */
#define MBA_CHG_IN_CONNECTION 0x8036 /* Change in connection mode. */
#define MBA_RIO_RESPONSE 0x8040 /* RIO response queue update. */
#define MBA_ZIO_RESPONSE 0x8040 /* ZIO response queue update. */
#define MBA_CMPLT_2_32BIT 0x8042 /* Completion 2 32bit IOSB. */
#define MBA_BYPASS_NOTIFICATION 0x8043 /* Auto bypass notification. */
#define MBA_DISCARD_RND_FRAME 0x8048 /* discard RND frame due to error. */
#define MBA_REJECTED_FCP_CMD 0x8049 /* rejected FCP_CMD. */
#define MBA_FW_NOT_STARTED 0x8050 /* Firmware not started */
#define MBA_FW_STARTING  0x8051 /* Firmware starting */
#define MBA_FW_RESTART_CMPLT 0x8060 /* Firmware restart complete */
#define MBA_INIT_REQUIRED 0x8061 /* Initialization required */
#define MBA_SHUTDOWN_REQUESTED 0x8062 /* Shutdown Requested */
#define MBA_TEMPERATURE_ALERT 0x8070 /* Temperature Alert */
#define MBA_DPORT_DIAGNOSTICS 0x8080 /* D-port Diagnostics */
#define MBA_TRANS_INSERT 0x8130 /* Transceiver Insertion */
#define MBA_TRANS_REMOVE 0x8131 /* Transceiver Removal */
#define MBA_FW_INIT_FAILURE 0x8401 /* Firmware initialization failure */
#define MBA_MIRROR_LUN_CHANGE 0x8402 /* Mirror LUN State Change
   Notification */

#define MBA_FW_POLL_STATE 0x8600  /* Firmware in poll diagnostic state */
#define MBA_FW_RESET_FCT 0x8502 /* Firmware reset factory defaults */
#define MBA_FW_INIT_INPROGRESS 0x8500 /* Firmware boot in progress */
/* 83XX FCoE specific */
#define MBA_IDC_AEN  0x8200  /* FCoE: NIC Core state change AEN */

/* Interrupt type codes */
#define INTR_ROM_MB_SUCCESS  0x1
#define INTR_ROM_MB_FAILED  0x2
#define INTR_MB_SUCCESS   0x10
#define INTR_MB_FAILED   0x11
#define INTR_ASYNC_EVENT  0x12
#define INTR_RSP_QUE_UPDATE  0x13
#define INTR_RSP_QUE_UPDATE_83XX 0x14
#define INTR_ATIO_QUE_UPDATE  0x1C
#define INTR_ATIO_RSP_QUE_UPDATE 0x1D
#define INTR_ATIO_QUE_UPDATE_27XX 0x1E

/* ISP mailbox loopback echo diagnostic error code */
#define MBS_LB_RESET 0x17

/* AEN mailbox Port Diagnostics test */
#define AEN_START_DIAG_TEST  0x0 /* start the diagnostics */
#define AEN_DONE_DIAG_TEST_WITH_NOERR 0x1 /* Done with no errors */
#define AEN_DONE_DIAG_TEST_WITH_ERR 0x2 /* Done with error.*/

/*
 * Firmware options 1, 2, 3.
 */

#define FO1_AE_ON_LIPF8   BIT_0
#define FO1_AE_ALL_LIP_RESET  BIT_1
#define FO1_CTIO_RETRY   BIT_3
#define FO1_DISABLE_LIP_F7_SW  BIT_4
#define FO1_DISABLE_100MS_LOS_WAIT BIT_5
#define FO1_DISABLE_GPIO6_7  BIT_6 /* LED bits */
#define FO1_AE_ON_LOOP_INIT_ERR  BIT_7
#define FO1_SET_EMPHASIS_SWING  BIT_8
#define FO1_AE_AUTO_BYPASS  BIT_9
#define FO1_ENABLE_PURE_IOCB  BIT_10
#define FO1_AE_PLOGI_RJT  BIT_11
#define FO1_ENABLE_ABORT_SEQUENCE BIT_12
#define FO1_AE_QUEUE_FULL  BIT_13

#define FO2_ENABLE_ATIO_TYPE_3  BIT_0
#define FO2_REV_LOOPBACK  BIT_1

#define FO3_ENABLE_EMERG_IOCB  BIT_0
#define FO3_AE_RND_ERROR  BIT_1

/* 24XX additional firmware options */
#define ADD_FO_COUNT   3
#define ADD_FO1_DISABLE_GPIO_LED_CTRL BIT_6 /* LED bits */
#define ADD_FO1_ENABLE_PUREX_IOCB BIT_10

#define ADD_FO2_ENABLE_SEL_CLS2  BIT_5

#define ADD_FO3_NO_ABT_ON_LINK_DOWN BIT_14

/*
 * ISP mailbox commands
 */

#define MBC_LOAD_RAM   1 /* Load RAM. */
#define MBC_EXECUTE_FIRMWARE  2 /* Execute firmware. */
#define MBC_READ_RAM_WORD  5 /* Read RAM word. */
#define MBC_MAILBOX_REGISTER_TEST 6 /* Wrap incoming mailboxes */
#define MBC_VERIFY_CHECKSUM  7 /* Verify checksum. */
#define MBC_GET_FIRMWARE_VERSION 8 /* Get firmware revision. */
#define MBC_LOAD_RISC_RAM  9 /* Load RAM command. */
#define MBC_DUMP_RISC_RAM  0xa /* Dump RAM command. */
#define MBC_SECURE_FLASH_UPDATE  0xa /* Secure Flash Update(28xx) */
#define MBC_LOAD_RISC_RAM_EXTENDED 0xb /* Load RAM extended. */
#define MBC_DUMP_RISC_RAM_EXTENDED 0xc /* Dump RAM extended. */
#define MBC_WRITE_RAM_WORD_EXTENDED 0xd /* Write RAM word extended */
#define MBC_READ_RAM_EXTENDED  0xf /* Read RAM extended. */
#define MBC_IOCB_COMMAND  0x12 /* Execute IOCB command. */
#define MBC_STOP_FIRMWARE  0x14 /* Stop firmware. */
#define MBC_ABORT_COMMAND  0x15 /* Abort IOCB command. */
#define MBC_ABORT_DEVICE  0x16 /* Abort device (ID/LUN). */
#define MBC_ABORT_TARGET  0x17 /* Abort target (ID). */
#define MBC_RESET   0x18 /* Reset. */
#define MBC_GET_ADAPTER_LOOP_ID  0x20 /* Get loop id of ISP2200. */
#define MBC_GET_SET_ZIO_THRESHOLD 0x21 /* Get/SET ZIO THRESHOLD. */
#define MBC_GET_RETRY_COUNT  0x22 /* Get f/w retry cnt/delay. */
#define MBC_DISABLE_VI   0x24 /* Disable VI operation. */
#define MBC_ENABLE_VI   0x25 /* Enable VI operation. */
#define MBC_GET_FIRMWARE_OPTION  0x28 /* Get Firmware Options. */
#define MBC_GET_MEM_OFFLOAD_CNTRL_STAT 0x34 /* Memory Offload ctrl/Stat*/
#define MBC_SET_FIRMWARE_OPTION  0x38 /* Set Firmware Options. */
#define MBC_SET_GET_FC_LED_CONFIG 0x3b /* Set/Get FC LED config */
#define MBC_LOOP_PORT_BYPASS  0x40 /* Loop Port Bypass. */
#define MBC_LOOP_PORT_ENABLE  0x41 /* Loop Port Enable. */
#define MBC_GET_RESOURCE_COUNTS  0x42 /* Get Resource Counts. */
#define MBC_NON_PARTICIPATE  0x43 /* Non-Participating Mode. */
#define MBC_DIAGNOSTIC_ECHO  0x44 /* Diagnostic echo. */
#define MBC_DIAGNOSTIC_LOOP_BACK 0x45 /* Diagnostic loop back. */
#define MBC_ONLINE_SELF_TEST  0x46 /* Online self-test. */
#define MBC_ENHANCED_GET_PORT_DATABASE 0x47 /* Get port database + login */
#define MBC_CONFIGURE_VF  0x4b /* Configure VFs */
#define MBC_RESET_LINK_STATUS  0x52 /* Reset Link Error Status */
#define MBC_IOCB_COMMAND_A64  0x54 /* Execute IOCB command (64) */
#define MBC_PORT_LOGOUT   0x56 /* Port Logout request */
#define MBC_SEND_RNID_ELS  0x57 /* Send RNID ELS request */
#define MBC_SET_RNID_PARAMS  0x59 /* Set RNID parameters */
#define MBC_GET_RNID_PARAMS  0x5a /* Get RNID parameters */
#define MBC_DATA_RATE   0x5d /* Data Rate */
#define MBC_INITIALIZE_FIRMWARE  0x60 /* Initialize firmware */
#define MBC_INITIATE_LIP  0x62 /* Initiate Loop */
      /* Initialization Procedure */
#define MBC_GET_FC_AL_POSITION_MAP 0x63 /* Get FC_AL Position Map. */
#define MBC_GET_PORT_DATABASE  0x64 /* Get Port Database. */
#define MBC_CLEAR_ACA   0x65 /* Clear ACA. */
#define MBC_TARGET_RESET  0x66 /* Target Reset. */
#define MBC_CLEAR_TASK_SET  0x67 /* Clear Task Set. */
#define MBC_ABORT_TASK_SET  0x68 /* Abort Task Set. */
#define MBC_GET_FIRMWARE_STATE  0x69 /* Get firmware state. */
#define MBC_GET_PORT_NAME  0x6a /* Get port name. */
#define MBC_GET_LINK_STATUS  0x6b /* Get port link status. */
#define MBC_LIP_RESET   0x6c /* LIP reset. */
#define MBC_SEND_SNS_COMMAND  0x6e /* Send Simple Name Server */
      /* commandd. */
#define MBC_LOGIN_FABRIC_PORT  0x6f /* Login fabric port. */
#define MBC_SEND_CHANGE_REQUEST  0x70 /* Send Change Request. */
#define MBC_LOGOUT_FABRIC_PORT  0x71 /* Logout fabric port. */
#define MBC_LIP_FULL_LOGIN  0x72 /* Full login LIP. */
#define MBC_LOGIN_LOOP_PORT  0x74 /* Login Loop Port. */
#define MBC_PORT_NODE_NAME_LIST  0x75 /* Get port/node name list. */
#define MBC_INITIALIZE_RECEIVE_QUEUE 0x77 /* Initialize receive queue */
#define MBC_UNLOAD_IP   0x79 /* Shutdown IP */
#define MBC_GET_ID_LIST   0x7C /* Get Port ID list. */
#define MBC_SEND_LFA_COMMAND  0x7D /* Send Loop Fabric Address */
#define MBC_LUN_RESET   0x7E /* Send LUN reset */

/*
 * all the Mt. Rainier mailbox command codes that clash with FC/FCoE ones
 * should be defined with MBC_MR_*
 */

#define MBC_MR_DRV_SHUTDOWN  0x6A

/*
 * ISP24xx mailbox commands
 */

#define MBC_WRITE_SERDES  0x3 /* Write serdes word. */
#define MBC_READ_SERDES   0x4 /* Read serdes word. */
#define MBC_LOAD_DUMP_MPI_RAM  0x5 /* Load/Dump MPI RAM. */
#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_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_DPORT_DIAGNOSTICS  0x47 /* D-Port Diagnostics */
#define MBC_MID_INITIALIZE_FIRMWARE 0x48 /* MID Initialize firmware. */
#define MBC_MID_GET_VP_DATABASE  0x49 /* MID Get VP Database. */
#define MBC_MID_GET_VP_ENTRY  0x4a /* MID Get VP Entry. */
#define MBC_HOST_MEMORY_COPY  0x53 /* Host Memory Copy. */
#define MBC_SEND_RNFT_ELS  0x5e /* Send RNFT ELS request */
#define MBC_GET_LINK_PRIV_STATS  0x6d /* Get link & private data. */
#define MBC_LINK_INITIALIZATION  0x72 /* Do link initialization. */
#define MBC_SET_VENDOR_ID  0x76 /* Set Vendor ID. */
#define MBC_PORT_RESET   0x120 /* Port Reset */
#define MBC_SET_PORT_CONFIG  0x122 /* Set port configuration */
#define MBC_GET_PORT_CONFIG  0x123 /* Get port configuration */

/*
 * ISP81xx mailbox commands
 */

#define MBC_WRITE_MPI_REGISTER  0x01    /* Write MPI Register. */

/*
 * ISP8044 mailbox commands
 */

#define MBC_SET_GET_ETH_SERDES_REG 0x150
#define HCS_WRITE_SERDES  0x3
#define HCS_READ_SERDES   0x4

/* Firmware return data sizes */
#define FCAL_MAP_SIZE 128

/* Mailbox bit definitions for out_mb and in_mb */
#define MBX_31  BIT_31
#define MBX_30  BIT_30
#define MBX_29  BIT_29
#define MBX_28  BIT_28
#define MBX_27  BIT_27
#define MBX_26  BIT_26
#define MBX_25  BIT_25
#define MBX_24  BIT_24
#define MBX_23  BIT_23
#define MBX_22  BIT_22
#define MBX_21  BIT_21
#define MBX_20  BIT_20
#define MBX_19  BIT_19
#define MBX_18  BIT_18
#define MBX_17  BIT_17
#define MBX_16  BIT_16
#define MBX_15  BIT_15
#define MBX_14  BIT_14
#define MBX_13  BIT_13
#define MBX_12  BIT_12
#define MBX_11  BIT_11
#define MBX_10  BIT_10
#define MBX_9  BIT_9
#define MBX_8  BIT_8
#define MBX_7  BIT_7
#define MBX_6  BIT_6
#define MBX_5  BIT_5
#define MBX_4  BIT_4
#define MBX_3  BIT_3
#define MBX_2  BIT_2
#define MBX_1  BIT_1
#define MBX_0  BIT_0

#define RNID_TYPE_ELS_CMD 0x5
#define RNID_TYPE_PORT_LOGIN 0x7
#define RNID_BUFFER_CREDITS 0x8
#define RNID_TYPE_SET_VERSION 0x9
#define RNID_TYPE_ASIC_TEMP 0xC

#define ELS_CMD_MAP_SIZE 32

/*
 * Firmware state codes from get firmware state mailbox command
 */

#define FSTATE_CONFIG_WAIT      0
#define FSTATE_WAIT_AL_PA       1
#define FSTATE_WAIT_LOGIN       2
#define FSTATE_READY            3
#define FSTATE_LOSS_OF_SYNC     4
#define FSTATE_ERROR            5
#define FSTATE_REINIT           6
#define FSTATE_NON_PART         7

#define FSTATE_CONFIG_CORRECT      0
#define FSTATE_P2P_RCV_LIP         1
#define FSTATE_P2P_CHOOSE_LOOP     2
#define FSTATE_P2P_RCV_UNIDEN_LIP  3
#define FSTATE_FATAL_ERROR         4
#define FSTATE_LOOP_BACK_CONN      5

#define QLA27XX_IMG_STATUS_VER_MAJOR   0x01
#define QLA27XX_IMG_STATUS_VER_MINOR    0x00
#define QLA27XX_IMG_STATUS_SIGN   0xFACEFADE
#define QLA28XX_IMG_STATUS_SIGN    0xFACEFADF
#define QLA28XX_IMG_STATUS_SIGN  0xFACEFADF
#define QLA28XX_AUX_IMG_STATUS_SIGN 0xFACEFAED
#define QLA27XX_DEFAULT_IMAGE  0
#define QLA27XX_PRIMARY_IMAGE  1
#define QLA27XX_SECONDARY_IMAGE    2

/*
 * Port Database structure definition
 * Little endian except where noted.
 */

#define PORT_DATABASE_SIZE 128 /* bytes */
typedef struct {
 uint8_t options;
 uint8_t control;
 uint8_t master_state;
 uint8_t slave_state;
 uint8_t reserved[2];
 uint8_t hard_address;
 uint8_t reserved_1;
 uint8_t port_id[4];
 uint8_t node_name[WWN_SIZE];
 uint8_t port_name[WWN_SIZE];
 __le16 execution_throttle;
 uint16_t execution_count;
 uint8_t reset_count;
 uint8_t reserved_2;
 uint16_t resource_allocation;
 uint16_t current_allocation;
 uint16_t queue_head;
 uint16_t queue_tail;
 uint16_t transmit_execution_list_next;
 uint16_t transmit_execution_list_previous;
 uint16_t common_features;
 uint16_t total_concurrent_sequences;
 uint16_t RO_by_information_category;
 uint8_t recipient;
 uint8_t initiator;
 uint16_t receive_data_size;
 uint16_t concurrent_sequences;
 uint16_t open_sequences_per_exchange;
 uint16_t lun_abort_flags;
 uint16_t lun_stop_flags;
 uint16_t stop_queue_head;
 uint16_t stop_queue_tail;
 uint16_t port_retry_timer;
 uint16_t next_sequence_id;
 uint16_t frame_count;
 uint16_t PRLI_payload_length;
 uint8_t prli_svc_param_word_0[2]; /* Big endian */
      /* Bits 15-0 of word 0 */
 uint8_t prli_svc_param_word_3[2]; /* Big endian */
      /* Bits 15-0 of word 3 */
 uint16_t loop_id;
 uint16_t extended_lun_info_list_pointer;
 uint16_t extended_lun_stop_list_pointer;
} port_database_t;

/*
 * Port database slave/master states
 */

#define PD_STATE_DISCOVERY   0
#define PD_STATE_WAIT_DISCOVERY_ACK  1
#define PD_STATE_PORT_LOGIN   2
#define PD_STATE_WAIT_PORT_LOGIN_ACK  3
#define PD_STATE_PROCESS_LOGIN   4
#define PD_STATE_WAIT_PROCESS_LOGIN_ACK  5
#define PD_STATE_PORT_LOGGED_IN   6
#define PD_STATE_PORT_UNAVAILABLE  7
#define PD_STATE_PROCESS_LOGOUT   8
#define PD_STATE_WAIT_PROCESS_LOGOUT_ACK 9
#define PD_STATE_PORT_LOGOUT   10
#define PD_STATE_WAIT_PORT_LOGOUT_ACK  11


#define QLA_ZIO_MODE_6  (BIT_2 | BIT_1)
#define QLA_ZIO_DISABLED 0
#define QLA_ZIO_DEFAULT_TIMER 2

/*
 * ISP Initialization Control Block.
 * Little endian except where noted.
 */

#define ICB_VERSION 1
typedef struct {
 uint8_t  version;
 uint8_t  reserved_1;

 /*
 * LSB BIT 0  = Enable Hard Loop Id
 * LSB BIT 1  = Enable Fairness
 * LSB BIT 2  = Enable Full-Duplex
 * LSB BIT 3  = Enable Fast Posting
 * LSB BIT 4  = Enable Target Mode
 * LSB BIT 5  = Disable Initiator Mode
 * LSB BIT 6  = Enable ADISC
 * LSB BIT 7  = Enable Target Inquiry Data
 *
 * MSB BIT 0  = Enable PDBC Notify
 * MSB BIT 1  = Non Participating LIP
 * MSB BIT 2  = Descending Loop ID Search
 * MSB BIT 3  = Acquire Loop ID in LIPA
 * MSB BIT 4  = Stop PortQ on Full Status
 * MSB BIT 5  = Full Login after LIP
 * MSB BIT 6  = Node Name Option
 * MSB BIT 7  = Ext IFWCB enable bit
 */

 uint8_t  firmware_options[2];

 __le16 frame_payload_size;
 __le16 max_iocb_allocation;
 __le16 execution_throttle;
 uint8_t  retry_count;
 uint8_t  retry_delay;   /* unused */
 uint8_t  port_name[WWN_SIZE];  /* Big endian. */
 uint16_t hard_address;
 uint8_t  inquiry_data;
 uint8_t  login_timeout;
 uint8_t  node_name[WWN_SIZE];  /* Big endian. */

 __le16 request_q_outpointer;
 __le16 response_q_inpointer;
 __le16 request_q_length;
 __le16 response_q_length;
 __le64  request_q_address __packed;
 __le64  response_q_address __packed;

 __le16 lun_enables;
 uint8_t  command_resource_count;
 uint8_t  immediate_notify_resource_count;
 __le16 timeout;
 uint8_t  reserved_2[2];

 /*
 * LSB BIT 0 = Timer Operation mode bit 0
 * LSB BIT 1 = Timer Operation mode bit 1
 * LSB BIT 2 = Timer Operation mode bit 2
 * LSB BIT 3 = Timer Operation mode bit 3
 * LSB BIT 4 = Init Config Mode bit 0
 * LSB BIT 5 = Init Config Mode bit 1
 * LSB BIT 6 = Init Config Mode bit 2
 * LSB BIT 7 = Enable Non part on LIHA failure
 *
 * MSB BIT 0 = Enable class 2
 * MSB BIT 1 = Enable ACK0
 * MSB BIT 2 =
 * MSB BIT 3 =
 * MSB BIT 4 = FC Tape Enable
 * MSB BIT 5 = Enable FC Confirm
 * MSB BIT 6 = Enable command queuing in target mode
 * MSB BIT 7 = No Logo On Link Down
 */

 uint8_t  add_firmware_options[2];

 uint8_t  response_accumulation_timer;
 uint8_t  interrupt_delay_timer;

 /*
 * LSB BIT 0 = Enable Read xfr_rdy
 * LSB BIT 1 = Soft ID only
 * LSB BIT 2 =
 * LSB BIT 3 =
 * LSB BIT 4 = FCP RSP Payload [0]
 * LSB BIT 5 = FCP RSP Payload [1] / Sbus enable - 2200
 * LSB BIT 6 = Enable Out-of-Order frame handling
 * LSB BIT 7 = Disable Automatic PLOGI on Local Loop
 *
 * MSB BIT 0 = Sbus enable - 2300
 * MSB BIT 1 =
 * MSB BIT 2 =
 * MSB BIT 3 =
 * MSB BIT 4 = LED mode
 * MSB BIT 5 = enable 50 ohm termination
 * MSB BIT 6 = Data Rate (2300 only)
 * MSB BIT 7 = Data Rate (2300 only)
 */

 uint8_t  special_options[2];

 uint8_t  reserved_3[26];
} init_cb_t;

/* Special Features Control Block */
struct init_sf_cb {
 uint8_t format;
 uint8_t reserved0;
 /*
 * BIT 15-14 = Reserved
 * BIT_13 = SAN Congestion Management (1 - Enabled, 0 - Disabled)
 * BIT_12 = Remote Write Optimization (1 - Enabled, 0 - Disabled)
 * BIT 11-0 = Reserved
 */

 __le16 flags;
 uint8_t reserved1[32];
 uint16_t discard_OHRB_timeout_value;
 uint16_t remote_write_opt_queue_num;
 uint8_t reserved2[40];
 uint8_t scm_related_parameter[16];
 uint8_t reserved3[32];
};

/*
 * Get Link Status mailbox command return buffer.
 */

#define GLSO_SEND_RPS BIT_0
#define GLSO_USE_DID BIT_3

struct link_statistics {
 __le32 link_fail_cnt;
 __le32 loss_sync_cnt;
 __le32 loss_sig_cnt;
 __le32 prim_seq_err_cnt;
 __le32 inval_xmit_word_cnt;
 __le32 inval_crc_cnt;
 __le32 lip_cnt;
 __le32 link_up_cnt;
 __le32 link_down_loop_init_tmo;
 __le32 link_down_los;
 __le32 link_down_loss_rcv_clk;
 uint32_t reserved0[5];
 __le32 port_cfg_chg;
 uint32_t reserved1[11];
 __le32 rsp_q_full;
 __le32 atio_q_full;
 __le32 drop_ae;
 __le32 els_proto_err;
 __le32 reserved2;
 __le32 tx_frames;
 __le32 rx_frames;
 __le32 discarded_frames;
 __le32 dropped_frames;
 uint32_t reserved3;
 __le32 nos_rcvd;
 uint32_t reserved4[4];
 __le32 tx_prjt;
 __le32 rcv_exfail;
 __le32 rcv_abts;
 __le32 seq_frm_miss;
 __le32 corr_err;
 __le32 mb_rqst;
 __le32 nport_full;
 __le32 eofa;
 uint32_t reserved5;
 __le64 fpm_recv_word_cnt;
 __le64 fpm_disc_word_cnt;
 __le64 fpm_xmit_word_cnt;
 uint32_t reserved6[70];
};

/*
 * NVRAM Command values.
 */

#define NV_START_BIT            BIT_2
#define NV_WRITE_OP             (BIT_26+BIT_24)
#define NV_READ_OP              (BIT_26+BIT_25)
#define NV_ERASE_OP             (BIT_26+BIT_25+BIT_24)
#define NV_MASK_OP              (BIT_26+BIT_25+BIT_24)
#define NV_DELAY_COUNT          10

/*
 * QLogic ISP2100, ISP2200 and ISP2300 NVRAM structure definition.
 */

typedef struct {
 /*
 * NVRAM header
 */

 uint8_t id[4];
 uint8_t nvram_version;
 uint8_t reserved_0;

 /*
 * NVRAM RISC parameter block
 */

 uint8_t parameter_block_version;
 uint8_t reserved_1;

 /*
 * LSB BIT 0  = Enable Hard Loop Id
 * LSB BIT 1  = Enable Fairness
 * LSB BIT 2  = Enable Full-Duplex
 * LSB BIT 3  = Enable Fast Posting
 * LSB BIT 4  = Enable Target Mode
 * LSB BIT 5  = Disable Initiator Mode
 * LSB BIT 6  = Enable ADISC
 * LSB BIT 7  = Enable Target Inquiry Data
 *
 * MSB BIT 0  = Enable PDBC Notify
 * MSB BIT 1  = Non Participating LIP
 * MSB BIT 2  = Descending Loop ID Search
 * MSB BIT 3  = Acquire Loop ID in LIPA
 * MSB BIT 4  = Stop PortQ on Full Status
 * MSB BIT 5  = Full Login after LIP
 * MSB BIT 6  = Node Name Option
 * MSB BIT 7  = Ext IFWCB enable bit
 */

 uint8_t  firmware_options[2];

 __le16 frame_payload_size;
 __le16 max_iocb_allocation;
 __le16 execution_throttle;
 uint8_t  retry_count;
 uint8_t  retry_delay;   /* unused */
 uint8_t  port_name[WWN_SIZE];  /* Big endian. */
 uint16_t hard_address;
 uint8_t  inquiry_data;
 uint8_t  login_timeout;
 uint8_t  node_name[WWN_SIZE];  /* Big endian. */

 /*
 * LSB BIT 0 = Timer Operation mode bit 0
 * LSB BIT 1 = Timer Operation mode bit 1
 * LSB BIT 2 = Timer Operation mode bit 2
 * LSB BIT 3 = Timer Operation mode bit 3
 * LSB BIT 4 = Init Config Mode bit 0
 * LSB BIT 5 = Init Config Mode bit 1
 * LSB BIT 6 = Init Config Mode bit 2
 * LSB BIT 7 = Enable Non part on LIHA failure
 *
 * MSB BIT 0 = Enable class 2
 * MSB BIT 1 = Enable ACK0
 * MSB BIT 2 =
 * MSB BIT 3 =
 * MSB BIT 4 = FC Tape Enable
 * MSB BIT 5 = Enable FC Confirm
 * MSB BIT 6 = Enable command queuing in target mode
 * MSB BIT 7 = No Logo On Link Down
 */

 uint8_t  add_firmware_options[2];

 uint8_t  response_accumulation_timer;
 uint8_t  interrupt_delay_timer;

 /*
 * LSB BIT 0 = Enable Read xfr_rdy
 * LSB BIT 1 = Soft ID only
 * LSB BIT 2 =
 * LSB BIT 3 =
 * LSB BIT 4 = FCP RSP Payload [0]
 * LSB BIT 5 = FCP RSP Payload [1] / Sbus enable - 2200
 * LSB BIT 6 = Enable Out-of-Order frame handling
 * LSB BIT 7 = Disable Automatic PLOGI on Local Loop
 *
 * MSB BIT 0 = Sbus enable - 2300
 * MSB BIT 1 =
 * MSB BIT 2 =
 * MSB BIT 3 =
 * MSB BIT 4 = LED mode
 * MSB BIT 5 = enable 50 ohm termination
 * MSB BIT 6 = Data Rate (2300 only)
 * MSB BIT 7 = Data Rate (2300 only)
 */

 uint8_t  special_options[2];

 /* Reserved for expanded RISC parameter block */
 uint8_t reserved_2[22];

 /*
 * LSB BIT 0 = Tx Sensitivity 1G bit 0
 * LSB BIT 1 = Tx Sensitivity 1G bit 1
 * LSB BIT 2 = Tx Sensitivity 1G bit 2
 * LSB BIT 3 = Tx Sensitivity 1G bit 3
 * LSB BIT 4 = Rx Sensitivity 1G bit 0
 * LSB BIT 5 = Rx Sensitivity 1G bit 1
 * LSB BIT 6 = Rx Sensitivity 1G bit 2
 * LSB BIT 7 = Rx Sensitivity 1G bit 3
 *
 * MSB BIT 0 = Tx Sensitivity 2G bit 0
 * MSB BIT 1 = Tx Sensitivity 2G bit 1
 * MSB BIT 2 = Tx Sensitivity 2G bit 2
 * MSB BIT 3 = Tx Sensitivity 2G bit 3
 * MSB BIT 4 = Rx Sensitivity 2G bit 0
 * MSB BIT 5 = Rx Sensitivity 2G bit 1
 * MSB BIT 6 = Rx Sensitivity 2G bit 2
 * MSB BIT 7 = Rx Sensitivity 2G bit 3
 *
 * LSB BIT 0 = Output Swing 1G bit 0
 * LSB BIT 1 = Output Swing 1G bit 1
 * LSB BIT 2 = Output Swing 1G bit 2
 * LSB BIT 3 = Output Emphasis 1G bit 0
 * LSB BIT 4 = Output Emphasis 1G bit 1
 * LSB BIT 5 = Output Swing 2G bit 0
 * LSB BIT 6 = Output Swing 2G bit 1
 * LSB BIT 7 = Output Swing 2G bit 2
 *
 * MSB BIT 0 = Output Emphasis 2G bit 0
 * MSB BIT 1 = Output Emphasis 2G bit 1
 * MSB BIT 2 = Output Enable
 * MSB BIT 3 =
 * MSB BIT 4 =
 * MSB BIT 5 =
 * MSB BIT 6 =
 * MSB BIT 7 =
 */

 uint8_t seriallink_options[4];

 /*
 * NVRAM host parameter block
 *
 * LSB BIT 0 = Enable spinup delay
 * LSB BIT 1 = Disable BIOS
 * LSB BIT 2 = Enable Memory Map BIOS
 * LSB BIT 3 = Enable Selectable Boot
 * LSB BIT 4 = Disable RISC code load
 * LSB BIT 5 = Set cache line size 1
 * LSB BIT 6 = PCI Parity Disable
 * LSB BIT 7 = Enable extended logging
 *
 * MSB BIT 0 = Enable 64bit addressing
 * MSB BIT 1 = Enable lip reset
 * MSB BIT 2 = Enable lip full login
 * MSB BIT 3 = Enable target reset
 * MSB BIT 4 = Enable database storage
 * MSB BIT 5 = Enable cache flush read
 * MSB BIT 6 = Enable database load
 * MSB BIT 7 = Enable alternate WWN
 */

 uint8_t host_p[2];

 uint8_t boot_node_name[WWN_SIZE];
 uint8_t boot_lun_number;
 uint8_t reset_delay;
 uint8_t port_down_retry_count;
 uint8_t boot_id_number;
 __le16 max_luns_per_target;
 uint8_t fcode_boot_port_name[WWN_SIZE];
 uint8_t alternate_port_name[WWN_SIZE];
 uint8_t alternate_node_name[WWN_SIZE];

 /*
 * BIT 0 = Selective Login
 * BIT 1 = Alt-Boot Enable
 * BIT 2 =
 * BIT 3 = Boot Order List
 * BIT 4 =
 * BIT 5 = Selective LUN
 * BIT 6 =
 * BIT 7 = unused
 */

 uint8_t efi_parameters;

 uint8_t link_down_timeout;

 uint8_t adapter_id[16];

 uint8_t alt1_boot_node_name[WWN_SIZE];
 uint16_t alt1_boot_lun_number;
 uint8_t alt2_boot_node_name[WWN_SIZE];
 uint16_t alt2_boot_lun_number;
 uint8_t alt3_boot_node_name[WWN_SIZE];
 uint16_t alt3_boot_lun_number;
 uint8_t alt4_boot_node_name[WWN_SIZE];
 uint16_t alt4_boot_lun_number;
 uint8_t alt5_boot_node_name[WWN_SIZE];
 uint16_t alt5_boot_lun_number;
 uint8_t alt6_boot_node_name[WWN_SIZE];
 uint16_t alt6_boot_lun_number;
 uint8_t alt7_boot_node_name[WWN_SIZE];
 uint16_t alt7_boot_lun_number;

 uint8_t reserved_3[2];

 /* Offset 200-215 : Model Number */
 uint8_t model_number[16];

 /* OEM related items */
 uint8_t oem_specific[16];

 /*
 * NVRAM Adapter Features offset 232-239
 *
 * LSB BIT 0 = External GBIC
 * LSB BIT 1 = Risc RAM parity
 * LSB BIT 2 = Buffer Plus Module
 * LSB BIT 3 = Multi Chip Adapter
 * LSB BIT 4 = Internal connector
 * LSB BIT 5 =
 * LSB BIT 6 =
 * LSB BIT 7 =
 *
 * MSB BIT 0 =
 * MSB BIT 1 =
 * MSB BIT 2 =
 * MSB BIT 3 =
 * MSB BIT 4 =
 * MSB BIT 5 =
 * MSB BIT 6 =
 * MSB BIT 7 =
 */

 uint8_t adapter_features[2];

 uint8_t reserved_4[16];

 /* Subsystem vendor ID for ISP2200 */
 uint16_t subsystem_vendor_id_2200;

 /* Subsystem device ID for ISP2200 */
 uint16_t subsystem_device_id_2200;

 uint8_t  reserved_5;
 uint8_t  checksum;
} nvram_t;

/*
 * ISP queue - response queue entry definition.
 */

typedef struct {
 uint8_t  entry_type;  /* Entry type. */
 uint8_t  entry_count;  /* Entry count. */
 uint8_t  sys_define;  /* System defined. */
 uint8_t  entry_status;  /* Entry Status. */
 uint32_t handle;   /* System defined handle */
 uint8_t  data[52];
 uint32_t signature;
#define RESPONSE_PROCESSED 0xDEADDEAD /* Signature */
} response_t;

/*
 * ISP queue - ATIO queue entry definition.
 */

struct atio {
 uint8_t  entry_type;  /* Entry type. */
 uint8_t  entry_count;  /* Entry count. */
 __le16  attr_n_length;
 uint8_t  data[56];
 uint32_t signature;
#define ATIO_PROCESSED 0xDEADDEAD  /* Signature */
};

typedef union {
 __le16 extended;
 struct {
  uint8_t reserved;
  uint8_t standard;
 } id;
} target_id_t;

#define SET_TARGET_ID(ha, to, from)   \
do {       \
 if (HAS_EXTENDED_IDS(ha))   \
  to.extended = cpu_to_le16(from); \
 else      \
  to.id.standard = (uint8_t)from;  \
while (0)

/*
 * ISP queue - command entry structure definition.
 */

#define COMMAND_TYPE 0x11  /* Command entry */
typedef struct {
 uint8_t entry_type;  /* Entry type. */
 uint8_t entry_count;  /* Entry count. */
 uint8_t sys_define;  /* System defined. */
 uint8_t entry_status;  /* Entry Status. */
 uint32_t handle;  /* System handle. */
 target_id_t target;  /* SCSI ID */
 __le16 lun;   /* SCSI LUN */
 __le16 control_flags;  /* Control flags. */
#define CF_WRITE BIT_6
#define CF_READ  BIT_5
#define CF_SIMPLE_TAG BIT_3
#define CF_ORDERED_TAG BIT_2
#define CF_HEAD_TAG BIT_1
 uint16_t reserved_1;
 __le16 timeout;  /* Command timeout. */
 __le16 dseg_count;  /* Data segment count. */
 uint8_t scsi_cdb[MAX_CMDSZ];  /* SCSI command words. */
 __le32 byte_count;  /* Total byte count. */
 union {
  struct dsd32 dsd32[3];
  struct dsd64 dsd64[2];
 };
} cmd_entry_t;

/*
 * ISP queue - 64-Bit addressing, command entry structure definition.
 */

#define COMMAND_A64_TYPE 0x19 /* Command A64 entry */
typedef struct {
 uint8_t entry_type;  /* Entry type. */
 uint8_t entry_count;  /* Entry count. */
 uint8_t sys_define;  /* System defined. */
 uint8_t entry_status;  /* Entry Status. */
 uint32_t handle;  /* System handle. */
 target_id_t target;  /* SCSI ID */
 __le16 lun;   /* SCSI LUN */
 __le16 control_flags;  /* Control flags. */
 uint16_t reserved_1;
 __le16 timeout;  /* Command timeout. */
 __le16 dseg_count;  /* Data segment count. */
 uint8_t scsi_cdb[MAX_CMDSZ]; /* SCSI command words. */
 uint32_t byte_count;  /* Total byte count. */
 struct dsd64 dsd[2];
} cmd_a64_entry_t, request_t;

/*
 * ISP queue - continuation entry structure definition.
 */

#define CONTINUE_TYPE  0x02 /* Continuation entry. */
typedef struct {
 uint8_t entry_type;  /* Entry type. */
 uint8_t entry_count;  /* Entry count. */
 uint8_t sys_define;  /* System defined. */
 uint8_t entry_status;  /* Entry Status. */
 uint32_t reserved;
 struct dsd32 dsd[7];
} cont_entry_t;

/*
 * ISP queue - 64-Bit addressing, continuation entry structure definition.
 */

#define CONTINUE_A64_TYPE 0x0A /* Continuation A64 entry. */
typedef struct {
 uint8_t entry_type;  /* Entry type. */
 uint8_t entry_count;  /* Entry count. */
 uint8_t sys_define;  /* System defined. */
 uint8_t entry_status;  /* Entry Status. */
 struct dsd64 dsd[5];
} cont_a64_entry_t;

#define PO_MODE_DIF_INSERT 0
#define PO_MODE_DIF_REMOVE 1
#define PO_MODE_DIF_PASS 2
#define PO_MODE_DIF_REPLACE 3
#define PO_MODE_DIF_TCP_CKSUM 6
#define PO_ENABLE_INCR_GUARD_SEED BIT_3
#define PO_DISABLE_GUARD_CHECK BIT_4
#define PO_DISABLE_INCR_REF_TAG BIT_5
#define PO_DIS_HEADER_MODE BIT_7
#define PO_ENABLE_DIF_BUNDLING BIT_8
#define PO_DIS_FRAME_MODE BIT_9
#define PO_DIS_VALD_APP_ESC BIT_10 /* Dis validation for escape tag/ffffh */
#define PO_DIS_VALD_APP_REF_ESC BIT_11

#define PO_DIS_APP_TAG_REPL BIT_12 /* disable REG Tag replacement */
#define PO_DIS_REF_TAG_REPL BIT_13
#define PO_DIS_APP_TAG_VALD BIT_14 /* disable REF Tag validation */
#define PO_DIS_REF_TAG_VALD BIT_15

/*
 * ISP queue - 64-Bit addressing, continuation crc entry structure definition.
 */

struct crc_context {
 uint32_t handle;  /* System handle. */
 __le32 ref_tag;
 __le16 app_tag;
 uint8_t ref_tag_mask[4]; /* Validation/Replacement Mask*/
 uint8_t app_tag_mask[2]; /* Validation/Replacement Mask*/
 __le16 guard_seed;  /* Initial Guard Seed */
 __le16 prot_opts;  /* Requested Data Protection Mode */
 __le16 blk_size;  /* Data size in bytes */
 __le16 runt_blk_guard; /* Guard value for runt block (tape
 * only) */

 __le32 byte_count;  /* Total byte count/ total data
 * transfer count */

 union {
  struct {
   uint32_t reserved_1;
   uint16_t reserved_2;
   uint16_t reserved_3;
   uint32_t reserved_4;
   struct dsd64 data_dsd[1];
   uint32_t reserved_5[2];
   uint32_t reserved_6;
  } nobundling;
  struct {
   __le32 dif_byte_count; /* Total DIF byte
 * count */

   uint16_t reserved_1;
   __le16 dseg_count; /* Data segment count */
   uint32_t reserved_2;
   struct dsd64 data_dsd[1];
   struct dsd64 dif_dsd;
  } bundling;
 } u;

 struct fcp_cmnd fcp_cmnd;
 dma_addr_t crc_ctx_dma;
 /* List of DMA context transfers */
 struct list_head dsd_list;

 /* List of DIF Bundling context DMA address */
 struct list_head ldif_dsd_list;
 u8 no_ldif_dsd;

 struct list_head ldif_dma_hndl_list;
 u32 dif_bundl_len;
 u8 no_dif_bundl;
 /* This structure should not exceed 512 bytes */
};

#define CRC_CONTEXT_LEN_FW (offsetof(struct crc_context, fcp_cmnd.lun))
#define CRC_CONTEXT_FCPCMND_OFF (offsetof(struct crc_context, fcp_cmnd.lun))

/*
 * ISP queue - status entry structure definition.
 */

#define STATUS_TYPE 0x03  /* Status entry. */
typedef struct {
 uint8_t entry_type;  /* Entry type. */
 uint8_t entry_count;  /* Entry count. */
 uint8_t sys_define;  /* System defined. */
 uint8_t entry_status;  /* Entry Status. */
 uint32_t handle;  /* System handle. */
 __le16 scsi_status;  /* SCSI status. */
 __le16 comp_status;  /* Completion status. */
 __le16 state_flags;  /* State flags. */
 __le16 status_flags;  /* Status flags. */
 __le16 rsp_info_len;  /* Response Info Length. */
 __le16 req_sense_length; /* Request sense data length. */
 __le32 residual_length; /* Residual transfer length. */
 uint8_t rsp_info[8];  /* FCP response information. */
 uint8_t req_sense_data[32]; /* Request sense data. */
} sts_entry_t;

/*
 * Status entry entry status
 */

#define RF_RQ_DMA_ERROR BIT_6  /* Request Queue DMA error. */
#define RF_INV_E_ORDER BIT_5  /* Invalid entry order. */
#define RF_INV_E_COUNT BIT_4  /* Invalid entry count. */
#define RF_INV_E_PARAM BIT_3  /* Invalid entry parameter. */
#define RF_INV_E_TYPE BIT_2  /* Invalid entry type. */
#define RF_BUSY  BIT_1  /* Busy */
#define RF_MASK  (RF_RQ_DMA_ERROR | RF_INV_E_ORDER | RF_INV_E_COUNT | \
    RF_INV_E_PARAM | RF_INV_E_TYPE | RF_BUSY)
#define RF_MASK_24XX (RF_INV_E_ORDER | RF_INV_E_COUNT | RF_INV_E_PARAM | \
    RF_INV_E_TYPE)

/*
 * Status entry SCSI status bit definitions.
 */

#define SS_MASK    0xfff /* Reserved bits BIT_12-BIT_15*/
#define SS_RESIDUAL_UNDER  BIT_11
#define SS_RESIDUAL_OVER  BIT_10
#define SS_SENSE_LEN_VALID  BIT_9
#define SS_RESPONSE_INFO_LEN_VALID BIT_8
#define SS_SCSI_STATUS_BYTE 0xff

#define SS_RESERVE_CONFLICT  (BIT_4 | BIT_3)
#define SS_BUSY_CONDITION  BIT_3
#define SS_CONDITION_MET  BIT_2
#define SS_CHECK_CONDITION  BIT_1

/*
 * Status entry completion status
 */

#define CS_COMPLETE  0x0 /* No errors */
#define CS_INCOMPLETE  0x1 /* Incomplete transfer of cmd. */
#define CS_DMA   0x2 /* A DMA direction error. */
#define CS_TRANSPORT  0x3 /* Transport error. */
#define CS_RESET  0x4 /* SCSI bus reset occurred */
#define CS_ABORTED  0x5 /* System aborted command. */
#define CS_TIMEOUT  0x6 /* Timeout error. */
#define CS_DATA_OVERRUN  0x7 /* Data overrun. */
#define CS_DIF_ERROR  0xC /* DIF error detected  */

#define CS_DATA_UNDERRUN 0x15 /* Data Underrun. */
#define CS_QUEUE_FULL  0x1C /* Queue Full. */
#define CS_PORT_UNAVAILABLE 0x28 /* Port unavailable */
     /* (selection timeout) */
#define CS_PORT_LOGGED_OUT 0x29 /* Port Logged Out */
#define CS_PORT_CONFIG_CHG 0x2A /* Port Configuration Changed */
#define CS_PORT_BUSY  0x2B /* Port Busy */
#define CS_COMPLETE_CHKCOND 0x30 /* Error? */
#define CS_IOCB_ERROR  0x31 /* Generic error for IOCB request
   failure */

#define CS_REJECT_RECEIVED 0x4E /* Reject received */
#define CS_EDIF_AUTH_ERROR 0x63 /* decrypt error */
#define CS_EDIF_PAD_LEN_ERROR 0x65 /* pad > frame size, not 4byte align */
#define CS_EDIF_INV_REQ  0x66 /* invalid request */
#define CS_EDIF_SPI_ERROR 0x67 /* rx frame unable to locate sa */
#define CS_EDIF_HDR_ERROR 0x69 /* data frame != expected len */
#define CS_BAD_PAYLOAD  0x80 /* Driver defined */
#define CS_UNKNOWN  0x81 /* Driver defined */
#define CS_RETRY  0x82 /* Driver defined */
#define CS_LOOP_DOWN_ABORT 0x83 /* Driver defined */

#define CS_BIDIR_RD_OVERRUN   0x700
#define CS_BIDIR_RD_WR_OVERRUN   0x707
#define CS_BIDIR_RD_OVERRUN_WR_UNDERRUN  0x715
#define CS_BIDIR_RD_UNDERRUN   0x1500
#define CS_BIDIR_RD_UNDERRUN_WR_OVERRUN  0x1507
#define CS_BIDIR_RD_WR_UNDERRUN   0x1515
#define CS_BIDIR_DMA    0x200
/*
 * Status entry status flags
 */

#define SF_ABTS_TERMINATED BIT_10
#define SF_LOGOUT_SENT  BIT_13

/*
 * ISP queue - status continuation entry structure definition.
 */

#define STATUS_CONT_TYPE 0x10 /* Status continuation entry. */
typedef struct {
 uint8_t entry_type;  /* Entry type. */
 uint8_t entry_count;  /* Entry count. */
 uint8_t sys_define;  /* System defined. */
 uint8_t entry_status;  /* Entry Status. */
 uint8_t data[60];  /* data */
} sts_cont_entry_t;

/*
 * ISP queue - RIO Type 1 status entry (32 bit I/O entry handles)
 * structure definition.
 */

#define STATUS_TYPE_21 0x21  /* Status entry. */
typedef struct {
 uint8_t entry_type;  /* Entry type. */
 uint8_t entry_count;  /* Entry count. */
 uint8_t handle_count;  /* Handle count. */
 uint8_t entry_status;  /* Entry Status. */
 uint32_t handle[15];  /* System handles. */
} sts21_entry_t;

/*
 * ISP queue - RIO Type 2 status entry (16 bit I/O entry handles)
 * structure definition.
 */

#define STATUS_TYPE_22 0x22  /* Status entry. */
typedef struct {
 uint8_t entry_type;  /* Entry type. */
 uint8_t entry_count;  /* Entry count. */
 uint8_t handle_count;  /* Handle count. */
 uint8_t entry_status;  /* Entry Status. */
 uint16_t handle[30];  /* System handles. */
} sts22_entry_t;

/*
 * ISP queue - marker entry structure definition.
 */

#define MARKER_TYPE 0x04  /* Marker entry. */
typedef struct {
 uint8_t entry_type;  /* Entry type. */
 uint8_t entry_count;  /* Entry count. */
 uint8_t handle_count;  /* Handle count. */
 uint8_t entry_status;  /* Entry Status. */
 uint32_t sys_define_2;  /* System defined. */
 target_id_t target;  /* SCSI ID */
 uint8_t modifier;  /* Modifier (7-0). */
#define MK_SYNC_ID_LUN 0  /* Synchronize ID/LUN */
#define MK_SYNC_ID 1  /* Synchronize ID */
--> --------------------

--> maximum size reached

--> --------------------

Messung V0.5
C=90 H=92 G=90

¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.20Angebot  ¤

*Eine klare Vorstellung vom Zielzustand






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge