1157114Sscottl/*- 2157114Sscottl * Copyright (c) 2006 IronPort Systems 3157114Sscottl * All rights reserved. 4157114Sscottl * 5157114Sscottl * Redistribution and use in source and binary forms, with or without 6157114Sscottl * modification, are permitted provided that the following conditions 7157114Sscottl * are met: 8157114Sscottl * 1. Redistributions of source code must retain the above copyright 9157114Sscottl * notice, this list of conditions and the following disclaimer. 10157114Sscottl * 2. Redistributions in binary form must reproduce the above copyright 11157114Sscottl * notice, this list of conditions and the following disclaimer in the 12157114Sscottl * documentation and/or other materials provided with the distribution. 13157114Sscottl * 14157114Sscottl * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15157114Sscottl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16157114Sscottl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17157114Sscottl * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18157114Sscottl * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19157114Sscottl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20157114Sscottl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21157114Sscottl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22157114Sscottl * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23157114Sscottl * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24157114Sscottl * SUCH DAMAGE. 25157114Sscottl */ 26157114Sscottl 27157114Sscottl#include <sys/cdefs.h> 28157114Sscottl__FBSDID("$FreeBSD$"); 29157114Sscottl 30196200Sscottl#include <dev/mfi/mfireg.h> 31196200Sscottl 32164281Sambriskostruct iovec32 { 33164281Sambrisko u_int32_t iov_base; 34164281Sambrisko int iov_len; 35164281Sambrisko}; 36164281Sambrisko 37157114Sscottl#define MFIQ_FREE 0 38157114Sscottl#define MFIQ_BIO 1 39157114Sscottl#define MFIQ_READY 2 40157114Sscottl#define MFIQ_BUSY 3 41157114Sscottl#define MFIQ_COUNT 4 42157114Sscottl 43157114Sscottlstruct mfi_qstat { 44157114Sscottl uint32_t q_length; 45157114Sscottl uint32_t q_max; 46157114Sscottl}; 47157114Sscottl 48157114Sscottlunion mfi_statrequest { 49157114Sscottl uint32_t ms_item; 50157114Sscottl struct mfi_qstat ms_qstat; 51157114Sscottl}; 52157114Sscottl 53184897Sambrisko#define MAX_SPACE_FOR_SENSE_PTR 32 54184897Sambriskounion mfi_sense_ptr { 55184897Sambrisko uint8_t sense_ptr_data[MAX_SPACE_FOR_SENSE_PTR]; 56184897Sambrisko void *user_space; 57184897Sambrisko struct { 58184897Sambrisko uint32_t low; 59184897Sambrisko uint32_t high; 60184897Sambrisko } addr; 61184897Sambrisko} __packed; 62184897Sambrisko 63164281Sambrisko#define MAX_IOCTL_SGE 16 64164281Sambrisko 65164281Sambriskostruct mfi_ioc_packet { 66165225Sambrisko uint16_t mfi_adapter_no; 67165225Sambrisko uint16_t mfi_pad1; 68165225Sambrisko uint32_t mfi_sgl_off; 69165225Sambrisko uint32_t mfi_sge_count; 70165225Sambrisko uint32_t mfi_sense_off; 71165225Sambrisko uint32_t mfi_sense_len; 72164281Sambrisko union { 73164281Sambrisko uint8_t raw[128]; 74164281Sambrisko struct mfi_frame_header hdr; 75165225Sambrisko } mfi_frame; 76164281Sambrisko 77165225Sambrisko struct iovec mfi_sgl[MAX_IOCTL_SGE]; 78164281Sambrisko} __packed; 79164281Sambrisko 80233711Sambrisko#ifdef COMPAT_FREEBSD32 81179392Sambriskostruct mfi_ioc_packet32 { 82179392Sambrisko uint16_t mfi_adapter_no; 83179392Sambrisko uint16_t mfi_pad1; 84179392Sambrisko uint32_t mfi_sgl_off; 85179392Sambrisko uint32_t mfi_sge_count; 86179392Sambrisko uint32_t mfi_sense_off; 87179392Sambrisko uint32_t mfi_sense_len; 88179392Sambrisko union { 89179392Sambrisko uint8_t raw[128]; 90179392Sambrisko struct mfi_frame_header hdr; 91179392Sambrisko } mfi_frame; 92179392Sambrisko 93179392Sambrisko struct iovec32 mfi_sgl[MAX_IOCTL_SGE]; 94179392Sambrisko} __packed; 95179392Sambrisko#endif 96179392Sambrisko 97164281Sambriskostruct mfi_ioc_aen { 98164281Sambrisko uint16_t aen_adapter_no; 99164281Sambrisko uint16_t aen_pad1; 100164281Sambrisko uint32_t aen_seq_num; 101164281Sambrisko uint32_t aen_class_locale; 102164281Sambrisko} __packed; 103164281Sambrisko 104164281Sambrisko#define MFI_CMD _IOWR('M', 1, struct mfi_ioc_packet) 105233711Sambrisko#ifdef COMPAT_FREEBSD32 106179392Sambrisko#define MFI_CMD32 _IOWR('M', 1, struct mfi_ioc_packet32) 107179392Sambrisko#endif 108164281Sambrisko#define MFI_SET_AEN _IOW('M', 3, struct mfi_ioc_aen) 109164281Sambrisko 110158737Sambrisko#define MAX_LINUX_IOCTL_SGE 16 111158737Sambrisko 112158737Sambriskostruct mfi_linux_ioc_packet { 113158737Sambrisko uint16_t lioc_adapter_no; 114158737Sambrisko uint16_t lioc_pad1; 115158737Sambrisko uint32_t lioc_sgl_off; 116158737Sambrisko uint32_t lioc_sge_count; 117158737Sambrisko uint32_t lioc_sense_off; 118158737Sambrisko uint32_t lioc_sense_len; 119158737Sambrisko union { 120158737Sambrisko uint8_t raw[128]; 121158737Sambrisko struct mfi_frame_header hdr; 122158737Sambrisko } lioc_frame; 123158737Sambrisko 124164281Sambrisko#if defined(__amd64__) /* Assume amd64 wants 32 bit Linux */ 125164281Sambrisko struct iovec32 lioc_sgl[MAX_LINUX_IOCTL_SGE]; 126164281Sambrisko#else 127158737Sambrisko struct iovec lioc_sgl[MAX_LINUX_IOCTL_SGE]; 128164281Sambrisko#endif 129158737Sambrisko} __packed; 130158737Sambrisko 131178968Sscottlstruct mfi_ioc_passthru { 132178968Sscottl struct mfi_dcmd_frame ioc_frame; 133178968Sscottl uint32_t buf_size; 134178968Sscottl uint8_t *buf; 135178968Sscottl} __packed; 136178968Sscottl 137233711Sambrisko#ifdef COMPAT_FREEBSD32 138178968Sscottlstruct mfi_ioc_passthru32 { 139178968Sscottl struct mfi_dcmd_frame ioc_frame; 140178968Sscottl uint32_t buf_size; 141178968Sscottl uint32_t buf; 142178968Sscottl} __packed; 143178968Sscottl#endif 144178968Sscottl 145157114Sscottl#define MFIIO_STATS _IOWR('Q', 101, union mfi_statrequest) 146178968Sscottl#define MFIIO_PASSTHRU _IOWR('C', 102, struct mfi_ioc_passthru) 147233711Sambrisko#ifdef COMPAT_FREEBSD32 148178968Sscottl#define MFIIO_PASSTHRU32 _IOWR('C', 102, struct mfi_ioc_passthru32) 149178968Sscottl#endif 150157114Sscottl 151158737Sambriskostruct mfi_linux_ioc_aen { 152158737Sambrisko uint16_t laen_adapter_no; 153158737Sambrisko uint16_t laen_pad1; 154158737Sambrisko uint32_t laen_seq_num; 155158737Sambrisko uint32_t laen_class_locale; 156158737Sambrisko} __packed; 157164281Sambrisko 158169451Sscottlstruct mfi_query_disk { 159169451Sscottl uint8_t array_id; 160169451Sscottl uint8_t present; 161169451Sscottl uint8_t open; 162169451Sscottl uint8_t reserved; /* reserved for future use */ 163169451Sscottl char devname[SPECNAMELEN + 1]; 164169451Sscottl} __packed; 165169451Sscottl 166169451Sscottl#define MFIIO_QUERY_DISK _IOWR('Q', 102, struct mfi_query_disk) 167169451Sscottl 168164281Sambrisko/* 169164281Sambrisko * Create a second set so the FreeBSD native ioctl doesn't 170164281Sambrisko * conflict in FreeBSD ioctl handler. Translate in mfi_linux.c. 171164281Sambrisko */ 172164281Sambrisko#define MFI_LINUX_CMD 0xc1144d01 173164281Sambrisko#define MFI_LINUX_SET_AEN 0x400c4d03 174164281Sambrisko#define MFI_LINUX_CMD_2 0xc1144d02 175164281Sambrisko#define MFI_LINUX_SET_AEN_2 0x400c4d04 176