summaryrefslogtreecommitdiff
path: root/drivers/scsi/megaraid/megaraid_sas_fusion.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/megaraid/megaraid_sas_fusion.h')
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_fusion.h115
1 files changed, 72 insertions, 43 deletions
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h b/drivers/scsi/megaraid/megaraid_sas_fusion.h
index f25a26252790..1441c35c58a3 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.h
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h
@@ -148,44 +148,13 @@ struct RAID_CONTEXT {
* starts in MPT IO Frames
*/
struct RAID_CONTEXT_G35 {
-#if defined(__BIG_ENDIAN_BITFIELD)
- u16 resvd0:8;
- u16 nseg:4;
- u16 type:4;
-#else
- u16 type:4; /* 0x00 */
- u16 nseg:4; /* 0x00 */
- u16 resvd0:8;
-#endif
+ #define RAID_CONTEXT_NSEG_MASK 0x00F0
+ #define RAID_CONTEXT_NSEG_SHIFT 4
+ #define RAID_CONTEXT_TYPE_MASK 0x000F
+ #define RAID_CONTEXT_TYPE_SHIFT 0
+ u16 nseg_type;
u16 timeout_value; /* 0x02 -0x03 */
- union {
- struct {
-#if defined(__BIG_ENDIAN_BITFIELD)
- u16 set_divert:4;
- u16 cpu_sel:4;
- u16 log:1;
- u16 rw:1;
- u16 sbs:1;
- u16 sqn:1;
- u16 fwn:1;
- u16 c2f:1;
- u16 sld:1;
- u16 reserved:1;
-#else
- u16 reserved:1;
- u16 sld:1;
- u16 c2f:1;
- u16 fwn:1;
- u16 sqn:1;
- u16 sbs:1;
- u16 rw:1;
- u16 log:1;
- u16 cpu_sel:4;
- u16 set_divert:4;
-#endif
- } bits;
- u16 s;
- } routing_flags; /* 0x04 -0x05 routing flags */
+ u16 routing_flags; // 0x04 -0x05 routing flags
u16 virtual_disk_tgt_id; /* 0x06 -0x07 */
u64 reg_lock_row_lba; /* 0x08 - 0x0F */
u32 reg_lock_length; /* 0x10 - 0x13 */
@@ -200,18 +169,78 @@ struct RAID_CONTEXT_G35 {
*/
u8 span_arm; /* 0x1C span[7:5], arm[4:0] */
u16 config_seq_num; /* 0x1A -0x1B */
+ union {
+ /*
+ * Bit format:
+ * ---------------------------------
+ * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+ * ---------------------------------
+ * Byte0 | numSGE[7]- numSGE[0] |
+ * ---------------------------------
+ * Byte1 |SD | resvd | numSGE 8-11 |
+ * --------------------------------
+ */
+ #define NUM_SGE_MASK_LOWER 0xFF
+ #define NUM_SGE_MASK_UPPER 0x0F
+ #define NUM_SGE_SHIFT_UPPER 8
+ #define STREAM_DETECT_SHIFT 7
+ #define STREAM_DETECT_MASK 0x80
+ struct {
#if defined(__BIG_ENDIAN_BITFIELD) /* 0x1C - 0x1D */
- u16 stream_detected:1;
- u16 reserved:3;
- u16 num_sge:12;
+ u16 stream_detected:1;
+ u16 reserved:3;
+ u16 num_sge:12;
#else
- u16 num_sge:12;
- u16 reserved:3;
- u16 stream_detected:1;
+ u16 num_sge:12;
+ u16 reserved:3;
+ u16 stream_detected:1;
#endif
+ } bits;
+ u8 bytes[2];
+ } u;
u8 resvd2[2]; /* 0x1E-0x1F */
};
+#define MR_RAID_CTX_ROUTINGFLAGS_SLD_SHIFT 1
+#define MR_RAID_CTX_ROUTINGFLAGS_C2D_SHIFT 2
+#define MR_RAID_CTX_ROUTINGFLAGS_FWD_SHIFT 3
+#define MR_RAID_CTX_ROUTINGFLAGS_SQN_SHIFT 4
+#define MR_RAID_CTX_ROUTINGFLAGS_SBS_SHIFT 5
+#define MR_RAID_CTX_ROUTINGFLAGS_RW_SHIFT 6
+#define MR_RAID_CTX_ROUTINGFLAGS_LOG_SHIFT 7
+#define MR_RAID_CTX_ROUTINGFLAGS_CPUSEL_SHIFT 8
+#define MR_RAID_CTX_ROUTINGFLAGS_CPUSEL_MASK 0x0F00
+#define MR_RAID_CTX_ROUTINGFLAGS_SETDIVERT_SHIFT 12
+#define MR_RAID_CTX_ROUTINGFLAGS_SETDIVERT_MASK 0xF000
+
+static inline void set_num_sge(struct RAID_CONTEXT_G35 *rctx_g35,
+ u16 sge_count)
+{
+ rctx_g35->u.bytes[0] = (u8)(sge_count & NUM_SGE_MASK_LOWER);
+ rctx_g35->u.bytes[1] |= (u8)((sge_count >> NUM_SGE_SHIFT_UPPER)
+ & NUM_SGE_MASK_UPPER);
+}
+
+static inline u16 get_num_sge(struct RAID_CONTEXT_G35 *rctx_g35)
+{
+ u16 sge_count;
+
+ sge_count = (u16)(((rctx_g35->u.bytes[1] & NUM_SGE_MASK_UPPER)
+ << NUM_SGE_SHIFT_UPPER) | (rctx_g35->u.bytes[0]));
+ return sge_count;
+}
+
+#define SET_STREAM_DETECTED(rctx_g35) \
+ (rctx_g35.u.bytes[1] |= STREAM_DETECT_MASK)
+
+#define CLEAR_STREAM_DETECTED(rctx_g35) \
+ (rctx_g35.u.bytes[1] &= ~(STREAM_DETECT_MASK))
+
+static inline bool is_stream_detected(struct RAID_CONTEXT_G35 *rctx_g35)
+{
+ return ((rctx_g35->u.bytes[1] & STREAM_DETECT_MASK));
+}
+
union RAID_CONTEXT_UNION {
struct RAID_CONTEXT raid_context;
struct RAID_CONTEXT_G35 raid_context_g35;