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 1999-2002 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_RSM_RSM_H
28 #define _SYS_RSM_RSM_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
36 #include <sys/rsm/rsm_common.h>
37 #include <sys/rsm/rsmapi_common.h>
39 #define RSM_IOCTL_CONTROLLER 0x00
40 #define RSM_IOCTL_EXPORT_SEG 0x10
41 #define RSM_IOCTL_IMPORT_SEG 0x20
42 #define RSM_IOCTL_QUEUE 0x30
43 #define RSM_IOCTL_TOPOLOGY 0x40
44 #define RSM_IOCTL_BAR 0x50
45 #define RSM_IOCTL_ERRCNT 0x60
46 #define RSM_IOCTL_BELL 0x70
47 #define RSM_IOCTL_IOVEC 0x80
48 #define RSM_IOCTL_MAP_ADDR 0x90
50 #define RSM_IOCTL_ATTR RSM_IOCTL_CONTROLLER + 0x0 /* get device attribute */
51 #define RSM_IOCTL_BAR_INFO RSM_IOCTL_CONTROLLER + 0x1 /* get barrier info */
53 #define RSM_IOCTL_CREATE RSM_IOCTL_EXPORT_SEG + 0x1
54 #define RSM_IOCTL_BIND RSM_IOCTL_EXPORT_SEG + 0x3
55 #define RSM_IOCTL_REBIND RSM_IOCTL_EXPORT_SEG + 0x4
56 #define RSM_IOCTL_UNBIND RSM_IOCTL_EXPORT_SEG + 0x5
57 #define RSM_IOCTL_PUBLISH RSM_IOCTL_EXPORT_SEG + 0x6
58 #define RSM_IOCTL_REPUBLISH RSM_IOCTL_EXPORT_SEG + 0x7
59 #define RSM_IOCTL_UNPUBLISH RSM_IOCTL_EXPORT_SEG + 0x8
61 #define RSM_IOCTL_CONNECT RSM_IOCTL_IMPORT_SEG + 0x0
62 #define RSM_IOCTL_DISCONNECT RSM_IOCTL_IMPORT_SEG + 0x1
64 #define RSM_IOCTL_TOPOLOGY_SIZE RSM_IOCTL_TOPOLOGY + 0x1
65 #define RSM_IOCTL_TOPOLOGY_DATA RSM_IOCTL_TOPOLOGY + 0x2
67 #define RSM_IOCTL_GETV RSM_IOCTL_IOVEC + 0x1
68 #define RSM_IOCTL_PUTV RSM_IOCTL_IOVEC + 0x2
70 #define RSM_IOCTL_BAR_OPEN RSM_IOCTL_BAR + 0x1
71 #define RSM_IOCTL_BAR_ORDER RSM_IOCTL_BAR + 0x2
72 #define RSM_IOCTL_BAR_CLOSE RSM_IOCTL_BAR + 0x3
73 #define RSM_IOCTL_BAR_CHECK RSM_IOCTL_BAR + 0x4
75 #define RSM_IOCTL_RING_BELL RSM_IOCTL_BELL + 0x1
76 #define RSM_IOCTL_CONSUMEEVENT RSM_IOCTL_BELL + 0x2
78 #define RSM_IOCTL_MAP_TO_ADDR RSM_IOCTL_MAP_ADDR + 0x1
79 #define RSM_IOCTL_MAP_TO_NODEID RSM_IOCTL_MAP_ADDR + 0x2
81 #define RSM_IOCTL_CMDGRP(cmd) ((cmd) & 0xfffffff0)
83 #define BETWEEN(x, lo, hi) (((x) >= (lo)) && ((x) <= (hi)))
85 #define RSM_MAX_IOVLEN 4
87 * DEBUG message categories
88 * 0xABCD: A=module, B=functionality C=operation D=misc
91 #define RSM_KERNEL_AGENT 0x1000 /* kernel agent messages */
92 #define RSM_LIBRARY 0x2000 /* rsmapi library messages */
93 #define RSM_OPS 0x4000 /* rsmops module messages */
94 #define RSM_PATH_MANAGER 0x8000 /* path manager messages */
95 #define RSM_MODULE_ALL 0xF000
97 #define RSM_IMPORT 0x0100 /* import operations */
98 #define RSM_EXPORT 0x0200 /* export operations */
99 #define RSM_LOOPBACK 0x0400 /* loopback mode */
100 #define RSM_FUNC_ALL 0x0F00
102 #define RSM_DDI 0x0010 /* dev driver infrastructure */
103 #define RSM_IO_ROUTINES 0x0020 /* put/get processing */
104 #define RSM_IOCTL 0x0040 /* ioctl processing */
105 #define RSM_INTR_CALLBACK 0x0080 /* interrupt processing */
106 #define RSM_OPER_ALL 0x00F0
108 #define RSM_FLOWCONTROL 0x0001 /* flow control related */
110 #define RSM_KERNEL_ALL (RSM_KERNEL_AGENT | RSM_PATH_MANAGER | 0x0FFF)
111 #define RSM_ALL 0xFFFF /* All of the above */
114 * DEBUG message levels
116 #define RSM_DEBUG_VERBOSE 6
117 #define RSM_DEBUG_LVL2 5
118 #define RSM_DEBUG_LVL1 4
121 #define RSM_WARNING 1
125 extern void dbg_printf(int category
, int level
, char *fmt
, ...);
126 #define DBG_DEFINE(var, value) int var = (value)
127 #define DBG_DEFINE_STR(var, value) char *var = (value)
128 #define DBG_ADDCATEGORY(var, category) (var |= (category))
129 #define DBG_PRINTF(message) dbg_printf message
131 #define DBG_DEFINE(var, value)
132 #define DBG_DEFINE_STR(var, value)
133 #define DBG_ADDCATEGORY(var, category)
134 #define DBG_PRINTF(message)
137 typedef uint16_t rsm_gnum_t
;
140 * data struct used between rsm base library and kernel agent for IOCTLS
143 /* following fields should be identical to rsmapi_controller_attr_t */
144 uint_t attr_direct_access_sizes
;
145 uint_t attr_atomic_sizes
;
146 size_t attr_page_size
;
147 size_t attr_max_export_segment_size
;
148 size_t attr_tot_export_segment_size
;
149 ulong_t attr_max_export_segments
;
150 size_t attr_max_import_map_size
;
151 size_t attr_tot_import_map_size
;
152 ulong_t attr_max_import_segments
;
153 /* following fields are for internal use */
154 rsm_addr_t attr_controller_addr
;
155 } rsmka_int_controller_attr_t
;
159 /* following fields should be identical to rsmapi_controller_attr_t */
160 uint32_t attr_direct_access_sizes
;
161 uint32_t attr_atomic_sizes
;
162 uint32_t attr_page_size
;
163 uint32_t attr_max_export_segment_size
;
164 uint32_t attr_tot_export_segment_size
;
165 uint32_t attr_max_export_segments
;
166 uint32_t attr_max_import_map_size
;
167 uint32_t attr_tot_import_map_size
;
168 uint32_t attr_max_import_segments
;
169 /* the following fields are for internal use */
170 rsm_addr_t attr_controller_addr
;
171 } rsmka_int_controller_attr32_t
;
174 /* kernel agent equivalents of rsm_iovec_t and rsm_scat_gath_t */
178 rsm_localmemory_handle_t handle
;
179 rsm_memseg_id_t segid
;
183 size_t remote_offset
;
191 uint32_t local_offset
;
192 uint32_t remote_offset
;
193 uint32_t transfer_len
;
198 * The following 2 structures represent the scatter-gather structures used
199 * within the kernel agent. Note that the io_residual_count and the flags fields
200 * fields must be contiguous within these structures due to this assumption
201 * made by the kernel agent when updating them in ddi_copyout.
204 rsm_node_id_t local_nodeid
;
205 ulong_t io_request_count
;
206 ulong_t io_residual_count
;
208 rsm_memseg_import_handle_t remote_handle
;
209 rsmka_iovec_t
*iovec
;
214 rsm_node_id_t local_nodeid
;
215 uint32_t io_request_count
;
216 uint32_t io_residual_count
;
218 caddr32_t remote_handle
;
220 } rsmka_scat_gath32_t
;
224 * Define the number of pollfds upto which we don't allocate memory on heap
227 #define RSM_MAX_POLLFDS 4
230 minor_t rnum
; /* segment's resource number */
231 int fdsidx
; /* index of the fd in the pollfd array */
232 int revent
; /* returned event */
240 } rsm_poll_event32_t
;
244 caddr_t seglist
; /* array of rsm_poll_event_t */
246 } rsm_consume_event_msg_t
;
250 caddr32_t seglist
; /* array of rsm_poll_event32_t */
252 } rsm_consume_event_msg32_t
;
260 int len
; /* size as well */
265 rsmapi_access_entry_t
*acl
;
266 rsm_node_id_t nodeid
;
268 rsm_permission_t perm
;
270 rsm_gnum_t gnum
; /* segment generation number */
271 minor_t rnum
; /* segment resource number */
280 int32_t len
; /* size as well */
286 rsm_node_id_t nodeid
;
288 rsm_permission_t perm
;
290 rsm_gnum_t gnum
; /* segment generation number */
291 minor_t rnum
; /* segment resource number */
296 * Remote messaging structures
299 /* cookie to exchange between sender and receiver */
302 uint_t index
: 8; /* slot number */
303 uint_t sequence
: 24; /* seq. number */
309 #define RSMIPC_MSG_SEGCONNECT 0 /* connect seg */
310 #define RSMIPC_MSG_DISCONNECT 1 /* disconnect seg */
311 #define RSMIPC_MSG_IMPORTING 2
312 #define RSMIPC_MSG_NOTIMPORTING 3
313 #define RSMIPC_MSG_REPLY 4 /* reply msg */
314 #define RSMIPC_MSG_BELL 5 /* post an event */
315 #define RSMIPC_MSG_REPUBLISH 6 /* seg republished */
316 #define RSMIPC_MSG_SUSPEND 7 /* tell importers to SUSPEND */
317 #define RSMIPC_MSG_SUSPEND_DONE 8 /* tell exporters - SUSPEND done */
318 #define RSMIPC_MSG_RESUME 9 /* tell importers to RESUME */
319 #define RSMIPC_MSG_SQREADY 10 /* sendq ready = I am up */
320 #define RSMIPC_MSG_SQREADY_ACK 11 /* sendq ready ack = I am up too */
321 #define RSMIPC_MSG_CREDIT 12 /* credits to sender */
324 * Dummy message header
326 typedef struct rsmipc_msg
{
328 rsm_node_id_t rsmipc_src
;
330 rsmipc_cookie_t rsmipc_cookie
;
335 #define RSM_NO_REPLY 0 /* for rsmipc_send when no reply is expected */
338 * Request message of connect operation
340 typedef struct rsmipc_request
{
341 rsmipc_msghdr_t rsmipc_hdr
;
342 rsm_memseg_id_t rsmipc_key
; /* user key or segid */
343 rsm_permission_t rsmipc_perm
;
344 rsm_addr_t rsmipc_adapter_hwaddr
;
345 void *rsmipc_segment_cookie
;
349 * Message format of the flow control messages
351 typedef struct rsmipc_controlmsg
{
352 rsmipc_msghdr_t rsmipc_hdr
;
353 int64_t rsmipc_local_incn
;
354 rsm_addr_t rsmipc_adapter_hwaddr
;
355 int32_t rsmipc_credits
; /* credits */
356 }rsmipc_controlmsg_t
;
359 * Reply message for connect operation
361 typedef struct rsmipc_reply
{
362 rsmipc_msghdr_t rsmipc_hdr
;
363 short rsmipc_status
; /* error code of remote call */
364 uint16_t rsmipc_cnum
; /* exported controller addr */
365 rsm_memseg_id_t rsmipc_segid
; /* segid from remote node */
366 size_t rsmipc_seglen
; /* exporter segment size */
377 #endif /* _SYS_RSM_RSM_H */