mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-26 09:47:13 +00:00
Initial attempt to port the Inventec D5254 to ONLPv2. Untested since we do not have a system in our lab.
This commit is contained in:
@@ -1,2 +1 @@
|
||||
FILTER=src
|
||||
include $(ONL)/make/subdirs.mk
|
||||
include $(ONL)/packages/base/any/onlp/builds/platform/build.mk
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,44 @@
|
||||
#include <onlp/platformi/chassisi.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
static onlp_oid_t __oid_info[] = {
|
||||
ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_PHY),
|
||||
ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE0),
|
||||
ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE1),
|
||||
ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE2),
|
||||
ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE3),
|
||||
ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_MAIN_BROAD),
|
||||
ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_MAIN_BROAD),
|
||||
ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_3_ON_MAIN_BROAD),
|
||||
ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_4_ON_MAIN_BROAD),
|
||||
ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_5_ON_MAIN_BROAD),
|
||||
ONLP_FAN_ID_CREATE(ONLP_FAN_1),
|
||||
ONLP_FAN_ID_CREATE(ONLP_FAN_2),
|
||||
ONLP_FAN_ID_CREATE(ONLP_FAN_3),
|
||||
ONLP_FAN_ID_CREATE(ONLP_FAN_4),
|
||||
ONLP_FAN_ID_CREATE(ONLP_FAN_5),
|
||||
ONLP_PSU_ID_CREATE(ONLP_PSU_1),
|
||||
ONLP_PSU_ID_CREATE(ONLP_PSU_2),
|
||||
ONLP_LED_ID_CREATE(ONLP_LED_MGMT_GREEN),
|
||||
ONLP_LED_ID_CREATE(ONLP_LED_MGMT_RED),
|
||||
};
|
||||
|
||||
int
|
||||
onlp_chassisi_hdr_get(onlp_oid_id_t id, onlp_oid_hdr_t* hdr)
|
||||
{
|
||||
int i;
|
||||
onlp_oid_t* e = hdr->coids;
|
||||
|
||||
ONLP_OID_STATUS_FLAG_SET(hdr, PRESENT);
|
||||
ONLP_OID_STATUS_FLAG_SET(hdr, OPERATIONAL);
|
||||
|
||||
memcpy(hdr->coids, __oid_info, sizeof(__oid_info));
|
||||
|
||||
/** Add 54 SFP OIDs after the static table */
|
||||
onlp_oid_t* e = hdr->coids + AIM_ARRAYSIZE(__oid_info);
|
||||
|
||||
/* 54 SFPs */
|
||||
for(i = 1; i <= 54; i++) {
|
||||
*e++ = ONLP_SFP_ID_CREATE(i);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
@@ -29,16 +29,6 @@
|
||||
#include <unistd.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_FAN(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct fani_info_s {
|
||||
int slow_pwm;
|
||||
int normal_pwm;
|
||||
@@ -116,253 +106,181 @@ static fani_info_t __info_list[ONLP_FAN_COUNT] = {
|
||||
/* Static values */
|
||||
static onlp_fan_info_t __onlp_fan_info[ONLP_FAN_COUNT] = {
|
||||
{ }, /* Not used */
|
||||
{ {
|
||||
ONLP_FAN_ID_CREATE(ONLP_FAN_1), "Fan 1", 0,
|
||||
{
|
||||
{
|
||||
.hdr = {
|
||||
.id = ONLP_FAN_ID_CREATE(ONLP_FAN_1),
|
||||
.description = "Fan 1",
|
||||
.poid = ONLP_OID_CHASSIS,
|
||||
.coids = {
|
||||
ONLP_FAN_ID_CREATE(ONLP_FAN_1_WEAK),
|
||||
ONLP_LED_ID_CREATE(ONLP_LED_FAN1_GREEN),
|
||||
ONLP_LED_ID_CREATE(ONLP_LED_FAN1_RED)
|
||||
}
|
||||
},
|
||||
.status = ONLP_OID_STATUS_FLAG_PRESENT
|
||||
},
|
||||
ONLP_FAN_STATUS_PRESENT|ONLP_FAN_STATUS_F2B,
|
||||
ONLP_FAN_CAPS_F2B|ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE
|
||||
.dir = ONLP_FAN_DIR_F2B,
|
||||
.caps = ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE,
|
||||
},
|
||||
{ {
|
||||
ONLP_FAN_ID_CREATE(ONLP_FAN_2), "Fan 2", 0,
|
||||
{
|
||||
{
|
||||
.hdr = {
|
||||
.id = ONLP_FAN_ID_CREATE(ONLP_FAN_2),
|
||||
.description = "Fan 2",
|
||||
.poid = ONLP_OID_CHASSIS,
|
||||
.coids = {
|
||||
ONLP_FAN_ID_CREATE(ONLP_FAN_2_WEAK),
|
||||
ONLP_LED_ID_CREATE(ONLP_LED_FAN2_GREEN),
|
||||
ONLP_LED_ID_CREATE(ONLP_LED_FAN2_RED)
|
||||
}
|
||||
},
|
||||
.status = ONLP_OID_STATUS_FLAG_PRESENT,
|
||||
},
|
||||
ONLP_FAN_STATUS_PRESENT|ONLP_FAN_STATUS_F2B,
|
||||
ONLP_FAN_CAPS_F2B|ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE
|
||||
.dir = ONLP_FAN_DIR_F2B,
|
||||
.caps = ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE,
|
||||
},
|
||||
{ {
|
||||
ONLP_FAN_ID_CREATE(ONLP_FAN_3), "Fan 3", 0,
|
||||
{
|
||||
{
|
||||
.hdr = {
|
||||
.id = ONLP_FAN_ID_CREATE(ONLP_FAN_3),
|
||||
.description = "Fan 3",
|
||||
.poid = ONLP_OID_CHASSIS,
|
||||
.coids = {
|
||||
ONLP_FAN_ID_CREATE(ONLP_FAN_3_WEAK),
|
||||
ONLP_LED_ID_CREATE(ONLP_LED_FAN3_GREEN),
|
||||
ONLP_LED_ID_CREATE(ONLP_LED_FAN3_RED)
|
||||
}
|
||||
},
|
||||
.status = ONLP_OID_STATUS_FLAG_PRESENT,
|
||||
},
|
||||
ONLP_FAN_STATUS_PRESENT|ONLP_FAN_STATUS_F2B,
|
||||
ONLP_FAN_CAPS_F2B|ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE
|
||||
.dir = ONLP_FAN_DIR_F2B,
|
||||
.caps = ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE,
|
||||
},
|
||||
{ {
|
||||
ONLP_FAN_ID_CREATE(ONLP_FAN_4), "Fan 4", 0,
|
||||
{
|
||||
{
|
||||
.hdr = {
|
||||
.id = ONLP_FAN_ID_CREATE(ONLP_FAN_4),
|
||||
.description = "Fan 4",
|
||||
.poid = ONLP_OID_CHASSIS,
|
||||
.coids = {
|
||||
ONLP_FAN_ID_CREATE(ONLP_FAN_4_WEAK),
|
||||
ONLP_LED_ID_CREATE(ONLP_LED_FAN4_GREEN),
|
||||
ONLP_LED_ID_CREATE(ONLP_LED_FAN4_RED)
|
||||
}
|
||||
},
|
||||
.status = ONLP_OID_STATUS_FLAG_PRESENT,
|
||||
},
|
||||
ONLP_FAN_STATUS_PRESENT|ONLP_FAN_STATUS_F2B,
|
||||
ONLP_FAN_CAPS_F2B|ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE
|
||||
.dir = ONLP_FAN_DIR_F2B,
|
||||
.caps = ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE,
|
||||
},
|
||||
{ {
|
||||
ONLP_FAN_ID_CREATE(ONLP_FAN_5), "Fan 5", 0,
|
||||
{
|
||||
{
|
||||
.hdr = {
|
||||
.id = ONLP_FAN_ID_CREATE(ONLP_FAN_5),
|
||||
.description = "Fan 5",
|
||||
.poid = ONLP_OID_CHASSIS,
|
||||
.coids = {
|
||||
ONLP_FAN_ID_CREATE(ONLP_FAN_5_WEAK),
|
||||
ONLP_LED_ID_CREATE(ONLP_LED_FAN5_GREEN),
|
||||
ONLP_LED_ID_CREATE(ONLP_LED_FAN5_RED)
|
||||
}
|
||||
},
|
||||
.status = ONLP_OID_STATUS_FLAG_PRESENT,
|
||||
},
|
||||
ONLP_FAN_STATUS_PRESENT|ONLP_FAN_STATUS_F2B,
|
||||
ONLP_FAN_CAPS_F2B|ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE
|
||||
.dir = ONLP_FAN_DIR_F2B,
|
||||
.caps = ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE
|
||||
},
|
||||
{ { ONLP_FAN_ID_CREATE(ONLP_FAN_1_WEAK), "Fan 1 WEAK", ONLP_FAN_ID_CREATE(ONLP_FAN_1)},
|
||||
ONLP_FAN_STATUS_PRESENT|ONLP_FAN_STATUS_F2B,
|
||||
ONLP_FAN_CAPS_F2B|ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE
|
||||
{
|
||||
.hdr = {
|
||||
.id = ONLP_FAN_ID_CREATE(ONLP_FAN_1_WEAK),
|
||||
.description = "Fan 1 WEAK",
|
||||
.poid = ONLP_FAN_ID_CREATE(ONLP_FAN_1),
|
||||
.status = ONLP_OID_STATUS_FLAG_PRESENT,
|
||||
},
|
||||
.dir = ONLP_FAN_DIR_F2B,
|
||||
.caps = ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE,
|
||||
},
|
||||
|
||||
{ { ONLP_FAN_ID_CREATE(ONLP_FAN_2_WEAK), "Fan 2 WEAK", ONLP_FAN_ID_CREATE(ONLP_FAN_2)},
|
||||
ONLP_FAN_STATUS_PRESENT|ONLP_FAN_STATUS_F2B,
|
||||
ONLP_FAN_CAPS_F2B|ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE
|
||||
{
|
||||
.hdr = {
|
||||
.id = ONLP_FAN_ID_CREATE(ONLP_FAN_2_WEAK),
|
||||
.description = "Fan 2 WEAK",
|
||||
.poid = ONLP_FAN_ID_CREATE(ONLP_FAN_2),
|
||||
.status = ONLP_OID_STATUS_FLAG_PRESENT,
|
||||
},
|
||||
.dir = ONLP_FAN_DIR_F2B,
|
||||
.caps = ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE,
|
||||
},
|
||||
{ { ONLP_FAN_ID_CREATE(ONLP_FAN_3_WEAK), "Fan 3 WEAK", ONLP_FAN_ID_CREATE(ONLP_FAN_3)},
|
||||
ONLP_FAN_STATUS_PRESENT|ONLP_FAN_STATUS_F2B,
|
||||
ONLP_FAN_CAPS_F2B|ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE
|
||||
{
|
||||
.hdr = {
|
||||
.id = ONLP_FAN_ID_CREATE(ONLP_FAN_3_WEAK),
|
||||
.description = "Fan 3 WEAK",
|
||||
.poid = ONLP_FAN_ID_CREATE(ONLP_FAN_3),
|
||||
.status = ONLP_OID_STATUS_FLAG_PRESENT,
|
||||
},
|
||||
.dir = ONLP_FAN_DIR_F2B,
|
||||
.caps = ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE,
|
||||
},
|
||||
{ { ONLP_FAN_ID_CREATE(ONLP_FAN_4_WEAK), "Fan 4 WEAK", ONLP_FAN_ID_CREATE(ONLP_FAN_4)},
|
||||
ONLP_FAN_STATUS_PRESENT|ONLP_FAN_STATUS_F2B,
|
||||
ONLP_FAN_CAPS_F2B|ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE
|
||||
{
|
||||
.hdr = {
|
||||
.id = ONLP_FAN_ID_CREATE(ONLP_FAN_4_WEAK),
|
||||
.description = "Fan 4 WEAK",
|
||||
.poid = ONLP_FAN_ID_CREATE(ONLP_FAN_4),
|
||||
.status = ONLP_OID_STATUS_FLAG_PRESENT,
|
||||
},
|
||||
.dir = ONLP_FAN_DIR_F2B,
|
||||
.caps = ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE,
|
||||
},
|
||||
{ { ONLP_FAN_ID_CREATE(ONLP_FAN_5_WEAK), "Fan 5 WEAK", ONLP_FAN_ID_CREATE(ONLP_FAN_5)},
|
||||
ONLP_FAN_STATUS_PRESENT|ONLP_FAN_STATUS_F2B,
|
||||
ONLP_FAN_CAPS_F2B|ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE
|
||||
{
|
||||
.hdr = {
|
||||
.id = ONLP_FAN_ID_CREATE(ONLP_FAN_5_WEAK),
|
||||
.description = "Fan 5 WEAK",
|
||||
.poid = ONLP_FAN_ID_CREATE(ONLP_FAN_5),
|
||||
.status = ONLP_OID_STATUS_FLAG_PRESENT,
|
||||
},
|
||||
.dir = ONLP_FAN_DIR_F2B,
|
||||
.caps = ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE,
|
||||
},
|
||||
{ { ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_1), "PSU-1 Fan", ONLP_PSU_ID_CREATE(ONLP_PSU_1)},
|
||||
ONLP_FAN_STATUS_PRESENT|ONLP_FAN_STATUS_F2B,
|
||||
ONLP_FAN_CAPS_F2B|ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE
|
||||
{
|
||||
.hdr = {
|
||||
.id = ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_1),
|
||||
.description = "PSU-1 Fan",
|
||||
.poid = ONLP_PSU_ID_CREATE(ONLP_PSU_1),
|
||||
.status = ONLP_OID_STATUS_FLAG_PRESENT,
|
||||
},
|
||||
.dir = ONLP_FAN_DIR_F2B,
|
||||
.caps = ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE,
|
||||
},
|
||||
{
|
||||
.hdr = {
|
||||
.id = ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_2),
|
||||
.description = "PSU-2 Fan",
|
||||
.poid = ONLP_PSU_ID_CREATE(ONLP_PSU_2),
|
||||
.status = ONLP_OID_STATUS_FLAG_PRESENT,
|
||||
},
|
||||
.dir = ONLP_FAN_DIR_F2B,
|
||||
.caps = ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE,
|
||||
},
|
||||
{ { ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_2), "PSU-2 Fan", ONLP_PSU_ID_CREATE(ONLP_PSU_2)},
|
||||
ONLP_FAN_STATUS_PRESENT|ONLP_FAN_STATUS_F2B,
|
||||
ONLP_FAN_CAPS_F2B|ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* This function will be called prior to all of onlp_fani_* functions.
|
||||
*/
|
||||
int
|
||||
onlp_fani_init(void)
|
||||
onlp_fani_id_validate(onlp_oid_id_t id)
|
||||
{
|
||||
return ONLP_OID_ID_VALIDATE_RANGE(id, 1, ONLP_FAN_MAX-1);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_fani_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr)
|
||||
{
|
||||
/** No Failed state processing? */
|
||||
*hdr = __onlp_fan_info[id].hdr;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info)
|
||||
onlp_fani_info_get(onlp_oid_id_t id, onlp_fan_info_t* info)
|
||||
{
|
||||
int rv = ONLP_STATUS_OK;
|
||||
int local_id;
|
||||
int pwm;
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
if(local_id >= ONLP_FAN_MAX) {
|
||||
rv = ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
ONLP_TRY(onlp_fani_hdr_get(id, &info->hdr));
|
||||
|
||||
if( ONLP_STATUS_OK == rv) {
|
||||
*info = __onlp_fan_info[local_id];
|
||||
rv = onlp_file_read_int(&info->rpm, __info_list[local_id].input_file);
|
||||
}
|
||||
ONLP_TRY(onlp_file_read_int(&info->rpm, __info_list[id].input_file));
|
||||
ONLP_TRY(onlp_file_read_int(&pwm, __info_list[id].pwm_file));
|
||||
|
||||
if(ONLP_STATUS_OK == rv) {
|
||||
rv = onlp_file_read_int(&pwm, __info_list[local_id].pwm_file);
|
||||
}
|
||||
info->percentage = (pwm*100)/__info_list[id].max_pwm;
|
||||
snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA");
|
||||
snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA");
|
||||
|
||||
if( ONLP_STATUS_OK == rv) {
|
||||
if(0 == info->rpm) {
|
||||
info->mode = ONLP_FAN_MODE_OFF;
|
||||
} else if(pwm < __info_list[local_id].slow_pwm) {
|
||||
info->mode = ONLP_FAN_MODE_SLOW;
|
||||
} else if(pwm < __info_list[local_id].normal_pwm) {
|
||||
info->mode = ONLP_FAN_MODE_NORMAL;
|
||||
} else if(pwm < __info_list[local_id].max_pwm) {
|
||||
info->mode = ONLP_FAN_MODE_FAST;
|
||||
} else {
|
||||
info->mode = ONLP_FAN_MODE_MAX;
|
||||
}
|
||||
|
||||
info->percentage = (pwm*100)/__info_list[local_id].max_pwm;
|
||||
snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA");
|
||||
snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA");
|
||||
}
|
||||
return rv;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieve the fan's operational status.
|
||||
* @param id The fan OID.
|
||||
* @param rv [out] Receives the fan's operations status flags.
|
||||
* @notes Only operational state needs to be returned -
|
||||
* PRESENT/FAILED
|
||||
*/
|
||||
int onlp_fani_status_get(onlp_oid_t id, uint32_t* rv)
|
||||
{
|
||||
int result = ONLP_STATUS_OK;
|
||||
onlp_fan_info_t* info;
|
||||
int local_id;
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
if(local_id >= ONLP_FAN_MAX) {
|
||||
result = ONLP_STATUS_E_INVALID;
|
||||
} else {
|
||||
info = &__onlp_fan_info[local_id];
|
||||
*rv = info->status;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieve the fan's OID hdr.
|
||||
* @param id The fan OID.
|
||||
* @param rv [out] Receives the OID header.
|
||||
*/
|
||||
int onlp_fani_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr)
|
||||
{
|
||||
int result = ONLP_STATUS_OK;
|
||||
onlp_fan_info_t* info;
|
||||
int local_id;
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
if(local_id >= ONLP_FAN_MAX) {
|
||||
result = ONLP_STATUS_E_INVALID;
|
||||
} else {
|
||||
info = &__onlp_fan_info[local_id];
|
||||
*hdr = info->hdr;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function sets the speed of the given fan in RPM.
|
||||
*
|
||||
* This function will only be called if the fan supprots the RPM_SET
|
||||
* capability.
|
||||
*
|
||||
* It is optional if you have no fans at all with this feature.
|
||||
*/
|
||||
int
|
||||
onlp_fani_rpm_set(onlp_oid_t id, int rpm)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets the fan speed of the given OID as a percentage.
|
||||
*
|
||||
* This will only be called if the OID has the PERCENTAGE_SET
|
||||
* capability.
|
||||
*
|
||||
* It is optional if you have no fans at all with this feature.
|
||||
*/
|
||||
int
|
||||
onlp_fani_percentage_set(onlp_oid_t id, int p)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function sets the fan speed of the given OID as per
|
||||
* the predefined ONLP fan speed modes: off, slow, normal, fast, max.
|
||||
*
|
||||
* Interpretation of these modes is up to the platform.
|
||||
*
|
||||
*/
|
||||
int
|
||||
onlp_fani_mode_set(onlp_oid_t id, onlp_fan_mode_t mode)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets the fan direction of the given OID.
|
||||
*
|
||||
* This function is only relevant if the fan OID supports both direction
|
||||
* capabilities.
|
||||
*
|
||||
* This function is optional unless the functionality is available.
|
||||
*/
|
||||
int
|
||||
onlp_fani_dir_set(onlp_oid_t id, onlp_fan_dir_t dir)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic fan ioctl. Optional.
|
||||
*/
|
||||
int
|
||||
onlp_fani_ioctl(onlp_oid_t id, va_list vargs)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,21 +32,14 @@
|
||||
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_LED(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* LED related data
|
||||
*/
|
||||
|
||||
/* CAPS*/
|
||||
#define CPLD_LED_GREEN_CAPS ONLP_LED_CAPS_ON_OFF|ONLP_LED_CAPS_GREEN|ONLP_LED_CAPS_GREEN_BLINKING
|
||||
#define CPLD_LED_RED_CAPS ONLP_LED_CAPS_ON_OFF|ONLP_LED_CAPS_RED|ONLP_LED_CAPS_RED_BLINKING
|
||||
#define PSOC_LED_GREEN_CAPS ONLP_LED_CAPS_ON_OFF|ONLP_LED_CAPS_GREEN
|
||||
#define PSOC_LED_RED_CAPS ONLP_LED_CAPS_ON_OFF|ONLP_LED_CAPS_RED
|
||||
#define CPLD_LED_GREEN_CAPS ONLP_LED_CAPS_OFF|ONLP_LED_CAPS_GREEN|ONLP_LED_CAPS_GREEN_BLINKING
|
||||
#define CPLD_LED_RED_CAPS ONLP_LED_CAPS_OFF|ONLP_LED_CAPS_RED|ONLP_LED_CAPS_RED_BLINKING
|
||||
#define PSOC_LED_GREEN_CAPS ONLP_LED_CAPS_OFF|ONLP_LED_CAPS_GREEN
|
||||
#define PSOC_LED_RED_CAPS ONLP_LED_CAPS_OFF|ONLP_LED_CAPS_RED
|
||||
|
||||
|
||||
typedef enum platform_led_color_e {
|
||||
@@ -81,10 +74,10 @@ typedef struct ledi_info_s {
|
||||
/* function declarations*/
|
||||
static onlp_led_mode_t _cpld_onlp_led_mode_convert(platform_led_color_t color, cpld_led_mode_t mode);
|
||||
static int _onlp_cpld_led_mode_convert(onlp_led_mode_t onlp_led_mode, platform_led_color_t *pcolor, cpld_led_mode_t *pmode);
|
||||
static int _cpld_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info);
|
||||
static int _psoc_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info);
|
||||
static int _cpld_onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t onlp_mode);
|
||||
static int _psoc_onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t onlp_mode);
|
||||
static int _cpld_onlp_ledi_info_get(onlp_oid_id_t id, onlp_led_info_t* info);
|
||||
static int _psoc_onlp_ledi_info_get(onlp_oid_id_t id, onlp_led_info_t* info);
|
||||
static int _cpld_onlp_ledi_mode_set(onlp_oid_id_t id, onlp_led_mode_t onlp_mode);
|
||||
static int _psoc_onlp_ledi_mode_set(onlp_oid_id_t id, onlp_led_mode_t onlp_mode);
|
||||
|
||||
static ledi_info_t __info_list[ONLP_LED_COUNT] = {
|
||||
{},
|
||||
@@ -108,66 +101,18 @@ static ledi_info_t __info_list[ONLP_LED_COUNT] = {
|
||||
*/
|
||||
static onlp_led_info_t __onlp_led_info[ONLP_LED_COUNT] = {
|
||||
{ }, /* Not used */
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(ONLP_LED_MGMT_GREEN), "MGMT LED GREEN", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
CPLD_LED_GREEN_CAPS,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(ONLP_LED_MGMT_RED), "MGMT LED RED", 0 },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
CPLD_LED_RED_CAPS,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(ONLP_LED_FAN1_GREEN), "FAN LED 1 GREEN", ONLP_FAN_ID_CREATE(ONLP_FAN_1) },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
PSOC_LED_GREEN_CAPS,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(ONLP_LED_FAN1_RED), "FAN LED 1 RED", ONLP_FAN_ID_CREATE(ONLP_FAN_1) },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
PSOC_LED_RED_CAPS,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(ONLP_LED_FAN2_GREEN), "FAN LED 2 GREEN", ONLP_FAN_ID_CREATE(ONLP_FAN_2) },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
PSOC_LED_GREEN_CAPS,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(ONLP_LED_FAN2_RED), "FAN LED 2 RED", ONLP_FAN_ID_CREATE(ONLP_FAN_2) },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
PSOC_LED_RED_CAPS,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(ONLP_LED_FAN3_GREEN), "FAN LED 3 GREEN", ONLP_FAN_ID_CREATE(ONLP_FAN_3) },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
PSOC_LED_GREEN_CAPS,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(ONLP_LED_FAN3_RED), "FAN LED 3 RED", ONLP_FAN_ID_CREATE(ONLP_FAN_3) },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
PSOC_LED_RED_CAPS,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(ONLP_LED_FAN4_GREEN), "FAN LED 4 GREEN", ONLP_FAN_ID_CREATE(ONLP_FAN_4) },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
PSOC_LED_GREEN_CAPS,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(ONLP_LED_FAN4_RED), "FAN LED 4 RED", ONLP_FAN_ID_CREATE(ONLP_FAN_4) },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
PSOC_LED_RED_CAPS,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(ONLP_LED_FAN5_GREEN), "FAN LED 5 GREEN", ONLP_FAN_ID_CREATE(ONLP_FAN_5) },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
PSOC_LED_GREEN_CAPS,
|
||||
},
|
||||
{
|
||||
{ ONLP_LED_ID_CREATE(ONLP_LED_FAN5_RED), "FAN LED 5 RED", ONLP_FAN_ID_CREATE(ONLP_FAN_5) },
|
||||
ONLP_LED_STATUS_PRESENT,
|
||||
PSOC_LED_RED_CAPS,
|
||||
},
|
||||
ONLP_CHASSIS_LED_INFO_ENTRY_INIT(ONLP_LED_MGMT_GREEN, "MGMT LED GREEN", CPLD_LED_GREEN_CAPS),
|
||||
ONLP_CHASSIS_LED_INFO_ENTRY_INIT(ONLP_LED_MGMT_RED, "MGMT LED RED", CPLD_LED_RED_CAPS),
|
||||
ONLP_FAN_LED_INFO_ENTRY_INIT(ONLP_LED_FAN1_GREEN, "FAN LED 1 GREEN", ONLP_FAN_1, PSOC_LED_GREEN_CAPS),
|
||||
ONLP_FAN_LED_INFO_ENTRY_INIT(ONLP_LED_FAN1_RED, "FAN LED 1 RED", ONLP_FAN_1, PSOC_LED_RED_CAPS),
|
||||
ONLP_FAN_LED_INFO_ENTRY_INIT(ONLP_LED_FAN2_GREEN, "FAN LED 2 GREEN", ONLP_FAN_2, PSOC_LED_GREEN_CAPS),
|
||||
ONLP_FAN_LED_INFO_ENTRY_INIT(ONLP_LED_FAN2_RED, "FAN LED 2 RED", ONLP_FAN_2, PSOC_LED_RED_CAPS),
|
||||
ONLP_FAN_LED_INFO_ENTRY_INIT(ONLP_LED_FAN3_GREEN, "FAN LED 3 GREEN", ONLP_FAN_3, PSOC_LED_GREEN_CAPS),
|
||||
ONLP_FAN_LED_INFO_ENTRY_INIT(ONLP_LED_FAN3_RED, "FAN LED 3 RED", ONLP_FAN_3, PSOC_LED_RED_CAPS),
|
||||
ONLP_FAN_LED_INFO_ENTRY_INIT(ONLP_LED_FAN4_GREEN, "FAN LED 4 GREEN", ONLP_FAN_4, PSOC_LED_GREEN_CAPS),
|
||||
ONLP_FAN_LED_INFO_ENTRY_INIT(ONLP_LED_FAN4_RED, "FAN LED 4 RED", ONLP_FAN_4, PSOC_LED_RED_CAPS),
|
||||
ONLP_FAN_LED_INFO_ENTRY_INIT(ONLP_LED_FAN5_GREEN, "FAN LED 5 GREEN", ONLP_FAN_5, PSOC_LED_GREEN_CAPS),
|
||||
ONLP_FAN_LED_INFO_ENTRY_INIT(ONLP_LED_FAN5_RED, "FAN LED 5 RED", ONLP_FAN_5, PSOC_LED_RED_CAPS),
|
||||
};
|
||||
|
||||
|
||||
@@ -181,10 +126,10 @@ static onlp_led_mode_t _cpld_onlp_led_mode_convert(platform_led_color_t color, c
|
||||
case CPLD_LED_MODE_0_5_HZ:
|
||||
case CPLD_LED_MODE_1_HZ:
|
||||
case CPLD_LED_MODE_2_HZ:
|
||||
ret = ONLP_LED_MODE_BLINKING;
|
||||
ret = ONLP_LED_MODE_AUTO_BLINKING;
|
||||
break;
|
||||
case CPLD_LED_MODE_ON:
|
||||
ret = ONLP_LED_MODE_ON;
|
||||
ret = ONLP_LED_MODE_AUTO;
|
||||
break;
|
||||
case CPLD_LED_MODE_OFF:
|
||||
default:
|
||||
@@ -195,10 +140,10 @@ static onlp_led_mode_t _cpld_onlp_led_mode_convert(platform_led_color_t color, c
|
||||
/* Add shift to color */
|
||||
switch(color) {
|
||||
case PLATFORM_LED_COLOR_RED:
|
||||
ret += (ONLP_LED_MODE_RED - ONLP_LED_MODE_ON);
|
||||
ret += (ONLP_LED_MODE_RED - ONLP_LED_MODE_AUTO);
|
||||
break;
|
||||
case PLATFORM_LED_COLOR_GREEN:
|
||||
ret += (ONLP_LED_MODE_GREEN - ONLP_LED_MODE_ON);
|
||||
ret += (ONLP_LED_MODE_GREEN - ONLP_LED_MODE_AUTO);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -215,11 +160,11 @@ static int _onlp_cpld_led_mode_convert(onlp_led_mode_t onlp_led_mode, platform_l
|
||||
*pcolor = PLATFORM_LED_COLOR_ANY;
|
||||
*pmode = CPLD_LED_MODE_OFF;
|
||||
break;
|
||||
case ONLP_LED_MODE_ON:
|
||||
case ONLP_LED_MODE_AUTO:
|
||||
*pcolor = PLATFORM_LED_COLOR_ANY;
|
||||
*pmode = CPLD_LED_MODE_ON;
|
||||
break;
|
||||
case ONLP_LED_MODE_BLINKING:
|
||||
case ONLP_LED_MODE_AUTO_BLINKING:
|
||||
*pcolor = PLATFORM_LED_COLOR_ANY;
|
||||
*pmode = CPLD_LED_MODE_1_HZ;
|
||||
break;
|
||||
@@ -250,117 +195,91 @@ static int _onlp_cpld_led_mode_convert(onlp_led_mode_t onlp_led_mode, platform_l
|
||||
}
|
||||
|
||||
|
||||
static int _cpld_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
|
||||
static int _cpld_onlp_ledi_info_get(onlp_oid_id_t id, onlp_led_info_t* info)
|
||||
{
|
||||
int local_id;
|
||||
int rv = ONLP_STATUS_OK;
|
||||
platform_led_color_t color;
|
||||
cpld_led_mode_t mode;
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
|
||||
/* Set the onlp_oid_hdr_t and capabilities */
|
||||
*info = __onlp_led_info[local_id];
|
||||
*info = __onlp_led_info[id];
|
||||
|
||||
color = __info_list[local_id].color;
|
||||
color = __info_list[id].color;
|
||||
|
||||
rv = onlp_file_read_int((int*)&mode, __info_list[local_id].file);
|
||||
rv = onlp_file_read_int((int*)&mode, __info_list[id].file);
|
||||
|
||||
if( ONLP_STATUS_OK == rv ) {
|
||||
info->mode = _cpld_onlp_led_mode_convert(color, mode);
|
||||
|
||||
/* Set the on/off status */
|
||||
if (info->mode != ONLP_LED_MODE_OFF) {
|
||||
info->status |= ONLP_LED_STATUS_ON;
|
||||
} else {
|
||||
info->status &= (~ONLP_LED_STATUS_ON);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int _psoc_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
|
||||
static int _psoc_onlp_ledi_info_get(onlp_oid_id_t id, onlp_led_info_t* info)
|
||||
{
|
||||
int local_id;
|
||||
int rv = ONLP_STATUS_OK;
|
||||
int mode;
|
||||
platform_led_color_t color;
|
||||
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
|
||||
/* Set the onlp_oid_hdr_t and capabilities */
|
||||
*info = __onlp_led_info[local_id];
|
||||
color = __info_list[local_id].color;
|
||||
*info = __onlp_led_info[id];
|
||||
color = __info_list[id].color;
|
||||
|
||||
rv = onlp_file_read_int((int*)&mode, __info_list[local_id].file);
|
||||
rv = onlp_file_read_int((int*)&mode, __info_list[id].file);
|
||||
|
||||
if( ONLP_STATUS_OK == rv ) {
|
||||
|
||||
if(!mode) {
|
||||
info->mode = ONLP_LED_MODE_OFF;
|
||||
} else {
|
||||
info->mode = ONLP_LED_MODE_ON;
|
||||
info->mode = ONLP_LED_MODE_AUTO;
|
||||
}
|
||||
|
||||
if(info->mode != ONLP_LED_MODE_OFF) {
|
||||
switch(color) {
|
||||
case PLATFORM_LED_COLOR_RED:
|
||||
info->mode += (ONLP_LED_MODE_RED - ONLP_LED_MODE_ON);
|
||||
info->mode += (ONLP_LED_MODE_RED - ONLP_LED_MODE_AUTO);
|
||||
break;
|
||||
case PLATFORM_LED_COLOR_GREEN:
|
||||
info->mode += (ONLP_LED_MODE_GREEN - ONLP_LED_MODE_ON);
|
||||
info->mode += (ONLP_LED_MODE_GREEN - ONLP_LED_MODE_AUTO);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the on/off status */
|
||||
if (info->mode != ONLP_LED_MODE_OFF) {
|
||||
info->status |= ONLP_LED_STATUS_ON;
|
||||
} else {
|
||||
info->status &= (~ONLP_LED_STATUS_ON);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int _cpld_onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t onlp_mode)
|
||||
static int _cpld_onlp_ledi_mode_set(onlp_oid_id_t id, onlp_led_mode_t onlp_mode)
|
||||
{
|
||||
int local_id;
|
||||
int rv = ONLP_STATUS_OK;
|
||||
platform_led_color_t color;
|
||||
cpld_led_mode_t cpld_mode;
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
|
||||
|
||||
/*convert onlp_led_mode to platform mod*/
|
||||
rv = _onlp_cpld_led_mode_convert(onlp_mode, &color, &cpld_mode);
|
||||
|
||||
if( ONLP_STATUS_OK == rv) {
|
||||
if((color != __info_list[local_id].color)&&(color != PLATFORM_LED_COLOR_ANY)) {
|
||||
if((color != __info_list[id].color)&&(color != PLATFORM_LED_COLOR_ANY)) {
|
||||
rv = ONLP_STATUS_E_INVALID;
|
||||
} else {
|
||||
rv = onlp_file_write_int(cpld_mode, __info_list[local_id].file);
|
||||
rv = onlp_file_write_int(cpld_mode, __info_list[id].file);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int _psoc_onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t onlp_mode)
|
||||
static int _psoc_onlp_ledi_mode_set(onlp_oid_id_t id, onlp_led_mode_t onlp_mode)
|
||||
{
|
||||
int local_id;
|
||||
int rv = ONLP_STATUS_OK;
|
||||
platform_led_color_t color;
|
||||
int psoc_mode;
|
||||
int psoc_diag;
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
id = ONLP_OID_ID_GET(id);
|
||||
|
||||
rv = platform_psoc_diag_enable_read(&psoc_diag);
|
||||
|
||||
@@ -375,7 +294,7 @@ static int _psoc_onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t onlp_mode)
|
||||
psoc_mode = 0;
|
||||
color = PLATFORM_LED_COLOR_ANY;
|
||||
break;
|
||||
case ONLP_LED_MODE_ON:
|
||||
case ONLP_LED_MODE_AUTO:
|
||||
psoc_mode = 1;
|
||||
color = PLATFORM_LED_COLOR_ANY;
|
||||
break;
|
||||
@@ -393,37 +312,29 @@ static int _psoc_onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t onlp_mode)
|
||||
}
|
||||
|
||||
if( ONLP_STATUS_OK == rv) {
|
||||
if((psoc_mode)&&(color != __info_list[local_id].color)&&(color != PLATFORM_LED_COLOR_ANY)) {
|
||||
if((psoc_mode)&&(color != __info_list[id].color)&&(color != PLATFORM_LED_COLOR_ANY)) {
|
||||
rv = ONLP_STATUS_E_INVALID;
|
||||
} else {
|
||||
rv = onlp_file_write_int(psoc_mode, __info_list[local_id].file);
|
||||
rv = onlp_file_write_int(psoc_mode, __info_list[id].file);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function will be called prior to any other onlp_ledi_* functions.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_init(void)
|
||||
onlp_ledi_id_validate(onlp_oid_id_t id)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
return ONLP_OID_ID_VALIDATE_RANGE(id, 1, ONLP_LED_MAX-1);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
|
||||
onlp_ledi_info_get(onlp_oid_id_t id, onlp_led_info_t* info)
|
||||
{
|
||||
int rv = ONLP_STATUS_OK;
|
||||
VALIDATE(id);
|
||||
|
||||
if(ONLP_OID_ID_GET(id) >= ONLP_LED_MAX) {
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
switch(__info_list[ONLP_OID_ID_GET(id)].driver) {
|
||||
switch(__info_list[id].driver) {
|
||||
case LED_DRIVER_MODE_NONE:
|
||||
*info = __onlp_led_info[ONLP_OID_ID_GET(id)];
|
||||
*info = __onlp_led_info[id];
|
||||
break;
|
||||
case LED_DRIVER_MODE_CPLD:
|
||||
rv = _cpld_onlp_ledi_info_get(id, info);
|
||||
@@ -438,93 +349,12 @@ onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info)
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the LED operational status.
|
||||
* @param id The LED OID
|
||||
* @param rv [out] Receives the operational status.
|
||||
*/
|
||||
int onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv)
|
||||
{
|
||||
int result = ONLP_STATUS_OK;
|
||||
onlp_led_info_t* info;
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
if(ONLP_OID_ID_GET(id) >= ONLP_LED_MAX) {
|
||||
result = ONLP_STATUS_E_INVALID;
|
||||
} else {
|
||||
info = &__onlp_led_info[ONLP_OID_ID_GET(id)];
|
||||
*rv = info->status;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the LED header.
|
||||
* @param id The LED OID
|
||||
* @param rv [out] Receives the header.
|
||||
*/
|
||||
int onlp_ledi_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv)
|
||||
{
|
||||
int result = ONLP_STATUS_OK;
|
||||
onlp_led_info_t* info;
|
||||
|
||||
VALIDATE(id);
|
||||
|
||||
if(ONLP_OID_ID_GET(id) >= ONLP_LED_MAX) {
|
||||
result = ONLP_STATUS_E_INVALID;
|
||||
} else {
|
||||
info = &__onlp_led_info[ONLP_OID_ID_GET(id)];
|
||||
*rv = info->hdr;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Turn an LED on or off.
|
||||
*
|
||||
* This function will only be called if the LED OID supports the ONOFF
|
||||
* capability.
|
||||
*
|
||||
* What 'on' means in terms of colors or modes for multimode LEDs is
|
||||
* up to the platform to decide. This is intended as baseline toggle mechanism.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_set(onlp_oid_t id, int on_or_off)
|
||||
{
|
||||
onlp_led_mode_t mode;
|
||||
VALIDATE(id);
|
||||
|
||||
if(ONLP_OID_ID_GET(id) >= ONLP_LED_MAX) {
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
|
||||
if (__onlp_led_info[ONLP_OID_ID_GET(id)].caps & ONLP_LED_CAPS_ON_OFF) {
|
||||
mode = on_or_off?ONLP_LED_MODE_ON:ONLP_LED_MODE_OFF;
|
||||
return onlp_ledi_mode_set(id, mode);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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)
|
||||
onlp_ledi_mode_set(onlp_oid_id_t id, onlp_led_mode_t mode)
|
||||
{
|
||||
int rv = ONLP_STATUS_OK;
|
||||
VALIDATE(id);
|
||||
|
||||
if(ONLP_OID_ID_GET(id) >= ONLP_LED_MAX) {
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
switch(__info_list[ONLP_OID_ID_GET(id)].driver) {
|
||||
switch(__info_list[id].driver) {
|
||||
case LED_DRIVER_MODE_CPLD:
|
||||
rv = _cpld_onlp_ledi_mode_set(id, mode);
|
||||
break;
|
||||
@@ -537,13 +367,3 @@ onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode)
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generic LED ioctl interface.
|
||||
*/
|
||||
int
|
||||
onlp_ledi_ioctl(onlp_oid_t id, va_list vargs)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
#include <onlp/platformi/base.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
const char*
|
||||
onlp_platformi_get(void)
|
||||
@@ -16,11 +17,15 @@ onlp_platformi_sw_init(void)
|
||||
int
|
||||
onlp_platformi_manage_fans(void)
|
||||
{
|
||||
/*Ensure switch manager is working*/
|
||||
PLATFORM_PSOC_DIAG_LOCK;
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_platformi_manage_leds(void)
|
||||
{
|
||||
/*Ensure switch manager is working*/
|
||||
PLATFORM_PSOC_DIAG_LOCK;
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -29,16 +29,9 @@
|
||||
#include <onlp/platformi/psui.h>
|
||||
#include <onlplib/file.h>
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_PSU(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define PSUI_PLATFORM_PSU_MODEL "DPS-800AB-37D"
|
||||
|
||||
|
||||
typedef enum psoc_psu_state_e {
|
||||
PSOC_PSU_NORMAL = 0,
|
||||
PSOC_PSU_NA_1, //001
|
||||
@@ -97,155 +90,94 @@ static psui_info_t __info_list[ONLP_PSU_COUNT] = {
|
||||
static onlp_psu_info_t __onlp_psu_info[ONLP_PSU_COUNT] = {
|
||||
{ }, /* Not used */
|
||||
{
|
||||
{
|
||||
ONLP_PSU_ID_CREATE(ONLP_PSU_1), "PSU-1", 0,
|
||||
{
|
||||
.hdr = {
|
||||
.id = ONLP_PSU_ID_CREATE(ONLP_PSU_1),
|
||||
.description = "PSU-1",
|
||||
.poid = ONLP_OID_CHASSIS,
|
||||
.coids = {
|
||||
ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_PSU1),
|
||||
ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_PSU1),
|
||||
ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_1)
|
||||
}
|
||||
},
|
||||
.status = ONLP_OID_STATUS_FLAG_PRESENT,
|
||||
},
|
||||
"","",ONLP_PSU_STATUS_PRESENT,
|
||||
ONLP_PSU_CAPS_DC12|ONLP_PSU_CAPS_VIN|ONLP_PSU_CAPS_VOUT|ONLP_PSU_CAPS_IIN|ONLP_PSU_CAPS_IOUT|ONLP_PSU_CAPS_PIN|ONLP_PSU_CAPS_POUT
|
||||
.model = "",
|
||||
.serial = "",
|
||||
.caps = ONLP_PSU_CAPS_GET_VIN|ONLP_PSU_CAPS_GET_VOUT|ONLP_PSU_CAPS_GET_IIN|ONLP_PSU_CAPS_GET_IOUT|ONLP_PSU_CAPS_GET_PIN|ONLP_PSU_CAPS_GET_POUT,
|
||||
.type = ONLP_PSU_TYPE_DC12,
|
||||
},
|
||||
{
|
||||
{
|
||||
ONLP_PSU_ID_CREATE(ONLP_PSU_2), "PSU-2", 0,
|
||||
{
|
||||
.hdr = {
|
||||
.id = ONLP_PSU_ID_CREATE(ONLP_PSU_2),
|
||||
.description = "PSU-2",
|
||||
.coids = {
|
||||
ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_PSU2),
|
||||
ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_PSU2),
|
||||
ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_2)
|
||||
}
|
||||
},
|
||||
.status = ONLP_OID_STATUS_FLAG_PRESENT,
|
||||
},
|
||||
"","",ONLP_PSU_STATUS_PRESENT,
|
||||
ONLP_PSU_CAPS_DC12|ONLP_PSU_CAPS_VIN|ONLP_PSU_CAPS_VOUT|ONLP_PSU_CAPS_IIN|ONLP_PSU_CAPS_IOUT|ONLP_PSU_CAPS_PIN|ONLP_PSU_CAPS_POUT
|
||||
.model = "",
|
||||
.serial = "",
|
||||
.caps = ONLP_PSU_CAPS_GET_VIN|ONLP_PSU_CAPS_GET_VOUT|ONLP_PSU_CAPS_GET_IIN|ONLP_PSU_CAPS_GET_IOUT|ONLP_PSU_CAPS_GET_PIN|ONLP_PSU_CAPS_GET_POUT,
|
||||
.type = ONLP_PSU_TYPE_DC12,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
onlp_psui_init(void)
|
||||
onlp_psui_id_validate(onlp_oid_id_t id)
|
||||
{
|
||||
return ONLP_OID_ID_VALIDATE_RANGE(id, 1, ONLP_PSU_MAX-1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_psui_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr)
|
||||
{
|
||||
psoc_psu_state_t psoc_state;
|
||||
|
||||
*hdr = __onlp_psu_info[id].hdr;
|
||||
|
||||
ONLP_TRY(onlp_file_read_int((int*)&psoc_state, __info_list[id].state));
|
||||
|
||||
if( PSOC_PSU_UNPOWERED == psoc_state) {
|
||||
ONLP_OID_STATUS_FLAG_SET(hdr, PRESENT);
|
||||
ONLP_OID_STATUS_FLAG_SET(hdr, UNPLUGGED);
|
||||
} else if ( PSOC_PSU_NORMAL == psoc_state) {
|
||||
ONLP_OID_STATUS_FLAG_SET(hdr, PRESENT);
|
||||
} else if( PSOC_PSU_FAULT == psoc_state) {
|
||||
ONLP_OID_STATUS_FLAG_SET(hdr, PRESENT);
|
||||
ONLP_OID_STATUS_FLAG_SET(hdr, FAILED);
|
||||
} else {
|
||||
ONLP_OID_STATUS_FLAGS_CLR(hdr);
|
||||
}
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info)
|
||||
onlp_psui_info_get(onlp_oid_id_t id, onlp_psu_info_t* info)
|
||||
{
|
||||
int ret = ONLP_STATUS_OK;
|
||||
int len;
|
||||
int local_id = ONLP_OID_ID_GET(id);
|
||||
uint8_t temp[ONLP_CONFIG_INFO_STR_MAX] = {0};
|
||||
psoc_psu_state_t psoc_state;
|
||||
ONLP_TRY(onlp_psui_hdr_get(id, &info->hdr));
|
||||
|
||||
VALIDATE(id);
|
||||
/* model */
|
||||
ONLP_TRY(onlp_file_read_str_dst(info->model, sizeof(info->model), __info_list[id].vendor));
|
||||
|
||||
if(local_id >= ONLP_PSU_MAX) {
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
|
||||
*info = __onlp_psu_info[local_id]; /* Set the onlp_oid_hdr_t */
|
||||
|
||||
ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, __info_list[local_id].vendor);
|
||||
/*remove the '\n'*/
|
||||
temp[strlen((char*)temp)-1] = 0;
|
||||
snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "%s", temp);
|
||||
|
||||
|
||||
memset(temp, 0, ONLP_CONFIG_INFO_STR_MAX);
|
||||
ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len,__info_list[local_id].serial);
|
||||
/*remove the '\n'*/
|
||||
temp[strlen((char*)temp)-1] = 0;
|
||||
snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "%s", temp);
|
||||
|
||||
|
||||
ret = onlp_file_read_int((int*)&psoc_state, __info_list[local_id].state);
|
||||
|
||||
if( PSOC_PSU_UNPOWERED == psoc_state) {
|
||||
info->status = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_UNPLUGGED;
|
||||
} else if ( PSOC_PSU_NORMAL == psoc_state) {
|
||||
info->status = ONLP_PSU_STATUS_PRESENT;
|
||||
} else if( PSOC_PSU_FAULT == psoc_state) {
|
||||
info->status = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_FAILED;
|
||||
} else {
|
||||
info->status = 0;
|
||||
}
|
||||
/* serial */
|
||||
ONLP_TRY(onlp_file_read_str_dst(info->serial, sizeof(info->serial), __info_list[id].serial));
|
||||
|
||||
/*millivolts*/
|
||||
ret = onlp_file_read_int(&info->mvin, __info_list[local_id].vin);
|
||||
ret = onlp_file_read_int(&info->mvout, __info_list[local_id].vout);
|
||||
ONLP_TRY(onlp_file_read_int(&info->mvin, __info_list[id].vin));
|
||||
ONLP_TRY(onlp_file_read_int(&info->mvout, __info_list[id].vout));
|
||||
|
||||
/* milliamps */
|
||||
ret = onlp_file_read_int(&info->miin, __info_list[local_id].iin);
|
||||
ret = onlp_file_read_int(&info->miout, __info_list[local_id].iout);
|
||||
ONLP_TRY(onlp_file_read_int(&info->miin, __info_list[id].iin));
|
||||
ONLP_TRY(onlp_file_read_int(&info->miout, __info_list[id].iout));
|
||||
|
||||
/* milliwatts */
|
||||
ret = onlp_file_read_int(&info->mpin, __info_list[local_id].pin);
|
||||
ret = onlp_file_read_int(&info->mpout, __info_list[local_id].pout);
|
||||
ONLP_TRY(onlp_file_read_int(&info->mpin, __info_list[id].pin));
|
||||
ONLP_TRY(onlp_file_read_int(&info->mpout, __info_list[id].pout));
|
||||
|
||||
return ret;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the PSU's operational status.
|
||||
* @param id The PSU OID.
|
||||
* @param rv [out] Receives the operational status.
|
||||
*/
|
||||
int onlp_psui_status_get(onlp_oid_t id, uint32_t* rv)
|
||||
{
|
||||
int result = ONLP_STATUS_OK;
|
||||
psoc_psu_state_t psoc_state;
|
||||
int local_id;
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
if(local_id >= ONLP_PSU_MAX) {
|
||||
result = ONLP_STATUS_E_INVALID;
|
||||
} else {
|
||||
result = onlp_file_read_int((int*)&psoc_state, __info_list[local_id].state);
|
||||
|
||||
if( PSOC_PSU_UNPOWERED == psoc_state) {
|
||||
*rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_UNPLUGGED;
|
||||
} else if ( PSOC_PSU_NORMAL == psoc_state) {
|
||||
*rv = ONLP_PSU_STATUS_PRESENT;
|
||||
} else if( PSOC_PSU_FAULT == psoc_state) {
|
||||
*rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_FAILED;
|
||||
} else {
|
||||
*rv = 0;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the PSU's oid header.
|
||||
* @param id The PSU OID.
|
||||
* @param rv [out] Receives the header.
|
||||
*/
|
||||
int onlp_psui_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv)
|
||||
{
|
||||
int result = ONLP_STATUS_OK;
|
||||
onlp_psu_info_t* info;
|
||||
int local_id;
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
if(local_id >= ONLP_PSU_MAX) {
|
||||
result = ONLP_STATUS_E_INVALID;
|
||||
} else {
|
||||
info = &__onlp_psu_info[local_id];
|
||||
*rv = info->hdr;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
onlp_psui_ioctl(onlp_oid_t pid, va_list vargs)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,17 +41,12 @@
|
||||
#define NUM_OF_SFP_PORT 48
|
||||
#define NUM_OF_QSFP_PORT 6
|
||||
#define NUM_OF_ALL_PORT (NUM_OF_SFP_PORT+NUM_OF_QSFP_PORT)
|
||||
|
||||
/************************************************************
|
||||
*
|
||||
* SFPI Entry Points
|
||||
*
|
||||
***********************************************************/
|
||||
int
|
||||
onlp_sfpi_init(void)
|
||||
{
|
||||
/* Called at initialization time */
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_port_is_valid(int port){
|
||||
@@ -130,7 +125,7 @@ onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_is_present(int port)
|
||||
onlp_sfpi_is_present(onlp_oid_id_t port)
|
||||
{
|
||||
/*
|
||||
* Return 1 if present.
|
||||
@@ -180,7 +175,7 @@ onlp_sfpi_is_rx_los(int port)
|
||||
|
||||
int
|
||||
onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
{
|
||||
{
|
||||
AIM_BITMAP_CLR_ALL(dst);
|
||||
int port=MUX_START_INDEX;
|
||||
for(port=MUX_START_INDEX;port<=NUM_OF_ALL_PORT;port++){
|
||||
@@ -191,67 +186,44 @@ onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dom_read(int port, uint8_t data[256])
|
||||
onlp_sfpi_dev_read(onlp_oid_id_t port, int devaddr, int addr,
|
||||
uint8_t* dst, int len)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
int bus = onlp_sfpi_port2chan(port);
|
||||
/* Can this be block_read? */
|
||||
return onlp_i2c_read(bus, devaddr, addr, len, dst, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_post_insert(int port, sff_info_t* info)
|
||||
{
|
||||
return ONLP_STATUS_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_eeprom_read(int port, uint8_t data[256])
|
||||
{
|
||||
/*
|
||||
* Read the SFP eeprom into data[]
|
||||
*
|
||||
* Return MISSING if SFP is missing.
|
||||
* Return OK if eeprom is read
|
||||
*/
|
||||
memset(data, 0, 256);
|
||||
|
||||
int byte = -1;
|
||||
byte = onlp_i2c_read(onlp_sfpi_port2chan(port), 0x50, 0, 256, data, 0);
|
||||
if(byte < 0){
|
||||
AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port);
|
||||
return ONLP_STATUS_E_INTERNAL;
|
||||
}
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr)
|
||||
onlp_sfpi_dev_readb(onlp_oid_id_t port, int devaddr, int addr)
|
||||
{
|
||||
int bus = onlp_sfpi_port2chan(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)
|
||||
onlp_sfpi_dev_writeb(onlp_oid_id_t port, int devaddr, int addr, uint8_t value)
|
||||
{
|
||||
int bus = onlp_sfpi_port2chan(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)
|
||||
onlp_sfpi_dev_readw(onlp_oid_id_t port, int devaddr, int addr)
|
||||
{
|
||||
int bus = onlp_sfpi_port2chan(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)
|
||||
onlp_sfpi_dev_writew(onlp_oid_id_t port, int devaddr, int addr, uint16_t value)
|
||||
{
|
||||
int bus = onlp_sfpi_port2chan(port);
|
||||
return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE);
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv)
|
||||
onlp_sfpi_control_supported(onlp_oid_id_t port, onlp_sfp_control_t control, int* rv)
|
||||
{
|
||||
switch (control) {
|
||||
case ONLP_SFP_CONTROL_RESET_STATE:
|
||||
@@ -289,7 +261,7 @@ onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
|
||||
onlp_sfpi_control_set(onlp_oid_id_t port, onlp_sfp_control_t control, int value)
|
||||
{
|
||||
int ret_val = 0;
|
||||
int err = 0;
|
||||
@@ -329,11 +301,11 @@ onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value)
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
|
||||
onlp_sfpi_control_get(onlp_oid_id_t port, onlp_sfp_control_t control, int* value)
|
||||
{
|
||||
int ret_val = 0;
|
||||
int err = 0;
|
||||
|
||||
|
||||
switch (control) {
|
||||
case ONLP_SFP_CONTROL_RESET_STATE:
|
||||
err = onlp_sfpi_get_file_byte(port, "reset");
|
||||
@@ -386,15 +358,3 @@ onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value)
|
||||
}
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
int
|
||||
onlp_sfpi_denit(void)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
onlp_sfpi_debug(int port, aim_pvs_t* pvs)
|
||||
{
|
||||
aim_printf(pvs, "Debug data for port %d goes here.", port);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#if 0
|
||||
/************************************************************
|
||||
* <bsn.cl fy=2014 v=onl>
|
||||
*
|
||||
@@ -1171,3 +1172,4 @@ onlp_sysi_platform_manage_leds(void)
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -29,14 +29,6 @@
|
||||
#include <fcntl.h>
|
||||
#include "platform_lib.h"
|
||||
|
||||
#define VALIDATE(_id) \
|
||||
do { \
|
||||
if(!ONLP_OID_IS_THERMAL(_id)) { \
|
||||
return ONLP_STATUS_E_INVALID; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
typedef struct thermali_info_s {
|
||||
char file[ONLP_CONFIG_INFO_STR_MAX];
|
||||
} thermali_info_t;
|
||||
@@ -63,141 +55,38 @@ static thermali_info_t __info_list[ONLP_THERMAL_COUNT] = {
|
||||
/* Static values */
|
||||
static onlp_thermal_info_t __onlp_thermal_info[ONLP_THERMAL_COUNT] = {
|
||||
{ }, /* Not used */
|
||||
{ { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_PHY), "CPU Physical", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE0), "CPU Core0", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE1), "CPU Core1", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE2), "CPU Core2", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE3), "CPU Core3", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_MAIN_BROAD), "Thermal Sensor 1", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_MAIN_BROAD), "Thermal Sensor 2", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_3_ON_MAIN_BROAD), "Thermal Sensor 3", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_4_ON_MAIN_BROAD), "Thermal Sensor 4", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_5_ON_MAIN_BROAD), "Thermal Sensor 5", 0},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_PSU1), "PSU-1 Thermal Sensor 1", ONLP_PSU_ID_CREATE(ONLP_PSU_1)},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_PSU1), "PSU-1 Thermal Sensor 2", ONLP_PSU_ID_CREATE(ONLP_PSU_1)},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_PSU2), "PSU-2 Thermal Sensor 1", ONLP_PSU_ID_CREATE(ONLP_PSU_2)},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
},
|
||||
{ { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_PSU2), "PSU-2 Thermal Sensor 2", ONLP_PSU_ID_CREATE(ONLP_PSU_2)},
|
||||
ONLP_THERMAL_STATUS_PRESENT,
|
||||
ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS
|
||||
}
|
||||
ONLP_CHASSIS_THERMAL_INFO_ENTRY_INIT(ONLP_THERMAL_CPU_PHY, "CPU Physical"),
|
||||
ONLP_CHASSIS_THERMAL_INFO_ENTRY_INIT(ONLP_THERMAL_CPU_CORE0, "CPU Core0"),
|
||||
ONLP_CHASSIS_THERMAL_INFO_ENTRY_INIT(ONLP_THERMAL_CPU_CORE1, "CPU Core1"),
|
||||
ONLP_CHASSIS_THERMAL_INFO_ENTRY_INIT(ONLP_THERMAL_CPU_CORE2, "CPU Core2"),
|
||||
ONLP_CHASSIS_THERMAL_INFO_ENTRY_INIT(ONLP_THERMAL_CPU_CORE3, "CPU Core3"),
|
||||
ONLP_CHASSIS_THERMAL_INFO_ENTRY_INIT(ONLP_THERMAL_1_ON_MAIN_BROAD, "Thermal Sensor 1"),
|
||||
ONLP_CHASSIS_THERMAL_INFO_ENTRY_INIT(ONLP_THERMAL_2_ON_MAIN_BROAD, "Thermal Sensor 2"),
|
||||
ONLP_CHASSIS_THERMAL_INFO_ENTRY_INIT(ONLP_THERMAL_3_ON_MAIN_BROAD, "Thermal Sensor 3"),
|
||||
ONLP_CHASSIS_THERMAL_INFO_ENTRY_INIT(ONLP_THERMAL_4_ON_MAIN_BROAD, "Thermal Sensor 4"),
|
||||
ONLP_CHASSIS_THERMAL_INFO_ENTRY_INIT(ONLP_THERMAL_5_ON_MAIN_BROAD, "Thermal Sensor 5"),
|
||||
ONLP_PSU_THERMAL_INFO_ENTRY_INIT(ONLP_THERMAL_1_ON_PSU1, "PSU-1 Thermal Sensor 1", ONLP_PSU_1),
|
||||
ONLP_PSU_THERMAL_INFO_ENTRY_INIT(ONLP_THERMAL_2_ON_PSU1, "PSU-1 Thermal Sensor 2", ONLP_PSU_1),
|
||||
ONLP_PSU_THERMAL_INFO_ENTRY_INIT(ONLP_THERMAL_1_ON_PSU2, "PSU-2 Thermal Sensor 1", ONLP_PSU_2),
|
||||
ONLP_PSU_THERMAL_INFO_ENTRY_INIT(ONLP_THERMAL_2_ON_PSU2, "PSU-2 Thermal Sensor 2", ONLP_PSU_2),
|
||||
};
|
||||
|
||||
/*
|
||||
* This will be called to intiialize the thermali subsystem.
|
||||
*/
|
||||
int
|
||||
onlp_thermali_init(void)
|
||||
onlp_thermali_id_validate(onlp_oid_id_t id)
|
||||
{
|
||||
return ONLP_STATUS_OK;
|
||||
return ONLP_OID_ID_VALIDATE_RANGE(id, 1, ONLP_THERMAL_MAX-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve the information structure for the given thermal OID.
|
||||
*
|
||||
* If the OID is invalid, return ONLP_E_STATUS_INVALID.
|
||||
* If an unexpected error occurs, return ONLP_E_STATUS_INTERNAL.
|
||||
* Otherwise, return ONLP_STATUS_OK with the OID's information.
|
||||
*
|
||||
* Note -- it is expected that you fill out the information
|
||||
* structure even if the sensor described by the OID is not present.
|
||||
*/
|
||||
int
|
||||
onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info)
|
||||
onlp_thermali_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr)
|
||||
{
|
||||
int local_id;
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
if(local_id >= ONLP_THERMAL_MAX) {
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
|
||||
/* Set the onlp_oid_hdr_t and capabilities */
|
||||
*info = __onlp_thermal_info[local_id];
|
||||
return onlp_file_read_int(&info->mcelsius, __info_list[local_id].file);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Retrieve the thermal's operational status.
|
||||
* @param id The thermal oid.
|
||||
* @param rv [out] Receives the operational status.
|
||||
*/
|
||||
int onlp_thermali_status_get(onlp_oid_t id, uint32_t* rv)
|
||||
{
|
||||
int local_id;
|
||||
|
||||
onlp_thermal_info_t* info;
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
if(local_id >= ONLP_THERMAL_MAX) {
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
info = &__onlp_thermal_info[local_id];
|
||||
|
||||
*rv = info->status;
|
||||
|
||||
*hdr = __onlp_thermal_info[id].hdr;
|
||||
return ONLP_STATUS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieve the thermal's oid header.
|
||||
* @param id The thermal oid.
|
||||
* @param rv [out] Receives the header.
|
||||
*/
|
||||
int onlp_thermali_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv)
|
||||
int
|
||||
onlp_thermali_info_get(onlp_oid_id_t id, onlp_thermal_info_t* info)
|
||||
{
|
||||
int local_id;
|
||||
onlp_thermal_info_t* info;
|
||||
VALIDATE(id);
|
||||
|
||||
local_id = ONLP_OID_ID_GET(id);
|
||||
if(local_id >= ONLP_THERMAL_MAX) {
|
||||
return ONLP_STATUS_E_INVALID;
|
||||
}
|
||||
info = &__onlp_thermal_info[local_id];
|
||||
|
||||
*rv = info->hdr;
|
||||
|
||||
return ONLP_STATUS_OK;
|
||||
*info = __onlp_thermal_info[id];
|
||||
return onlp_file_read_int(&info->mcelsius, __info_list[id].file);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user