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