Esempio n. 1
0
static void
sensor_change(enum ipmi_update_e op,
	      ipmi_entity_t      *ent,
	      ipmi_sensor_t      *sensor,
	      void               *cb_data)
{
    int id, instance, rv;
    char name[50];

    id = ipmi_entity_get_entity_id(ent);
    instance = ipmi_entity_get_entity_instance(ent);
    ipmi_sensor_get_id(sensor, name, 50);
    if (op == IPMI_ADDED) {
         if (!strncmp(name, sname, 15)) {
             int val;

             val = ipmi_sensor_get_hysteresis_support(sensor);
             if (val == IPMI_HYSTERESIS_SUPPORT_SETTABLE) {
                 printf("setting %s 's hysteresis...\n", name);
                 rv = ipmi_sensor_set_hysteresis(sensor, 1, 1, 
                                                 set_data, &done);
                 if (rv)
                       printf("ipmi_sensor_set_hysteresis return :%d\n", rv);
             }else {
                 printf("sensor don't support hysteresis set capability\n");
             }
         }
    }

}
Esempio n. 2
0
static SaErrorT set_hysteresis(ipmi_sensor_t	                *sensor,
			  struct ohoi_sensor_thresholds	*thres_data)
{
	int			rv;	
	unsigned int		pos = 0, neg = 0;
	SaHpiSensorReadingT	pos_reading 
                = thres_data->sensor_thres.PosThdHysteresis;
	SaHpiSensorReadingT	neg_reading 
                = thres_data->sensor_thres.NegThdHysteresis;
	
        switch (pos_reading.Type) {
                case SAHPI_SENSOR_READING_TYPE_INT64:
                        pos = pos_reading.Value.SensorInt64;
                        break;
                case SAHPI_SENSOR_READING_TYPE_UINT64:
                        pos = pos_reading.Value.SensorUint64;
                        break;
                case SAHPI_SENSOR_READING_TYPE_FLOAT64:
                        pos = pos_reading.Value.SensorFloat64;
                        break;
                case SAHPI_SENSOR_READING_TYPE_BUFFER:
                        dbg("ipmi sensor doesn't support this type of reading");
                        return SA_ERR_HPI_INVALID_DATA;   
        }
	
        switch (neg_reading.Type) {
                case SAHPI_SENSOR_READING_TYPE_INT64:
                        neg = neg_reading.Value.SensorInt64;
                        break;
                case SAHPI_SENSOR_READING_TYPE_UINT64:
                        neg = neg_reading.Value.SensorUint64;
                        break;
                case SAHPI_SENSOR_READING_TYPE_FLOAT64:
                        neg = neg_reading.Value.SensorFloat64;
                        break;
                case SAHPI_SENSOR_READING_TYPE_BUFFER:
                        dbg("ipmi sensor doesn't support this type of reading");
                        return SA_ERR_HPI_INVALID_DATA;
        }


	rv = ipmi_sensor_set_hysteresis(sensor, pos, neg, hys_set_data, 
                                        thres_data);
	if (rv) {
		dbg("Unable to set sensor hysteresis: 0x%x\n", rv);
		return SA_ERR_HPI_INTERNAL_ERROR;
	}

        return SA_OK;
}
Esempio n. 3
0
static int set_hysteresis(ipmi_sensor_t	                *sensor,
			  struct ohoi_sensor_thresholds	*thres_data)
{
	int			rv;	
	double			tmp;
	unsigned int		pos, neg;
	SaHpiSensorReadingT	pos_reading 
                = thres_data->sensor_thres->PosThdHysteresis;
	SaHpiSensorReadingT	neg_reading 
                = thres_data->sensor_thres->NegThdHysteresis;	
	
	if (pos_reading.ValuesPresent & SAHPI_SRF_RAW)
		pos = pos_reading.Raw;
	else if (pos_reading.ValuesPresent & SAHPI_SRF_INTERPRETED) {
		if (pos_reading.Interpreted.Type !=
		    SAHPI_SENSOR_INTERPRETED_TYPE_FLOAT32) {
			tmp = pos_reading.Interpreted.Value.SensorFloat32;
			ipmi_sensor_convert_to_raw(sensor, ROUND_NORMAL, 
						   tmp, &pos);	
		}
		else {
			dbg("Invalid input thresholds");
			return -1;
		}
	}
	
	if (neg_reading.ValuesPresent & SAHPI_SRF_RAW) 
		neg = neg_reading.Raw;
	else if (neg_reading.ValuesPresent & SAHPI_SRF_INTERPRETED) {
		if (neg_reading.Interpreted.Type !=
		    SAHPI_SENSOR_INTERPRETED_TYPE_FLOAT32) {
			tmp = neg_reading.Interpreted.Value.SensorFloat32;
			ipmi_sensor_convert_to_raw(sensor, ROUND_NORMAL,
						   tmp, &neg);
		}
		else {
			dbg("Invalid input thresholds");
			return -1;
		}
	}
	
	rv = ipmi_sensor_set_hysteresis(sensor, pos, neg, set_data, 
                                        &thres_data->hyster_done);
	if (rv) {
		dbg("Unable to set sensor thresholds: 0x%x\n", rv);
		return -1;
	}

        return rv;
}
Esempio n. 4
0
static int set_hysteresis(ipmi_sensor_t	                *sensor,
			  struct ohoi_sensor_thresholds	*thres_data)
{
	int			rv;	
	unsigned int		pos = 0, neg = 0;
	SaHpiSensorReadingT	pos_reading 
                = thres_data->sensor_thres->PosThdHysteresis;
	SaHpiSensorReadingT	neg_reading 
                = thres_data->sensor_thres->NegThdHysteresis;	
	
        switch (pos_reading.Type) {
                case SAHPI_SENSOR_READING_TYPE_INT64:
                        pos = pos_reading.Value.SensorInt64;
                        break;
                case SAHPI_SENSOR_READING_TYPE_UINT64:
                        pos = pos_reading.Value.SensorUint64;
                        break;
                case SAHPI_SENSOR_READING_TYPE_FLOAT64:
                        pos = pos_reading.Value.SensorFloat64;
                        break;
                case SAHPI_SENSOR_READING_TYPE_BUFFER:
                        dbg("ipmi sensor doesn't support this type of reading");
                        return -1;   
        }
	
        switch (neg_reading.Type) {
                case SAHPI_SENSOR_READING_TYPE_INT64:
                        neg = neg_reading.Value.SensorInt64;
                        break;
                case SAHPI_SENSOR_READING_TYPE_UINT64:
                        neg = neg_reading.Value.SensorUint64;
                        break;
                case SAHPI_SENSOR_READING_TYPE_FLOAT64:
                        neg = neg_reading.Value.SensorFloat64;
                        break;
                case SAHPI_SENSOR_READING_TYPE_BUFFER:
                        dbg("ipmi sensor doesn't support this type of reading");
                        return -1;
        }

	rv = ipmi_sensor_set_hysteresis(sensor, pos, neg, set_data, 
                                        &thres_data->hyster_done);
	if (rv) {
		dbg("Unable to set sensor thresholds: 0x%x\n", rv);
		return -1;
	}

        return rv;
}
Esempio n. 5
0
static void
sensor_set_hysteresis(ipmi_sensor_t *sensor, void *cb_data)
{
    ipmi_cmd_info_t    *cmd_info = cb_data;
    ipmi_cmdlang_t     *cmdlang = ipmi_cmdinfo_get_cmdlang(cmd_info);
    int                rv;
    int                curr_arg = ipmi_cmdlang_get_curr_arg(cmd_info);
    int                argc = ipmi_cmdlang_get_argc(cmd_info);
    char               **argv = ipmi_cmdlang_get_argv(cmd_info);
    int                pos, neg;

    if ((argc - curr_arg) < 2) {
	/* Not enough parameters */
	cmdlang->errstr = "Not enough parameters";
	cmdlang->err = EINVAL;
	goto out_err;
    }

    ipmi_cmdlang_get_int(argv[curr_arg], &pos, cmd_info);
    if (cmdlang->err) {
	cmdlang->errstr = "Invalid positive hysteresis";
	goto out_err;
    }
    curr_arg++;

    ipmi_cmdlang_get_int(argv[curr_arg], &neg, cmd_info);
    if (cmdlang->err) {
	cmdlang->errstr = "Invalid negative hysteresis";
	goto out_err;
    }
    curr_arg++;

    ipmi_cmdlang_cmd_info_get(cmd_info);
    rv = ipmi_sensor_set_hysteresis(sensor, pos, neg,
				    sensor_set_hysteresis_done, cmd_info);
    if (rv) {
	ipmi_cmdlang_cmd_info_put(cmd_info);
	cmdlang->err = rv;
	cmdlang->errstr = "Error setting hysteresis";
	goto out_err;
    }

 out_err:
    ipmi_sensor_get_name(sensor, cmdlang->objstr,
			 cmdlang->objstr_len);
    cmdlang->location = "cmd_sensor.c(sensor_set_hysteresis)";
}