Print this page
OS-61 Need ability for fault injection in mptsas
OS-62 slow io error detector is needed.
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/scsi/scsi_pkt.h
+++ new/usr/src/uts/common/sys/scsi/scsi_pkt.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
|
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 + *
25 + * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
24 26 */
25 27
26 28 #ifndef _SYS_SCSI_SCSI_PKT_H
27 29 #define _SYS_SCSI_SCSI_PKT_H
28 30
29 31 #include <sys/scsi/scsi_types.h>
30 32
31 33 #ifdef __cplusplus
32 34 extern "C" {
33 35 #endif
34 36
35 37 #ifdef _KERNEL
36 38 /*
37 39 * SCSI packet definition.
38 40 *
39 41 * This structure defines the packet which is allocated by a library
40 42 * function and handed to a target driver. The target driver fills
41 43 * in some information, and passes it to the library for transport
42 44 * to an addressed SCSI device. The host adapter found by
43 45 * the library fills in some other information as the command is
44 46 * processed. When the command completes (or can be taken no further)
45 47 * the function specified in the packet is called with a pointer to
46 48 * the packet as it argument. From fields within the packet, the target
47 49 * driver can determine the success or failure of the command.
48 50 */
49 51 struct scsi_pkt {
50 52 opaque_t pkt_ha_private; /* private data for host adapter */
51 53 struct scsi_address pkt_address; /* destination packet is for */
52 54 opaque_t pkt_private; /* private data for target driver */
53 55 void (*pkt_comp)(struct scsi_pkt *); /* completion routine */
54 56 uint_t pkt_flags; /* flags */
55 57 int pkt_time; /* time allotted to complete command */
56 58 uchar_t *pkt_scbp; /* pointer to status block */
57 59 uchar_t *pkt_cdbp; /* pointer to command block */
58 60 ssize_t pkt_resid; /* data bytes not transferred */
59 61 uint_t pkt_state; /* state of command */
60 62 uint_t pkt_statistics; /* statistics */
61 63 uchar_t pkt_reason; /* reason completion called */
62 64
63 65 /*
64 66 * The DDI does not allow a driver to allocate it's own scsi_pkt(9S),
65 67 * a driver should not have *any* compiled in dependencies on
66 68 * "sizeof (struct scsi_pkt)". If the driver has such dependencies, it
67 69 * limits SCSA's ability to evolve. The proper way for an HBA to
68 70 * allocate a scsi_pkt is via scsi_hba_pkt_alloc(9F), or the newer
69 71 * tran_setup_pkt(9E) interfaces. Allocation rules have been in place
70 72 * for many years, unfortunately a significant number of drivers
71 73 * are still broken.
72 74 *
73 75 * NB: Until we can trust drivers to follow DDI scsi_pkt(9S) allocation
74 76 * rules, access to all fields below require special consideration.
75 77 * Access to these fields is limited to code paths that 'know' correct
76 78 * scsi_pkt allocation interfaces must have been used. This means that
77 79 * any target driver access to these fields is suspect, since a target
78 80 * knows nothing about how an HBA drivers performs scsi_pkt allocation.
79 81 *
80 82 * NB: A private scsi_pkt_size() interface has been added to simplify
81 83 * 'fixing' legacy HBA drivers. Use of scsi_pkt_size() is only
82 84 * appropriate when the effort/cost of fixing a legacy driver to use
83 85 * proper DDI scsi_pkt allocation interfaces is too great given the
84 86 * remaining driver life. New HBA drivers should *not* use
85 87 * scsi_pkt_size().
86 88 *
87 89 * NB: While HBA drivers with violations are being fixed, in
88 90 * rare cases access conditioned by scsi_pkt_allocated_correctly() is
89 91 * permitted.
90 92 */
91 93 /* HBA driver only, iff scsi_hba_pkt_alloc(9F)|tran_seup_pkt(9E) used */
92 94 uint_t pkt_cdblen; /* length of pkt_cdbp */
93 95 uint_t pkt_tgtlen; /* length of pkt_private */
94 96 uint_t pkt_scblen; /* lenght of pkt_scbp */
95 97
96 98 /* HBA driver only, iff tran_seup_pkt(9E) used */
97 99 ddi_dma_handle_t pkt_handle; /* private */
98 100 uint_t pkt_numcookies; /* number of DMA cookies */
|
↓ open down ↓ |
65 lines elided |
↑ open up ↑ |
99 101 off_t pkt_dma_offset; /* private */
100 102 size_t pkt_dma_len; /* private */
101 103 uint_t pkt_dma_flags; /* DMA flags */
102 104 ddi_dma_cookie_t *pkt_cookies; /* array of DMA cookies */
103 105
104 106 /* private: iff scsi_pkt_allocated_correctly() */
105 107 int pkt_path_instance; /* pHCI transport path */
106 108
107 109 /* stage-temporary: iff scsi_pkt_allocated_correctly() */
108 110 void *pkt_stmp; /* temporary for current pkt stage */
111 + hrtime_t pkt_start;
112 + hrtime_t pkt_stop;
109 113
110 114 #ifdef SCSI_SIZE_CLEAN_VERIFY
111 115 /*
112 116 * Must be last: Building a driver with-and-without
113 117 * -DSCSI_SIZE_CLEAN_VERIFY, and checking driver modules for
114 118 * differences with a tools like 'wsdiff' allows a developer to verify
115 119 * that their driver has no dependencies on scsi*(9S) size.
116 120 */
117 121 int i_pkt_pad[8];
118 122 #endif /* SCSI_SIZE_CLEAN_VERIFY */
119 123 };
120 124 #endif /* _KERNEL */
121 125
122 126 /*
123 127 * Definitions for the pkt_flags field.
124 128 */
125 129
126 130 /*
127 131 * Following defines are generic.
128 132 */
129 133 #define FLAG_STAG 0x4000 /* Run command with Simple attribute */
130 134 #define FLAG_OTAG 0x2000 /* Run command with Ordered attribute */
131 135 #define FLAG_HTAG 0x1000 /* Run command with Head of Queue attribute */
132 136 #define FLAG_TAGMASK (FLAG_HTAG|FLAG_OTAG|FLAG_STAG)
133 137
134 138 #define FLAG_ACA 0x0100 /* internal; do not use */
135 139 #define FLAG_HEAD 0x8000 /* This cmd should be put at the head */
136 140 /* of the HBA driver's queue */
137 141 #define FLAG_SENSING 0x0400 /* Running request sense for failed pkt */
138 142 #define FLAG_NOINTR 0x0001 /* Run command with no cmd completion */
139 143 /* callback; command has been completed */
140 144 /* upon return from scsi_transport(9F) */
141 145
142 146 /*
143 147 * Following defines are appropriate for SCSI parallel bus.
144 148 */
145 149 #define FLAG_NODISCON 0x0002 /* Run command without disconnects */
146 150 #define FLAG_NOPARITY 0x0008 /* Run command without parity checking */
147 151 #define FLAG_RENEGOTIATE_WIDE_SYNC \
148 152 0x1000000 /* Do wide and sync renegotiation before */
149 153 /* transporting this command to target */
150 154
151 155 /*
152 156 * Following defines are internal i.e. not part of DDI.
153 157 */
154 158 #define FLAG_IMMEDIATE_CB \
155 159 0x0800 /* Immediate callback on command */
156 160 /* completion, ie. do not defer */
157 161
158 162 /*
159 163 * Following defines are for USCSI options.
160 164 */
161 165 #define FLAG_SILENT 0x00010000
162 166 #define FLAG_DIAGNOSE 0x00020000
163 167 #define FLAG_ISOLATE 0x00040000
164 168
165 169 /*
166 170 * pkg_flag for TLR
167 171 */
168 172 #define FLAG_TLR 0x00080000
169 173
170 174
171 175 /*
172 176 * Following define is for scsi_vhci.
173 177 * NOQUEUE If pHCI cannot transport the command to the device,
174 178 * do not queue the pkt in pHCI. Return immediately with
175 179 * TRAN_BUSY.
|
↓ open down ↓ |
57 lines elided |
↑ open up ↑ |
176 180 * PATH_INSTANCE Select specific path (pkt_path_instance).
177 181 * We need both a pkt_path_instance field and flag bit so
178 182 * that a retry after a path failure, which sets
179 183 * pkt_path_instance to failed path, does not select the
180 184 * failed path.
181 185 */
182 186 #define FLAG_NOQUEUE 0x80000000
183 187 #define FLAG_PKT_PATH_INSTANCE 0x40000000 /* Tell vhci the path to use */
184 188 #define FLAG_PKT_COMP_CALLED 0x20000000 /* Set once pkt_comp called */
185 189
190 +/* Extended flags. */
191 +#define FLAG_PKT_BUSY 0x04000000 /* Reject packet immediately. */
192 +#define FLAG_PKT_TIMEOUT 0x08000000 /* Timed-out packet. */
193 +
186 194 /*
187 195 * Definitions for the pkt_reason field.
188 196 */
189 197
190 198 /*
191 199 * Following defines are generic.
192 200 */
193 201 #define CMD_CMPLT 0 /* no transport errors- normal completion */
194 202 #define CMD_INCOMPLETE 1 /* transport stopped with not normal state */
195 203 #define CMD_DMA_DERR 2 /* dma direction error occurred */
196 204 #define CMD_TRAN_ERR 3 /* unspecified transport error */
197 205 #define CMD_RESET 4 /* Target completed hard reset sequence */
198 206 #define CMD_ABORTED 5 /* Command transport aborted on request */
199 207 #define CMD_TIMEOUT 6 /* Command timed out */
200 208 #define CMD_DATA_OVR 7 /* Data Overrun */
201 209 #define CMD_CMD_OVR 8 /* Command Overrun */
202 210 #define CMD_STS_OVR 9 /* Status Overrun */
203 211 #define CMD_TERMINATED 22 /* Command transport terminated on request */
204 212 #define CMD_TLR_OFF 23 /* don't support TLR */
205 213
206 214 /*
207 215 * Following defines are appropriate for SCSI parallel bus.
208 216 */
209 217 #define CMD_BADMSG 10 /* Message not Command Complete */
210 218 #define CMD_NOMSGOUT 11 /* Target refused to go to Message Out phase */
211 219 #define CMD_XID_FAIL 12 /* Extended Identify message rejected */
212 220 #define CMD_IDE_FAIL 13 /* Initiator Detected Error message rejected */
213 221 #define CMD_ABORT_FAIL 14 /* Abort message rejected */
214 222 #define CMD_REJECT_FAIL 15 /* Reject message rejected */
215 223 #define CMD_NOP_FAIL 16 /* No Operation message rejected */
216 224 #define CMD_PER_FAIL 17 /* Message Parity Error message rejected */
217 225 #define CMD_BDR_FAIL 18 /* Bus Device Reset message rejected */
218 226 #define CMD_ID_FAIL 19 /* Identify message rejected */
219 227 #define CMD_UNX_BUS_FREE 20 /* Unexpected Bus Free Phase occurred */
220 228 #define CMD_TAG_REJECT 21 /* Target rejected our tag message */
221 229 #define CMD_DEV_GONE 24 /* The device has been removed */
222 230
223 231 /* Used by scsi_rname(9F) */
224 232 #define CMD_REASON_ASCII { \
225 233 "cmplt", "incomplete", "dma_derr", "tran_err", "reset", \
226 234 "aborted", "timeout", "data_ovr", "cmd_ovr", "sts_ovr", \
227 235 "badmsg", "nomsgout", "xid_fail", "ide_fail", "abort_fail", \
228 236 "reject_fail", "nop_fail", "per_fail", "bdr_fail", "id_fail", \
229 237 "unexpected_bus_free", "tag reject", "terminated", "", "gone", \
230 238 NULL }
231 239
232 240 /*
233 241 * Definitions for the pkt_state field
234 242 */
235 243 #define STATE_GOT_BUS 0x01 /* Success in getting SCSI bus */
236 244 #define STATE_GOT_TARGET 0x02 /* Successfully connected with target */
237 245 #define STATE_SENT_CMD 0x04 /* Command successfully sent */
238 246 #define STATE_XFERRED_DATA 0x08 /* Data transfer took place */
239 247 #define STATE_GOT_STATUS 0x10 /* SCSI status received */
240 248 #define STATE_ARQ_DONE 0x20 /* auto rqsense took place */
241 249 #define STATE_XARQ_DONE 0X40 /* extra auto rqsense took place */
242 250
243 251 /*
244 252 * Definitions for the pkt_statistics field
245 253 */
246 254
247 255 /*
248 256 * Following defines are generic.
249 257 */
250 258 #define STAT_BUS_RESET 0x8 /* Reset operation on interconnect */
251 259 #define STAT_DEV_RESET 0x10 /* Target completed hard reset sequence */
252 260 #define STAT_ABORTED 0x20 /* Command was aborted */
253 261 #define STAT_TERMINATED 0x80 /* Command was terminated */
254 262 #define STAT_TIMEOUT 0x40 /* Command experienced a timeout */
255 263
256 264 /*
257 265 * Following defines are appropriate for SCSI parallel bus.
258 266 */
259 267 #define STAT_DISCON 0x1 /* Command experienced a disconnect */
260 268 #define STAT_SYNC 0x2 /* Command did a synchronous data transfer */
261 269 #define STAT_PERR 0x4 /* Command experienced a SCSI parity error */
262 270
263 271 /*
264 272 * Definitions for what scsi_transport returns
265 273 */
266 274 #define TRAN_ACCEPT 1
267 275 #define TRAN_BUSY 0
268 276 #define TRAN_BADPKT -1
269 277 #define TRAN_FATAL_ERROR -2 /* HBA cannot accept any pkts */
270 278
271 279 #ifdef _KERNEL
272 280 /*
273 281 * Kernel function declarations
274 282 */
275 283 int scsi_transport(struct scsi_pkt *pkt);
276 284
277 285 #define pkt_transport scsi_transport
278 286
279 287 #define SCSI_POLL_TIMEOUT 60
280 288
281 289 #endif /* _KERNEL */
282 290
283 291 #ifdef __cplusplus
284 292 }
285 293 #endif
286 294
287 295 #endif /* _SYS_SCSI_SCSI_PKT_H */
|
↓ open down ↓ |
92 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX