1226026Sdelphij/* 2226026Sdelphij * Copyright (c) 2010, LSI Corp. 3226026Sdelphij * All rights reserved. 4226026Sdelphij * Author : Manjunath Ranganathaiah 5226026Sdelphij * Support: freebsdraid@lsi.com 6226026Sdelphij * 7226026Sdelphij * Redistribution and use in source and binary forms, with or without 8226026Sdelphij * modification, are permitted provided that the following conditions 9226026Sdelphij * are met: 10226026Sdelphij * 11226026Sdelphij * 1. Redistributions of source code must retain the above copyright 12226026Sdelphij * notice, this list of conditions and the following disclaimer. 13226026Sdelphij * 2. Redistributions in binary form must reproduce the above copyright 14226026Sdelphij * notice, this list of conditions and the following disclaimer in 15226026Sdelphij * the documentation and/or other materials provided with the 16226026Sdelphij * distribution. 17226026Sdelphij * 3. Neither the name of the <ORGANIZATION> nor the names of its 18226026Sdelphij * contributors may be used to endorse or promote products derived 19226026Sdelphij * from this software without specific prior written permission. 20226026Sdelphij * 21226026Sdelphij * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22226026Sdelphij * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23226026Sdelphij * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24226026Sdelphij * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25226026Sdelphij * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26226026Sdelphij * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27226026Sdelphij * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28226026Sdelphij * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29226026Sdelphij * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30226026Sdelphij * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31226026Sdelphij * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32226026Sdelphij * POSSIBILITY OF SUCH DAMAGE. 33226026Sdelphij * 34226026Sdelphij * $FreeBSD: releng/10.3/sys/dev/tws/tws_user.h 226026 2011-10-04 21:40:25Z delphij $ 35226026Sdelphij */ 36226026Sdelphij 37226026Sdelphij#define TWS_AEN_NOT_RETRIEVED 0x1 38226026Sdelphij#define TWS_AEN_RETRIEVED 0x2 39226026Sdelphij 40226026Sdelphij#define TWS_AEN_NO_EVENTS 0x1003 /* No more events */ 41226026Sdelphij#define TWS_AEN_OVERFLOW 0x1004 /* AEN overflow occurred */ 42226026Sdelphij 43226026Sdelphij#define TWS_IOCTL_LOCK_NOT_HELD 0x1001 /* Not locked */ 44226026Sdelphij#define TWS_IOCTL_LOCK_ALREADY_HELD 0x1002 /* Already locked */ 45226026Sdelphij 46226026Sdelphij#define TWS_IOCTL_LOCK_HELD 0x1 47226026Sdelphij#define TWS_IOCTL_LOCK_FREE 0x0 48226026Sdelphij 49226026Sdelphij#pragma pack(1) 50226026Sdelphij 51226026Sdelphij/* Structure used to handle GET/RELEASE LOCK ioctls. */ 52226026Sdelphijstruct tws_lock_packet { 53226026Sdelphij u_int32_t timeout_msec; 54226026Sdelphij u_int32_t time_remaining_msec; 55226026Sdelphij u_int32_t force_flag; 56226026Sdelphij}; 57226026Sdelphij 58226026Sdelphij/* Structure used to handle GET COMPATIBILITY INFO ioctl. */ 59226026Sdelphijstruct tws_compatibility_packet { 60226026Sdelphij u_int8_t driver_version[32];/* driver version */ 61226026Sdelphij u_int16_t working_srl; /* driver & firmware negotiated srl */ 62226026Sdelphij u_int16_t working_branch; /* branch # of the firmware that the 63226026Sdelphij driver is compatible with */ 64226026Sdelphij u_int16_t working_build; /* build # of the firmware that the 65226026Sdelphij driver is compatible with */ 66226026Sdelphij u_int16_t driver_srl_high;/* highest driver supported srl */ 67226026Sdelphij u_int16_t driver_branch_high;/* highest driver supported branch */ 68226026Sdelphij u_int16_t driver_build_high;/* highest driver supported build */ 69226026Sdelphij u_int16_t driver_srl_low;/* lowest driver supported srl */ 70226026Sdelphij u_int16_t driver_branch_low;/* lowest driver supported branch */ 71226026Sdelphij u_int16_t driver_build_low;/* lowest driver supported build */ 72226026Sdelphij u_int16_t fw_on_ctlr_srl; /* srl of running firmware */ 73226026Sdelphij u_int16_t fw_on_ctlr_branch;/* branch # of running firmware */ 74226026Sdelphij u_int16_t fw_on_ctlr_build;/* build # of running firmware */ 75226026Sdelphij}; 76226026Sdelphij 77226026Sdelphij 78226026Sdelphij/* Driver understandable part of the ioctl packet built by the API. */ 79226026Sdelphijstruct tws_driver_packet { 80226026Sdelphij u_int32_t control_code; 81226026Sdelphij u_int32_t status; 82226026Sdelphij u_int32_t unique_id; 83226026Sdelphij u_int32_t sequence_id; 84226026Sdelphij u_int32_t os_status; 85226026Sdelphij u_int32_t buffer_length; 86226026Sdelphij}; 87226026Sdelphij 88226026Sdelphij/* ioctl packet built by the API. */ 89226026Sdelphijstruct tws_ioctl_packet { 90226026Sdelphij struct tws_driver_packet driver_pkt; 91226026Sdelphij char padding[488]; 92226026Sdelphij struct tws_command_packet cmd_pkt; 93226026Sdelphij char data_buf[1]; 94226026Sdelphij}; 95226026Sdelphij 96226026Sdelphij#pragma pack() 97226026Sdelphij 98226026Sdelphij 99226026Sdelphij#pragma pack(1) 100226026Sdelphij/* 101226026Sdelphij * We need the structure below to ensure that the first byte of 102226026Sdelphij * data_buf is not overwritten by the kernel, after we return 103226026Sdelphij * from the ioctl call. Note that cmd_pkt has been reduced 104226026Sdelphij * to an array of 1024 bytes even though it's actually 2048 bytes 105226026Sdelphij * in size. This is because, we don't expect requests from user 106226026Sdelphij * land requiring 2048 (273 sg elements) byte cmd pkts. 107226026Sdelphij */ 108226026Sdelphijstruct tws_ioctl_no_data_buf { 109226026Sdelphij struct tws_driver_packet driver_pkt; 110226026Sdelphij void *pdata; /* points to data_buf */ 111226026Sdelphij char padding[488 - sizeof(void *)]; 112226026Sdelphij struct tws_command_packet cmd_pkt; 113226026Sdelphij}; 114226026Sdelphij 115226026Sdelphij#pragma pack() 116226026Sdelphij 117226026Sdelphij 118226026Sdelphij#include <sys/ioccom.h> 119226026Sdelphij 120226026Sdelphij#pragma pack(1) 121226026Sdelphij 122226026Sdelphijstruct tws_ioctl_with_payload { 123226026Sdelphij struct tws_driver_packet driver_pkt; 124226026Sdelphij char padding[488]; 125226026Sdelphij struct tws_command_packet cmd_pkt; 126226026Sdelphij union { 127226026Sdelphij struct tws_event_packet event_pkt; 128226026Sdelphij struct tws_lock_packet lock_pkt; 129226026Sdelphij struct tws_compatibility_packet compat_pkt; 130226026Sdelphij char data_buf[1]; 131226026Sdelphij } payload; 132226026Sdelphij}; 133226026Sdelphij 134226026Sdelphij#pragma pack() 135226026Sdelphij 136226026Sdelphij/* ioctl cmds */ 137226026Sdelphij 138226026Sdelphij#define TWS_IOCTL_SCAN_BUS \ 139226026Sdelphij _IO('T', 200) 140226026Sdelphij#define TWS_IOCTL_FIRMWARE_PASS_THROUGH \ 141226026Sdelphij _IOWR('T', 202, struct tws_ioctl_no_data_buf) 142226026Sdelphij#define TWS_IOCTL_GET_FIRST_EVENT \ 143226026Sdelphij _IOWR('T', 203, struct tws_ioctl_with_payload) 144226026Sdelphij#define TWS_IOCTL_GET_LAST_EVENT \ 145226026Sdelphij _IOWR('T', 204, struct tws_ioctl_with_payload) 146226026Sdelphij#define TWS_IOCTL_GET_NEXT_EVENT \ 147226026Sdelphij _IOWR('T', 205, struct tws_ioctl_with_payload) 148226026Sdelphij#define TWS_IOCTL_GET_PREVIOUS_EVENT \ 149226026Sdelphij _IOWR('T', 206, struct tws_ioctl_with_payload) 150226026Sdelphij#define TWS_IOCTL_GET_LOCK \ 151226026Sdelphij _IOWR('T', 207, struct tws_ioctl_with_payload) 152226026Sdelphij#define TWS_IOCTL_RELEASE_LOCK \ 153226026Sdelphij _IOWR('T', 208, struct tws_ioctl_with_payload) 154226026Sdelphij#define TWS_IOCTL_GET_COMPATIBILITY_INFO \ 155226026Sdelphij _IOWR('T', 209, struct tws_ioctl_with_payload) 156226026Sdelphij 157