xref: /openbsd/sys/scsi/scsiconf.h (revision 264ca280)
1 /*	$OpenBSD: scsiconf.h,v 1.164 2016/03/10 13:56:14 krw Exp $	*/
2 /*	$NetBSD: scsiconf.h,v 1.35 1997/04/02 02:29:38 mycroft Exp $	*/
3 
4 /*
5  * Copyright (c) 1993, 1994, 1995 Charles Hannum.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *	This product includes software developed by Charles Hannum.
18  * 4. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 /*
34  * Originally written by Julian Elischer (julian@tfs.com)
35  * for TRW Financial Systems for use under the MACH(2.5) operating system.
36  *
37  * TRW Financial Systems, in accordance with their agreement with Carnegie
38  * Mellon University, makes this software available to CMU to distribute
39  * or use in any manner that they see fit as long as this message is kept with
40  * the software. For this reason TFS also grants any other persons or
41  * organisations permission to use or modify this software.
42  *
43  * TFS supplies this software to be publicly redistributed
44  * on the understanding that TFS is not responsible for the correct
45  * functioning of this software in any circumstances.
46  *
47  * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
48  */
49 
50 #ifndef	SCSI_SCSICONF_H
51 #define SCSI_SCSICONF_H
52 
53 #include <sys/queue.h>
54 #include <sys/timeout.h>
55 #include <sys/mutex.h>
56 #include <scsi/scsi_debug.h>
57 
58 static __inline void _lto2b(u_int32_t val, u_int8_t *bytes);
59 static __inline void _lto3b(u_int32_t val, u_int8_t *bytes);
60 static __inline void _lto4b(u_int32_t val, u_int8_t *bytes);
61 static __inline void _lto8b(u_int64_t val, u_int8_t *bytes);
62 static __inline u_int32_t _2btol(u_int8_t *bytes);
63 static __inline u_int32_t _3btol(u_int8_t *bytes);
64 static __inline u_int32_t _4btol(u_int8_t *bytes);
65 static __inline u_int64_t _5btol(u_int8_t *bytes);
66 static __inline u_int64_t _8btol(u_int8_t *bytes);
67 
68 static __inline void
69 _lto2b(u_int32_t val, u_int8_t *bytes)
70 {
71 
72 	bytes[0] = (val >> 8) & 0xff;
73 	bytes[1] = val & 0xff;
74 }
75 
76 static __inline void
77 _lto3b(u_int32_t val, u_int8_t *bytes)
78 {
79 
80 	bytes[0] = (val >> 16) & 0xff;
81 	bytes[1] = (val >> 8) & 0xff;
82 	bytes[2] = val & 0xff;
83 }
84 
85 static __inline void
86 _lto4b(u_int32_t val, u_int8_t *bytes)
87 {
88 
89 	bytes[0] = (val >> 24) & 0xff;
90 	bytes[1] = (val >> 16) & 0xff;
91 	bytes[2] = (val >> 8) & 0xff;
92 	bytes[3] = val & 0xff;
93 }
94 
95 static __inline void
96 _lto8b(u_int64_t val, u_int8_t *bytes)
97 {
98 
99 	bytes[0] = (val >> 56) & 0xff;
100 	bytes[1] = (val >> 48) & 0xff;
101 	bytes[2] = (val >> 40) & 0xff;
102 	bytes[3] = (val >> 32) & 0xff;
103 	bytes[4] = (val >> 24) & 0xff;
104 	bytes[5] = (val >> 16) & 0xff;
105 	bytes[6] = (val >> 8) & 0xff;
106 	bytes[7] = val & 0xff;
107 }
108 
109 static __inline u_int32_t
110 _2btol(u_int8_t *bytes)
111 {
112 	u_int32_t rv;
113 
114 	rv = (bytes[0] << 8) | bytes[1];
115 	return (rv);
116 }
117 
118 static __inline u_int32_t
119 _3btol(u_int8_t *bytes)
120 {
121 	u_int32_t rv;
122 
123 	rv = (bytes[0] << 16) | (bytes[1] << 8) | bytes[2];
124 	return (rv);
125 }
126 
127 static __inline u_int32_t
128 _4btol(u_int8_t *bytes)
129 {
130 	u_int32_t rv;
131 
132 	rv = (bytes[0] << 24) | (bytes[1] << 16) |
133 	    (bytes[2] << 8) | bytes[3];
134 	return (rv);
135 }
136 
137 static __inline u_int64_t
138 _5btol(u_int8_t *bytes)
139 {
140 	u_int64_t rv;
141 
142 	rv = ((u_int64_t)bytes[0] << 32) |
143 	     ((u_int64_t)bytes[1] << 24) |
144 	     ((u_int64_t)bytes[2] << 16) |
145 	     ((u_int64_t)bytes[3] << 8) |
146 	     (u_int64_t)bytes[4];
147 	return (rv);
148 }
149 
150 static __inline u_int64_t
151 _8btol(u_int8_t *bytes)
152 {
153 	u_int64_t rv;
154 
155 	rv = (((u_int64_t)bytes[0]) << 56) |
156 	    (((u_int64_t)bytes[1]) << 48) |
157 	    (((u_int64_t)bytes[2]) << 40) |
158 	    (((u_int64_t)bytes[3]) << 32) |
159 	    (((u_int64_t)bytes[4]) << 24) |
160 	    (((u_int64_t)bytes[5]) << 16) |
161 	    (((u_int64_t)bytes[6]) << 8) |
162 	    ((u_int64_t)bytes[7]);
163 	return (rv);
164 }
165 
166 #ifdef _KERNEL
167 
168 #define DEVID_NONE	0
169 #define DEVID_NAA	1
170 #define DEVID_EUI	2
171 #define DEVID_T10	3
172 #define DEVID_SERIAL	4
173 #define DEVID_WWN	5
174 
175 struct devid {
176 	u_int8_t	d_type;
177 	u_int8_t	d_flags;
178 #define DEVID_F_PRINT		(1<<0)
179 	u_int8_t	d_refcount;
180 	u_int8_t	d_len;
181 
182 	/*
183 	 * the devid struct is basically a header, the actual id is allocated
184 	 * immediately after it.
185 	 */
186 };
187 
188 #define DEVID_CMP(_a, _b) (					\
189 	(_a) != NULL && (_b) != NULL &&				\
190 	((_a) == (_b) ||					\
191 	((_a)->d_type != DEVID_NONE &&				\
192 	 (_a)->d_type == (_b)->d_type &&			\
193 	 (_a)->d_len == (_b)->d_len &&				\
194 	 bcmp((_a) + 1, (_b) + 1, (_a)->d_len) == 0))		\
195 )
196 
197 struct devid *	devid_alloc(u_int8_t, u_int8_t, u_int8_t, u_int8_t *);
198 struct devid *	devid_copy(struct devid *);
199 void		devid_free(struct devid *);
200 
201 /*
202  * The following documentation tries to describe the relationship between the
203  * various structures defined in this file:
204  *
205  * each adapter type has a scsi_adapter struct. This describes the adapter and
206  *    identifies routines that can be called to use the adapter.
207  * each existing device position (scsibus + target + lun)
208  *    can be described by a scsi_link struct.
209  *    Only scsi positions that actually have devices, have a scsi_link
210  *    structure assigned. so in effect each device has scsi_link struct.
211  *    The scsi_link structure contains information identifying both the
212  *    device driver and the adapter driver for that position on that scsi bus,
213  *    and can be said to 'link' the two.
214  * each individual scsi bus has an array that points to all the scsi_link
215  *    structs associated with that scsi bus. Slots with no device have
216  *    a NULL pointer.
217  * each individual device also knows the address of its own scsi_link
218  *    structure.
219  *
220  *				-------------
221  *
222  * The key to all this is the scsi_link structure which associates all the
223  * other structures with each other in the correct configuration.  The
224  * scsi_link is the connecting information that allows each part of the
225  * scsi system to find the associated other parts.
226  */
227 
228 struct scsi_xfer;
229 struct scsi_link;
230 struct scsibus_softc;
231 
232 /*
233  * Temporary hack
234  */
235 extern int scsi_autoconf;
236 
237 /*
238  * These entrypoints are called by the high-end drivers to get services from
239  * whatever low-end drivers they are attached to.  Each adapter type has one
240  * of these statically allocated.
241  */
242 struct scsi_adapter {
243 	void		(*scsi_cmd)(struct scsi_xfer *);
244 	void		(*scsi_minphys)(struct buf *, struct scsi_link *);
245 	int		(*dev_probe)(struct scsi_link *);
246 	void		(*dev_free)(struct scsi_link *);
247 	int		(*ioctl)(struct scsi_link *, u_long, caddr_t, int);
248 };
249 
250 struct scsi_iopool;
251 
252 struct scsi_iohandler {
253 	TAILQ_ENTRY(scsi_iohandler) q_entry;
254 	u_int q_state;
255 
256 	struct scsi_iopool *pool;
257 	void (*handler)(void *, void *);
258 	void *cookie;
259 };
260 TAILQ_HEAD(scsi_runq, scsi_iohandler);
261 
262 struct scsi_iopool {
263 	/* access to the IOs */
264 	void	*iocookie;
265 	void	*(*io_get)(void *);
266 	void	 (*io_put)(void *, void *);
267 
268 	/* the runqueue */
269 	struct scsi_runq queue;
270 	/* runqueue semaphore */
271 	u_int running;
272 	/* protection for the runqueue and its semaphore */
273 	struct mutex mtx;
274 };
275 
276 struct scsi_xshandler {
277 	struct scsi_iohandler ioh; /* must be first */
278 
279 	struct scsi_link *link;
280 	void (*handler)(struct scsi_xfer *);
281 };
282 
283 /*
284  * This structure describes the connection between an adapter driver and
285  * a device driver, and is used by each to call services provided by
286  * the other, and to allow generic scsi glue code to call these services
287  * as well.
288  */
289 struct scsi_link {
290 	SLIST_ENTRY(scsi_link)	bus_list;
291 
292 	u_int		state;
293 #define SDEV_S_WAITING		(1<<0)
294 #define SDEV_S_DYING		(1<<1)
295 
296 	u_int8_t scsibus;		/* the Nth scsibus */
297 	u_int8_t luns;
298 	u_int16_t target;		/* targ of this dev */
299 	u_int16_t lun;			/* lun of this dev */
300 	u_int16_t openings;		/* available operations */
301 	u_int64_t port_wwn;		/* world wide name of port */
302 	u_int64_t node_wwn;		/* world wide name of node */
303 	u_int16_t adapter_target;	/* what are we on the scsi bus */
304 	u_int16_t adapter_buswidth;	/* 8 (regular) or 16 (wide). (0 becomes 8) */
305 	u_int16_t flags;		/* flags that all devices have */
306 #define	SDEV_REMOVABLE		0x0001	/* media is removable */
307 #define	SDEV_MEDIA_LOADED	0x0002	/* device figures are still valid */
308 #define	SDEV_READONLY		0x0004	/* device is read-only */
309 #define	SDEV_OPEN		0x0008	/* at least 1 open session */
310 #define	SDEV_DBX		0x00f0	/* debugging flags (scsi_debug.h) */
311 #define	SDEV_EJECTING		0x0100	/* eject on device close */
312 #define	SDEV_ATAPI		0x0200	/* device is ATAPI */
313 #define	SDEV_2NDBUS		0x0400	/* device is a 'second' bus device */
314 #define SDEV_UMASS		0x0800	/* device is UMASS SCSI */
315 #define SDEV_VIRTUAL		0x1000	/* device is virtualised on the hba */
316 #define SDEV_OWN_IOPL		0x2000	/* scsibus */
317 	u_int16_t quirks;		/* per-device oddities */
318 #define	SDEV_AUTOSAVE		0x0001	/* do implicit SAVEDATAPOINTER on disconnect */
319 #define	SDEV_NOSYNC		0x0002	/* does not grok SDTR */
320 #define	SDEV_NOWIDE		0x0004	/* does not grok WDTR */
321 #define	SDEV_NOTAGS		0x0008	/* lies about having tagged queueing */
322 #define	SDEV_NOSYNCCACHE	0x0100	/* no SYNCHRONIZE_CACHE */
323 #define	ADEV_NOSENSE		0x0200	/* No request sense - ATAPI */
324 #define	ADEV_LITTLETOC		0x0400	/* little-endian TOC - ATAPI */
325 #define	ADEV_NOCAPACITY		0x0800	/* no READ CD CAPACITY */
326 #define	ADEV_NODOORLOCK		0x2000	/* can't lock door */
327 #define SDEV_ONLYBIG		0x4000  /* always use READ_BIG and WRITE_BIG */
328 	int	(*interpret_sense)(struct scsi_xfer *);
329 	void	*device_softc;		/* needed for call to foo_start */
330 	struct	scsi_adapter *adapter;	/* adapter entry points etc. */
331 	void	*adapter_softc;		/* needed for call to foo_scsi_cmd */
332 	struct	scsibus_softc *bus;	/* link to the scsibus we're on */
333 	struct	scsi_inquiry_data inqdata; /* copy of INQUIRY data from probe */
334 	struct  devid *id;
335 
336 	struct	scsi_runq queue;
337 	u_int	running;
338 	u_short	pending;
339 
340 	struct	scsi_iopool *pool;
341 };
342 
343 int	scsiprint(void *, const char *);
344 
345 /*
346  * This describes matching information for scsi_inqmatch().  The more things
347  * match, the higher the configuration priority.
348  */
349 struct scsi_inquiry_pattern {
350 	u_int8_t type;
351 	int removable;
352 	char *vendor;
353 	char *product;
354 	char *revision;
355 };
356 
357 struct scsibus_attach_args {
358 	struct scsi_link *saa_sc_link;
359 };
360 
361 /*
362  * One of these is allocated and filled in for each scsi bus.
363  * It holds pointers to allow the scsi bus to get to the driver
364  * that is running each LUN on the bus.
365  * It also has a template entry which is the prototype struct
366  * supplied by the adapter driver.  This is used to initialise
367  * the others, before they have the rest of the fields filled in.
368  */
369 struct scsibus_softc {
370 	struct device sc_dev;
371 	struct scsi_link *adapter_link;	/* prototype supplied by adapter */
372 	SLIST_HEAD(, scsi_link) sc_link_list;
373 	u_int16_t sc_buswidth;
374 };
375 
376 /*
377  * This is used to pass information from the high-level configuration code
378  * to the device-specific drivers.
379  */
380 struct scsi_attach_args {
381 	struct scsi_link *sa_sc_link;
382 	struct scsi_inquiry_data *sa_inqbuf;
383 };
384 
385 /*
386  * Each scsi transaction is fully described by one of these structures.
387  * It includes information about the source of the command and also the
388  * device and adapter for which the command is destined.
389  * (via the scsi_link structure)
390  */
391 struct scsi_xfer {
392 	SIMPLEQ_ENTRY(scsi_xfer) xfer_list;
393 	int	flags;
394 	struct	scsi_link *sc_link;	/* all about our device and adapter */
395 	int	retries;		/* the number of times to retry */
396 	int	timeout;		/* in milliseconds */
397 	struct	scsi_generic *cmd;	/* The scsi command to execute */
398 	int	cmdlen;			/* how long it is */
399 	u_char	*data;			/* dma address OR a uio address */
400 	int	datalen;		/* data len (blank if uio)    */
401 	size_t	resid;			/* how much buffer was not touched */
402 	int	error;			/* an error value	*/
403 	struct	buf *bp;		/* If we need to associate with a buf */
404 	struct	scsi_sense_data	sense;	/* 18 bytes*/
405 	u_int8_t status;		/* SCSI status */
406 	struct	scsi_generic cmdstore;	/* stash the command in here */
407 	/*
408 	 * timeout structure for hba's to use for a command
409 	 */
410 	struct timeout stimeout;
411 	void *cookie;
412 	void (*done)(struct scsi_xfer *);
413 
414 	void *io;			/* adapter io resource */
415 };
416 SIMPLEQ_HEAD(scsi_xfer_list, scsi_xfer);
417 
418 /*
419  * Per-request Flag values
420  */
421 #define	SCSI_NOSLEEP	0x00001	/* don't sleep */
422 #define	SCSI_POLL	0x00002	/* poll for completion */
423 #define	SCSI_AUTOCONF	0x00003	/* shorthand for SCSI_POLL | SCSI_NOSLEEP */
424 #define	ITSDONE		0x00008	/* the transfer is as done as it gets	*/
425 #define	SCSI_SILENT	0x00020	/* don't announce NOT READY or MEDIA CHANGE */
426 #define	SCSI_IGNORE_NOT_READY		0x00040	/* ignore NOT READY */
427 #define	SCSI_IGNORE_MEDIA_CHANGE	0x00080	/* ignore MEDIA CHANGE */
428 #define	SCSI_IGNORE_ILLEGAL_REQUEST	0x00100	/* ignore ILLEGAL REQUEST */
429 #define	SCSI_RESET	0x00200	/* Reset the device in question		*/
430 #define	SCSI_DATA_IN	0x00800	/* expect data to come INTO memory	*/
431 #define	SCSI_DATA_OUT	0x01000	/* expect data to flow OUT of memory	*/
432 #define	SCSI_TARGET	0x02000	/* This defines a TARGET mode op.	*/
433 #define	SCSI_ESCAPE	0x04000	/* Escape operation			*/
434 #define	SCSI_PRIVATE	0xf0000	/* private to each HBA flags */
435 
436 /*
437  * Escape op-codes.  This provides an extensible setup for operations
438  * that are not scsi commands.  They are intended for modal operations.
439  */
440 
441 #define SCSI_OP_TARGET	0x0001
442 #define	SCSI_OP_RESET	0x0002
443 #define	SCSI_OP_BDINFO	0x0003
444 
445 /*
446  * Error values an adapter driver may return
447  */
448 #define XS_NOERROR	0	/* there is no error, (sense is invalid)  */
449 #define XS_SENSE	1	/* Check the returned sense for the error */
450 #define	XS_DRIVER_STUFFUP 2	/* Driver failed to perform operation	  */
451 #define XS_SELTIMEOUT	3	/* The device timed out.. turned off?	  */
452 #define XS_TIMEOUT	4	/* The Timeout reported was caught by SW  */
453 #define XS_BUSY		5	/* The device busy, try again later?	  */
454 #define XS_SHORTSENSE   6	/* Check the ATAPI sense for the error */
455 #define XS_RESET	8	/* bus was reset; possible retry command  */
456 #define XS_NO_CCB	9	/* device should requeue io and retry */
457 
458 /*
459  * Possible retries for scsi_test_unit_ready()
460  */
461 #define TEST_READY_RETRIES	5
462 
463 /*
464  * Possible retries for most SCSI commands.
465  */
466 #define SCSI_RETRIES		4
467 
468 const void *scsi_inqmatch(struct scsi_inquiry_data *, const void *, int,
469 	    int, int *);
470 
471 void	scsi_init(void);
472 int	scsi_test_unit_ready(struct scsi_link *, int, int);
473 int	scsi_inquire(struct scsi_link *, struct scsi_inquiry_data *, int);
474 int	scsi_inquire_vpd(struct scsi_link *, void *, u_int, u_int8_t, int);
475 void	scsi_init_inquiry(struct scsi_xfer *, u_int8_t, u_int8_t,
476 	    void *, size_t);
477 int	scsi_prevent(struct scsi_link *, int, int);
478 int	scsi_start(struct scsi_link *, int, int);
479 int	scsi_mode_sense(struct scsi_link *, int, int, struct scsi_mode_header *,
480 	    size_t, int, int);
481 int	scsi_mode_sense_big(struct scsi_link *, int, int,
482 	    struct scsi_mode_header_big *, size_t, int, int);
483 void *	scsi_mode_sense_page(struct scsi_mode_header *, int);
484 void *	scsi_mode_sense_big_page(struct scsi_mode_header_big *, int);
485 int	scsi_do_mode_sense(struct scsi_link *, int,
486 	    union scsi_mode_sense_buf *, void **, u_int32_t *, u_int64_t *,
487 	    u_int32_t *, int, int, int *);
488 int	scsi_mode_select(struct scsi_link *, int, struct scsi_mode_header *,
489 	    int, int);
490 int	scsi_mode_select_big(struct scsi_link *, int,
491 	    struct scsi_mode_header_big *, int, int);
492 void	scsi_done(struct scsi_xfer *);
493 int	scsi_do_ioctl(struct scsi_link *, u_long, caddr_t, int);
494 void	sc_print_addr(struct scsi_link *);
495 int	scsi_report_luns(struct scsi_link *, int,
496 	    struct scsi_report_luns_data *, u_int32_t, int, int);
497 void	scsi_minphys(struct buf *, struct scsi_link *);
498 int	scsi_interpret_sense(struct scsi_xfer *);
499 
500 void	scsi_xs_show(struct scsi_xfer *);
501 void	scsi_print_sense(struct scsi_xfer *);
502 void	scsi_show_mem(u_char *, int);
503 void	scsi_strvis(u_char *, u_char *, int);
504 int	scsi_delay(struct scsi_xfer *, int);
505 
506 int	scsi_probe(struct scsibus_softc *, int, int);
507 int	scsi_probe_bus(struct scsibus_softc *);
508 int	scsi_probe_target(struct scsibus_softc *, int);
509 int	scsi_probe_lun(struct scsibus_softc *, int, int);
510 
511 int	scsi_detach(struct scsibus_softc *, int, int, int);
512 int	scsi_detach_bus(struct scsibus_softc *, int);
513 int	scsi_detach_target(struct scsibus_softc *, int, int);
514 int	scsi_detach_lun(struct scsibus_softc *, int, int, int);
515 
516 int	scsi_req_probe(struct scsibus_softc *, int, int);
517 int	scsi_req_detach(struct scsibus_softc *, int, int, int);
518 
519 int	scsi_activate(struct scsibus_softc *, int, int, int);
520 
521 struct scsi_link *	scsi_get_link(struct scsibus_softc *, int, int);
522 void			scsi_add_link(struct scsibus_softc *,
523 			    struct scsi_link *);
524 void			scsi_remove_link(struct scsibus_softc *,
525 			    struct scsi_link *);
526 
527 extern const u_int8_t version_to_spc[];
528 #define SCSISPC(x)	(version_to_spc[(x) & SID_ANSII])
529 
530 struct scsi_xfer *	scsi_xs_get(struct scsi_link *, int);
531 void			scsi_xs_exec(struct scsi_xfer *);
532 int			scsi_xs_sync(struct scsi_xfer *);
533 void			scsi_xs_put(struct scsi_xfer *);
534 #ifdef SCSIDEBUG
535 void			scsi_sense_print_debug(struct scsi_xfer *);
536 #endif
537 
538 /*
539  * iopool stuff
540  */
541 void	scsi_iopool_init(struct scsi_iopool *, void *,
542 	    void *(*)(void *), void (*)(void *, void *));
543 void	scsi_iopool_run(struct scsi_iopool *);
544 void	scsi_iopool_destroy(struct scsi_iopool *);
545 void	scsi_link_shutdown(struct scsi_link *);
546 
547 void *	scsi_io_get(struct scsi_iopool *, int);
548 void	scsi_io_put(struct scsi_iopool *, void *);
549 
550 /*
551  * default io allocator.
552  */
553 #define SCSI_IOPOOL_POISON ((void *)0x5c5)
554 void *	scsi_default_get(void *);
555 void	scsi_default_put(void *, void *);
556 
557 /*
558  * io handler interface
559  */
560 void	scsi_ioh_set(struct scsi_iohandler *, struct scsi_iopool *,
561 	    void (*)(void *, void *), void *);
562 int	scsi_ioh_add(struct scsi_iohandler *);
563 int	scsi_ioh_del(struct scsi_iohandler *);
564 
565 void	scsi_xsh_set(struct scsi_xshandler *, struct scsi_link *,
566 	    void (*)(struct scsi_xfer *));
567 int	scsi_xsh_add(struct scsi_xshandler *);
568 int	scsi_xsh_del(struct scsi_xshandler *);
569 
570 /*
571  * utility functions
572  */
573 int	scsi_pending_start(struct mutex *, u_int *);
574 int	scsi_pending_finish(struct mutex *, u_int *);
575 
576 /*
577  * Utility functions for SCSI HBA emulation.
578  */
579 void	scsi_cmd_rw_decode(struct scsi_generic *, u_int64_t *, u_int32_t *);
580 
581 #endif /* _KERNEL */
582 #endif /* SCSI_SCSICONF_H */
583