1 /*- 2 * Copyright (c) 2006 IronPort Systems 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27 #include <sys/cdefs.h> 28 __FBSDID("$FreeBSD$"); 29 30 #if defined(__amd64__) /* Assume amd64 wants 32 bit Linux */ 31 struct iovec32 { 32 u_int32_t iov_base; 33 int iov_len; 34 }; 35 #endif 36 37 #define MFIQ_FREE 0 38 #define MFIQ_BIO 1 39 #define MFIQ_READY 2 40 #define MFIQ_BUSY 3 41 #define MFIQ_COUNT 4 42 43 struct mfi_qstat { 44 uint32_t q_length; 45 uint32_t q_max; 46 }; 47 48 union mfi_statrequest { 49 uint32_t ms_item; 50 struct mfi_qstat ms_qstat; 51 }; 52 53 #define MAX_IOCTL_SGE 16 54 55 struct mfi_ioc_packet { 56 uint16_t mfi_adapter_no; 57 uint16_t mfi_pad1; 58 uint32_t mfi_sgl_off; 59 uint32_t mfi_sge_count; 60 uint32_t mfi_sense_off; 61 uint32_t mfi_sense_len; 62 union { 63 uint8_t raw[128]; 64 struct mfi_frame_header hdr; 65 } mfi_frame; 66 67 struct iovec mfi_sgl[MAX_IOCTL_SGE]; 68 } __packed; 69 70 struct mfi_ioc_aen { 71 uint16_t aen_adapter_no; 72 uint16_t aen_pad1; 73 uint32_t aen_seq_num; 74 uint32_t aen_class_locale; 75 } __packed; 76 77 #define MFI_CMD _IOWR('M', 1, struct mfi_ioc_packet) 78 #define MFI_SET_AEN _IOW('M', 3, struct mfi_ioc_aen) 79 80 #define MAX_LINUX_IOCTL_SGE 16 81 82 struct mfi_linux_ioc_packet { 83 uint16_t lioc_adapter_no; 84 uint16_t lioc_pad1; 85 uint32_t lioc_sgl_off; 86 uint32_t lioc_sge_count; 87 uint32_t lioc_sense_off; 88 uint32_t lioc_sense_len; 89 union { 90 uint8_t raw[128]; 91 struct mfi_frame_header hdr; 92 } lioc_frame; 93 94 #if defined(__amd64__) /* Assume amd64 wants 32 bit Linux */ 95 struct iovec32 lioc_sgl[MAX_LINUX_IOCTL_SGE]; 96 #else 97 struct iovec lioc_sgl[MAX_LINUX_IOCTL_SGE]; 98 #endif 99 } __packed; 100 101 #define MFIIO_STATS _IOWR('Q', 101, union mfi_statrequest) 102 103 struct mfi_linux_ioc_aen { 104 uint16_t laen_adapter_no; 105 uint16_t laen_pad1; 106 uint32_t laen_seq_num; 107 uint32_t laen_class_locale; 108 } __packed; 109 110 struct mfi_query_disk { 111 uint8_t array_id; 112 uint8_t present; 113 uint8_t open; 114 uint8_t reserved; /* reserved for future use */ 115 char devname[SPECNAMELEN + 1]; 116 } __packed; 117 118 #define MFIIO_QUERY_DISK _IOWR('Q', 102, struct mfi_query_disk) 119 120 /* 121 * Create a second set so the FreeBSD native ioctl doesn't 122 * conflict in FreeBSD ioctl handler. Translate in mfi_linux.c. 123 */ 124 #define MFI_LINUX_CMD 0xc1144d01 125 #define MFI_LINUX_SET_AEN 0x400c4d03 126 #define MFI_LINUX_CMD_2 0xc1144d02 127 #define MFI_LINUX_SET_AEN_2 0x400c4d04 128