xref: /titanic_41/usr/src/uts/common/sys/scsi/impl/smp_transport.h (revision 499cfd156ad653fc27397c5f021047c091dd12c5)
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 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_SCSI_IMPL_SMP_TRANSPORT_H
28 #define	_SYS_SCSI_IMPL_SMP_TRANSPORT_H
29 
30 #include <sys/types.h>
31 #include <sys/scsi/impl/usmp.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 #if defined(_KERNEL)
38 
39 /*
40  * Properties for smp device
41  */
42 #define	SMP_PROP			"smp-device"
43 #define	SMP_WWN				"smp-wwn"
44 #define	SMP_PROP_REPORT_MANUFACTURER	"report-manufacturer"
45 
46 typedef struct smp_hba_tran	smp_hba_tran_t;
47 
48 typedef struct smp_address {
49 	uint8_t		smp_a_wwn[SAS_WWN_BYTE_SIZE];	/* expander wwn */
50 	smp_hba_tran_t	*smp_a_hba_tran;		/* Transport vector */
51 } smp_address_t;
52 
53 typedef struct smp_device {
54 	smp_address_t	smp_sd_address;
55 	dev_info_t	*smp_sd_dev;
56 	void		*smp_sd_hba_private;
57 	void		*smp_sd_private;
58 } smp_device_t;
59 
60 typedef struct smp_pkt {
61 	smp_address_t	*smp_pkt_address;
62 	caddr_t		smp_pkt_req;
63 	caddr_t		smp_pkt_rsp;
64 	size_t		smp_pkt_reqsize;
65 	size_t		smp_pkt_rspsize;
66 	int		smp_pkt_timeout;
67 	uchar_t		smp_pkt_reason;		/* code from errno.h */
68 	uchar_t		smp_pkt_will_retry;	/* will retry on EAGAIN */
69 } smp_pkt_t;
70 
71 struct smp_hba_tran {
72 	void		*smp_tran_hba_private;
73 
74 	int		(*smp_tran_init)(
75 				dev_info_t		*self,
76 				dev_info_t		*child,
77 				smp_hba_tran_t		*tran,
78 				smp_device_t		*smp);
79 
80 	void		(*smp_tran_free)(
81 				dev_info_t		*self,
82 				dev_info_t		*child,
83 				smp_hba_tran_t		*tran,
84 				smp_device_t		*smp);
85 
86 	int		(*smp_tran_start)(
87 				struct smp_pkt		*pkt);
88 
89 };
90 
91 /* interfaces for hba/iport driver */
92 extern smp_hba_tran_t	*smp_hba_tran_alloc(dev_info_t *dip);
93 extern int		smp_hba_attach_setup(dev_info_t *dip,
94 			    smp_hba_tran_t *smp);
95 extern int		smp_hba_detach(dev_info_t *self);
96 extern void		smp_hba_tran_free(smp_hba_tran_t *smp);
97 
98 /* interfaces target driver (and framework) */
99 extern int		smp_probe(struct smp_device *smp_devp);
100 extern int		smp_transport(struct smp_pkt *pkt);
101 
102 /* ==== The following interfaces are private (currently) ==== */
103 
104 /*
105  * smp_device_prop_*() property interfaces: flags
106  *
107  *   SMP_DEVICE_PROP_DEVICE: property of device.
108  *	The property is always associated with the smp_sd_dev devinfo
109  *	node.  Implementation uses ndi_prop_*() interfaces applied
110  *	dev_info_t (smp_sd_dev) nodes.
111  */
112 #define	SMP_DEVICE_PROP_DEVICE		0x2	/* type is property-of-device */
113 #define	SMP_DEVICE_PROP_TYPE_MSK	0xF
114 
115 int	smp_device_prop_get_int(struct smp_device *smp_sd, char *name,
116 	    int defvalue);
117 int64_t	smp_device_prop_get_int64(struct smp_device *, char *name,
118 	    int64_t defvalue);
119 
120 int	smp_device_prop_lookup_byte_array(struct smp_device *smp_sd, char *name,
121 	    uchar_t **, uint_t *);
122 int	smp_device_prop_lookup_int_array(struct smp_device *smp_sd, char *name,
123 	    int **, uint_t *);
124 int	smp_device_prop_lookup_string(struct smp_device *smp_sd, char *name,
125 	    char **);
126 int	smp_device_prop_lookup_string_array(struct smp_device *smp_sd,
127 	    char *name, char ***, uint_t *);
128 
129 int	smp_device_prop_update_byte_array(struct smp_device *smp_sd, char *name,
130 	    uchar_t *, uint_t);
131 int	smp_device_prop_update_int(struct smp_device *smp_sd, char *name, int);
132 int	smp_device_prop_update_int64(struct smp_device *smp_sd, char *name,
133 	    int64_t);
134 int	smp_device_prop_update_int_array(struct smp_device *smp_sd, char *name,
135 	    int *, uint_t);
136 int	smp_device_prop_update_string(struct smp_device *smp_sd, char *name,
137 	    char *);
138 int	smp_device_prop_update_string_array(struct smp_device *smp_sd,
139 	    char *name, char **, uint_t);
140 
141 int	smp_device_prop_remove(struct smp_device *smp_sd, char *name);
142 void	smp_device_prop_free(struct smp_device *smp_sd, void *data);
143 
144 #endif /* defined(_KERNEL) */
145 
146 #ifdef	__cplusplus
147 }
148 #endif
149 
150 #endif	/* _SYS_SCSI_IMPL_SMP_TRANSPORT_H */
151