mpt2sas_ctl.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. /*
  2. * Management Module Support for MPT (Message Passing Technology) based
  3. * controllers
  4. *
  5. * This code is based on drivers/scsi/mpt2sas/mpt2_ctl.h
  6. * Copyright (C) 2007-2010 LSI Corporation
  7. * (mailto:DL-MPTFusionLinux@lsi.com)
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * NO WARRANTY
  20. * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
  21. * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
  22. * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
  23. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
  24. * solely responsible for determining the appropriateness of using and
  25. * distributing the Program and assumes all risks associated with its
  26. * exercise of rights under this Agreement, including but not limited to
  27. * the risks and costs of program errors, damage to or loss of data,
  28. * programs or equipment, and unavailability or interruption of operations.
  29. * DISCLAIMER OF LIABILITY
  30. * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
  31. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  32. * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
  33. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  34. * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  35. * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
  36. * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
  37. * You should have received a copy of the GNU General Public License
  38. * along with this program; if not, write to the Free Software
  39. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  40. * USA.
  41. */
  42. #ifndef MPT2SAS_CTL_H_INCLUDED
  43. #define MPT2SAS_CTL_H_INCLUDED
  44. #ifdef __KERNEL__
  45. #include <linux/miscdevice.h>
  46. #endif
  47. #define MPT2SAS_DEV_NAME "mpt2ctl"
  48. #define MPT2_MAGIC_NUMBER 'L'
  49. #define MPT2_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */
  50. /**
  51. * IOCTL opcodes
  52. */
  53. #define MPT2IOCINFO _IOWR(MPT2_MAGIC_NUMBER, 17, \
  54. struct mpt2_ioctl_iocinfo)
  55. #define MPT2COMMAND _IOWR(MPT2_MAGIC_NUMBER, 20, \
  56. struct mpt2_ioctl_command)
  57. #ifdef CONFIG_COMPAT
  58. #define MPT2COMMAND32 _IOWR(MPT2_MAGIC_NUMBER, 20, \
  59. struct mpt2_ioctl_command32)
  60. #endif
  61. #define MPT2EVENTQUERY _IOWR(MPT2_MAGIC_NUMBER, 21, \
  62. struct mpt2_ioctl_eventquery)
  63. #define MPT2EVENTENABLE _IOWR(MPT2_MAGIC_NUMBER, 22, \
  64. struct mpt2_ioctl_eventenable)
  65. #define MPT2EVENTREPORT _IOWR(MPT2_MAGIC_NUMBER, 23, \
  66. struct mpt2_ioctl_eventreport)
  67. #define MPT2HARDRESET _IOWR(MPT2_MAGIC_NUMBER, 24, \
  68. struct mpt2_ioctl_diag_reset)
  69. #define MPT2BTDHMAPPING _IOWR(MPT2_MAGIC_NUMBER, 31, \
  70. struct mpt2_ioctl_btdh_mapping)
  71. /* diag buffer support */
  72. #define MPT2DIAGREGISTER _IOWR(MPT2_MAGIC_NUMBER, 26, \
  73. struct mpt2_diag_register)
  74. #define MPT2DIAGRELEASE _IOWR(MPT2_MAGIC_NUMBER, 27, \
  75. struct mpt2_diag_release)
  76. #define MPT2DIAGUNREGISTER _IOWR(MPT2_MAGIC_NUMBER, 28, \
  77. struct mpt2_diag_unregister)
  78. #define MPT2DIAGQUERY _IOWR(MPT2_MAGIC_NUMBER, 29, \
  79. struct mpt2_diag_query)
  80. #define MPT2DIAGREADBUFFER _IOWR(MPT2_MAGIC_NUMBER, 30, \
  81. struct mpt2_diag_read_buffer)
  82. /**
  83. * struct mpt2_ioctl_header - main header structure
  84. * @ioc_number - IOC unit number
  85. * @port_number - IOC port number
  86. * @max_data_size - maximum number bytes to transfer on read
  87. */
  88. struct mpt2_ioctl_header {
  89. uint32_t ioc_number;
  90. uint32_t port_number;
  91. uint32_t max_data_size;
  92. };
  93. /**
  94. * struct mpt2_ioctl_diag_reset - diagnostic reset
  95. * @hdr - generic header
  96. */
  97. struct mpt2_ioctl_diag_reset {
  98. struct mpt2_ioctl_header hdr;
  99. };
  100. /**
  101. * struct mpt2_ioctl_pci_info - pci device info
  102. * @device - pci device id
  103. * @function - pci function id
  104. * @bus - pci bus id
  105. * @segment_id - pci segment id
  106. */
  107. struct mpt2_ioctl_pci_info {
  108. union {
  109. struct {
  110. uint32_t device:5;
  111. uint32_t function:3;
  112. uint32_t bus:24;
  113. } bits;
  114. uint32_t word;
  115. } u;
  116. uint32_t segment_id;
  117. };
  118. #define MPT2_IOCTL_INTERFACE_SCSI (0x00)
  119. #define MPT2_IOCTL_INTERFACE_FC (0x01)
  120. #define MPT2_IOCTL_INTERFACE_FC_IP (0x02)
  121. #define MPT2_IOCTL_INTERFACE_SAS (0x03)
  122. #define MPT2_IOCTL_INTERFACE_SAS2 (0x04)
  123. #define MPT2_IOCTL_INTERFACE_SAS2_SSS6200 (0x05)
  124. #define MPT2_IOCTL_VERSION_LENGTH (32)
  125. /**
  126. * struct mpt2_ioctl_iocinfo - generic controller info
  127. * @hdr - generic header
  128. * @adapter_type - type of adapter (spi, fc, sas)
  129. * @port_number - port number
  130. * @pci_id - PCI Id
  131. * @hw_rev - hardware revision
  132. * @sub_system_device - PCI subsystem Device ID
  133. * @sub_system_vendor - PCI subsystem Vendor ID
  134. * @rsvd0 - reserved
  135. * @firmware_version - firmware version
  136. * @bios_version - BIOS version
  137. * @driver_version - driver version - 32 ASCII characters
  138. * @rsvd1 - reserved
  139. * @scsi_id - scsi id of adapter 0
  140. * @rsvd2 - reserved
  141. * @pci_information - pci info (2nd revision)
  142. */
  143. struct mpt2_ioctl_iocinfo {
  144. struct mpt2_ioctl_header hdr;
  145. uint32_t adapter_type;
  146. uint32_t port_number;
  147. uint32_t pci_id;
  148. uint32_t hw_rev;
  149. uint32_t subsystem_device;
  150. uint32_t subsystem_vendor;
  151. uint32_t rsvd0;
  152. uint32_t firmware_version;
  153. uint32_t bios_version;
  154. uint8_t driver_version[MPT2_IOCTL_VERSION_LENGTH];
  155. uint8_t rsvd1;
  156. uint8_t scsi_id;
  157. uint16_t rsvd2;
  158. struct mpt2_ioctl_pci_info pci_information;
  159. };
  160. /* number of event log entries */
  161. #define MPT2SAS_CTL_EVENT_LOG_SIZE (50)
  162. /**
  163. * struct mpt2_ioctl_eventquery - query event count and type
  164. * @hdr - generic header
  165. * @event_entries - number of events returned by get_event_report
  166. * @rsvd - reserved
  167. * @event_types - type of events currently being captured
  168. */
  169. struct mpt2_ioctl_eventquery {
  170. struct mpt2_ioctl_header hdr;
  171. uint16_t event_entries;
  172. uint16_t rsvd;
  173. uint32_t event_types[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  174. };
  175. /**
  176. * struct mpt2_ioctl_eventenable - enable/disable event capturing
  177. * @hdr - generic header
  178. * @event_types - toggle off/on type of events to be captured
  179. */
  180. struct mpt2_ioctl_eventenable {
  181. struct mpt2_ioctl_header hdr;
  182. uint32_t event_types[4];
  183. };
  184. #define MPT2_EVENT_DATA_SIZE (192)
  185. /**
  186. * struct MPT2_IOCTL_EVENTS -
  187. * @event - the event that was reported
  188. * @context - unique value for each event assigned by driver
  189. * @data - event data returned in fw reply message
  190. */
  191. struct MPT2_IOCTL_EVENTS {
  192. uint32_t event;
  193. uint32_t context;
  194. uint8_t data[MPT2_EVENT_DATA_SIZE];
  195. };
  196. /**
  197. * struct mpt2_ioctl_eventreport - returing event log
  198. * @hdr - generic header
  199. * @event_data - (see struct MPT2_IOCTL_EVENTS)
  200. */
  201. struct mpt2_ioctl_eventreport {
  202. struct mpt2_ioctl_header hdr;
  203. struct MPT2_IOCTL_EVENTS event_data[1];
  204. };
  205. /**
  206. * struct mpt2_ioctl_command - generic mpt firmware passthru ioclt
  207. * @hdr - generic header
  208. * @timeout - command timeout in seconds. (if zero then use driver default
  209. * value).
  210. * @reply_frame_buf_ptr - reply location
  211. * @data_in_buf_ptr - destination for read
  212. * @data_out_buf_ptr - data source for write
  213. * @sense_data_ptr - sense data location
  214. * @max_reply_bytes - maximum number of reply bytes to be sent to app.
  215. * @data_in_size - number bytes for data transfer in (read)
  216. * @data_out_size - number bytes for data transfer out (write)
  217. * @max_sense_bytes - maximum number of bytes for auto sense buffers
  218. * @data_sge_offset - offset in words from the start of the request message to
  219. * the first SGL
  220. * @mf[1];
  221. */
  222. struct mpt2_ioctl_command {
  223. struct mpt2_ioctl_header hdr;
  224. uint32_t timeout;
  225. void __user *reply_frame_buf_ptr;
  226. void __user *data_in_buf_ptr;
  227. void __user *data_out_buf_ptr;
  228. void __user *sense_data_ptr;
  229. uint32_t max_reply_bytes;
  230. uint32_t data_in_size;
  231. uint32_t data_out_size;
  232. uint32_t max_sense_bytes;
  233. uint32_t data_sge_offset;
  234. uint8_t mf[1];
  235. };
  236. #ifdef CONFIG_COMPAT
  237. struct mpt2_ioctl_command32 {
  238. struct mpt2_ioctl_header hdr;
  239. uint32_t timeout;
  240. uint32_t reply_frame_buf_ptr;
  241. uint32_t data_in_buf_ptr;
  242. uint32_t data_out_buf_ptr;
  243. uint32_t sense_data_ptr;
  244. uint32_t max_reply_bytes;
  245. uint32_t data_in_size;
  246. uint32_t data_out_size;
  247. uint32_t max_sense_bytes;
  248. uint32_t data_sge_offset;
  249. uint8_t mf[1];
  250. };
  251. #endif
  252. /**
  253. * struct mpt2_ioctl_btdh_mapping - mapping info
  254. * @hdr - generic header
  255. * @id - target device identification number
  256. * @bus - SCSI bus number that the target device exists on
  257. * @handle - device handle for the target device
  258. * @rsvd - reserved
  259. *
  260. * To obtain a bus/id the application sets
  261. * handle to valid handle, and bus/id to 0xFFFF.
  262. *
  263. * To obtain the device handle the application sets
  264. * bus/id valid value, and the handle to 0xFFFF.
  265. */
  266. struct mpt2_ioctl_btdh_mapping {
  267. struct mpt2_ioctl_header hdr;
  268. uint32_t id;
  269. uint32_t bus;
  270. uint16_t handle;
  271. uint16_t rsvd;
  272. };
  273. /* status bits for ioc->diag_buffer_status */
  274. #define MPT2_DIAG_BUFFER_IS_REGISTERED (0x01)
  275. #define MPT2_DIAG_BUFFER_IS_RELEASED (0x02)
  276. #define MPT2_DIAG_BUFFER_IS_DIAG_RESET (0x04)
  277. /* application flags for mpt2_diag_register, mpt2_diag_query */
  278. #define MPT2_APP_FLAGS_APP_OWNED (0x0001)
  279. #define MPT2_APP_FLAGS_BUFFER_VALID (0x0002)
  280. #define MPT2_APP_FLAGS_FW_BUFFER_ACCESS (0x0004)
  281. /* flags for mpt2_diag_read_buffer */
  282. #define MPT2_FLAGS_REREGISTER (0x0001)
  283. #define MPT2_PRODUCT_SPECIFIC_DWORDS 23
  284. /**
  285. * struct mpt2_diag_register - application register with driver
  286. * @hdr - generic header
  287. * @reserved -
  288. * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
  289. * @application_flags - misc flags
  290. * @diagnostic_flags - specifies flags affecting command processing
  291. * @product_specific - product specific information
  292. * @requested_buffer_size - buffers size in bytes
  293. * @unique_id - tag specified by application that is used to signal ownership
  294. * of the buffer.
  295. *
  296. * This will allow the driver to setup any required buffers that will be
  297. * needed by firmware to communicate with the driver.
  298. */
  299. struct mpt2_diag_register {
  300. struct mpt2_ioctl_header hdr;
  301. uint8_t reserved;
  302. uint8_t buffer_type;
  303. uint16_t application_flags;
  304. uint32_t diagnostic_flags;
  305. uint32_t product_specific[MPT2_PRODUCT_SPECIFIC_DWORDS];
  306. uint32_t requested_buffer_size;
  307. uint32_t unique_id;
  308. };
  309. /**
  310. * struct mpt2_diag_unregister - application unregister with driver
  311. * @hdr - generic header
  312. * @unique_id - tag uniquely identifies the buffer to be unregistered
  313. *
  314. * This will allow the driver to cleanup any memory allocated for diag
  315. * messages and to free up any resources.
  316. */
  317. struct mpt2_diag_unregister {
  318. struct mpt2_ioctl_header hdr;
  319. uint32_t unique_id;
  320. };
  321. /**
  322. * struct mpt2_diag_query - query relevant info associated with diag buffers
  323. * @hdr - generic header
  324. * @reserved -
  325. * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
  326. * @application_flags - misc flags
  327. * @diagnostic_flags - specifies flags affecting command processing
  328. * @product_specific - product specific information
  329. * @total_buffer_size - diag buffer size in bytes
  330. * @driver_added_buffer_size - size of extra space appended to end of buffer
  331. * @unique_id - unique id associated with this buffer.
  332. *
  333. * The application will send only buffer_type and unique_id. Driver will
  334. * inspect unique_id first, if valid, fill in all the info. If unique_id is
  335. * 0x00, the driver will return info specified by Buffer Type.
  336. */
  337. struct mpt2_diag_query {
  338. struct mpt2_ioctl_header hdr;
  339. uint8_t reserved;
  340. uint8_t buffer_type;
  341. uint16_t application_flags;
  342. uint32_t diagnostic_flags;
  343. uint32_t product_specific[MPT2_PRODUCT_SPECIFIC_DWORDS];
  344. uint32_t total_buffer_size;
  345. uint32_t driver_added_buffer_size;
  346. uint32_t unique_id;
  347. };
  348. /**
  349. * struct mpt2_diag_release - request to send Diag Release Message to firmware
  350. * @hdr - generic header
  351. * @unique_id - tag uniquely identifies the buffer to be released
  352. *
  353. * This allows ownership of the specified buffer to returned to the driver,
  354. * allowing an application to read the buffer without fear that firmware is
  355. * overwritting information in the buffer.
  356. */
  357. struct mpt2_diag_release {
  358. struct mpt2_ioctl_header hdr;
  359. uint32_t unique_id;
  360. };
  361. /**
  362. * struct mpt2_diag_read_buffer - request for copy of the diag buffer
  363. * @hdr - generic header
  364. * @status -
  365. * @reserved -
  366. * @flags - misc flags
  367. * @starting_offset - starting offset within drivers buffer where to start
  368. * reading data at into the specified application buffer
  369. * @bytes_to_read - number of bytes to copy from the drivers buffer into the
  370. * application buffer starting at starting_offset.
  371. * @unique_id - unique id associated with this buffer.
  372. * @diagnostic_data - data payload
  373. */
  374. struct mpt2_diag_read_buffer {
  375. struct mpt2_ioctl_header hdr;
  376. uint8_t status;
  377. uint8_t reserved;
  378. uint16_t flags;
  379. uint32_t starting_offset;
  380. uint32_t bytes_to_read;
  381. uint32_t unique_id;
  382. uint32_t diagnostic_data[1];
  383. };
  384. #endif /* MPT2SAS_CTL_H_INCLUDED */