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