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