xref: /titanic_41/usr/src/uts/common/io/scsi/adapters/iscsi/isns_client.h (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
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 #ifndef	_ISNS_CLIENT_H
27 #define	_ISNS_CLIENT_H
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/types.h>
34 #include <sys/scsi/adapters/iscsi_if.h>
35 
36 #define	ISNS_DEFAULT_ESI_SCN_PORT	32046
37 #define	ISNS_DEFAULT_PORTAL_GROUP_TAG	1
38 
39 typedef enum isns_status {
40 	isns_ok,
41 	isns_no_svr_found,
42 	isns_internal_err,
43 	isns_create_msg_err,
44 	isns_open_conn_err,
45 	isns_send_msg_err,
46 	isns_rcv_msg_err,
47 	isns_no_rsp_rcvd,
48 	isns_op_failed,
49 	isns_op_partially_failed,
50 	isns_no_transport_found
51 } isns_status_t;
52 
53 #define	ISNSP_MULT_PAYLOAD_HEADER_SIZE		8
54 /*
55  * when we concatenate payloads from multiple pdus, we need
56  * a larger payload_len then what is defined in isns_protocol.h
57  *
58  * for each payload that comes in, we need to save off the payload_len
59  * and the payload
60  */
61 typedef struct isns_pdu_mult_payload {
62 	size_t payload_len;
63 	uint8_t payload[1];
64 } isns_pdu_mult_payload_t;
65 
66 typedef struct isns_scn_callback_arg {
67 	uint32_t scn_type;
68 	uint8_t source_key_attr[ISCSI_MAX_NAME_LEN];
69 } isns_scn_callback_arg_t;
70 
71 /*
72  * To initialize the iSNS Client module.
73  */
74 void
75 isns_client_init(void);
76 
77 /*
78  * To clean up the resources associated with the iSNS Client module.
79  */
80 void
81 isns_client_cleanup(void);
82 
83 /*
84  * To register a network entity against the iSNS server(s) visible to the
85  * specified LHBA.
86  */
87 isns_status_t
88 isns_reg(uint8_t *lhba_handle,
89 	uint8_t *node_name,
90 	size_t node_name_len,
91 	uint8_t *node_alias,
92 	size_t node_alias_len,
93 	uint32_t node_type,
94 	void (*scn_callback)(void *));
95 
96 /*
97  * To register a network entity against the specified iSNS server.
98  */
99 isns_status_t
100 isns_reg_one_server(entry_t *isns_server,
101 	uint8_t *lhba_handle,
102 	uint8_t *node_name,
103 	size_t node_name_len,
104 	uint8_t *node_alias,
105 	size_t node_alias_len,
106 	uint32_t node_type,
107 	void (*scn_callback)(void *));
108 
109 /*
110  * To deregister a network entity from the all iSNS server(s) visible to the
111  * specified LHBA.
112  */
113 isns_status_t
114 isns_dereg(uint8_t *lhba_handle, uint8_t *node_name);
115 
116 /*
117  * To deregister a network entity from the specified iSNS server.
118  */
119 isns_status_t
120 isns_dereg_one_server(entry_t *isns_server, uint8_t *node_name,
121 	boolean_t is_last_isns_server);
122 
123 /*
124  * To query all portal group objects that are visible to the specified LHBA
125  * registered through all iSNS servers this LHBA discovered.
126  * pg_list is NULL if no portal group object is found.
127  */
128 isns_status_t
129 isns_query(uint8_t *lhba_handle,
130 	uint8_t *node_name,
131 	uint8_t *node_alias,
132 	uint32_t node_type,
133 	isns_portal_group_list_t **pg_list);
134 
135 /*
136  * To query all portal group objects registered through the specified iSNS
137  * server registered through the specified iSNS server. pg_list is NULL if
138  * no portal group object is found.
139  */
140 isns_status_t
141 isns_query_one_server(iscsi_addr_t *isns_server_addr,
142 	uint8_t *lhba_handle,
143 	uint8_t *node_name,
144 	uint8_t *node_alias,
145 	uint32_t node_type,
146 	isns_portal_group_list_t **pg_list);
147 
148 /*
149  * To query the portal group objects associated with the specified storage
150  * node through all iSNS servers this LHBA discovered. pg_list is NULL if
151  * no portal group object is found.
152  */
153 isns_status_t
154 isns_query_one_node(uint8_t *target_node_name,
155 	uint8_t *lhba_handle,
156 	uint8_t *source_node_name,
157 	uint8_t *source_node_alias,
158 	uint32_t source_node_type,
159 	isns_portal_group_list_t **pg_list);
160 
161 /*
162  * To query the portal group objects associated with the specified storage
163  * node registered through the specified iSNS server. pg_list is NULL if
164  * no portal group object is found.
165  */
166 isns_status_t
167 isns_query_one_server_one_node(iscsi_addr_t *isns_server_addr,
168 	uint8_t *target_node_name,
169 	uint8_t *lhba_handle,
170 	uint8_t *source_node_name,
171 	uint8_t *source_node_alias,
172 	uint32_t source_node_type,
173 	isns_portal_group_list_t **pg_list);
174 
175 #ifdef __cplusplus
176 }
177 #endif
178 
179 #endif /* _ISNS_CLIENT_H */
180