コード例 #1
0
ファイル: ipmi_sensor.c プロジェクト: openhpi1/testrepo
static void get_sensor_thresholds(ipmi_sensor_t *sensor, 
                                  void          *cb_data)
{
	struct ohoi_sensor_thresholds *thres_data;
	int rv;
	
        thres_data = cb_data;
	if (ignore_sensor(sensor)) {
                dbg("ENTITY_NOT_PRESENT");
		return;
	}	
	
	if (ipmi_sensor_get_event_reading_type(sensor) ==
			IPMI_EVENT_READING_TYPE_THRESHOLD) {
		if (ipmi_sensor_get_threshold_access(sensor) ==
				IPMI_EVENT_SUPPORT_NONE)
			dbg("sensor doesn't support threshold read");
		else {
			rv = get_thresholds(sensor, thres_data);
			if (rv < 0) {
                                dbg("Unable to get sensor thresholds");
				return;
                        }
		}
					
		rv = ipmi_sensor_get_hysteresis_support(sensor);
		if (rv == IPMI_HYSTERESIS_SUPPORT_NONE) {
#if 0
			/* I'm zeroing them so we return but invalid data FIXME? */
			thres_data->sensor_thres->PosThdHysteresis.ValuesPresent = 0;
			thres_data->sensor_thres->NegThdHysteresis.ValuesPresent = 0;
#else
			thres_data->sensor_thres->PosThdHysteresis.IsSupported = SAHPI_FALSE;
			thres_data->sensor_thres->NegThdHysteresis.IsSupported = SAHPI_FALSE;
#endif
                        thres_data->hyster_done = 1; /* read no more */
			return;
		} else {
			if (rv == IPMI_HYSTERESIS_SUPPORT_READABLE ||
					rv == IPMI_HYSTERESIS_SUPPORT_SETTABLE) { 
				rv = get_hysteresis(sensor, thres_data);
				if (rv < 0)
					dbg("failed to get hysteresis");
			}
		}
		
	} else {
		dbg("Not threshold sensor!");
        }
	
	return;
}
コード例 #2
0
ファイル: ipmi_sensor.c プロジェクト: openhpi1/testrepo
static void get_sensor_thresholds(ipmi_sensor_t *sensor, 
                                  void          *cb_data)
{
	struct ohoi_sensor_thresholds *thres_data;
	int rv;
	
        thres_data = cb_data;

	if (ignore_sensor(sensor)) {
		thres_data->hyster_done = 1;
		thres_data->thres_done = 1;
		thres_data->rvalue = SA_ERR_HPI_NOT_PRESENT;
                dbg("ENTITY_NOT_PRESENT");
		return;
	}	

	if (ipmi_sensor_get_event_reading_type(sensor) ==
			IPMI_EVENT_READING_TYPE_THRESHOLD) {
		if (ipmi_sensor_get_threshold_access(sensor) ==
				IPMI_THRESHOLD_ACCESS_SUPPORT_NONE)
			dbg("sensor doesn't support threshold read");
		else {
			rv = get_thresholds(sensor, thres_data);
			if (rv < 0) {
                                dbg("Unable to get sensor thresholds");
				return;
                        }
		}
					
		rv = ipmi_sensor_get_hysteresis_support(sensor);
		if (rv == IPMI_HYSTERESIS_SUPPORT_NONE) {
			thres_data->sensor_thres.PosThdHysteresis.IsSupported = SAHPI_FALSE;
			thres_data->sensor_thres.NegThdHysteresis.IsSupported = SAHPI_FALSE;
                        thres_data->hyster_done = 1; /* read no more */
			return;
		} else {
			if (rv == IPMI_HYSTERESIS_SUPPORT_READABLE ||
					rv == IPMI_HYSTERESIS_SUPPORT_SETTABLE) { 
				rv = get_hysteresis(sensor, thres_data);
				if (rv < 0)
					dbg("failed to get hysteresis");
			}
		}
		
	} else {
		dbg("Not threshold sensor!");
        }
	
	return;
}
コード例 #3
0
time_t wrsTemperature_data_fill(void)
{
	unsigned ii;
	unsigned retries = 0;
	static time_t time_update;
	time_t time_cur;
	static int first_run = 1;

	time_cur = get_monotonic_sec();
	if (time_update
	    && time_cur - time_update < WRSTEMPERATURE_CACHE_TIMEOUT) {
		/* cache not updated, return last update time */
		return time_update;
	}
	time_update = time_cur;

	if (first_run) {
		/* load thresholds only once */
		get_thresholds();
		first_run = 0;
	}

	if (!shmem_ready_hald()) {
		/* Unable to open shmem, return current time */
		snmp_log(LOG_ERR, "%s: Unable to read HAL's shmem\n", __func__);
		return time_update;
	}

	while (1) {
		ii = wrs_shm_seqbegin(hal_head);

		wrsTemperature_s.temp_fpga = hal_shmem->temp.fpga >> 8;
		wrsTemperature_s.temp_pll = hal_shmem->temp.pll >> 8;
		wrsTemperature_s.temp_psl = hal_shmem->temp.psl >> 8;
		wrsTemperature_s.temp_psr = hal_shmem->temp.psr >> 8;

		retries++;
		if (retries > 100) {
			snmp_log(LOG_ERR, "%s: too many retries to read HAL\n",
				 __func__);
			retries = 0;
			}
		if (!wrs_shm_seqretry(hal_head, ii))
			break; /* consistent read */
		usleep(1000);
	}
	/* there was an update, return current time */
	return time_update;
}
コード例 #4
0
ファイル: ipmi_sensor.c プロジェクト: openhpi1/openhpitest
static void get_sensor_thresholds(ipmi_sensor_t *sensor, 
                                  void          *cb_data)
{
	struct ohoi_sensor_thresholds *thres_data;
	int rv;
	
        thres_data = cb_data;

	if (ignore_sensor(sensor)) {
		thres_data->hyster_done = 1;
		thres_data->thres_done = 1;
		thres_data->rvalue = SA_ERR_HPI_NOT_PRESENT;
                err("ENTITY_NOT_PRESENT");
		return;
	}	

	if (ipmi_sensor_get_event_reading_type(sensor) !=
			IPMI_EVENT_READING_TYPE_THRESHOLD) {
		err("Not threshold sensor!");
		thres_data->hyster_done = 1;
		thres_data->thres_done = 1;
		thres_data->rvalue = SA_ERR_HPI_INVALID_CMD;
		return;
	}
	if (ipmi_sensor_get_threshold_access(sensor) ==
				IPMI_THRESHOLD_ACCESS_SUPPORT_NONE) {
		err("sensor doesn't support threshold read");
			err("Unable to get sensor thresholds");
			thres_data->hyster_done = 1;
			thres_data->thres_done = 1;
			thres_data->rvalue = SA_ERR_HPI_INVALID_CMD;
			return;
	}
	rv = get_thresholds(sensor, thres_data);
	if (rv != SA_OK) {
		err("Unable to get sensor thresholds");
		thres_data->hyster_done = 1;
		thres_data->thres_done = 1;
		thres_data->rvalue = rv;
		return;
	}

	rv = ipmi_sensor_get_hysteresis_support(sensor);

	if (rv != IPMI_HYSTERESIS_SUPPORT_READABLE &&
			rv != IPMI_HYSTERESIS_SUPPORT_SETTABLE) {
//		thres_data->thres_done = 1;
		thres_data->hyster_done = 1;
		thres_data->sensor_thres.PosThdHysteresis.IsSupported =
				SAHPI_FALSE;
		thres_data->sensor_thres.NegThdHysteresis.IsSupported =
				SAHPI_FALSE;
		return;
	} 
	rv = get_hysteresis(sensor, thres_data);
	if (rv != SA_OK) {
		err("failed to get hysteresis");
		thres_data->hyster_done = 1;
//		thres_data->thres_done = 1;
		thres_data->rvalue = SA_ERR_HPI_INTERNAL_ERROR;
		return;
	}

	return;
}