10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51772Sjl139090 * Common Development and Distribution License (the "License"). 61772Sjl139090 * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 226111Scy152378 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _CMA_H 270Sstevel@tonic-gate #define _CMA_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #include <fm/fmd_api.h> 300Sstevel@tonic-gate #include <sys/types.h> 310Sstevel@tonic-gate 320Sstevel@tonic-gate #ifdef __cplusplus 330Sstevel@tonic-gate extern "C" { 340Sstevel@tonic-gate #endif 350Sstevel@tonic-gate 361772Sjl139090 #define CMA_RA_SUCCESS 0 371772Sjl139090 #define CMA_RA_FAILURE 1 381772Sjl139090 396111Scy152378 #ifdef opl 406111Scy152378 #define FM_FMRI_HC_CPUIDS "hc-xscf-cpuids" 416111Scy152378 #endif 426111Scy152378 437532SSean.Ye@Sun.COM #ifdef i386 447532SSean.Ye@Sun.COM extern boolean_t cma_is_native; 457532SSean.Ye@Sun.COM #endif 467532SSean.Ye@Sun.COM 470Sstevel@tonic-gate typedef struct cma_page { 480Sstevel@tonic-gate struct cma_page *pg_next; /* List of page retirements for retry */ 49*8221SSean.Ye@Sun.COM nvlist_t *pg_rsrc; /* Resource for this page */ 50*8221SSean.Ye@Sun.COM nvlist_t *pg_asru; /* ASRU for this page */ 510Sstevel@tonic-gate uint64_t pg_addr; /* Address of this page */ 520Sstevel@tonic-gate char *pg_uuid; /* UUID for this page's case */ 530Sstevel@tonic-gate uint_t pg_nretries; /* Number of retries so far for page */ 540Sstevel@tonic-gate } cma_page_t; 550Sstevel@tonic-gate 566111Scy152378 #ifdef sun4v 576111Scy152378 typedef struct cma_cpu { 586111Scy152378 struct cma_cpu *cpu_next; /* List of cpus */ 596111Scy152378 nvlist_t *cpu_fmri; /* FMRI for this cpu entry */ 606111Scy152378 int cpuid; /* physical id of this cpu */ 616111Scy152378 char *cpu_uuid; /* UUID for this cpu's case */ 626111Scy152378 uint_t cpu_nretries; /* Number of retries so far for cpu */ 636111Scy152378 } cma_cpu_t; 646111Scy152378 #endif /* sun4v */ 656111Scy152378 660Sstevel@tonic-gate typedef struct cma { 670Sstevel@tonic-gate struct timespec cma_cpu_delay; /* CPU offline retry interval */ 680Sstevel@tonic-gate uint_t cma_cpu_tries; /* Number of CPU offline retries */ 690Sstevel@tonic-gate uint_t cma_cpu_dooffline; /* Whether to offline CPUs */ 700Sstevel@tonic-gate uint_t cma_cpu_forcedoffline; /* Whether to do forced CPU offline */ 716111Scy152378 uint_t cma_cpu_doonline; /* Whether to online CPUs */ 720Sstevel@tonic-gate uint_t cma_cpu_doblacklist; /* Whether to blacklist CPUs */ 736111Scy152378 uint_t cma_cpu_dounblacklist; /* Whether to unblacklist CPUs */ 740Sstevel@tonic-gate cma_page_t *cma_pages; /* List of page retirements for retry */ 750Sstevel@tonic-gate hrtime_t cma_page_curdelay; /* Current retry sleep interval */ 760Sstevel@tonic-gate hrtime_t cma_page_mindelay; /* Minimum retry sleep interval */ 770Sstevel@tonic-gate hrtime_t cma_page_maxdelay; /* Maximum retry sleep interval */ 780Sstevel@tonic-gate id_t cma_page_timerid; /* fmd timer ID for retry sleep */ 790Sstevel@tonic-gate uint_t cma_page_doretire; /* Whether to retire pages */ 806111Scy152378 uint_t cma_page_dounretire; /* Whether to unretire pages */ 816111Scy152378 #ifdef sun4v 826111Scy152378 cma_cpu_t *cma_cpus; /* List of cpus */ 836111Scy152378 hrtime_t cma_cpu_curdelay; /* Current retry sleep interval */ 846111Scy152378 hrtime_t cma_cpu_mindelay; /* Minimum retry sleep interval */ 856111Scy152378 hrtime_t cma_cpu_maxdelay; /* Maximum retry sleep interval */ 866111Scy152378 id_t cma_cpu_timerid; /* LDOM cpu timer */ 876111Scy152378 #endif /* sun4v */ 880Sstevel@tonic-gate } cma_t; 890Sstevel@tonic-gate 900Sstevel@tonic-gate typedef struct cma_stats { 910Sstevel@tonic-gate fmd_stat_t cpu_flts; /* Successful offlines */ 926111Scy152378 fmd_stat_t cpu_repairs; /* Successful onlines */ 936111Scy152378 fmd_stat_t cpu_fails; /* Failed offlines/onlines */ 940Sstevel@tonic-gate fmd_stat_t cpu_blfails; /* Failed blacklists */ 956111Scy152378 fmd_stat_t cpu_supp; /* Suppressed offlines/onlines */ 960Sstevel@tonic-gate fmd_stat_t cpu_blsupp; /* Suppressed blacklists */ 970Sstevel@tonic-gate fmd_stat_t page_flts; /* Successful page retires */ 986111Scy152378 fmd_stat_t page_repairs; /* Successful page unretires */ 996111Scy152378 fmd_stat_t page_fails; /* Failed page retires/unretires */ 1006111Scy152378 fmd_stat_t page_supp; /* Suppressed retires/unretires */ 1010Sstevel@tonic-gate fmd_stat_t page_nonent; /* Retires for non-present pages */ 1020Sstevel@tonic-gate fmd_stat_t bad_flts; /* Malformed faults */ 1030Sstevel@tonic-gate fmd_stat_t nop_flts; /* Inapplicable faults */ 1040Sstevel@tonic-gate fmd_stat_t auto_flts; /* Auto-close faults */ 1050Sstevel@tonic-gate } cma_stats_t; 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate extern cma_stats_t cma_stats; 1080Sstevel@tonic-gate extern cma_t cma; 1090Sstevel@tonic-gate 110*8221SSean.Ye@Sun.COM extern int cma_cpu_cpu_retire(fmd_hdl_t *, nvlist_t *, nvlist_t *, 1116111Scy152378 const char *, boolean_t); 1126111Scy152378 extern int cma_cpu_hc_retire(fmd_hdl_t *, nvlist_t *, nvlist_t *, 1136111Scy152378 const char *, boolean_t); 1146111Scy152378 extern int cma_page_retire(fmd_hdl_t *, nvlist_t *, nvlist_t *, 1156111Scy152378 const char *, boolean_t); 1160Sstevel@tonic-gate extern void cma_page_retry(fmd_hdl_t *); 1170Sstevel@tonic-gate extern void cma_page_fini(fmd_hdl_t *); 1186111Scy152378 extern int cma_set_errno(int); 1190Sstevel@tonic-gate 1206330Sjc25722 extern int cma_cache_way_retire(fmd_hdl_t *, nvlist_t *, nvlist_t *, 1216330Sjc25722 const char *, boolean_t); 1226111Scy152378 /* 1236111Scy152378 * Platforms may have their own implementations of these functions 1246111Scy152378 */ 1256111Scy152378 extern int cma_cpu_blacklist(fmd_hdl_t *, nvlist_t *, nvlist_t *, boolean_t); 1266111Scy152378 extern int cma_cpu_statechange(fmd_hdl_t *, nvlist_t *, const char *, int, 1276111Scy152378 boolean_t); 1287532SSean.Ye@Sun.COM extern int cma_fmri_page_service_state(fmd_hdl_t *, nvlist_t *); 1297532SSean.Ye@Sun.COM extern int cma_fmri_page_retire(fmd_hdl_t *, nvlist_t *); 1307532SSean.Ye@Sun.COM extern int cma_fmri_page_unretire(fmd_hdl_t *, nvlist_t *); 1316111Scy152378 1326111Scy152378 #ifdef sun4v 133*8221SSean.Ye@Sun.COM extern void cma_cpu_start_retry(fmd_hdl_t *, nvlist_t *, const char *, 134*8221SSean.Ye@Sun.COM boolean_t); 1356111Scy152378 extern void cma_cpu_fini(fmd_hdl_t *); 1366111Scy152378 extern void cma_cpu_retry(fmd_hdl_t *); 1376111Scy152378 #endif /* sun4v */ 1386111Scy152378 1396111Scy152378 extern const char *p_online_state_fmt(int); 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate #ifdef __cplusplus 1420Sstevel@tonic-gate } 1430Sstevel@tonic-gate #endif 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate #endif /* _CMA_H */ 146