mpt3sas_ctl.h 14 KB

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