1 /*- 2 * SPDX-License-Identifier: BSD-4-Clause 3 * 4 * Copyright (c) 2003 Hidetoshi Shimokawa 5 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the acknowledgement as bellow: 18 * 19 * This product includes software developed by K. Kobayashi and H. Shimokawa 20 * 21 * 4. The name of the author may not be used to endorse or promote products 22 * derived from this software without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 28 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 33 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 * POSSIBILITY OF SUCH DAMAGE. 35 * 36 * $FreeBSD$ 37 * 38 */ 39 40 #define ORB_NOTIFY (1U << 31) 41 #define ORB_FMT_STD (0 << 29) 42 #define ORB_FMT_VED (2 << 29) 43 #define ORB_FMT_NOP (3 << 29) 44 #define ORB_FMT_MSK (3 << 29) 45 #define ORB_EXV (1 << 28) 46 /* */ 47 #define ORB_CMD_IN (1 << 27) 48 /* */ 49 #define ORB_CMD_SPD(x) ((x) << 24) 50 #define ORB_CMD_MAXP(x) ((x) << 20) 51 #define ORB_RCN_TMO(x) ((x) << 20) 52 #define ORB_CMD_PTBL (1 << 19) 53 #define ORB_CMD_PSZ(x) ((x) << 16) 54 55 #define ORB_FUN_LGI (0 << 16) 56 #define ORB_FUN_QLG (1 << 16) 57 #define ORB_FUN_RCN (3 << 16) 58 #define ORB_FUN_LGO (7 << 16) 59 #define ORB_FUN_ATA (0xb << 16) 60 #define ORB_FUN_ATS (0xc << 16) 61 #define ORB_FUN_LUR (0xe << 16) 62 #define ORB_FUN_RST (0xf << 16) 63 #define ORB_FUN_MSK (0xf << 16) 64 #define ORB_FUN_RUNQUEUE 0xffff 65 66 #define ORB_RES_CMPL 0 67 #define ORB_RES_FAIL 1 68 #define ORB_RES_ILLE 2 69 #define ORB_RES_VEND 3 70 71 #define SBP_DEBUG(x) if (debug > x) { 72 #define END_DEBUG } 73 74 struct ind_ptr { 75 uint32_t hi,lo; 76 }; 77 78 79 #define SBP_RECV_LEN 32 80 81 struct sbp_login_res { 82 uint16_t len; 83 uint16_t id; 84 uint16_t res0; 85 uint16_t cmd_hi; 86 uint32_t cmd_lo; 87 uint16_t res1; 88 uint16_t recon_hold; 89 }; 90 91 struct sbp_status { 92 #if BYTE_ORDER == BIG_ENDIAN 93 uint8_t src:2, 94 resp:2, 95 dead:1, 96 len:3; 97 #else 98 uint8_t len:3, 99 dead:1, 100 resp:2, 101 src:2; 102 #endif 103 uint8_t status; 104 uint16_t orb_hi; 105 uint32_t orb_lo; 106 uint32_t data[6]; 107 }; 108 /* src */ 109 #define SRC_NEXT_EXISTS 0 110 #define SRC_NO_NEXT 1 111 #define SRC_UNSOL 2 112 113 /* resp */ 114 #define SBP_REQ_CMP 0 /* request complete */ 115 #define SBP_TRANS_FAIL 1 /* transport failure */ 116 #define SBP_ILLE_REQ 2 /* illegal request */ 117 #define SBP_VEND_DEP 3 /* vendor dependent */ 118 119 /* status (resp == 0) */ 120 /* 0: No additional Information to report */ 121 /* 1: Request Type not supported */ 122 /* 2: Speed not supported */ 123 /* 3: Page size not supported */ 124 /* 4: Access denied */ 125 #define STATUS_ACCESS_DENY 4 126 #define STATUS_LUR 5 127 /* 6: Maximum payload too small */ 128 /* 7: Reserved for future standardization */ 129 /* 8: Resource unavailabe */ 130 #define STATUS_RES_UNAVAIL 8 131 /* 9: Function Rejected */ 132 /* 10: Login ID not recognized */ 133 /* 11: Dummy ORB completed */ 134 /* 12: Request aborted */ 135 /* 255: Unspecified error */ 136 137 /* status (resp == 1) */ 138 /* Referenced object */ 139 #define OBJ_ORB (0 << 6) /* 0: ORB */ 140 #define OBJ_DATA (1 << 6) /* 1: Data buffer */ 141 #define OBJ_PT (2 << 6) /* 2: Page table */ 142 #define OBJ_UNSPEC (3 << 6) /* 3: Unable to specify */ 143 /* Serial bus error */ 144 /* 0: Missing acknowledge */ 145 /* 1: Reserved; not to be used */ 146 /* 2: Time-out error */ 147 #define SBE_TIMEOUT 2 148 /* 3: Reserved; not to be used */ 149 /* 4: Busy retry limit exceeded: ack_busy_X */ 150 /* 5: Busy retry limit exceeded: ack_busy_A */ 151 /* 6: Busy retry limit exceeded: ack_busy_B */ 152 /* 7-A: Reserved for future standardization */ 153 /* B: Tardy retry limit exceeded */ 154 /* C: Confilict error */ 155 /* D: Data error */ 156 /* E: Type error */ 157 /* F: Address error */ 158 159 160 struct sbp_cmd_status { 161 #define SBP_SFMT_CURR 0 162 #define SBP_SFMT_DEFER 1 163 #if BYTE_ORDER == BIG_ENDIAN 164 uint8_t sfmt:2, 165 status:6; 166 uint8_t valid:1, 167 mark:1, 168 eom:1, 169 ill_len:1, 170 s_key:4; 171 #else 172 uint8_t status:6, 173 sfmt:2; 174 uint8_t s_key:4, 175 ill_len:1, 176 eom:1, 177 mark:1, 178 valid:1; 179 #endif 180 uint8_t s_code; 181 uint8_t s_qlfr; 182 uint32_t info; 183 uint32_t cdb; 184 uint8_t fru; 185 uint8_t s_keydep[3]; 186 uint32_t vend[2]; 187 }; 188 189 #define ORB_FUN_NAMES \ 190 /* 0 */ "LOGIN", \ 191 /* 1 */ "QUERY LOGINS", \ 192 /* 2 */ "Reserved", \ 193 /* 3 */ "RECONNECT", \ 194 /* 4 */ "SET PASSWORD", \ 195 /* 5 */ "Reserved", \ 196 /* 6 */ "Reserved", \ 197 /* 7 */ "LOGOUT", \ 198 /* 8 */ "Reserved", \ 199 /* 9 */ "Reserved", \ 200 /* A */ "Reserved", \ 201 /* B */ "ABORT TASK", \ 202 /* C */ "ABORT TASK SET", \ 203 /* D */ "Reserved", \ 204 /* E */ "LOGICAL UNIT RESET", \ 205 /* F */ "TARGET RESET" 206