Exemplo n.º 1
0
int
onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
{
    int rv;

    if (port < 0 || port >= 48) {
        return ONLP_STATUS_E_UNSUPPORTED;
    }

    int addr = (port < 29) ? 61 : 62;
    int bus  = (addr == 61) ? 10 : 11;

    switch(control)
        {
        case ONLP_SFP_CONTROL_TX_DISABLE:
            {
                if (onlp_file_write_int(value, MODULE_TXDISABLE_FORMAT, bus, addr, (port+1)) < 0) {
                    AIM_LOG_ERROR("Unable to set tx_disable status to port(%d)\r\n", port);
                    rv = ONLP_STATUS_E_INTERNAL;
                }
                else {
                    rv = ONLP_STATUS_OK;
                }
                break;
            }

        default:
            rv = ONLP_STATUS_E_UNSUPPORTED;
            break;
        }

    return rv;
}
Exemplo n.º 2
0
int
sys_fan_rpm_percent_set(int perc)
{  
    int rc;
    rc = onlp_file_write_int(perc, SYS_FAN_PREFIX "pwm%d", FAN_CTRL_SET1);
    
    if (rc < 0) {
        return ONLP_STATUS_E_INTERNAL;
    }
    
    rc = onlp_file_write_int(perc, SYS_FAN_PREFIX "pwm%d", FAN_CTRL_SET2);
    if (rc < 0) {
        return ONLP_STATUS_E_INTERNAL;
    }
       
    return ONLP_STATUS_OK;
}
Exemplo n.º 3
0
int
onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value)
{
    int rv = ONLP_STATUS_OK;
    int data = 0;

    data = ((addr << 16) | (value & 0xffff)) & 0x00ffffff;
    rv = onlp_file_write_int(data, SYS_HWMON2_PREFIX "/port_%d_sfp_copper", (port+1));

    return rv;
}
Exemplo n.º 4
0
int pca953x_gpio_value_set(int gpio, int value) {
    int ret;

    pca953x_gpio_direction_set(gpio, GPIO_OUT);

    try_export_gpio(gpio);
    ret = onlp_file_write_int(value, "%s%d/value", GPIO_PREF, gpio);
    try_unexport_gpio(gpio);

    return ret;
}
Exemplo n.º 5
0
int
onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
{
    int rv;
    char* path = NULL;

    switch(control){
        case ONLP_SFP_CONTROL_RESET_STATE:
            {
                path = sfp_get_port_status_path(port, "reset");

                if (onlp_file_write_int(value, path) != 0) {
                    AIM_LOG_ERROR("Unable to set reset status to port(%d)\r\n", port);
                    rv = ONLP_STATUS_E_INTERNAL;
                }
                else {
                    rv = ONLP_STATUS_OK;
                }
                break;
            }

        case ONLP_SFP_CONTROL_LP_MODE:
            {
                path = sfp_get_port_status_path(port, "lpmode");

                if (onlp_file_write_int(value, path) != 0) {
                    AIM_LOG_ERROR("Unable to set lp_mode status to port(%d)\r\n", port);
                    rv = ONLP_STATUS_E_INTERNAL;
                }
                else {
                    rv = ONLP_STATUS_OK;
                }
                break;
            }

        default:
            rv = ONLP_STATUS_E_UNSUPPORTED;
    }

    return rv;
}
Exemplo n.º 6
0
static int try_unexport_gpio(int gpio) {
    char filename[PATH_MAX];

    memset(filename, 0, sizeof(filename));
    sprintf(filename, "%s%d/value", GPIO_PREF, gpio);

    if(file_exists(filename)) {
        onlp_file_write_int(gpio, GPIO_UNEXPORT);
    }

    return ONLP_STATUS_OK;
}
Exemplo n.º 7
0
/*
 * This function puts the LED into the given mode. It is a more functional
 * interface for multimode LEDs.
 *
 * Only modes reported in the LED's capabilities will be attempted.
 */
int
onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)
{
    int  lid;	
    VALIDATE(id);

    lid = ONLP_OID_ID_GET(id);
    if (onlp_file_write_int(onlp_to_driver_led_mode(lid , mode), LED_FORMAT, leds[lid]) < 0) {
        return ONLP_STATUS_E_INTERNAL;
    }

    return ONLP_STATUS_OK;
}
Exemplo n.º 8
0
int
onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
{
    int rv = ONLP_STATUS_OK;
    int supported = 0;

    if ((onlp_sfpi_control_supported(port, control, &supported) == ONLP_STATUS_OK) && (supported == 0))
        return ONLP_STATUS_E_UNSUPPORTED;

    switch (control)
    {
        case ONLP_SFP_CONTROL_TX_DISABLE:
            rv = onlp_file_write_int(value, SYS_HWMON2_PREFIX "/port_%d_tx_disable", (port+1));
            break;

        default:
            rv = ONLP_STATUS_E_UNSUPPORTED;
            break;
    }
    return rv;
}
Exemplo n.º 9
0
int psu_ym2651y_pmbus_info_set(int id, char *node, int value)
{
    char path[PSU_NODE_MAX_PATH_LEN] = {0};

	switch (id) {
	case PSU1_ID:
		sprintf(path, "%s%s", PSU1_AC_PMBUS_PREFIX, node);
		break;
	case PSU2_ID:
		sprintf(path, "%s%s", PSU2_AC_PMBUS_PREFIX, node);
		break;
	default:
		return ONLP_STATUS_E_UNSUPPORTED;
	};

    if (onlp_file_write_int(value, path) < 0) {
        AIM_LOG_ERROR("Unable to write data to file (%s)\r\n", path);
        return ONLP_STATUS_E_INTERNAL;
    }

    return ONLP_STATUS_OK;
}