[SCSI] ipr: Runtime debugging options
[powerpc.git] / drivers / scsi / ipr.h
index 8cf9671..414aa07 100644 (file)
 #define IPR_DRIVER_VERSION "2.0.14"
 #define IPR_DRIVER_DATE "(May 2, 2005)"
 
-/*
- * IPR_DBG_TRACE: Setting this to 1 will turn on some general function tracing
- *                     resulting in a bunch of extra debugging printks to the console
- *
- * IPR_DEBUG:  Setting this to 1 will turn on some error path tracing.
- *                     Enables the ipr_trace macro.
- */
-#ifdef IPR_DEBUG_ALL
-#define IPR_DEBUG                              1
-#define IPR_DBG_TRACE                  1
-#else
-#define IPR_DEBUG                              0
-#define IPR_DBG_TRACE                  0
-#endif
-
 /*
  * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding
  *     ops per device for devices not running tagged command queuing.
@@ -261,6 +246,11 @@ struct ipr_std_inq_vpids {
        u8 product_id[IPR_PROD_ID_LEN];
 }__attribute__((packed));
 
+struct ipr_vpd {
+       struct ipr_std_inq_vpids vpids;
+       u8 sn[IPR_SERIAL_NUM_LEN];
+}__attribute__((packed));
+
 struct ipr_std_inq_data {
        u8 peri_qual_dev_type;
 #define IPR_STD_INQ_PERI_QUAL(peri) ((peri) >> 5)
@@ -536,22 +526,26 @@ struct ipr_inquiry_page3 {
        u8 patch_number[4];
 }__attribute__((packed));
 
+#define IPR_INQUIRY_PAGE0_ENTRIES 20
+struct ipr_inquiry_page0 {
+       u8 peri_qual_dev_type;
+       u8 page_code;
+       u8 reserved1;
+       u8 len;
+       u8 page[IPR_INQUIRY_PAGE0_ENTRIES];
+}__attribute__((packed));
+
 struct ipr_hostrcb_device_data_entry {
-       struct ipr_std_inq_vpids dev_vpids;
-       u8 dev_sn[IPR_SERIAL_NUM_LEN];
+       struct ipr_vpd vpd;
        struct ipr_res_addr dev_res_addr;
-       struct ipr_std_inq_vpids new_dev_vpids;
-       u8 new_dev_sn[IPR_SERIAL_NUM_LEN];
-       struct ipr_std_inq_vpids ioa_last_with_dev_vpids;
-       u8 ioa_last_with_dev_sn[IPR_SERIAL_NUM_LEN];
-       struct ipr_std_inq_vpids cfc_last_with_dev_vpids;
-       u8 cfc_last_with_dev_sn[IPR_SERIAL_NUM_LEN];
+       struct ipr_vpd new_vpd;
+       struct ipr_vpd ioa_last_with_dev_vpd;
+       struct ipr_vpd cfc_last_with_dev_vpd;
        __be32 ioa_data[5];
 }__attribute__((packed, aligned (4)));
 
 struct ipr_hostrcb_array_data_entry {
-       struct ipr_std_inq_vpids vpids;
-       u8 serial_num[IPR_SERIAL_NUM_LEN];
+       struct ipr_vpd vpd;
        struct ipr_res_addr expected_dev_res_addr;
        struct ipr_res_addr dev_res_addr;
 }__attribute__((packed, aligned (4)));
@@ -568,47 +562,35 @@ struct ipr_hostrcb_type_01_error {
 }__attribute__((packed, aligned (4)));
 
 struct ipr_hostrcb_type_02_error {
-       struct ipr_std_inq_vpids ioa_vpids;
-       u8 ioa_sn[IPR_SERIAL_NUM_LEN];
-       struct ipr_std_inq_vpids cfc_vpids;
-       u8 cfc_sn[IPR_SERIAL_NUM_LEN];
-       struct ipr_std_inq_vpids ioa_last_attached_to_cfc_vpids;
-       u8 ioa_last_attached_to_cfc_sn[IPR_SERIAL_NUM_LEN];
-       struct ipr_std_inq_vpids cfc_last_attached_to_ioa_vpids;
-       u8 cfc_last_attached_to_ioa_sn[IPR_SERIAL_NUM_LEN];
+       struct ipr_vpd ioa_vpd;
+       struct ipr_vpd cfc_vpd;
+       struct ipr_vpd ioa_last_attached_to_cfc_vpd;
+       struct ipr_vpd cfc_last_attached_to_ioa_vpd;
        __be32 ioa_data[3];
-       u8 reserved[844];
 }__attribute__((packed, aligned (4)));
 
 struct ipr_hostrcb_type_03_error {
-       struct ipr_std_inq_vpids ioa_vpids;
-       u8 ioa_sn[IPR_SERIAL_NUM_LEN];
-       struct ipr_std_inq_vpids cfc_vpids;
-       u8 cfc_sn[IPR_SERIAL_NUM_LEN];
+       struct ipr_vpd ioa_vpd;
+       struct ipr_vpd cfc_vpd;
        __be32 errors_detected;
        __be32 errors_logged;
        u8 ioa_data[12];
-       struct ipr_hostrcb_device_data_entry dev_entry[3];
-       u8 reserved[444];
+       struct ipr_hostrcb_device_data_entry dev[3];
 }__attribute__((packed, aligned (4)));
 
 struct ipr_hostrcb_type_04_error {
-       struct ipr_std_inq_vpids ioa_vpids;
-       u8 ioa_sn[IPR_SERIAL_NUM_LEN];
-       struct ipr_std_inq_vpids cfc_vpids;
-       u8 cfc_sn[IPR_SERIAL_NUM_LEN];
+       struct ipr_vpd ioa_vpd;
+       struct ipr_vpd cfc_vpd;
        u8 ioa_data[12];
        struct ipr_hostrcb_array_data_entry array_member[10];
        __be32 exposed_mode_adn;
        __be32 array_id;
-       struct ipr_std_inq_vpids incomp_dev_vpids;
-       u8 incomp_dev_sn[IPR_SERIAL_NUM_LEN];
+       struct ipr_vpd incomp_dev_vpd;
        __be32 ioa_data2;
        struct ipr_hostrcb_array_data_entry array_member2[8];
        struct ipr_res_addr last_func_vset_res_addr;
        u8 vset_serial_num[IPR_SERIAL_NUM_LEN];
        u8 protection_level[8];
-       u8 reserved[124];
 }__attribute__((packed, aligned (4)));
 
 struct ipr_hostrcb_error {
@@ -743,6 +725,7 @@ struct ipr_resource_table {
 
 struct ipr_misc_cbs {
        struct ipr_ioa_vpd ioa_vpd;
+       struct ipr_inquiry_page0 page0_data;
        struct ipr_inquiry_page3 page3_data;
        struct ipr_mode_pages mode_pages;
        struct ipr_supported_device supp_dev;
@@ -813,6 +796,7 @@ struct ipr_trace_entry {
 struct ipr_sglist {
        u32 order;
        u32 num_sg;
+       u32 num_dma_sg;
        u32 buffer_len;
        struct scatterlist scatterlist[1];
 };
@@ -825,6 +809,13 @@ enum ipr_sdt_state {
        DUMP_OBTAINED
 };
 
+enum ipr_cache_state {
+       CACHE_NONE,
+       CACHE_DISABLED,
+       CACHE_ENABLED,
+       CACHE_INVALID
+};
+
 /* Per-controller data */
 struct ipr_ioa_cfg {
        char eye_catcher[8];
@@ -841,6 +832,7 @@ struct ipr_ioa_cfg {
        u8 allow_cmds:1;
        u8 allow_ml_add_del:1;
 
+       enum ipr_cache_state cache_state;
        u16 type; /* CCIN of the card */
 
        u8 log_level;
@@ -1083,11 +1075,7 @@ struct ipr_ucode_image_header {
 /*
  * Macros
  */
-#if IPR_DEBUG
-#define IPR_DBG_CMD(CMD) do { CMD; } while (0)
-#else
-#define IPR_DBG_CMD(CMD)
-#endif
+#define IPR_DBG_CMD(CMD) if (ipr_debug) { CMD; }
 
 #ifdef CONFIG_SCSI_IPR_TRACE
 #define ipr_create_trace_file(kobj, attr) sysfs_create_bin_file(kobj, attr)
@@ -1135,16 +1123,22 @@ struct ipr_ucode_image_header {
 #define ipr_res_dbg(ioa_cfg, res, fmt, ...) \
        IPR_DBG_CMD(ipr_res_printk(KERN_INFO, ioa_cfg, res, fmt, ##__VA_ARGS__))
 
+#define ipr_phys_res_err(ioa_cfg, res, fmt, ...)                       \
+{                                                                      \
+       if ((res).bus >= IPR_MAX_NUM_BUSES) {                           \
+               ipr_err(fmt": unknown\n", ##__VA_ARGS__);               \
+       } else {                                                        \
+               ipr_err(fmt": %d:%d:%d:%d\n",                           \
+                       ##__VA_ARGS__, (ioa_cfg)->host->host_no,        \
+                       (res).bus, (res).target, (res).lun);            \
+       }                                                               \
+}
+
 #define ipr_trace ipr_dbg("%s: %s: Line: %d\n",\
        __FILE__, __FUNCTION__, __LINE__)
 
-#if IPR_DBG_TRACE
-#define ENTER printk(KERN_INFO IPR_NAME": Entering %s\n", __FUNCTION__)
-#define LEAVE printk(KERN_INFO IPR_NAME": Leaving %s\n", __FUNCTION__)
-#else
-#define ENTER
-#define LEAVE
-#endif
+#define ENTER IPR_DBG_CMD(printk(KERN_INFO IPR_NAME": Entering %s\n", __FUNCTION__))
+#define LEAVE IPR_DBG_CMD(printk(KERN_INFO IPR_NAME": Leaving %s\n", __FUNCTION__))
 
 #define ipr_err_separator \
 ipr_err("----------------------------------------------------------\n")