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