1*7282444bSPedro F. Giffuni /*- 2*7282444bSPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 3*7282444bSPedro F. Giffuni * 4db1fda10SXin LI * Copyright (c) 2010, LSI Corp. 5db1fda10SXin LI * All rights reserved. 6db1fda10SXin LI * Author : Manjunath Ranganathaiah 7db1fda10SXin LI * Support: freebsdraid@lsi.com 8db1fda10SXin LI * 9db1fda10SXin LI * Redistribution and use in source and binary forms, with or without 10db1fda10SXin LI * modification, are permitted provided that the following conditions 11db1fda10SXin LI * are met: 12db1fda10SXin LI * 13db1fda10SXin LI * 1. Redistributions of source code must retain the above copyright 14db1fda10SXin LI * notice, this list of conditions and the following disclaimer. 15db1fda10SXin LI * 2. Redistributions in binary form must reproduce the above copyright 16db1fda10SXin LI * notice, this list of conditions and the following disclaimer in 17db1fda10SXin LI * the documentation and/or other materials provided with the 18db1fda10SXin LI * distribution. 19db1fda10SXin LI * 3. Neither the name of the <ORGANIZATION> nor the names of its 20db1fda10SXin LI * contributors may be used to endorse or promote products derived 21db1fda10SXin LI * from this software without specific prior written permission. 22db1fda10SXin LI * 23db1fda10SXin LI * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24db1fda10SXin LI * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25db1fda10SXin LI * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26db1fda10SXin LI * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27db1fda10SXin LI * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28db1fda10SXin LI * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29db1fda10SXin LI * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30db1fda10SXin LI * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31db1fda10SXin LI * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32db1fda10SXin LI * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33db1fda10SXin LI * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34db1fda10SXin LI * POSSIBILITY OF SUCH DAMAGE. 35db1fda10SXin LI */ 36db1fda10SXin LI 37db1fda10SXin LI #define TWS_AEN_NOT_RETRIEVED 0x1 38db1fda10SXin LI #define TWS_AEN_RETRIEVED 0x2 39db1fda10SXin LI 40db1fda10SXin LI #define TWS_AEN_NO_EVENTS 0x1003 /* No more events */ 41db1fda10SXin LI #define TWS_AEN_OVERFLOW 0x1004 /* AEN overflow occurred */ 42db1fda10SXin LI 43db1fda10SXin LI #define TWS_IOCTL_LOCK_NOT_HELD 0x1001 /* Not locked */ 44db1fda10SXin LI #define TWS_IOCTL_LOCK_ALREADY_HELD 0x1002 /* Already locked */ 45db1fda10SXin LI 46db1fda10SXin LI #define TWS_IOCTL_LOCK_HELD 0x1 47db1fda10SXin LI #define TWS_IOCTL_LOCK_FREE 0x0 48db1fda10SXin LI 49db1fda10SXin LI #pragma pack(1) 50db1fda10SXin LI 51db1fda10SXin LI /* Structure used to handle GET/RELEASE LOCK ioctls. */ 52db1fda10SXin LI struct tws_lock_packet { 53db1fda10SXin LI u_int32_t timeout_msec; 54db1fda10SXin LI u_int32_t time_remaining_msec; 55db1fda10SXin LI u_int32_t force_flag; 56db1fda10SXin LI }; 57db1fda10SXin LI 58db1fda10SXin LI /* Structure used to handle GET COMPATIBILITY INFO ioctl. */ 59db1fda10SXin LI struct tws_compatibility_packet { 60db1fda10SXin LI u_int8_t driver_version[32];/* driver version */ 61db1fda10SXin LI u_int16_t working_srl; /* driver & firmware negotiated srl */ 62db1fda10SXin LI u_int16_t working_branch; /* branch # of the firmware that the 63db1fda10SXin LI driver is compatible with */ 64db1fda10SXin LI u_int16_t working_build; /* build # of the firmware that the 65db1fda10SXin LI driver is compatible with */ 66db1fda10SXin LI u_int16_t driver_srl_high;/* highest driver supported srl */ 67db1fda10SXin LI u_int16_t driver_branch_high;/* highest driver supported branch */ 68db1fda10SXin LI u_int16_t driver_build_high;/* highest driver supported build */ 69db1fda10SXin LI u_int16_t driver_srl_low;/* lowest driver supported srl */ 70db1fda10SXin LI u_int16_t driver_branch_low;/* lowest driver supported branch */ 71db1fda10SXin LI u_int16_t driver_build_low;/* lowest driver supported build */ 72db1fda10SXin LI u_int16_t fw_on_ctlr_srl; /* srl of running firmware */ 73db1fda10SXin LI u_int16_t fw_on_ctlr_branch;/* branch # of running firmware */ 74db1fda10SXin LI u_int16_t fw_on_ctlr_build;/* build # of running firmware */ 75db1fda10SXin LI }; 76db1fda10SXin LI 77db1fda10SXin LI /* Driver understandable part of the ioctl packet built by the API. */ 78db1fda10SXin LI struct tws_driver_packet { 79db1fda10SXin LI u_int32_t control_code; 80db1fda10SXin LI u_int32_t status; 81db1fda10SXin LI u_int32_t unique_id; 82db1fda10SXin LI u_int32_t sequence_id; 83db1fda10SXin LI u_int32_t os_status; 84db1fda10SXin LI u_int32_t buffer_length; 85db1fda10SXin LI }; 86db1fda10SXin LI 87db1fda10SXin LI /* ioctl packet built by the API. */ 88db1fda10SXin LI struct tws_ioctl_packet { 89db1fda10SXin LI struct tws_driver_packet driver_pkt; 90db1fda10SXin LI char padding[488]; 91db1fda10SXin LI struct tws_command_packet cmd_pkt; 92db1fda10SXin LI char data_buf[1]; 93db1fda10SXin LI }; 94db1fda10SXin LI 95db1fda10SXin LI #pragma pack() 96db1fda10SXin LI 97db1fda10SXin LI #pragma pack(1) 98db1fda10SXin LI /* 99db1fda10SXin LI * We need the structure below to ensure that the first byte of 100db1fda10SXin LI * data_buf is not overwritten by the kernel, after we return 101db1fda10SXin LI * from the ioctl call. Note that cmd_pkt has been reduced 102db1fda10SXin LI * to an array of 1024 bytes even though it's actually 2048 bytes 103db1fda10SXin LI * in size. This is because, we don't expect requests from user 104db1fda10SXin LI * land requiring 2048 (273 sg elements) byte cmd pkts. 105db1fda10SXin LI */ 106db1fda10SXin LI struct tws_ioctl_no_data_buf { 107db1fda10SXin LI struct tws_driver_packet driver_pkt; 108db1fda10SXin LI void *pdata; /* points to data_buf */ 109db1fda10SXin LI char padding[488 - sizeof(void *)]; 110db1fda10SXin LI struct tws_command_packet cmd_pkt; 111db1fda10SXin LI }; 112db1fda10SXin LI 113db1fda10SXin LI #pragma pack() 114db1fda10SXin LI 115db1fda10SXin LI #include <sys/ioccom.h> 116db1fda10SXin LI 117db1fda10SXin LI #pragma pack(1) 118db1fda10SXin LI 119db1fda10SXin LI struct tws_ioctl_with_payload { 120db1fda10SXin LI struct tws_driver_packet driver_pkt; 121db1fda10SXin LI char padding[488]; 122db1fda10SXin LI struct tws_command_packet cmd_pkt; 123db1fda10SXin LI union { 124db1fda10SXin LI struct tws_event_packet event_pkt; 125db1fda10SXin LI struct tws_lock_packet lock_pkt; 126db1fda10SXin LI struct tws_compatibility_packet compat_pkt; 127db1fda10SXin LI char data_buf[1]; 128db1fda10SXin LI } payload; 129db1fda10SXin LI }; 130db1fda10SXin LI 131db1fda10SXin LI #pragma pack() 132db1fda10SXin LI 133db1fda10SXin LI /* ioctl cmds */ 134db1fda10SXin LI 135db1fda10SXin LI #define TWS_IOCTL_SCAN_BUS \ 136db1fda10SXin LI _IO('T', 200) 137db1fda10SXin LI #define TWS_IOCTL_FIRMWARE_PASS_THROUGH \ 138db1fda10SXin LI _IOWR('T', 202, struct tws_ioctl_no_data_buf) 139db1fda10SXin LI #define TWS_IOCTL_GET_FIRST_EVENT \ 140db1fda10SXin LI _IOWR('T', 203, struct tws_ioctl_with_payload) 141db1fda10SXin LI #define TWS_IOCTL_GET_LAST_EVENT \ 142db1fda10SXin LI _IOWR('T', 204, struct tws_ioctl_with_payload) 143db1fda10SXin LI #define TWS_IOCTL_GET_NEXT_EVENT \ 144db1fda10SXin LI _IOWR('T', 205, struct tws_ioctl_with_payload) 145db1fda10SXin LI #define TWS_IOCTL_GET_PREVIOUS_EVENT \ 146db1fda10SXin LI _IOWR('T', 206, struct tws_ioctl_with_payload) 147db1fda10SXin LI #define TWS_IOCTL_GET_LOCK \ 148db1fda10SXin LI _IOWR('T', 207, struct tws_ioctl_with_payload) 149db1fda10SXin LI #define TWS_IOCTL_RELEASE_LOCK \ 150db1fda10SXin LI _IOWR('T', 208, struct tws_ioctl_with_payload) 151db1fda10SXin LI #define TWS_IOCTL_GET_COMPATIBILITY_INFO \ 152db1fda10SXin LI _IOWR('T', 209, struct tws_ioctl_with_payload) 153