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 _SYS_RSM_RSM_H 28 #define _SYS_RSM_RSM_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #include <sys/rsm/rsm_common.h> 37 #include <sys/rsm/rsmapi_common.h> 38 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 49 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 */ 52 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 60 61 #define RSM_IOCTL_CONNECT RSM_IOCTL_IMPORT_SEG + 0x0 62 #define RSM_IOCTL_DISCONNECT RSM_IOCTL_IMPORT_SEG + 0x1 63 64 #define RSM_IOCTL_TOPOLOGY_SIZE RSM_IOCTL_TOPOLOGY + 0x1 65 #define RSM_IOCTL_TOPOLOGY_DATA RSM_IOCTL_TOPOLOGY + 0x2 66 67 #define RSM_IOCTL_GETV RSM_IOCTL_IOVEC + 0x1 68 #define RSM_IOCTL_PUTV RSM_IOCTL_IOVEC + 0x2 69 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 74 75 #define RSM_IOCTL_RING_BELL RSM_IOCTL_BELL + 0x1 76 #define RSM_IOCTL_CONSUMEEVENT RSM_IOCTL_BELL + 0x2 77 78 #define RSM_IOCTL_MAP_TO_ADDR RSM_IOCTL_MAP_ADDR + 0x1 79 #define RSM_IOCTL_MAP_TO_NODEID RSM_IOCTL_MAP_ADDR + 0x2 80 81 #define RSM_IOCTL_CMDGRP(cmd) ((cmd) & 0xfffffff0) 82 83 #define BETWEEN(x, lo, hi) (((x) >= (lo)) && ((x) <= (hi))) 84 85 #define RSM_MAX_IOVLEN 4 86 /* 87 * DEBUG message categories 88 * 0xABCD: A=module, B=functionality C=operation D=misc 89 * 90 */ 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 96 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 101 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 107 108 #define RSM_FLOWCONTROL 0x0001 /* flow control related */ 109 110 #define RSM_KERNEL_ALL (RSM_KERNEL_AGENT | RSM_PATH_MANAGER | 0x0FFF) 111 #define RSM_ALL 0xFFFF /* All of the above */ 112 113 /* 114 * DEBUG message levels 115 */ 116 #define RSM_DEBUG_VERBOSE 6 117 #define RSM_DEBUG_LVL2 5 118 #define RSM_DEBUG_LVL1 4 119 #define RSM_DEBUG 3 120 #define RSM_NOTICE 2 121 #define RSM_WARNING 1 122 #define RSM_ERR 0 123 124 #ifdef DEBUG 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 130 #else 131 #define DBG_DEFINE(var, value) 132 #define DBG_DEFINE_STR(var, value) 133 #define DBG_ADDCATEGORY(var, category) 134 #define DBG_PRINTF(message) 135 #endif /* DEBUG */ 136 137 typedef uint16_t rsm_gnum_t; 138 139 /* 140 * data struct used between rsm base library and kernel agent for IOCTLS 141 */ 142 typedef struct { 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; 156 157 #ifdef _SYSCALL32 158 typedef struct { 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; 172 #endif 173 174 /* kernel agent equivalents of rsm_iovec_t and rsm_scat_gath_t */ 175 typedef struct { 176 int io_type; 177 union { 178 rsm_localmemory_handle_t handle; 179 rsm_memseg_id_t segid; 180 caddr_t vaddr; 181 } local; 182 size_t local_offset; 183 size_t remote_offset; 184 size_t transfer_len; 185 } rsmka_iovec_t; 186 187 #ifdef _SYSCALL32 188 typedef struct { 189 int32_t io_type; 190 uint32_t local; 191 uint32_t local_offset; 192 uint32_t remote_offset; 193 uint32_t transfer_len; 194 } rsmka_iovec32_t; 195 #endif 196 197 /* 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. 202 */ 203 typedef struct { 204 rsm_node_id_t local_nodeid; 205 ulong_t io_request_count; 206 ulong_t io_residual_count; 207 uint_t flags; 208 rsm_memseg_import_handle_t remote_handle; 209 rsmka_iovec_t *iovec; 210 } rsmka_scat_gath_t; 211 212 #ifdef _SYSCALL32 213 typedef struct { 214 rsm_node_id_t local_nodeid; 215 uint32_t io_request_count; 216 uint32_t io_residual_count; 217 uint32_t flags; 218 caddr32_t remote_handle; 219 caddr32_t iovec; 220 } rsmka_scat_gath32_t; 221 #endif 222 223 /* 224 * Define the number of pollfds upto which we don't allocate memory on heap 225 * 226 */ 227 #define RSM_MAX_POLLFDS 4 228 229 typedef struct { 230 minor_t rnum; /* segment's resource number */ 231 int fdsidx; /* index of the fd in the pollfd array */ 232 int revent; /* returned event */ 233 } rsm_poll_event_t; 234 235 #ifdef _SYSCALL32 236 typedef struct { 237 minor_t rnum; 238 int32_t fdsidx; 239 int32_t revent; 240 } rsm_poll_event32_t; 241 #endif 242 243 typedef struct { 244 caddr_t seglist; /* array of rsm_poll_event_t */ 245 uint32_t numents; 246 } rsm_consume_event_msg_t; 247 248 #ifdef _SYSCALL32 249 typedef struct { 250 caddr32_t seglist; /* array of rsm_poll_event32_t */ 251 uint32_t numents; 252 } rsm_consume_event_msg32_t; 253 #endif 254 255 typedef struct { 256 int cnum; 257 caddr_t cname; 258 int cname_len; 259 caddr_t arg; 260 int len; /* size as well */ 261 caddr_t vaddr; 262 int off; 263 rsm_memseg_id_t key; 264 int acl_len; 265 rsmapi_access_entry_t *acl; 266 rsm_node_id_t nodeid; 267 rsm_addr_t hwaddr; 268 rsm_permission_t perm; 269 rsm_barrier_t bar; 270 rsm_gnum_t gnum; /* segment generation number */ 271 minor_t rnum; /* segment resource number */ 272 } rsm_ioctlmsg_t; 273 274 #ifdef _SYSCALL32 275 typedef struct { 276 int32_t cnum; 277 caddr32_t cname; 278 int32_t cname_len; 279 caddr32_t arg; 280 int32_t len; /* size as well */ 281 caddr32_t vaddr; 282 int32_t off; 283 rsm_memseg_id_t key; 284 int32_t acl_len; 285 caddr32_t acl; 286 rsm_node_id_t nodeid; 287 rsm_addr_t hwaddr; 288 rsm_permission_t perm; 289 rsm_barrier_t bar; 290 rsm_gnum_t gnum; /* segment generation number */ 291 minor_t rnum; /* segment resource number */ 292 } rsm_ioctlmsg32_t; 293 #endif 294 295 /* 296 * Remote messaging structures 297 */ 298 299 /* cookie to exchange between sender and receiver */ 300 typedef union { 301 struct { 302 uint_t index : 8; /* slot number */ 303 uint_t sequence : 24; /* seq. number */ 304 } ic; 305 uint_t value; 306 }rsmipc_cookie_t; 307 308 /* IPC msg types */ 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 */ 322 323 /* 324 * Dummy message header 325 */ 326 typedef struct rsmipc_msg { 327 int rsmipc_version; 328 rsm_node_id_t rsmipc_src; 329 int rsmipc_type; 330 rsmipc_cookie_t rsmipc_cookie; 331 int64_t rsmipc_incn; 332 }rsmipc_msghdr_t; 333 334 335 #define RSM_NO_REPLY 0 /* for rsmipc_send when no reply is expected */ 336 337 /* 338 * Request message of connect operation 339 */ 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; 346 }rsmipc_request_t; 347 348 /* 349 * Message format of the flow control messages 350 */ 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; 357 358 /* 359 * Reply message for connect operation 360 */ 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 */ 367 mode_t rsmipc_mode; 368 uid_t rsmipc_uid; 369 gid_t rsmipc_gid; 370 }rsmipc_reply_t; 371 372 #ifdef __cplusplus 373 } 374 #endif 375 376 377 #endif /* _SYS_RSM_RSM_H */ 378