smartmontools  SVN Rev 4078
Utility to control and monitor storage systems with "S.M.A.R.T."
megaraid.h
Go to the documentation of this file.
1 int megaraid_io_interface(int device, int target, struct scsi_cmnd_io *, int);
2 
3 #undef u32
4 
5 #define u8 uint8_t
6 #define u16 uint16_t
7 #define u32 uint32_t
8 #define u64 uint64_t
9 
10 /*======================================================
11 * PERC2/3/4 Passthrough SCSI Command Interface
12 *
13 * Contents from:
14 * drivers/scsi/megaraid/megaraid_ioctl.h
15 * drivers/scsi/megaraid/mbox_defs.h
16 *======================================================*/
17 #define MEGAIOC_MAGIC 'm'
18 #define MEGAIOCCMD _IOWR(MEGAIOC_MAGIC, 0, struct uioctl_t)
19 
20 /* Following subopcode work for opcode == 0x82 */
21 #define MKADAP(adapno) (MEGAIOC_MAGIC << 8 | adapno)
22 #define MEGAIOC_QNADAP 'm'
23 #define MEGAIOC_QDRVRVER 'e'
24 #define MEGAIOC_QADAPINFO 'g'
25 
26 #define MEGA_MBOXCMD_PASSTHRU 0x03
27 
28 #define MAX_REQ_SENSE_LEN 0x20
29 #define MAX_CDB_LEN 10
30 
31 typedef struct
32 {
33  uint8_t timeout : 3;
34  uint8_t ars : 1;
35  uint8_t reserved : 3;
36  uint8_t islogical : 1;
37  uint8_t logdrv;
38  uint8_t channel;
39  uint8_t target;
40  uint8_t queuetag;
41  uint8_t queueaction;
42  uint8_t cdb[MAX_CDB_LEN];
43  uint8_t cdblen;
44  uint8_t reqsenselen;
45  uint8_t reqsensearea[MAX_REQ_SENSE_LEN];
46  uint8_t numsgelements;
47  uint8_t scsistatus;
48  uint32_t dataxferaddr;
49  uint32_t dataxferlen;
50 } __attribute__((packed)) mega_passthru;
51 
52 typedef struct
53 {
54  uint8_t cmd;
55  uint8_t cmdid;
56  uint8_t opcode;
57  uint8_t subopcode;
58  uint32_t lba;
59  uint32_t xferaddr;
60  uint8_t logdrv;
61  uint8_t resvd[3];
62  uint8_t numstatus;
63  uint8_t status;
64 } __attribute__((packed)) megacmd_t;
65 
66 typedef union {
67  uint8_t *pointer;
68  uint8_t pad[8];
69 } ptr_t;
70 
71 // The above definition assumes sizeof(void*) <= 8.
72 // This assumption also exists in the linux megaraid device driver.
73 // So define a macro to check expected size of ptr_t at compile time using
74 // a dummy typedef. On size mismatch, compiler reports a negative array
75 // size. If you see an error message of this form, it means that
76 // you have an unexpected pointer size on your platform and can not
77 // use megaraid support in smartmontools.
78 typedef char assert_sizeof_ptr_t[sizeof(ptr_t) == 8 ? 1 : -1];
79 
80 struct uioctl_t
81 {
82  uint32_t inlen;
83  uint32_t outlen;
84  union {
85  uint8_t fca[16];
86  struct {
87  uint8_t opcode;
88  uint8_t subopcode;
89  uint16_t adapno;
91  uint32_t length;
92  } __attribute__((packed)) fcs;
93  } __attribute__((packed)) ui;
94 
95  megacmd_t mbox;
96  mega_passthru pthru;
98 } __attribute__((packed));
99 
100 /*===================================================
101 * PERC5/6 Passthrough SCSI Command Interface
102 *
103 * Contents from:
104 * drivers/scsi/megaraid/megaraid_sas.h
105 *===================================================*/
106 #define MEGASAS_MAGIC 'M'
107 #define MEGASAS_IOC_FIRMWARE _IOWR(MEGASAS_MAGIC, 1, struct megasas_iocpacket)
108 
109 #define MFI_CMD_PD_SCSI_IO 0x04
110 #define MFI_CMD_DCMD 0x05
111 #define MFI_FRAME_SGL64 0x02
112 #define MFI_STAT_OK 0x00
113 #define MFI_DCMD_PD_GET_LIST 0x02010000
114 /*
115 * Number of mailbox bytes in DCMD message frame
116 */
117 #define MFI_MBOX_SIZE 12
118 #define MAX_IOCTL_SGE 16
119 #define MFI_FRAME_DIR_NONE 0x0000
120 #define MFI_FRAME_DIR_WRITE 0x0008
121 #define MFI_FRAME_DIR_READ 0x0010
122 #define MFI_FRAME_DIR_BOTH 0x0018
123 
124 #define MAX_SYS_PDS 240
125 
127 
130 
131 } __attribute__ ((packed));
132 
134 
137 
138 } __attribute__ ((packed));
139 
140 union megasas_sgl {
141 
142  struct megasas_sge32 sge32[1];
143  struct megasas_sge64 sge64[1];
144 
145 } __attribute__ ((packed));
146 
148 
149  u8 cmd; /*00h */
150  u8 sense_len; /*01h */
151  u8 cmd_status; /*02h */
152  u8 scsi_status; /*03h */
153 
154  u8 target_id; /*04h */
155  u8 lun; /*05h */
156  u8 cdb_len; /*06h */
157  u8 sge_count; /*07h */
158 
159  u32 context; /*08h */
160  u32 pad_0; /*0Ch */
161 
162  u16 flags; /*10h */
163  u16 timeout; /*12h */
164  u32 data_xferlen; /*14h */
165 
166 } __attribute__ ((packed));
167 
169 
170  u8 cmd; /*00h */
171  u8 sense_len; /*01h */
172  u8 cmd_status; /*02h */
173  u8 scsi_status; /*03h */
174 
175  u8 target_id; /*04h */
176  u8 lun; /*05h */
177  u8 cdb_len; /*06h */
178  u8 sge_count; /*07h */
179 
180  u32 context; /*08h */
181  u32 pad_0; /*0Ch */
182 
183  u16 flags; /*10h */
184  u16 timeout; /*12h */
185  u32 data_xfer_len; /*14h */
186 
189 
190  u8 cdb[16]; /*20h */
191  union megasas_sgl sgl; /*30h */
192 
193 } __attribute__ ((packed));
194 
196 
197  u8 cmd; /*00h */
198  u8 reserved_0; /*01h */
199  u8 cmd_status; /*02h */
200  u8 reserved_1[4]; /*03h */
201  u8 sge_count; /*07h */
202 
203  u32 context; /*08h */
204  u32 pad_0; /*0Ch */
205 
206  u16 flags; /*10h */
207  u16 timeout; /*12h */
208 
209  u32 data_xfer_len; /*14h */
210  u32 opcode; /*18h */
211 
212  union { /*1Ch */
213  u8 b[12];
214  u16 s[6];
215  u32 w[3];
216  } mbox;
217 
218  union megasas_sgl sgl; /*28h */
219 
220 } __attribute__ ((packed));
221 
229  union {
230  u8 raw[128];
232  struct megasas_pthru_frame pthru;
234  } frame;
235 
236  struct iovec sgl[MAX_IOCTL_SGE];
237 } __attribute__ ((packed));
238 
244  u8 scsi_dev_type; /* 0 = disk */
247 } __attribute__ ((packed));
248 
253 } __attribute__ ((packed));
254 
255 #undef u8
256 #undef u16
257 #undef u32
258 #undef u64
259 
u8 raw[128]
Definition: megaraid.h:86
uint32_t outlen
Definition: megaraid.h:83
uint8_t cmdid
Definition: megaraid.h:55
u16 s[6]
Definition: megaraid.h:97
uint8_t * pointer
Definition: megaraid.h:67
uint16_t adapno
Definition: megaraid.h:89
ptr_t buffer
Definition: megaraid.h:90
uint8_t numsgelements
Definition: megaraid.h:46
u32 sense_buf_phys_addr_lo
Definition: megaraid.h:187
struct megasas_sge32 sge32[1]
Definition: megaraid.h:80
struct @31 __attribute__((packed)) fcs
uint8_t reqsenselen
Definition: megaraid.h:44
uint32_t inlen
Definition: megaraid.h:82
struct megasas_sge64 sge64[1]
Definition: megaraid.h:81
uint32_t xferaddr
Definition: megaraid.h:59
struct megasas_dcmd_frame dcmd
Definition: megaraid.h:89
uint8_t cmd
Definition: megaraid.h:54
int megaraid_io_interface(int device, int target, struct scsi_cmnd_io *, int)
mega_passthru pthru
Definition: megaraid.h:96
union @38 frame
uint8_t queueaction
Definition: megaraid.h:41
union uioctl_t::@29 __attribute__((packed)) ui
uint8_t logdrv
Definition: megaraid.h:37
uint32_t dataxferlen
Definition: megaraid.h:49
uint8_t target
Definition: megaraid.h:39
u8 cdb[16]
Definition: megaraid.h:100
u32 sense_buf_phys_addr_hi
Definition: megaraid.h:188
uint8_t fca[16]
Definition: megaraid.h:85
uint8_t cdblen
Definition: megaraid.h:43
uint32_t length
Definition: megaraid.h:91
Definition: megaraid.h:66
#define u8
Definition: megaraid.h:5
#define MAX_CDB_LEN
Definition: megaraid.h:29
#define MAX_SYS_PDS
Definition: megaraid.h:124
uint8_t status
Definition: megaraid.h:63
uint32_t dataxferaddr
Definition: megaraid.h:48
union megasas_sgl sgl
Definition: megaraid.h:101
struct megasas_pd_address addr[MAX_SYS_PDS]
Definition: megaraid.h:81
uint8_t scsistatus
Definition: megaraid.h:47
#define MAX_IOCTL_SGE
Definition: megaraid.h:118
uint8_t opcode
Definition: megaraid.h:56
#define u64
Definition: megaraid.h:8
u16 timeout
Definition: megaraid.h:94
u8 b[12]
Definition: megaraid.h:96
uint8_t subopcode
Definition: megaraid.h:88
ptr_t data
Definition: megaraid.h:97
u32 w[3]
Definition: megaraid.h:98
char assert_sizeof_ptr_t[sizeof(ptr_t)==8?1:-1]
Definition: megaraid.h:78
uint8_t subopcode
Definition: megaraid.h:57
uint8_t opcode
Definition: megaraid.h:87
#define MAX_REQ_SENSE_LEN
Definition: megaraid.h:28
struct megasas_header hdr
Definition: megaraid.h:87
megacmd_t mbox
Definition: megaraid.h:95
uint8_t channel
Definition: megaraid.h:38
#define u32
Definition: megaraid.h:7
uint32_t lba
Definition: megaraid.h:58
uint8_t numstatus
Definition: megaraid.h:62
uint8_t queuetag
Definition: megaraid.h:40
u32 data_xferlen
Definition: megaraid.h:164
u64 sas_addr[2]
Definition: megaraid.h:85
#define u16
Definition: megaraid.h:6
u8 reserved_1[4]
Definition: megaraid.h:83