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 #endif /* defined(_KERNEL) */
103 
104 #ifdef	__cplusplus
105 }
106 #endif
107 
108 #endif	/* _SYS_SCSI_IMPL_SMP_TRANSPORT_H */
109