12072Svn83148 /* 22072Svn83148 * CDDL HEADER START 32072Svn83148 * 42072Svn83148 * The contents of this file are subject to the terms of the 52072Svn83148 * Common Development and Distribution License (the "License"). 62072Svn83148 * You may not use this file except in compliance with the License. 72072Svn83148 * 82072Svn83148 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 92072Svn83148 * or http://www.opensolaris.org/os/licensing. 102072Svn83148 * See the License for the specific language governing permissions 112072Svn83148 * and limitations under the License. 122072Svn83148 * 132072Svn83148 * When distributing Covered Code, include this CDDL HEADER in each 142072Svn83148 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 152072Svn83148 * If applicable, add the following below this CDDL HEADER, with the 162072Svn83148 * fields enclosed by brackets "[]" replaced with your own identifying 172072Svn83148 * information: Portions Copyright [yyyy] [name of copyright owner] 182072Svn83148 * 192072Svn83148 * CDDL HEADER END 202072Svn83148 */ 212072Svn83148 /* 22*6111Scy152378 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 232072Svn83148 * Use is subject to license terms. 242072Svn83148 */ 252072Svn83148 262072Svn83148 #ifndef _LDMSVCS_UTILS_H 272072Svn83148 #define _LDMSVCS_UTILS_H 282072Svn83148 292072Svn83148 #pragma ident "%Z%%M% %I% %E% SMI" 302072Svn83148 312072Svn83148 #include <stdlib.h> 322072Svn83148 #include <sys/types.h> 332072Svn83148 #include <sys/ldc.h> 342072Svn83148 #include <sys/vldc.h> 352072Svn83148 #include <sys/ds.h> 362072Svn83148 #include <sys/ds_impl.h> 372072Svn83148 382072Svn83148 #ifdef __cplusplus 392072Svn83148 extern "C" { 402072Svn83148 #endif 412072Svn83148 422072Svn83148 /* 432072Svn83148 * Service Information 442072Svn83148 */ 452072Svn83148 typedef struct fds_svc { 462072Svn83148 ds_svc_hdl_t hdl; /* handle assigned by DS */ 472072Svn83148 ds_svc_state_t state; /* current service state */ 482072Svn83148 ds_ver_t ver; /* svc protocol version in use */ 492072Svn83148 char *name; 502072Svn83148 } fds_svc_t; 512072Svn83148 522072Svn83148 /* 532072Svn83148 * table of registered services 542072Svn83148 */ 552072Svn83148 typedef struct fds_reg_svcs { 562072Svn83148 pthread_mutex_t mt; 572072Svn83148 pthread_cond_t cv; 582072Svn83148 fds_svc_t **tbl; /* the table itself */ 592072Svn83148 uint_t nsvcs; /* current number of items */ 602072Svn83148 } fds_reg_svcs_t; 612072Svn83148 622072Svn83148 632072Svn83148 typedef enum { 642072Svn83148 CHANNEL_UNINITIALIZED, /* status of channel unknown */ 652072Svn83148 CHANNEL_CLOSED, /* port structure not in use */ 662072Svn83148 CHANNEL_OPEN, /* open but not initialized/reset */ 672072Svn83148 CHANNEL_READY, /* init/reset done */ 682072Svn83148 CHANNEL_UNUSABLE, /* cannot be used (possibly busy) */ 692072Svn83148 CHANNEL_EXIT /* normal exit */ 702072Svn83148 } fds_chan_state_t; 712072Svn83148 722072Svn83148 typedef struct fds_channel { 732072Svn83148 int fd; /* FD for this channel */ 742072Svn83148 fds_chan_state_t state; /* state of the port */ 752072Svn83148 ds_ver_t ver; /* DS protocol version in use */ 762072Svn83148 } fds_channel_t; 772072Svn83148 782072Svn83148 792072Svn83148 /* 802072Svn83148 * FMA services 812072Svn83148 */ 822072Svn83148 typedef struct { 832072Svn83148 uint64_t req_num; 842072Svn83148 } fma_req_pri_t; 852072Svn83148 862072Svn83148 /* 872072Svn83148 * definition of fma_pri_resp_t is not shown here. for more details, 882072Svn83148 * see ldmsvcs_utils.c:ldmsvcs_get_core_md(). 892072Svn83148 */ 902072Svn83148 912072Svn83148 #define FMA_CPU_REQ_STATUS 0 922072Svn83148 #define FMA_CPU_REQ_OFFLINE 1 932072Svn83148 #define FMA_CPU_REQ_ONLINE 2 942072Svn83148 952072Svn83148 #define FMA_CPU_RESP_OK 0 962072Svn83148 #define FMA_CPU_RESP_FAILURE 1 972072Svn83148 982072Svn83148 #define FMA_CPU_STAT_ONLINE 0 992072Svn83148 #define FMA_CPU_STAT_OFFLINE 1 1002072Svn83148 #define FMA_CPU_STAT_ILLEGAL 2 1012072Svn83148 1022072Svn83148 typedef struct { 1032072Svn83148 uint64_t req_num; 1042072Svn83148 uint32_t msg_type; 1052072Svn83148 uint32_t cpu_id; 1062072Svn83148 } fma_cpu_service_req_t; 1072072Svn83148 1082072Svn83148 typedef struct { 1092072Svn83148 uint64_t req_num; 1102072Svn83148 uint32_t result; 1112072Svn83148 uint32_t status; 1122072Svn83148 } fma_cpu_resp_t; 1132072Svn83148 1142072Svn83148 #define FMA_MEM_REQ_STATUS 0 1152072Svn83148 #define FMA_MEM_REQ_RETIRE 1 1162072Svn83148 #define FMA_MEM_REQ_RESURRECT 2 1172072Svn83148 1182072Svn83148 #define FMA_MEM_RESP_OK 0 1192072Svn83148 #define FMA_MEM_RESP_FAILURE 1 1202072Svn83148 1212072Svn83148 #define FMA_MEM_STAT_NOTRETIRED 0 1222072Svn83148 #define FMA_MEM_STAT_RETIRED 1 1232072Svn83148 #define FMA_MEM_STAT_ILLEGAL 2 1242072Svn83148 1252072Svn83148 typedef struct { 1262072Svn83148 uint64_t req_num; 1272072Svn83148 uint32_t msg_type; 1282072Svn83148 uint32_t _resvd; 1292072Svn83148 uint64_t real_addr; 1302072Svn83148 uint64_t length; 1312072Svn83148 } fma_mem_service_req_t; 1322072Svn83148 1332072Svn83148 typedef struct { 1342072Svn83148 uint64_t req_num; 1352072Svn83148 uint32_t result; 1362072Svn83148 uint32_t status; 1372072Svn83148 uint64_t res_addr; 1382072Svn83148 uint64_t res_length; 1392072Svn83148 } fma_mem_resp_t; 1402072Svn83148 1412072Svn83148 1422072Svn83148 struct ldom_hdl { 1432072Svn83148 int major_version; 1442072Svn83148 int service_ldom; 1452072Svn83148 void *(*allocp)(size_t size); 1462072Svn83148 void (*freep)(void *addr, size_t size); 1472072Svn83148 struct ldmsvcs_info *lsinfo; 1482072Svn83148 }; 1492072Svn83148 1504358Srb144127 /* 1514358Srb144127 * in the default case of ldmd (the LDOM manager daemon/service) 1524358Srb144127 * not installed/running, set short timeouts for contacting ldmd, 1534358Srb144127 * so that higher levels in the software stack (ex: diagnosis engines) 1544358Srb144127 * are not excessively delayed by ldmd's absence. both timeouts are tunable 1554358Srb144127 * via SMF properties in ldmd's service manifest, and expected to be set 1564358Srb144127 * thusly to appropriate values when ldmd is installed. 1574358Srb144127 * 1584358Srb144127 * timeouts are in seconds. init is the initial timeout; running is 1594358Srb144127 * for subsequent timeouts. 1604358Srb144127 */ 1614358Srb144127 #define LDM_INIT_WAIT_TIME 2 1624358Srb144127 #define LDM_RUNNING_WAIT_TIME 2 1634358Srb144127 1644358Srb144127 #define LDM_SVC_NM "svc:/ldoms/ldmd:default" 1654358Srb144127 #define LDM_PROP_GROUP_NM "fmd_config" 1664358Srb144127 1674358Srb144127 #define LDM_INIT_TO_PROP_NM "fmd_to_ldmd_init_timeout" 1684358Srb144127 #define LDM_RUNNING_TO_PROP_NM "fmd_to_ldmd_running_timeout" 1692072Svn83148 1702072Svn83148 extern int ldmsvcs_check_channel(void); 1712072Svn83148 1722072Svn83148 extern void ldmsvcs_init(struct ldom_hdl *lhp); 1732072Svn83148 1742072Svn83148 extern void ldmsvcs_fini(struct ldom_hdl *lhp); 1752072Svn83148 1762072Svn83148 extern ssize_t ldmsvcs_get_core_md(struct ldom_hdl *lhp, uint64_t **buf); 1772072Svn83148 1782072Svn83148 extern int ldmsvcs_cpu_req_status(struct ldom_hdl *lhp, uint32_t cpuid); 1792072Svn83148 1802072Svn83148 extern int ldmsvcs_mem_req_status(struct ldom_hdl *lhp, uint64_t pa); 1812072Svn83148 1822072Svn83148 extern int ldmsvcs_cpu_req_offline(struct ldom_hdl *lhp, uint32_t cpuid); 1832072Svn83148 1842072Svn83148 extern int ldmsvcs_mem_req_retire(struct ldom_hdl *lhp, uint64_t pa); 1852072Svn83148 186*6111Scy152378 extern int ldmsvcs_cpu_req_online(struct ldom_hdl *lhp, uint32_t cpuid); 187*6111Scy152378 188*6111Scy152378 extern int ldmsvcs_mem_req_unretire(struct ldom_hdl *lhp, uint64_t pa); 189*6111Scy152378 1902072Svn83148 #ifdef __cplusplus 1912072Svn83148 } 1922072Svn83148 #endif 1932072Svn83148 1942072Svn83148 #endif /* _LDMSVCS_UTILS_H */ 195