xref: /illumos-gate/usr/src/uts/common/sys/idm/idm_transport.h (revision a4faba164aa153855d621c694fc5aa75dd183b81)
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	_IDM_TRANSPORT_H_
28 #define	_IDM_TRANSPORT_H_
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #include <sys/nvpair.h>
35 #include <sys/sunldi.h>
36 
37 #define	IDM_TRANSPORT_PATHLEN	0x40
38 
39 /* Note, this is tied to iSER currently */
40 #define	IDM_TRANSPORT_HEADER_LENGTH	0x20
41 
42 /*
43  * idm_transport_type_t
44  * An enumerated list of the transports available to iSER.
45  * Note that new transports should be added to the enum prior to NUM_TYPES.
46  */
47 typedef enum {
48 	IDM_TRANSPORT_TYPE_ISER	= 0,
49 	IDM_TRANSPORT_TYPE_SOCKETS,
50 	IDM_TRANSPORT_NUM_TYPES,
51 	IDM_TRANSPORT_TYPE_UNDEFINED
52 } idm_transport_type_t;
53 
54 /*
55  * idm_transport_caps_t
56  * Encodes a set of attributes describing an IDM transport's capabilities.
57  *	JB - do we need this?
58  */
59 typedef struct idm_transport_caps_s {
60 	uint32_t	flags;
61 } idm_transport_caps_t;
62 
63 /*
64  * Transport routine definitions for idm_transport_ops_t below
65  */
66 
67 /* Send_Control - transmit a Control-type PDU */
68 typedef void (transport_tx_op_t)(struct idm_conn_s *ic, struct idm_pdu_s *pdu);
69 
70 /*
71  * Target transport data primitives, caller (IDM) holds idt->idt_mutex,
72  * and the transport should release the mutex before returning.
73  */
74 typedef idm_status_t (transport_buf_tx_to_ini_op_t)(struct idm_task_s *idt,
75     struct idm_buf_s *idb);
76 typedef idm_status_t (transport_buf_rx_from_ini_op_t)(struct idm_task_s *idt,
77     struct idm_buf_s *idb);
78 
79 /* Initiator transport data handlers */
80 typedef void (transport_rx_datain_op_t)(struct idm_conn_s *ic,
81     struct idm_pdu_s *pdu);
82 typedef void (transport_rx_rtt_op_t)(struct idm_conn_s *ic,
83     struct idm_pdu_s *pdu);
84 
85 /* Target transport Data-out handler */
86 typedef void (transport_rx_dataout_op_t)(struct idm_conn_s *ic,
87     struct idm_pdu_s *pdu);
88 
89 /* Transport-specific resource allocation and free */
90 typedef idm_status_t (transport_alloc_conn_rsrc_op_t)(struct idm_conn_s *ic);
91 typedef idm_status_t (transport_free_conn_rsrc_op_t)(struct idm_conn_s *ic);
92 
93 /* Transport driver operations enable/disable */
94 typedef idm_status_t (transport_tgt_enable_datamover_op_t)(struct
95     idm_conn_s *ic);
96 typedef idm_status_t (transport_ini_enable_datamover_op_t)(struct
97     idm_conn_s *ic);
98 typedef idm_status_t (transport_conn_terminate_op_t)(struct idm_conn_s *ic);
99 
100 /* Task resource cleanup */
101 typedef idm_status_t (transport_free_task_rsrcs_op_t)(struct idm_task_s *it);
102 
103 /* Negotiate key value pairs */
104 typedef kv_status_t (transport_negotiate_key_values_op_t)(struct
105     idm_conn_s *ic, nvlist_t *request_nvl, nvlist_t *response_nvl,
106     nvlist_t *negotiated_nvl);
107 
108 /* Activate the negotiated key value pairs */
109 typedef void (transport_notice_key_values_op_t)(struct idm_conn_s *ic,
110     nvlist_t *negotiated_nvl);
111 
112 /* Declare the declarative key value pairs */
113 typedef kv_status_t (transport_declare_key_values_op_t)(struct idm_conn_s *ic,
114     nvlist_t *config_nvl, nvlist_t *outgoing_nvl);
115 
116 /* Transport capability probe */
117 typedef boolean_t (transport_conn_is_capable_op_t)(idm_conn_req_t *ic,
118     struct idm_transport_caps_s *caps);
119 
120 /* Transport buffer services */
121 typedef idm_status_t (transport_buf_alloc_op_t)(struct idm_buf_s *idb,
122     uint64_t buflen);
123 typedef idm_status_t (transport_buf_setup_op_t)(struct idm_buf_s *idb);
124 typedef void (transport_buf_teardown_op_t)(struct idm_buf_s *idb);
125 typedef void (transport_buf_free_op_t)(struct idm_buf_s *idb);
126 
127 /* Transport target context and service management services */
128 typedef idm_status_t (transport_tgt_svc_create_op_t)(idm_svc_req_t *sr,
129     struct idm_svc_s *is);
130 typedef void (transport_tgt_svc_destroy_op_t)(struct idm_svc_s *is);
131 typedef idm_status_t (transport_tgt_svc_online_op_t)(struct idm_svc_s *is);
132 typedef void (transport_tgt_svc_offline_op_t)(struct idm_svc_s *is);
133 
134 /* Transport target connection establishment */
135 typedef void (transport_tgt_conn_destroy_op_t)(struct idm_conn_s *ic);
136 typedef idm_status_t (transport_tgt_conn_connect_op_t)(struct idm_conn_s *ic);
137 typedef void (transport_tgt_conn_disconnect_op_t)(struct idm_conn_s *ic);
138 
139 /* Transport initiator context and connection management services */
140 typedef idm_status_t (transport_ini_conn_create_op_t)(idm_conn_req_t *cr,
141     struct idm_conn_s *ic);
142 typedef void (transport_ini_conn_destroy_op_t)(struct idm_conn_s *ic);
143 typedef idm_status_t (transport_ini_conn_connect_op_t)(struct idm_conn_s *ic);
144 typedef void (transport_ini_conn_disconnect_op_t)(struct idm_conn_s *ic);
145 
146 
147 /*
148  * idm_transport_ops_t
149  * Encodes a set of vectors into an IDM transport driver that implement the
150  * transport-specific Datamover operations for IDM usage. These routines are
151  * invoked by the IDM layer to execute the transport-specific implementations
152  * of the DataMover primitives and supporting routines.
153  */
154 typedef struct idm_transport_ops_s {
155 	transport_tx_op_t			*it_tx_pdu;
156 	transport_buf_tx_to_ini_op_t		*it_buf_tx_to_ini;
157 	transport_buf_rx_from_ini_op_t		*it_buf_rx_from_ini;
158 	transport_rx_datain_op_t		*it_rx_datain;
159 	transport_rx_rtt_op_t			*it_rx_rtt;
160 	transport_rx_dataout_op_t		*it_rx_dataout;
161 	transport_alloc_conn_rsrc_op_t		*it_alloc_conn_rsrc;
162 	transport_free_conn_rsrc_op_t		*it_free_conn_rsrc;
163 	transport_tgt_enable_datamover_op_t	*it_tgt_enable_datamover;
164 	transport_ini_enable_datamover_op_t	*it_ini_enable_datamover;
165 	transport_conn_terminate_op_t		*it_conn_terminate;
166 	transport_free_task_rsrcs_op_t		*it_free_task_rsrc;
167 	transport_negotiate_key_values_op_t	*it_negotiate_key_values;
168 	transport_notice_key_values_op_t	*it_notice_key_values;
169 	transport_conn_is_capable_op_t		*it_conn_is_capable;
170 	transport_buf_alloc_op_t		*it_buf_alloc;
171 	transport_buf_free_op_t			*it_buf_free;
172 	transport_buf_setup_op_t		*it_buf_setup;
173 	transport_buf_teardown_op_t		*it_buf_teardown;
174 	transport_tgt_svc_create_op_t		*it_tgt_svc_create;
175 	transport_tgt_svc_destroy_op_t		*it_tgt_svc_destroy;
176 	transport_tgt_svc_online_op_t		*it_tgt_svc_online;
177 	transport_tgt_svc_offline_op_t		*it_tgt_svc_offline;
178 	transport_tgt_conn_destroy_op_t		*it_tgt_conn_destroy;
179 	transport_tgt_conn_connect_op_t		*it_tgt_conn_connect;
180 	transport_tgt_conn_disconnect_op_t	*it_tgt_conn_disconnect;
181 	transport_ini_conn_create_op_t		*it_ini_conn_create;
182 	transport_ini_conn_destroy_op_t		*it_ini_conn_destroy;
183 	transport_ini_conn_connect_op_t		*it_ini_conn_connect;
184 	transport_ini_conn_disconnect_op_t	*it_ini_conn_disconnect;
185 	transport_declare_key_values_op_t	*it_declare_key_values;
186 } idm_transport_ops_t;
187 
188 /*
189  * idm_transport_t encodes all of the data related to an IDM transport
190  * type. In addition to type and capabilities, it also stores a pointer
191  * to the connection and transport operation implementations, and also
192  * it stores the LDI handle.
193  */
194 typedef struct idm_transport_s {
195 	idm_transport_type_t	it_type;
196 	char			*it_device_path;
197 	ldi_handle_t		it_ldi_hdl;
198 	idm_transport_ops_t	*it_ops;
199 	idm_transport_caps_t	*it_caps;
200 } idm_transport_t;
201 
202 /*
203  * idm_transport_attr_t encodes details of a transport driver seeking
204  * registration with the IDM kernel module.
205  */
206 typedef struct idm_transport_attr_s {
207 	idm_transport_type_t	type;
208 	idm_transport_ops_t	*it_ops;
209 	idm_transport_caps_t	*it_caps;
210 } idm_transport_attr_t;
211 
212 /* IDM transport API */
213 idm_status_t
214 idm_transport_register(idm_transport_attr_t *attr);
215 
216 idm_transport_t *
217 idm_transport_lookup(idm_conn_req_t *cr);
218 
219 void
220 idm_transport_setup(ldi_ident_t li);
221 
222 void
223 idm_transport_teardown();
224 
225 #ifdef	__cplusplus
226 }
227 #endif
228 
229 #endif /* _IDM_TRANSPORT_H_ */
230