1*fcf3ce44SJohn Forte /*
2*fcf3ce44SJohn Forte  * CDDL HEADER START
3*fcf3ce44SJohn Forte  *
4*fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5*fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6*fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7*fcf3ce44SJohn Forte  *
8*fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10*fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11*fcf3ce44SJohn Forte  * and limitations under the License.
12*fcf3ce44SJohn Forte  *
13*fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14*fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16*fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17*fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18*fcf3ce44SJohn Forte  *
19*fcf3ce44SJohn Forte  * CDDL HEADER END
20*fcf3ce44SJohn Forte  */
21*fcf3ce44SJohn Forte /*
22*fcf3ce44SJohn Forte  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*fcf3ce44SJohn Forte  * Use is subject to license terms.
24*fcf3ce44SJohn Forte  */
25*fcf3ce44SJohn Forte 
26*fcf3ce44SJohn Forte #ifndef	_ISNS_CLIENT_H
27*fcf3ce44SJohn Forte #define	_ISNS_CLIENT_H
28*fcf3ce44SJohn Forte 
29*fcf3ce44SJohn Forte #ifdef __cplusplus
30*fcf3ce44SJohn Forte extern "C" {
31*fcf3ce44SJohn Forte #endif
32*fcf3ce44SJohn Forte 
33*fcf3ce44SJohn Forte #include <sys/types.h>
34*fcf3ce44SJohn Forte #include <sys/scsi/adapters/iscsi_if.h>
35*fcf3ce44SJohn Forte 
36*fcf3ce44SJohn Forte #define	ISNS_DEFAULT_ESI_SCN_PORT	32046
37*fcf3ce44SJohn Forte #define	ISNS_DEFAULT_PORTAL_GROUP_TAG	1
38*fcf3ce44SJohn Forte 
39*fcf3ce44SJohn Forte typedef enum isns_status {
40*fcf3ce44SJohn Forte 	isns_ok,
41*fcf3ce44SJohn Forte 	isns_no_svr_found,
42*fcf3ce44SJohn Forte 	isns_internal_err,
43*fcf3ce44SJohn Forte 	isns_create_msg_err,
44*fcf3ce44SJohn Forte 	isns_open_conn_err,
45*fcf3ce44SJohn Forte 	isns_send_msg_err,
46*fcf3ce44SJohn Forte 	isns_rcv_msg_err,
47*fcf3ce44SJohn Forte 	isns_no_rsp_rcvd,
48*fcf3ce44SJohn Forte 	isns_op_failed,
49*fcf3ce44SJohn Forte 	isns_op_partially_failed,
50*fcf3ce44SJohn Forte 	isns_no_transport_found
51*fcf3ce44SJohn Forte } isns_status_t;
52*fcf3ce44SJohn Forte 
53*fcf3ce44SJohn Forte #define	ISNSP_MULT_PAYLOAD_HEADER_SIZE		8
54*fcf3ce44SJohn Forte /*
55*fcf3ce44SJohn Forte  * when we concatenate payloads from multiple pdus, we need
56*fcf3ce44SJohn Forte  * a larger payload_len then what is defined in isns_protocol.h
57*fcf3ce44SJohn Forte  *
58*fcf3ce44SJohn Forte  * for each payload that comes in, we need to save off the payload_len
59*fcf3ce44SJohn Forte  * and the payload
60*fcf3ce44SJohn Forte  */
61*fcf3ce44SJohn Forte typedef struct isns_pdu_mult_payload {
62*fcf3ce44SJohn Forte 	size_t payload_len;
63*fcf3ce44SJohn Forte 	uint8_t payload[1];
64*fcf3ce44SJohn Forte } isns_pdu_mult_payload_t;
65*fcf3ce44SJohn Forte 
66*fcf3ce44SJohn Forte typedef struct isns_scn_callback_arg {
67*fcf3ce44SJohn Forte 	uint32_t scn_type;
68*fcf3ce44SJohn Forte 	uint8_t source_key_attr[ISCSI_MAX_NAME_LEN];
69*fcf3ce44SJohn Forte } isns_scn_callback_arg_t;
70*fcf3ce44SJohn Forte 
71*fcf3ce44SJohn Forte /*
72*fcf3ce44SJohn Forte  * To initialize the iSNS Client module.
73*fcf3ce44SJohn Forte  */
74*fcf3ce44SJohn Forte void
75*fcf3ce44SJohn Forte isns_client_init(void);
76*fcf3ce44SJohn Forte 
77*fcf3ce44SJohn Forte /*
78*fcf3ce44SJohn Forte  * To clean up the resources associated with the iSNS Client module.
79*fcf3ce44SJohn Forte  */
80*fcf3ce44SJohn Forte void
81*fcf3ce44SJohn Forte isns_client_cleanup(void);
82*fcf3ce44SJohn Forte 
83*fcf3ce44SJohn Forte /*
84*fcf3ce44SJohn Forte  * To register a network entity against the iSNS server(s) visible to the
85*fcf3ce44SJohn Forte  * specified LHBA.
86*fcf3ce44SJohn Forte  */
87*fcf3ce44SJohn Forte isns_status_t
88*fcf3ce44SJohn Forte isns_reg(uint8_t *lhba_handle,
89*fcf3ce44SJohn Forte 	uint8_t *node_name,
90*fcf3ce44SJohn Forte 	size_t node_name_len,
91*fcf3ce44SJohn Forte 	uint8_t *node_alias,
92*fcf3ce44SJohn Forte 	size_t node_alias_len,
93*fcf3ce44SJohn Forte 	uint32_t node_type,
94*fcf3ce44SJohn Forte 	void (*scn_callback)(void *));
95*fcf3ce44SJohn Forte 
96*fcf3ce44SJohn Forte /*
97*fcf3ce44SJohn Forte  * To register a network entity against the specified iSNS server.
98*fcf3ce44SJohn Forte  */
99*fcf3ce44SJohn Forte isns_status_t
100*fcf3ce44SJohn Forte isns_reg_one_server(entry_t *isns_server,
101*fcf3ce44SJohn Forte 	uint8_t *lhba_handle,
102*fcf3ce44SJohn Forte 	uint8_t *node_name,
103*fcf3ce44SJohn Forte 	size_t node_name_len,
104*fcf3ce44SJohn Forte 	uint8_t *node_alias,
105*fcf3ce44SJohn Forte 	size_t node_alias_len,
106*fcf3ce44SJohn Forte 	uint32_t node_type,
107*fcf3ce44SJohn Forte 	void (*scn_callback)(void *));
108*fcf3ce44SJohn Forte 
109*fcf3ce44SJohn Forte /*
110*fcf3ce44SJohn Forte  * To deregister a network entity from the all iSNS server(s) visible to the
111*fcf3ce44SJohn Forte  * specified LHBA.
112*fcf3ce44SJohn Forte  */
113*fcf3ce44SJohn Forte isns_status_t
114*fcf3ce44SJohn Forte isns_dereg(uint8_t *lhba_handle, uint8_t *node_name);
115*fcf3ce44SJohn Forte 
116*fcf3ce44SJohn Forte /*
117*fcf3ce44SJohn Forte  * To deregister a network entity from the specified iSNS server.
118*fcf3ce44SJohn Forte  */
119*fcf3ce44SJohn Forte isns_status_t
120*fcf3ce44SJohn Forte isns_dereg_one_server(entry_t *isns_server, uint8_t *node_name,
121*fcf3ce44SJohn Forte 	boolean_t is_last_isns_server);
122*fcf3ce44SJohn Forte 
123*fcf3ce44SJohn Forte /*
124*fcf3ce44SJohn Forte  * To query all portal group objects that are visible to the specified LHBA
125*fcf3ce44SJohn Forte  * registered through all iSNS servers this LHBA discovered.
126*fcf3ce44SJohn Forte  * pg_list is NULL if no portal group object is found.
127*fcf3ce44SJohn Forte  */
128*fcf3ce44SJohn Forte isns_status_t
129*fcf3ce44SJohn Forte isns_query(uint8_t *lhba_handle,
130*fcf3ce44SJohn Forte 	uint8_t *node_name,
131*fcf3ce44SJohn Forte 	uint8_t *node_alias,
132*fcf3ce44SJohn Forte 	uint32_t node_type,
133*fcf3ce44SJohn Forte 	isns_portal_group_list_t **pg_list);
134*fcf3ce44SJohn Forte 
135*fcf3ce44SJohn Forte /*
136*fcf3ce44SJohn Forte  * To query all portal group objects registered through the specified iSNS
137*fcf3ce44SJohn Forte  * server registered through the specified iSNS server. pg_list is NULL if
138*fcf3ce44SJohn Forte  * no portal group object is found.
139*fcf3ce44SJohn Forte  */
140*fcf3ce44SJohn Forte isns_status_t
141*fcf3ce44SJohn Forte isns_query_one_server(iscsi_addr_t *isns_server_addr,
142*fcf3ce44SJohn Forte 	uint8_t *lhba_handle,
143*fcf3ce44SJohn Forte 	uint8_t *node_name,
144*fcf3ce44SJohn Forte 	uint8_t *node_alias,
145*fcf3ce44SJohn Forte 	uint32_t node_type,
146*fcf3ce44SJohn Forte 	isns_portal_group_list_t **pg_list);
147*fcf3ce44SJohn Forte 
148*fcf3ce44SJohn Forte /*
149*fcf3ce44SJohn Forte  * To query the portal group objects associated with the specified storage
150*fcf3ce44SJohn Forte  * node through all iSNS servers this LHBA discovered. pg_list is NULL if
151*fcf3ce44SJohn Forte  * no portal group object is found.
152*fcf3ce44SJohn Forte  */
153*fcf3ce44SJohn Forte isns_status_t
154*fcf3ce44SJohn Forte isns_query_one_node(uint8_t *target_node_name,
155*fcf3ce44SJohn Forte 	uint8_t *lhba_handle,
156*fcf3ce44SJohn Forte 	uint8_t *source_node_name,
157*fcf3ce44SJohn Forte 	uint8_t *source_node_alias,
158*fcf3ce44SJohn Forte 	uint32_t source_node_type,
159*fcf3ce44SJohn Forte 	isns_portal_group_list_t **pg_list);
160*fcf3ce44SJohn Forte 
161*fcf3ce44SJohn Forte /*
162*fcf3ce44SJohn Forte  * To query the portal group objects associated with the specified storage
163*fcf3ce44SJohn Forte  * node registered through the specified iSNS server. pg_list is NULL if
164*fcf3ce44SJohn Forte  * no portal group object is found.
165*fcf3ce44SJohn Forte  */
166*fcf3ce44SJohn Forte isns_status_t
167*fcf3ce44SJohn Forte isns_query_one_server_one_node(iscsi_addr_t *isns_server_addr,
168*fcf3ce44SJohn Forte 	uint8_t *target_node_name,
169*fcf3ce44SJohn Forte 	uint8_t *lhba_handle,
170*fcf3ce44SJohn Forte 	uint8_t *source_node_name,
171*fcf3ce44SJohn Forte 	uint8_t *source_node_alias,
172*fcf3ce44SJohn Forte 	uint32_t source_node_type,
173*fcf3ce44SJohn Forte 	isns_portal_group_list_t **pg_list);
174*fcf3ce44SJohn Forte 
175*fcf3ce44SJohn Forte #ifdef __cplusplus
176*fcf3ce44SJohn Forte }
177*fcf3ce44SJohn Forte #endif
178*fcf3ce44SJohn Forte 
179*fcf3ce44SJohn Forte #endif /* _ISNS_CLIENT_H */
180