scsi: qla2xxx: Enable type checking for the SRB free and done callback functions
[linux-2.6-block.git] / drivers / scsi / qla2xxx / qla_def.h
index bad2b12604f1b49ed60c40cf1c146a340cc4149d..65d79bcb7ccf62f27a4316882baea1c25640d376 100644 (file)
 #include <scsi/scsi_transport_fc.h>
 #include <scsi/scsi_bsg_fc.h>
 
+/* 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;
+
 #include "qla_bsg.h"
 #include "qla_dsd.h"
 #include "qla_nx.h"
 #define RD_REG_BYTE_RELAXED(addr)      readb_relaxed(addr)
 #define RD_REG_WORD_RELAXED(addr)      readw_relaxed(addr)
 #define RD_REG_DWORD_RELAXED(addr)     readl_relaxed(addr)
-#define WRT_REG_BYTE(addr, data)       writeb(data,addr)
-#define WRT_REG_WORD(addr, data)       writew(data,addr)
-#define WRT_REG_DWORD(addr, data)      writel(data,addr)
+#define WRT_REG_BYTE(addr, data)       writeb(data, addr)
+#define WRT_REG_WORD(addr, data)       writew(data, addr)
+#define WRT_REG_DWORD(addr, data)      writel(data, addr)
 
 /*
  * ISP83XX specific remote register addresses
  * 133Mhz slot.
  */
 #define RD_REG_WORD_PIO(addr)          (inw((unsigned long)addr))
-#define WRT_REG_WORD_PIO(addr, data)   (outw(data,(unsigned long)addr))
+#define WRT_REG_WORD_PIO(addr, data)   (outw(data, (unsigned long)addr))
 
 /*
  * Fibre Channel device definitions.
@@ -343,6 +357,51 @@ typedef union {
 } port_id_t;
 #define INVALID_PORT_ID        0xFFFFFF
 
+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 els_logo_payload {
        uint8_t opcode;
        uint8_t rsvd[3];
@@ -537,6 +596,7 @@ typedef struct srb {
        wait_queue_head_t nvme_ls_waitq;
        struct fc_port *fcport;
        struct scsi_qla_host *vha;
+       unsigned int start_timer:1;
        uint32_t handle;
        uint16_t flags;
        uint16_t type;
@@ -554,8 +614,18 @@ typedef struct srb {
                struct bsg_job *bsg_job;
                struct srb_cmd scmd;
        } u;
-       void (*done)(void *, int);
-       void (*free)(void *);
+       /*
+        * 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);
 } srb_t;
 
@@ -1851,7 +1921,7 @@ struct crc_context {
                        uint16_t        reserved_2;
                        uint16_t        reserved_3;
                        uint32_t        reserved_4;
-                       struct dsd64    data_dsd;
+                       struct dsd64    data_dsd[1];
                        uint32_t        reserved_5[2];
                        uint32_t        reserved_6;
                } nobundling;
@@ -1861,7 +1931,7 @@ struct crc_context {
                        uint16_t        reserved_1;
                        __le16  dseg_count;     /* Data segment count */
                        uint32_t        reserved_2;
-                       struct dsd64    data_dsd;
+                       struct dsd64    data_dsd[1];
                        struct dsd64    dif_dsd;
                } bundling;
        } u;
@@ -2745,7 +2815,7 @@ struct ct_sns_req {
                /* GA_NXT, GPN_ID, GNN_ID, GFT_ID, GFPN_ID */
                struct {
                        uint8_t reserved;
-                       uint8_t port_id[3];
+                       be_id_t port_id;
                } port_id;
 
                struct {
@@ -2764,13 +2834,13 @@ struct ct_sns_req {
 
                struct {
                        uint8_t reserved;
-                       uint8_t port_id[3];
+                       be_id_t port_id;
                        uint8_t fc4_types[32];
                } rft_id;
 
                struct {
                        uint8_t reserved;
-                       uint8_t port_id[3];
+                       be_id_t port_id;
                        uint16_t reserved2;
                        uint8_t fc4_feature;
                        uint8_t fc4_type;
@@ -2778,7 +2848,7 @@ struct ct_sns_req {
 
                struct {
                        uint8_t reserved;
-                       uint8_t port_id[3];
+                       be_id_t port_id;
                        uint8_t node_name[8];
                } rnn_id;
 
@@ -2865,7 +2935,7 @@ struct ct_rsp_hdr {
 
 struct ct_sns_gid_pt_data {
        uint8_t control_byte;
-       uint8_t port_id[3];
+       be_id_t port_id;
 };
 
 /* It's the same for both GPN_FT and GNN_FT */
@@ -2895,7 +2965,7 @@ struct ct_sns_rsp {
        union {
                struct {
                        uint8_t port_type;
-                       uint8_t port_id[3];
+                       be_id_t port_id;
                        uint8_t port_name[8];
                        uint8_t sym_port_name_len;
                        uint8_t sym_port_name[255];
@@ -3111,7 +3181,7 @@ struct isp_operations {
        void (*update_fw_options) (struct scsi_qla_host *);
        int (*load_risc) (struct scsi_qla_host *, uint32_t *);
 
-       char * (*pci_info_str) (struct scsi_qla_host *, char *);
+       char * (*pci_info_str)(struct scsi_qla_host *, char *, size_t);
        char * (*fw_version_str)(struct scsi_qla_host *, char *, size_t);
 
        irq_handler_t intr_handler;
@@ -3850,7 +3920,7 @@ struct qla_hw_data {
 
        /* NVRAM configuration data */
 #define MAX_NVRAM_SIZE  4096
-#define VPD_OFFSET      MAX_NVRAM_SIZE / 2
+#define VPD_OFFSET      (MAX_NVRAM_SIZE / 2)
        uint16_t        nvram_size;
        uint16_t        nvram_base;
        void            *nvram;
@@ -4628,6 +4698,7 @@ struct secure_flash_update_block_pk {
 #define QLA_SUSPENDED                  0x106
 #define QLA_BUSY                       0x107
 #define QLA_ALREADY_REGISTERED         0x109
+#define QLA_OS_TIMER_EXPIRED           0x10a
 
 #define NVRAM_DELAY()          udelay(10)