/* hxsstas : read exerciser info from shared memory and store it /tmp/htxstats file */
int htxd_load_hxstats(void)
{
	int hxstats_pid, rc = 0;
	char hxsstats_path[512], temp_str[300];


	hxstats_pid = htxd_create_child_process();
	switch(hxstats_pid)
	{
	case 0:
		strcpy(hxsstats_path, global_htx_home_dir);
		strcat(hxsstats_path, "/bin/hxstats");

		sprintf(temp_str, "%s/htxstats", global_htx_log_dir);
		execl(hxsstats_path, "hxstats", temp_str, "30", (char *) 0 );

		sprintf(temp_str, "htxd_load_hxstats: hxstats load failed, execl failed with errno <%d>", errno); 
		HTXD_TRACE(LOG_ON, temp_str);
		exit(errno);

	case -1:
		sprintf(temp_str, "htxd_load_hxstats: htxd_create_child_process returned -1 with errno <%d>", errno);
		HTXD_TRACE(LOG_ON, temp_str);
		exit(-1);

	default:
		htxd_set_htx_stats_pid(hxstats_pid);
	}

	htxd_reset_FD_close_on_exec_flag();
#ifdef __HTX_LINUX__
	if ((htxd_get_equaliser_offline_cpu_flag()) == 1) {
		rc = do_the_bind_proc(hxstats_pid);
		if (rc < 0) {
			sprintf(temp_str, "binding hxstats process to core 0 failed.");
			htxd_send_message(temp_str, 0, HTX_SYS_INFO, HTX_SYS_MSG);
		}

	}
#endif

	return 0;
}
/* start equaliser process */
int htxd_start_equaliser(void)
{

	int rc = 0;
	pid_t equaliser_pid;
	char	temp_str[128];

	equaliser_pid = htxd_create_child_process();
	switch(equaliser_pid)
	{
	case 0:
		htxd_equaliser();
		sprintf(temp_str, "htxd_start_equaliser: returned from htxd_equaliser, exiting...");
		HTXD_TRACE(LOG_ON, temp_str);
		exit(0);
		break;

	case -1:
		sprintf(temp_str, "Unable to fork for equaliser process.  errno = %d", errno);
		htxd_send_message(temp_str, errno, HTX_SYS_HARD_ERROR, HTX_SYS_MSG);
		break;

	default:
		printf("DEBUG: equaliser process started with pid <%d>\n", equaliser_pid);
		htxd_set_equaliser_pid(equaliser_pid);
	#ifdef __HTX_LINUX__
		if ((htxd_get_equaliser_offline_cpu_flag()) == 1) {
			rc = do_the_bind_proc(equaliser_pid);
			if (rc < 0) {
				sprintf(temp_str, "binding equaliser process to core 0 failed.\n");
				htxd_send_message(temp_str, 0, HTX_SYS_INFO, HTX_SYS_MSG);
			}
		}
	#endif
		break;

	}

	return 0;
}
/* hxsmsg : picks messages from HTX message queue and stores the messages in files */
int htxd_load_hxsmsg(htxd_profile *p_profile)
{
	int hxsmsg_pid, rc = 0;
	char hxsmsg_path[512], temp_str[256];
	char auto_start_flag_string[8];


	hxsmsg_pid = htxd_create_child_process();
	switch(hxsmsg_pid)
	{
	case 0:
		strcpy(hxsmsg_path, global_htx_home_dir);
		strcat(hxsmsg_path, "/bin/hxsmsg");

		sprintf(temp_str, "%s/%s", global_htx_home_dir, HTXD_AUTOSTART_FILE);
		if(htxd_is_file_exist(temp_str) == FALSE) {
			strcpy(auto_start_flag_string, "no");
		} else {
			strcpy(auto_start_flag_string, "yes");
		}

		execl(	hxsmsg_path,
				"hxsmsg",
				p_profile->max_htxerr_size,
				p_profile->max_htxmsg_size,
				p_profile->max_htxerr_save_size,
				p_profile->max_htxmsg_save_size,
				p_profile->htxerr_wrap,
				p_profile->htxmsg_wrap,
				p_profile->htxmsg_archive,
				auto_start_flag_string,
				p_profile->stress_device,
				p_profile->stress_cycle,
				(char *) 0);
		sprintf(temp_str, "htxd_load_hxsmsg: hxsmsg load failedi, execl returned with errno  <errno : %d> !!!", errno); 
		HTXD_TRACE(LOG_ON, temp_str);
		exit(errno);

	case -1:
		return -1;
		break;

	default:
		htxd_set_htx_msg_pid(hxsmsg_pid);
	#ifdef __HTX_LINUX__
		if ((htxd_get_equaliser_offline_cpu_flag()) == 1) {
			rc = do_the_bind_proc(hxsmsg_pid);
			if (rc < 0) {
				sprintf(temp_str, "binding hxsmsg process to core 0 failed.");
				htxd_send_message(temp_str, 0, HTX_SYS_INFO, HTX_SYS_MSG);
				HTXD_TRACE(LOG_ON, temp_str);
			}

		}
	#endif
		break;
	}

	htxd_reset_FD_close_on_exec_flag();

	return 0;
}
Пример #4
0
/* get equaliser flag value from ECG */
int htxd_init_equaliser_info( htxd_ecg_info *p_ecg_info)
{
	int		return_code;
	CFG__SFT *	mdt_fd = NULL;
	char		default_mdt_snz[4096];
	char		temp_str[128];


	p_ecg_info->ecg_equaliser_info.enable_flag	= 0;
	p_ecg_info->ecg_equaliser_info.debug_flag	= 0;
	p_ecg_info->ecg_equaliser_info.config_file[0]	= '\0';
	p_ecg_info->ecg_equaliser_info.wof_test = 0;

	mdt_fd = cfgcopsf (p_ecg_info->ecg_name);
	if (mdt_fd == (CFG__SFT *) NULL) {
		sprintf (temp_str, "ERROR: Unable to open ECG file again.n");
		return -1;
	}

	return_code = cfgcrdsz (mdt_fd, default_mdt_snz, sizeof (default_mdt_snz), "default");
	if (return_code == CFG_SUCC) {
		return_code = cfgcskwd("equaliser_flag", default_mdt_snz, temp_str);
		if(return_code ==  CFG_SUCC) {
			p_ecg_info->ecg_equaliser_info.enable_flag = atoi(htxd_unquote(temp_str));
		}
		if(p_ecg_info->ecg_equaliser_info.enable_flag == 1) {
			putenv("EQUALISER_FLAG=1");
			return_code = cfgcskwd("cfg_file", default_mdt_snz, temp_str);
			if(return_code ==  CFG_SUCC) {
				strcpy( p_ecg_info->ecg_equaliser_info.config_file, htxd_unquote(temp_str));
				htxd_set_equaliser_conf_file(p_ecg_info->ecg_equaliser_info.config_file);
			}

			return_code = cfgcskwd("equaliser_debug_flag", default_mdt_snz, temp_str);
			if(return_code ==  CFG_SUCC) {
				p_ecg_info->ecg_equaliser_info.debug_flag = atoi(htxd_unquote(temp_str));
				htxd_set_equaliser_debug_flag(p_ecg_info->ecg_equaliser_info.debug_flag);
			}
			return_code = cfgcskwd("wof_test", default_mdt_snz, temp_str);
			if(return_code ==  CFG_SUCC) {
				p_ecg_info->ecg_equaliser_info.wof_test = atoi(htxd_unquote(temp_str));
				htxd_set_equaliser_wof_test_flag(p_ecg_info->ecg_equaliser_info.wof_test);
			#ifdef __HTX_LINUX__
				/* Also, get the SMT for core 0, if WOF test is enabled as this will be
				 * while binding the threads/processes to core 0.
				 */
				if (p_ecg_info->ecg_equaliser_info.wof_test == 1) {
					smt = get_smt_status(0);
					return_code = do_the_bind_proc(getpid());
					if (return_code < 0) {
						sprintf(temp_str, "Binding of htxd process to core 0 failed.\n");
						htxd_send_message(temp_str, 0, HTX_SYS_INFO, HTX_SYS_MSG);

					}
				}
			#endif
			}
			htxd_set_equaliser_shm_addr(p_ecg_info->ecg_shm_addr);
			htxd_set_equaliser_semhe_id(p_ecg_info->ecg_sem_id);
		} else {
		}

		if (cfgcclsf (mdt_fd) != CFG_SUCC) {
		}

	}

	return 0;
}