xref: /openbsd/sys/scsi/scsiconf.h (revision 17df1aa7)
1 /*	$OpenBSD: scsiconf.h,v 1.124 2010/04/17 00:51:13 dlg 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/workq.h>
56 #include <sys/mutex.h>
57 #include <machine/cpu.h>
58 #include <scsi/scsi_debug.h>
59 
60 static __inline void _lto2b(u_int32_t val, u_int8_t *bytes);
61 static __inline void _lto3b(u_int32_t val, u_int8_t *bytes);
62 static __inline void _lto4b(u_int32_t val, u_int8_t *bytes);
63 static __inline void _lto8b(u_int64_t val, u_int8_t *bytes);
64 static __inline u_int32_t _2btol(u_int8_t *bytes);
65 static __inline u_int32_t _3btol(u_int8_t *bytes);
66 static __inline u_int32_t _4btol(u_int8_t *bytes);
67 static __inline u_int64_t _5btol(u_int8_t *bytes);
68 static __inline u_int64_t _8btol(u_int8_t *bytes);
69 
70 static __inline void _lto2l(u_int32_t val, u_int8_t *bytes);
71 static __inline void _lto3l(u_int32_t val, u_int8_t *bytes);
72 static __inline void _lto4l(u_int32_t val, u_int8_t *bytes);
73 static __inline u_int32_t _2ltol(u_int8_t *bytes);
74 static __inline u_int32_t _3ltol(u_int8_t *bytes);
75 static __inline u_int32_t _4ltol(u_int8_t *bytes);
76 
77 static __inline void
78 _lto2b(u_int32_t val, u_int8_t *bytes)
79 {
80 
81 	bytes[0] = (val >> 8) & 0xff;
82 	bytes[1] = val & 0xff;
83 }
84 
85 static __inline void
86 _lto3b(u_int32_t val, u_int8_t *bytes)
87 {
88 
89 	bytes[0] = (val >> 16) & 0xff;
90 	bytes[1] = (val >> 8) & 0xff;
91 	bytes[2] = val & 0xff;
92 }
93 
94 static __inline void
95 _lto4b(u_int32_t val, u_int8_t *bytes)
96 {
97 
98 	bytes[0] = (val >> 24) & 0xff;
99 	bytes[1] = (val >> 16) & 0xff;
100 	bytes[2] = (val >> 8) & 0xff;
101 	bytes[3] = val & 0xff;
102 }
103 
104 static __inline void
105 _lto8b(u_int64_t val, u_int8_t *bytes)
106 {
107 
108 	bytes[0] = (val >> 56) & 0xff;
109 	bytes[1] = (val >> 48) & 0xff;
110 	bytes[2] = (val >> 40) & 0xff;
111 	bytes[3] = (val >> 32) & 0xff;
112 	bytes[4] = (val >> 24) & 0xff;
113 	bytes[5] = (val >> 16) & 0xff;
114 	bytes[6] = (val >> 8) & 0xff;
115 	bytes[7] = val & 0xff;
116 }
117 
118 static __inline u_int32_t
119 _2btol(u_int8_t *bytes)
120 {
121 	u_int32_t rv;
122 
123 	rv = (bytes[0] << 8) | bytes[1];
124 	return (rv);
125 }
126 
127 static __inline u_int32_t
128 _3btol(u_int8_t *bytes)
129 {
130 	u_int32_t rv;
131 
132 	rv = (bytes[0] << 16) | (bytes[1] << 8) | bytes[2];
133 	return (rv);
134 }
135 
136 static __inline u_int32_t
137 _4btol(u_int8_t *bytes)
138 {
139 	u_int32_t rv;
140 
141 	rv = (bytes[0] << 24) | (bytes[1] << 16) |
142 	    (bytes[2] << 8) | bytes[3];
143 	return (rv);
144 }
145 
146 static __inline u_int64_t
147 _5btol(u_int8_t *bytes)
148 {
149 	u_int64_t rv;
150 
151 	rv = ((u_int64_t)bytes[0] << 32) |
152 	     ((u_int64_t)bytes[1] << 24) |
153 	     ((u_int64_t)bytes[2] << 16) |
154 	     ((u_int64_t)bytes[3] << 8) |
155 	     (u_int64_t)bytes[4];
156 	return (rv);
157 }
158 
159 static __inline u_int64_t
160 _8btol(u_int8_t *bytes)
161 {
162 	u_int64_t rv;
163 
164 	rv = (((u_int64_t)bytes[0]) << 56) |
165 	    (((u_int64_t)bytes[1]) << 48) |
166 	    (((u_int64_t)bytes[2]) << 40) |
167 	    (((u_int64_t)bytes[3]) << 32) |
168 	    (((u_int64_t)bytes[4]) << 24) |
169 	    (((u_int64_t)bytes[5]) << 16) |
170 	    (((u_int64_t)bytes[6]) << 8) |
171 	    ((u_int64_t)bytes[7]);
172 	return (rv);
173 }
174 
175 static __inline void
176 _lto2l(u_int32_t val, u_int8_t *bytes)
177 {
178 
179 	bytes[0] = val & 0xff;
180 	bytes[1] = (val >> 8) & 0xff;
181 }
182 
183 static __inline void
184 _lto3l(u_int32_t val, u_int8_t *bytes)
185 {
186 
187 	bytes[0] = val & 0xff;
188 	bytes[1] = (val >> 8) & 0xff;
189 	bytes[2] = (val >> 16) & 0xff;
190 }
191 
192 static __inline void
193 _lto4l(u_int32_t val, u_int8_t *bytes)
194 {
195 
196 	bytes[0] = val & 0xff;
197 	bytes[1] = (val >> 8) & 0xff;
198 	bytes[2] = (val >> 16) & 0xff;
199 	bytes[3] = (val >> 24) & 0xff;
200 }
201 
202 static __inline u_int32_t
203 _2ltol(u_int8_t *bytes)
204 {
205 	u_int32_t rv;
206 
207 	rv = bytes[0] | (bytes[1] << 8);
208 	return (rv);
209 }
210 
211 static __inline u_int32_t
212 _3ltol(u_int8_t *bytes)
213 {
214 	u_int32_t rv;
215 
216 	rv = bytes[0] | (bytes[1] << 8) | (bytes[2] << 16);
217 	return (rv);
218 }
219 
220 static __inline u_int32_t
221 _4ltol(u_int8_t *bytes)
222 {
223 	u_int32_t rv;
224 
225 	rv = bytes[0] | (bytes[1] << 8) |
226 	    (bytes[2] << 16) | (bytes[3] << 24);
227 	return (rv);
228 }
229 
230 #ifdef _KERNEL
231 
232 #define DEVID_NONE	0
233 #define DEVID_NAA	1
234 #define DEVID_EUI	2
235 #define DEVID_T10	3
236 
237 struct devid {
238 	u_int8_t	d_type;
239 	u_int8_t	d_flags;
240 #define DEVID_F_PRINT		(1<<0)
241 	u_int8_t	d_refcount;
242 	u_int8_t	d_len;
243 
244 	/*
245 	 * the devid struct is basically a header, the actual id is allocated
246 	 * immediately after it.
247 	 */
248 };
249 
250 #define DEVID_CMP(_a, _b) (					\
251 	(_a) != NULL && (_b) != NULL &&				\
252 	((_a) == (_b) ||					\
253 	((_a)->d_type != DEVID_NONE &&				\
254 	 (_a)->d_type == (_b)->d_type &&			\
255 	 (_a)->d_len == (_b)->d_len &&				\
256 	 bcmp((_a) + 1, (_b) + 1, (_a)->d_len) == 0))		\
257 )
258 
259 struct devid *	devid_alloc(u_int8_t, u_int8_t, u_int8_t, u_int8_t *);
260 struct devid *	devid_copy(struct devid *);
261 void		devid_free(struct devid *);
262 
263 /*
264  * The following documentation tries to describe the relationship between the
265  * various structures defined in this file:
266  *
267  * each adapter type has a scsi_adapter struct. This describes the adapter and
268  *    identifies routines that can be called to use the adapter.
269  * each device type has a scsi_device struct. This describes the device and
270  *    identifies routines that can be called to use the device.
271  * each existing device position (scsibus + target + lun)
272  *    can be described by a scsi_link struct.
273  *    Only scsi positions that actually have devices, have a scsi_link
274  *    structure assigned. so in effect each device has scsi_link struct.
275  *    The scsi_link structure contains information identifying both the
276  *    device driver and the adapter driver for that position on that scsi bus,
277  *    and can be said to 'link' the two.
278  * each individual scsi bus has an array that points to all the scsi_link
279  *    structs associated with that scsi bus. Slots with no device have
280  *    a NULL pointer.
281  * each individual device also knows the address of its own scsi_link
282  *    structure.
283  *
284  *				-------------
285  *
286  * The key to all this is the scsi_link structure which associates all the
287  * other structures with each other in the correct configuration.  The
288  * scsi_link is the connecting information that allows each part of the
289  * scsi system to find the associated other parts.
290  */
291 
292 struct scsi_xfer;
293 struct scsi_link;
294 struct scsibus_softc;
295 
296 /*
297  * Temporary hack
298  */
299 extern int scsi_autoconf;
300 
301 /*
302  * These entrypoints are called by the high-end drivers to get services from
303  * whatever low-end drivers they are attached to.  Each adapter type has one
304  * of these statically allocated.
305  */
306 struct scsi_adapter {
307 	void		(*scsi_cmd)(struct scsi_xfer *);
308 	void		(*scsi_minphys)(struct buf *, struct scsi_link *);
309 	int		(*dev_probe)(struct scsi_link *);
310 	void		(*dev_free)(struct scsi_link *);
311 	int		(*ioctl)(struct scsi_link *, u_long, caddr_t, int,
312 			    struct proc *);
313 };
314 
315 /*
316  * These entry points are called by the low-end drivers to get services from
317  * whatever high-end drivers they are attached to.  Each device type has one
318  * of these statically allocated.
319  */
320 struct scsi_device {
321 	int	(*err_handler)(struct scsi_xfer *);
322 			/* returns -1 to say err processing done */
323 	void	(*start)(void *);
324 
325 	int	(*async)(void);
326 	void	(*done)(struct scsi_xfer *);
327 };
328 
329 /*
330  *
331  */
332 
333 struct scsi_runq_entry {
334 	TAILQ_ENTRY(scsi_runq_entry) e;
335 	u_int state;
336 #define RUNQ_IDLE	0
337 #define RUNQ_LINKQ	1
338 #define RUNQ_POOLQ	3
339 };
340 TAILQ_HEAD(scsi_runq, scsi_runq_entry);
341 
342 struct scsi_iopool;
343 
344 struct scsi_iohandler {
345 	struct scsi_runq_entry entry; /* must be first */
346 
347 	struct scsi_iopool *pool;
348 	void (*handler)(void *, void *);
349 	void *cookie;
350 };
351 
352 struct scsi_iopool {
353 	/* access to the IOs */
354 	void	*iocookie;
355 	void	*(*io_get)(void *);
356 	void	 (*io_put)(void *, void *);
357 
358 	/* the runqueue */
359 	struct scsi_runq queue;
360 	/* runqueue semaphore */
361 	u_int running;
362 	/* protection for the runqueue and its semaphore */
363 	struct mutex mtx;
364 };
365 
366 /*
367  *
368  */
369 
370 struct scsi_xshandler {
371 	struct scsi_iohandler ioh; /* must be first */
372 
373 	struct scsi_link *link;
374 	void (*handler)(struct scsi_xfer *);
375 };
376 
377 /*
378  * This structure describes the connection between an adapter driver and
379  * a device driver, and is used by each to call services provided by
380  * the other, and to allow generic scsi glue code to call these services
381  * as well.
382  */
383 struct scsi_link {
384 	u_int		state;
385 #define SDEV_S_WAITING		(1<<0)
386 #define SDEV_S_DYING		(1<<1)
387 
388 	u_int8_t scsibus;		/* the Nth scsibus */
389 	u_int8_t luns;
390 	u_int16_t target;		/* targ of this dev */
391 	u_int16_t lun;			/* lun of this dev */
392 	u_int16_t openings;		/* available operations */
393 	u_int64_t port_wwn;		/* world wide name of port */
394 	u_int64_t node_wwn;		/* world wide name of node */
395 	u_int16_t adapter_target;	/* what are we on the scsi bus */
396 	u_int16_t adapter_buswidth;	/* 8 (regular) or 16 (wide). (0 becomes 8) */
397 	u_int16_t flags;		/* flags that all devices have */
398 #define	SDEV_REMOVABLE	 	0x0001	/* media is removable */
399 #define	SDEV_MEDIA_LOADED 	0x0002	/* device figures are still valid */
400 #define	SDEV_OPEN	 	0x0008	/* at least 1 open session */
401 #define	SDEV_DBX		0x00f0	/* debugging flags (scsi_debug.h) */
402 #define	SDEV_EJECTING		0x0100	/* eject on device close */
403 #define	SDEV_ATAPI		0x0200	/* device is ATAPI */
404 #define	SDEV_2NDBUS		0x0400	/* device is a 'second' bus device */
405 #define SDEV_UMASS		0x0800	/* device is UMASS SCSI */
406 #define SDEV_VIRTUAL		0x1000	/* device is virtualised on the hba */
407 #define SDEV_OWN_IOPL		0x2000	/* scsibus */
408 	u_int16_t quirks;		/* per-device oddities */
409 #define	SDEV_AUTOSAVE		0x0001	/* do implicit SAVEDATAPOINTER on disconnect */
410 #define	SDEV_NOSYNC		0x0002	/* does not grok SDTR */
411 #define	SDEV_NOWIDE		0x0004	/* does not grok WDTR */
412 #define	SDEV_NOTAGS		0x0008	/* lies about having tagged queueing */
413 #define	SDEV_NOSYNCCACHE	0x0100	/* no SYNCHRONIZE_CACHE */
414 #define	ADEV_NOSENSE		0x0200	/* No request sense - ATAPI */
415 #define	ADEV_LITTLETOC		0x0400	/* little-endian TOC - ATAPI */
416 #define	ADEV_NOCAPACITY		0x0800	/* no READ CD CAPACITY */
417 #define	ADEV_NODOORLOCK		0x2000	/* can't lock door */
418 #define SDEV_ONLYBIG		0x4000  /* always use READ_BIG and WRITE_BIG */
419 	struct	scsi_device *device;	/* device entry points etc. */
420 	void	*device_softc;		/* needed for call to foo_start */
421 	struct	scsi_adapter *adapter;	/* adapter entry points etc. */
422 	void	*adapter_softc;		/* needed for call to foo_scsi_cmd */
423 	struct	scsibus_softc *bus;	/* link to the scsibus we're on */
424 	struct	scsi_inquiry_data inqdata; /* copy of INQUIRY data from probe */
425 	struct  devid *id;
426 
427 	struct	scsi_runq queue;
428 	u_int	running;
429 
430 	struct	scsi_iopool *pool;
431 };
432 
433 int	scsiprint(void *, const char *);
434 
435 /*
436  * This describes matching information for scsi_inqmatch().  The more things
437  * match, the higher the configuration priority.
438  */
439 struct scsi_inquiry_pattern {
440 	u_int8_t type;
441 	int removable;
442 	char *vendor;
443 	char *product;
444 	char *revision;
445 };
446 
447 struct scsibus_attach_args {
448 	struct scsi_link *saa_sc_link;
449 };
450 
451 /*
452  * One of these is allocated and filled in for each scsi bus.
453  * It holds pointers to allow the scsi bus to get to the driver
454  * that is running each LUN on the bus.
455  * It also has a template entry which is the prototype struct
456  * supplied by the adapter driver.  This is used to initialise
457  * the others, before they have the rest of the fields filled in.
458  */
459 struct scsibus_softc {
460 	struct device sc_dev;
461 	struct scsi_link *adapter_link;	/* prototype supplied by adapter */
462 	struct scsi_link ***sc_link;
463 	u_int16_t sc_buswidth;
464 };
465 
466 /*
467  * This is used to pass information from the high-level configuration code
468  * to the device-specific drivers.
469  */
470 struct scsi_attach_args {
471 	struct scsi_link *sa_sc_link;
472 	struct scsi_inquiry_data *sa_inqbuf;
473 };
474 
475 /*
476  * Each scsi transaction is fully described by one of these structures.
477  * It includes information about the source of the command and also the
478  * device and adapter for which the command is destined.
479  * (via the scsi_link structure)
480  */
481 struct scsi_xfer {
482 	LIST_ENTRY(scsi_xfer) free_list;
483 	int	flags;
484 	struct	scsi_link *sc_link;	/* all about our device and adapter */
485 	int	retries;		/* the number of times to retry */
486 	int	timeout;		/* in milliseconds */
487 	struct	scsi_generic *cmd;	/* The scsi command to execute */
488 	int	cmdlen;			/* how long it is */
489 	u_char	*data;			/* dma address OR a uio address */
490 	int	datalen;		/* data len (blank if uio)    */
491 	size_t	resid;			/* how much buffer was not touched */
492 	int	error;			/* an error value	*/
493 	struct	buf *bp;		/* If we need to associate with a buf */
494 	struct	scsi_sense_data	sense; /* 32 bytes*/
495 	/*
496 	 * Believe it or not, Some targets fall on the ground with
497 	 * anything but a certain sense length.
498 	 */
499 	int	req_sense_length;	/* Explicit request sense length */
500 	u_int8_t status;		/* SCSI status */
501 	struct	scsi_generic cmdstore;	/* stash the command in here */
502 	/*
503 	 * timeout structure for hba's to use for a command
504 	 */
505 	struct timeout stimeout;
506 	void *cookie;
507 	void (*done)(struct scsi_xfer *);
508 
509 	void *io;			/* adapter io resource */
510 };
511 
512 /*
513  * Per-request Flag values
514  */
515 #define	SCSI_NOSLEEP	0x00001	/* don't sleep */
516 #define	SCSI_POLL	0x00002	/* poll for completion */
517 #define	SCSI_AUTOCONF	0x00003	/* shorthand for SCSI_POLL | SCSI_NOSLEEP */
518 #define	ITSDONE		0x00008	/* the transfer is as done as it gets	*/
519 #define	SCSI_SILENT	0x00020	/* don't announce NOT READY or MEDIA CHANGE */
520 #define	SCSI_IGNORE_NOT_READY		0x00040	/* ignore NOT READY */
521 #define	SCSI_IGNORE_MEDIA_CHANGE	0x00080	/* ignore MEDIA CHANGE */
522 #define	SCSI_IGNORE_ILLEGAL_REQUEST	0x00100	/* ignore ILLEGAL REQUEST */
523 #define	SCSI_RESET	0x00200	/* Reset the device in question		*/
524 #define	SCSI_DATA_IN	0x00800	/* expect data to come INTO memory	*/
525 #define	SCSI_DATA_OUT	0x01000	/* expect data to flow OUT of memory	*/
526 #define	SCSI_TARGET	0x02000	/* This defines a TARGET mode op.	*/
527 #define	SCSI_ESCAPE	0x04000	/* Escape operation			*/
528 #define	SCSI_PRIVATE	0xf0000	/* private to each HBA flags */
529 
530 /*
531  * Escape op-codes.  This provides an extensible setup for operations
532  * that are not scsi commands.  They are intended for modal operations.
533  */
534 
535 #define SCSI_OP_TARGET	0x0001
536 #define	SCSI_OP_RESET	0x0002
537 #define	SCSI_OP_BDINFO	0x0003
538 
539 /*
540  * Error values an adapter driver may return
541  */
542 #define XS_NOERROR	0	/* there is no error, (sense is invalid)  */
543 #define XS_SENSE	1	/* Check the returned sense for the error */
544 #define	XS_DRIVER_STUFFUP 2	/* Driver failed to perform operation	  */
545 #define XS_SELTIMEOUT	3	/* The device timed out.. turned off?	  */
546 #define XS_TIMEOUT	4	/* The Timeout reported was caught by SW  */
547 #define XS_BUSY		5	/* The device busy, try again later?	  */
548 #define XS_SHORTSENSE   6	/* Check the ATAPI sense for the error */
549 #define XS_RESET	8	/* bus was reset; possible retry command  */
550 #define XS_NO_CCB	9	/* device should requeue io and retry */
551 
552 /*
553  * Possible retries for scsi_test_unit_ready()
554  */
555 #define TEST_READY_RETRIES	5
556 
557 /*
558  * Possible retries for most SCSI commands.
559  */
560 #define SCSI_RETRIES		4
561 
562 const void *scsi_inqmatch(struct scsi_inquiry_data *, const void *, int,
563 	    int, int *);
564 
565 #define scsi_task(_f, _a1, _a2, _fl) \
566     workq_add_task(NULL, (_fl), (_f), (_a1), (_a2))
567 
568 void	scsi_init(void);
569 void	scsi_deinit(void);
570 struct scsi_xfer *
571 	scsi_get_xs(struct scsi_link *, int);
572 void	scsi_free_xs(struct scsi_xfer *, int);
573 int	scsi_execute_xs(struct scsi_xfer *);
574 daddr64_t scsi_size(struct scsi_link *, int, u_int32_t *);
575 int	scsi_test_unit_ready(struct scsi_link *, int, int);
576 int	scsi_inquire(struct scsi_link *, struct scsi_inquiry_data *, int);
577 int	scsi_inquire_vpd(struct scsi_link *, void *, u_int, u_int8_t, int);
578 int	scsi_prevent(struct scsi_link *, int, int);
579 int	scsi_start(struct scsi_link *, int, int);
580 int	scsi_mode_sense(struct scsi_link *, int, int, struct scsi_mode_header *,
581 	    size_t, int, int);
582 int	scsi_mode_sense_big(struct scsi_link *, int, int,
583 	    struct scsi_mode_header_big *, size_t, int, int);
584 void *	scsi_mode_sense_page(struct scsi_mode_header *, int);
585 void *	scsi_mode_sense_big_page(struct scsi_mode_header_big *, int);
586 int	scsi_do_mode_sense(struct scsi_link *, int,
587 	    union scsi_mode_sense_buf *, void **, u_int32_t *, u_int64_t *,
588 	    u_int32_t *, int, int, int *);
589 int	scsi_mode_select(struct scsi_link *, int, struct scsi_mode_header *,
590 	    int, int);
591 int	scsi_mode_select_big(struct scsi_link *, int,
592 	    struct scsi_mode_header_big *, int, int);
593 void	scsi_done(struct scsi_xfer *);
594 void	scsi_user_done(struct scsi_xfer *);
595 int	scsi_scsi_cmd(struct scsi_link *, struct scsi_generic *,
596 	    int cmdlen, u_char *data_addr, int datalen, int retries,
597 	    int timeout, struct buf *bp, int flags);
598 int	scsi_do_ioctl(struct scsi_link *, dev_t, u_long, caddr_t,
599 	    int, struct proc *);
600 void	sc_print_addr(struct scsi_link *);
601 int	scsi_report_luns(struct scsi_link *, int,
602 	    struct scsi_report_luns_data *, u_int32_t, int, int);
603 void	scsi_minphys(struct buf *, struct scsi_link *);
604 int	scsi_interpret_sense(struct scsi_xfer *);
605 
606 void		 scsi_buf_enqueue(struct buf *, struct buf *, struct mutex *);
607 struct buf	*scsi_buf_dequeue(struct buf *, struct mutex *);
608 void		 scsi_buf_requeue(struct buf *, struct buf *, struct mutex *);
609 int		 scsi_buf_canqueue(struct buf *, struct mutex *);
610 void		 scsi_buf_killqueue(struct buf *, struct mutex *);
611 
612 void	scsi_xs_show(struct scsi_xfer *);
613 void	scsi_print_sense(struct scsi_xfer *);
614 void	scsi_show_mem(u_char *, int);
615 void	scsi_strvis(u_char *, u_char *, int);
616 int	scsi_delay(struct scsi_xfer *, int);
617 
618 int	scsi_probe_bus(struct scsibus_softc *);
619 int	scsi_probe_target(struct scsibus_softc *, int);
620 int	scsi_probe_lun(struct scsibus_softc *, int, int);
621 
622 int	scsi_detach_bus(struct scsibus_softc *, int);
623 int	scsi_detach_target(struct scsibus_softc *, int, int);
624 int	scsi_detach_lun(struct scsibus_softc *, int, int, int);
625 
626 int	scsi_req_probe(struct scsibus_softc *, int, int);
627 int	scsi_req_detach(struct scsibus_softc *, int, int, int);
628 
629 void	scsi_activate(struct scsibus_softc *, int, int, int);
630 
631 extern const u_int8_t version_to_spc[];
632 #define SCSISPC(x)(version_to_spc[(x) & SID_ANSII])
633 
634 struct scsi_xfer *	scsi_xs_get(struct scsi_link *, int);
635 void			scsi_xs_exec(struct scsi_xfer *);
636 int			scsi_xs_sync(struct scsi_xfer *);
637 void			scsi_xs_put(struct scsi_xfer *);
638 
639 /*
640  * iopool stuff
641  */
642 void	scsi_iopool_init(struct scsi_iopool *, void *,
643 	    void *(*)(void *), void (*)(void *, void *));
644 
645 void *	scsi_io_get(struct scsi_iopool *, int);
646 void	scsi_io_put(struct scsi_iopool *, void *);
647 
648 /*
649  * default io allocator.
650  */
651 void *	scsi_default_get(void *);
652 void	scsi_default_put(void *, void *);
653 
654 /*
655  * io handler interface
656  */
657 void	scsi_ioh_set(struct scsi_iohandler *, struct scsi_iopool *,
658 	    void (*)(void *, void *), void *);
659 void	scsi_ioh_add(struct scsi_iohandler *);
660 void	scsi_ioh_del(struct scsi_iohandler *);
661 
662 void	scsi_xsh_set(struct scsi_xshandler *, struct scsi_link *,
663 	    void (*)(struct scsi_xfer *));
664 void	scsi_xsh_add(struct scsi_xshandler *);
665 void	scsi_xsh_del(struct scsi_xshandler *);
666 
667 /*
668  * Entrypoints for multipathing
669  */
670 int	mpath_path_attach(struct scsi_link *);
671 int	mpath_path_detach(struct scsi_link *, int);
672 
673 void	mpath_path_activate(struct scsi_link *);
674 void	mpath_path_deactivate(struct scsi_link *);
675 
676 #endif /* _KERNEL */
677 #endif /* SCSI_SCSICONF_H */
678