xref: /titanic_51/usr/src/uts/common/sys/rsm/rsmpi.h (revision f875b4ebb1dd9fdbeb043557cab38ab3bf7f6e01)
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 (c) 1998-2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef _SYS_RSM_RSMPI_H
28 #define	_SYS_RSM_RSMPI_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #ifndef _KERNEL
37 typedef void * ddi_as_handle_t;
38 #endif
39 
40 #include <sys/sunddi.h>
41 #include <sys/rsm/rsm_common.h>
42 
43 struct __rsm_resource_callback_arg;
44 typedef struct __rsm_resource_callback_arg *rsm_resource_callback_arg_t;
45 
46 typedef void (*rsm_resource_callback_t)(rsm_resource_callback_arg_t);
47 
48 struct __rsm_callback_arg;
49 typedef struct __rsm_callback_arg *rsm_callback_arg_t;
50 
51 typedef void (*rsm_callback_t)(rsm_callback_arg_t);
52 
53 /* Values for resource callback function pointer */
54 #define	RSM_RESOURCE_SLEEP	(rsm_resource_callback_t)0
55 #define	RSM_RESOURCE_DONTWAIT	(rsm_resource_callback_t)-1
56 
57 /* rsm_seg_create() flags values */
58 #define	RSM_ALLOW_UNBIND_REBIND		0x01
59 
60 typedef uint_t rsm_intr_t;
61 typedef rsm_intr_t rsm_intr_service_t;
62 /* The following definitions used to describe the ranges fro rsm_intr_t */
63 #define	RSM_INTR_T_DRV_BASE		0
64 #define	RSM_INTR_T_DRV_END		0x3F
65 #define	RSM_INTR_T_FRM_BASE		0x40
66 #define	RSM_INTR_T_FRM_END		0x4F
67 #define	RSM_INTR_T_RESERVED_BASE	0x50
68 #define	RSM_INTR_T_RESERVED_END		0x5F
69 #define	RSM_INTR_T_SUN_BASE		0x60
70 #define	RSM_INTR_T_SUN_END		0xDF
71 #define	RSM_INTR_T_USR_BASE		0xE0
72 #define	RSM_INTR_T_USR_END		0xFF
73 #define	RSM_INTR_T_NSVC			0x100
74 
75 /* kstat's ks_name for RSMPI controller drivers */
76 #define	RSM_KS_NAME			"rsmpi_stat"
77 
78 /* named kstat component names */
79 #define	RSM_KS_CTLR_STATE		"ctlr_state"	/* CHAR */
80 #define	RSM_KS_ADDR			"addr"		/* UINT64 */
81 #define	RSM_KS_EX_MEMSEGS		"ex_memsegs"	/* UINT32 */
82 #define	RSM_KS_EX_MEMSEGS_PUB		"ex_memsegs_pub"	/* UINT32 */
83 #define	RSM_KS_EX_MEMSEGS_CON		"ex_memsegs_con"	/* UINT32 */
84 #define	RSM_KS_BYTES_BOUND		"bytes_bound"		/* UINT64 */
85 #define	RSM_KS_IM_MEMSEGS_CON		"im_memsegs_con"	/* UINT32 */
86 #define	RSM_KS_SENDQS			"sendqs"		/* UINT64 */
87 #define	RSM_KS_HANDLERS			"handlers"		/* UINT64 */
88 
89 /* The following are the possible values of RSM_KS_CTLR_STATE */
90 #define	RSM_AE_CTLR_DOWN	"rsm_down"
91 #define	RSM_AE_CTLR_UP		"rsm_up"
92 
93 
94 struct __rsm_send_q_handle;
95 typedef struct __rsm_send_q_handle *rsm_send_q_handle_t;
96 
97 /* rsm_intr_send_q_create flags values */
98 #define	RSM_INTR_SEND_Q_NO_FENCE	0x1
99 #define	RSM_INTR_SEND_Q_FULL_FAIL	0x2
100 #define	RSM_INTR_SEND_Q_UNRELIABLE	0x4
101 
102 typedef struct {
103 	void	*is_data;
104 	size_t	is_size;
105 	int	is_flags;
106 	clock_t	is_wait;
107 } rsm_send_t;
108 
109 /* rsm_send_t flags values */
110 #define	RSM_INTR_SEND_QUEUE		0x1
111 #define	RSM_INTR_SEND_DELIVER		0x2
112 #define	RSM_INTR_SEND_POLL		0x4
113 #define	RSM_INTR_SEND_SLEEP		0x8
114 #define	RSM_INTR_SEND_LOWER_FENCE	0x10
115 
116 typedef enum {
117 	RSM_INTR_HAND_UNCLAIMED = 0,
118 	RSM_INTR_HAND_CLAIMED = 1,
119 	RSM_INTR_HAND_CLAIMED_EXCLUSIVE = 2
120 } rsm_intr_hand_ret_t;
121 
122 typedef enum {
123 	RSM_INTR_Q_OP_CREATE,
124 	RSM_INTR_Q_OP_CONFIGURE,
125 	RSM_INTR_Q_OP_DESTROY,
126 	RSM_INTR_Q_OP_RECEIVE,
127 	RSM_INTR_Q_OP_DROP
128 } rsm_intr_q_op_t;
129 
130 struct __rsm_intr_hand_arg;
131 typedef struct __rsm_intr_hand_arg *rsm_intr_hand_arg_t;
132 
133 struct __rsm_registry_item;
134 typedef struct __rsm_registry_item *rsm_registry_item_t;
135 
136 typedef int   rsm_intr_pri_t;
137 
138 typedef struct {
139 	rsm_addr_t	 ae_addr;	/* node hwaddr allowed access */
140 	rsm_permission_t ae_permission;	/* permissions for node */
141 } rsm_access_entry_t;
142 /*
143  * ae_addr can be set to the following value to mean that the permissions
144  * should apply to all nodes accessible through this RSM controller
145  */
146 #define	RSM_ACCESS_PUBLIC	0xFFFF
147 
148 struct __rsm_controller_handle;
149 typedef struct __rsm_controller_handle *rsm_controller_handle_t;
150 
151 /*
152  * The following typedef is used to represent a controller object.
153  */
154 typedef struct rsm_controller_object {
155 	struct rsm_ops *ops;
156 	rsm_controller_handle_t handle;
157 } rsm_controller_object_t;
158 
159 typedef rsm_intr_hand_ret_t (*rsm_intr_hand_t)(
160     rsm_controller_object_t *controller,
161     rsm_intr_q_op_t operation,
162     rsm_addr_t sender,
163     void *data,
164     size_t size,
165     rsm_intr_hand_arg_t arg);
166 
167 typedef struct {
168 	enum { RSM_MEM_VADDR,
169 		RSM_MEM_BUF,
170 		RSM_MEM_HANDLE,
171 		RSM_MEM_INVALID } ms_type;
172 	union {
173 		struct {
174 			void *vaddr;
175 			size_t length;
176 			ddi_as_handle_t as;
177 		} vr;
178 		struct buf *bp;
179 		rsm_memseg_export_handle_t	handle;
180 	} ms_memory;
181 #define	ms_bp		ms_memory.bp
182 #define	ms_vaddr	ms_memory.vr.vaddr
183 #define	ms_length	ms_memory.vr.length
184 #define	ms_as		ms_memory.vr.as
185 } rsm_memory_local_t;
186 
187 typedef struct {
188 	rsm_memory_local_t		local_mem;
189 	size_t				local_offset;
190 	rsm_memseg_import_handle_t	remote_handle;
191 	size_t				remote_offset;
192 	size_t				transfer_length;
193 } rsmpi_iovec_t;
194 
195 typedef struct {
196 	ulong_t		io_request_count;	/* size of iovec array */
197 	ulong_t		io_residual_count;	/* zero for success    */
198 	uio_seg_t	io_segflg;		/* user/kernel addr    */
199 	rsmpi_iovec_t	*iovec;			/* ptr to array		*/
200 } rsmpi_scat_gath_t;
201 
202 typedef struct {
203 	char			*attr_name;
204 	rsm_addr_t		attr_controller_addr;
205 	uint_t			attr_direct_access_sizes;
206 	uint_t			attr_atomic_sizes;
207 	uint_t			attr_error_sizes;
208 	uint_t			attr_error_behavior;
209 	boolean_t		attr_mmu_protections;
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 	boolean_t		attr_io_space_exportable;
218 	boolean_t		attr_imported_space_ioable;
219 	boolean_t		attr_intr_sender_ident;
220 	size_t			attr_intr_data_size_max;
221 	uint_t			attr_intr_data_align;
222 	boolean_t		attr_intr_piggyback;
223 	boolean_t	attr_resource_callbacks;
224 } rsm_controller_attr_t;
225 
226 /*
227  * The following three defines are possible values for attr_error_behavior
228  * field of the rsm_controller_attr_t struct.
229  */
230 #define	RSM_ERR_NOCHANGE	0
231 #define	RSM_ERR_ZEROES		0x1
232 #define	RSM_ERR_RANDOM		0x2
233 
234 typedef struct rsm_ops {
235 
236 	/*
237 	 * structure revision number:
238 	 */
239 	uint_t rsm_version;
240 
241 	/*
242 	 * export side memory segment operations:
243 	 */
244 	int (*rsm_seg_create)
245 	    (rsm_controller_handle_t controller,
246 	    rsm_memseg_export_handle_t *memseg,
247 	    size_t	size,
248 	    uint_t	flags,
249 	    rsm_memory_local_t *memory,
250 	    rsm_resource_callback_t callback,
251 	    rsm_resource_callback_arg_t callback_arg);
252 	int (*rsm_seg_destroy)
253 	    (rsm_memseg_export_handle_t handle);
254 	int (*rsm_bind)
255 	    (rsm_memseg_export_handle_t memseg,
256 	    off_t offset,
257 	    rsm_memory_local_t *memory,
258 	    rsm_resource_callback_t callback,
259 	    rsm_resource_callback_arg_t callback_arg);
260 	int (*rsm_unbind)
261 	    (rsm_memseg_export_handle_t memseg,
262 	    off_t offset,
263 	    size_t length);
264 	int (*rsm_rebind)
265 	    (rsm_memseg_export_handle_t memseg,
266 	    off_t offset,
267 	    rsm_memory_local_t *memory,
268 	    rsm_resource_callback_t callback,
269 	    rsm_resource_callback_arg_t callback_arg);
270 	int (*rsm_publish)
271 	    (rsm_memseg_export_handle_t memseg,
272 	    rsm_access_entry_t access_list[],
273 	    uint_t access_list_length,
274 	    rsm_memseg_id_t segment_id,
275 	    rsm_resource_callback_t callback,
276 	    rsm_resource_callback_arg_t callback_arg);
277 	int (*rsm_unpublish)
278 	    (rsm_memseg_export_handle_t memseg);
279 	int (*rsm_republish)
280 	    (rsm_memseg_export_handle_t memseg,
281 	    rsm_access_entry_t access_list[],
282 	    uint_t access_list_length,
283 	    rsm_resource_callback_t callback,
284 	    rsm_resource_callback_arg_t callback_arg);
285 
286 	/*
287 	 * import side memory segment operations
288 	 */
289 	int (*rsm_connect)
290 	    (rsm_controller_handle_t controller,
291 	    rsm_addr_t addr,
292 	    rsm_memseg_id_t segment_id,
293 	    rsm_memseg_import_handle_t *im_memseg);
294 
295 	int (*rsm_disconnect)
296 	    (rsm_memseg_import_handle_t im_memseg);
297 
298 	/*
299 	 * import side memory segment operations (read access functions):
300 	 */
301 	int (* rsm_get8)
302 	    (rsm_memseg_import_handle_t im_memseg,
303 	    off_t offset,
304 	    uint8_t *datap,
305 	    ulong_t rep_cnt,
306 	    boolean_t byte_swap);
307 	int (* rsm_get16)
308 	    (rsm_memseg_import_handle_t im_memseg,
309 	    off_t offset,
310 	    uint16_t *datap,
311 	    ulong_t rep_cnt,
312 	    boolean_t byte_swap);
313 	int (* rsm_get32)
314 	    (rsm_memseg_import_handle_t im_memseg,
315 	    off_t offset,
316 	    uint32_t *datap,
317 	    ulong_t rep_cnt,
318 	    boolean_t byte_swap);
319 	int (* rsm_get64)
320 	    (rsm_memseg_import_handle_t im_memseg,
321 	    off_t offset,
322 	    uint64_t *datap,
323 	    ulong_t rep_cnt,
324 	    boolean_t byte_swap);
325 	int (* rsm_get)
326 	    (rsm_memseg_import_handle_t im_memseg,
327 	    off_t offset,
328 	    void *datap,
329 	    size_t length);
330 
331 	/*
332 	 * import side memory segment operations (write access functions)
333 	 */
334 	int (* rsm_put8)
335 	    (rsm_memseg_import_handle_t im_memseg,
336 	    off_t offset,
337 	    uint8_t *datap,
338 	    ulong_t rep_cnt,
339 	    boolean_t byte_swap);
340 	int (* rsm_put16)
341 	    (rsm_memseg_import_handle_t im_memseg,
342 	    off_t offset,
343 	    uint16_t *datap,
344 	    ulong_t rep_cnt,
345 	    boolean_t byte_swap);
346 	int (* rsm_put32)
347 	    (rsm_memseg_import_handle_t im_memseg,
348 	    off_t offset,
349 	    uint32_t *datap,
350 	    ulong_t rep_cnt,
351 	    boolean_t byte_swap);
352 	int (* rsm_put64)
353 	    (rsm_memseg_import_handle_t im_memseg,
354 	    off_t offset,
355 	    uint64_t *datap,
356 	    ulong_t rep_cnt,
357 	    boolean_t byte_swap);
358 	int (* rsm_put)
359 	    (rsm_memseg_import_handle_t im_memseg,
360 	    off_t offset,
361 	    void *datap,
362 	    size_t length);
363 
364 	/*
365 	 * import side memory segment operations (mapping)
366 	 */
367 	int (*rsm_map)(rsm_memseg_import_handle_t im_memseg,
368 	    off_t offset,
369 	    size_t len,
370 	    size_t *maplen,
371 	    dev_info_t **dipp,
372 	    uint_t *register_number,
373 	    off_t *register_offset,
374 	    rsm_resource_callback_t callback,
375 	    rsm_resource_callback_arg_t callback_arg);
376 
377 	int (*rsm_unmap)
378 	    (rsm_memseg_import_handle_t im_memseg);
379 
380 	/*
381 	 * import side memory segment operations (barriers):
382 	 */
383 	int (* rsm_open_barrier_region)
384 	    (rsm_memseg_import_handle_t region,
385 	    rsm_barrier_t *barrier);
386 	int (* rsm_open_barrier_regions)
387 	    (rsm_memseg_import_handle_t regions[],
388 	    uint_t num_regions,
389 	    rsm_barrier_t *barrier);
390 	int (* rsm_open_barrier_node)
391 	    (rsm_controller_handle_t controller,
392 	    rsm_addr_t addr,
393 	    rsm_barrier_t *barrier);
394 	int (* rsm_open_barrier_ctrl)
395 	    (rsm_controller_handle_t controller,
396 	    rsm_barrier_t *barrier);
397 	int (* rsm_open_barrier_region_thr)
398 	    (rsm_memseg_import_handle_t region,
399 	    rsm_barrier_t *barrier);
400 	int (* rsm_open_barrier_regions_thr)
401 	    (rsm_memseg_import_handle_t regions[],
402 	    uint_t num_regions,
403 	    rsm_barrier_t *barrier);
404 	int (* rsm_open_barrier_node_thr)
405 	    (rsm_controller_handle_t controller,
406 	    rsm_addr_t addr,
407 	    rsm_barrier_t *barrier);
408 	int (* rsm_open_barrier_ctrl_thr)
409 	    (rsm_controller_handle_t controller,
410 	    rsm_barrier_t *barrier);
411 	int (* rsm_close_barrier)
412 	    (rsm_barrier_t *barrier);
413 	int (* rsm_reopen_barrier)
414 	    (rsm_barrier_t *barrier);
415 	int (* rsm_order_barrier)
416 	    (rsm_barrier_t *barrier);
417 	int (* rsm_thread_init)
418 	    (rsm_controller_handle_t controller);
419 	int (* rsm_thread_fini)
420 	    (rsm_controller_handle_t controller);
421 	int (* rsm_get_barrier_mode)
422 	    (rsm_memseg_import_handle_t im_memseg,
423 	    rsm_barrier_mode_t *mode);
424 	int (* rsm_set_barrier_mode)
425 	    (rsm_memseg_import_handle_t im_memseg,
426 	    rsm_barrier_mode_t mode);
427 
428 	/*
429 	 * sending side interrupt operations:
430 	 */
431 	int (* rsm_sendq_create)
432 	    (rsm_controller_handle_t controller,
433 	    rsm_addr_t addr,
434 	    rsm_intr_service_t service,
435 	    rsm_intr_pri_t pri,
436 	    ulong_t qdepth,
437 	    uint_t flags,
438 	    rsm_resource_callback_t callback,
439 	    rsm_resource_callback_arg_t arg,
440 	    rsm_send_q_handle_t *iqp);
441 	int (* rsm_sendq_config)
442 	    (rsm_send_q_handle_t iq,
443 	    rsm_intr_pri_t pri,
444 	    ulong_t qdepth,
445 	    uint_t flags,
446 	    rsm_resource_callback_t callback,
447 	    rsm_resource_callback_arg_t arg);
448 	int (* rsm_sendq_destroy)
449 	    (rsm_send_q_handle_t iq);
450 	int (* rsm_send)
451 	    (rsm_send_q_handle_t iq,
452 	    rsm_send_t *is,
453 	    rsm_barrier_t *barrier);
454 
455 
456 	/*
457 	 * receiving side interrupt operations:
458 	 */
459 	int (* rsm_register_handler)
460 	    (rsm_controller_handle_t controller,
461 	    rsm_controller_object_t *controller_obj,
462 	    rsm_intr_t type,
463 	    rsm_intr_hand_t handler,
464 	    rsm_intr_hand_arg_t handler_arg,
465 	    rsm_addr_t senders_list[],
466 	    uint_t senders_list_length);
467 
468 	int (* rsm_unregister_handler)
469 	    (rsm_controller_handle_t controller,
470 	    rsm_intr_t type,
471 	    rsm_intr_hand_t handler,
472 	    rsm_intr_hand_arg_t handler_arg);
473 
474 
475 	/* scatter-gather I/O */
476 	int (* rsm_memseg_import_getv)
477 	    (rsm_controller_handle_t cp,
478 	    rsmpi_scat_gath_t *sg_io);
479 	int (* rsm_memseg_import_putv)
480 	    (rsm_controller_handle_t cp,
481 	    rsmpi_scat_gath_t *sg_io);
482 
483 	/* Management operation */
484 	int (*rsm_get_peers)
485 	    (rsm_controller_handle_t controller,
486 	    rsm_addr_t *addr_list,
487 	    uint_t count,
488 	    uint_t *num_addrs);
489 
490 	/* Extension operation */
491 	int (*rsm_extension)
492 	    (rsm_controller_handle_t controller,
493 	    char *extname,
494 	    void *extobj);
495 
496 } rsm_ops_t;
497 
498 /*
499  * service module function templates:
500  */
501 
502 int rsm_get_controller(const char *name, uint_t number,
503     rsm_controller_object_t *controller,
504     uint_t version);
505 
506 int rsm_release_controller(const char *name, uint_t number,
507     rsm_controller_object_t *controller);
508 
509 int rsm_get_controller_attr(rsm_controller_handle_t,
510     rsm_controller_attr_t **attrp);
511 /*
512  * MACROS for Clients requesting services via RSMPI module
513  */
514 
515 /*
516  * Export Side segment operations
517  */
518 
519 #define	RSM_SEG_CREATE(controller, memseg, size, flags, memory, callback, \
520 	callback_arg) \
521 	(*((controller).ops->rsm_seg_create)) \
522 	((controller).handle, (memseg), (size), (flags), (memory), \
523 	(callback), (callback_arg))
524 #define	RSM_SEG_DESTROY(controller, memseg) \
525 	(*((controller).ops->rsm_seg_destroy)) \
526 	((memseg))
527 #define	RSM_BIND(controller, memseg, offset, memory, callback, \
528 	callback_arg) \
529 	(*((controller).ops->rsm_bind)) \
530 	((memseg), offset, (memory), (callback), (callback_arg))
531 #define	RSM_UNBIND(controller, memseg, offset, length) \
532 	(*((controller).ops->rsm_unbind)) \
533 	((memseg), (offset), (length))
534 #define	RSM_REBIND(controller, memseg, offset, memory, callback, \
535 	callback_arg) \
536 	(*((controller).ops->rsm_rebind)) \
537 	((memseg), offset, (memory), (callback), (callback_arg))
538 #define	RSM_PUBLISH(controller, memseg, access_list, access_list_length, \
539 	segment_id, callback, callback_arg) \
540 	(*((controller).ops->rsm_publish)) \
541 	((memseg), access_list,	access_list_length, segment_id, \
542 	(callback), (callback_arg))
543 #define	RSM_UNPUBLISH(controller, memseg) \
544 	(*((controller).ops->rsm_unpublish)) \
545 	((memseg))
546 #define	RSM_REPUBLISH(controller, memseg,  access_list, access_list_length, \
547 	callback, callback_arg) \
548 	(*((controller).ops->rsm_republish)) \
549 	((memseg), (access_list), (access_list_length), (callback), \
550 	(callback_arg))
551 #define	RSM_CONNECT(controller, addr, segment_id, im_memseg) \
552 	(*((controller).ops->rsm_connect)) \
553 	((controller).handle, (addr), (segment_id), (im_memseg))
554 #define	RSM_DISCONNECT(controller, im_memseg) \
555 	(*((controller).ops->rsm_disconnect))  \
556 	((im_memseg))
557 
558 	/*
559 	 * import side memory segment operations (read access functions)
560 	 */
561 
562 #define	RSM_GET8(controller, im_memseg, offset, datap, rep_cnt, byte_swap) \
563 	(*((controller).ops->rsm_get8)) \
564 	((im_memseg), (offset), (datap), (rep_cnt), (byte_swap))
565 #define	RSM_GET16(controller, im_memseg, offset, datap, rep_cnt, byte_swap) \
566 	(*((controller).ops->rsm_get16)) \
567 	((im_memseg), (offset), (datap), (rep_cnt), (byte_swap))
568 #define	RSM_GET32(controller, im_memseg, offset, datap, rep_cnt, byte_swap) \
569 	(*((controller).ops->rsm_get32)) \
570 	((im_memseg), (offset), (datap), (rep_cnt), (byte_swap))
571 #define	RSM_GET64(controller, im_memseg, offset, datap, rep_cnt, byte_swap) \
572 	(*((controller).ops->rsm_get64)) \
573 	((im_memseg), (offset), (datap), (rep_cnt), (byte_swap))
574 #define	RSM_GET(controller, im_memseg, offset, dst_addr, length) \
575 	(*((controller).ops->rsm_get)) \
576 	((im_memseg), (offset), (dst_addr), (length))
577 
578 	/*
579 	 * import side memory segment operations (write access functions)
580 	 */
581 
582 #define	RSM_PUT8(controller, im_memseg, offset, datap, rep_cnt, byte_swap) \
583 	(*((controller).ops->rsm_put8)) \
584 	((im_memseg), (offset), (datap), (rep_cnt), (byte_swap))
585 #define	RSM_PUT16(controller, im_memseg, offset, datap, rep_cnt, byte_swap) \
586 	(*((controller).ops->rsm_put16)) \
587 	((im_memseg), (offset), (datap), (rep_cnt), (byte_swap))
588 #define	RSM_PUT32(controller, im_memseg, offset, datap, rep_cnt, byte_swap) \
589 	(*((controller).ops->rsm_put32)) \
590 	((im_memseg), (offset), (datap), (rep_cnt), (byte_swap))
591 #define	RSM_PUT64(controller, im_memseg, offset, datap, rep_cnt, byte_swap) \
592 	(*((controller).ops->rsm_put64)) \
593 	((im_memseg), (offset), (datap), (rep_cnt), (byte_swap))
594 #define	RSM_PUT(controller, im_memseg, offset, datap, length) \
595 	(*((controller).ops->rsm_put)) \
596 	((im_memseg), (offset), (datap), (length))
597 
598 	/*
599 	 * import side memory segment operations (mapping):
600 	 */
601 
602 #define	RSM_MAP(controller, im_memseg, offset, length, maplen, dipp, \
603 	dev_register, dev_offset, callback, arg) \
604 	(*((controller).ops->rsm_map)) \
605 	((im_memseg), (offset), (length), (maplen), (dipp), (dev_register), \
606 	(dev_offset), (callback), (arg))
607 #define	RSM_UNMAP(controller, im_memseg) \
608 	(*((controller).ops->rsm_unmap)) \
609 	((im_memseg))
610 
611 	/*
612 	 * import side memory segment operations (barriers):
613 	 */
614 
615 #define	RSM_OPEN_BARRIER_REGION(controller, region, barrier) \
616 	(*((controller).ops->rsm_open_barrier_region)) \
617 	((region), (barrier))
618 #define	RSM_OPEN_BARRIER_REGIONS(controller, regions, num_regions, barrier) \
619 	(*((controller).ops->rsm_open_barrier_regions)) \
620 	((regions), (num_regions), (barrier))
621 #define	RSM_OPEN_BARRIER_NODE(controller, addr, barrier) \
622 	(*((controller).ops-> rsm_open_barrier_node)) \
623 	((controller).handle, (addr), (barrier))
624 #define	RSM_OPEN_BARRIER_CTRL(controller, barrier) \
625 	(*((controller).ops->rsm_open_barrier_ctrl)) \
626 	((controller).handle, (barrier))
627 #define	RSM_OPEN_BARRIER_REGION_THR(controller, region, barrier) \
628 	(*((controller).ops->rsm_open_barrier_region_thr)) \
629 	((region), (barrier))
630 #define	RSM_OPEN_BARRIER_REGIONS_THR(controller, regions, num_regions, barrier)\
631 	(*((controller).ops->rsm_open_barrier_regions_thr)) \
632 	((regions), (num_regions), (barrier))
633 #define	RSM_OPEN_BARRIER_NODE_THR(controller, addr, barrier) \
634 	(*((controller).ops->rsm_open_barrier_node_thr)) \
635 	((controller).handle, (addr), (barrier))
636 #define	RSM_OPEN_BARRIER_CTRL_THR(controller, barrier) \
637 	(*((controller).ops->rsm_open_barrier_ctrl_thr)) \
638 	((controller).handle, (barrier));
639 #define	RSM_CLOSE_BARRIER(controller, barrier) \
640 	(*((controller).ops->rsm_close_barrier)) \
641 	((barrier))
642 #define	RSM_REOPEN_BARRIER(controller, barrier) \
643 	(*((controller).ops->rsm_reopen_barrier)) \
644 	((barrier));
645 #define	RSM_ORDER_BARRIER(controller, barrier) \
646 	(*((controller).ops->rsm_order_barrier)) \
647 	((barrier))
648 #define	RSM_THREAD_INIT(controller) \
649 	(*((controller).ops->rsm_thread_init)) \
650 	((controller).handle)
651 #define	RSM_THREAD_FINI(controller) \
652 	(*((controller).ops->rsm_thread_fini)) \
653 	((controller).handle)
654 #define	RSM_GET_BARRIER_MODE(controller, im_memseg, mode) \
655 	(*((controller).ops->rsm_get_barrier_mode)) \
656 	((im_memseg), (mode))
657 #define	RSM_SET_BARRIER_MODE(controller, im_memseg, mode) \
658 	(*((controller).ops->rsm_set_barrier_mode)) \
659 	((im_memseg), (mode))
660 	/*
661 	 * sending side interrupt operations:
662 	 */
663 
664 #define	RSM_SENDQ_CREATE(controller, addr, service, pri, qdepth, flags, \
665 	callback, arg, iqp) \
666 	(*((controller).ops->rsm_sendq_create)) \
667 	((controller).handle, (addr), (service), (pri), (qdepth), (flags), \
668 	(callback), (arg),  (iqp))
669 #define	RSM_SENDQ_CONFIG(controller, iq, pri, qdepth, flags, callback, arg) \
670 	(*((controller).ops->rsm_sendq_config)) \
671 	((iq),  (pri),  (qdepth), (flags), \
672 	(callback), (arg))
673 #define	RSM_SENDQ_DESTROY(controller, iq) \
674 	(*((controller).ops->rsm_sendq_destroy)) \
675 	((iq))
676 #define	RSM_SEND(controller, iq, is, barrier) \
677 	(*((controller).ops->rsm_send)) \
678 	((iq), (is), (barrier))
679 
680 	/*
681 	 * receiving side interrupt operations:
682 	 */
683 #define	RSM_REGISTER_HANDLER(controller, type, handler, handler_arg, \
684 	senders_list, senders_list_length) \
685 	(*((controller).ops->rsm_register_handler)) \
686 	((controller).handle, &(controller), (type), (handler), (handler_arg), \
687 	(senders_list), (senders_list_length))
688 #define	RSM_UNREGISTER_HANDLER(controller, type, handler, handler_arg) \
689 	(*((controller).ops->rsm_unregister_handler))  \
690 	((controller).handle, (type), (handler), (handler_arg))
691 #define	RSM_GETV(controller, sg_io) \
692 	(*((controller).ops->rsm_memseg_import_getv)) \
693 	((controller).handle, (sg_io))
694 #define	RSM_PUTV(controller, sg_io) \
695 	(*((controller).ops->rsm_memseg_import_putv)) \
696 	((controller).handle, (sg_io))
697 #define	RSM_GET_PEERS(controller, addr_list, count, num_addrs) \
698 	(*((controller).ops->rsm_get_peers)) \
699 	((controller).handle, (addr_list), (count), (num_addrs))
700 #define	RSM_EXTENSION(controller, extname, extobj) \
701 	(*((controller).ops->rsm_extension)) \
702 	((controller).handle, (extname), (extobj))
703 
704 #ifdef	__cplusplus
705 }
706 #endif
707 
708 
709 #endif	/* _SYS_RSM_RSMPI_H */
710