mpt3sas_ctl.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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 MPT3_IOCTL_INTERFACE_SAS35 (0x07)
  134. #define MPT2_IOCTL_VERSION_LENGTH (32)
  135. /**
  136. * struct mpt3_ioctl_iocinfo - generic controller info
  137. * @hdr - generic header
  138. * @adapter_type - type of adapter (spi, fc, sas)
  139. * @port_number - port number
  140. * @pci_id - PCI Id
  141. * @hw_rev - hardware revision
  142. * @sub_system_device - PCI subsystem Device ID
  143. * @sub_system_vendor - PCI subsystem Vendor ID
  144. * @rsvd0 - reserved
  145. * @firmware_version - firmware version
  146. * @bios_version - BIOS version
  147. * @driver_version - driver version - 32 ASCII characters
  148. * @rsvd1 - reserved
  149. * @scsi_id - scsi id of adapter 0
  150. * @rsvd2 - reserved
  151. * @pci_information - pci info (2nd revision)
  152. */
  153. struct mpt3_ioctl_iocinfo {
  154. struct mpt3_ioctl_header hdr;
  155. uint32_t adapter_type;
  156. uint32_t port_number;
  157. uint32_t pci_id;
  158. uint32_t hw_rev;
  159. uint32_t subsystem_device;
  160. uint32_t subsystem_vendor;
  161. uint32_t rsvd0;
  162. uint32_t firmware_version;
  163. uint32_t bios_version;
  164. uint8_t driver_version[MPT2_IOCTL_VERSION_LENGTH];
  165. uint8_t rsvd1;
  166. uint8_t scsi_id;
  167. uint16_t rsvd2;
  168. struct mpt3_ioctl_pci_info pci_information;
  169. };
  170. /* number of event log entries */
  171. #define MPT3SAS_CTL_EVENT_LOG_SIZE (50)
  172. /**
  173. * struct mpt3_ioctl_eventquery - query event count and type
  174. * @hdr - generic header
  175. * @event_entries - number of events returned by get_event_report
  176. * @rsvd - reserved
  177. * @event_types - type of events currently being captured
  178. */
  179. struct mpt3_ioctl_eventquery {
  180. struct mpt3_ioctl_header hdr;
  181. uint16_t event_entries;
  182. uint16_t rsvd;
  183. uint32_t event_types[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  184. };
  185. /**
  186. * struct mpt3_ioctl_eventenable - enable/disable event capturing
  187. * @hdr - generic header
  188. * @event_types - toggle off/on type of events to be captured
  189. */
  190. struct mpt3_ioctl_eventenable {
  191. struct mpt3_ioctl_header hdr;
  192. uint32_t event_types[4];
  193. };
  194. #define MPT3_EVENT_DATA_SIZE (192)
  195. /**
  196. * struct MPT3_IOCTL_EVENTS -
  197. * @event - the event that was reported
  198. * @context - unique value for each event assigned by driver
  199. * @data - event data returned in fw reply message
  200. */
  201. struct MPT3_IOCTL_EVENTS {
  202. uint32_t event;
  203. uint32_t context;
  204. uint8_t data[MPT3_EVENT_DATA_SIZE];
  205. };
  206. /**
  207. * struct mpt3_ioctl_eventreport - returing event log
  208. * @hdr - generic header
  209. * @event_data - (see struct MPT3_IOCTL_EVENTS)
  210. */
  211. struct mpt3_ioctl_eventreport {
  212. struct mpt3_ioctl_header hdr;
  213. struct MPT3_IOCTL_EVENTS event_data[1];
  214. };
  215. /**
  216. * struct mpt3_ioctl_command - generic mpt firmware passthru ioctl
  217. * @hdr - generic header
  218. * @timeout - command timeout in seconds. (if zero then use driver default
  219. * value).
  220. * @reply_frame_buf_ptr - reply location
  221. * @data_in_buf_ptr - destination for read
  222. * @data_out_buf_ptr - data source for write
  223. * @sense_data_ptr - sense data location
  224. * @max_reply_bytes - maximum number of reply bytes to be sent to app.
  225. * @data_in_size - number bytes for data transfer in (read)
  226. * @data_out_size - number bytes for data transfer out (write)
  227. * @max_sense_bytes - maximum number of bytes for auto sense buffers
  228. * @data_sge_offset - offset in words from the start of the request message to
  229. * the first SGL
  230. * @mf[1];
  231. */
  232. struct mpt3_ioctl_command {
  233. struct mpt3_ioctl_header hdr;
  234. uint32_t timeout;
  235. void __user *reply_frame_buf_ptr;
  236. void __user *data_in_buf_ptr;
  237. void __user *data_out_buf_ptr;
  238. void __user *sense_data_ptr;
  239. uint32_t max_reply_bytes;
  240. uint32_t data_in_size;
  241. uint32_t data_out_size;
  242. uint32_t max_sense_bytes;
  243. uint32_t data_sge_offset;
  244. uint8_t mf[1];
  245. };
  246. #ifdef CONFIG_COMPAT
  247. struct mpt3_ioctl_command32 {
  248. struct mpt3_ioctl_header hdr;
  249. uint32_t timeout;
  250. uint32_t reply_frame_buf_ptr;
  251. uint32_t data_in_buf_ptr;
  252. uint32_t data_out_buf_ptr;
  253. uint32_t sense_data_ptr;
  254. uint32_t max_reply_bytes;
  255. uint32_t data_in_size;
  256. uint32_t data_out_size;
  257. uint32_t max_sense_bytes;
  258. uint32_t data_sge_offset;
  259. uint8_t mf[1];
  260. };
  261. #endif
  262. /**
  263. * struct mpt3_ioctl_btdh_mapping - mapping info
  264. * @hdr - generic header
  265. * @id - target device identification number
  266. * @bus - SCSI bus number that the target device exists on
  267. * @handle - device handle for the target device
  268. * @rsvd - reserved
  269. *
  270. * To obtain a bus/id the application sets
  271. * handle to valid handle, and bus/id to 0xFFFF.
  272. *
  273. * To obtain the device handle the application sets
  274. * bus/id valid value, and the handle to 0xFFFF.
  275. */
  276. struct mpt3_ioctl_btdh_mapping {
  277. struct mpt3_ioctl_header hdr;
  278. uint32_t id;
  279. uint32_t bus;
  280. uint16_t handle;
  281. uint16_t rsvd;
  282. };
  283. /* application flags for mpt3_diag_register, mpt3_diag_query */
  284. #define MPT3_APP_FLAGS_APP_OWNED (0x0001)
  285. #define MPT3_APP_FLAGS_BUFFER_VALID (0x0002)
  286. #define MPT3_APP_FLAGS_FW_BUFFER_ACCESS (0x0004)
  287. /* flags for mpt3_diag_read_buffer */
  288. #define MPT3_FLAGS_REREGISTER (0x0001)
  289. #define MPT3_PRODUCT_SPECIFIC_DWORDS 23
  290. /**
  291. * struct mpt3_diag_register - application register with driver
  292. * @hdr - generic header
  293. * @reserved -
  294. * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
  295. * @application_flags - misc flags
  296. * @diagnostic_flags - specifies flags affecting command processing
  297. * @product_specific - product specific information
  298. * @requested_buffer_size - buffers size in bytes
  299. * @unique_id - tag specified by application that is used to signal ownership
  300. * of the buffer.
  301. *
  302. * This will allow the driver to setup any required buffers that will be
  303. * needed by firmware to communicate with the driver.
  304. */
  305. struct mpt3_diag_register {
  306. struct mpt3_ioctl_header hdr;
  307. uint8_t reserved;
  308. uint8_t buffer_type;
  309. uint16_t application_flags;
  310. uint32_t diagnostic_flags;
  311. uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS];
  312. uint32_t requested_buffer_size;
  313. uint32_t unique_id;
  314. };
  315. /**
  316. * struct mpt3_diag_unregister - application unregister with driver
  317. * @hdr - generic header
  318. * @unique_id - tag uniquely identifies the buffer to be unregistered
  319. *
  320. * This will allow the driver to cleanup any memory allocated for diag
  321. * messages and to free up any resources.
  322. */
  323. struct mpt3_diag_unregister {
  324. struct mpt3_ioctl_header hdr;
  325. uint32_t unique_id;
  326. };
  327. /**
  328. * struct mpt3_diag_query - query relevant info associated with diag buffers
  329. * @hdr - generic header
  330. * @reserved -
  331. * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
  332. * @application_flags - misc flags
  333. * @diagnostic_flags - specifies flags affecting command processing
  334. * @product_specific - product specific information
  335. * @total_buffer_size - diag buffer size in bytes
  336. * @driver_added_buffer_size - size of extra space appended to end of buffer
  337. * @unique_id - unique id associated with this buffer.
  338. *
  339. * The application will send only buffer_type and unique_id. Driver will
  340. * inspect unique_id first, if valid, fill in all the info. If unique_id is
  341. * 0x00, the driver will return info specified by Buffer Type.
  342. */
  343. struct mpt3_diag_query {
  344. struct mpt3_ioctl_header hdr;
  345. uint8_t reserved;
  346. uint8_t buffer_type;
  347. uint16_t application_flags;
  348. uint32_t diagnostic_flags;
  349. uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS];
  350. uint32_t total_buffer_size;
  351. uint32_t driver_added_buffer_size;
  352. uint32_t unique_id;
  353. };
  354. /**
  355. * struct mpt3_diag_release - request to send Diag Release Message to firmware
  356. * @hdr - generic header
  357. * @unique_id - tag uniquely identifies the buffer to be released
  358. *
  359. * This allows ownership of the specified buffer to returned to the driver,
  360. * allowing an application to read the buffer without fear that firmware is
  361. * overwritting information in the buffer.
  362. */
  363. struct mpt3_diag_release {
  364. struct mpt3_ioctl_header hdr;
  365. uint32_t unique_id;
  366. };
  367. /**
  368. * struct mpt3_diag_read_buffer - request for copy of the diag buffer
  369. * @hdr - generic header
  370. * @status -
  371. * @reserved -
  372. * @flags - misc flags
  373. * @starting_offset - starting offset within drivers buffer where to start
  374. * reading data at into the specified application buffer
  375. * @bytes_to_read - number of bytes to copy from the drivers buffer into the
  376. * application buffer starting at starting_offset.
  377. * @unique_id - unique id associated with this buffer.
  378. * @diagnostic_data - data payload
  379. */
  380. struct mpt3_diag_read_buffer {
  381. struct mpt3_ioctl_header hdr;
  382. uint8_t status;
  383. uint8_t reserved;
  384. uint16_t flags;
  385. uint32_t starting_offset;
  386. uint32_t bytes_to_read;
  387. uint32_t unique_id;
  388. uint32_t diagnostic_data[1];
  389. };
  390. #endif /* MPT3SAS_CTL_H_INCLUDED */