xref: /illumos-gate/usr/src/uts/common/sys/idm/idm_transport.h (revision e44e85a7f9935f0428e188393e3da61b17e83884)
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 /* Transport capability probe */
113 typedef boolean_t (transport_conn_is_capable_op_t)(idm_conn_req_t *ic,
114     struct idm_transport_caps_s *caps);
115 
116 /* Transport buffer services */
117 typedef idm_status_t (transport_buf_alloc_op_t)(struct idm_buf_s *idb,
118     uint64_t buflen);
119 typedef idm_status_t (transport_buf_setup_op_t)(struct idm_buf_s *idb);
120 typedef void (transport_buf_teardown_op_t)(struct idm_buf_s *idb);
121 typedef void (transport_buf_free_op_t)(struct idm_buf_s *idb);
122 
123 /* Transport target context and service management services */
124 typedef idm_status_t (transport_tgt_svc_create_op_t)(idm_svc_req_t *sr,
125     struct idm_svc_s *is);
126 typedef void (transport_tgt_svc_destroy_op_t)(struct idm_svc_s *is);
127 typedef idm_status_t (transport_tgt_svc_online_op_t)(struct idm_svc_s *is);
128 typedef void (transport_tgt_svc_offline_op_t)(struct idm_svc_s *is);
129 
130 /* Transport target connection establishment */
131 typedef void (transport_tgt_conn_destroy_op_t)(struct idm_conn_s *ic);
132 typedef idm_status_t (transport_tgt_conn_connect_op_t)(struct idm_conn_s *ic);
133 typedef void (transport_tgt_conn_disconnect_op_t)(struct idm_conn_s *ic);
134 
135 /* Transport initiator context and connection management services */
136 typedef idm_status_t (transport_ini_conn_create_op_t)(idm_conn_req_t *cr,
137     struct idm_conn_s *ic);
138 typedef void (transport_ini_conn_destroy_op_t)(struct idm_conn_s *ic);
139 typedef idm_status_t (transport_ini_conn_connect_op_t)(struct idm_conn_s *ic);
140 typedef void (transport_ini_conn_disconnect_op_t)(struct idm_conn_s *ic);
141 
142 
143 /*
144  * idm_transport_ops_t
145  * Encodes a set of vectors into an IDM transport driver that implement the
146  * transport-specific Datamover operations for IDM usage. These routines are
147  * invoked by the IDM layer to execute the transport-specific implementations
148  * of the DataMover primitives and supporting routines.
149  */
150 typedef struct idm_transport_ops_s {
151 	transport_tx_op_t			*it_tx_pdu;
152 	transport_buf_tx_to_ini_op_t		*it_buf_tx_to_ini;
153 	transport_buf_rx_from_ini_op_t		*it_buf_rx_from_ini;
154 	transport_rx_datain_op_t		*it_rx_datain;
155 	transport_rx_rtt_op_t			*it_rx_rtt;
156 	transport_rx_dataout_op_t		*it_rx_dataout;
157 	transport_alloc_conn_rsrc_op_t		*it_alloc_conn_rsrc;
158 	transport_free_conn_rsrc_op_t		*it_free_conn_rsrc;
159 	transport_tgt_enable_datamover_op_t	*it_tgt_enable_datamover;
160 	transport_ini_enable_datamover_op_t	*it_ini_enable_datamover;
161 	transport_conn_terminate_op_t		*it_conn_terminate;
162 	transport_free_task_rsrcs_op_t		*it_free_task_rsrc;
163 	transport_negotiate_key_values_op_t	*it_negotiate_key_values;
164 	transport_notice_key_values_op_t	*it_notice_key_values;
165 	transport_conn_is_capable_op_t		*it_conn_is_capable;
166 	transport_buf_alloc_op_t		*it_buf_alloc;
167 	transport_buf_free_op_t			*it_buf_free;
168 	transport_buf_setup_op_t		*it_buf_setup;
169 	transport_buf_teardown_op_t		*it_buf_teardown;
170 	transport_tgt_svc_create_op_t		*it_tgt_svc_create;
171 	transport_tgt_svc_destroy_op_t		*it_tgt_svc_destroy;
172 	transport_tgt_svc_online_op_t		*it_tgt_svc_online;
173 	transport_tgt_svc_offline_op_t		*it_tgt_svc_offline;
174 	transport_tgt_conn_destroy_op_t		*it_tgt_conn_destroy;
175 	transport_tgt_conn_connect_op_t		*it_tgt_conn_connect;
176 	transport_tgt_conn_disconnect_op_t	*it_tgt_conn_disconnect;
177 	transport_ini_conn_create_op_t		*it_ini_conn_create;
178 	transport_ini_conn_destroy_op_t		*it_ini_conn_destroy;
179 	transport_ini_conn_connect_op_t		*it_ini_conn_connect;
180 	transport_ini_conn_disconnect_op_t	*it_ini_conn_disconnect;
181 } idm_transport_ops_t;
182 
183 /*
184  * idm_transport_t encodes all of the data related to an IDM transport
185  * type. In addition to type and capabilities, it also stores a pointer
186  * to the connection and transport operation implementations, and also
187  * it stores the LDI handle.
188  */
189 typedef struct idm_transport_s {
190 	idm_transport_type_t	it_type;
191 	char			*it_device_path;
192 	ldi_handle_t		it_ldi_hdl;
193 	idm_transport_ops_t	*it_ops;
194 	idm_transport_caps_t	*it_caps;
195 } idm_transport_t;
196 
197 /*
198  * idm_transport_attr_t encodes details of a transport driver seeking
199  * registration with the IDM kernel module.
200  */
201 typedef struct idm_transport_attr_s {
202 	idm_transport_type_t	type;
203 	idm_transport_ops_t	*it_ops;
204 	idm_transport_caps_t	*it_caps;
205 } idm_transport_attr_t;
206 
207 /* IDM transport API */
208 idm_status_t
209 idm_transport_register(idm_transport_attr_t *attr);
210 
211 idm_transport_t *
212 idm_transport_lookup(idm_conn_req_t *cr);
213 
214 void
215 idm_transport_setup(ldi_ident_t li);
216 
217 void
218 idm_transport_teardown();
219 
220 #ifdef	__cplusplus
221 }
222 #endif
223 
224 #endif /* _IDM_TRANSPORT_H_ */
225