xref: /titanic_41/usr/src/uts/sun/sys/dada/dada_pkt.h (revision 7c2fbfb345896881c631598ee3852ce9ce33fb07)
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 1996, 1999-2000, 2002 Sun Microsystems, Inc.
24  * All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #ifndef	_SYS_DADA_DADA_PKT_H
29 #define	_SYS_DADA_DADA_PKT_H
30 
31 #pragma ident	"%Z%%M%	%I%	%E% SMI"
32 
33 #include <sys/dada/dada_types.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 
40 /*
41  * DCD pkt definition.
42  *
43  *	This structure defined the packet which is allocated by a library
44  *	function and handed to a target driver. The target driver fills
45  *	in some information, and passes it to the library for transport
46  *	to an addressed DCD devices. The host adapter found by the library
47  * 	fills in some other information as the command is processed. When
48  *	the command completes (or can be taken  no further) the function
49  *	specified in the pkt is called with a pointer to the packet as
50  *	argument. For fields within the packet, the target driver can
51  *	determine the success or failure of the command.
52  */
53 
54 
55 struct	dcd_pkt	{
56 	uchar_t		*pkt_cdbp;		/* pointer to command block */
57 	uchar_t		*pkt_scbp;		/* ptr to status block */
58 	int		pkt_flags;		/* Pkt flags */
59 	int		pkt_time;		/* Completion timeout */
60 	int		pkt_scblen;		/* Scb length */
61 	int		pkt_cdblen;		/* Length of cdb */
62 	uint_t		pkt_state;		/* State of command */
63 	uint_t		pkt_statistics;		/* Statistics */
64 	uint_t		pkt_reason;		/* reason or error stat */
65 	uint_t		pkt_secleft;		/* remaining sectors */
66 	void		(*pkt_comp)();		/* Pkt Completion routine */
67 	ssize_t		pkt_resid;		/* bytes not transfered */
68 	daddr32_t	pkt_startsec;		/* Starting sector */
69 	ataopaque_t	pkt_private;		/* Target drivers priV data */
70 	ataopaque_t	pkt_ha_private;		/* HBA private data */
71 	ataopaque_t	pkt_passthru;		/* pass through command ptr */
72 	struct	dcd_address	pkt_address;	/* destination address */
73 	uint_t		version_no;		/* Version Number of this */
74 	ushort_t	reserved[2];		/* Reserved for future */
75 };
76 
77 /*
78  * definition for the pkt_flags field.
79  */
80 
81 /*
82  * Following defines are generic.
83  */
84 
85 #define	FLAG_NOINTR	0x0001	/* Run command with no cmd completion */
86 				/* callback; command has been complted */
87 				/* up return from dcd_transport(9F)   */
88 
89 #define	FLAG_NODICON	0x0002	/* Even is overlap is possible donot do it */
90 #define	FLAG_NOPARITY	0x0008	/* Run command without parity checking */
91 #define	FLAG_FORCENOINTR\
92 			0x0010	/* Force command with to run in polled mode */
93 
94 #define	FLAG_IMMEDIATE_CB\
95 			0x0800	/* Immediate callback on command completion */
96 
97 
98 /*
99  * The following flags are they needed ???
100  */
101 #define	FLAG_SILENT	0x00010000
102 #define	FLAG_DIAGNOSE	0x00020000
103 #define	FLAG_ISOLATE	0x00040000
104 
105 
106 /*
107  * Definitions for pkt_reason field.
108  */
109 
110 /*
111  * Following defines are generic.
112  */
113 #define	CMD_CMPLT	0	/* no transport errors - normal completion */
114 #define	CMD_INCOMPLETE	1	/* transport stopped with not normal state */
115 #define	CMD_DMA_DERR	2	/* dama direction error occurred */
116 #define	CMD_TRAN_ERR	3	/* Unspecified transport error */
117 #define	CMD_RESET	4	/* Target completed hard reset sequence */
118 #define	CMD_ABORTED	5 	/* Command transport aborted on request */
119 #define	CMD_TIMEOUT	6	/* Command timedout */
120 #define	CMD_DATA_OVR	7	/* Data Overrun */
121 #define	CMD_CMD_OVR	8	/* Command Overrun  - Not used */
122 #define	CMD_STS_OVR	9	/* Status Overrun - Not used */
123 #define	CMD_FATAL	10	/* There is a fatal error */
124 
125 
126 /*
127  * definitions for pkt_state field.
128  */
129 #define	STATE_SENT_CMD		0x04	/* Command successsully sent */
130 #define	STATE_XFERRED_DATA	0x08	/* Data Transfer took place */
131 #define	STATE_GOT_STATUS	0x10	/* Status got */
132 
133 
134 /*
135  * Definitions for pkt_statistics field
136  */
137 
138 /*
139  * Following defines are generic.
140  */
141 
142 #define	STAT_ATA_BUS_RESET	0x08	/* TBD */
143 #define	STAT_ATA_DEV_RESET	0x10	/* TBD */
144 #define	STAT_ATA_ABORTED	0x20	/* Command was aborted */
145 #define	STAT_ATA_TERMINATED 	0x80	/* Command was terminated */
146 #define	STAT_ATA_TIMEOUT	0x40	/* Command experienced a timeout */
147 
148 
149 /*
150  * Following filds are appropriate depending on feature used.
151  */
152 #define	STAT_ATA_DISCON	0x01	/* Command is doing overlap processing */
153 #define	STAT_ATA_SYNC	0x02	/* May be used for DMA transfers */
154 #define	STAT_ATA_PERR	0x04	/* Command experienced a parity error */
155 
156 
157 /*
158  * Definitions for what dcd_transport returns
159  */
160 #define	TRAN_ACCEPT	1
161 #define	TRAN_BUSY	0
162 #define	TRAN_BADPKT	-1
163 #define	TRAN_FATAL_ERROR -2	/* The hba cannot accept any pkt */
164 
165 
166 #ifdef _KERNEL
167 /*
168  * Kernel function declarations
169  */
170 
171 #define	ata_pkt_transport	dcd_transport
172 
173 #ifdef	__STDC__
174 extern int dcd_transport(struct dcd_pkt *);
175 #else	/* __STDC__ */
176 extern int dcd_transport();
177 #endif	/* __STDC__ */
178 
179 #define	DCD_POLL_TIMEOUT	60
180 
181 #endif	/* _KERNEL */
182 
183 #ifdef	__cplusplus
184 }
185 #endif
186 
187 #endif	/* _SYS_DADA_DADA_PKT_H */
188