1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_1394_CMD1394_H 28 #define _SYS_1394_CMD1394_H 29 30 /* 31 * cmd1394.h 32 * Contains the enums, command structures, and error codes used with 33 * the 1394 Framework's t1394_read(), t1394_write(), and t1394_lock() 34 * interfaces. 35 * For outgoing (Asynchronous Transmit - AT) commands, target drivers 36 * allocate a command using t1394_alloc_cmd(), fill it in with the 37 * transmit info, and send it using one of t1394_read(), t1394_write(), 38 * of t1394_lock(). 39 * The target driver can choose whether to get a callback when the 40 * command completes, block until it completes, or poll on the return 41 * status in the command. 42 * For incoming (Asynchronous Receive - AR) requests, the same command 43 * structure is used and most of the information has the same or a 44 * similar meaning to what it does on the AT side. The major differences 45 * are that nodeID indicates the node from which the command was sent 46 * and broadcast informs a target driver whether the incoming request 47 * was broadcast to everyone. 48 */ 49 50 #include <sys/types.h> 51 #include <sys/stream.h> 52 #include <sys/note.h> 53 54 #include <sys/1394/s1394_impl.h> 55 56 #ifdef __cplusplus 57 extern "C" { 58 #endif 59 60 /* 61 * cmd1394_cmd.cmd_type 62 * Used to select/indicate the request packet type 63 */ 64 typedef enum { 65 CMD1394_ASYNCH_RD_QUAD = 0, 66 CMD1394_ASYNCH_WR_QUAD = 1, 67 CMD1394_ASYNCH_RD_BLOCK = 2, 68 CMD1394_ASYNCH_WR_BLOCK = 3, 69 CMD1394_ASYNCH_LOCK_32 = 4, 70 CMD1394_ASYNCH_LOCK_64 = 5 71 } cmd1394_cmd_type_t; 72 73 /* 74 * cmd1394_cmd.flags 75 * Used to select the request's behavior, including 76 * how the destination address is determined, how 77 * a large request will be broken into smaller requests, 78 * whether the command should be resent after a 79 * bus reset has happened, etc. 80 */ 81 typedef enum { 82 CMD1394_CANCEL_ON_BUS_RESET = (1 << 0), 83 CMD1394_OVERRIDE_ADDR = (1 << 1), 84 CMD1394_OVERRIDE_MAX_PAYLOAD = (1 << 2), 85 CMD1394_DISABLE_ADDR_INCREMENT = (1 << 3), 86 CMD1394_BLOCKING = (1 << 4), 87 CMD1394_OVERRIDE_SPEED = (1 << 5) 88 } cmd1394_flags_t; 89 90 /* 91 * cmd1394_cmd.arg.l.lock_type 92 * Used to select/indicate the type of lock operation 93 * in the request. Some are supported by the 1394 spec 94 * others (0x10000+) are supported locally in software. 95 */ 96 typedef enum { 97 /* Reserved = 0x0000 */ 98 CMD1394_LOCK_MASK_SWAP = 0x0001, 99 CMD1394_LOCK_COMPARE_SWAP = 0x0002, 100 CMD1394_LOCK_FETCH_ADD = 0x0003, 101 CMD1394_LOCK_LITTLE_ADD = 0x0004, 102 CMD1394_LOCK_BOUNDED_ADD = 0x0005, 103 CMD1394_LOCK_WRAP_ADD = 0x0006, 104 /* Vendor-Defined = 0x0007 */ 105 /* Reserved = 0x0008 - 0xFFFF */ 106 107 CMD1394_LOCK_BIT_AND = 0x10000, 108 CMD1394_LOCK_BIT_OR = 0x10001, 109 CMD1394_LOCK_BIT_XOR = 0x10002, 110 CMD1394_LOCK_INCREMENT = 0x10003, 111 CMD1394_LOCK_DECREMENT = 0x10004, 112 CMD1394_LOCK_ADD = 0x10005, 113 CMD1394_LOCK_SUBTRACT = 0x10006, 114 CMD1394_LOCK_THRESH_ADD = 0x10007, 115 CMD1394_LOCK_THRESH_SUBTRACT = 0x10008, 116 CMD1394_LOCK_CLIP_ADD = 0x10009, 117 CMD1394_LOCK_CLIP_SUBTRACT = 0x1000A 118 } cmd1394_lock_type_t; 119 120 /* Asynchronous Command (Data Quadlet) */ 121 typedef struct cmd1394_quadlet { 122 uint32_t quadlet_data; 123 } cmd1394_quadlet_t; 124 125 /* Asynchronous Command (Data Block) */ 126 typedef struct cmd1394_block { 127 mblk_t *data_block; 128 size_t blk_length; 129 size_t bytes_transferred; 130 uint_t max_payload; 131 } cmd1394_block_t; 132 133 /* Asynchronous Command (Lock Cmd - 32 bit) */ 134 typedef struct cmd1394_lock32 { 135 uint32_t old_value; 136 uint32_t data_value; 137 uint32_t arg_value; 138 uint_t num_retries; 139 cmd1394_lock_type_t lock_type; 140 } cmd1394_lock32_t; 141 142 /* Asynchronous Command (Lock Cmd - 64 bit) */ 143 typedef struct cmd1394_lock64 { 144 uint64_t old_value; 145 uint64_t data_value; 146 uint64_t arg_value; 147 uint_t num_retries; 148 cmd1394_lock_type_t lock_type; 149 } cmd1394_lock64_t; 150 151 /* cmd1394_cmd: cmd1394 - common command type */ 152 typedef struct cmd1394_cmd 153 { 154 int cmd_version; 155 volatile int cmd_result; 156 cmd1394_flags_t cmd_options; 157 cmd1394_cmd_type_t cmd_type; 158 void (*completion_callback)(struct cmd1394_cmd *); 159 opaque_t cmd_callback_arg; 160 uint64_t cmd_addr; 161 uint_t cmd_speed; 162 uint_t bus_generation; 163 uint_t nodeID; 164 uint_t broadcast; 165 union { 166 cmd1394_quadlet_t q; 167 cmd1394_block_t b; 168 cmd1394_lock32_t l32; 169 cmd1394_lock64_t l64; 170 } cmd_u; 171 } cmd1394_cmd_t; 172 173 /* 174 * NOTE: Make sure CMD1394_ERR_LAST is updated if a new error code is 175 * added. t1394_errmsg.c uses *FIRST and *LAST as bounds checks. 176 */ 177 /* cmd1394_cmd.result - Immediate failures (with DDI_FAILURE) */ 178 #define CMD1394_ENULL_MBLK (-10) 179 #define CMD1394_EMBLK_TOO_SMALL (-11) 180 #define CMD1394_ESTALE_GENERATION (-12) 181 #define CMD1394_EDEVICE_REMOVED (-13) 182 #define CMD1394_EINVALID_CONTEXT (-14) 183 #define CMD1394_EINVALID_COMMAND (-15) 184 #define CMD1394_EUNKNOWN_ERROR (-16) 185 #define CMD1394_NOSTATUS (-17) 186 #define CMD1394_EFATAL_ERROR (-18) 187 #define CMD1394_ENO_ATREQ (-19) 188 #define CMD1394_EDEVICE_ERROR (-20) /* bad tcode or ack or... */ 189 190 /* cmd1394_cmd.result - Returned with completion_callback */ 191 #define CMD1394_CMDSUCCESS (0) 192 #define CMD1394_EDEVICE_BUSY (-30) 193 #define CMD1394_ERETRIES_EXCEEDED (-31) 194 #define CMD1394_ETYPE_ERROR (-32) 195 #define CMD1394_EDATA_ERROR (-33) 196 #define CMD1394_EBUSRESET (-34) 197 #define CMD1394_EADDRESS_ERROR (-35) 198 #define CMD1394_ETIMEOUT (-36) 199 #define CMD1394_ERSRC_CONFLICT (-37) 200 201 #define CMD1394_ERR_FIRST CMD1394_CMDSUCCESS 202 #define CMD1394_ERR_LAST CMD1394_ERSRC_CONFLICT 203 204 /* Warlock directives for cmd1394 */ 205 206 _NOTE(SCHEME_PROTECTS_DATA("One per call", cmd1394_cmd_t)) 207 208 #ifdef __cplusplus 209 } 210 #endif 211 212 #endif /* _SYS_1394_CMD1394_H */ 213