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 (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27#ifndef _FPSD_H 28#define _FPSD_H 29 30/* 31 * FPSD structure and global functions 32 */ 33 34#ifdef __cplusplus 35extern "C" { 36#endif 37 38#include <door.h> 39#include <sys/processor.h> 40#include <sys/param.h> 41 42#define FPS_DAEMON_NAME "fpsd" 43#define FPS_FPUTST_NAME "fptest" 44 45#define FPS_DIR "/usr/lib/fps" 46#define FPS_CORE_DIR "/var/fps/core" 47 48#define FPU_TST_SRCH_DPTH 4 /* File search depth from FPS_DIR */ 49#define DFLT_DBG_LVL 1 /* Default debug level */ 50#define FPS_DOOR_COOKIE ((void *)0xdeadbead) 51 52#define SMF_PROP_INTVL "interval" 53#define SMF_FPS_PROP_GRP_NAME "config" 54#define SMF_PROP_EXCLD_CPUS "exclude_cpus" 55 56/* 57 * RSS of fptest is about 10M and size = 15M; Keeping 185M in reserve, 58 * which is chosen aribitrarily that didn't cause test fork failure, 59 * nor a memory crunch in the system. So total swap space needed = 200M. 60 */ 61#define FPS_LOWTST_SWAP 15 /* Low stress consumes 15 MB */ 62#define FPS_SWAP_RESERVE 185 /* Leave atleast 185 MB in the system */ 63 64/* (in secs) Delay test on low config m/c for 5min during bootup */ 65#define FPS_BOOT_TST_DELAY (3*60) 66#define MAX_RETRIES 2 67#define MAX_FAILURES 3 68#define RETRY_INTVL 2000 /* in milli-seconds */ 69#define MIN_INTERVAL 3 /* in seconds */ 70 71/* Maximum time fptest is expected to run which is 1s */ 72 73#define MAX_TEST_RUN_TIME 1 74 75typedef struct 76{ 77 processorid_t cpuid; 78 int frequency; 79 char brand[MAXNAMELEN]; 80 int asc; 81 int previous_iteration; 82 int total_iterations; /* For this fpu */ 83 int disable_test; 84 int num_failures; /* Failures to run fptest successfully. */ 85 char fptest_path[MAXPATHLEN]; 86 87} fps_cpu_t; 88 89typedef struct 90{ 91 char m_machine[MAXNAMELEN]; /* machine name e.g. sun4u */ 92 uint_t m_num_fpus; /* num of fpus in the system */ 93 uint_t m_num_on_fpuids; /* num of online cpus */ 94 int m_max_cpuid; /* maximum cpuid for this system */ 95 fps_cpu_t *m_cpus; /* array of cpus to test */ 96 int m_cpuids_size; /* size of previous array */ 97 int m_num_cpus_to_test; /* Num cpus to run test */ 98 int m_reprobe; /* flag set if reprobe required: */ 99 /* - config changed */ 100 /* - fp-test failed to offline */ 101 int total_iter; /* total iterations to run in 24 hr */ 102} mach_conf_t; 103 104typedef struct fpsd_struct 105{ 106 unsigned d_fg; /* "fg" foreground property */ 107 int d_daemon; /* running as daemon ? */ 108 mach_conf_t *d_conf; /* machine config information */ 109 processorid_t *d_ignore_cpuid; /* array of cpuids to ignore */ 110 int num_ignore_cpus; /* No. of cpuids to ignore */ 111 int d_iteration; /* iteration number */ 112 int d_interval; /* sleep time between iterations */ 113 int d_fpuid_index; /* Currently testing fpu */ 114 const char *d_rootdir; /* root directory path */ 115 pid_t d_pid; /* Process id */ 116 /* Timestamp last time HUP was recd */ 117 volatile hrtime_t d_ts_hup; 118} fpsd_t; 119 120/* 121 * Exit status values used for the few places within fpsd where we exit(2) or 122 * return from main(). fpsd only exits if a fatal error occurs during startup; 123 * if anything else happens errors are reported and we just keep tracking. 124 */ 125#define FPSD_NO_EXIT 0 /* continue execution of daemon */ 126#define FPSD_EXIT_ERROR 1 /* failed to initialize daemon */ 127#define FPSD_EXIT_USAGE 2 /* syntax error on command-line */ 128#define FPSD_EXIT_TEST_USAGE 3 /* Invalid args passed to fp-test */ 129 130#define FPSD_INIT_SUCCESS 0 /* To inform parent process that */ 131 /* initialization was successful, so */ 132 /* that the parent can detach */ 133 134#define NO_DAEMON 0 135#define DAEMON_EXISTS 1 136#define DAEMON_EXISTS_AND_SAME_PROC 2 137 138#define NO_CPUS_2_TEST -2 139#define ZERO_INTERVAL -1 140 141/* Global Variables */ 142 143/* Defined in fpsd_main.c */ 144extern int debug_level; 145extern fpsd_t fpsd; 146extern pthread_mutex_t log_mutex; /* fpsd_log.c */ 147extern int is_estar_system; /* fpsd_esutil.c */ 148extern int sys_pm_state; /* fpsd_esutil.c */ 149 150 151/* Util Functions */ 152 153extern uint64_t get_free_swap(void); /* fpsd_util.c */ 154extern void fps_wait_secs(int secs); /* fpsd_util.c */ 155 156extern void *test_fpu_thr(void *arg); /* in fpsd_sched.c */ 157 158extern void fps_door_handler(void *cookie, char *argp, size_t asize, 159 door_desc_t *dp, uint_t n_desc); /* in fpsd_util.c */ 160 161extern void update_pm_state(); /* fpsd_esutil.c */ 162extern int get_idle_rem_stats(int *min_idle, 163 int *min_rem, int *max_rem); /* fpsd_esutil.c */ 164extern void init_estar_db(); /* fpsd_esutil.c */ 165extern void wait_for_pm_state_change(); /* fpsd_esutil.c */ 166 167/* fpsd_log.c */ 168extern void fpsd_message(int return_code, int msg_type, char *fmt, ...); 169 170extern void terminate_process(); /* fpsd_main.c */ 171extern void fpsd_read_config(); /* fpsd_main.c */ 172 173#ifdef __cplusplus 174} 175#endif 176 177#endif /* _FPSD_H */ 178