2 * Copyright (c) 2008 Yahoo!, Inc.
4 * Written by: John Baldwin <jhb@FreeBSD.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of the author nor the names of any co-contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * Broadcom Inc. (LSI) MPT-Fusion Host Adapter FreeBSD userland interface
35 * Copyright (c) 2011-2015 LSI Corp.
36 * Copyright (c) 2013-2016 Avago Technologies
37 * Copyright 2000-2020 Broadcom Inc.
38 * All rights reserved.
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
43 * 1. Redistributions of source code must retain the above copyright
44 * notice, this list of conditions and the following disclaimer.
45 * 2. Redistributions in binary form must reproduce the above copyright
46 * notice, this list of conditions and the following disclaimer in the
47 * documentation and/or other materials provided with the distribution.
49 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
50 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
51 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
52 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
61 * Broadcom Inc. (LSI) MPT-Fusion Host Adapter FreeBSD
69 #include <dev/mpr/mpi/mpi2_type.h>
70 #include <dev/mpr/mpi/mpi2.h>
71 #include <dev/mpr/mpi/mpi2_cnfg.h>
72 #include <dev/mpr/mpi/mpi2_sas.h>
75 * For the read header requests, the header should include the page
76 * type or extended page type, page number, and page version. The
77 * buffer and length are unused. The completed header is returned in
78 * the 'header' member.
80 * For the read page and write page requests, 'buf' should point to a
81 * buffer of 'len' bytes which holds the entire page (including the
84 * All requests specify the page address in 'page_address'.
86 struct mpr_cfg_page_req {
87 MPI2_CONFIG_PAGE_HEADER header;
88 uint32_t page_address;
94 struct mpr_ext_cfg_page_req {
95 MPI2_CONFIG_EXTENDED_PAGE_HEADER header;
96 uint32_t page_address;
102 struct mpr_raid_action {
106 uint8_t phys_disk_num;
107 uint32_t action_data_word;
110 uint32_t volume_status;
111 uint32_t action_data[4];
112 uint16_t action_status;
117 struct mpr_usr_command {
127 typedef struct mpr_pci_bits
131 uint32_t DeviceNumber :5;
132 uint32_t FunctionNumber :3;
133 uint32_t BusNumber :24;
137 uint32_t PciSegmentId;
141 * The following is the MPRIOCTL_GET_ADAPTER_DATA data structure. This data
142 * structure is setup so that we hopefully are properly aligned for both
143 * 32-bit and 64-bit mode applications.
145 * Adapter Type - Value = 6 = SCSI Protocol through SAS-3 adapter
147 * MPI Port Number - The PCI Function number for this device
149 * PCI Device HW Id - The PCI device number for this device
152 #define MPRIOCTL_ADAPTER_TYPE_SAS3 6
153 #define MPRIOCTL_ADAPTER_TYPE_SAS35 7
154 typedef struct mpr_adapter_data
156 uint32_t StructureLength;
157 uint32_t AdapterType;
158 uint32_t MpiPortNumber;
159 uint32_t PCIDeviceHwId;
160 uint32_t PCIDeviceHwRev;
161 uint32_t SubSystemId;
162 uint32_t SubsystemVendorId;
164 uint32_t MpiFirmwareVersion;
165 uint32_t BiosVersion;
166 uint8_t DriverVersion[32];
170 mpr_pci_bits_t PciInformation;
171 } mpr_adapter_data_t;
173 typedef struct mpr_update_flash
176 uint32_t ImageChecksum;
177 uint32_t ImageOffset;
180 } mpr_update_flash_t;
182 #define MPR_PASS_THRU_DIRECTION_NONE 0
183 #define MPR_PASS_THRU_DIRECTION_READ 1
184 #define MPR_PASS_THRU_DIRECTION_WRITE 2
185 #define MPR_PASS_THRU_DIRECTION_BOTH 3
187 typedef struct mpr_pass_thru
192 uint32_t RequestSize;
195 uint32_t DataDirection;
197 uint32_t DataOutSize;
202 * Event queue defines
204 #define MPR_EVENT_QUEUE_SIZE (200) /* Max Events stored in driver */
205 #define MPR_MAX_EVENT_DATA_LENGTH (48) /* Size of each event in Dwords */
207 typedef struct mpr_event_query
214 typedef struct mpr_event_enable
217 } mpr_event_enable_t;
220 * Event record entry for ioctl.
222 typedef struct mpr_event_entry
226 uint32_t Data[MPR_MAX_EVENT_DATA_LENGTH];
229 typedef struct mpr_event_report
233 } mpr_event_report_t;
235 typedef struct mpr_pci_info
238 uint8_t DeviceNumber;
239 uint8_t FunctionNumber;
240 uint16_t InterruptVector;
241 uint8_t PciHeader[256];
244 typedef struct mpr_diag_action
248 uint64_t PtrDiagAction;
252 #define MPR_FW_DIAGNOSTIC_UID_NOT_FOUND (0xFF)
254 #define MPR_FW_DIAG_NEW (0x806E6577)
256 #define MPR_FW_DIAG_TYPE_REGISTER (0x00000001)
257 #define MPR_FW_DIAG_TYPE_UNREGISTER (0x00000002)
258 #define MPR_FW_DIAG_TYPE_QUERY (0x00000003)
259 #define MPR_FW_DIAG_TYPE_READ_BUFFER (0x00000004)
260 #define MPR_FW_DIAG_TYPE_RELEASE (0x00000005)
262 #define MPR_FW_DIAG_INVALID_UID (0x00000000)
264 #define MPR_DIAG_SUCCESS 0
265 #define MPR_DIAG_FAILURE 1
267 #define MPR_FW_DIAG_ERROR_SUCCESS (0x00000000)
268 #define MPR_FW_DIAG_ERROR_FAILURE (0x00000001)
269 #define MPR_FW_DIAG_ERROR_INVALID_PARAMETER (0x00000002)
270 #define MPR_FW_DIAG_ERROR_POST_FAILED (0x00000010)
271 #define MPR_FW_DIAG_ERROR_INVALID_UID (0x00000011)
272 #define MPR_FW_DIAG_ERROR_RELEASE_FAILED (0x00000012)
273 #define MPR_FW_DIAG_ERROR_NO_BUFFER (0x00000013)
274 #define MPR_FW_DIAG_ERROR_ALREADY_RELEASED (0x00000014)
276 typedef struct mpr_fw_diag_register
278 uint8_t ExtendedType;
280 uint16_t ApplicationFlags;
281 uint32_t DiagnosticFlags;
282 uint32_t ProductSpecific[23];
283 uint32_t RequestedBufferSize;
285 } mpr_fw_diag_register_t;
287 typedef struct mpr_fw_diag_unregister
290 } mpr_fw_diag_unregister_t;
292 #define MPR_FW_DIAG_FLAG_APP_OWNED (0x0001)
293 #define MPR_FW_DIAG_FLAG_BUFFER_VALID (0x0002)
294 #define MPR_FW_DIAG_FLAG_FW_BUFFER_ACCESS (0x0004)
296 typedef struct mpr_fw_diag_query
298 uint8_t ExtendedType;
300 uint16_t ApplicationFlags;
301 uint32_t DiagnosticFlags;
302 uint32_t ProductSpecific[23];
303 uint32_t TotalBufferSize;
304 uint32_t DriverAddedBufferSize;
306 } mpr_fw_diag_query_t;
308 typedef struct mpr_fw_diag_release
311 } mpr_fw_diag_release_t;
313 #define MPR_FW_DIAG_FLAG_REREGISTER (0x0001)
314 #define MPR_FW_DIAG_FLAG_FORCE_RELEASE (0x0002)
316 typedef struct mpr_diag_read_buffer
321 uint32_t StartingOffset;
322 uint32_t BytesToRead;
324 uint64_t PtrDataBuffer;
325 } mpr_diag_read_buffer_t;
330 #define REG_IO_READ 1
331 #define REG_IO_WRITE 2
332 #define REG_MEM_READ 3
333 #define REG_MEM_WRITE 4
335 typedef struct mpr_reg_access
342 typedef struct mpr_btdh_mapping
348 } mpr_btdh_mapping_t;
350 #define MPRIO_MPR_COMMAND_FLAG_VERBOSE 0x01
351 #define MPRIO_MPR_COMMAND_FLAG_DEBUG 0x02
352 #define MPRIO_READ_CFG_HEADER _IOWR('M', 200, struct mpr_cfg_page_req)
353 #define MPRIO_READ_CFG_PAGE _IOWR('M', 201, struct mpr_cfg_page_req)
354 #define MPRIO_READ_EXT_CFG_HEADER _IOWR('M', 202, struct mpr_ext_cfg_page_req)
355 #define MPRIO_READ_EXT_CFG_PAGE _IOWR('M', 203, struct mpr_ext_cfg_page_req)
356 #define MPRIO_WRITE_CFG_PAGE _IOWR('M', 204, struct mpr_cfg_page_req)
357 #define MPRIO_RAID_ACTION _IOWR('M', 205, struct mpr_raid_action)
358 #define MPRIO_MPR_COMMAND _IOWR('M', 210, struct mpr_usr_command)
361 #define MPTIOCTL ('I')
362 #define MPTIOCTL_GET_ADAPTER_DATA _IOWR(MPTIOCTL, 1,\
363 struct mpr_adapter_data)
364 #define MPTIOCTL_UPDATE_FLASH _IOWR(MPTIOCTL, 2,\
365 struct mpr_update_flash)
366 #define MPTIOCTL_RESET_ADAPTER _IO(MPTIOCTL, 3)
367 #define MPTIOCTL_PASS_THRU _IOWR(MPTIOCTL, 4,\
368 struct mpr_pass_thru)
369 #define MPTIOCTL_EVENT_QUERY _IOWR(MPTIOCTL, 5,\
370 struct mpr_event_query)
371 #define MPTIOCTL_EVENT_ENABLE _IOWR(MPTIOCTL, 6,\
372 struct mpr_event_enable)
373 #define MPTIOCTL_EVENT_REPORT _IOWR(MPTIOCTL, 7,\
374 struct mpr_event_report)
375 #define MPTIOCTL_GET_PCI_INFO _IOWR(MPTIOCTL, 8,\
377 #define MPTIOCTL_DIAG_ACTION _IOWR(MPTIOCTL, 9,\
378 struct mpr_diag_action)
379 #define MPTIOCTL_REG_ACCESS _IOWR(MPTIOCTL, 10,\
380 struct mpr_reg_access)
381 #define MPTIOCTL_BTDH_MAPPING _IOWR(MPTIOCTL, 11,\
382 struct mpr_btdh_mapping)
383 #endif /* MPTIOCTL */
385 #endif /* !_MPR_IOCTL_H_ */