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 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 MPT2_IOCTL_INTERFACE_SAS2_SSS6200 (0x05) 145 #define MPT3_IOCTL_INTERFACE_SAS3 (0x06) 146 #define MPT3_IOCTL_INTERFACE_SAS35 (0x07) 147 #define MPT2_IOCTL_VERSION_LENGTH (32) 148 149 /** 150 * struct mpt3_ioctl_iocinfo - generic controller info 151 * @hdr - generic header 152 * @adapter_type - type of adapter (spi, fc, sas) 153 * @port_number - port number 154 * @pci_id - PCI Id 155 * @hw_rev - hardware revision 156 * @sub_system_device - PCI subsystem Device ID 157 * @sub_system_vendor - PCI subsystem Vendor ID 158 * @rsvd0 - reserved 159 * @firmware_version - firmware version 160 * @bios_version - BIOS version 161 * @driver_version - driver version - 32 ASCII characters 162 * @rsvd1 - reserved 163 * @scsi_id - scsi id of adapter 0 164 * @rsvd2 - reserved 165 * @pci_information - pci info (2nd revision) 166 */ 167 struct mpt3_ioctl_iocinfo { 168 struct mpt3_ioctl_header hdr; 169 uint32_t adapter_type; 170 uint32_t port_number; 171 uint32_t pci_id; 172 uint32_t hw_rev; 173 uint32_t subsystem_device; 174 uint32_t subsystem_vendor; 175 uint32_t rsvd0; 176 uint32_t firmware_version; 177 uint32_t bios_version; 178 uint8_t driver_version[MPT2_IOCTL_VERSION_LENGTH]; 179 uint8_t rsvd1; 180 uint8_t scsi_id; 181 uint16_t rsvd2; 182 struct mpt3_ioctl_pci_info pci_information; 183 }; 184 185 186 /* number of event log entries */ 187 #define MPT3SAS_CTL_EVENT_LOG_SIZE (200) 188 189 /** 190 * struct mpt3_ioctl_eventquery - query event count and type 191 * @hdr - generic header 192 * @event_entries - number of events returned by get_event_report 193 * @rsvd - reserved 194 * @event_types - type of events currently being captured 195 */ 196 struct mpt3_ioctl_eventquery { 197 struct mpt3_ioctl_header hdr; 198 uint16_t event_entries; 199 uint16_t rsvd; 200 uint32_t event_types[MPI2_EVENT_NOTIFY_EVENTMASK_WORDS]; 201 }; 202 203 /** 204 * struct mpt3_ioctl_eventenable - enable/disable event capturing 205 * @hdr - generic header 206 * @event_types - toggle off/on type of events to be captured 207 */ 208 struct mpt3_ioctl_eventenable { 209 struct mpt3_ioctl_header hdr; 210 uint32_t event_types[4]; 211 }; 212 213 #define MPT3_EVENT_DATA_SIZE (192) 214 /** 215 * struct MPT3_IOCTL_EVENTS - 216 * @event - the event that was reported 217 * @context - unique value for each event assigned by driver 218 * @data - event data returned in fw reply message 219 */ 220 struct MPT3_IOCTL_EVENTS { 221 uint32_t event; 222 uint32_t context; 223 uint8_t data[MPT3_EVENT_DATA_SIZE]; 224 }; 225 226 /** 227 * struct mpt3_ioctl_eventreport - returing event log 228 * @hdr - generic header 229 * @event_data - (see struct MPT3_IOCTL_EVENTS) 230 */ 231 struct mpt3_ioctl_eventreport { 232 struct mpt3_ioctl_header hdr; 233 struct MPT3_IOCTL_EVENTS event_data[1]; 234 }; 235 236 /** 237 * struct mpt3_ioctl_command - generic mpt firmware passthru ioctl 238 * @hdr - generic header 239 * @timeout - command timeout in seconds. (if zero then use driver default 240 * value). 241 * @reply_frame_buf_ptr - reply location 242 * @data_in_buf_ptr - destination for read 243 * @data_out_buf_ptr - data source for write 244 * @sense_data_ptr - sense data location 245 * @max_reply_bytes - maximum number of reply bytes to be sent to app. 246 * @data_in_size - number bytes for data transfer in (read) 247 * @data_out_size - number bytes for data transfer out (write) 248 * @max_sense_bytes - maximum number of bytes for auto sense buffers 249 * @data_sge_offset - offset in words from the start of the request message to 250 * the first SGL 251 * @mf[1]; 252 */ 253 struct mpt3_ioctl_command { 254 struct mpt3_ioctl_header hdr; 255 uint32_t timeout; 256 void __user *reply_frame_buf_ptr; 257 void __user *data_in_buf_ptr; 258 void __user *data_out_buf_ptr; 259 void __user *sense_data_ptr; 260 uint32_t max_reply_bytes; 261 uint32_t data_in_size; 262 uint32_t data_out_size; 263 uint32_t max_sense_bytes; 264 uint32_t data_sge_offset; 265 uint8_t mf[1]; 266 }; 267 268 #ifdef CONFIG_COMPAT 269 struct mpt3_ioctl_command32 { 270 struct mpt3_ioctl_header hdr; 271 uint32_t timeout; 272 uint32_t reply_frame_buf_ptr; 273 uint32_t data_in_buf_ptr; 274 uint32_t data_out_buf_ptr; 275 uint32_t sense_data_ptr; 276 uint32_t max_reply_bytes; 277 uint32_t data_in_size; 278 uint32_t data_out_size; 279 uint32_t max_sense_bytes; 280 uint32_t data_sge_offset; 281 uint8_t mf[1]; 282 }; 283 #endif 284 285 /** 286 * struct mpt3_ioctl_btdh_mapping - mapping info 287 * @hdr - generic header 288 * @id - target device identification number 289 * @bus - SCSI bus number that the target device exists on 290 * @handle - device handle for the target device 291 * @rsvd - reserved 292 * 293 * To obtain a bus/id the application sets 294 * handle to valid handle, and bus/id to 0xFFFF. 295 * 296 * To obtain the device handle the application sets 297 * bus/id valid value, and the handle to 0xFFFF. 298 */ 299 struct mpt3_ioctl_btdh_mapping { 300 struct mpt3_ioctl_header hdr; 301 uint32_t id; 302 uint32_t bus; 303 uint16_t handle; 304 uint16_t rsvd; 305 }; 306 307 308 309 /* application flags for mpt3_diag_register, mpt3_diag_query */ 310 #define MPT3_APP_FLAGS_APP_OWNED (0x0001) 311 #define MPT3_APP_FLAGS_BUFFER_VALID (0x0002) 312 #define MPT3_APP_FLAGS_FW_BUFFER_ACCESS (0x0004) 313 314 /* flags for mpt3_diag_read_buffer */ 315 #define MPT3_FLAGS_REREGISTER (0x0001) 316 317 #define MPT3_PRODUCT_SPECIFIC_DWORDS 23 318 319 /** 320 * struct mpt3_diag_register - application register with driver 321 * @hdr - generic header 322 * @reserved - 323 * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED 324 * @application_flags - misc flags 325 * @diagnostic_flags - specifies flags affecting command processing 326 * @product_specific - product specific information 327 * @requested_buffer_size - buffers size in bytes 328 * @unique_id - tag specified by application that is used to signal ownership 329 * of the buffer. 330 * 331 * This will allow the driver to setup any required buffers that will be 332 * needed by firmware to communicate with the driver. 333 */ 334 struct mpt3_diag_register { 335 struct mpt3_ioctl_header hdr; 336 uint8_t reserved; 337 uint8_t buffer_type; 338 uint16_t application_flags; 339 uint32_t diagnostic_flags; 340 uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS]; 341 uint32_t requested_buffer_size; 342 uint32_t unique_id; 343 }; 344 345 /** 346 * struct mpt3_diag_unregister - application unregister with driver 347 * @hdr - generic header 348 * @unique_id - tag uniquely identifies the buffer to be unregistered 349 * 350 * This will allow the driver to cleanup any memory allocated for diag 351 * messages and to free up any resources. 352 */ 353 struct mpt3_diag_unregister { 354 struct mpt3_ioctl_header hdr; 355 uint32_t unique_id; 356 }; 357 358 /** 359 * struct mpt3_diag_query - query relevant info associated with diag buffers 360 * @hdr - generic header 361 * @reserved - 362 * @buffer_type - specifies either TRACE, SNAPSHOT, or EXTENDED 363 * @application_flags - misc flags 364 * @diagnostic_flags - specifies flags affecting command processing 365 * @product_specific - product specific information 366 * @total_buffer_size - diag buffer size in bytes 367 * @driver_added_buffer_size - size of extra space appended to end of buffer 368 * @unique_id - unique id associated with this buffer. 369 * 370 * The application will send only buffer_type and unique_id. Driver will 371 * inspect unique_id first, if valid, fill in all the info. If unique_id is 372 * 0x00, the driver will return info specified by Buffer Type. 373 */ 374 struct mpt3_diag_query { 375 struct mpt3_ioctl_header hdr; 376 uint8_t reserved; 377 uint8_t buffer_type; 378 uint16_t application_flags; 379 uint32_t diagnostic_flags; 380 uint32_t product_specific[MPT3_PRODUCT_SPECIFIC_DWORDS]; 381 uint32_t total_buffer_size; 382 uint32_t driver_added_buffer_size; 383 uint32_t unique_id; 384 }; 385 386 /** 387 * struct mpt3_diag_release - request to send Diag Release Message to firmware 388 * @hdr - generic header 389 * @unique_id - tag uniquely identifies the buffer to be released 390 * 391 * This allows ownership of the specified buffer to returned to the driver, 392 * allowing an application to read the buffer without fear that firmware is 393 * overwriting information in the buffer. 394 */ 395 struct mpt3_diag_release { 396 struct mpt3_ioctl_header hdr; 397 uint32_t unique_id; 398 }; 399 400 /** 401 * struct mpt3_diag_read_buffer - request for copy of the diag buffer 402 * @hdr - generic header 403 * @status - 404 * @reserved - 405 * @flags - misc flags 406 * @starting_offset - starting offset within drivers buffer where to start 407 * reading data at into the specified application buffer 408 * @bytes_to_read - number of bytes to copy from the drivers buffer into the 409 * application buffer starting at starting_offset. 410 * @unique_id - unique id associated with this buffer. 411 * @diagnostic_data - data payload 412 */ 413 struct mpt3_diag_read_buffer { 414 struct mpt3_ioctl_header hdr; 415 uint8_t status; 416 uint8_t reserved; 417 uint16_t flags; 418 uint32_t starting_offset; 419 uint32_t bytes_to_read; 420 uint32_t unique_id; 421 uint32_t diagnostic_data[1]; 422 }; 423 424 #endif /* MPT3SAS_CTL_H_INCLUDED */ 425