mpt3sas_ctl.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. /*
  2. * Management Module Support for MPT (Message Passing Technology) based
  3. * controllers
  4. *
  5. * This code is based on drivers/scsi/mpt3sas/mpt3sas_ctl.h
  6. * Copyright (C) 2012 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 MPT3SAS_CTL_H_INCLUDED
  43. #define MPT3SAS_CTL_H_INCLUDED
  44. #ifdef __KERNEL__
  45. #include <linux/miscdevice.h>
  46. #endif
  47. #ifndef MPT3SAS_MINOR
  48. #define MPT3SAS_MINOR (MPT_MINOR + 2)
  49. #endif
  50. #define MPT3SAS_DEV_NAME "mpt3ctl"
  51. #define MPT3_MAGIC_NUMBER 'L'
  52. #define MPT3_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */
  53. /**
  54. * IOCTL opcodes
  55. */
  56. #define MPT3IOCINFO _IOWR(MPT3_MAGIC_NUMBER, 17, \
  57. struct mpt3_ioctl_iocinfo)
  58. #define MPT3COMMAND _IOWR(MPT3_MAGIC_NUMBER, 20, \
  59. struct mpt3_ioctl_command)
  60. #ifdef CONFIG_COMPAT
  61. #define MPT3COMMAND32 _IOWR(MPT3_MAGIC_NUMBER, 20, \
  62. struct mpt3_ioctl_command32)
  63. #endif
  64. #define MPT3EVENTQUERY _IOWR(MPT3_MAGIC_NUMBER, 21, \
  65. struct mpt3_ioctl_eventquery)
  66. #define MPT3EVENTENABLE _IOWR(MPT3_MAGIC_NUMBER, 22, \
  67. struct mpt3_ioctl_eventenable)
  68. #define MPT3EVENTREPORT _IOWR(MPT3_MAGIC_NUMBER, 23, \
  69. struct mpt3_ioctl_eventreport)
  70. #define MPT3HARDRESET _IOWR(MPT3_MAGIC_NUMBER, 24, \
  71. struct mpt3_ioctl_diag_reset)
  72. #define MPT3BTDHMAPPING _IOWR(MPT3_MAGIC_NUMBER, 31, \
  73. struct mpt3_ioctl_btdh_mapping)
  74. /* diag buffer support */
  75. #define MPT3DIAGREGISTER _IOWR(MPT3_MAGIC_NUMBER, 26, \
  76. struct mpt3_diag_register)
  77. #define MPT3DIAGRELEASE _IOWR(MPT3_MAGIC_NUMBER, 27, \
  78. struct mpt3_diag_release)
  79. #define MPT3DIAGUNREGISTER _IOWR(MPT3_MAGIC_NUMBER, 28, \
  80. struct mpt3_diag_unregister)
  81. #define MPT3DIAGQUERY _IOWR(MPT3_MAGIC_NUMBER, 29, \
  82. struct mpt3_diag_query)
  83. #define MPT3DIAGREADBUFFER _IOWR(MPT3_MAGIC_NUMBER, 30, \
  84. struct mpt3_diag_read_buffer)
  85. /**
  86. * struct mpt3_ioctl_header - main header structure
  87. * @ioc_number - IOC unit number
  88. * @port_number - IOC port number
  89. * @max_data_size - maximum number bytes to transfer on read
  90. */
  91. struct mpt3_ioctl_header {
  92. uint32_t ioc_number;
  93. uint32_t port_number;
  94. uint32_t max_data_size;
  95. };
  96. /**
  97. * struct mpt3_ioctl_diag_reset - diagnostic reset
  98. * @hdr - generic header
  99. */
  100. struct mpt3_ioctl_diag_reset {
  101. struct mpt3_ioctl_header hdr;
  102. };
  103. /**
  104. * struct mpt3_ioctl_pci_info - pci device info
  105. * @device - pci device id
  106. * @function - pci function id
  107. * @bus - pci bus id
  108. * @segment_id - pci segment id
  109. */
  110. struct mpt3_ioctl_pci_info {
  111. union {
  112. struct {
  113. uint32_t device:5;
  114. uint32_t function:3;
  115. uint32_t bus:24;
  116. } bits;
  117. uint32_t word;
  118. } u;
  119. uint32_t segment_id;
  120. };
  121. #define MPT2_IOCTL_INTERFACE_SCSI (0x00)
  122. #define MPT2_IOCTL_INTERFACE_FC (0x01)
  123. #define MPT2_IOCTL_INTERFACE_FC_IP (0x02)
  124. #define MPT2_IOCTL_INTERFACE_SAS (0x03)
  125. #define MPT2_IOCTL_INTERFACE_SAS2 (0x04)
  126. #define MPT3_IOCTL_INTERFACE_SAS3 (0x06)
  127. #define MPT2_IOCTL_VERSION_LENGTH (32)
  128. /**
  129. * struct mpt3_ioctl_iocinfo - generic controller info
  130. * @hdr - generic header
  131. * @adapter_type - type of adapter (spi, fc, sas)
  132. * @port_number - port number
  133. * @pci_id - PCI Id
  134. * @hw_rev - hardware revision
  135. * @sub_system_device - PCI subsystem Device ID
  136. * @sub_system_vendor - PCI subsystem Vendor ID
  137. * @rsvd0 - reserved
  138. * @firmware_version - firmware version
  139. * @bios_version - BIOS version
  140. * @driver_version - driver version - 32 ASCII characters
  141. * @rsvd1 - reserved
  142. * @scsi_id - scsi id of adapter 0
  143. * @rsvd2 - reserved
  144. * @pci_information - pci info (2nd revision)
  145. */
  146. struct mpt3_ioctl_iocinfo {
  147. struct mpt3_ioctl_header hdr;
  148. uint32_t adapter_type;
  149. uint32_t port_number;
  150. uint32_t pci_id;
  151. uint32_t hw_rev;
  152. uint32_t subsystem_device;
  153. uint32_t subsystem_vendor;
  154. uint32_t rsvd0;
  155. uint32_t firmware_version;
  156. uint32_t bios_version;
  157. uint8_t driver_version[MPT2_IOCTL_VERSION_LENGTH];
  158. uint8_t rsvd1;
  159. uint8_t scsi_id;
  160. uint16_t rsvd2;
  161. struct mpt3_ioctl_pci_info pci_information;
  162. };
  163. /* number of event log entries */
  164. #define MPT3SAS_CTL_EVENT_LOG_SIZE (50)
  165. /**
  166. * struct mpt3_ioctl_eventquery - query event count and type
  167. * @hdr - generic header
  168. * @event_entries - number of events returned by get_event_report
  169. * @rsvd - reserved
  170. * @event_types - type of events currently being captured
  171. */
  172. struct mpt3_ioctl_eventquery {
  173. struct mpt3_ioctl_header hdr;
  174. uint16_t event_entries;
  175. uint16_t rsvd;
  176. uint32_t event_types[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  177. };
  178. /**
  179. * struct mpt3_ioctl_eventenable - enable/disable event capturing
  180. * @hdr - generic header
  181. * @event_types - toggle off/on type of events to be captured
  182. */
  183. struct mpt3_ioctl_eventenable {
  184. struct mpt3_ioctl_header hdr;
  185. uint32_t event_types[4];
  186. };
  187. #define MPT3_EVENT_DATA_SIZE (192)
  188. /**
  189. * struct MPT3_IOCTL_EVENTS -
  190. * @event - the event that was reported
  191. * @context - unique value for each event assigned by driver
  192. * @data - event data returned in fw reply message
  193. */
  194. struct MPT3_IOCTL_EVENTS {
  195. uint32_t event;
  196. uint32_t context;
  197. uint8_t data[MPT3_EVENT_DATA_SIZE];
  198. };
  199. /**
  200. * struct mpt3_ioctl_eventreport - returing event log
  201. * @hdr - generic header
  202. * @event_data - (see struct MPT3_IOCTL_EVENTS)
  203. */
  204. struct mpt3_ioctl_eventreport {
  205. struct mpt3_ioctl_header hdr;
  206. struct MPT3_IOCTL_EVENTS event_data[1];
  207. };
  208. /**
  209. * struct mpt3_ioctl_command - generic mpt firmware passthru ioctl
  210. * @hdr - generic header
  211. * @timeout - command timeout in seconds. (if zero then use driver default
  212. * value).
  213. * @reply_frame_buf_ptr - reply location
  214. * @data_in_buf_ptr - destination for read
  215. * @data_out_buf_ptr - data source for write
  216. * @sense_data_ptr - sense data location
  217. * @max_reply_bytes - maximum number of reply bytes to be sent to app.
  218. * @data_in_size - number bytes for data transfer in (read)
  219. * @data_out_size - number bytes for data transfer out (write)
  220. * @max_sense_bytes - maximum number of bytes for auto sense buffers
  221. * @data_sge_offset - offset in words from the start of the request message to
  222. * the first SGL
  223. * @mf[1];
  224. */
  225. struct mpt3_ioctl_command {
  226. struct mpt3_ioctl_header hdr;
  227. uint32_t timeout;
  228. void __user *reply_frame_buf_ptr;
  229. void __user *data_in_buf_ptr;
  230. void __user *data_out_buf_ptr;
  231. void __user *sense_data_ptr;
  232. uint32_t max_reply_bytes;
  233. uint32_t data_in_size;
  234. uint32_t data_out_size;
  235. uint32_t max_sense_bytes;
  236. uint32_t data_sge_offset;
  237. uint8_t mf[1];
  238. };
  239. #ifdef CONFIG_COMPAT
  240. struct mpt3_ioctl_command32 {
  241. struct mpt3_ioctl_header hdr;
  242. uint32_t timeout;
  243. uint32_t reply_frame_buf_ptr;
  244. uint32_t data_in_buf_ptr;
  245. uint32_t data_out_buf_ptr;
  246. uint32_t sense_data_ptr;
  247. uint32_t max_reply_bytes;
  248. uint32_t data_in_size;
  249. uint32_t data_out_size;
  250. uint32_t max_sense_bytes;
  251. uint32_t data_sge_offset;
  252. uint8_t mf[1];
  253. };
  254. #endif
  255. /**
  256. * struct mpt3_ioctl_btdh_mapping - mapping info
  257. * @hdr - generic header
  258. * @id - target device identification number
  259. * @bus - SCSI bus number that the target device exists on
  260. * @handle - device handle for the target device
  261. * @rsvd - reserved
  262. *
  263. * To obtain a bus/id the application sets
  264. * handle to valid handle, and bus/id to 0xFFFF.
  265. *
  266. * To obtain the device handle the application sets
  267. * bus/id valid value, and the handle to 0xFFFF.
  268. */
  269. struct mpt3_ioctl_btdh_mapping {
  270. struct mpt3_ioctl_header hdr;
  271. uint32_t id;
  272. uint32_t bus;
  273. uint16_t handle;
  274. uint16_t rsvd;
  275. };
  276. /* application flags for mpt3_diag_register, mpt3_diag_query */
  277. #define MPT3_APP_FLAGS_APP_OWNED (0x0001)
  278. #define MPT3_APP_FLAGS_BUFFER_VALID (0x0002)
  279. #define MPT3_APP_FLAGS_FW_BUFFER_ACCESS (0x0004)
  280. /* flags for mpt3_diag_read_buffer */
  281. #define MPT3_FLAGS_REREGISTER (0x0001)
  282. #define MPT3_PRODUCT_SPECIFIC_DWORDS 23
  283. /**
  284. * struct mpt3_diag_register - application register with driver
  285. * @hdr - generic header
  286. * @reserved -
  287. * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
  288. * @application_flags - misc flags
  289. * @diagnostic_flags - specifies flags affecting command processing
  290. * @product_specific - product specific information
  291. * @requested_buffer_size - buffers size in bytes
  292. * @unique_id - tag specified by application that is used to signal ownership
  293. * of the buffer.
  294. *
  295. * This will allow the driver to setup any required buffers that will be
  296. * needed by firmware to communicate with the driver.
  297. */
  298. struct mpt3_diag_register {
  299. struct mpt3_ioctl_header hdr;
  300. uint8_t reserved;
  301. uint8_t buffer_type;
  302. uint16_t application_flags;
  303. uint32_t diagnostic_flags;
  304. uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS];
  305. uint32_t requested_buffer_size;
  306. uint32_t unique_id;
  307. };
  308. /**
  309. * struct mpt3_diag_unregister - application unregister with driver
  310. * @hdr - generic header
  311. * @unique_id - tag uniquely identifies the buffer to be unregistered
  312. *
  313. * This will allow the driver to cleanup any memory allocated for diag
  314. * messages and to free up any resources.
  315. */
  316. struct mpt3_diag_unregister {
  317. struct mpt3_ioctl_header hdr;
  318. uint32_t unique_id;
  319. };
  320. /**
  321. * struct mpt3_diag_query - query relevant info associated with diag buffers
  322. * @hdr - generic header
  323. * @reserved -
  324. * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
  325. * @application_flags - misc flags
  326. * @diagnostic_flags - specifies flags affecting command processing
  327. * @product_specific - product specific information
  328. * @total_buffer_size - diag buffer size in bytes
  329. * @driver_added_buffer_size - size of extra space appended to end of buffer
  330. * @unique_id - unique id associated with this buffer.
  331. *
  332. * The application will send only buffer_type and unique_id. Driver will
  333. * inspect unique_id first, if valid, fill in all the info. If unique_id is
  334. * 0x00, the driver will return info specified by Buffer Type.
  335. */
  336. struct mpt3_diag_query {
  337. struct mpt3_ioctl_header hdr;
  338. uint8_t reserved;
  339. uint8_t buffer_type;
  340. uint16_t application_flags;
  341. uint32_t diagnostic_flags;
  342. uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS];
  343. uint32_t total_buffer_size;
  344. uint32_t driver_added_buffer_size;
  345. uint32_t unique_id;
  346. };
  347. /**
  348. * struct mpt3_diag_release - request to send Diag Release Message to firmware
  349. * @hdr - generic header
  350. * @unique_id - tag uniquely identifies the buffer to be released
  351. *
  352. * This allows ownership of the specified buffer to returned to the driver,
  353. * allowing an application to read the buffer without fear that firmware is
  354. * overwritting information in the buffer.
  355. */
  356. struct mpt3_diag_release {
  357. struct mpt3_ioctl_header hdr;
  358. uint32_t unique_id;
  359. };
  360. /**
  361. * struct mpt3_diag_read_buffer - request for copy of the diag buffer
  362. * @hdr - generic header
  363. * @status -
  364. * @reserved -
  365. * @flags - misc flags
  366. * @starting_offset - starting offset within drivers buffer where to start
  367. * reading data at into the specified application buffer
  368. * @bytes_to_read - number of bytes to copy from the drivers buffer into the
  369. * application buffer starting at starting_offset.
  370. * @unique_id - unique id associated with this buffer.
  371. * @diagnostic_data - data payload
  372. */
  373. struct mpt3_diag_read_buffer {
  374. struct mpt3_ioctl_header hdr;
  375. uint8_t status;
  376. uint8_t reserved;
  377. uint16_t flags;
  378. uint32_t starting_offset;
  379. uint32_t bytes_to_read;
  380. uint32_t unique_id;
  381. uint32_t diagnostic_data[1];
  382. };
  383. #endif /* MPT3SAS_CTL_H_INCLUDED */