|
smartmontools SVN Rev 3317
Utility to control and monitor storage systems with "S.M.A.R.T."
|
00001 int megaraid_io_interface(int device, int target, struct scsi_cmnd_io *, int); 00002 00003 #undef u32 00004 00005 #define u8 uint8_t 00006 #define u16 uint16_t 00007 #define u32 uint32_t 00008 #define u64 uint64_t 00009 00010 /*====================================================== 00011 * PERC2/3/4 Passthrough SCSI Command Interface 00012 * 00013 * Contents from: 00014 * drivers/scsi/megaraid/megaraid_ioctl.h 00015 * drivers/scsi/megaraid/mbox_defs.h 00016 *======================================================*/ 00017 #define MEGAIOC_MAGIC 'm' 00018 #define MEGAIOCCMD _IOWR(MEGAIOC_MAGIC, 0, struct uioctl_t) 00019 00020 /* Following subopcode work for opcode == 0x82 */ 00021 #define MKADAP(adapno) (MEGAIOC_MAGIC << 8 | adapno) 00022 #define MEGAIOC_QNADAP 'm' 00023 #define MEGAIOC_QDRVRVER 'e' 00024 #define MEGAIOC_QADAPINFO 'g' 00025 00026 #define MEGA_MBOXCMD_PASSTHRU 0x03 00027 00028 #define MAX_REQ_SENSE_LEN 0x20 00029 #define MAX_CDB_LEN 10 00030 00031 typedef struct 00032 { 00033 uint8_t timeout : 3; 00034 uint8_t ars : 1; 00035 uint8_t reserved : 3; 00036 uint8_t islogical : 1; 00037 uint8_t logdrv; 00038 uint8_t channel; 00039 uint8_t target; 00040 uint8_t queuetag; 00041 uint8_t queueaction; 00042 uint8_t cdb[MAX_CDB_LEN]; 00043 uint8_t cdblen; 00044 uint8_t reqsenselen; 00045 uint8_t reqsensearea[MAX_REQ_SENSE_LEN]; 00046 uint8_t numsgelements; 00047 uint8_t scsistatus; 00048 uint32_t dataxferaddr; 00049 uint32_t dataxferlen; 00050 } __attribute__((packed)) mega_passthru; 00051 00052 typedef struct 00053 { 00054 uint8_t cmd; 00055 uint8_t cmdid; 00056 uint8_t opcode; 00057 uint8_t subopcode; 00058 uint32_t lba; 00059 uint32_t xferaddr; 00060 uint8_t logdrv; 00061 uint8_t resvd[3]; 00062 uint8_t numstatus; 00063 uint8_t status; 00064 } __attribute__((packed)) megacmd_t; 00065 00066 typedef union { 00067 uint8_t *pointer; 00068 uint8_t pad[8]; 00069 } ptr_t; 00070 00071 // The above definition assumes sizeof(void*) <= 8. 00072 // This assumption also exists in the linux megaraid device driver. 00073 // So define a macro to check expected size of ptr_t at compile time using 00074 // a dummy typedef. On size mismatch, compiler reports a negative array 00075 // size. If you see an error message of this form, it means that 00076 // you have an unexpected pointer size on your platform and can not 00077 // use megaraid support in smartmontools. 00078 typedef char assert_sizeof_ptr_t[sizeof(ptr_t) == 8 ? 1 : -1]; 00079 00080 struct uioctl_t 00081 { 00082 uint32_t inlen; 00083 uint32_t outlen; 00084 union { 00085 uint8_t fca[16]; 00086 struct { 00087 uint8_t opcode; 00088 uint8_t subopcode; 00089 uint16_t adapno; 00090 ptr_t buffer; 00091 uint32_t length; 00092 } __attribute__((packed)) fcs; 00093 } __attribute__((packed)) ui; 00094 00095 megacmd_t mbox; 00096 mega_passthru pthru; 00097 ptr_t data; 00098 } __attribute__((packed)); 00099 00100 /*=================================================== 00101 * PERC5/6 Passthrough SCSI Command Interface 00102 * 00103 * Contents from: 00104 * drivers/scsi/megaraid/megaraid_sas.h 00105 *===================================================*/ 00106 #define MEGASAS_MAGIC 'M' 00107 #define MEGASAS_IOC_FIRMWARE _IOWR(MEGASAS_MAGIC, 1, struct megasas_iocpacket) 00108 00109 #define MFI_CMD_PD_SCSI_IO 0x04 00110 #define MFI_CMD_DCMD 0x05 00111 #define MFI_FRAME_SGL64 0x02 00112 #define MFI_STAT_OK 0x00 00113 #define MFI_DCMD_PD_GET_LIST 0x02010000 00114 /* 00115 * Number of mailbox bytes in DCMD message frame 00116 */ 00117 #define MFI_MBOX_SIZE 12 00118 #define MAX_IOCTL_SGE 16 00119 #define MFI_FRAME_DIR_NONE 0x0000 00120 #define MFI_FRAME_DIR_WRITE 0x0008 00121 #define MFI_FRAME_DIR_READ 0x0010 00122 #define MFI_FRAME_DIR_BOTH 0x0018 00123 00124 #define MAX_SYS_PDS 240 00125 00126 struct megasas_sge32 { 00127 00128 u32 phys_addr; 00129 u32 length; 00130 00131 } __attribute__ ((packed)); 00132 00133 struct megasas_sge64 { 00134 00135 u64 phys_addr; 00136 u32 length; 00137 00138 } __attribute__ ((packed)); 00139 00140 union megasas_sgl { 00141 00142 struct megasas_sge32 sge32[1]; 00143 struct megasas_sge64 sge64[1]; 00144 00145 } __attribute__ ((packed)); 00146 00147 struct megasas_header { 00148 00149 u8 cmd; /*00h */ 00150 u8 sense_len; /*01h */ 00151 u8 cmd_status; /*02h */ 00152 u8 scsi_status; /*03h */ 00153 00154 u8 target_id; /*04h */ 00155 u8 lun; /*05h */ 00156 u8 cdb_len; /*06h */ 00157 u8 sge_count; /*07h */ 00158 00159 u32 context; /*08h */ 00160 u32 pad_0; /*0Ch */ 00161 00162 u16 flags; /*10h */ 00163 u16 timeout; /*12h */ 00164 u32 data_xferlen; /*14h */ 00165 00166 } __attribute__ ((packed)); 00167 00168 struct megasas_pthru_frame { 00169 00170 u8 cmd; /*00h */ 00171 u8 sense_len; /*01h */ 00172 u8 cmd_status; /*02h */ 00173 u8 scsi_status; /*03h */ 00174 00175 u8 target_id; /*04h */ 00176 u8 lun; /*05h */ 00177 u8 cdb_len; /*06h */ 00178 u8 sge_count; /*07h */ 00179 00180 u32 context; /*08h */ 00181 u32 pad_0; /*0Ch */ 00182 00183 u16 flags; /*10h */ 00184 u16 timeout; /*12h */ 00185 u32 data_xfer_len; /*14h */ 00186 00187 u32 sense_buf_phys_addr_lo; /*18h */ 00188 u32 sense_buf_phys_addr_hi; /*1Ch */ 00189 00190 u8 cdb[16]; /*20h */ 00191 union megasas_sgl sgl; /*30h */ 00192 00193 } __attribute__ ((packed)); 00194 00195 struct megasas_dcmd_frame { 00196 00197 u8 cmd; /*00h */ 00198 u8 reserved_0; /*01h */ 00199 u8 cmd_status; /*02h */ 00200 u8 reserved_1[4]; /*03h */ 00201 u8 sge_count; /*07h */ 00202 00203 u32 context; /*08h */ 00204 u32 pad_0; /*0Ch */ 00205 00206 u16 flags; /*10h */ 00207 u16 timeout; /*12h */ 00208 00209 u32 data_xfer_len; /*14h */ 00210 u32 opcode; /*18h */ 00211 00212 union { /*1Ch */ 00213 u8 b[12]; 00214 u16 s[6]; 00215 u32 w[3]; 00216 } mbox; 00217 00218 union megasas_sgl sgl; /*28h */ 00219 00220 } __attribute__ ((packed)); 00221 00222 struct megasas_iocpacket { 00223 u16 host_no; 00224 u16 __pad1; 00225 u32 sgl_off; 00226 u32 sge_count; 00227 u32 sense_off; 00228 u32 sense_len; 00229 union { 00230 u8 raw[128]; 00231 struct megasas_header hdr; 00232 struct megasas_pthru_frame pthru; 00233 struct megasas_dcmd_frame dcmd; 00234 } frame; 00235 00236 struct iovec sgl[MAX_IOCTL_SGE]; 00237 } __attribute__ ((packed)); 00238 00239 struct megasas_pd_address { 00240 u16 device_id; 00241 u16 encl_device_id; 00242 u8 encl_index; 00243 u8 slot_number; 00244 u8 scsi_dev_type; /* 0 = disk */ 00245 u8 connect_port_bitmap; 00246 u64 sas_addr[2]; 00247 } __attribute__ ((packed)); 00248 00249 struct megasas_pd_list { 00250 u32 size; 00251 u32 count; 00252 struct megasas_pd_address addr[MAX_SYS_PDS]; 00253 } __attribute__ ((packed)); 00254 00255 #undef u8 00256 #undef u16 00257 #undef u32 00258 #undef u64 00259
1.7.4