From c98074f15f036dd4d19faacf2ed3a3ff718f1241 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Sun, 13 Jan 2019 19:39:01 +0000 Subject: [PATCH] Initial attempt to port the Inventec D5254 to ONLPv2. Untested since we do not have a system in our lab. --- .../x86-64/d5254/onlp/builds/Makefile | 3 +- .../module/src/attributei.c | 1052 ++++++++++++++++- .../module/src/chassisi.c | 37 +- .../x86_64_inventec_d5254/module/src/fani.c | 344 ++---- .../x86_64_inventec_d5254/module/src/ledi.c | 284 +---- .../module/src/platformi.c | 5 + .../x86_64_inventec_d5254/module/src/psui.c | 188 +-- .../x86_64_inventec_d5254/module/src/sfpi.c | 72 +- .../x86_64_inventec_d5254/module/src/sysi.c | 2 + .../module/src/thermali.c | 155 +-- 10 files changed, 1373 insertions(+), 769 deletions(-) diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/d5254/onlp/builds/Makefile index e7437cb2..2ba2635f 100644 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/Makefile +++ b/packages/platforms/inventec/x86-64/d5254/onlp/builds/Makefile @@ -1,2 +1 @@ -FILTER=src -include $(ONL)/make/subdirs.mk +include $(ONL)/packages/base/any/onlp/builds/platform/build.mk diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/attributei.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/attributei.c index 72637b66..ffbcd9c1 100644 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/attributei.c +++ b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/attributei.c @@ -1,7 +1,1052 @@ +#include +#include +#include + #include #include #include +#include +#include +#include + +#include "x86_64_inventec_d5254_int.h" +#include "x86_64_inventec_d5254_log.h" + +#include "platform_lib.h" + +#define SYSI_ONIE_TYPE_SUPPORT_NUM 17 +#define SYSI_PLATFORM_INFO_TYPE_STR_MAX 10 +#define SYSI_PLATFORM_INFO_NUM 2 + +/** + * The TLV Types. + */ +#define TLV_CODE_PRODUCT_NAME 0x21 +#define TLV_CODE_PART_NUMBER 0x22 +#define TLV_CODE_SERIAL_NUMBER 0x23 +#define TLV_CODE_MAC_BASE 0x24 +#define TLV_CODE_MANUF_DATE 0x25 +#define TLV_CODE_DEVICE_VERSION 0x26 +#define TLV_CODE_LABEL_REVISION 0x27 +#define TLV_CODE_PLATFORM_NAME 0x28 +#define TLV_CODE_ONIE_VERSION 0x29 +#define TLV_CODE_MAC_SIZE 0x2A +#define TLV_CODE_MANUF_NAME 0x2B +#define TLV_CODE_MANUF_COUNTRY 0x2C +#define TLV_CODE_VENDOR_NAME 0x2D +#define TLV_CODE_DIAG_VERSION 0x2E +#define TLV_CODE_SERVICE_TAG 0x2F +#define TLV_CODE_VENDOR_EXT 0xFD +#define TLV_CODE_CRC_32 0xFE + + +typedef struct sysi_onie_vpd_s { + uint8_t type; + char file[ONLP_CONFIG_INFO_STR_MAX]; +} sysi_onie_vpd_t; + +typedef struct sysi_platform_info_s { + char type[SYSI_PLATFORM_INFO_TYPE_STR_MAX]; + char file[ONLP_CONFIG_INFO_STR_MAX]; + int (*parsing_func_ptr)(char* file_str, char* version); +} sysi_platform_info_t; + +static int _sysi_cpld_version_parsing(char* file_str, char* version); +static int _sysi_psoc_version_parsing(char* file_str, char* version); +static int _sysi_onie_product_name_get(char** product_name); +static int _sysi_onie_part_number_get(char** part_number); +static int _sysi_onie_serial_number_get(char** serial_number); +static int _sysi_onie_mac_base_get(uint8_t mac_base[6]); +static int _sysi_onie_manuf_date_get(char** manuf_date); +static int _sysi_onie_device_version_get(uint8_t* device_version); +static int _sysi_onie_label_revision_get(char** label_revision); +static int _sysi_onie_platform_name_get(char** platform_name); +static int _sysi_onie_onie_version_get(char** onie_version); +static int _sysi_onie_mac_size_get(uint16_t* mac_size); +static int _sysi_onie_manuf_name_get(char** manuf_name); +static int _sysi_onie_manuf_country_get(char** manuf_country); +static int _sysi_onie_vendor_name_get(char** vendor_name); +static int _sysi_onie_diag_version_get(char** diag_version); +static int _sysi_onie_service_tag_get(char** service_tag); +static int _sysi_onie_vendor_ext_get(list_head_t *vendor_ext); +static int _sysi_onie_crc_32_get(uint32_t* crc_32); + +static int _sysi_onie_info_total_len_get(onlp_onie_info_t *onie, uint16_t *total_len); + +static sysi_onie_vpd_t __tlv_vpd_info[SYSI_ONIE_TYPE_SUPPORT_NUM] = { + { + TLV_CODE_PRODUCT_NAME, + "/sys/class/eeprom/vpd/product_name" + }, + { + TLV_CODE_PART_NUMBER, + "/sys/class/eeprom/vpd/pn" + }, + { + TLV_CODE_SERIAL_NUMBER, + "/sys/class/eeprom/vpd/sn" + }, + { + TLV_CODE_MAC_BASE, + "/sys/class/eeprom/vpd/base_mac_addr" + }, + { + TLV_CODE_MANUF_DATE, + "/sys/class/eeprom/vpd/man_date" + }, + { + TLV_CODE_DEVICE_VERSION, + "/sys/class/eeprom/vpd/dev_ver" + }, + { + TLV_CODE_LABEL_REVISION, + "/sys/class/eeprom/vpd/label_rev" + }, + { + TLV_CODE_PLATFORM_NAME, + "/sys/class/eeprom/vpd/plat_name" + }, + { + TLV_CODE_ONIE_VERSION, + "/sys/class/eeprom/vpd/ldr_ver" + }, + { + TLV_CODE_MAC_SIZE, + "/sys/class/eeprom/vpd/mac_addr" + }, + { + TLV_CODE_MANUF_NAME, + "/sys/class/eeprom/vpd/manufacturer" + }, + { + TLV_CODE_MANUF_COUNTRY, + "/sys/class/eeprom/vpd/country_code" + }, + { + TLV_CODE_VENDOR_NAME, + "/sys/class/eeprom/vpd/vendor_name" + }, + { + TLV_CODE_DIAG_VERSION, + "/sys/class/eeprom/vpd/diag_ver" + }, + { + TLV_CODE_SERVICE_TAG, + "/sys/class/eeprom/vpd/service_tag" + }, + { + TLV_CODE_VENDOR_EXT, + "/sys/class/eeprom/vpd/vendor_ext" + }, + { + TLV_CODE_CRC_32, + "/sys/class/eeprom/vpd/crc32" + } +}; + + +static sysi_platform_info_t __platform_info[SYSI_PLATFORM_INFO_NUM] = { + {"cpld", "/sys/class/hwmon/hwmon2/device/info",_sysi_cpld_version_parsing}, + {"psoc", "/sys/class/hwmon/hwmon1/device/version",_sysi_psoc_version_parsing} +}; + +static int _sysi_cpld_version_parsing(char* file_str, char* version) +{ + int rv = ONLP_STATUS_OK; + int len; + char buf[ONLP_CONFIG_INFO_STR_MAX*4]; + char *temp; + + rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX*4, &len, file_str); + + temp = strstr(buf, "The CPLD version is "); + if(temp) { + temp += strlen("The CPLD version is "); + snprintf(version,ONLP_CONFIG_INFO_STR_MAX, temp); + /*remove '\n'*/ + version[strlen(version)-1] = 0; + } else { + rv = ONLP_STATUS_E_MISSING; + } + return rv; +} + +static int _sysi_psoc_version_parsing(char* file_str, char* version) +{ + int rv = ONLP_STATUS_OK; + int len; + char buf[ONLP_CONFIG_INFO_STR_MAX]; + char *temp; + + rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, file_str); + temp = strstr(buf, "ver: "); + if(temp) { + temp += strlen("ver: "); + snprintf(version,ONLP_CONFIG_INFO_STR_MAX, temp); + /*remove '\n'*/ + version[strlen(version)-1] = 0; + } else { + rv = ONLP_STATUS_E_MISSING; + } + return rv; +} + +static int _sysi_onie_product_name_get(char** product_name) +{ + int rv = ONLP_STATUS_OK; + int i; + int len; + char* path; + char buf[ONLP_CONFIG_INFO_STR_MAX]; + + for(i=0; iproduct_name)!= 0) { + len += 2; + len += strlen(onie->product_name); + } + /*part_number*/ + if(strlen(onie->part_number)!= 0) { + len += 2; + len += strlen(onie->part_number); + } + /*serial_number*/ + if(strlen(onie->serial_number)!= 0) { + len += 2; + len += strlen(onie->serial_number); + } + + /*mac*/ + len += 2; + len += 6; + + /*manufacture_date*/ + if(strlen(onie->manufacture_date)!= 0) { + len += 2; + len += 19; + } + + /*device_version*/ + len += 2; + len += 1; + + /*label_revision*/ + if(strlen(onie->label_revision)!= 0) { + len += 2; + len += strlen(onie->label_revision); + } + + /*platform_name*/ + if(strlen(onie->platform_name)!= 0) { + len += 2; + len += strlen(onie->platform_name); + } + + /*onie_version*/ + if(strlen(onie->onie_version)!= 0) { + len += 2; + len += strlen(onie->onie_version); + } + + /*mac_range*/ + len += 2; + len += 2; + + /*manufacturer*/ + if(strlen(onie->manufacturer)!= 0) { + len += 2; + len += strlen(onie->manufacturer); + } + + /*country_code*/ + if(strlen(onie->country_code)!= 0) { + len += 2; + len += 2; + } + + /*vendor*/ + if(strlen(onie->vendor)!= 0) { + len += 2; + len += strlen(onie->vendor); + } + + /*diag_version*/ + if(strlen(onie->diag_version)!= 0) { + len += 2; + len += strlen(onie->diag_version); + } + + /*service_tag*/ + if(strlen(onie->service_tag)!= 0) { + len += 2; + len += strlen(onie->service_tag); + } + + /*crc*/ + len += 2; + len += 4; + + /*vx_list*/ + /*TODO*/ + + *total_len = len; + return ONLP_STATUS_OK; +} + + + +const char* +onlp_sysi_platform_get(void) +{ + return "x86-64-inventec-d5254-r0"; +} + + +/* + * This function is called to return the physical base address + * of the ONIE boot rom. + * + * The ONLP framework will mmap() and parse the ONIE TLV structure + * from the given data. + * + * If you platform does not support a mappable address for the ONIE + * eeprom then you should not provide this function at all. + * + * For the purposes of this example we will provide it but + * return UNSUPPORTED (which is all the default implementation does). + * + */ +int +onlp_sysi_onie_data_phys_addr_get(void** pa) +{ + return ONLP_STATUS_E_UNSUPPORTED; +} + + +/* + * If you cannot provide a base address you must provide the ONLP + * framework the raw ONIE data through whatever means necessary. + * + * This function will be called as a backup in the event that + * onlp_sysi_onie_data_phys_addr_get() fails. + */ +int +onlp_sysi_onie_data_get(uint8_t** data, int* size) +{ +#if 0 + int rv; + int i; + + /* + * This represents the example ONIE data. + */ + static uint8_t onie_data[] = { + 'T', 'l', 'v','I','n','f','o', 0, + 0x1, 0x0, 0x0, + 0x21, 0x8, 'O', 'N', 'L', 'P', 'I', 'E', 0, 0, + 0x22, 0x3, 'O', 'N', 'L', + 0xFE, 0x4, 0x4b, 0x1b, 0x1d, 0xde, + }; + + + memcpy(*data, onie_data, ONLPLIB_CONFIG_I2C_BLOCK_SIZE); + return 0; +#endif + return ONLP_STATUS_E_UNSUPPORTED; +} + +static int +__onlp_sysi_onie_info_get (onlp_onie_info_t *onie) +{ + int rv = ONLP_STATUS_OK; + uint16_t total_len; + + if(ONLP_STATUS_OK == rv) { + rv = _sysi_onie_product_name_get(&onie->product_name); + } + + if(ONLP_STATUS_OK == rv) { + rv = _sysi_onie_part_number_get(&onie->part_number); + } + if(ONLP_STATUS_OK == rv) { + rv = _sysi_onie_serial_number_get(&onie->serial_number); + } + if(ONLP_STATUS_OK == rv) { + rv = _sysi_onie_mac_base_get(onie->mac); + } + if(ONLP_STATUS_OK == rv) { + rv = _sysi_onie_manuf_date_get(&onie->manufacture_date); + } + if(ONLP_STATUS_OK == rv) { + rv = _sysi_onie_device_version_get(&onie->device_version); + } + if(ONLP_STATUS_OK == rv) { + rv = _sysi_onie_label_revision_get(&onie->label_revision); + } + if(ONLP_STATUS_OK == rv) { + rv = _sysi_onie_platform_name_get(&onie->platform_name); + } + if(ONLP_STATUS_OK == rv) { + rv = _sysi_onie_onie_version_get(&onie->onie_version); + } + if(ONLP_STATUS_OK == rv) { + rv = _sysi_onie_mac_size_get(&onie->mac_range); + } + if(ONLP_STATUS_OK == rv) { + rv = _sysi_onie_manuf_name_get(&onie->manufacturer); + } + if(ONLP_STATUS_OK == rv) { + rv = _sysi_onie_manuf_country_get(&onie->country_code); + } + if(ONLP_STATUS_OK == rv) { + rv = _sysi_onie_vendor_name_get(&onie->vendor); + } + if(ONLP_STATUS_OK == rv) { + rv = _sysi_onie_diag_version_get(&onie->diag_version); + } + if(ONLP_STATUS_OK == rv) { + rv = _sysi_onie_service_tag_get(&onie->service_tag); + } + if(ONLP_STATUS_OK == rv) { + rv = _sysi_onie_vendor_ext_get(&onie->vx_list); + } + if(ONLP_STATUS_OK == rv) { + rv = _sysi_onie_crc_32_get(&onie->crc); + } + + _sysi_onie_info_total_len_get(onie, &total_len); + + onie->_hdr_id_string = aim_fstrdup("TlvInfo"); + onie->_hdr_version = 0x1; + onie->_hdr_length = total_len; + return rv; +} + + +static int +__asset_versions(char** cpld, char** other) +{ + int i; + int rv = ONLP_STATUS_OK; + char cpld_str[ONLP_CONFIG_INFO_STR_MAX]= {0}; + char other_str[ONLP_CONFIG_INFO_STR_MAX]= {0}; + char version[ONLP_CONFIG_INFO_STR_MAX]; + + for(i=0 ; i 0) { + *cpld = aim_fstrdup("%s",cpld_str); + } + + /*other version*/ + if(strlen(other_str) > 0) { + *other = aim_fstrdup("%s",other_str); + } + return rv; +} + int onlp_attributei_onie_info_get(onlp_oid_t oid, onlp_onie_info_t* rp) { @@ -13,8 +1058,7 @@ onlp_attributei_onie_info_get(onlp_oid_t oid, onlp_onie_info_t* rp) return ONLP_STATUS_OK; } - //return onlp_onie_decode_file(rp, IDPROM_PATH); - return ONLP_STATUS_E_UNSUPPORTED; + return __onlp_sysi_onie_info_get(rp); } int @@ -29,6 +1073,8 @@ onlp_attributei_asset_info_get(onlp_oid_t oid, onlp_asset_info_t* rp) } rp->oid = oid; - rp->firmware_revision = aim_strdup("fixme"); + + __asset_versions(&rp->firmware_revision, &rp->additional); + return ONLP_STATUS_OK; } diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/chassisi.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/chassisi.c index 98e89d58..c6bd8bcd 100644 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/chassisi.c +++ b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/chassisi.c @@ -1,11 +1,44 @@ #include +#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; } diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/fani.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/fani.c index e2b1c221..fa58684e 100644 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/fani.c +++ b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/fani.c @@ -29,16 +29,6 @@ #include #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; -} - diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/ledi.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/ledi.c index 4781ca37..d30f5acb 100644 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/ledi.c +++ b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/ledi.c @@ -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; -} - diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/platformi.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/platformi.c index 0bcc868e..a9ba90e1 100644 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/platformi.c +++ b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/platformi.c @@ -1,5 +1,6 @@ #include +#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; } diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/psui.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/psui.c index b97c87ee..6c47775d 100644 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/psui.c +++ b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/psui.c @@ -29,16 +29,9 @@ #include #include -#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; -} - diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/sfpi.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/sfpi.c index 696d384f..ba1dcb9d 100644 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/sfpi.c +++ b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/sfpi.c @@ -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); -} diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/sysi.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/sysi.c index f1544719..8ec5187d 100644 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/sysi.c +++ b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/sysi.c @@ -1,3 +1,4 @@ +#if 0 /************************************************************ * * @@ -1171,3 +1172,4 @@ onlp_sysi_platform_manage_leds(void) return ONLP_STATUS_OK; } +#endif diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/thermali.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/thermali.c index bcbfda1f..b7d0aa5d 100644 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/thermali.c +++ b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/thermali.c @@ -29,14 +29,6 @@ #include #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); }