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