xref: /titanic_51/usr/src/uts/common/sys/scsi/scsi_resource.h (revision 98157a7002f4f2cf7978f3084ca5577f0a1d72b2)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_SCSI_SCSI_RESOURCE_H
27 #define	_SYS_SCSI_SCSI_RESOURCE_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef __lock_lint
32 #include <note.h>
33 #endif
34 #include <sys/scsi/scsi_types.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * SCSI Resource Function Declarations
42  */
43 
44 /*
45  * Defines for stating preferences in resource allocation
46  */
47 
48 #define	NULL_FUNC	((int (*)())0)
49 #define	SLEEP_FUNC	((int (*)())1)
50 
51 #ifdef	_KERNEL
52 /*
53  * Defines for the flags to scsi_init_pkt()
54  */
55 #define	PKT_CONSISTENT	0x0001		/* this is an 'iopb' packet */
56 #define	PKT_DMA_PARTIAL	0x040000	/* partial xfer ok */
57 #define	PKT_XARQ	0x080000	/* request for extra sense */
58 
59 /*
60  * Old PKT_CONSISTENT value for binary compatibility with x86 2.1
61  */
62 #define	PKT_CONSISTENT_OLD	0x001000
63 
64 /*
65  * Kernel function declarations
66  */
67 struct buf	*scsi_alloc_consistent_buf(struct scsi_address *,
68 		    struct buf *, size_t, uint_t, int (*)(caddr_t), caddr_t);
69 struct scsi_pkt	*scsi_init_pkt(struct scsi_address *,
70 		    struct scsi_pkt *, struct buf *, int, int, int, int,
71 		    int (*)(caddr_t), caddr_t);
72 void		scsi_destroy_pkt(struct scsi_pkt *);
73 void		scsi_free_consistent_buf(struct buf *);
74 struct scsi_pkt	*scsi_resalloc(struct scsi_address *, int,
75 		    int, opaque_t, int (*)(void));
76 struct scsi_pkt	*scsi_pktalloc(struct scsi_address *, int, int, int (*)(void));
77 struct scsi_pkt	*scsi_dmaget(struct scsi_pkt *, opaque_t, int (*)(void));
78 void		scsi_dmafree(struct scsi_pkt *);
79 void		scsi_sync_pkt(struct scsi_pkt *);
80 void		scsi_resfree(struct scsi_pkt *);
81 
82 /*
83  * Private wrapper for scsi_pkt's allocated via scsi_init_cache_pkt()
84  */
85 struct scsi_pkt_cache_wrapper {
86 	struct scsi_pkt		 pcw_pkt;
87 	uint_t			 pcw_total_xfer;
88 	uint_t			 pcw_curwin;
89 	uint_t			 pcw_totalwin;
90 	uint_t			 pcw_granular;
91 	struct buf		*pcw_bp;
92 	ddi_dma_cookie_t	 pcw_cookie;
93 	void			(*pcw_orig_comp)(struct scsi_pkt *);
94 	uint_t			 pcw_flags;
95 };
96 
97 #ifdef __lock_lint
98 _NOTE(SCHEME_PROTECTS_DATA("unique per packet", \
99 	scsi_pkt_cache_wrapper::pcw_orig_comp))
100 #endif
101 struct buf	*scsi_pkt2bp(struct scsi_pkt *);
102 
103 #define	PCW_NEED_EXT_CDB	0x0001
104 #define	PCW_NEED_EXT_TGT	0x0002
105 #define	PCW_NEED_EXT_SCB	0x0004
106 #define	PCW_BOUND		0x0020
107 
108 /*
109  * Private defines i.e. not part of the DDI.
110  */
111 #define	DEFAULT_CDBLEN	16
112 #define	DEFAULT_PRIVLEN	0
113 #define	DEFAULT_SCBLEN	(sizeof (struct scsi_arq_status))
114 
115 /*
116  * Preliminary version of the SCSA specification
117  * mentioned a routine called scsi_pktfree, which
118  * turned out to be semantically equivialent to
119  * scsi_resfree.
120  */
121 #define	scsi_pktfree	scsi_resfree
122 
123 #endif	/* _KERNEL */
124 
125 #ifdef	__cplusplus
126 }
127 #endif
128 
129 #endif	/* _SYS_SCSI_SCSI_RESOURCE_H */
130