xref: /titanic_44/usr/src/uts/common/sys/scsi/conf/device.h (revision 23c57df72989c916b3e98084eb88d48777999691)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * SCSI device structure.
28  *
29  *	All SCSI target drivers will have one of these per target/lun/sfunc.
30  *	It will be allocated and initialized by the SCSA HBA nexus code
31  *	for each SCSI target dev_info_t node and stored as driver private data
32  *	in that target device's dev_info_t (and thus can be retrieved by
33  *	the function ddi_get_driver_private).
34  */
35 #ifndef	_SYS_SCSI_CONF_DEVICE_H
36 #define	_SYS_SCSI_CONF_DEVICE_H
37 
38 #pragma ident	"%Z%%M%	%I%	%E% SMI"
39 
40 #include <sys/scsi/scsi_types.h>
41 
42 #ifdef	__cplusplus
43 extern "C" {
44 #endif
45 
46 struct scsi_device {
47 	/*
48 	 * Routing info for this device.  Contains a_hba_tran pointer to
49 	 * the transport and decoded addressing for SPI devices.
50 	 */
51 	struct scsi_address	sd_address;
52 
53 	/*
54 	 * Cross-reference to target device's dev_info_t.
55 	 */
56 	dev_info_t		*sd_dev;
57 
58 	/*
59 	 * Mutex for this device, initialized by
60 	 * parent prior to calling probe or attach
61 	 * routine.
62 	 */
63 	kmutex_t		sd_mutex;
64 
65 	/*
66 	 * Reserved, do not use.
67 	 */
68 	void			*sd_reserved;
69 
70 
71 	/*
72 	 * If scsi_slave is used to probe out this device,
73 	 * a scsi_inquiry data structure will be allocated
74 	 * and an INQUIRY command will be run to fill it in.
75 	 *
76 	 * The allocation will be done via ddi_iopb_alloc,
77 	 * so any manual freeing may be done by ddi_iopb_free.
78 	 *
79 	 * The inquiry data is allocated/refreshed by
80 	 * scsi_probe/scsi_slave and freed by uninitchild (inquiry
81 	 * data is no longer freed by scsi_unprobe/scsi_unslave).
82 	 *
83 	 * Additional device identity information may be available
84 	 * as properties of sd_dev.
85 	 */
86 	struct scsi_inquiry	*sd_inq;
87 
88 	/*
89 	 * Place to point to an extended request sense buffer.
90 	 * The target driver is responsible for managing this.
91 	 */
92 	struct scsi_extended_sense	*sd_sense;
93 
94 	/*
95 	 * More detailed information is 'private' information. Typically a
96 	 * pointer to target driver private soft_state information for the
97 	 * device.  This soft_state is typically established in target driver
98 	 * attach(9E), and freed in the target driver detach(9E).
99 	 */
100 	caddr_t			sd_private;
101 
102 
103 	/*
104 	 * FMA capabilities of scsi_device.
105 	 */
106 	int			sd_fm_capable;
107 
108 #ifdef	SCSI_SIZE_CLEAN_VERIFY
109 	/*
110 	 * Must be last: Building a driver with-and-without
111 	 * -DSCSI_SIZE_CLEAN_VERIFY, and checking driver modules for
112 	 * differences with a tools like 'wsdiff' allows a developer to verify
113 	 * that their driver has no dependencies on scsi*(9S) size.
114 	 */
115 	int			_pad[8];
116 #endif	/* SCSI_SIZE_CLEAN_VERIFY */
117 };
118 
119 #ifdef	_KERNEL
120 int	scsi_slave(struct scsi_device *devp, int (*callback)(void));
121 int	scsi_probe(struct scsi_device *devp, int (*callback)(void));
122 void	scsi_unslave(struct scsi_device *devp);
123 void	scsi_unprobe(struct scsi_device *devp);
124 size_t	scsi_device_size();			/* private */
125 #endif	/* _KERNEL */
126 
127 #ifdef	__cplusplus
128 }
129 #endif
130 
131 #endif	/* _SYS_SCSI_CONF_DEVICE_H */
132