2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 2008 Yahoo!, Inc.
6 * Written by: John Baldwin <jhb@FreeBSD.org>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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.
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
32 * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD userland interface
35 * Copyright (c) 2011-2015 LSI Corp.
36 * Copyright (c) 2013-2015 Avago Technologies
37 * All rights reserved.
39 * Redistribution and use in source and binary forms, with or without
40 * modification, are permitted provided that the following conditions
42 * 1. Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer.
44 * 2. Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in the
46 * documentation and/or other materials provided with the distribution.
48 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
66 #include <dev/mps/mpi/mpi2_type.h>
67 #include <dev/mps/mpi/mpi2.h>
68 #include <dev/mps/mpi/mpi2_cnfg.h>
69 #include <dev/mps/mpi/mpi2_sas.h>
72 * For the read header requests, the header should include the page
73 * type or extended page type, page number, and page version. The
74 * buffer and length are unused. The completed header is returned in
75 * the 'header' member.
77 * For the read page and write page requests, 'buf' should point to a
78 * buffer of 'len' bytes which holds the entire page (including the
81 * All requests specify the page address in 'page_address'.
83 struct mps_cfg_page_req {
84 MPI2_CONFIG_PAGE_HEADER header;
85 uint32_t page_address;
91 struct mps_ext_cfg_page_req {
92 MPI2_CONFIG_EXTENDED_PAGE_HEADER header;
93 uint32_t page_address;
99 struct mps_raid_action {
103 uint8_t phys_disk_num;
104 uint32_t action_data_word;
107 uint32_t volume_status;
108 uint32_t action_data[4];
109 uint16_t action_status;
114 struct mps_usr_command {
124 typedef struct mps_pci_bits
128 uint32_t DeviceNumber :5;
129 uint32_t FunctionNumber :3;
130 uint32_t BusNumber :24;
134 uint32_t PciSegmentId;
138 * The following is the MPSIOCTL_GET_ADAPTER_DATA data structure. This data
139 * structure is setup so that we hopefully are properly aligned for both
140 * 32-bit and 64-bit mode applications.
142 * Adapter Type - Value = 4 = SCSI Protocol through SAS-2 adapter
144 * MPI Port Number - The PCI Function number for this device
146 * PCI Device HW Id - The PCI device number for this device
149 #define MPSIOCTL_ADAPTER_TYPE_SAS2 4
150 #define MPSIOCTL_ADAPTER_TYPE_SAS2_SSS6200 5
151 typedef struct mps_adapter_data
153 uint32_t StructureLength;
154 uint32_t AdapterType;
155 uint32_t MpiPortNumber;
156 uint32_t PCIDeviceHwId;
157 uint32_t PCIDeviceHwRev;
158 uint32_t SubSystemId;
159 uint32_t SubsystemVendorId;
161 uint32_t MpiFirmwareVersion;
162 uint32_t BiosVersion;
163 uint8_t DriverVersion[32];
167 mps_pci_bits_t PciInformation;
168 } mps_adapter_data_t;
170 typedef struct mps_update_flash
173 uint32_t ImageChecksum;
174 uint32_t ImageOffset;
177 } mps_update_flash_t;
179 #define MPS_PASS_THRU_DIRECTION_NONE 0
180 #define MPS_PASS_THRU_DIRECTION_READ 1
181 #define MPS_PASS_THRU_DIRECTION_WRITE 2
182 #define MPS_PASS_THRU_DIRECTION_BOTH 3
184 typedef struct mps_pass_thru
189 uint32_t RequestSize;
192 uint32_t DataDirection;
194 uint32_t DataOutSize;
199 * Event queue defines
201 #define MPS_EVENT_QUEUE_SIZE (50) /* Max Events stored in driver */
202 #define MPS_MAX_EVENT_DATA_LENGTH (48) /* Size of each event in Dwords */
204 typedef struct mps_event_query
211 typedef struct mps_event_enable
214 } mps_event_enable_t;
217 * Event record entry for ioctl.
219 typedef struct mps_event_entry
223 uint32_t Data[MPS_MAX_EVENT_DATA_LENGTH];
226 typedef struct mps_event_report
230 } mps_event_report_t;
232 typedef struct mps_pci_info
235 uint8_t DeviceNumber;
236 uint8_t FunctionNumber;
237 uint16_t InterruptVector;
238 uint8_t PciHeader[256];
241 typedef struct mps_diag_action
245 uint64_t PtrDiagAction;
249 #define MPS_FW_DIAGNOSTIC_UID_NOT_FOUND (0xFF)
251 #define MPS_FW_DIAG_NEW (0x806E6577)
253 #define MPS_FW_DIAG_TYPE_REGISTER (0x00000001)
254 #define MPS_FW_DIAG_TYPE_UNREGISTER (0x00000002)
255 #define MPS_FW_DIAG_TYPE_QUERY (0x00000003)
256 #define MPS_FW_DIAG_TYPE_READ_BUFFER (0x00000004)
257 #define MPS_FW_DIAG_TYPE_RELEASE (0x00000005)
259 #define MPS_FW_DIAG_INVALID_UID (0x00000000)
261 #define MPS_DIAG_SUCCESS 0
262 #define MPS_DIAG_FAILURE 1
264 #define MPS_FW_DIAG_ERROR_SUCCESS (0x00000000)
265 #define MPS_FW_DIAG_ERROR_FAILURE (0x00000001)
266 #define MPS_FW_DIAG_ERROR_INVALID_PARAMETER (0x00000002)
267 #define MPS_FW_DIAG_ERROR_POST_FAILED (0x00000010)
268 #define MPS_FW_DIAG_ERROR_INVALID_UID (0x00000011)
269 #define MPS_FW_DIAG_ERROR_RELEASE_FAILED (0x00000012)
270 #define MPS_FW_DIAG_ERROR_NO_BUFFER (0x00000013)
271 #define MPS_FW_DIAG_ERROR_ALREADY_RELEASED (0x00000014)
273 typedef struct mps_fw_diag_register
275 uint8_t ExtendedType;
277 uint16_t ApplicationFlags;
278 uint32_t DiagnosticFlags;
279 uint32_t ProductSpecific[23];
280 uint32_t RequestedBufferSize;
282 } mps_fw_diag_register_t;
284 typedef struct mps_fw_diag_unregister
287 } mps_fw_diag_unregister_t;
289 #define MPS_FW_DIAG_FLAG_APP_OWNED (0x0001)
290 #define MPS_FW_DIAG_FLAG_BUFFER_VALID (0x0002)
291 #define MPS_FW_DIAG_FLAG_FW_BUFFER_ACCESS (0x0004)
293 typedef struct mps_fw_diag_query
295 uint8_t ExtendedType;
297 uint16_t ApplicationFlags;
298 uint32_t DiagnosticFlags;
299 uint32_t ProductSpecific[23];
300 uint32_t TotalBufferSize;
301 uint32_t DriverAddedBufferSize;
303 } mps_fw_diag_query_t;
305 typedef struct mps_fw_diag_release
308 } mps_fw_diag_release_t;
310 #define MPS_FW_DIAG_FLAG_REREGISTER (0x0001)
311 #define MPS_FW_DIAG_FLAG_FORCE_RELEASE (0x0002)
313 typedef struct mps_diag_read_buffer
318 uint32_t StartingOffset;
319 uint32_t BytesToRead;
321 uint64_t PtrDataBuffer;
322 } mps_diag_read_buffer_t;
327 #define REG_IO_READ 1
328 #define REG_IO_WRITE 2
329 #define REG_MEM_READ 3
330 #define REG_MEM_WRITE 4
332 typedef struct mps_reg_access
339 typedef struct mps_btdh_mapping
345 } mps_btdh_mapping_t;
347 #define MPSIO_MPS_COMMAND_FLAG_VERBOSE 0x01
348 #define MPSIO_MPS_COMMAND_FLAG_DEBUG 0x02
349 #define MPSIO_READ_CFG_HEADER _IOWR('M', 200, struct mps_cfg_page_req)
350 #define MPSIO_READ_CFG_PAGE _IOWR('M', 201, struct mps_cfg_page_req)
351 #define MPSIO_READ_EXT_CFG_HEADER _IOWR('M', 202, struct mps_ext_cfg_page_req)
352 #define MPSIO_READ_EXT_CFG_PAGE _IOWR('M', 203, struct mps_ext_cfg_page_req)
353 #define MPSIO_WRITE_CFG_PAGE _IOWR('M', 204, struct mps_cfg_page_req)
354 #define MPSIO_RAID_ACTION _IOWR('M', 205, struct mps_raid_action)
355 #define MPSIO_MPS_COMMAND _IOWR('M', 210, struct mps_usr_command)
358 #define MPTIOCTL ('I')
359 #define MPTIOCTL_GET_ADAPTER_DATA _IOWR(MPTIOCTL, 1,\
360 struct mps_adapter_data)
361 #define MPTIOCTL_UPDATE_FLASH _IOWR(MPTIOCTL, 2,\
362 struct mps_update_flash)
363 #define MPTIOCTL_RESET_ADAPTER _IO(MPTIOCTL, 3)
364 #define MPTIOCTL_PASS_THRU _IOWR(MPTIOCTL, 4,\
365 struct mps_pass_thru)
366 #define MPTIOCTL_EVENT_QUERY _IOWR(MPTIOCTL, 5,\
367 struct mps_event_query)
368 #define MPTIOCTL_EVENT_ENABLE _IOWR(MPTIOCTL, 6,\
369 struct mps_event_enable)
370 #define MPTIOCTL_EVENT_REPORT _IOWR(MPTIOCTL, 7,\
371 struct mps_event_report)
372 #define MPTIOCTL_GET_PCI_INFO _IOWR(MPTIOCTL, 8,\
374 #define MPTIOCTL_DIAG_ACTION _IOWR(MPTIOCTL, 9,\
375 struct mps_diag_action)
376 #define MPTIOCTL_REG_ACCESS _IOWR(MPTIOCTL, 10,\
377 struct mps_reg_access)
378 #define MPTIOCTL_BTDH_MAPPING _IOWR(MPTIOCTL, 11,\
379 struct mps_btdh_mapping)
380 #endif /* MPTIOCTL */
382 #endif /* !_MPS_IOCTL_H_ */