mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-25 17:27:01 +00:00
Merge fixes and new development from the original onlp-accton repository.
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
#define MAX_FAN_SPEED 18000
|
||||
#define MAX_PSU_FAN_SPEED 25500
|
||||
|
||||
#define PROJECT_NAME
|
||||
#define PROJECT_NAME
|
||||
#define LEN_FILE_NAME 80
|
||||
|
||||
#define FAN_RESERVED 0
|
||||
@@ -144,7 +144,7 @@ _onlp_fani_info_get_fan_direction(void)
|
||||
for (i = PSU1_ID; i <= PSU2_ID; i++) {
|
||||
psu_type_t psu_type;
|
||||
psu_type = get_psu_type(i, NULL, 0);
|
||||
|
||||
|
||||
if (psu_type == PSU_TYPE_UNKNOWN) {
|
||||
continue;
|
||||
}
|
||||
@@ -156,47 +156,47 @@ _onlp_fani_info_get_fan_direction(void)
|
||||
return ONLP_FAN_STATUS_B2F;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t* info)
|
||||
{
|
||||
int fd, len, nbytes = 10;
|
||||
char r_data[10] = {0};
|
||||
char fullpath[65] = {0};
|
||||
|
||||
|
||||
/* get fan fault status (turn on when any one fails)
|
||||
*/
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].status);
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].status);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
if (atoi(r_data) > 0) {
|
||||
info->status |= ONLP_FAN_STATUS_FAILED;
|
||||
}
|
||||
|
||||
/* get fan direction (both : the same)
|
||||
/* get fan direction (both : the same)
|
||||
*/
|
||||
info->status |= _onlp_fani_info_get_fan_direction();
|
||||
|
||||
/* get fan speed (take the min from two speeds)
|
||||
*/
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].speed);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].speed);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
info->rpm = atoi(r_data);
|
||||
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].r_speed);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_MAIN_BOARD, fan_path[local_id].r_speed);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
if (info->rpm > atoi(r_data)) {
|
||||
info->rpm = atoi(r_data);
|
||||
}
|
||||
|
||||
/* get speed percentage from rpm */
|
||||
info->percentage = (info->rpm * 100)/MAX_FAN_SPEED;
|
||||
info->percentage = (info->rpm * 100)/MAX_FAN_SPEED;
|
||||
|
||||
/* check present */
|
||||
/* check present */
|
||||
if (info->rpm > 0) {
|
||||
info->status |= ONLP_FAN_STATUS_PRESENT;
|
||||
info->status |= ONLP_FAN_STATUS_PRESENT;
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
@@ -209,21 +209,21 @@ _onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info)
|
||||
char r_data[10] = {0};
|
||||
char fullpath[80] = {0};
|
||||
|
||||
/* get fan direction
|
||||
/* get fan direction
|
||||
*/
|
||||
info->status |= _onlp_fani_info_get_fan_direction();
|
||||
|
||||
/* get fan fault status
|
||||
/* get fan fault status
|
||||
*/
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].status);
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].status);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
info->status |= (atoi(r_data) > 0) ? ONLP_FAN_STATUS_FAILED : 0;
|
||||
|
||||
|
||||
/* get fan speed
|
||||
*/
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].speed);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
info->rpm = atoi(r_data);
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].speed);
|
||||
OPEN_READ_FILE(fd,fullpath,r_data,nbytes,len);
|
||||
info->rpm = atoi(r_data);
|
||||
|
||||
/* get speed percentage from rpm */
|
||||
info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED;
|
||||
@@ -255,7 +255,7 @@ onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info)
|
||||
{
|
||||
case FAN_1_ON_PSU1:
|
||||
case FAN_1_ON_PSU2:
|
||||
rc = _onlp_fani_info_get_fan_on_psu(local_id, info);
|
||||
rc = _onlp_fani_info_get_fan_on_psu(local_id, info);
|
||||
break;
|
||||
case FAN_1_ON_MAIN_BOARD:
|
||||
case FAN_2_ON_MAIN_BOARD:
|
||||
@@ -263,13 +263,13 @@ onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info)
|
||||
case FAN_4_ON_MAIN_BOARD:
|
||||
case FAN_5_ON_MAIN_BOARD:
|
||||
case FAN_6_ON_MAIN_BOARD:
|
||||
rc =_onlp_fani_info_get_fan(local_id, info);
|
||||
rc =_onlp_fani_info_get_fan(local_id, info);
|
||||
break;
|
||||
default:
|
||||
rc = ONLP_STATUS_E_INVALID;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -303,20 +303,20 @@ onlp_fani_percentage_set(onlp_oid_t id, int p)
|
||||
char fullpath[70] = {0};
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
|
||||
/* reject p=0 (p=0, stop fan) */
|
||||
if (p == 0){
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
|
||||
/* get fullpath */
|
||||
switch (local_id)
|
||||
{
|
||||
case FAN_1_ON_PSU1:
|
||||
case FAN_1_ON_PSU2:
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].ctrl_speed);
|
||||
sprintf(fullpath, "%s%s", PREFIX_PATH_ON_PSU, fan_path[local_id].ctrl_speed);
|
||||
break;
|
||||
case FAN_1_ON_MAIN_BOARD:
|
||||
case FAN_2_ON_MAIN_BOARD:
|
||||
|
||||
@@ -165,6 +165,11 @@ static int onlp_to_driver_led_mode(enum onlp_led_id id, onlp_led_mode_t onlp_led
|
||||
int
|
||||
onlp_ledi_init(void)
|
||||
{
|
||||
/*
|
||||
* Diag LED Off
|
||||
*/
|
||||
onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_DIAG), ONLP_LED_MODE_OFF);
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ int deviceNodeWriteInt(char *filename, int value, int data_len)
|
||||
char buf[8] = {0};
|
||||
sprintf(buf, "%d", value);
|
||||
|
||||
return deviceNodeWrite(filename, buf, sizeof(buf)-1, data_len);
|
||||
return deviceNodeWrite(filename, buf, (int)strlen(buf), data_len);
|
||||
}
|
||||
|
||||
int deviceNodeReadBinary(char *filename, char *buffer, int buf_size, int data_len)
|
||||
|
||||
@@ -197,7 +197,7 @@ onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
|
||||
info->status |= ONLP_PSU_STATUS_UNPLUGGED;
|
||||
info->status &= ~ONLP_PSU_STATUS_FAILED;
|
||||
ret = ONLP_STATUS_OK;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
ret = ONLP_STATUS_E_UNSUPPORTED;
|
||||
break;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <onlplib/i2c.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define MAX_SFP_PATH 64
|
||||
@@ -164,12 +164,6 @@ onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
{
|
||||
@@ -191,6 +185,34 @@ onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
int bus = FRONT_PORT_TO_MUX_INDEX(port);
|
||||
return onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value)
|
||||
{
|
||||
int bus = FRONT_PORT_TO_MUX_INDEX(port);
|
||||
return onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr)
|
||||
{
|
||||
int bus = FRONT_PORT_TO_MUX_INDEX(port);
|
||||
return onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value)
|
||||
{
|
||||
int bus = FRONT_PORT_TO_MUX_INDEX(port);
|
||||
return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_denit(void)
|
||||
{
|
||||
|
||||
@@ -43,6 +43,15 @@
|
||||
#define NUM_OF_PSU_ON_MAIN_BROAD 2
|
||||
#define NUM_OF_LED_ON_MAIN_BROAD 5
|
||||
|
||||
#define PREFIX_PATH_ON_CPLD_DEV "/sys/bus/i2c/devices/"
|
||||
#define NUM_OF_CPLD 3
|
||||
static char arr_cplddev_name[NUM_OF_CPLD][10] =
|
||||
{
|
||||
"4-0060",
|
||||
"5-0062",
|
||||
"6-0064"
|
||||
};
|
||||
|
||||
const char*
|
||||
onlp_sysi_platform_get(void)
|
||||
{
|
||||
@@ -65,6 +74,27 @@ onlp_sysi_onie_data_get(uint8_t** data, int* size)
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
|
||||
{
|
||||
int i, v[NUM_OF_CPLD]={0};
|
||||
for (i=0; i < NUM_OF_CPLD; i++) {
|
||||
v[i] = 0;
|
||||
if(onlp_file_read_int(v+i, "%s%s/version", PREFIX_PATH_ON_CPLD_DEV, arr_cplddev_name[i]) < 0) {
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
}
|
||||
pi->cpld_versions = aim_fstrdup("%d.%d.%d", v[0], v[1], v[2]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
onlp_sysi_platform_info_free(onlp_platform_info_t* pi)
|
||||
{
|
||||
aim_free(pi->cpld_versions);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_sysi_oids_get(onlp_oid_t* table, int max)
|
||||
{
|
||||
|
||||
@@ -143,7 +143,6 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
DEBUG_PRINT("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id);
|
||||
|
||||
/* Set the onlp_oid_hdr_t and capabilities */
|
||||
*info = linfo[local_id];
|
||||
|
||||
Reference in New Issue
Block a user