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