1 /*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 2008 Yahoo!, Inc. 5 * All rights reserved. 6 * Written by: John Baldwin <jhb@FreeBSD.org> 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of the author nor the names of any co-contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD userland interface 33 * 34 * $FreeBSD$ 35 */ 36 /*- 37 * Copyright (c) 2011-2015 LSI Corp. 38 * Copyright (c) 2013-2015 Avago Technologies 39 * All rights reserved. 40 * 41 * Redistribution and use in source and binary forms, with or without 42 * modification, are permitted provided that the following conditions 43 * are met: 44 * 1. Redistributions of source code must retain the above copyright 45 * notice, this list of conditions and the following disclaimer. 46 * 2. Redistributions in binary form must reproduce the above copyright 47 * notice, this list of conditions and the following disclaimer in the 48 * documentation and/or other materials provided with the distribution. 49 * 50 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 53 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 60 * SUCH DAMAGE. 61 * 62 * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD 63 * 64 * $FreeBSD$ 65 */ 66 67 #ifndef _MPS_IOCTL_H_ 68 #define _MPS_IOCTL_H_ 69 70 #include <dev/mps/mpi/mpi2_type.h> 71 #include <dev/mps/mpi/mpi2.h> 72 #include <dev/mps/mpi/mpi2_cnfg.h> 73 #include <dev/mps/mpi/mpi2_sas.h> 74 75 /* 76 * For the read header requests, the header should include the page 77 * type or extended page type, page number, and page version. The 78 * buffer and length are unused. The completed header is returned in 79 * the 'header' member. 80 * 81 * For the read page and write page requests, 'buf' should point to a 82 * buffer of 'len' bytes which holds the entire page (including the 83 * header). 84 * 85 * All requests specify the page address in 'page_address'. 86 */ 87 struct mps_cfg_page_req { 88 MPI2_CONFIG_PAGE_HEADER header; 89 uint32_t page_address; 90 void *buf; 91 int len; 92 uint16_t ioc_status; 93 }; 94 95 struct mps_ext_cfg_page_req { 96 MPI2_CONFIG_EXTENDED_PAGE_HEADER header; 97 uint32_t page_address; 98 void *buf; 99 int len; 100 uint16_t ioc_status; 101 }; 102 103 struct mps_raid_action { 104 uint8_t action; 105 uint8_t volume_bus; 106 uint8_t volume_id; 107 uint8_t phys_disk_num; 108 uint32_t action_data_word; 109 void *buf; 110 int len; 111 uint32_t volume_status; 112 uint32_t action_data[4]; 113 uint16_t action_status; 114 uint16_t ioc_status; 115 uint8_t write; 116 }; 117 118 struct mps_usr_command { 119 void *req; 120 uint32_t req_len; 121 void *rpl; 122 uint32_t rpl_len; 123 void *buf; 124 int len; 125 uint32_t flags; 126 }; 127 128 typedef struct mps_pci_bits 129 { 130 union { 131 struct { 132 uint32_t DeviceNumber :5; 133 uint32_t FunctionNumber :3; 134 uint32_t BusNumber :24; 135 } bits; 136 uint32_t AsDWORD; 137 } u; 138 uint32_t PciSegmentId; 139 } mps_pci_bits_t; 140 141 /* 142 * The following is the MPSIOCTL_GET_ADAPTER_DATA data structure. This data 143 * structure is setup so that we hopefully are properly aligned for both 144 * 32-bit and 64-bit mode applications. 145 * 146 * Adapter Type - Value = 4 = SCSI Protocol through SAS-2 adapter 147 * 148 * MPI Port Number - The PCI Function number for this device 149 * 150 * PCI Device HW Id - The PCI device number for this device 151 * 152 */ 153 #define MPSIOCTL_ADAPTER_TYPE_SAS2 4 154 #define MPSIOCTL_ADAPTER_TYPE_SAS2_SSS6200 5 155 typedef struct mps_adapter_data 156 { 157 uint32_t StructureLength; 158 uint32_t AdapterType; 159 uint32_t MpiPortNumber; 160 uint32_t PCIDeviceHwId; 161 uint32_t PCIDeviceHwRev; 162 uint32_t SubSystemId; 163 uint32_t SubsystemVendorId; 164 uint32_t Reserved1; 165 uint32_t MpiFirmwareVersion; 166 uint32_t BiosVersion; 167 uint8_t DriverVersion[32]; 168 uint8_t Reserved2; 169 uint8_t ScsiId; 170 uint16_t Reserved3; 171 mps_pci_bits_t PciInformation; 172 } mps_adapter_data_t; 173 174 175 typedef struct mps_update_flash 176 { 177 uint64_t PtrBuffer; 178 uint32_t ImageChecksum; 179 uint32_t ImageOffset; 180 uint32_t ImageSize; 181 uint32_t ImageType; 182 } mps_update_flash_t; 183 184 185 #define MPS_PASS_THRU_DIRECTION_NONE 0 186 #define MPS_PASS_THRU_DIRECTION_READ 1 187 #define MPS_PASS_THRU_DIRECTION_WRITE 2 188 #define MPS_PASS_THRU_DIRECTION_BOTH 3 189 190 typedef struct mps_pass_thru 191 { 192 uint64_t PtrRequest; 193 uint64_t PtrReply; 194 uint64_t PtrData; 195 uint32_t RequestSize; 196 uint32_t ReplySize; 197 uint32_t DataSize; 198 uint32_t DataDirection; 199 uint64_t PtrDataOut; 200 uint32_t DataOutSize; 201 uint32_t Timeout; 202 } mps_pass_thru_t; 203 204 205 /* 206 * Event queue defines 207 */ 208 #define MPS_EVENT_QUEUE_SIZE (50) /* Max Events stored in driver */ 209 #define MPS_MAX_EVENT_DATA_LENGTH (48) /* Size of each event in Dwords */ 210 211 typedef struct mps_event_query 212 { 213 uint16_t Entries; 214 uint16_t Reserved; 215 uint32_t Types[4]; 216 } mps_event_query_t; 217 218 typedef struct mps_event_enable 219 { 220 uint32_t Types[4]; 221 } mps_event_enable_t; 222 223 /* 224 * Event record entry for ioctl. 225 */ 226 typedef struct mps_event_entry 227 { 228 uint32_t Type; 229 uint32_t Number; 230 uint32_t Data[MPS_MAX_EVENT_DATA_LENGTH]; 231 } mps_event_entry_t; 232 233 typedef struct mps_event_report 234 { 235 uint32_t Size; 236 uint64_t PtrEvents; 237 } mps_event_report_t; 238 239 240 typedef struct mps_pci_info 241 { 242 uint32_t BusNumber; 243 uint8_t DeviceNumber; 244 uint8_t FunctionNumber; 245 uint16_t InterruptVector; 246 uint8_t PciHeader[256]; 247 } mps_pci_info_t; 248 249 250 typedef struct mps_diag_action 251 { 252 uint32_t Action; 253 uint32_t Length; 254 uint64_t PtrDiagAction; 255 uint32_t ReturnCode; 256 } mps_diag_action_t; 257 258 #define MPS_FW_DIAGNOSTIC_UID_NOT_FOUND (0xFF) 259 260 #define MPS_FW_DIAG_NEW (0x806E6577) 261 262 #define MPS_FW_DIAG_TYPE_REGISTER (0x00000001) 263 #define MPS_FW_DIAG_TYPE_UNREGISTER (0x00000002) 264 #define MPS_FW_DIAG_TYPE_QUERY (0x00000003) 265 #define MPS_FW_DIAG_TYPE_READ_BUFFER (0x00000004) 266 #define MPS_FW_DIAG_TYPE_RELEASE (0x00000005) 267 268 #define MPS_FW_DIAG_INVALID_UID (0x00000000) 269 270 #define MPS_DIAG_SUCCESS 0 271 #define MPS_DIAG_FAILURE 1 272 273 #define MPS_FW_DIAG_ERROR_SUCCESS (0x00000000) 274 #define MPS_FW_DIAG_ERROR_FAILURE (0x00000001) 275 #define MPS_FW_DIAG_ERROR_INVALID_PARAMETER (0x00000002) 276 #define MPS_FW_DIAG_ERROR_POST_FAILED (0x00000010) 277 #define MPS_FW_DIAG_ERROR_INVALID_UID (0x00000011) 278 #define MPS_FW_DIAG_ERROR_RELEASE_FAILED (0x00000012) 279 #define MPS_FW_DIAG_ERROR_NO_BUFFER (0x00000013) 280 #define MPS_FW_DIAG_ERROR_ALREADY_RELEASED (0x00000014) 281 282 283 typedef struct mps_fw_diag_register 284 { 285 uint8_t ExtendedType; 286 uint8_t BufferType; 287 uint16_t ApplicationFlags; 288 uint32_t DiagnosticFlags; 289 uint32_t ProductSpecific[23]; 290 uint32_t RequestedBufferSize; 291 uint32_t UniqueId; 292 } mps_fw_diag_register_t; 293 294 typedef struct mps_fw_diag_unregister 295 { 296 uint32_t UniqueId; 297 } mps_fw_diag_unregister_t; 298 299 #define MPS_FW_DIAG_FLAG_APP_OWNED (0x0001) 300 #define MPS_FW_DIAG_FLAG_BUFFER_VALID (0x0002) 301 #define MPS_FW_DIAG_FLAG_FW_BUFFER_ACCESS (0x0004) 302 303 typedef struct mps_fw_diag_query 304 { 305 uint8_t ExtendedType; 306 uint8_t BufferType; 307 uint16_t ApplicationFlags; 308 uint32_t DiagnosticFlags; 309 uint32_t ProductSpecific[23]; 310 uint32_t TotalBufferSize; 311 uint32_t DriverAddedBufferSize; 312 uint32_t UniqueId; 313 } mps_fw_diag_query_t; 314 315 typedef struct mps_fw_diag_release 316 { 317 uint32_t UniqueId; 318 } mps_fw_diag_release_t; 319 320 #define MPS_FW_DIAG_FLAG_REREGISTER (0x0001) 321 #define MPS_FW_DIAG_FLAG_FORCE_RELEASE (0x0002) 322 323 typedef struct mps_diag_read_buffer 324 { 325 uint8_t Status; 326 uint8_t Reserved; 327 uint16_t Flags; 328 uint32_t StartingOffset; 329 uint32_t BytesToRead; 330 uint32_t UniqueId; 331 uint64_t PtrDataBuffer; 332 } mps_diag_read_buffer_t; 333 334 /* 335 * Register Access 336 */ 337 #define REG_IO_READ 1 338 #define REG_IO_WRITE 2 339 #define REG_MEM_READ 3 340 #define REG_MEM_WRITE 4 341 342 typedef struct mps_reg_access 343 { 344 uint32_t Command; 345 uint32_t RegOffset; 346 uint32_t RegData; 347 } mps_reg_access_t; 348 349 typedef struct mps_btdh_mapping 350 { 351 uint16_t TargetID; 352 uint16_t Bus; 353 uint16_t DevHandle; 354 uint16_t Reserved; 355 } mps_btdh_mapping_t; 356 357 #define MPSIO_MPS_COMMAND_FLAG_VERBOSE 0x01 358 #define MPSIO_MPS_COMMAND_FLAG_DEBUG 0x02 359 #define MPSIO_READ_CFG_HEADER _IOWR('M', 200, struct mps_cfg_page_req) 360 #define MPSIO_READ_CFG_PAGE _IOWR('M', 201, struct mps_cfg_page_req) 361 #define MPSIO_READ_EXT_CFG_HEADER _IOWR('M', 202, struct mps_ext_cfg_page_req) 362 #define MPSIO_READ_EXT_CFG_PAGE _IOWR('M', 203, struct mps_ext_cfg_page_req) 363 #define MPSIO_WRITE_CFG_PAGE _IOWR('M', 204, struct mps_cfg_page_req) 364 #define MPSIO_RAID_ACTION _IOWR('M', 205, struct mps_raid_action) 365 #define MPSIO_MPS_COMMAND _IOWR('M', 210, struct mps_usr_command) 366 367 #ifndef MPTIOCTL 368 #define MPTIOCTL ('I') 369 #define MPTIOCTL_GET_ADAPTER_DATA _IOWR(MPTIOCTL, 1,\ 370 struct mps_adapter_data) 371 #define MPTIOCTL_UPDATE_FLASH _IOWR(MPTIOCTL, 2,\ 372 struct mps_update_flash) 373 #define MPTIOCTL_RESET_ADAPTER _IO(MPTIOCTL, 3) 374 #define MPTIOCTL_PASS_THRU _IOWR(MPTIOCTL, 4,\ 375 struct mps_pass_thru) 376 #define MPTIOCTL_EVENT_QUERY _IOWR(MPTIOCTL, 5,\ 377 struct mps_event_query) 378 #define MPTIOCTL_EVENT_ENABLE _IOWR(MPTIOCTL, 6,\ 379 struct mps_event_enable) 380 #define MPTIOCTL_EVENT_REPORT _IOWR(MPTIOCTL, 7,\ 381 struct mps_event_report) 382 #define MPTIOCTL_GET_PCI_INFO _IOWR(MPTIOCTL, 8,\ 383 struct mps_pci_info) 384 #define MPTIOCTL_DIAG_ACTION _IOWR(MPTIOCTL, 9,\ 385 struct mps_diag_action) 386 #define MPTIOCTL_REG_ACCESS _IOWR(MPTIOCTL, 10,\ 387 struct mps_reg_access) 388 #define MPTIOCTL_BTDH_MAPPING _IOWR(MPTIOCTL, 11,\ 389 struct mps_btdh_mapping) 390 #endif /* MPTIOCTL */ 391 392 #endif /* !_MPS_IOCTL_H_ */ 393