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
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.
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]
23 * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_RSM_RSMNDI_H
28 #define _SYS_RSM_RSMNDI_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
36 #include <sys/types.h>
42 #include <sys/rsm/rsm_common.h>
43 #include <sys/rsm/rsmapi_common.h>
46 * This structure defines the functions implemented in rsmlib
47 * that the NDI library can call.
51 #define RSM_LIB_FUNCS_VERSION 1
52 int (* rsm_get_hwaddr
)(
53 rsmapi_controller_handle_t handle
,
56 int (* rsm_get_nodeid
)(
57 rsmapi_controller_handle_t handle
,
59 rsm_node_id_t
*nodeidp
);
62 /* Library attributes - set by specific NDI libraries */
64 boolean_t rsm_putget_map_reqd
; /* put/get require mapping */
65 boolean_t rsm_scatgath_map_reqd
; /* putv/getv require mapping */
68 /* The opaque barrier handle used by the RSMNDI plugin for the barrier calls */
69 typedef struct rsm_barrier
*rsm_barrier_handle_t
;
74 * structure revision number:
79 * import side memory segment operations
81 int (* rsm_memseg_import_connect
)
82 (rsmapi_controller_handle_t controller
,
83 rsm_node_id_t node_id
,
84 rsm_memseg_id_t segment_id
,
85 rsm_permission_t perm
,
86 rsm_memseg_import_handle_t
*im_memseg
);
87 int (* rsm_memseg_import_disconnect
)
88 (rsm_memseg_import_handle_t im_memseg
);
91 * import side memory segment operations (read access functions):
93 int (* rsm_memseg_import_get8
)
94 (rsm_memseg_import_handle_t im_memseg
,
99 int (* rsm_memseg_import_get16
)
100 (rsm_memseg_import_handle_t im_memseg
,
105 int (* rsm_memseg_import_get32
)
106 (rsm_memseg_import_handle_t im_memseg
,
111 int (* rsm_memseg_import_get64
)
112 (rsm_memseg_import_handle_t im_memseg
,
117 int (* rsm_memseg_import_get
)
118 (rsm_memseg_import_handle_t im_memseg
,
124 * import side memory segment operations (read access functions):
126 int (* rsm_memseg_import_put8
)
127 (rsm_memseg_import_handle_t im_memseg
,
132 int (* rsm_memseg_import_put16
)
133 (rsm_memseg_import_handle_t im_memseg
,
138 int (* rsm_memseg_import_put32
)
139 (rsm_memseg_import_handle_t im_memseg
,
144 int (* rsm_memseg_import_put64
)
145 (rsm_memseg_import_handle_t im_memseg
,
150 int (* rsm_memseg_import_put
)
151 (rsm_memseg_import_handle_t im_memseg
,
157 * import side memory segment operations (barriers):
159 int (* rsm_memseg_import_init_barrier
)
160 (rsm_memseg_import_handle_t im_memseg
,
161 rsm_barrier_type_t type
,
162 rsm_barrier_handle_t barrier
);
164 int (* rsm_memseg_import_open_barrier
)(rsm_barrier_handle_t barrier
);
166 int (* rsm_memseg_import_order_barrier
)(rsm_barrier_handle_t barrier
);
168 int (* rsm_memseg_import_close_barrier
)(rsm_barrier_handle_t barrier
);
170 int (* rsm_memseg_import_destroy_barrier
)(rsm_barrier_handle_t barrier
);
172 int (* rsm_memseg_import_get_mode
)
173 (rsm_memseg_import_handle_t im_memseg
,
174 rsm_barrier_mode_t
*mode
);
176 int (* rsm_memseg_import_set_mode
)
177 (rsm_memseg_import_handle_t im_memseg
,
178 rsm_barrier_mode_t mode
);
182 * import side memory segment data transfer operations.
184 int (* rsm_memseg_import_putv
)(rsm_scat_gath_t
*sg_io
);
185 int (* rsm_memseg_import_getv
)(rsm_scat_gath_t
*sg_io
);
187 int (* rsm_create_localmemory_handle
)
188 (rsmapi_controller_handle_t controller
,
189 rsm_localmemory_handle_t
*local_handle_p
,
190 caddr_t local_vaddr
, size_t len
);
192 int (* rsm_free_localmemory_handle
)
193 (rsm_localmemory_handle_t local_handle
);
195 int (* rsm_register_lib_funcs
)
196 (rsm_lib_funcs_t
*libfuncs
);
197 int (* rsm_get_lib_attr
)
198 (rsm_ndlib_attr_t
**libattr
);
199 int (* rsm_closedevice
)
200 (rsmapi_controller_handle_t controller
);
203 #define RSM_LIB_VERSION 1
205 /* library internal controller attribute structure */
207 /* following fields should be identical to rsmapi_controller_attr_t */
208 uint_t attr_direct_access_sizes
;
209 uint_t attr_atomic_sizes
;
210 size_t attr_page_size
;
211 size_t attr_max_export_segment_size
;
212 size_t attr_tot_export_segment_size
;
213 ulong_t attr_max_export_segments
;
214 size_t attr_max_import_map_size
;
215 size_t attr_tot_import_map_size
;
216 ulong_t attr_max_import_segments
;
217 /* following fields are for internal use */
218 rsm_addr_t attr_controller_addr
;
219 } rsm_int_controller_attr_t
;
221 typedef struct rsm_controller
{
223 struct rsm_controller
*cntr_next
;
227 char *cntr_name
; /* generic type eg. sci */
228 rsm_segops_t
*cntr_segops
;
229 struct rsmqueue
*cntr_rqlist
; /* list of receive queues */
230 rsm_int_controller_attr_t cntr_attr
;
231 rsm_ndlib_attr_t
*cntr_lib_attr
;
248 void *rsmseg_privdata
;
249 rsm_segops_t
*rsmseg_ops
;
250 rsm_seg_state_t rsmseg_state
;
251 caddr_t rsmseg_vaddr
; /* base address of segment */
252 size_t rsmseg_size
; /* size of segment */
253 size_t rsmseg_maplen
; /* length of mapped region */
254 rsm_node_id_t rsmseg_nodeid
;
255 rsm_memseg_id_t rsmseg_keyid
;
257 int rsmseg_pollfd_refcnt
;
258 rsm_permission_t rsmseg_perm
;
259 rsm_controller_t
*rsmseg_controller
;
260 rsm_barrier_mode_t rsmseg_barmode
;
262 uint16_t *rsmseg_bar
;
263 uint16_t rsmseg_gnum
; /* generation number */
266 rsmapi_barrier_t
*rsmseg_barrier
; /* used in put/get routines */
267 offset_t rsmseg_mapoffset
; /* seg offset where mmapped */
268 uint32_t rsmseg_flags
;
269 minor_t rsmseg_rnum
; /* resource number of the segment */
273 * defines for rsmseg_flags
275 #define RSM_IMPLICIT_MAP 0x00000001 /* segment mapped implicitly */
277 /* This is a template for all barrier implementations */
279 rsmseg_handle_t
*rsmbar_seg
;
280 uint16_t rsmbar_gen
; /* generation number */
281 void *rsmbar_privdata
;
285 * These macros set and get the private data pointer in the opaque barrier
286 * structure for Network plugins.
288 #define RSMNDI_BARRIER_SETPRIV(HANDLE, ADDR) \
289 ((rsmbar_handle_t *)HANDLE)->rsmbar_privdata = (void *)ADDR;
291 #define RSMNDI_BARRIER_GETPRIV(HANDLE) \
292 ((rsmbar_handle_t *)HANDLE)->rsmbar_privdata
294 #define RSMNDI_BARRIER_GETSEG(HANDLE) \
295 ((rsmbar_handle_t *)HANDLE)->rsmbar_seg
297 #define RSMNDI_BARRIER_GETUNIT(HANDLE) \
298 ((rsmbar_handle_t *)HANDLE)->rsmbar_seg->rsmseg_controller->cntr_unit
301 * These macros set and get the private data pointer in the opaque segment
302 * structure for Network plugins.
304 #define RSMNDI_SEG_SETPRIV(HANDLE, ADDR) \
305 ((rsmseg_handle_t *)HANDLE)->rsmseg_privdata = (void *)ADDR;
307 #define RSMNDI_SEG_GETPRIV(HANDLE) \
308 ((rsmseg_handle_t *)HANDLE)->rsmseg_privdata
311 * Get the controller unit number from a opaque segment structure.
314 #define RSMNDI_SEG_GETUNIT(HANDLE) \
315 ((rsmseg_handle_t *)HANDLE)->rsmseg_controller->cntr_unit
318 * These macros set and get the private data pointer in the opaque controller
319 * structure for Network plugins.
321 #define RSMNDI_CNTRLR_SETPRIV(HANDLE, ADDR) \
322 ((rsm_controller_t *)HANDLE)->cntr_privdata = (void *)ADDR;
324 #define RSMNDI_CNTRLR_GETPRIV(HANDLE) \
325 ((rsm_controller_t *)HANDLE)->cntr_privdata
328 * Get the controller unit number from a opaque controller structure.
330 #define RSMNDI_CNTRLR_GETUNIT(HANDLE) \
331 ((rsm_controller_t *)HANDLE)->cntr_unit
334 * This macro returns an address inside a segment given the segment handle
337 #define RSMNDI_GET_MAPADDR(HANDLE, OFFSET) \
338 (((rsmseg_handle_t *)HANDLE)->rsmseg_vaddr + OFFSET)
344 #endif /* _SYS_RSM_RSMNDI_H */