mpt3sas_ctl.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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 MPT3SAS_MINOR
  49. #define MPT3SAS_MINOR (MPT_MINOR + 2)
  50. #endif
  51. #define MPT3SAS_DEV_NAME "mpt3ctl"
  52. #define MPT3_MAGIC_NUMBER 'L'
  53. #define MPT3_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */
  54. /**
  55. * IOCTL opcodes
  56. */
  57. #define MPT3IOCINFO _IOWR(MPT3_MAGIC_NUMBER, 17, \
  58. struct mpt3_ioctl_iocinfo)
  59. #define MPT3COMMAND _IOWR(MPT3_MAGIC_NUMBER, 20, \
  60. struct mpt3_ioctl_command)
  61. #ifdef CONFIG_COMPAT
  62. #define MPT3COMMAND32 _IOWR(MPT3_MAGIC_NUMBER, 20, \
  63. struct mpt3_ioctl_command32)
  64. #endif
  65. #define MPT3EVENTQUERY _IOWR(MPT3_MAGIC_NUMBER, 21, \
  66. struct mpt3_ioctl_eventquery)
  67. #define MPT3EVENTENABLE _IOWR(MPT3_MAGIC_NUMBER, 22, \
  68. struct mpt3_ioctl_eventenable)
  69. #define MPT3EVENTREPORT _IOWR(MPT3_MAGIC_NUMBER, 23, \
  70. struct mpt3_ioctl_eventreport)
  71. #define MPT3HARDRESET _IOWR(MPT3_MAGIC_NUMBER, 24, \
  72. struct mpt3_ioctl_diag_reset)
  73. #define MPT3BTDHMAPPING _IOWR(MPT3_MAGIC_NUMBER, 31, \
  74. struct mpt3_ioctl_btdh_mapping)
  75. /* diag buffer support */
  76. #define MPT3DIAGREGISTER _IOWR(MPT3_MAGIC_NUMBER, 26, \
  77. struct mpt3_diag_register)
  78. #define MPT3DIAGRELEASE _IOWR(MPT3_MAGIC_NUMBER, 27, \
  79. struct mpt3_diag_release)
  80. #define MPT3DIAGUNREGISTER _IOWR(MPT3_MAGIC_NUMBER, 28, \
  81. struct mpt3_diag_unregister)
  82. #define MPT3DIAGQUERY _IOWR(MPT3_MAGIC_NUMBER, 29, \
  83. struct mpt3_diag_query)
  84. #define MPT3DIAGREADBUFFER _IOWR(MPT3_MAGIC_NUMBER, 30, \
  85. struct mpt3_diag_read_buffer)
  86. /**
  87. * struct mpt3_ioctl_header - main header structure
  88. * @ioc_number - IOC unit number
  89. * @port_number - IOC port number
  90. * @max_data_size - maximum number bytes to transfer on read
  91. */
  92. struct mpt3_ioctl_header {
  93. uint32_t ioc_number;
  94. uint32_t port_number;
  95. uint32_t max_data_size;
  96. };
  97. /**
  98. * struct mpt3_ioctl_diag_reset - diagnostic reset
  99. * @hdr - generic header
  100. */
  101. struct mpt3_ioctl_diag_reset {
  102. struct mpt3_ioctl_header hdr;
  103. };
  104. /**
  105. * struct mpt3_ioctl_pci_info - pci device info
  106. * @device - pci device id
  107. * @function - pci function id
  108. * @bus - pci bus id
  109. * @segment_id - pci segment id
  110. */
  111. struct mpt3_ioctl_pci_info {
  112. union {
  113. struct {
  114. uint32_t device:5;
  115. uint32_t function:3;
  116. uint32_t bus:24;
  117. } bits;
  118. uint32_t word;
  119. } u;
  120. uint32_t segment_id;
  121. };
  122. #define MPT2_IOCTL_INTERFACE_SCSI (0x00)
  123. #define MPT2_IOCTL_INTERFACE_FC (0x01)
  124. #define MPT2_IOCTL_INTERFACE_FC_IP (0x02)
  125. #define MPT2_IOCTL_INTERFACE_SAS (0x03)
  126. #define MPT2_IOCTL_INTERFACE_SAS2 (0x04)
  127. #define MPT3_IOCTL_INTERFACE_SAS3 (0x06)
  128. #define MPT2_IOCTL_VERSION_LENGTH (32)
  129. /**
  130. * struct mpt3_ioctl_iocinfo - generic controller info
  131. * @hdr - generic header
  132. * @adapter_type - type of adapter (spi, fc, sas)
  133. * @port_number - port number
  134. * @pci_id - PCI Id
  135. * @hw_rev - hardware revision
  136. * @sub_system_device - PCI subsystem Device ID
  137. * @sub_system_vendor - PCI subsystem Vendor ID
  138. * @rsvd0 - reserved
  139. * @firmware_version - firmware version
  140. * @bios_version - BIOS version
  141. * @driver_version - driver version - 32 ASCII characters
  142. * @rsvd1 - reserved
  143. * @scsi_id - scsi id of adapter 0
  144. * @rsvd2 - reserved
  145. * @pci_information - pci info (2nd revision)
  146. */
  147. struct mpt3_ioctl_iocinfo {
  148. struct mpt3_ioctl_header hdr;
  149. uint32_t adapter_type;
  150. uint32_t port_number;
  151. uint32_t pci_id;
  152. uint32_t hw_rev;
  153. uint32_t subsystem_device;
  154. uint32_t subsystem_vendor;
  155. uint32_t rsvd0;
  156. uint32_t firmware_version;
  157. uint32_t bios_version;
  158. uint8_t driver_version[MPT2_IOCTL_VERSION_LENGTH];
  159. uint8_t rsvd1;
  160. uint8_t scsi_id;
  161. uint16_t rsvd2;
  162. struct mpt3_ioctl_pci_info pci_information;
  163. };
  164. /* number of event log entries */
  165. #define MPT3SAS_CTL_EVENT_LOG_SIZE (50)
  166. /**
  167. * struct mpt3_ioctl_eventquery - query event count and type
  168. * @hdr - generic header
  169. * @event_entries - number of events returned by get_event_report
  170. * @rsvd - reserved
  171. * @event_types - type of events currently being captured
  172. */
  173. struct mpt3_ioctl_eventquery {
  174. struct mpt3_ioctl_header hdr;
  175. uint16_t event_entries;
  176. uint16_t rsvd;
  177. uint32_t event_types[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  178. };
  179. /**
  180. * struct mpt3_ioctl_eventenable - enable/disable event capturing
  181. * @hdr - generic header
  182. * @event_types - toggle off/on type of events to be captured
  183. */
  184. struct mpt3_ioctl_eventenable {
  185. struct mpt3_ioctl_header hdr;
  186. uint32_t event_types[4];
  187. };
  188. #define MPT3_EVENT_DATA_SIZE (192)
  189. /**
  190. * struct MPT3_IOCTL_EVENTS -
  191. * @event - the event that was reported
  192. * @context - unique value for each event assigned by driver
  193. * @data - event data returned in fw reply message
  194. */
  195. struct MPT3_IOCTL_EVENTS {
  196. uint32_t event;
  197. uint32_t context;
  198. uint8_t data[MPT3_EVENT_DATA_SIZE];
  199. };
  200. /**
  201. * struct mpt3_ioctl_eventreport - returing event log
  202. * @hdr - generic header
  203. * @event_data - (see struct MPT3_IOCTL_EVENTS)
  204. */
  205. struct mpt3_ioctl_eventreport {
  206. struct mpt3_ioctl_header hdr;
  207. struct MPT3_IOCTL_EVENTS event_data[1];
  208. };
  209. /**
  210. * struct mpt3_ioctl_command - generic mpt firmware passthru ioctl
  211. * @hdr - generic header
  212. * @timeout - command timeout in seconds. (if zero then use driver default
  213. * value).
  214. * @reply_frame_buf_ptr - reply location
  215. * @data_in_buf_ptr - destination for read
  216. * @data_out_buf_ptr - data source for write
  217. * @sense_data_ptr - sense data location
  218. * @max_reply_bytes - maximum number of reply bytes to be sent to app.
  219. * @data_in_size - number bytes for data transfer in (read)
  220. * @data_out_size - number bytes for data transfer out (write)
  221. * @max_sense_bytes - maximum number of bytes for auto sense buffers
  222. * @data_sge_offset - offset in words from the start of the request message to
  223. * the first SGL
  224. * @mf[1];
  225. */
  226. struct mpt3_ioctl_command {
  227. struct mpt3_ioctl_header hdr;
  228. uint32_t timeout;
  229. void __user *reply_frame_buf_ptr;
  230. void __user *data_in_buf_ptr;
  231. void __user *data_out_buf_ptr;
  232. void __user *sense_data_ptr;
  233. uint32_t max_reply_bytes;
  234. uint32_t data_in_size;
  235. uint32_t data_out_size;
  236. uint32_t max_sense_bytes;
  237. uint32_t data_sge_offset;
  238. uint8_t mf[1];
  239. };
  240. #ifdef CONFIG_COMPAT
  241. struct mpt3_ioctl_command32 {
  242. struct mpt3_ioctl_header hdr;
  243. uint32_t timeout;
  244. uint32_t reply_frame_buf_ptr;
  245. uint32_t data_in_buf_ptr;
  246. uint32_t data_out_buf_ptr;
  247. uint32_t sense_data_ptr;
  248. uint32_t max_reply_bytes;
  249. uint32_t data_in_size;
  250. uint32_t data_out_size;
  251. uint32_t max_sense_bytes;
  252. uint32_t data_sge_offset;
  253. uint8_t mf[1];
  254. };
  255. #endif
  256. /**
  257. * struct mpt3_ioctl_btdh_mapping - mapping info
  258. * @hdr - generic header
  259. * @id - target device identification number
  260. * @bus - SCSI bus number that the target device exists on
  261. * @handle - device handle for the target device
  262. * @rsvd - reserved
  263. *
  264. * To obtain a bus/id the application sets
  265. * handle to valid handle, and bus/id to 0xFFFF.
  266. *
  267. * To obtain the device handle the application sets
  268. * bus/id valid value, and the handle to 0xFFFF.
  269. */
  270. struct mpt3_ioctl_btdh_mapping {
  271. struct mpt3_ioctl_header hdr;
  272. uint32_t id;
  273. uint32_t bus;
  274. uint16_t handle;
  275. uint16_t rsvd;
  276. };
  277. /* application flags for mpt3_diag_register, mpt3_diag_query */
  278. #define MPT3_APP_FLAGS_APP_OWNED (0x0001)
  279. #define MPT3_APP_FLAGS_BUFFER_VALID (0x0002)
  280. #define MPT3_APP_FLAGS_FW_BUFFER_ACCESS (0x0004)
  281. /* flags for mpt3_diag_read_buffer */
  282. #define MPT3_FLAGS_REREGISTER (0x0001)
  283. #define MPT3_PRODUCT_SPECIFIC_DWORDS 23
  284. /**
  285. * struct mpt3_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 mpt3_diag_register {
  300. struct mpt3_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[MPT3_PRODUCT_SPECIFIC_DWORDS];
  306. uint32_t requested_buffer_size;
  307. uint32_t unique_id;
  308. };
  309. /**
  310. * struct mpt3_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 mpt3_diag_unregister {
  318. struct mpt3_ioctl_header hdr;
  319. uint32_t unique_id;
  320. };
  321. /**
  322. * struct mpt3_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 mpt3_diag_query {
  338. struct mpt3_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[MPT3_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 mpt3_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 mpt3_diag_release {
  358. struct mpt3_ioctl_header hdr;
  359. uint32_t unique_id;
  360. };
  361. /**
  362. * struct mpt3_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 mpt3_diag_read_buffer {
  375. struct mpt3_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 /* MPT3SAS_CTL_H_INCLUDED */