mpt2sas_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/mpt2sas/mpt2_ctl.h
  6. * Copyright (C) 2007-2014 LSI Corporation
  7. * Copyright (C) 20013-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 MPT2SAS_CTL_H_INCLUDED
  44. #define MPT2SAS_CTL_H_INCLUDED
  45. #ifdef __KERNEL__
  46. #include <linux/miscdevice.h>
  47. #endif
  48. #define MPT2SAS_DEV_NAME "mpt2ctl"
  49. #define MPT2_MAGIC_NUMBER 'L'
  50. #define MPT2_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */
  51. /**
  52. * IOCTL opcodes
  53. */
  54. #define MPT2IOCINFO _IOWR(MPT2_MAGIC_NUMBER, 17, \
  55. struct mpt2_ioctl_iocinfo)
  56. #define MPT2COMMAND _IOWR(MPT2_MAGIC_NUMBER, 20, \
  57. struct mpt2_ioctl_command)
  58. #ifdef CONFIG_COMPAT
  59. #define MPT2COMMAND32 _IOWR(MPT2_MAGIC_NUMBER, 20, \
  60. struct mpt2_ioctl_command32)
  61. #endif
  62. #define MPT2EVENTQUERY _IOWR(MPT2_MAGIC_NUMBER, 21, \
  63. struct mpt2_ioctl_eventquery)
  64. #define MPT2EVENTENABLE _IOWR(MPT2_MAGIC_NUMBER, 22, \
  65. struct mpt2_ioctl_eventenable)
  66. #define MPT2EVENTREPORT _IOWR(MPT2_MAGIC_NUMBER, 23, \
  67. struct mpt2_ioctl_eventreport)
  68. #define MPT2HARDRESET _IOWR(MPT2_MAGIC_NUMBER, 24, \
  69. struct mpt2_ioctl_diag_reset)
  70. #define MPT2BTDHMAPPING _IOWR(MPT2_MAGIC_NUMBER, 31, \
  71. struct mpt2_ioctl_btdh_mapping)
  72. /* diag buffer support */
  73. #define MPT2DIAGREGISTER _IOWR(MPT2_MAGIC_NUMBER, 26, \
  74. struct mpt2_diag_register)
  75. #define MPT2DIAGRELEASE _IOWR(MPT2_MAGIC_NUMBER, 27, \
  76. struct mpt2_diag_release)
  77. #define MPT2DIAGUNREGISTER _IOWR(MPT2_MAGIC_NUMBER, 28, \
  78. struct mpt2_diag_unregister)
  79. #define MPT2DIAGQUERY _IOWR(MPT2_MAGIC_NUMBER, 29, \
  80. struct mpt2_diag_query)
  81. #define MPT2DIAGREADBUFFER _IOWR(MPT2_MAGIC_NUMBER, 30, \
  82. struct mpt2_diag_read_buffer)
  83. /**
  84. * struct mpt2_ioctl_header - main header structure
  85. * @ioc_number - IOC unit number
  86. * @port_number - IOC port number
  87. * @max_data_size - maximum number bytes to transfer on read
  88. */
  89. struct mpt2_ioctl_header {
  90. uint32_t ioc_number;
  91. uint32_t port_number;
  92. uint32_t max_data_size;
  93. };
  94. /**
  95. * struct mpt2_ioctl_diag_reset - diagnostic reset
  96. * @hdr - generic header
  97. */
  98. struct mpt2_ioctl_diag_reset {
  99. struct mpt2_ioctl_header hdr;
  100. };
  101. /**
  102. * struct mpt2_ioctl_pci_info - pci device info
  103. * @device - pci device id
  104. * @function - pci function id
  105. * @bus - pci bus id
  106. * @segment_id - pci segment id
  107. */
  108. struct mpt2_ioctl_pci_info {
  109. union {
  110. struct {
  111. uint32_t device:5;
  112. uint32_t function:3;
  113. uint32_t bus:24;
  114. } bits;
  115. uint32_t word;
  116. } u;
  117. uint32_t segment_id;
  118. };
  119. #define MPT2_IOCTL_INTERFACE_SCSI (0x00)
  120. #define MPT2_IOCTL_INTERFACE_FC (0x01)
  121. #define MPT2_IOCTL_INTERFACE_FC_IP (0x02)
  122. #define MPT2_IOCTL_INTERFACE_SAS (0x03)
  123. #define MPT2_IOCTL_INTERFACE_SAS2 (0x04)
  124. #define MPT2_IOCTL_INTERFACE_SAS2_SSS6200 (0x05)
  125. #define MPT2_IOCTL_VERSION_LENGTH (32)
  126. /**
  127. * struct mpt2_ioctl_iocinfo - generic controller info
  128. * @hdr - generic header
  129. * @adapter_type - type of adapter (spi, fc, sas)
  130. * @port_number - port number
  131. * @pci_id - PCI Id
  132. * @hw_rev - hardware revision
  133. * @sub_system_device - PCI subsystem Device ID
  134. * @sub_system_vendor - PCI subsystem Vendor ID
  135. * @rsvd0 - reserved
  136. * @firmware_version - firmware version
  137. * @bios_version - BIOS version
  138. * @driver_version - driver version - 32 ASCII characters
  139. * @rsvd1 - reserved
  140. * @scsi_id - scsi id of adapter 0
  141. * @rsvd2 - reserved
  142. * @pci_information - pci info (2nd revision)
  143. */
  144. struct mpt2_ioctl_iocinfo {
  145. struct mpt2_ioctl_header hdr;
  146. uint32_t adapter_type;
  147. uint32_t port_number;
  148. uint32_t pci_id;
  149. uint32_t hw_rev;
  150. uint32_t subsystem_device;
  151. uint32_t subsystem_vendor;
  152. uint32_t rsvd0;
  153. uint32_t firmware_version;
  154. uint32_t bios_version;
  155. uint8_t driver_version[MPT2_IOCTL_VERSION_LENGTH];
  156. uint8_t rsvd1;
  157. uint8_t scsi_id;
  158. uint16_t rsvd2;
  159. struct mpt2_ioctl_pci_info pci_information;
  160. };
  161. /* number of event log entries */
  162. #define MPT2SAS_CTL_EVENT_LOG_SIZE (50)
  163. /**
  164. * struct mpt2_ioctl_eventquery - query event count and type
  165. * @hdr - generic header
  166. * @event_entries - number of events returned by get_event_report
  167. * @rsvd - reserved
  168. * @event_types - type of events currently being captured
  169. */
  170. struct mpt2_ioctl_eventquery {
  171. struct mpt2_ioctl_header hdr;
  172. uint16_t event_entries;
  173. uint16_t rsvd;
  174. uint32_t event_types[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  175. };
  176. /**
  177. * struct mpt2_ioctl_eventenable - enable/disable event capturing
  178. * @hdr - generic header
  179. * @event_types - toggle off/on type of events to be captured
  180. */
  181. struct mpt2_ioctl_eventenable {
  182. struct mpt2_ioctl_header hdr;
  183. uint32_t event_types[4];
  184. };
  185. #define MPT2_EVENT_DATA_SIZE (192)
  186. /**
  187. * struct MPT2_IOCTL_EVENTS -
  188. * @event - the event that was reported
  189. * @context - unique value for each event assigned by driver
  190. * @data - event data returned in fw reply message
  191. */
  192. struct MPT2_IOCTL_EVENTS {
  193. uint32_t event;
  194. uint32_t context;
  195. uint8_t data[MPT2_EVENT_DATA_SIZE];
  196. };
  197. /**
  198. * struct mpt2_ioctl_eventreport - returing event log
  199. * @hdr - generic header
  200. * @event_data - (see struct MPT2_IOCTL_EVENTS)
  201. */
  202. struct mpt2_ioctl_eventreport {
  203. struct mpt2_ioctl_header hdr;
  204. struct MPT2_IOCTL_EVENTS event_data[1];
  205. };
  206. /**
  207. * struct mpt2_ioctl_command - generic mpt firmware passthru ioctl
  208. * @hdr - generic header
  209. * @timeout - command timeout in seconds. (if zero then use driver default
  210. * value).
  211. * @reply_frame_buf_ptr - reply location
  212. * @data_in_buf_ptr - destination for read
  213. * @data_out_buf_ptr - data source for write
  214. * @sense_data_ptr - sense data location
  215. * @max_reply_bytes - maximum number of reply bytes to be sent to app.
  216. * @data_in_size - number bytes for data transfer in (read)
  217. * @data_out_size - number bytes for data transfer out (write)
  218. * @max_sense_bytes - maximum number of bytes for auto sense buffers
  219. * @data_sge_offset - offset in words from the start of the request message to
  220. * the first SGL
  221. * @mf[1];
  222. */
  223. struct mpt2_ioctl_command {
  224. struct mpt2_ioctl_header hdr;
  225. uint32_t timeout;
  226. void __user *reply_frame_buf_ptr;
  227. void __user *data_in_buf_ptr;
  228. void __user *data_out_buf_ptr;
  229. void __user *sense_data_ptr;
  230. uint32_t max_reply_bytes;
  231. uint32_t data_in_size;
  232. uint32_t data_out_size;
  233. uint32_t max_sense_bytes;
  234. uint32_t data_sge_offset;
  235. uint8_t mf[1];
  236. };
  237. #ifdef CONFIG_COMPAT
  238. struct mpt2_ioctl_command32 {
  239. struct mpt2_ioctl_header hdr;
  240. uint32_t timeout;
  241. uint32_t reply_frame_buf_ptr;
  242. uint32_t data_in_buf_ptr;
  243. uint32_t data_out_buf_ptr;
  244. uint32_t sense_data_ptr;
  245. uint32_t max_reply_bytes;
  246. uint32_t data_in_size;
  247. uint32_t data_out_size;
  248. uint32_t max_sense_bytes;
  249. uint32_t data_sge_offset;
  250. uint8_t mf[1];
  251. };
  252. #endif
  253. /**
  254. * struct mpt2_ioctl_btdh_mapping - mapping info
  255. * @hdr - generic header
  256. * @id - target device identification number
  257. * @bus - SCSI bus number that the target device exists on
  258. * @handle - device handle for the target device
  259. * @rsvd - reserved
  260. *
  261. * To obtain a bus/id the application sets
  262. * handle to valid handle, and bus/id to 0xFFFF.
  263. *
  264. * To obtain the device handle the application sets
  265. * bus/id valid value, and the handle to 0xFFFF.
  266. */
  267. struct mpt2_ioctl_btdh_mapping {
  268. struct mpt2_ioctl_header hdr;
  269. uint32_t id;
  270. uint32_t bus;
  271. uint16_t handle;
  272. uint16_t rsvd;
  273. };
  274. /* status bits for ioc->diag_buffer_status */
  275. #define MPT2_DIAG_BUFFER_IS_REGISTERED (0x01)
  276. #define MPT2_DIAG_BUFFER_IS_RELEASED (0x02)
  277. #define MPT2_DIAG_BUFFER_IS_DIAG_RESET (0x04)
  278. /* application flags for mpt2_diag_register, mpt2_diag_query */
  279. #define MPT2_APP_FLAGS_APP_OWNED (0x0001)
  280. #define MPT2_APP_FLAGS_BUFFER_VALID (0x0002)
  281. #define MPT2_APP_FLAGS_FW_BUFFER_ACCESS (0x0004)
  282. /* flags for mpt2_diag_read_buffer */
  283. #define MPT2_FLAGS_REREGISTER (0x0001)
  284. #define MPT2_PRODUCT_SPECIFIC_DWORDS 23
  285. /**
  286. * struct mpt2_diag_register - application register with driver
  287. * @hdr - generic header
  288. * @reserved -
  289. * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
  290. * @application_flags - misc flags
  291. * @diagnostic_flags - specifies flags affecting command processing
  292. * @product_specific - product specific information
  293. * @requested_buffer_size - buffers size in bytes
  294. * @unique_id - tag specified by application that is used to signal ownership
  295. * of the buffer.
  296. *
  297. * This will allow the driver to setup any required buffers that will be
  298. * needed by firmware to communicate with the driver.
  299. */
  300. struct mpt2_diag_register {
  301. struct mpt2_ioctl_header hdr;
  302. uint8_t reserved;
  303. uint8_t buffer_type;
  304. uint16_t application_flags;
  305. uint32_t diagnostic_flags;
  306. uint32_t product_specific[MPT2_PRODUCT_SPECIFIC_DWORDS];
  307. uint32_t requested_buffer_size;
  308. uint32_t unique_id;
  309. };
  310. /**
  311. * struct mpt2_diag_unregister - application unregister with driver
  312. * @hdr - generic header
  313. * @unique_id - tag uniquely identifies the buffer to be unregistered
  314. *
  315. * This will allow the driver to cleanup any memory allocated for diag
  316. * messages and to free up any resources.
  317. */
  318. struct mpt2_diag_unregister {
  319. struct mpt2_ioctl_header hdr;
  320. uint32_t unique_id;
  321. };
  322. /**
  323. * struct mpt2_diag_query - query relevant info associated with diag buffers
  324. * @hdr - generic header
  325. * @reserved -
  326. * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED
  327. * @application_flags - misc flags
  328. * @diagnostic_flags - specifies flags affecting command processing
  329. * @product_specific - product specific information
  330. * @total_buffer_size - diag buffer size in bytes
  331. * @driver_added_buffer_size - size of extra space appended to end of buffer
  332. * @unique_id - unique id associated with this buffer.
  333. *
  334. * The application will send only buffer_type and unique_id. Driver will
  335. * inspect unique_id first, if valid, fill in all the info. If unique_id is
  336. * 0x00, the driver will return info specified by Buffer Type.
  337. */
  338. struct mpt2_diag_query {
  339. struct mpt2_ioctl_header hdr;
  340. uint8_t reserved;
  341. uint8_t buffer_type;
  342. uint16_t application_flags;
  343. uint32_t diagnostic_flags;
  344. uint32_t product_specific[MPT2_PRODUCT_SPECIFIC_DWORDS];
  345. uint32_t total_buffer_size;
  346. uint32_t driver_added_buffer_size;
  347. uint32_t unique_id;
  348. };
  349. /**
  350. * struct mpt2_diag_release - request to send Diag Release Message to firmware
  351. * @hdr - generic header
  352. * @unique_id - tag uniquely identifies the buffer to be released
  353. *
  354. * This allows ownership of the specified buffer to returned to the driver,
  355. * allowing an application to read the buffer without fear that firmware is
  356. * overwritting information in the buffer.
  357. */
  358. struct mpt2_diag_release {
  359. struct mpt2_ioctl_header hdr;
  360. uint32_t unique_id;
  361. };
  362. /**
  363. * struct mpt2_diag_read_buffer - request for copy of the diag buffer
  364. * @hdr - generic header
  365. * @status -
  366. * @reserved -
  367. * @flags - misc flags
  368. * @starting_offset - starting offset within drivers buffer where to start
  369. * reading data at into the specified application buffer
  370. * @bytes_to_read - number of bytes to copy from the drivers buffer into the
  371. * application buffer starting at starting_offset.
  372. * @unique_id - unique id associated with this buffer.
  373. * @diagnostic_data - data payload
  374. */
  375. struct mpt2_diag_read_buffer {
  376. struct mpt2_ioctl_header hdr;
  377. uint8_t status;
  378. uint8_t reserved;
  379. uint16_t flags;
  380. uint32_t starting_offset;
  381. uint32_t bytes_to_read;
  382. uint32_t unique_id;
  383. uint32_t diagnostic_data[1];
  384. };
  385. #endif /* MPT2SAS_CTL_H_INCLUDED */