xref: /onnv-gate/usr/src/uts/common/sys/fibre-channel/ulp/fcp_util.h (revision 7836:4e95154b5b7a)
1*7836SJohn.Forte@Sun.COM /*
2*7836SJohn.Forte@Sun.COM  * CDDL HEADER START
3*7836SJohn.Forte@Sun.COM  *
4*7836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
5*7836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
6*7836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
7*7836SJohn.Forte@Sun.COM  *
8*7836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*7836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
11*7836SJohn.Forte@Sun.COM  * and limitations under the License.
12*7836SJohn.Forte@Sun.COM  *
13*7836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*7836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*7836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*7836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*7836SJohn.Forte@Sun.COM  *
19*7836SJohn.Forte@Sun.COM  * CDDL HEADER END
20*7836SJohn.Forte@Sun.COM  */
21*7836SJohn.Forte@Sun.COM /*
22*7836SJohn.Forte@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*7836SJohn.Forte@Sun.COM  * Use is subject to license terms.
24*7836SJohn.Forte@Sun.COM  */
25*7836SJohn.Forte@Sun.COM 
26*7836SJohn.Forte@Sun.COM #ifndef	_FCP_UTIL_H
27*7836SJohn.Forte@Sun.COM #define	_FCP_UTIL_H
28*7836SJohn.Forte@Sun.COM 
29*7836SJohn.Forte@Sun.COM 
30*7836SJohn.Forte@Sun.COM 
31*7836SJohn.Forte@Sun.COM #ifdef	__cplusplus
32*7836SJohn.Forte@Sun.COM extern "C" {
33*7836SJohn.Forte@Sun.COM #endif
34*7836SJohn.Forte@Sun.COM 
35*7836SJohn.Forte@Sun.COM #include <sys/types.h>
36*7836SJohn.Forte@Sun.COM 
37*7836SJohn.Forte@Sun.COM 
38*7836SJohn.Forte@Sun.COM #define	FCP_TGT_INQUIRY		0x01
39*7836SJohn.Forte@Sun.COM #define	FCP_TGT_CREATE		0x02
40*7836SJohn.Forte@Sun.COM #define	FCP_TGT_DELETE		0x04
41*7836SJohn.Forte@Sun.COM #define	FCP_TGT_SEND_SCSI	0x08
42*7836SJohn.Forte@Sun.COM #define	FCP_STATE_COUNT		0x10
43*7836SJohn.Forte@Sun.COM #define	FCP_GET_TARGET_MAPPINGS	0x11
44*7836SJohn.Forte@Sun.COM 
45*7836SJohn.Forte@Sun.COM struct	fcp_ioctl {
46*7836SJohn.Forte@Sun.COM 	minor_t		fp_minor;
47*7836SJohn.Forte@Sun.COM 	uint32_t	listlen;
48*7836SJohn.Forte@Sun.COM 	caddr_t		list;
49*7836SJohn.Forte@Sun.COM };
50*7836SJohn.Forte@Sun.COM 
51*7836SJohn.Forte@Sun.COM struct	device_data {
52*7836SJohn.Forte@Sun.COM 	la_wwn_t	dev_pwwn;
53*7836SJohn.Forte@Sun.COM 	int		dev_status;
54*7836SJohn.Forte@Sun.COM 	int		dev_lun_cnt;
55*7836SJohn.Forte@Sun.COM 	uchar_t		dev0_type;
56*7836SJohn.Forte@Sun.COM };
57*7836SJohn.Forte@Sun.COM 
58*7836SJohn.Forte@Sun.COM struct fcp_scsi_cmd {
59*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_fc_port_num;
60*7836SJohn.Forte@Sun.COM 	la_wwn_t	scsi_fc_pwwn;
61*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_fc_status;
62*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_fc_rspcode;
63*7836SJohn.Forte@Sun.COM 	uchar_t		scsi_pkt_state;
64*7836SJohn.Forte@Sun.COM 	uchar_t		scsi_pkt_action;
65*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_pkt_reason;
66*7836SJohn.Forte@Sun.COM 	uint64_t	scsi_lun;
67*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_flags;
68*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_timeout;
69*7836SJohn.Forte@Sun.COM 	caddr_t		scsi_cdbbufaddr;
70*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_cdblen;
71*7836SJohn.Forte@Sun.COM 	caddr_t		scsi_bufaddr;
72*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_buflen;
73*7836SJohn.Forte@Sun.COM 	int32_t		scsi_bufresid;
74*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_bufstatus;
75*7836SJohn.Forte@Sun.COM 	caddr_t		scsi_rqbufaddr;
76*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_rqlen;
77*7836SJohn.Forte@Sun.COM 	int32_t		scsi_rqresid;
78*7836SJohn.Forte@Sun.COM };
79*7836SJohn.Forte@Sun.COM 
80*7836SJohn.Forte@Sun.COM typedef struct fc_hba_mapping_entry {
81*7836SJohn.Forte@Sun.COM     char			targetDriver[MAXPATHLEN];
82*7836SJohn.Forte@Sun.COM     uint32_t			d_id;
83*7836SJohn.Forte@Sun.COM     uint32_t			busNumber;
84*7836SJohn.Forte@Sun.COM     uint32_t			targetNumber;
85*7836SJohn.Forte@Sun.COM     uint32_t			osLUN;
86*7836SJohn.Forte@Sun.COM     uint64_t			samLUN;
87*7836SJohn.Forte@Sun.COM     la_wwn_t			NodeWWN;
88*7836SJohn.Forte@Sun.COM     la_wwn_t			PortWWN;
89*7836SJohn.Forte@Sun.COM     uint8_t			guid[256];
90*7836SJohn.Forte@Sun.COM } fc_hba_mapping_entry_t;
91*7836SJohn.Forte@Sun.COM 
92*7836SJohn.Forte@Sun.COM #define	FC_HBA_TARGET_MAPPINGS_VERSION		1
93*7836SJohn.Forte@Sun.COM typedef struct fc_hba_target_mappings {
94*7836SJohn.Forte@Sun.COM     uint32_t			version;
95*7836SJohn.Forte@Sun.COM     uint32_t			numLuns;
96*7836SJohn.Forte@Sun.COM     uint64_t			reserved;
97*7836SJohn.Forte@Sun.COM     fc_hba_mapping_entry_t	entries[1];
98*7836SJohn.Forte@Sun.COM } fc_hba_target_mappings_t;
99*7836SJohn.Forte@Sun.COM 
100*7836SJohn.Forte@Sun.COM /*
101*7836SJohn.Forte@Sun.COM  * flags for scsi_flags field of fcp_scsi_cmd structure
102*7836SJohn.Forte@Sun.COM  */
103*7836SJohn.Forte@Sun.COM #define	FCP_SCSI_READ	0x0001	/* get data from device */
104*7836SJohn.Forte@Sun.COM 
105*7836SJohn.Forte@Sun.COM 
106*7836SJohn.Forte@Sun.COM #if defined(_SYSCALL32)
107*7836SJohn.Forte@Sun.COM /*
108*7836SJohn.Forte@Sun.COM  * 32 bit variant of fcp_ioctl and fcp_scsi_cmd
109*7836SJohn.Forte@Sun.COM  * used only in the driver.
110*7836SJohn.Forte@Sun.COM  */
111*7836SJohn.Forte@Sun.COM 
112*7836SJohn.Forte@Sun.COM #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
113*7836SJohn.Forte@Sun.COM #pragma pack(4)
114*7836SJohn.Forte@Sun.COM #endif
115*7836SJohn.Forte@Sun.COM 
116*7836SJohn.Forte@Sun.COM struct	fcp32_ioctl {
117*7836SJohn.Forte@Sun.COM 	minor_t		fp_minor;
118*7836SJohn.Forte@Sun.COM 	uint32_t	listlen;
119*7836SJohn.Forte@Sun.COM 	caddr32_t	list;
120*7836SJohn.Forte@Sun.COM };
121*7836SJohn.Forte@Sun.COM 
122*7836SJohn.Forte@Sun.COM struct fcp32_scsi_cmd {
123*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_fc_port_num;
124*7836SJohn.Forte@Sun.COM 	la_wwn_t	scsi_fc_pwwn;
125*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_fc_status;
126*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_fc_rspcode;
127*7836SJohn.Forte@Sun.COM 	uchar_t		scsi_pkt_state;
128*7836SJohn.Forte@Sun.COM 	uchar_t		scsi_pkt_action;
129*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_pkt_reason;
130*7836SJohn.Forte@Sun.COM 	uint64_t	scsi_lun;
131*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_flags;
132*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_timeout;
133*7836SJohn.Forte@Sun.COM 	caddr32_t	scsi_cdbbufaddr;
134*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_cdblen;
135*7836SJohn.Forte@Sun.COM 	caddr32_t	scsi_bufaddr;
136*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_buflen;
137*7836SJohn.Forte@Sun.COM 	int32_t		scsi_bufresid;
138*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_bufstatus;
139*7836SJohn.Forte@Sun.COM 	caddr32_t	scsi_rqbufaddr;
140*7836SJohn.Forte@Sun.COM 	uint32_t	scsi_rqlen;
141*7836SJohn.Forte@Sun.COM 	int32_t		scsi_rqresid;
142*7836SJohn.Forte@Sun.COM };
143*7836SJohn.Forte@Sun.COM 
144*7836SJohn.Forte@Sun.COM #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
145*7836SJohn.Forte@Sun.COM #pragma pack()
146*7836SJohn.Forte@Sun.COM #endif
147*7836SJohn.Forte@Sun.COM 
148*7836SJohn.Forte@Sun.COM #define	FCP32_SCSI_CMD_TO_FCP_SCSI_CMD(cmd32, cmd)			\
149*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_fc_port_num	= (cmd32)->scsi_fc_port_num;		\
150*7836SJohn.Forte@Sun.COM 	bcopy(&((cmd32)->scsi_fc_pwwn), &((cmd)->scsi_fc_pwwn),		\
151*7836SJohn.Forte@Sun.COM 			sizeof ((cmd)->scsi_fc_pwwn));			\
152*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_fc_status	= (cmd32)->scsi_fc_status;		\
153*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_fc_rspcode	= (cmd32)->scsi_fc_rspcode;		\
154*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_pkt_state	= (cmd32)->scsi_pkt_state;		\
155*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_pkt_action	= (cmd32)->scsi_pkt_action;		\
156*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_pkt_reason	= (cmd32)->scsi_pkt_reason;		\
157*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_lun		= (cmd32)->scsi_lun;			\
158*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_flags	= (cmd32)->scsi_flags;			\
159*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_timeout	= (cmd32)->scsi_timeout;		\
160*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_cdbbufaddr	= (caddr_t)(long)(cmd32)->scsi_cdbbufaddr; \
161*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_cdblen	= (cmd32)->scsi_cdblen;			\
162*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_bufaddr	= (caddr_t)(long)(cmd32)->scsi_bufaddr;	\
163*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_buflen	= (cmd32)->scsi_buflen;			\
164*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_bufresid	= (cmd32)->scsi_bufresid;		\
165*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_bufstatus	= (cmd32)->scsi_bufstatus;		\
166*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_rqbufaddr	= (caddr_t)(long)(cmd32)->scsi_rqbufaddr; \
167*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_rqlen	= (cmd32)->scsi_rqlen;			\
168*7836SJohn.Forte@Sun.COM 	(cmd)->scsi_rqresid	= (cmd32)->scsi_rqresid;
169*7836SJohn.Forte@Sun.COM 
170*7836SJohn.Forte@Sun.COM #define	FCP_SCSI_CMD_TO_FCP32_SCSI_CMD(cmd, cmd32)			\
171*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_fc_port_num = (cmd)->scsi_fc_port_num;		\
172*7836SJohn.Forte@Sun.COM 	bcopy(&((cmd)->scsi_fc_pwwn), &((cmd32)->scsi_fc_pwwn),		\
173*7836SJohn.Forte@Sun.COM 			sizeof ((cmd32)->scsi_fc_pwwn));		\
174*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_fc_status	= (cmd)->scsi_fc_status;		\
175*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_fc_rspcode = (cmd)->scsi_fc_rspcode;		\
176*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_pkt_state	= (cmd)->scsi_pkt_state;		\
177*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_pkt_action = (cmd)->scsi_pkt_action;		\
178*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_pkt_reason = (cmd)->scsi_pkt_reason;		\
179*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_lun	= (cmd)->scsi_lun;			\
180*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_flags	= (cmd)->scsi_flags;			\
181*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_timeout	= (cmd)->scsi_timeout;			\
182*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_cdbbufaddr = (caddr32_t)(long)(cmd)->scsi_cdbbufaddr; \
183*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_cdblen	= (cmd)->scsi_cdblen;			\
184*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_bufaddr	= (caddr32_t)(long)(cmd)->scsi_bufaddr;	\
185*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_buflen	= (cmd)->scsi_buflen;			\
186*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_bufresid	= (cmd)->scsi_bufresid;			\
187*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_bufstatus	= (cmd)->scsi_bufstatus;		\
188*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_rqbufaddr	= (caddr32_t)(long)(cmd)->scsi_rqbufaddr; \
189*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_rqlen	= (cmd)->scsi_rqlen;			\
190*7836SJohn.Forte@Sun.COM 	(cmd32)->scsi_rqresid	= (cmd)->scsi_rqresid;
191*7836SJohn.Forte@Sun.COM 
192*7836SJohn.Forte@Sun.COM #endif /* _SYSCALL32 */
193*7836SJohn.Forte@Sun.COM 
194*7836SJohn.Forte@Sun.COM #if !defined(__lint)
195*7836SJohn.Forte@Sun.COM _NOTE(SCHEME_PROTECTS_DATA("Unshared Data", device_data))
196*7836SJohn.Forte@Sun.COM _NOTE(SCHEME_PROTECTS_DATA("Unshared Data", fcp_scsi_cmd))
197*7836SJohn.Forte@Sun.COM #endif /* __lint */
198*7836SJohn.Forte@Sun.COM 
199*7836SJohn.Forte@Sun.COM #ifdef	__cplusplus
200*7836SJohn.Forte@Sun.COM }
201*7836SJohn.Forte@Sun.COM #endif
202*7836SJohn.Forte@Sun.COM 
203*7836SJohn.Forte@Sun.COM #endif	/* _FCP_UTIL_H */
204