mptctl.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. /*
  2. * linux/drivers/message/fusion/mptioctl.h
  3. * Fusion MPT misc device (ioctl) driver.
  4. * For use with PCI chip/adapter(s):
  5. * LSIFC9xx/LSI409xx Fibre Channel
  6. * running LSI Fusion MPT (Message Passing Technology) firmware.
  7. *
  8. * Copyright (c) 1999-2008 LSI Corporation
  9. * (mailto:DL-MPTFusionLinux@lsi.com)
  10. *
  11. */
  12. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  13. /*
  14. This program is free software; you can redistribute it and/or modify
  15. it under the terms of the GNU General Public License as published by
  16. the Free Software Foundation; version 2 of the License.
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. GNU General Public License for more details.
  21. NO WARRANTY
  22. THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
  23. CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
  24. LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
  25. MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
  26. solely responsible for determining the appropriateness of using and
  27. distributing the Program and assumes all risks associated with its
  28. exercise of rights under this Agreement, including but not limited to
  29. the risks and costs of program errors, damage to or loss of data,
  30. programs or equipment, and unavailability or interruption of operations.
  31. DISCLAIMER OF LIABILITY
  32. NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
  33. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  34. DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
  35. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  36. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  37. USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
  38. HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
  39. You should have received a copy of the GNU General Public License
  40. along with this program; if not, write to the Free Software
  41. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  42. */
  43. #ifndef MPTCTL_H_INCLUDED
  44. #define MPTCTL_H_INCLUDED
  45. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  46. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  47. /*
  48. *
  49. */
  50. #define MPT_MISCDEV_BASENAME "mptctl"
  51. #define MPT_MISCDEV_PATHNAME "/dev/" MPT_MISCDEV_BASENAME
  52. #define MPT_PRODUCT_LENGTH 12
  53. /*
  54. * Generic MPT Control IOCTLs and structures
  55. */
  56. #define MPT_MAGIC_NUMBER 'm'
  57. #define MPTRWPERF _IOWR(MPT_MAGIC_NUMBER,0,struct mpt_raw_r_w)
  58. #define MPTFWDOWNLOAD _IOWR(MPT_MAGIC_NUMBER,15,struct mpt_fw_xfer)
  59. #define MPTCOMMAND _IOWR(MPT_MAGIC_NUMBER,20,struct mpt_ioctl_command)
  60. #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
  61. #define MPTFWDOWNLOAD32 _IOWR(MPT_MAGIC_NUMBER,15,struct mpt_fw_xfer32)
  62. #define MPTCOMMAND32 _IOWR(MPT_MAGIC_NUMBER,20,struct mpt_ioctl_command32)
  63. #endif
  64. #define MPTIOCINFO _IOWR(MPT_MAGIC_NUMBER,17,struct mpt_ioctl_iocinfo)
  65. #define MPTIOCINFO1 _IOWR(MPT_MAGIC_NUMBER,17,struct mpt_ioctl_iocinfo_rev0)
  66. #define MPTIOCINFO2 _IOWR(MPT_MAGIC_NUMBER,17,struct mpt_ioctl_iocinfo_rev1)
  67. #define MPTTARGETINFO _IOWR(MPT_MAGIC_NUMBER,18,struct mpt_ioctl_targetinfo)
  68. #define MPTTEST _IOWR(MPT_MAGIC_NUMBER,19,struct mpt_ioctl_test)
  69. #define MPTEVENTQUERY _IOWR(MPT_MAGIC_NUMBER,21,struct mpt_ioctl_eventquery)
  70. #define MPTEVENTENABLE _IOWR(MPT_MAGIC_NUMBER,22,struct mpt_ioctl_eventenable)
  71. #define MPTEVENTREPORT _IOWR(MPT_MAGIC_NUMBER,23,struct mpt_ioctl_eventreport)
  72. #define MPTHARDRESET _IOWR(MPT_MAGIC_NUMBER,24,struct mpt_ioctl_diag_reset)
  73. #define MPTFWREPLACE _IOWR(MPT_MAGIC_NUMBER,25,struct mpt_ioctl_replace_fw)
  74. /*
  75. * SPARC PLATFORM REMARKS:
  76. * IOCTL data structures that contain pointers
  77. * will have different sizes in the driver and applications
  78. * (as the app. will not use 8-byte pointers).
  79. * Apps should use MPTFWDOWNLOAD and MPTCOMMAND.
  80. * The driver will convert data from
  81. * mpt_fw_xfer32 (mpt_ioctl_command32) to mpt_fw_xfer (mpt_ioctl_command)
  82. * internally.
  83. *
  84. * If data structures change size, must handle as in IOCGETINFO.
  85. */
  86. struct mpt_fw_xfer {
  87. unsigned int iocnum; /* IOC unit number */
  88. unsigned int fwlen;
  89. void __user *bufp; /* Pointer to firmware buffer */
  90. };
  91. #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
  92. struct mpt_fw_xfer32 {
  93. unsigned int iocnum;
  94. unsigned int fwlen;
  95. u32 bufp;
  96. };
  97. #endif /*}*/
  98. /*
  99. * IOCTL header structure.
  100. * iocnum - must be defined.
  101. * port - must be defined for all IOCTL commands other than MPTIOCINFO
  102. * maxDataSize - ignored on MPTCOMMAND commands
  103. * - ignored on MPTFWREPLACE commands
  104. * - on query commands, reports the maximum number of bytes to be returned
  105. * to the host driver (count includes the header).
  106. * That is, set to sizeof(struct mpt_ioctl_iocinfo) for fixed sized commands.
  107. * Set to sizeof(struct mpt_ioctl_targetinfo) + datasize for variable
  108. * sized commands. (MPTTARGETINFO, MPTEVENTREPORT)
  109. */
  110. typedef struct _mpt_ioctl_header {
  111. unsigned int iocnum; /* IOC unit number */
  112. unsigned int port; /* IOC port number */
  113. int maxDataSize; /* Maximum Num. bytes to transfer on read */
  114. } mpt_ioctl_header;
  115. /*
  116. * Issue a diagnostic reset
  117. */
  118. struct mpt_ioctl_diag_reset {
  119. mpt_ioctl_header hdr;
  120. };
  121. /*
  122. * PCI bus/device/function information structure.
  123. */
  124. struct mpt_ioctl_pci_info {
  125. union {
  126. struct {
  127. unsigned int deviceNumber : 5;
  128. unsigned int functionNumber : 3;
  129. unsigned int busNumber : 24;
  130. } bits;
  131. unsigned int asUlong;
  132. } u;
  133. };
  134. struct mpt_ioctl_pci_info2 {
  135. union {
  136. struct {
  137. unsigned int deviceNumber : 5;
  138. unsigned int functionNumber : 3;
  139. unsigned int busNumber : 24;
  140. } bits;
  141. unsigned int asUlong;
  142. } u;
  143. int segmentID;
  144. };
  145. /*
  146. * Adapter Information Page
  147. * Read only.
  148. * Data starts at offset 0xC
  149. */
  150. #define MPT_IOCTL_INTERFACE_SCSI (0x00)
  151. #define MPT_IOCTL_INTERFACE_FC (0x01)
  152. #define MPT_IOCTL_INTERFACE_FC_IP (0x02)
  153. #define MPT_IOCTL_INTERFACE_SAS (0x03)
  154. #define MPT_IOCTL_VERSION_LENGTH (32)
  155. struct mpt_ioctl_iocinfo {
  156. mpt_ioctl_header hdr;
  157. int adapterType; /* SCSI or FCP */
  158. int port; /* port number */
  159. int pciId; /* PCI Id. */
  160. int hwRev; /* hardware revision */
  161. int subSystemDevice; /* PCI subsystem Device ID */
  162. int subSystemVendor; /* PCI subsystem Vendor ID */
  163. int numDevices; /* number of devices */
  164. int FWVersion; /* FW Version (integer) */
  165. int BIOSVersion; /* BIOS Version (integer) */
  166. char driverVersion[MPT_IOCTL_VERSION_LENGTH]; /* Driver Version (string) */
  167. char busChangeEvent;
  168. char hostId;
  169. char rsvd[2];
  170. struct mpt_ioctl_pci_info2 pciInfo; /* Added Rev 2 */
  171. };
  172. struct mpt_ioctl_iocinfo_rev1 {
  173. mpt_ioctl_header hdr;
  174. int adapterType; /* SCSI or FCP */
  175. int port; /* port number */
  176. int pciId; /* PCI Id. */
  177. int hwRev; /* hardware revision */
  178. int subSystemDevice; /* PCI subsystem Device ID */
  179. int subSystemVendor; /* PCI subsystem Vendor ID */
  180. int numDevices; /* number of devices */
  181. int FWVersion; /* FW Version (integer) */
  182. int BIOSVersion; /* BIOS Version (integer) */
  183. char driverVersion[MPT_IOCTL_VERSION_LENGTH]; /* Driver Version (string) */
  184. char busChangeEvent;
  185. char hostId;
  186. char rsvd[2];
  187. struct mpt_ioctl_pci_info pciInfo; /* Added Rev 1 */
  188. };
  189. /* Original structure, must always accept these
  190. * IOCTLs. 4 byte pads can occur based on arch with
  191. * above structure. Wish to re-align, but cannot.
  192. */
  193. struct mpt_ioctl_iocinfo_rev0 {
  194. mpt_ioctl_header hdr;
  195. int adapterType; /* SCSI or FCP */
  196. int port; /* port number */
  197. int pciId; /* PCI Id. */
  198. int hwRev; /* hardware revision */
  199. int subSystemDevice; /* PCI subsystem Device ID */
  200. int subSystemVendor; /* PCI subsystem Vendor ID */
  201. int numDevices; /* number of devices */
  202. int FWVersion; /* FW Version (integer) */
  203. int BIOSVersion; /* BIOS Version (integer) */
  204. char driverVersion[MPT_IOCTL_VERSION_LENGTH]; /* Driver Version (string) */
  205. char busChangeEvent;
  206. char hostId;
  207. char rsvd[2];
  208. };
  209. /*
  210. * Device Information Page
  211. * Report the number of, and ids of, all targets
  212. * on this IOC. The ids array is a packed structure
  213. * of the known targetInfo.
  214. * bits 31-24: reserved
  215. * 23-16: LUN
  216. * 15- 8: Bus Number
  217. * 7- 0: Target ID
  218. */
  219. struct mpt_ioctl_targetinfo {
  220. mpt_ioctl_header hdr;
  221. int numDevices; /* Num targets on this ioc */
  222. int targetInfo[1];
  223. };
  224. /*
  225. * Event reporting IOCTL's. These IOCTL's will
  226. * use the following defines:
  227. */
  228. struct mpt_ioctl_eventquery {
  229. mpt_ioctl_header hdr;
  230. unsigned short eventEntries;
  231. unsigned short reserved;
  232. unsigned int eventTypes;
  233. };
  234. struct mpt_ioctl_eventenable {
  235. mpt_ioctl_header hdr;
  236. unsigned int eventTypes;
  237. };
  238. #ifndef __KERNEL__
  239. typedef struct {
  240. uint event;
  241. uint eventContext;
  242. uint data[2];
  243. } MPT_IOCTL_EVENTS;
  244. #endif
  245. struct mpt_ioctl_eventreport {
  246. mpt_ioctl_header hdr;
  247. MPT_IOCTL_EVENTS eventData[1];
  248. };
  249. #define MPT_MAX_NAME 32
  250. struct mpt_ioctl_test {
  251. mpt_ioctl_header hdr;
  252. u8 name[MPT_MAX_NAME];
  253. int chip_type;
  254. u8 product [MPT_PRODUCT_LENGTH];
  255. };
  256. /* Replace the FW image cached in host driver memory
  257. * newImageSize - image size in bytes
  258. * newImage - first byte of the new image
  259. */
  260. typedef struct mpt_ioctl_replace_fw {
  261. mpt_ioctl_header hdr;
  262. int newImageSize;
  263. u8 newImage[1];
  264. } mpt_ioctl_replace_fw_t;
  265. /* General MPT Pass through data strucutre
  266. *
  267. * iocnum
  268. * timeout - in seconds, command timeout. If 0, set by driver to
  269. * default value.
  270. * replyFrameBufPtr - reply location
  271. * dataInBufPtr - destination for read
  272. * dataOutBufPtr - data source for write
  273. * senseDataPtr - sense data location
  274. * maxReplyBytes - maximum number of reply bytes to be sent to app.
  275. * dataInSize - num bytes for data transfer in (read)
  276. * dataOutSize - num bytes for data transfer out (write)
  277. * dataSgeOffset - offset in words from the start of the request message
  278. * to the first SGL
  279. * MF[1];
  280. *
  281. * Remark: Some config pages have bi-directional transfer,
  282. * both a read and a write. The basic structure allows for
  283. * a bidirectional set up. Normal messages will have one or
  284. * both of these buffers NULL.
  285. */
  286. struct mpt_ioctl_command {
  287. mpt_ioctl_header hdr;
  288. int timeout; /* optional (seconds) */
  289. char __user *replyFrameBufPtr;
  290. char __user *dataInBufPtr;
  291. char __user *dataOutBufPtr;
  292. char __user *senseDataPtr;
  293. int maxReplyBytes;
  294. int dataInSize;
  295. int dataOutSize;
  296. int maxSenseBytes;
  297. int dataSgeOffset;
  298. char MF[1];
  299. };
  300. /*
  301. * SPARC PLATFORM: See earlier remark.
  302. */
  303. #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
  304. struct mpt_ioctl_command32 {
  305. mpt_ioctl_header hdr;
  306. int timeout;
  307. u32 replyFrameBufPtr;
  308. u32 dataInBufPtr;
  309. u32 dataOutBufPtr;
  310. u32 senseDataPtr;
  311. int maxReplyBytes;
  312. int dataInSize;
  313. int dataOutSize;
  314. int maxSenseBytes;
  315. int dataSgeOffset;
  316. char MF[1];
  317. };
  318. #endif /*}*/
  319. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  320. #define CPQFCTS_IOC_MAGIC 'Z'
  321. #define HP_IOC_MAGIC 'Z'
  322. #define HP_GETHOSTINFO _IOR(HP_IOC_MAGIC, 20, hp_host_info_t)
  323. #define HP_GETHOSTINFO1 _IOR(HP_IOC_MAGIC, 20, hp_host_info_rev0_t)
  324. #define HP_GETTARGETINFO _IOR(HP_IOC_MAGIC, 21, hp_target_info_t)
  325. typedef struct _hp_header {
  326. unsigned int iocnum;
  327. unsigned int host;
  328. unsigned int channel;
  329. unsigned int id;
  330. unsigned int lun;
  331. } hp_header_t;
  332. /*
  333. * Header:
  334. * iocnum required (input)
  335. * host ignored
  336. * channe ignored
  337. * id ignored
  338. * lun ignored
  339. */
  340. typedef struct _hp_host_info {
  341. hp_header_t hdr;
  342. u16 vendor;
  343. u16 device;
  344. u16 subsystem_vendor;
  345. u16 subsystem_id;
  346. u8 devfn;
  347. u8 bus;
  348. ushort host_no; /* SCSI Host number, if scsi driver not loaded*/
  349. u8 fw_version[16]; /* string */
  350. u8 serial_number[24]; /* string */
  351. u32 ioc_status;
  352. u32 bus_phys_width;
  353. u32 base_io_addr;
  354. u32 rsvd;
  355. unsigned int hard_resets; /* driver initiated resets */
  356. unsigned int soft_resets; /* ioc, external resets */
  357. unsigned int timeouts; /* num timeouts */
  358. } hp_host_info_t;
  359. /* replace ulongs with uints, need to preserve backwards
  360. * compatibility.
  361. */
  362. typedef struct _hp_host_info_rev0 {
  363. hp_header_t hdr;
  364. u16 vendor;
  365. u16 device;
  366. u16 subsystem_vendor;
  367. u16 subsystem_id;
  368. u8 devfn;
  369. u8 bus;
  370. ushort host_no; /* SCSI Host number, if scsi driver not loaded*/
  371. u8 fw_version[16]; /* string */
  372. u8 serial_number[24]; /* string */
  373. u32 ioc_status;
  374. u32 bus_phys_width;
  375. u32 base_io_addr;
  376. u32 rsvd;
  377. unsigned long hard_resets; /* driver initiated resets */
  378. unsigned long soft_resets; /* ioc, external resets */
  379. unsigned long timeouts; /* num timeouts */
  380. } hp_host_info_rev0_t;
  381. /*
  382. * Header:
  383. * iocnum required (input)
  384. * host required
  385. * channel required (bus number)
  386. * id required
  387. * lun ignored
  388. *
  389. * All error values between 0 and 0xFFFF in size.
  390. */
  391. typedef struct _hp_target_info {
  392. hp_header_t hdr;
  393. u32 parity_errors;
  394. u32 phase_errors;
  395. u32 select_timeouts;
  396. u32 message_rejects;
  397. u32 negotiated_speed;
  398. u8 negotiated_width;
  399. u8 rsvd[7]; /* 8 byte alignment */
  400. } hp_target_info_t;
  401. #define HP_STATUS_OTHER 1
  402. #define HP_STATUS_OK 2
  403. #define HP_STATUS_FAILED 3
  404. #define HP_BUS_WIDTH_UNK 1
  405. #define HP_BUS_WIDTH_8 2
  406. #define HP_BUS_WIDTH_16 3
  407. #define HP_BUS_WIDTH_32 4
  408. #define HP_DEV_SPEED_ASYNC 2
  409. #define HP_DEV_SPEED_FAST 3
  410. #define HP_DEV_SPEED_ULTRA 4
  411. #define HP_DEV_SPEED_ULTRA2 5
  412. #define HP_DEV_SPEED_ULTRA160 6
  413. #define HP_DEV_SPEED_SCSI1 7
  414. #define HP_DEV_SPEED_ULTRA320 8
  415. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  416. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
  417. #endif