mpt2sas_ctl.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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-2008 LSI Corporation
  7. * (mailto:DL-MPTFusionLinux@lsi.com)
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * NO WARRANTY
  20. * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
  21. * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
  22. * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
  23. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
  24. * solely responsible for determining the appropriateness of using and
  25. * distributing the Program and assumes all risks associated with its
  26. * exercise of rights under this Agreement, including but not limited to
  27. * the risks and costs of program errors, damage to or loss of data,
  28. * programs or equipment, and unavailability or interruption of operations.
  29. * DISCLAIMER OF LIABILITY
  30. * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
  31. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  32. * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
  33. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  34. * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  35. * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
  36. * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
  37. * You should have received a copy of the GNU General Public License
  38. * along with this program; if not, write to the Free Software
  39. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  40. * USA.
  41. */
  42. #ifndef MPT2SAS_CTL_H_INCLUDED
  43. #define MPT2SAS_CTL_H_INCLUDED
  44. #ifdef __KERNEL__
  45. #include <linux/miscdevice.h>
  46. #endif
  47. #define MPT2SAS_DEV_NAME "mpt2ctl"
  48. #define MPT2_MAGIC_NUMBER 'L'
  49. #define MPT2_IOCTL_DEFAULT_TIMEOUT (10) /* in seconds */
  50. /**
  51. * IOCTL opcodes
  52. */
  53. #define MPT2IOCINFO _IOWR(MPT2_MAGIC_NUMBER, 17, \
  54. struct mpt2_ioctl_iocinfo)
  55. #define MPT2COMMAND _IOWR(MPT2_MAGIC_NUMBER, 20, \
  56. struct mpt2_ioctl_command)
  57. #ifdef CONFIG_COMPAT
  58. #define MPT2COMMAND32 _IOWR(MPT2_MAGIC_NUMBER, 20, \
  59. struct mpt2_ioctl_command32)
  60. #endif
  61. #define MPT2EVENTQUERY _IOWR(MPT2_MAGIC_NUMBER, 21, \
  62. struct mpt2_ioctl_eventquery)
  63. #define MPT2EVENTENABLE _IOWR(MPT2_MAGIC_NUMBER, 22, \
  64. struct mpt2_ioctl_eventenable)
  65. #define MPT2EVENTREPORT _IOWR(MPT2_MAGIC_NUMBER, 23, \
  66. struct mpt2_ioctl_eventreport)
  67. #define MPT2HARDRESET _IOWR(MPT2_MAGIC_NUMBER, 24, \
  68. struct mpt2_ioctl_diag_reset)
  69. #define MPT2BTDHMAPPING _IOWR(MPT2_MAGIC_NUMBER, 31, \
  70. struct mpt2_ioctl_btdh_mapping)
  71. /* diag buffer support */
  72. #define MPT2DIAGREGISTER _IOWR(MPT2_MAGIC_NUMBER, 26, \
  73. struct mpt2_diag_register)
  74. #define MPT2DIAGRELEASE _IOWR(MPT2_MAGIC_NUMBER, 27, \
  75. struct mpt2_diag_release)
  76. #define MPT2DIAGUNREGISTER _IOWR(MPT2_MAGIC_NUMBER, 28, \
  77. struct mpt2_diag_unregister)
  78. #define MPT2DIAGQUERY _IOWR(MPT2_MAGIC_NUMBER, 29, \
  79. struct mpt2_diag_query)
  80. #define MPT2DIAGREADBUFFER _IOWR(MPT2_MAGIC_NUMBER, 30, \
  81. struct mpt2_diag_read_buffer)
  82. /**
  83. * struct mpt2_ioctl_header - main header structure
  84. * @ioc_number - IOC unit number
  85. * @port_number - IOC port number
  86. * @max_data_size - maximum number bytes to transfer on read
  87. */
  88. struct mpt2_ioctl_header {
  89. uint32_t ioc_number;
  90. uint32_t port_number;
  91. uint32_t max_data_size;
  92. };
  93. /**
  94. * struct mpt2_ioctl_diag_reset - diagnostic reset
  95. * @hdr - generic header
  96. */
  97. struct mpt2_ioctl_diag_reset {
  98. struct mpt2_ioctl_header hdr;
  99. };
  100. /**
  101. * struct mpt2_ioctl_pci_info - pci device info
  102. * @device - pci device id
  103. * @function - pci function id
  104. * @bus - pci bus id
  105. * @segment_id - pci segment id
  106. */
  107. struct mpt2_ioctl_pci_info {
  108. union {
  109. struct {
  110. uint32_t device:5;
  111. uint32_t function:3;
  112. uint32_t bus:24;
  113. } bits;
  114. uint32_t word;
  115. } u;
  116. uint32_t segment_id;
  117. };
  118. #define MPT2_IOCTL_INTERFACE_SCSI (0x00)
  119. #define MPT2_IOCTL_INTERFACE_FC (0x01)
  120. #define MPT2_IOCTL_INTERFACE_FC_IP (0x02)
  121. #define MPT2_IOCTL_INTERFACE_SAS (0x03)
  122. #define MPT2_IOCTL_INTERFACE_SAS2 (0x04)
  123. #define MPT2_IOCTL_VERSION_LENGTH (32)
  124. /**
  125. * struct mpt2_ioctl_iocinfo - generic controller info
  126. * @hdr - generic header
  127. * @adapter_type - type of adapter (spi, fc, sas)
  128. * @port_number - port number
  129. * @pci_id - PCI Id
  130. * @hw_rev - hardware revision
  131. * @sub_system_device - PCI subsystem Device ID
  132. * @sub_system_vendor - PCI subsystem Vendor ID
  133. * @rsvd0 - reserved
  134. * @firmware_version - firmware version
  135. * @bios_version - BIOS version
  136. * @driver_version - driver version - 32 ASCII characters
  137. * @rsvd1 - reserved
  138. * @scsi_id - scsi id of adapter 0
  139. * @rsvd2 - reserved
  140. * @pci_information - pci info (2nd revision)
  141. */
  142. struct mpt2_ioctl_iocinfo {
  143. struct mpt2_ioctl_header hdr;
  144. uint32_t adapter_type;
  145. uint32_t port_number;
  146. uint32_t pci_id;
  147. uint32_t hw_rev;
  148. uint32_t subsystem_device;
  149. uint32_t subsystem_vendor;
  150. uint32_t rsvd0;
  151. uint32_t firmware_version;
  152. uint32_t bios_version;
  153. uint8_t driver_version[MPT2_IOCTL_VERSION_LENGTH];
  154. uint8_t rsvd1;
  155. uint8_t scsi_id;
  156. uint16_t rsvd2;
  157. struct mpt2_ioctl_pci_info pci_information;
  158. };
  159. /* number of event log entries */
  160. #define MPT2SAS_CTL_EVENT_LOG_SIZE (50)
  161. /**
  162. * struct mpt2_ioctl_eventquery - query event count and type
  163. * @hdr - generic header
  164. * @event_entries - number of events returned by get_event_report
  165. * @rsvd - reserved
  166. * @event_types - type of events currently being captured
  167. */
  168. struct mpt2_ioctl_eventquery {
  169. struct mpt2_ioctl_header hdr;
  170. uint16_t event_entries;
  171. uint16_t rsvd;
  172. uint32_t event_types[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS];
  173. };
  174. /**
  175. * struct mpt2_ioctl_eventenable - enable/disable event capturing
  176. * @hdr - generic header
  177. * @event_types - toggle off/on type of events to be captured
  178. */
  179. struct mpt2_ioctl_eventenable {
  180. struct mpt2_ioctl_header hdr;
  181. uint32_t event_types[4];
  182. };
  183. #define MPT2_EVENT_DATA_SIZE (192)
  184. /**
  185. * struct MPT2_IOCTL_EVENTS -
  186. * @event - the event that was reported
  187. * @context - unique value for each event assigned by driver
  188. * @data - event data returned in fw reply message
  189. */
  190. struct MPT2_IOCTL_EVENTS {
  191. uint32_t event;
  192. uint32_t context;
  193. uint8_t data[MPT2_EVENT_DATA_SIZE];
  194. };
  195. /**
  196. * struct mpt2_ioctl_eventreport - returing event log
  197. * @hdr - generic header
  198. * @event_data - (see struct MPT2_IOCTL_EVENTS)
  199. */
  200. struct mpt2_ioctl_eventreport {
  201. struct mpt2_ioctl_header hdr;
  202. struct MPT2_IOCTL_EVENTS event_data[1];
  203. };
  204. /**
  205. * struct mpt2_ioctl_command - generic mpt firmware passthru ioclt
  206. * @hdr - generic header
  207. * @timeout - command timeout in seconds. (if zero then use driver default
  208. * value).
  209. * @reply_frame_buf_ptr - reply location
  210. * @data_in_buf_ptr - destination for read
  211. * @data_out_buf_ptr - data source for write
  212. * @sense_data_ptr - sense data location
  213. * @max_reply_bytes - maximum number of reply bytes to be sent to app.
  214. * @data_in_size - number bytes for data transfer in (read)
  215. * @data_out_size - number bytes for data transfer out (write)
  216. * @max_sense_bytes - maximum number of bytes for auto sense buffers
  217. * @data_sge_offset - offset in words from the start of the request message to
  218. * the first SGL
  219. * @mf[1];
  220. */
  221. struct mpt2_ioctl_command {
  222. struct mpt2_ioctl_header hdr;
  223. uint32_t timeout;
  224. void __user *reply_frame_buf_ptr;
  225. void __user *data_in_buf_ptr;
  226. void __user *data_out_buf_ptr;
  227. void __user *sense_data_ptr;
  228. uint32_t max_reply_bytes;
  229. uint32_t data_in_size;
  230. uint32_t data_out_size;
  231. uint32_t max_sense_bytes;
  232. uint32_t data_sge_offset;
  233. uint8_t mf[1];
  234. };
  235. #ifdef CONFIG_COMPAT
  236. struct mpt2_ioctl_command32 {
  237. struct mpt2_ioctl_header hdr;
  238. uint32_t timeout;
  239. uint32_t reply_frame_buf_ptr;
  240. uint32_t data_in_buf_ptr;
  241. uint32_t data_out_buf_ptr;
  242. uint32_t sense_data_ptr;
  243. uint32_t max_reply_bytes;
  244. uint32_t data_in_size;
  245. uint32_t data_out_size;
  246. uint32_t max_sense_bytes;
  247. uint32_t data_sge_offset;
  248. uint8_t mf[1];
  249. };
  250. #endif
  251. /**
  252. * struct mpt2_ioctl_btdh_mapping - mapping info
  253. * @hdr - generic header
  254. * @id - target device identification number
  255. * @bus - SCSI bus number that the target device exists on
  256. * @handle - device handle for the target device
  257. * @rsvd - reserved
  258. *
  259. * To obtain a bus/id the application sets
  260. * handle to valid handle, and bus/id to 0xFFFF.
  261. *
  262. * To obtain the device handle the application sets
  263. * bus/id valid value, and the handle to 0xFFFF.
  264. */
  265. struct mpt2_ioctl_btdh_mapping {
  266. struct mpt2_ioctl_header hdr;
  267. uint32_t id;
  268. uint32_t bus;
  269. uint16_t handle;
  270. uint16_t rsvd;
  271. };
  272. /* status bits for ioc->diag_buffer_status */
  273. #define MPT2_DIAG_BUFFER_IS_REGISTERED (0x01)
  274. #define MPT2_DIAG_BUFFER_IS_RELEASED (0x02)
  275. /* application flags for mpt2_diag_register, mpt2_diag_query */
  276. #define MPT2_APP_FLAGS_APP_OWNED (0x0001)
  277. #define MPT2_APP_FLAGS_BUFFER_VALID (0x0002)
  278. #define MPT2_APP_FLAGS_FW_BUFFER_ACCESS (0x0004)
  279. /* flags for mpt2_diag_read_buffer */
  280. #define MPT2_FLAGS_REREGISTER (0x0001)
  281. #define MPT2_PRODUCT_SPECIFIC_DWORDS 23
  282. /**
  283. * struct mpt2_diag_register - application register with driver
  284. * @hdr - generic header
  285. * @reserved -
  286. * @buffer_type - specifies either TRACE or SNAPSHOT
  287. * @application_flags - misc flags
  288. * @diagnostic_flags - specifies flags affecting command processing
  289. * @product_specific - product specific information
  290. * @requested_buffer_size - buffers size in bytes
  291. * @unique_id - tag specified by application that is used to signal ownership
  292. * of the buffer.
  293. *
  294. * This will allow the driver to setup any required buffers that will be
  295. * needed by firmware to communicate with the driver.
  296. */
  297. struct mpt2_diag_register {
  298. struct mpt2_ioctl_header hdr;
  299. uint8_t reserved;
  300. uint8_t buffer_type;
  301. uint16_t application_flags;
  302. uint32_t diagnostic_flags;
  303. uint32_t product_specific[MPT2_PRODUCT_SPECIFIC_DWORDS];
  304. uint32_t requested_buffer_size;
  305. uint32_t unique_id;
  306. };
  307. /**
  308. * struct mpt2_diag_unregister - application unregister with driver
  309. * @hdr - generic header
  310. * @unique_id - tag uniquely identifies the buffer to be unregistered
  311. *
  312. * This will allow the driver to cleanup any memory allocated for diag
  313. * messages and to free up any resources.
  314. */
  315. struct mpt2_diag_unregister {
  316. struct mpt2_ioctl_header hdr;
  317. uint32_t unique_id;
  318. };
  319. /**
  320. * struct mpt2_diag_query - query relevant info associated with diag buffers
  321. * @hdr - generic header
  322. * @reserved -
  323. * @buffer_type - specifies either TRACE or SNAPSHOT
  324. * @application_flags - misc flags
  325. * @diagnostic_flags - specifies flags affecting command processing
  326. * @product_specific - product specific information
  327. * @total_buffer_size - diag buffer size in bytes
  328. * @driver_added_buffer_size - size of extra space appended to end of buffer
  329. * @unique_id - unique id associated with this buffer.
  330. *
  331. * The application will send only buffer_type and unique_id. Driver will
  332. * inspect unique_id first, if valid, fill in all the info. If unique_id is
  333. * 0x00, the driver will return info specified by Buffer Type.
  334. */
  335. struct mpt2_diag_query {
  336. struct mpt2_ioctl_header hdr;
  337. uint8_t reserved;
  338. uint8_t buffer_type;
  339. uint16_t application_flags;
  340. uint32_t diagnostic_flags;
  341. uint32_t product_specific[MPT2_PRODUCT_SPECIFIC_DWORDS];
  342. uint32_t total_buffer_size;
  343. uint32_t driver_added_buffer_size;
  344. uint32_t unique_id;
  345. };
  346. /**
  347. * struct mpt2_diag_release - request to send Diag Release Message to firmware
  348. * @hdr - generic header
  349. * @unique_id - tag uniquely identifies the buffer to be released
  350. *
  351. * This allows ownership of the specified buffer to returned to the driver,
  352. * allowing an application to read the buffer without fear that firmware is
  353. * overwritting information in the buffer.
  354. */
  355. struct mpt2_diag_release {
  356. struct mpt2_ioctl_header hdr;
  357. uint32_t unique_id;
  358. };
  359. /**
  360. * struct mpt2_diag_read_buffer - request for copy of the diag buffer
  361. * @hdr - generic header
  362. * @status -
  363. * @reserved -
  364. * @flags - misc flags
  365. * @starting_offset - starting offset within drivers buffer where to start
  366. * reading data at into the specified application buffer
  367. * @bytes_to_read - number of bytes to copy from the drivers buffer into the
  368. * application buffer starting at starting_offset.
  369. * @unique_id - unique id associated with this buffer.
  370. * @diagnostic_data - data payload
  371. */
  372. struct mpt2_diag_read_buffer {
  373. struct mpt2_ioctl_header hdr;
  374. uint8_t status;
  375. uint8_t reserved;
  376. uint16_t flags;
  377. uint32_t starting_offset;
  378. uint32_t bytes_to_read;
  379. uint32_t unique_id;
  380. uint32_t diagnostic_data[1];
  381. };
  382. #endif /* MPT2SAS_CTL_H_INCLUDED */