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