Merge branch 'master' into for_paulus
[linux-drm-fsl-dcu.git] / drivers / scsi / ipr.h
index 1ad24df69d704d910cadc555e10fe03167cc12a1..88f285de97bb22ab45c607c8026da1dd0438830e 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <linux/types.h>
 #include <linux/completion.h>
+#include <linux/libata.h>
 #include <linux/list.h>
 #include <linux/kref.h>
 #include <scsi/scsi.h>
@@ -36,8 +37,8 @@
 /*
  * Literals
  */
-#define IPR_DRIVER_VERSION "2.1.3"
-#define IPR_DRIVER_DATE "(March 29, 2006)"
+#define IPR_DRIVER_VERSION "2.3.1"
+#define IPR_DRIVER_DATE "(January 23, 2007)"
 
 /*
  * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding
@@ -45,6 +46,7 @@
  *     This can be adjusted at runtime through sysfs device attributes.
  */
 #define IPR_MAX_CMD_PER_LUN                            6
+#define IPR_MAX_CMD_PER_ATA_LUN                        1
 
 /*
  * IPR_NUM_BASE_CMD_BLKS: This defines the maximum number of
@@ -52,6 +54,8 @@
  */
 #define IPR_NUM_BASE_CMD_BLKS                          100
 
+#define PCI_DEVICE_ID_IBM_OBSIDIAN_E   0x0339
+
 #define IPR_SUBS_DEV_ID_2780   0x0264
 #define IPR_SUBS_DEV_ID_5702   0x0266
 #define IPR_SUBS_DEV_ID_5703   0x0278
 #define IPR_SUBS_DEV_ID_571F   0x02D5
 #define IPR_SUBS_DEV_ID_572A   0x02C1
 #define IPR_SUBS_DEV_ID_572B   0x02C2
+#define IPR_SUBS_DEV_ID_572F   0x02C3
 #define IPR_SUBS_DEV_ID_575B   0x030D
+#define IPR_SUBS_DEV_ID_575C   0x0338
+#define IPR_SUBS_DEV_ID_57B7   0x0360
+#define IPR_SUBS_DEV_ID_57B8   0x02C2
 
 #define IPR_NAME                               "ipr"
 
 #define IPR_IOASC_IOA_WAS_RESET                        0x10000001
 #define IPR_IOASC_PCI_ACCESS_ERROR                     0x10000002
 
+#define IPR_DEFAULT_MAX_ERROR_DUMP                     984
 #define IPR_NUM_LOG_HCAMS                              2
 #define IPR_NUM_CFG_CHG_HCAMS                          2
 #define IPR_NUM_HCAMS  (IPR_NUM_LOG_HCAMS + IPR_NUM_CFG_CHG_HCAMS)
 #define IPR_IOA_BUS                                            0xff
 #define IPR_IOA_TARGET                                 0xff
 #define IPR_IOA_LUN                                            0xff
-#define IPR_MAX_NUM_BUSES                              8
+#define IPR_MAX_NUM_BUSES                              16
 #define IPR_MAX_BUS_TO_SCAN                            IPR_MAX_NUM_BUSES
 
 #define IPR_NUM_RESET_RELOAD_RETRIES           3
 #define        IPR_LUN_RESET                                   0x40
 #define        IPR_TARGET_RESET                                        0x20
 #define        IPR_BUS_RESET                                   0x10
+#define        IPR_ATA_PHY_RESET                                       0x80
 #define IPR_ID_HOST_RR_Q                               0xC4
 #define IPR_QUERY_IOA_CONFIG                           0xC5
 #define IPR_CANCEL_ALL_REQUESTS                        0xCE
@@ -295,7 +305,11 @@ struct ipr_std_inq_data {
 }__attribute__ ((packed));
 
 struct ipr_config_table_entry {
-       u8 service_level;
+       u8 proto;
+#define IPR_PROTO_SATA                 0x02
+#define IPR_PROTO_SATA_ATAPI           0x03
+#define IPR_PROTO_SAS_STP              0x06
+#define IPR_PROTO_SAS_STP_ATAPI        0x07
        u8 array_id;
        u8 flags;
 #define IPR_IS_IOA_RESOURCE    0x80
@@ -307,6 +321,7 @@ struct ipr_config_table_entry {
 #define IPR_SUBTYPE_AF_DASD                    0
 #define IPR_SUBTYPE_GENERIC_SCSI       1
 #define IPR_SUBTYPE_VOLUME_SET         2
+#define IPR_SUBTYPE_GENERIC_ATA        4
 
 #define IPR_QUEUEING_MODEL(res)        ((((res)->cfgte.flags) & 0x70) >> 4)
 #define IPR_QUEUE_FROZEN_MODEL 0
@@ -350,6 +365,7 @@ struct ipr_cmd_pkt {
 #define IPR_RQTYPE_SCSICDB             0x00
 #define IPR_RQTYPE_IOACMD              0x01
 #define IPR_RQTYPE_HCAM                        0x02
+#define IPR_RQTYPE_ATA_PASSTHRU        0x04
 
        u8 luntar_luntrn;
 
@@ -373,6 +389,37 @@ struct ipr_cmd_pkt {
        __be16 timeout;
 }__attribute__ ((packed, aligned(4)));
 
+struct ipr_ioarcb_ata_regs {
+       u8 flags;
+#define IPR_ATA_FLAG_PACKET_CMD                        0x80
+#define IPR_ATA_FLAG_XFER_TYPE_DMA                     0x40
+#define IPR_ATA_FLAG_STATUS_ON_GOOD_COMPLETION 0x20
+       u8 reserved[3];
+
+       __be16 data;
+       u8 feature;
+       u8 nsect;
+       u8 lbal;
+       u8 lbam;
+       u8 lbah;
+       u8 device;
+       u8 command;
+       u8 reserved2[3];
+       u8 hob_feature;
+       u8 hob_nsect;
+       u8 hob_lbal;
+       u8 hob_lbam;
+       u8 hob_lbah;
+       u8 ctl;
+}__attribute__ ((packed, aligned(4)));
+
+struct ipr_ioarcb_add_data {
+       union {
+               struct ipr_ioarcb_ata_regs regs;
+               __be32 add_cmd_parms[10];
+       }u;
+}__attribute__ ((packed, aligned(4)));
+
 /* IOA Request Control Block    128 bytes  */
 struct ipr_ioarcb {
        __be32 ioarcb_host_pci_addr;
@@ -397,7 +444,7 @@ struct ipr_ioarcb {
        struct ipr_cmd_pkt cmd_pkt;
 
        __be32 add_cmd_parms_len;
-       __be32 add_cmd_parms[10];
+       struct ipr_ioarcb_add_data add_data;
 }__attribute__((packed, aligned (4)));
 
 struct ipr_ioadl_desc {
@@ -433,6 +480,21 @@ struct ipr_ioasa_gpdd {
        __be32 ioa_data[2];
 }__attribute__((packed, aligned (4)));
 
+struct ipr_ioasa_gata {
+       u8 error;
+       u8 nsect;               /* Interrupt reason */
+       u8 lbal;
+       u8 lbam;
+       u8 lbah;
+       u8 device;
+       u8 status;
+       u8 alt_status;  /* ATA CTL */
+       u8 hob_nsect;
+       u8 hob_lbal;
+       u8 hob_lbam;
+       u8 hob_lbah;
+}__attribute__((packed, aligned (4)));
+
 struct ipr_auto_sense {
        __be16 auto_sense_len;
        __be16 ioa_data_len;
@@ -466,6 +528,7 @@ struct ipr_ioasa {
        __be32 ioasc_specific;  /* status code specific field */
 #define IPR_ADDITIONAL_STATUS_FMT              0x80000000
 #define IPR_AUTOSENSE_VALID                    0x40000000
+#define IPR_ATA_DEVICE_WAS_RESET               0x20000000
 #define IPR_IOASC_SPECIFIC_MASK                0x00ffffff
 #define IPR_FIELD_POINTER_VALID                (0x80000000 >> 8)
 #define IPR_FIELD_POINTER_MASK         0x0000ffff
@@ -474,6 +537,7 @@ struct ipr_ioasa {
                struct ipr_ioasa_vset vset;
                struct ipr_ioasa_af_dasd dasd;
                struct ipr_ioasa_gpdd gpdd;
+               struct ipr_ioasa_gata gata;
        } u;
 
        struct ipr_auto_sense auto_sense;
@@ -674,6 +738,64 @@ struct ipr_hostrcb_type_17_error {
        u32 data[476];
 }__attribute__((packed, aligned (4)));
 
+struct ipr_hostrcb_config_element {
+       u8 type_status;
+#define IPR_PATH_CFG_TYPE_MASK 0xF0
+#define IPR_PATH_CFG_NOT_EXIST 0x00
+#define IPR_PATH_CFG_IOA_PORT          0x10
+#define IPR_PATH_CFG_EXP_PORT          0x20
+#define IPR_PATH_CFG_DEVICE_PORT       0x30
+#define IPR_PATH_CFG_DEVICE_LUN        0x40
+
+#define IPR_PATH_CFG_STATUS_MASK       0x0F
+#define IPR_PATH_CFG_NO_PROB           0x00
+#define IPR_PATH_CFG_DEGRADED          0x01
+#define IPR_PATH_CFG_FAILED            0x02
+#define IPR_PATH_CFG_SUSPECT           0x03
+#define IPR_PATH_NOT_DETECTED          0x04
+#define IPR_PATH_INCORRECT_CONN        0x05
+
+       u8 cascaded_expander;
+       u8 phy;
+       u8 link_rate;
+#define IPR_PHY_LINK_RATE_MASK 0x0F
+
+       __be32 wwid[2];
+}__attribute__((packed, aligned (4)));
+
+struct ipr_hostrcb_fabric_desc {
+       __be16 length;
+       u8 ioa_port;
+       u8 cascaded_expander;
+       u8 phy;
+       u8 path_state;
+#define IPR_PATH_ACTIVE_MASK           0xC0
+#define IPR_PATH_NO_INFO               0x00
+#define IPR_PATH_ACTIVE                        0x40
+#define IPR_PATH_NOT_ACTIVE            0x80
+
+#define IPR_PATH_STATE_MASK            0x0F
+#define IPR_PATH_STATE_NO_INFO 0x00
+#define IPR_PATH_HEALTHY               0x01
+#define IPR_PATH_DEGRADED              0x02
+#define IPR_PATH_FAILED                        0x03
+
+       __be16 num_entries;
+       struct ipr_hostrcb_config_element elem[1];
+}__attribute__((packed, aligned (4)));
+
+#define for_each_fabric_cfg(fabric, cfg) \
+               for (cfg = (fabric)->elem; \
+                       cfg < ((fabric)->elem + be16_to_cpu((fabric)->num_entries)); \
+                       cfg++)
+
+struct ipr_hostrcb_type_20_error {
+       u8 failure_reason[64];
+       u8 reserved[3];
+       u8 num_entries;
+       struct ipr_hostrcb_fabric_desc desc[1];
+}__attribute__((packed, aligned (4)));
+
 struct ipr_hostrcb_error {
        __be32 failing_dev_ioasc;
        struct ipr_res_addr failing_dev_res_addr;
@@ -690,6 +812,7 @@ struct ipr_hostrcb_error {
                struct ipr_hostrcb_type_13_error type_13_error;
                struct ipr_hostrcb_type_14_error type_14_error;
                struct ipr_hostrcb_type_17_error type_17_error;
+               struct ipr_hostrcb_type_20_error type_20_error;
        } u;
 }__attribute__((packed, aligned (4)));
 
@@ -729,6 +852,7 @@ struct ipr_hcam {
 #define IPR_HOST_RCB_OVERLAY_ID_14                             0x14
 #define IPR_HOST_RCB_OVERLAY_ID_16                             0x16
 #define IPR_HOST_RCB_OVERLAY_ID_17                             0x17
+#define IPR_HOST_RCB_OVERLAY_ID_20                             0x20
 #define IPR_HOST_RCB_OVERLAY_ID_DEFAULT                        0xFF
 
        u8 reserved1[3];
@@ -748,6 +872,7 @@ struct ipr_hostrcb {
        struct ipr_hcam hcam;
        dma_addr_t hostrcb_dma;
        struct list_head queue;
+       struct ipr_ioa_cfg *ioa_cfg;
 };
 
 /* IPR smart dump table structures */
@@ -793,6 +918,13 @@ struct ipr_bus_attributes {
        u32 max_xfer_rate;
 };
 
+struct ipr_sata_port {
+       struct ipr_ioa_cfg *ioa_cfg;
+       struct ata_port *ap;
+       struct ipr_resource_entry *res;
+       struct ipr_ioasa_gata ioasa;
+};
+
 struct ipr_resource_entry {
        struct ipr_config_table_entry cfgte;
        u8 needs_sync_complete:1;
@@ -802,6 +934,7 @@ struct ipr_resource_entry {
        u8 resetting_device:1;
 
        struct scsi_device *sdev;
+       struct ipr_sata_port *sata_port;
        struct list_head queue;
 };
 
@@ -872,10 +1005,11 @@ struct ipr_trace_entry {
        u32 time;
 
        u8 op_code;
+       u8 ata_op_code;
        u8 type;
 #define IPR_TRACE_START                        0x00
 #define IPR_TRACE_FINISH               0xff
-       u16 cmd_index;
+       u8 cmd_index;
 
        __be32 res_handle;
        union {
@@ -1017,6 +1151,7 @@ struct ipr_ioa_cfg {
 
        struct ipr_cmnd *reset_cmd;
 
+       struct ata_host ata_host;
        char ipr_cmd_label[8];
 #define IPR_CMD_LABEL          "ipr_cmnd"
        struct ipr_cmnd *ipr_cmnd_list[IPR_NUM_CMD_BLKS];
@@ -1029,6 +1164,7 @@ struct ipr_cmnd {
        struct ipr_ioadl_desc ioadl[IPR_NUM_IOADL_ENTRIES];
        struct list_head queue;
        struct scsi_cmnd *scsi_cmd;
+       struct ata_queued_cmd *qc;
        struct completion completion;
        struct timer_list timer;
        void (*done) (struct ipr_cmnd *);
@@ -1215,6 +1351,17 @@ struct ipr_ucode_image_header {
        }                                                               \
 }
 
+#define ipr_hcam_err(hostrcb, fmt, ...)                                        \
+{                                                                                                      \
+       if (ipr_is_device(&(hostrcb)->hcam.u.error.failing_dev_res_addr)) {             \
+               ipr_ra_err((hostrcb)->ioa_cfg,                                                  \
+                               (hostrcb)->hcam.u.error.failing_dev_res_addr,                   \
+                               fmt, ##__VA_ARGS__);                                                    \
+       } else {                                                                                        \
+               dev_err(&(hostrcb)->ioa_cfg->pdev->dev, fmt, ##__VA_ARGS__);            \
+       }                                                                                               \
+}
+
 #define ipr_trace ipr_dbg("%s: %s: Line: %d\n",\
        __FILE__, __FUNCTION__, __LINE__)
 
@@ -1307,6 +1454,22 @@ static inline int ipr_is_scsi_disk(struct ipr_resource_entry *res)
                return 0;
 }
 
+/**
+ * ipr_is_gata - Determine if a resource is a generic ATA resource
+ * @res:       resource entry struct
+ *
+ * Return value:
+ *     1 if GATA / 0 if not GATA
+ **/
+static inline int ipr_is_gata(struct ipr_resource_entry *res)
+{
+       if (!ipr_is_ioa_resource(res) &&
+           IPR_RES_SUBTYPE(res) == IPR_SUBTYPE_GENERIC_ATA)
+               return 1;
+       else
+               return 0;
+}
+
 /**
  * ipr_is_naca_model - Determine if a resource is using NACA queueing model
  * @res:       resource entry struct