Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394...
[safe/jmp/linux-2.6] / drivers / ieee1394 / sbp2.h
index 8902a46..c5036f1 100644 (file)
@@ -67,7 +67,7 @@ struct sbp2_command_orb {
 #define ORB_SET_LUN(v)                 ((v) & 0xffff)
 #define ORB_SET_FUNCTION(v)            (((v) & 0xf) << 16)
 #define ORB_SET_RECONNECT(v)           (((v) & 0xf) << 20)
-#define ORB_SET_EXCLUSIVE(v)           (((v) & 0x1) << 28)
+#define ORB_SET_EXCLUSIVE(v)           ((v) ? 1 << 28 : 0)
 #define ORB_SET_LOGIN_RESP_LENGTH(v)   ((v) & 0xffff)
 #define ORB_SET_PASSWD_LENGTH(v)       (((v) & 0xffff) << 16)
 
@@ -139,13 +139,10 @@ struct sbp2_logout_orb {
        u32 status_fifo_lo;
 } __attribute__((packed));
 
-#define PAGE_TABLE_SET_SEGMENT_BASE_HI(v)      ((v) & 0xffff)
-#define PAGE_TABLE_SET_SEGMENT_LENGTH(v)       (((v) & 0xffff) << 16)
-
 struct sbp2_unrestricted_page_table {
-       u32 length_segment_base_hi;
-       u32 segment_base_lo;
-} __attribute__((packed));
+       __be32 high;
+       __be32 low;
+};
 
 #define RESP_STATUS_REQUEST_COMPLETE           0x0
 #define RESP_STATUS_TRANSPORT_FAILURE          0x1
@@ -216,16 +213,18 @@ struct sbp2_status_block {
 #define SBP2_UNIT_SPEC_ID_ENTRY                        0x0000609e
 #define SBP2_SW_VERSION_ENTRY                  0x00010483
 
-
 /*
- * SCSI specific definitions
+ * The default maximum s/g segment size of a FireWire controller is
+ * usually 0x10000, but SBP-2 only allows 0xffff. Since buffers have to
+ * be quadlet-aligned, we set the length limit to 0xffff & ~3.
  */
+#define SBP2_MAX_SEG_SIZE                      0xfffc
 
-#define SBP2_MAX_SG_ELEMENT_LENGTH             0xf000
-#define SBP2_MAX_SECTORS                       255
-/* There is no real limitation of the queue depth (i.e. length of the linked
+/*
+ * There is no real limitation of the queue depth (i.e. length of the linked
  * list of command ORBs) at the target. The chosen depth is merely an
- * implementation detail of the sbp2 driver. */
+ * implementation detail of the sbp2 driver.
+ */
 #define SBP2_MAX_CMDS                          8
 
 #define SBP2_SCSI_STATUS_GOOD                  0x0
@@ -241,38 +240,28 @@ struct sbp2_status_block {
  * Representations of commands and devices
  */
 
-enum sbp2_dma_types {
-       CMD_DMA_NONE,
-       CMD_DMA_PAGE,
-       CMD_DMA_SINGLE
-};
-
 /* Per SCSI command */
 struct sbp2_command_info {
        struct list_head list;
-       struct sbp2_command_orb command_orb ____cacheline_aligned;
-       dma_addr_t command_orb_dma ____cacheline_aligned;
+       struct sbp2_command_orb command_orb;
+       dma_addr_t command_orb_dma;
        struct scsi_cmnd *Current_SCpnt;
        void (*Current_done)(struct scsi_cmnd *);
 
        /* Also need s/g structure for each sbp2 command */
-       struct sbp2_unrestricted_page_table scatter_gather_element[SG_ALL] ____cacheline_aligned;
-       dma_addr_t sge_dma ____cacheline_aligned;
-       void *sge_buffer;
-       dma_addr_t cmd_dma;
-       enum sbp2_dma_types dma_type;
-       unsigned long dma_size;
-       int dma_dir;
+       struct sbp2_unrestricted_page_table
+               scatter_gather_element[SG_ALL] __attribute__((aligned(8)));
+       dma_addr_t sge_dma;
 };
 
 /* Per FireWire host */
 struct sbp2_fwhost_info {
        struct hpsb_host *host;
-       struct list_head scsi_ids;
+       struct list_head logical_units;
 };
 
 /* Per logical unit */
-struct scsi_id_instance_data {
+struct sbp2_lu {
        /* Operation request blocks */
        struct sbp2_command_orb *last_orb;
        dma_addr_t last_orb_dma;
@@ -301,7 +290,7 @@ struct scsi_id_instance_data {
        u64 status_fifo_addr;
 
        /* Waitqueue flag for logins, reconnects, logouts, query logins */
-       int access_complete:1;
+       unsigned int access_complete:1;
 
        /* Pool of command ORBs for this logical unit */
        spinlock_t cmd_orb_lock;
@@ -310,7 +299,7 @@ struct scsi_id_instance_data {
 
        /* Backlink to FireWire host; list of units attached to the host */
        struct sbp2_fwhost_info *hi;
-       struct list_head scsi_list;
+       struct list_head lu_list;
 
        /* IEEE 1394 core's device representations */
        struct node_entry *ne;
@@ -318,7 +307,7 @@ struct scsi_id_instance_data {
 
        /* SCSI core's device representations */
        struct scsi_device *sdev;
-       struct Scsi_Host *scsi_host;
+       struct Scsi_Host *shost;
 
        /* Device specific workarounds/brokeness */
        unsigned workarounds;
@@ -330,19 +319,22 @@ struct scsi_id_instance_data {
        struct work_struct protocol_work;
 };
 
-/* For use in scsi_id_instance_data.state */
+/* For use in sbp2_lu.state */
 enum sbp2lu_state_types {
        SBP2LU_STATE_RUNNING,           /* all normal */
        SBP2LU_STATE_IN_RESET,          /* between bus reset and reconnect */
        SBP2LU_STATE_IN_SHUTDOWN        /* when sbp2_remove was called */
 };
 
-/* For use in scsi_id_instance_data.workarounds and in the corresponding
+/* For use in sbp2_lu.workarounds and in the corresponding
  * module load parameter */
 #define SBP2_WORKAROUND_128K_MAX_TRANS 0x1
 #define SBP2_WORKAROUND_INQUIRY_36     0x2
 #define SBP2_WORKAROUND_MODE_SENSE_8   0x4
 #define SBP2_WORKAROUND_FIX_CAPACITY   0x8
+#define SBP2_WORKAROUND_DELAY_INQUIRY  0x10
+#define SBP2_INQUIRY_DELAY             12
+#define SBP2_WORKAROUND_POWER_CONDITION        0x20
 #define SBP2_WORKAROUND_OVERRIDE       0x100
 
 #endif /* SBP2_H */