mpt3sas_ctl.h 13 KB

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