186d7f5d3SJohn Marino /* 286d7f5d3SJohn Marino * Copyright (c) 2010, LSI Corp. 386d7f5d3SJohn Marino * All rights reserved. 486d7f5d3SJohn Marino * Author : Manjunath Ranganathaiah 586d7f5d3SJohn Marino * Support: freebsdraid@lsi.com 686d7f5d3SJohn Marino * 786d7f5d3SJohn Marino * Redistribution and use in source and binary forms, with or without 886d7f5d3SJohn Marino * modification, are permitted provided that the following conditions 986d7f5d3SJohn Marino * are met: 1086d7f5d3SJohn Marino * 1186d7f5d3SJohn Marino * 1. Redistributions of source code must retain the above copyright 1286d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer. 1386d7f5d3SJohn Marino * 2. Redistributions in binary form must reproduce the above copyright 1486d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer in 1586d7f5d3SJohn Marino * the documentation and/or other materials provided with the 1686d7f5d3SJohn Marino * distribution. 1786d7f5d3SJohn Marino * 3. Neither the name of the <ORGANIZATION> nor the names of its 1886d7f5d3SJohn Marino * contributors may be used to endorse or promote products derived 1986d7f5d3SJohn Marino * from this software without specific prior written permission. 2086d7f5d3SJohn Marino * 2186d7f5d3SJohn Marino * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2286d7f5d3SJohn Marino * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2386d7f5d3SJohn Marino * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 2486d7f5d3SJohn Marino * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 2586d7f5d3SJohn Marino * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 2686d7f5d3SJohn Marino * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 2786d7f5d3SJohn Marino * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 2886d7f5d3SJohn Marino * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 2986d7f5d3SJohn Marino * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3086d7f5d3SJohn Marino * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 3186d7f5d3SJohn Marino * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3286d7f5d3SJohn Marino * POSSIBILITY OF SUCH DAMAGE. 3386d7f5d3SJohn Marino * 3486d7f5d3SJohn Marino * $FreeBSD: src/sys/dev/tws/tws_user.h,v 1.3 2007/05/09 04:16:32 mrangana Exp $ 3586d7f5d3SJohn Marino */ 3686d7f5d3SJohn Marino 3786d7f5d3SJohn Marino #define TWS_AEN_NOT_RETRIEVED 0x1 3886d7f5d3SJohn Marino #define TWS_AEN_RETRIEVED 0x2 3986d7f5d3SJohn Marino 4086d7f5d3SJohn Marino #define TWS_AEN_NO_EVENTS 0x1003 /* No more events */ 4186d7f5d3SJohn Marino #define TWS_AEN_OVERFLOW 0x1004 /* AEN overflow occurred */ 4286d7f5d3SJohn Marino 4386d7f5d3SJohn Marino #define TWS_IOCTL_LOCK_NOT_HELD 0x1001 /* Not locked */ 4486d7f5d3SJohn Marino #define TWS_IOCTL_LOCK_ALREADY_HELD 0x1002 /* Already locked */ 4586d7f5d3SJohn Marino 4686d7f5d3SJohn Marino #define TWS_IOCTL_LOCK_HELD 0x1 4786d7f5d3SJohn Marino #define TWS_IOCTL_LOCK_FREE 0x0 4886d7f5d3SJohn Marino 4986d7f5d3SJohn Marino #pragma pack(1) 5086d7f5d3SJohn Marino 5186d7f5d3SJohn Marino /* Structure used to handle GET/RELEASE LOCK ioctls. */ 5286d7f5d3SJohn Marino struct tws_lock_packet { 5386d7f5d3SJohn Marino u_int32_t timeout_msec; 5486d7f5d3SJohn Marino u_int32_t time_remaining_msec; 5586d7f5d3SJohn Marino u_int32_t force_flag; 5686d7f5d3SJohn Marino }; 5786d7f5d3SJohn Marino 5886d7f5d3SJohn Marino /* Structure used to handle GET COMPATIBILITY INFO ioctl. */ 5986d7f5d3SJohn Marino struct tws_compatibility_packet { 6086d7f5d3SJohn Marino u_int8_t driver_version[32];/* driver version */ 6186d7f5d3SJohn Marino u_int16_t working_srl; /* driver & firmware negotiated srl */ 6286d7f5d3SJohn Marino u_int16_t working_branch; /* branch # of the firmware that the 6386d7f5d3SJohn Marino driver is compatible with */ 6486d7f5d3SJohn Marino u_int16_t working_build; /* build # of the firmware that the 6586d7f5d3SJohn Marino driver is compatible with */ 6686d7f5d3SJohn Marino u_int16_t driver_srl_high;/* highest driver supported srl */ 6786d7f5d3SJohn Marino u_int16_t driver_branch_high;/* highest driver supported branch */ 6886d7f5d3SJohn Marino u_int16_t driver_build_high;/* highest driver supported build */ 6986d7f5d3SJohn Marino u_int16_t driver_srl_low;/* lowest driver supported srl */ 7086d7f5d3SJohn Marino u_int16_t driver_branch_low;/* lowest driver supported branch */ 7186d7f5d3SJohn Marino u_int16_t driver_build_low;/* lowest driver supported build */ 7286d7f5d3SJohn Marino u_int16_t fw_on_ctlr_srl; /* srl of running firmware */ 7386d7f5d3SJohn Marino u_int16_t fw_on_ctlr_branch;/* branch # of running firmware */ 7486d7f5d3SJohn Marino u_int16_t fw_on_ctlr_build;/* build # of running firmware */ 7586d7f5d3SJohn Marino }; 7686d7f5d3SJohn Marino 7786d7f5d3SJohn Marino 7886d7f5d3SJohn Marino /* Driver understandable part of the ioctl packet built by the API. */ 7986d7f5d3SJohn Marino struct tws_driver_packet { 8086d7f5d3SJohn Marino u_int32_t control_code; 8186d7f5d3SJohn Marino u_int32_t status; 8286d7f5d3SJohn Marino u_int32_t unique_id; 8386d7f5d3SJohn Marino u_int32_t sequence_id; 8486d7f5d3SJohn Marino u_int32_t os_status; 8586d7f5d3SJohn Marino u_int32_t buffer_length; 8686d7f5d3SJohn Marino }; 8786d7f5d3SJohn Marino 8886d7f5d3SJohn Marino /* ioctl packet built by the API. */ 8986d7f5d3SJohn Marino struct tws_ioctl_packet { 9086d7f5d3SJohn Marino struct tws_driver_packet driver_pkt; 9186d7f5d3SJohn Marino char padding[488]; 9286d7f5d3SJohn Marino struct tws_command_packet cmd_pkt; 9386d7f5d3SJohn Marino char data_buf[1]; 9486d7f5d3SJohn Marino }; 9586d7f5d3SJohn Marino 9686d7f5d3SJohn Marino #pragma pack() 9786d7f5d3SJohn Marino 9886d7f5d3SJohn Marino 9986d7f5d3SJohn Marino #pragma pack(1) 10086d7f5d3SJohn Marino /* 10186d7f5d3SJohn Marino * We need the structure below to ensure that the first byte of 10286d7f5d3SJohn Marino * data_buf is not overwritten by the kernel, after we return 10386d7f5d3SJohn Marino * from the ioctl call. Note that cmd_pkt has been reduced 10486d7f5d3SJohn Marino * to an array of 1024 bytes even though it's actually 2048 bytes 10586d7f5d3SJohn Marino * in size. This is because, we don't expect requests from user 10686d7f5d3SJohn Marino * land requiring 2048 (273 sg elements) byte cmd pkts. 10786d7f5d3SJohn Marino */ 10886d7f5d3SJohn Marino struct tws_ioctl_no_data_buf { 10986d7f5d3SJohn Marino struct tws_driver_packet driver_pkt; 11086d7f5d3SJohn Marino void *pdata; /* points to data_buf */ 11186d7f5d3SJohn Marino char padding[488 - sizeof(void *)]; 11286d7f5d3SJohn Marino struct tws_command_packet cmd_pkt; 11386d7f5d3SJohn Marino }; 11486d7f5d3SJohn Marino 11586d7f5d3SJohn Marino #pragma pack() 11686d7f5d3SJohn Marino 11786d7f5d3SJohn Marino 11886d7f5d3SJohn Marino #include <sys/ioccom.h> 11986d7f5d3SJohn Marino 12086d7f5d3SJohn Marino #pragma pack(1) 12186d7f5d3SJohn Marino 12286d7f5d3SJohn Marino struct tws_ioctl_with_payload { 12386d7f5d3SJohn Marino struct tws_driver_packet driver_pkt; 12486d7f5d3SJohn Marino char padding[488]; 12586d7f5d3SJohn Marino struct tws_command_packet cmd_pkt; 12686d7f5d3SJohn Marino union { 12786d7f5d3SJohn Marino struct tws_event_packet event_pkt; 12886d7f5d3SJohn Marino struct tws_lock_packet lock_pkt; 12986d7f5d3SJohn Marino struct tws_compatibility_packet compat_pkt; 13086d7f5d3SJohn Marino char data_buf[1]; 13186d7f5d3SJohn Marino } payload; 13286d7f5d3SJohn Marino }; 13386d7f5d3SJohn Marino 13486d7f5d3SJohn Marino #pragma pack() 13586d7f5d3SJohn Marino 13686d7f5d3SJohn Marino /* ioctl cmds */ 13786d7f5d3SJohn Marino 13886d7f5d3SJohn Marino #define TWS_IOCTL_SCAN_BUS \ 13986d7f5d3SJohn Marino _IO('T', 200) 14086d7f5d3SJohn Marino #define TWS_IOCTL_FIRMWARE_PASS_THROUGH \ 14186d7f5d3SJohn Marino _IOWR('T', 202, struct tws_ioctl_no_data_buf) 14286d7f5d3SJohn Marino #define TWS_IOCTL_GET_FIRST_EVENT \ 14386d7f5d3SJohn Marino _IOWR('T', 203, struct tws_ioctl_with_payload) 14486d7f5d3SJohn Marino #define TWS_IOCTL_GET_LAST_EVENT \ 14586d7f5d3SJohn Marino _IOWR('T', 204, struct tws_ioctl_with_payload) 14686d7f5d3SJohn Marino #define TWS_IOCTL_GET_NEXT_EVENT \ 14786d7f5d3SJohn Marino _IOWR('T', 205, struct tws_ioctl_with_payload) 14886d7f5d3SJohn Marino #define TWS_IOCTL_GET_PREVIOUS_EVENT \ 14986d7f5d3SJohn Marino _IOWR('T', 206, struct tws_ioctl_with_payload) 15086d7f5d3SJohn Marino #define TWS_IOCTL_GET_LOCK \ 15186d7f5d3SJohn Marino _IOWR('T', 207, struct tws_ioctl_with_payload) 15286d7f5d3SJohn Marino #define TWS_IOCTL_RELEASE_LOCK \ 15386d7f5d3SJohn Marino _IOWR('T', 208, struct tws_ioctl_with_payload) 15486d7f5d3SJohn Marino #define TWS_IOCTL_GET_COMPATIBILITY_INFO \ 15586d7f5d3SJohn Marino _IOWR('T', 209, struct tws_ioctl_with_payload) 156