xref: /titanic_51/usr/src/lib/librsm/inc/rsmapi.h (revision bbaa8b60dd95d714741fc474adad3cf710ef4efd)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1999-2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _RSMAPI_H
28 #define	_RSMAPI_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <poll.h>
37 #include <sys/param.h>
38 #include <sys/rsm/rsm_common.h>
39 #include <sys/rsm/rsmapi_common.h>
40 
41 typedef enum {
42 	RSM_MAP_NONE = 0x0,
43 	RSM_MAP_FIXED = 0x1,
44 	RSM_MAP_RESERVED = 0x2
45 }rsm_attribute_t;
46 
47 /*
48  * Topology data structures - The primary structure is struct rsm_topology_t
49  *
50  * The key interconnect data required for segment operations includes the
51  * cluster nodeids and the controllers (name, hardware address); with
52  * the fundamental constraint that the controller specified for a segment
53  * import must have a physical connection with the contorller used in the
54  * export of the segment. To facilitate applications in the establishment
55  * of proper and efficient export and import policies, a delineation of the
56  * interconnect topology is provided by these data structures.
57  *
58  */
59 
60 
61 #define	RSM_CONNECTION_ACTIVE	3
62 
63 
64 typedef struct rsm_topology_hdr {
65 	rsm_node_id_t		local_nodeid;
66 	uint_t			local_cntlr_count;
67 } rsm_topology_hdr_t;
68 
69 
70 typedef struct rsm_connections_hdr {
71 	char		cntlr_name[MAXNAMELEN]; /* <cntlr_type><unit> */
72 	rsm_addr_t	local_hwaddr;
73 	int		remote_cntlr_count;
74 } rsm_connections_hdr_t;
75 
76 
77 /*
78  * The remote cntrlname element should be used for matching with the
79  * cntrlname of an exported segment.
80  *
81  * An application must not attempt to use a connection unless the
82  * the connection_state element of struct rsm_remote_cntlr_t is equal to
83  * RSM_CONNECTION_ACTIVE
84  */
85 typedef struct rsm_remote_cntlr {
86 	rsm_node_id_t		remote_nodeid;
87 	char			remote_cntlrname[MAXNAMELEN];
88 	rsm_addr_t		remote_hwaddr;
89 	uint_t			connection_state;
90 } rsm_remote_cntlr_t;
91 
92 
93 /*
94  * The actual size of the remote_cntlr array is equal to the remote_cntlr_count
95  * of the rsm_connections_hdr_t struct.
96  */
97 typedef struct rsm_connection {
98 	rsm_connections_hdr_t	hdr;
99 	rsm_remote_cntlr_t	remote_cntlr[1];
100 } rsm_connections_t;
101 
102 
103 /*
104  * A pointer to an instance of this structure type is returned by a call
105  * to rsm_get_interconnect_topology().  The actual size of the connections
106  * array is equal to the local_cntlr_count of the rsm_topology_hdr_t struct.
107  */
108 typedef struct rsm_topology {
109 	rsm_topology_hdr_t	topology_hdr;
110 	rsm_connections_t	*connections[1];
111 } rsm_topology_t;
112 
113 /*
114  * function templates:
115  */
116 
117 int rsm_get_controller(char *name, rsmapi_controller_handle_t *controller);
118 
119 int rsm_get_controller_attr(rsmapi_controller_handle_t chdl,
120     rsmapi_controller_attr_t *attr);
121 
122 int rsm_release_controller(rsmapi_controller_handle_t controller);
123 
124 /*
125  * Export side memory segment operations
126  */
127 int rsm_memseg_export_create(rsmapi_controller_handle_t controller,
128     rsm_memseg_export_handle_t *memseg,
129     void *vaddr, size_t size, uint_t flags);
130 
131 
132 int rsm_memseg_export_destroy(rsm_memseg_export_handle_t memseg);
133 
134 
135 
136 int rsm_memseg_export_rebind(rsm_memseg_export_handle_t memseg,
137     void *vaddr, offset_t off, size_t size);
138 
139 
140 
141 int rsm_memseg_export_publish(rsm_memseg_export_handle_t memseg,
142     rsm_memseg_id_t *segment_id,
143     rsmapi_access_entry_t access_list[],
144     uint_t access_list_length);
145 
146 
147 int rsm_memseg_export_unpublish(rsm_memseg_export_handle_t memseg);
148 
149 int rsm_memseg_export_republish(rsm_memseg_export_handle_t memseg,
150     rsmapi_access_entry_t access_list[],
151     uint_t access_list_length);
152 
153 
154 
155 
156 
157 
158 
159 /*
160  * import side memory segment operations:
161  */
162 
163 int rsm_memseg_import_connect(rsmapi_controller_handle_t controller,
164     rsm_node_id_t node_id,
165     rsm_memseg_id_t segment_id,
166     rsm_permission_t perm,
167     rsm_memseg_import_handle_t *im_memseg);
168 
169 
170 int rsm_memseg_import_disconnect(rsm_memseg_import_handle_t im_memseg);
171 
172 
173 
174 /*
175  * import side memory segment operations (read access functions):
176  */
177 int rsm_memseg_import_get8(rsm_memseg_import_handle_t im_memseg,
178     off_t offset,
179     uint8_t *datap,
180     ulong_t rep_cnt);
181 int rsm_memseg_import_get16(rsm_memseg_import_handle_t im_memseg,
182     off_t offset,
183     uint16_t *datap,
184     ulong_t rep_cnt);
185 int rsm_memseg_import_get32(rsm_memseg_import_handle_t im_memseg,
186     off_t offset,
187     uint32_t *datap,
188     ulong_t rep_cnt);
189 int rsm_memseg_import_get64(rsm_memseg_import_handle_t im_memseg,
190     off_t offset,
191     uint64_t *datap,
192     ulong_t rep_cnt);
193 int rsm_memseg_import_get(rsm_memseg_import_handle_t im_memseg,
194     off_t offset,
195     void *dst_addr,
196     size_t length);
197 
198 int rsm_memseg_import_getv(rsm_scat_gath_t *);
199 
200 
201 
202 /*
203  * import side memory segment operations (write access functions):
204  */
205 int rsm_memseg_import_put8(rsm_memseg_import_handle_t im_memseg,
206     off_t offset,
207     uint8_t *datap,
208     ulong_t rep_cnt);
209 int rsm_memseg_import_put16(rsm_memseg_import_handle_t im_memseg,
210     off_t offset,
211     uint16_t *datap,
212     ulong_t rep_cnt);
213 int rsm_memseg_import_put32(rsm_memseg_import_handle_t im_memseg,
214     off_t offset,
215     uint32_t *datap,
216     ulong_t rep_cnt);
217 int rsm_memseg_import_put64(rsm_memseg_import_handle_t im_memseg,
218     off_t offset,
219     uint64_t *datap,
220     ulong_t rep_cnt);
221 int rsm_memseg_import_put(rsm_memseg_import_handle_t im_memseg,
222     off_t offset,
223     void *src_addr,
224     size_t length);
225 
226 int rsm_memseg_import_putv(rsm_scat_gath_t *);
227 
228 
229 /*
230  * import side memory segment operations (mapping):
231  */
232 int rsm_memseg_import_map(rsm_memseg_import_handle_t im_memseg,
233     void **address,
234     rsm_attribute_t attr,
235     rsm_permission_t perm,
236     off_t offset, size_t length);
237 
238 
239 
240 
241 int rsm_memseg_import_unmap(rsm_memseg_import_handle_t im_memseg);
242 
243 
244 
245 /*
246  * import side memory segment operations (barriers):
247  */
248 
249 int rsm_memseg_import_init_barrier(rsm_memseg_import_handle_t im_memseg,
250     rsm_barrier_type_t type,
251     rsmapi_barrier_t *barrier);
252 
253 
254 int rsm_memseg_import_open_barrier(rsmapi_barrier_t *barrier);
255 
256 
257 int rsm_memseg_import_close_barrier(rsmapi_barrier_t *barrier);
258 
259 int rsm_memseg_import_order_barrier(rsmapi_barrier_t *barrier);
260 
261 int rsm_memseg_import_destroy_barrier(rsmapi_barrier_t *barrier);
262 
263 int rsm_memseg_import_get_mode(rsm_memseg_import_handle_t im_memseg,
264     rsm_barrier_mode_t *mode);
265 
266 int rsm_memseg_import_set_mode(rsm_memseg_import_handle_t im_memseg,
267     rsm_barrier_mode_t mode);
268 
269 
270 
271 
272 int rsm_intr_signal_post(void * im_memseg, uint_t flags);
273 
274 int rsm_intr_signal_wait(void * im_memseg, int timeout);
275 
276 int rsm_memseg_get_pollfd(void *, struct pollfd *);
277 int rsm_memseg_release_pollfd(void *);
278 
279 int rsm_get_interconnect_topology(rsm_topology_t **);
280 void rsm_free_interconnect_topology(rsm_topology_t *);
281 
282 int rsm_create_localmemory_handle(rsmapi_controller_handle_t,
283     rsm_localmemory_handle_t *,
284     caddr_t, size_t);
285 
286 int rsm_free_localmemory_handle(rsmapi_controller_handle_t,
287     rsm_localmemory_handle_t);
288 
289 int rsm_get_segmentid_range(const char *, rsm_memseg_id_t *, uint32_t *);
290 
291 int rsm_intr_signal_wait_pollfd(struct pollfd [], nfds_t, int, int *);
292 
293 #ifdef	__cplusplus
294 }
295 #endif
296 
297 #endif	/* _RSMAPI_H */
298