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