xref: /titanic_41/usr/src/uts/common/sys/scsi/adapters/iscsi_door.h (revision 4246c8e92ef9ad6ada2b992b7af02832ff071bf7)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_ISCSI_DOOR_H
27 #define	_ISCSI_DOOR_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #define	ISCSI_DOOR_REQ_SIGNATURE	0x53435349
34 #define	ISCSI_DOOR_REQ_VERSION_1	1
35 #define	ISCSI_DOOR_MAX_DATA_SIZE	8192
36 
37 
38 #define	ISCSI_DOOR_GETIPNODEBYNAME_REQ	0x0000
39 #define	ISCSI_DOOR_GETIPNODEBYNAME_CNF	0x4000
40 #define	ISCSI_DOOR_ERROR_IND		0x8000
41 
42 #define	ISCSI_DOOR_STATUS_SUCCESS	0x00000000
43 #define	ISCSI_DOOR_STATUS_REQ_LENGTH	0x00000001
44 #define	ISCSI_DOOR_STATUS_REQ_FORMAT	0x00000002
45 #define	ISCSI_DOOR_STATUS_REQ_INVALID	0x00000003
46 #define	ISCSI_DOOR_STATUS_REQ_VERSION	0x00000004
47 #define	ISCSI_DOOR_STATUS_MORE		0x00000005
48 
49 typedef struct _iscsi_door_msg_hdr {
50 	uint32_t		signature;
51 	uint32_t		version;
52 	uint32_t		opcode;
53 	uint32_t		status;
54 } iscsi_door_msg_hdr_t;
55 
56 typedef struct _getipnodebyname_req {
57 	iscsi_door_msg_hdr_t	hdr;
58 	uint32_t		name_offset;
59 	uint32_t		name_length;
60 	uint32_t		af;
61 	uint32_t		flags;
62 } getipnodebyname_req_t;
63 
64 typedef struct _getipnodebyname_cnf {
65 	iscsi_door_msg_hdr_t	hdr;
66 	uint32_t		h_size_needed;
67 	uint32_t		h_addr_list_offset;
68 	uint32_t		h_addr_list_length;
69 	uint32_t		h_addrtype;
70 	uint32_t		h_addrlen;
71 	uint32_t		h_name_offset;
72 	uint32_t		h_name_len;
73 	uint32_t		h_alias_list_offset;
74 	uint32_t		h_alias_list_length;
75 	int32_t			error_num;
76 } getipnodebyname_cnf_t;
77 
78 typedef union _iscsi_door_req {
79 	iscsi_door_msg_hdr_t	hdr;
80 	getipnodebyname_req_t	ginbn_req;
81 } iscsi_door_req_t;
82 
83 typedef union _iscsi_door_cnf {
84 	iscsi_door_msg_hdr_t	hdr;
85 	getipnodebyname_cnf_t	ginbn_cnf;
86 } iscsi_door_cnf_t;
87 
88 typedef union _iscsi_door_ind {
89 	iscsi_door_msg_hdr_t	hdr;
90 	iscsi_door_msg_hdr_t	error_ind;
91 } iscsi_door_ind_t;
92 
93 typedef union _iscsi_door_msg {
94 	iscsi_door_msg_hdr_t	hdr;
95 	iscsi_door_req_t	req;
96 	iscsi_door_cnf_t	cnf;
97 	iscsi_door_ind_t	ind;
98 } iscsi_door_msg_t;
99 
100 #ifdef _KERNEL
101 
102 /* Defines copied from netdb.h */
103 #define	HOST_NOT_FOUND	1 /* Authoritive Answer Host not found */
104 #define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
105 #define	NO_RECOVERY	3 /* Non recoverable errors,FORMERR,REFUSED,NOTIMP */
106 #define	NO_DATA		4 /* Valid name, no data record of requested type */
107 #define	NO_ADDRESS	NO_DATA	/* no address, look for MX record */
108 
109 #define	AI_V4MAPPED	0x0001 /* IPv4 mapped addresses if no IPv6 */
110 #define	AI_ALL		0x0002 /* IPv6 and IPv4 mapped addresses */
111 #define	AI_ADDRCONFIG	0x0004 /* AAAA or A records only if IPv6/IPv4 cnfgd */
112 
113 struct  hostent {
114 	char	*h_name;	/* official name of host */
115 	char	**h_aliases;	/* alias list */
116 	int	h_addrtype;	/* host address type */
117 	int	h_length;	/* length of address */
118 	char	**h_addr_list;	/* list of addresses from name server */
119 };
120 
121 boolean_t
122 iscsi_door_ini(void);
123 
124 boolean_t
125 iscsi_door_term(void);
126 
127 boolean_t
128 iscsi_door_bind(
129 	int		did
130 );
131 
132 void
133 iscsi_door_unbind(void);
134 
135 void
136 kfreehostent(
137 	struct hostent	*hptr
138 );
139 
140 struct hostent *
141 kgetipnodebyname(
142 	const char	*name,
143 	int		af,
144 	int		flags,
145 	int		*error_num
146 );
147 
148 #else	/* !_KERNEL */
149 
150 #define	kfreehostent		freehostent
151 #define	kgetipnodebyname	getipnodebyname
152 
153 #endif	/* _KERNEL */
154 
155 /*
156  * iSCSI initiator SMF service status in kernel
157  */
158 #define	ISCSI_SERVICE_ENABLED		0x0
159 #define	ISCSI_SERVICE_DISABLED		0x1
160 #define	ISCSI_SERVICE_TRANSITION	0x2
161 
162 #ifdef __cplusplus
163 }
164 #endif
165 
166 #endif /* _ISCSI_DOOR_H */
167