mpt3sas_ctl.h 14 KB

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