diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/modules/builds/dni_agc7648sv1_psu.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/modules/builds/dni_agc7648sv1_psu.c index 4ba6e2c8..1257252f 100644 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/modules/builds/dni_agc7648sv1_psu.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/modules/builds/dni_agc7648sv1_psu.c @@ -59,8 +59,8 @@ struct dps_800ab_16_d_data { u8 fan_fault; u16 fan_duty_cycle[2]; u16 fan_speed[2]; - u8 mfr_model[14]; - u8 mfr_serial[14]; + u8 mfr_model[16]; + u8 mfr_serial[16]; }; static int two_complement_to_int(u16 data, u8 valid_bit, int mask); diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/fani.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/fani.c index 27ca6d28..c344c7aa 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/fani.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/fani.c @@ -96,11 +96,6 @@ onlp_fan_info_t linfo[] = { static int dni_fani_info_get_fan(int local_id, onlp_fan_info_t* info, char *dev_name) { int rv = ONLP_STATUS_OK; -#ifdef I2C - int rpm = 0; - int fantray_present = -1; - char fullpath[100] = {0}; -#endif #ifdef BMC uint8_t bit_data = 0x00; UINT4 u4Data = 0; @@ -149,8 +144,11 @@ static int dni_fani_info_get_fan(int local_id, onlp_fan_info_t* info, char *dev_ info->status |= ONLP_FAN_STATUS_FAILED; break; } -#endif -#ifdef I2C +#elif defined I2C + int rpm = 0; + int fantray_present = -1; + char fullpath[100] = {0}; + sprintf(fullpath, "%s%s", PREFIX_PATH, fan_path[local_id].speed); rpm = dni_i2c_lock_read_attribute(NULL, fullpath); info->rpm = rpm; @@ -203,11 +201,6 @@ static int dni_fani_info_get_fan(int local_id, onlp_fan_info_t* info, char *dev_ static int dni_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info, char *dev_name) { int rv = ONLP_STATUS_OK; -#ifdef I2C - int psu_present = 0; - int r_data = 0; - char fullpath[100] = {0}; -#endif #ifdef BMC UINT4 multiplier = 1; UINT4 u4Data = 0; @@ -249,8 +242,11 @@ static int dni_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t* info, cha } break; } -#endif -#ifdef I2C +#elif defined I2C + int psu_present = 0; + int r_data = 0; + char fullpath[100] = {0}; + switch(local_id) { case FAN_1_ON_PSU1: psu_present = dni_i2c_lock_read_attribute(NULL, PSU1_PRESENT_PATH); diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/ledi.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/ledi.c index 2c7498c9..9d5e4c92 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/ledi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/ledi.c @@ -208,8 +208,7 @@ int onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) info->mode = ONLP_LED_MODE_OFF; break; } -#endif -#ifdef I2C +#elif defined I2C switch(local_id) { case LED_FRONT_FAN: diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/platform_lib.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/platform_lib.c index 10212f23..8cf8980f 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/platform_lib.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/platform_lib.c @@ -42,12 +42,12 @@ static onlp_shlock_t* dni_lock = NULL; -#define DNI_BUS_LOCK() \ +#define DNI_LOCK() \ do{ \ onlp_shlock_take(dni_lock); \ }while(0) -#define DNI_BUS_UNLOCK() \ +#define DNI_UNLOCK() \ do{ \ onlp_shlock_give(dni_lock); \ }while(0) @@ -64,6 +64,7 @@ void lockinit() } } +#ifdef BMC int dni_ipmi_data_time_check(long last_time, long new_time, int time_threshold) { int ipmi_data_update = 0; @@ -210,7 +211,7 @@ int dni_bmc_sensor_read(char *device_name, UINT4 *num, UINT4 multiplier, int sen if(ipmi_data_update == 1) { - DNI_BUS_LOCK(); + DNI_LOCK(); if(dni_ipmi_data_time_check(file_last_time, bmc_check.time, time_threshold)) { sprintf(ipmi_cmd, "ipmitool sdr > /tmp/bmc_info"); @@ -234,7 +235,7 @@ int dni_bmc_sensor_read(char *device_name, UINT4 *num, UINT4 multiplier, int sen } gettimeofday(&new_tv,NULL); bmc_check.time = new_tv.tv_sec; - DNI_BUS_UNLOCK(); + DNI_UNLOCK(); } for(dev_num = 0; dev_num < DEV_NUM; dev_num++) @@ -305,11 +306,11 @@ int dni_bmc_data_get(int bus, int addr, int reg, int *r_data) if(ipmi_data_update == 1) { - DNI_BUS_LOCK(); + DNI_LOCK(); swpld_table[swpld_num].time = new_tv.tv_sec; sprintf(cmd, "ipmitool raw 0x38 0x2 %d 0x%x 0x00 255 > /tmp/%s_data", bus, addr, swpld_table[swpld_num].name); system(cmd); - DNI_BUS_UNLOCK(); + DNI_UNLOCK(); } sprintf(data_path, "/tmp/%s_data",swpld_table[swpld_num].name); @@ -332,7 +333,7 @@ int dni_bmc_data_set(int bus, int addr, int reg, uint8_t w_data) char cmd[50] = {0}; FILE *fptr = NULL; - DNI_BUS_LOCK(); + DNI_LOCK(); sprintf(cmd, "ipmitool raw 0x38 0x3 %d 0x%x 0x%x %d > /dev/null", bus, addr, reg, w_data); fptr = popen(cmd, "w"); if(fptr != NULL) @@ -340,7 +341,7 @@ int dni_bmc_data_set(int bus, int addr, int reg, uint8_t w_data) else rv = ONLP_STATUS_E_INVALID; pclose(fptr); - DNI_BUS_UNLOCK(); + DNI_UNLOCK(); return rv; } @@ -362,7 +363,7 @@ int dni_bmc_fanpresent_info_get(uint8_t *fan_present_bit) if(ipmi_data_update == 1) { - DNI_BUS_LOCK(); + DNI_LOCK(); fan.time = new_tv.tv_sec; sprintf(fanpresent_cmd, "ipmitool raw 0x38 0x0e"); fptr = popen(fanpresent_cmd, "r"); @@ -379,7 +380,7 @@ int dni_bmc_fanpresent_info_get(uint8_t *fan_present_bit) else rv = ONLP_STATUS_E_INVALID; pclose(fptr); - DNI_BUS_UNLOCK(); + DNI_UNLOCK(); } *fan_present_bit = fan.data; @@ -448,7 +449,7 @@ int dni_bmc_psueeprom_info_get(char * r_data, char *device_name, int number) if(ipmi_data_update == 1) { - DNI_BUS_LOCK(); + DNI_LOCK(); if(dni_ipmi_data_time_check(file_last_time, psu_eeprom_check.time, PSU_EEPROM_TIME_THRESHOLD)) { for(psu_num = 1; psu_num < 3; psu_num++) @@ -478,7 +479,7 @@ int dni_bmc_psueeprom_info_get(char * r_data, char *device_name, int number) } } psu_eeprom_check.time = new_tv.tv_sec; - DNI_BUS_UNLOCK(); + DNI_UNLOCK(); } for(table_num = 0; table_num < 2 ; table_num++) { @@ -497,7 +498,7 @@ int dni_bmc_psueeprom_info_get(char * r_data, char *device_name, int number) END: return rv; } - +#endif int hex_to_int(char hex_input) { int first = hex_input / 16 - 3; @@ -543,26 +544,26 @@ int dni_i2c_lock_read(mux_info_t * mux_info, dev_info_t * dev_info) { int r_data = 0; - DNI_BUS_LOCK(); + DNI_LOCK(); if(dev_info->size == 1) r_data = onlp_i2c_readb(dev_info->bus, dev_info->addr, dev_info->offset, dev_info->flags); else r_data = onlp_i2c_readw(dev_info->bus, dev_info->addr, dev_info->offset, dev_info->flags); - DNI_BUS_UNLOCK(); + DNI_UNLOCK(); return r_data; } int dni_i2c_lock_write(mux_info_t * mux_info, dev_info_t * dev_info) { - DNI_BUS_LOCK(); + DNI_LOCK(); /* Write size */ if(dev_info->size == 1) onlp_i2c_write(dev_info->bus, dev_info->addr, dev_info->offset, 1, &dev_info->data_8, dev_info->flags); else onlp_i2c_writew(dev_info->bus, dev_info->addr, dev_info->offset, dev_info->data_16, dev_info->flags); - DNI_BUS_UNLOCK(); + DNI_UNLOCK(); return 0; } @@ -571,14 +572,14 @@ int dni_i2c_lock_read_attribute(mux_info_t * mux_info, char * fullpath) int fd, nbytes = 10, rv = -1; char r_data[10] = {0}; - DNI_BUS_LOCK(); + DNI_LOCK(); if ((fd = open(fullpath, O_RDONLY)) >= 0) { if ((read(fd, r_data, nbytes)) > 0) rv = atoi(r_data); } close(fd); - DNI_BUS_UNLOCK(); + DNI_UNLOCK(); return rv; } @@ -586,7 +587,7 @@ int dni_i2c_lock_write_attribute(mux_info_t * mux_info, char * data,char * fullp { int fd, rv = -1; - DNI_BUS_LOCK(); + DNI_LOCK(); /* Create output file descriptor */ if ((fd = open(fullpath, O_WRONLY, 0644)) >= 0) { @@ -597,7 +598,7 @@ int dni_i2c_lock_write_attribute(mux_info_t * mux_info, char * data,char * fullp } } close(fd); - DNI_BUS_UNLOCK(); + DNI_UNLOCK(); return rv; } @@ -613,7 +614,7 @@ int dni_lock_cpld_read_attribute(char *cpld_path, int addr) sprintf(cpld_data_path, "%s/swpld1_reg_value", cpld_path); sprintf(cpld_addr_path, "%s/swpld1_reg_addr", cpld_path); sprintf(address, "0x%02x", addr); - DNI_BUS_LOCK(); + DNI_LOCK(); /* Create output file descriptor */ if ((fd = open(cpld_addr_path, O_WRONLY, 0644)) >= 0) { @@ -632,7 +633,7 @@ int dni_lock_cpld_read_attribute(char *cpld_path, int addr) } } close(fd); - DNI_BUS_UNLOCK(); + DNI_UNLOCK(); return rv; } @@ -648,7 +649,7 @@ int dni_lock_cpld_write_attribute(char *cpld_path, int addr, int data) sprintf(cpld_data_path, "%s/swpld1_reg_value", cpld_path); sprintf(cpld_addr_path, "%s/swpld1_reg_addr", cpld_path); sprintf(address, "0x%02x", addr); - DNI_BUS_LOCK(); + DNI_LOCK(); /* Create output file descriptor */ if ((fd = open(cpld_addr_path, O_WRONLY, 0644)) >= 0) { @@ -668,7 +669,7 @@ int dni_lock_cpld_write_attribute(char *cpld_path, int addr, int data) } } close(fd); - DNI_BUS_UNLOCK(); + DNI_UNLOCK(); return rv; } @@ -692,8 +693,7 @@ int dni_fan_present(int id) } else rv = ONLP_STATUS_E_INVALID; -#endif -#ifdef I2C +#elif defined I2C int fantray_present = -1; switch(id) { case LED_REAR_FAN_TRAY_1: @@ -748,7 +748,7 @@ int dni_i2c_read_attribute_binary(char *filename, char *buffer, int buf_size, in { int fd, rv = 0; int len; - DNI_BUS_LOCK(); + DNI_LOCK(); if ((buffer == NULL) || (buf_size < 0)) { rv = -1; @@ -777,7 +777,7 @@ int dni_i2c_read_attribute_binary(char *filename, char *buffer, int buf_size, in } ERROR: - DNI_BUS_UNLOCK(); + DNI_UNLOCK(); return rv; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/platform_lib.h b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/platform_lib.h index 92f4c5b7..afe83ef0 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/platform_lib.h +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/platform_lib.h @@ -31,6 +31,7 @@ #include #define BMC +//#define I2C typedef unsigned int UINT4; diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/psui.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/psui.c index 0f04093a..a3fe7bc7 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/psui.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/psui.c @@ -57,7 +57,8 @@ static int dni_psu_pmbus_info_get(int id, char *node, int *value) *value = 0; - switch (id) { + switch(id) + { case PSU1_ID: sprintf(node_path, "%s%s", PSU1_AC_PMBUS_PREFIX, node); break; @@ -84,6 +85,13 @@ static int dni_psu_info_get(onlp_oid_t id, onlp_psu_info_t* info) { int ret = ONLP_STATUS_OK; int local_id; + + local_id = ONLP_OID_ID_GET(info->hdr.id); + + /* Set the associated oid_table + * Set PSU's fan and thermal to child OID */ + info->hdr.coids[0] = ONLP_FAN_ID_CREATE(local_id + CHASSIS_FAN_COUNT); + info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(local_id + CHASSIS_THERMAL_COUNT); #ifdef BMC int i = 0; char device_name[10] = {0}; @@ -93,20 +101,8 @@ static int dni_psu_info_get(onlp_oid_t id, onlp_psu_info_t* info) char name1[20] = {0}; char *module_name = name; char *module_name1 = name1; -#endif -#ifdef I2C - int val = 0; - char val_char[16] = {'\0'}; - char node_path[PSU_NODE_MAX_PATH_LEN] = {'\0'}; -#endif - local_id = ONLP_OID_ID_GET(info->hdr.id); - /* Set the associated oid_table - * Set PSU's fan and thermal to child OID */ - info->hdr.coids[0] = ONLP_FAN_ID_CREATE(local_id + CHASSIS_FAN_COUNT); - info->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(local_id + CHASSIS_THERMAL_COUNT); -#ifdef BMC /* get psu model name */ if(dni_bmc_psueeprom_info_get(name, "Product Name", local_id) == ONLP_STATUS_OK) { @@ -189,17 +185,34 @@ static int dni_psu_info_get(onlp_oid_t id, onlp_psu_info_t* info) } else info->caps |= ONLP_PSU_STATUS_UNPLUGGED; -#endif -#ifdef I2C + +#elif defined I2C + int val = 0; + char val_char[15] = {'\0'}; + char node_path[PSU_NODE_MAX_PATH_LEN] = {'\0'}; + char psu_path[PSU_NODE_MAX_PATH_LEN] = {'\0'}; + int index = ONLP_OID_ID_GET(info->hdr.id); + switch(index) + { + case PSU1_ID: + sprintf(psu_path, "%s", PSU1_AC_PMBUS_PREFIX); + break; + case PSU2_ID: + sprintf(psu_path, "%s", PSU2_AC_PMBUS_PREFIX); + break; + default: + break; + } + /* Read PSU product name from attribute */ - sprintf(node_path, "%s%s", PSU1_AC_PMBUS_PREFIX, "psu_mfr_model"); + sprintf(node_path, "%s%s", psu_path, "psu_mfr_model"); dni_i2c_read_attribute_string(node_path, val_char, sizeof(val_char), 0); strcpy(info->model, val_char); /* Read PSU serial number from attribute */ - sprintf(node_path, "%s%s", PSU1_AC_PMBUS_PREFIX, "psu_mfr_serial"); + sprintf(node_path, "%s%s", psu_path, "psu_mfr_serial"); dni_i2c_read_attribute_string(node_path, val_char, sizeof(val_char), 0); strcpy(info->serial, val_char); @@ -238,7 +251,8 @@ static int dni_psu_info_get(onlp_oid_t id, onlp_psu_info_t* info) { info->mpout = val; info->caps |= ONLP_PSU_CAPS_POUT; - } + } + #endif return ret; } @@ -247,15 +261,6 @@ int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) { int ret = ONLP_STATUS_OK; int index = ONLP_OID_ID_GET(id); -#ifdef BMC - char device_name[10] = {0}; - UINT4 u4Data = 0; - UINT4 multiplier = 1000; -#endif -#ifdef I2C - int psu_present = -1; - int val = 0; -#endif VALIDATE(id); @@ -263,6 +268,10 @@ int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) memset(info, 0, sizeof(onlp_psu_info_t)); *info = pinfo[index]; #ifdef BMC + char device_name[10] = {0}; + UINT4 u4Data = 0; + UINT4 multiplier = 1000; + /* Check PSU have voltage input or not */ sprintf(device_name, "PSU%d_Vin", index); if(dni_bmc_sensor_read(device_name, &u4Data, multiplier, PSU_SENSOR) == ONLP_STATUS_OK) @@ -276,9 +285,12 @@ int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) info->status = ONLP_PSU_STATUS_PRESENT; info->caps |= ONLP_PSU_CAPS_VIN; } -#endif -#ifdef I2C - switch (index) { +#elif defined I2C + int psu_present = -1; + int val = 0; + + switch(index) + { case PSU1_ID: psu_present = dni_i2c_lock_read_attribute(NULL, PSU1_PRESENT_PATH); break; @@ -293,22 +305,23 @@ int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) dni_psu_pmbus_info_get(index, "psu_v_in", &val); /* Check PSU is PRESENT or not */ - if(psu_present == 0) - info->status |= ONLP_PSU_STATUS_PRESENT; - else if(val == 0 && psu_present == 1) + if(val == 0 && psu_present == 1) { /* PSU is not PRESENT */ /* Able to read PSU VIN(psu_power_not_good) */ info->status |= ONLP_PSU_STATUS_FAILED; return ret; } - else + else if(val == 0 && psu_present == 0) { /* Unable to read PSU VIN(psu_power_good) */ info->status |= ONLP_PSU_STATUS_UNPLUGGED; } + else + { + info->status |= ONLP_PSU_STATUS_PRESENT; + } #endif - ret = dni_psu_info_get(id, info); return ret; } diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/sfpi.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/sfpi.c index 10572b2d..0678dce0 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/sfpi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/sfpi.c @@ -77,10 +77,10 @@ int onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) int onlp_sfpi_is_present(int port) { + int present, present_bit = 0x00; #ifdef BMC uint8_t reg_t = 0x00; int bit_t = 0x00; - int present, present_bit = 0x00; if (port > 0 && port < 9) { /* SFP Port 1-8 */ reg_t = SFP_PRESENCE_1; @@ -107,7 +107,7 @@ int onlp_sfpi_is_present(int port) bit_t = 1 << (port % 8); present_bit = present_bit & bit_t; present_bit = present_bit / bit_t; - } + } else { /* SFP */ if (dni_bmc_data_get(BMC_SWPLD_BUS, SWPLD_2_ADDR, reg_t, &present_bit) != ONLP_STATUS_OK) return ONLP_STATUS_E_INTERNAL; @@ -116,10 +116,8 @@ int onlp_sfpi_is_present(int port) present_bit = present_bit & bit_t; present_bit = present_bit / bit_t; } -#endif -#ifdef I2C +#elif defined I2C char port_data[3] = {'\0'}; - int present, present_bit; if(port > 0 && port < 55) { @@ -155,12 +153,12 @@ int onlp_sfpi_is_present(int port) int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) { + int count = 0; + uint8_t bytes[7] = {0}; #ifdef BMC uint8_t reg_t = 0x00; int present_data = 0x00; uint8_t r_array[7] = {0}; - uint8_t bytes[7] = {0}; - int count = 0; /* Read presence bitmap from SWPLD2 SFP+ and SWPLD1 QSFP28 Presence Register * if only port 0 is present, return 3F FF FF FF FF FF FE @@ -185,14 +183,14 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) for (count = 0; count < 7; count++) { bytes[count] = ~r_array[6 - count]; } -#endif - -#ifdef I2C +#elif defined I2C char present_all_data[21] = {'\0'}; char *r_byte; char *r_array[7]; - uint8_t bytes[7] = {0}; - int count = 0; + + /* Read presence bitmap from SWPLD2 SFP+ and SWPLD1 QSFP28 Presence Register + * if only port 0 is present, return 3F FF FF FF FF FF FE + * if only port 0 and 1 present, return 3F FF FF FF FF FF FC */ if(dni_i2c_read_attribute_string(SFP_IS_PRESENT_ALL_PATH, present_all_data, sizeof(present_all_data), 0) < 0) { @@ -205,6 +203,7 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) r_array[count++] = r_byte; r_byte = strtok(NULL, " "); } + /* Convert a string to unsigned 8 bit integer * and saved into bytes[] */ for (count = 0; count < 7; count++) { @@ -212,7 +211,6 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) } #endif - /* Mask out non-existant SFP/QSFP ports */ bytes[0] &= 0x3F; @@ -220,6 +218,7 @@ int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) int i = 0; uint64_t presence_all = 0; + for(i = 0; i < AIM_ARRAYSIZE(bytes); i++) { presence_all <<= 8; presence_all |= bytes[i]; @@ -265,28 +264,13 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) uint8_t reg_t = 0x00; int rdata_bit = 0x00; int bit_t = 0x00; -#endif -#ifdef I2C - char port_data[3] = {'\0'}; - - if(port > 0 && port < 55) - { - /* Select SFP(1-48), QSFP(49-54) port */ - sprintf(port_data, "%d", port ); - if(dni_i2c_lock_write_attribute(NULL, port_data, SFP_SELECT_PORT_PATH) < 0){ - AIM_LOG_INFO("Unable to select port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - } -#endif - - switch (control) { + switch (control) { case ONLP_SFP_CONTROL_RESET_STATE: /* From sfp_reset value, * return 0 = The module is in Reset * return 1 = The module is not in Reset */ -#ifdef BMC + if (port > 48 && port < 55) { /* QSFP Port 49-54 */ reg_t = QSFP_RESET; if (dni_bmc_data_get(BMC_SWPLD_BUS, SWPLD_1_ADDR, reg_t, &rdata_bit) != ONLP_STATUS_OK) @@ -303,25 +287,14 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) *value = 1; else if (rdata_bit == 1) *value = 0; -#endif -#ifdef I2C - *value = dni_i2c_lock_read_attribute(NULL, QSFP_RESET_PATH); - if (*value == 0) - { - *value = 1; - } - else if (*value == 1) - { - *value = 0; - } -#endif + value_t = ONLP_STATUS_OK; break; case ONLP_SFP_CONTROL_RX_LOS: /* From sfp_rx_los value, * return 0 = The module is Normal Operation * return 1 = The module is Error */ -#ifdef BMC + if (port > 0 && port < 49) { /* SFP */ if (port > 0 && port < 9) { /* SFP Port 1-8 */ reg_t = SFP_RXLOS_1; @@ -338,28 +311,23 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) } if (dni_bmc_data_get(BMC_SWPLD_BUS, SWPLD_2_ADDR, reg_t, &rdata_bit) != ONLP_STATUS_OK) return ONLP_STATUS_E_INTERNAL; - port = port - 1; - bit_t = 1 << (port % 8); - rdata_bit = rdata_bit & bit_t; - rdata_bit = rdata_bit / bit_t; + port = port - 1; + bit_t = 1 << (port % 8); + rdata_bit = rdata_bit & bit_t; + rdata_bit = rdata_bit / bit_t; } else { /* In agc7648sv1 only SFP support control RX_LOS MODE */ rdata_bit = 1; /* return 1, module Error */ } *value = rdata_bit; -#endif -#ifdef I2C - *value = dni_i2c_lock_read_attribute(NULL, SFP_RX_LOS_PATH); -#endif value_t = ONLP_STATUS_OK; break; - case ONLP_SFP_CONTROL_TX_DISABLE: /* From sfp_tx_disable value, * return 0 = The module is Enable Transmitter on * return 1 = The module is Transmitter Disabled */ -#ifdef BMC + if (port > 0 && port < 49) { /* SFP */ if (port > 0 && port < 9) { /* SFP Port 1-8 */ reg_t = SFP_TXDIS_1; @@ -385,18 +353,14 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) rdata_bit = 1; /* return 1, module Transmitter Disabled */ } *value = rdata_bit; -#endif -#ifdef I2C - *value = dni_i2c_lock_read_attribute(NULL, SFP_TX_DISABLE_PATH); -#endif + value_t = ONLP_STATUS_OK; break; - case ONLP_SFP_CONTROL_TX_FAULT: /* From sfp_tx_fault value, * return 0 = The module is Normal * return 1 = The module is Fault */ -#ifdef BMC + if (port > 0 && port < 49) { /* SFP */ if (port > 0 && port < 9) { /* SFP Port 1-8 */ reg_t = SFP_TXFAULT_1; @@ -413,23 +377,19 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) } if (dni_bmc_data_get(BMC_SWPLD_BUS, SWPLD_2_ADDR, reg_t, &rdata_bit) != ONLP_STATUS_OK) return ONLP_STATUS_E_INTERNAL; - port = port - 1; - bit_t = 1 << (port % 8); - rdata_bit = rdata_bit & bit_t; - rdata_bit = rdata_bit / bit_t; + port = port - 1; + bit_t = 1 << (port % 8); + rdata_bit = rdata_bit & bit_t; + rdata_bit = rdata_bit / bit_t; } else { /* In agc7648sv1 only SFP support control TX_FAULT MODE */ rdata_bit = 1; /* return 1, module is Fault */ } *value = rdata_bit; -#endif -#ifdef I2C - *value = dni_i2c_lock_read_attribute(NULL, SFP_TX_FAULT_PATH); -#endif + value_t = ONLP_STATUS_OK; break; case ONLP_SFP_CONTROL_LP_MODE: -#ifdef BMC /* From sfp_lp_mode value, * return 0 = The module is not in LP mode * return 1 = The module is in LP mode */ @@ -446,29 +406,14 @@ int onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) rdata_bit = 0; /* return 0, module is not in LP mode */ } *value = rdata_bit; -#endif -#ifdef I2C - *value = dni_i2c_lock_read_attribute(NULL, QSFP_LP_MODE_PATH); -#endif + value_t = ONLP_STATUS_OK; break; default: value_t = ONLP_STATUS_E_UNSUPPORTED; break; } - return value_t; -} - -int onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) -{ - int value_t; -#ifdef BMC - uint8_t reg_t = 0x00; - int data_bit = 0x00; - int bit_t = 0x00; -#endif - -#ifdef I2C +#elif defined I2C char port_data[3] = {'\0'}; if(port > 0 && port < 55) @@ -480,11 +425,69 @@ int onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) return ONLP_STATUS_E_INTERNAL; } } -#endif switch (control) { case ONLP_SFP_CONTROL_RESET_STATE: + /* From sfp_reset value, + * return 0 = The module is in Reset + * return 1 = The module is NOT in Reset */ + *value = dni_i2c_lock_read_attribute(NULL, QSFP_RESET_PATH); + if (*value == 0) + { + *value = 1; + } + else if (*value == 1) + { + *value = 0; + } + value_t = ONLP_STATUS_OK; + break; + case ONLP_SFP_CONTROL_RX_LOS: + /* From sfp_rx_los value, + * return 0 = The module is Normal Operation + * return 1 = The module is Error */ + *value = dni_i2c_lock_read_attribute(NULL, SFP_RX_LOS_PATH); + value_t = ONLP_STATUS_OK; + break; + case ONLP_SFP_CONTROL_TX_DISABLE: + /* From sfp_tx_disable value, + * return 0 = The module is Enable Transmitter on + * return 1 = The module is Transmitter Disabled */ + *value = dni_i2c_lock_read_attribute(NULL, SFP_TX_DISABLE_PATH); + value_t = ONLP_STATUS_OK; + break; + case ONLP_SFP_CONTROL_TX_FAULT: + /* From sfp_tx_fault value, + * return 0 = The module is Normal + * return 1 = The module is Fault */ + *value = dni_i2c_lock_read_attribute(NULL, SFP_TX_FAULT_PATH); + value_t = ONLP_STATUS_OK; + break; + case ONLP_SFP_CONTROL_LP_MODE: + /* From sfp_lp_mode value, + * return 0 = The module is NOT in LP mode + * return 1 = The module is in LP mode */ + *value = dni_i2c_lock_read_attribute(NULL, QSFP_LP_MODE_PATH); + value_t = ONLP_STATUS_OK; + break; + default: + value_t = ONLP_STATUS_E_UNSUPPORTED; + break; + } +#endif + return value_t; +} + +int onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) +{ + int value_t; #ifdef BMC + uint8_t reg_t = 0x00; + int data_bit = 0x00; + int bit_t = 0x00; + + switch (control) { + case ONLP_SFP_CONTROL_RESET_STATE: if (port > 48 && port < 55) { /* QSFP Port 49-54 */ reg_t = QSFP_RESET; if (dni_bmc_data_get(BMC_SWPLD_BUS, SWPLD_1_ADDR, reg_t, &data_bit) != ONLP_STATUS_OK) @@ -506,21 +509,13 @@ int onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) } else { return ONLP_STATUS_E_UNSUPPORTED; } -#endif -#ifdef I2C - sprintf(port_data, "%d", value); - if(dni_i2c_lock_write_attribute(NULL, port_data, QSFP_RESET_PATH) < 0){ - AIM_LOG_INFO("Unable to control reset state from port(%d)\r\n", port); - value_t = ONLP_STATUS_E_INTERNAL; - } -#endif + value_t = ONLP_STATUS_OK; break; case ONLP_SFP_CONTROL_RX_LOS: value_t = ONLP_STATUS_E_UNSUPPORTED; break; case ONLP_SFP_CONTROL_TX_DISABLE: -#ifdef BMC if (port > 0 && port < 49) { /* SFP */ if (port > 0 && port < 9) { /* SFP Port 1-8 */ reg_t = SFP_TXDIS_1; @@ -555,21 +550,13 @@ int onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) } else { return ONLP_STATUS_E_UNSUPPORTED; } -#endif -#ifdef I2Ci - sprintf(port_data, "%d", value); - if(dni_i2c_lock_write_attribute(NULL, port_data, SFP_TX_DISABLE_PATH) < 0){ - AIM_LOG_INFO("Unable to control tx disable from port(%d)\r\n", port); - value_t = ONLP_STATUS_E_INTERNAL; - } -#endif + value_t = ONLP_STATUS_OK; break; case ONLP_SFP_CONTROL_TX_FAULT: value_t = ONLP_STATUS_E_UNSUPPORTED; break; case ONLP_SFP_CONTROL_LP_MODE: -#ifdef BMC if (port > 48 && port < 55) { /* QSFP Port 49-54 */ reg_t = QSFP_LPMODE; if (dni_bmc_data_get(BMC_SWPLD_BUS, SWPLD_1_ADDR, reg_t, &data_bit) != ONLP_STATUS_OK) @@ -591,20 +578,62 @@ int onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) } else { return ONLP_STATUS_E_UNSUPPORTED; } -#endif -#ifdef I2C - sprintf(port_data, "%d", value); - if(dni_i2c_lock_write_attribute(NULL, port_data, QSFP_LP_MODE_PATH) < 0){ - AIM_LOG_INFO("Unable to control LP mode from port(%d)\r\n", port); - value_t = ONLP_STATUS_E_INTERNAL; - } -#endif + value_t = ONLP_STATUS_OK; break; default: value_t = ONLP_STATUS_E_UNSUPPORTED; break; } +#elif defined I2C + char port_data[3] = {'\0'}; + + if(port > 0 && port < 55) + { + /* Select SFP(1-48), QSFP(49-54) port */ + sprintf(port_data, "%d", port ); + if(dni_i2c_lock_write_attribute(NULL, port_data, SFP_SELECT_PORT_PATH) < 0){ + AIM_LOG_INFO("Unable to select port(%d)\r\n", port); + return ONLP_STATUS_E_INTERNAL; + } + } + + switch (control) { + case ONLP_SFP_CONTROL_RESET_STATE: + sprintf(port_data, "%d", value); + if(dni_i2c_lock_write_attribute(NULL, port_data, QSFP_RESET_PATH) < 0){ + AIM_LOG_INFO("Unable to control reset state from port(%d)\r\n", port); + value_t = ONLP_STATUS_E_INTERNAL; + } + value_t = ONLP_STATUS_OK; + break; + case ONLP_SFP_CONTROL_RX_LOS: + value_t = ONLP_STATUS_E_UNSUPPORTED; + break; + case ONLP_SFP_CONTROL_TX_DISABLE: + sprintf(port_data, "%d", value); + if(dni_i2c_lock_write_attribute(NULL, port_data, SFP_TX_DISABLE_PATH) < 0){ + AIM_LOG_INFO("Unable to control tx disable from port(%d)\r\n", port); + value_t = ONLP_STATUS_E_INTERNAL; + } + value_t = ONLP_STATUS_OK; + break; + case ONLP_SFP_CONTROL_TX_FAULT: + value_t = ONLP_STATUS_E_UNSUPPORTED; + break; + case ONLP_SFP_CONTROL_LP_MODE: + sprintf(port_data, "%d", value); + if(dni_i2c_lock_write_attribute(NULL, port_data, QSFP_LP_MODE_PATH) < 0){ + AIM_LOG_INFO("Unable to control LP mode from port(%d)\r\n", port); + value_t = ONLP_STATUS_E_INTERNAL; + } + value_t = ONLP_STATUS_OK; + break; + default: + value_t = ONLP_STATUS_E_UNSUPPORTED; + break; + } +#endif return value_t; } @@ -700,23 +729,17 @@ int onlp_sfpi_denit(void) int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) { + int count = 0; + uint8_t bytes[6] = {0}; #ifdef BMC uint8_t reg_t = 0x00; int rxlos_data = 0x00; uint8_t r_array[6] = {0}; -#endif -#ifdef I2C - char rxlos_all_data[18] = {'\0'}; - char *r_byte; - char *r_array[6]; -#endif - uint8_t bytes[6] = {0}; - int count = 0; /* Read rx_los bitmap from SWPLD2 SFP+ LOSS Register * if only port 0 is normal operation, return FF FF FF FF FF FE * if only port 0 and 1 normal operation, return FF FF FF FF FF FC */ -#ifdef BMC + for (count = 0; count < 6; count++) { /* SFP Port 1-48 */ reg_t = SFP_RXLOS_1 + count; if (dni_bmc_data_get(BMC_SWPLD_BUS, SWPLD_2_ADDR, reg_t, &rxlos_data) != ONLP_STATUS_OK) @@ -728,8 +751,15 @@ int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) for (count = 0; count < 6; count++) { bytes[count] = r_array[5 - count]; } -#endif -#ifdef I2C +#elif defined I2C + char rxlos_all_data[18] = {'\0'}; + char *r_byte; + char *r_array[6]; + + /* Read rx_los bitmap from SWPLD2 SFP+ LOSS Register + * if only port 0 is normal operation, return FF FF FF FF FF FE + * if only port 0 and 1 normal operation, return FF FF FF FF FF FC */ + if(dni_i2c_read_attribute_string(SFP_RX_LOS_ALL_PATH, rxlos_all_data, sizeof(rxlos_all_data), 0) < 0) { return -1; @@ -741,6 +771,7 @@ int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) r_array[count++] = r_byte; r_byte = strtok(NULL, " "); } + /* Convert a string to unsigned 8 bit integer * and saved into bytes[] */ for (count = 0; count < 6; count++) { @@ -768,6 +799,7 @@ int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) AIM_BITMAP_MOD(dst, i+1, 0); return ONLP_STATUS_OK; + } int onlp_sfpi_dom_read(int port, uint8_t data[256]) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/sysi.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/sysi.c index dc384685..146e3a0d 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/sysi.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/sysi.c @@ -204,7 +204,7 @@ int onlp_sysi_platform_manage_leds(void) int rpm = 0, rpm1 = 0, count = 0; int fantray_count; char fantray_count_str[2] = {'\0'}; - uint8_t psu_state; + uint8_t psu1_state, psu2_state; int psu_pwr_status = 0; int psu_pwr_int = 0; int fantray_present = -1; @@ -308,26 +308,13 @@ int onlp_sysi_platform_manage_leds(void) } /* Set front light of PWR */ - psu_state = dni_i2c_lock_read_attribute(NULL, PSU1_PRESENT_PATH); + psu1_state = dni_i2c_lock_read_attribute(NULL, PSU1_PRESENT_PATH); + psu2_state = dni_i2c_lock_read_attribute(NULL, PSU2_PRESENT_PATH); psu_pwr_status = dni_lock_cpld_read_attribute(SWPLD1_PATH,POWER_STATUS_REGISTER); psu_pwr_int = dni_lock_cpld_read_attribute(SWPLD1_PATH,POWER_INT_REGISTER); - if(psu_state == 0 && (psu_pwr_status & 0x80) == 0x80 && (psu_pwr_int & 0x10) == 0x10) - { - /* Green */ - if(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR),ONLP_LED_MODE_GREEN) != ONLP_STATUS_OK) - rv = ONLP_STATUS_E_INTERNAL; - } - else - { - /* Amber */ - if(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR),ONLP_LED_MODE_YELLOW) != ONLP_STATUS_OK) - rv = ONLP_STATUS_E_INTERNAL; - } - psu_state = dni_i2c_lock_read_attribute(NULL, PSU2_PRESENT_PATH); - - if(psu_state == 0 && (psu_pwr_status & 0x40) == 0x40 && (psu_pwr_int & 0x20) == 0x20) + if(psu1_state == 0 && psu2_state == 0 && (psu_pwr_status & 0xc0) == 0xc0 && (psu_pwr_int & 0x30) == 0x30) { /* Green */ if(onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FRONT_PWR),ONLP_LED_MODE_GREEN) != ONLP_STATUS_OK) diff --git a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/thermali.c b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/thermali.c index 6b4838c1..cf25b90e 100755 --- a/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/thermali.c +++ b/packages/platforms/delta/x86-64/x86-64-delta-agc7648sv1/onlp/builds/src/module/src/thermali.c @@ -134,22 +134,16 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) { uint8_t local_id = 0; int rv = ONLP_STATUS_OK; -#ifdef BMC - UINT4 multiplier = 1000; - UINT4 u4Data = 0; - char device_buf[20] = {0}; -#endif -#ifdef I2C - int temp_base = 1; - char fullpath[50] = {0}; - int r_data = 0; -#endif VALIDATE(id); local_id = ONLP_OID_ID_GET(id); *info = linfo[local_id]; #ifdef BMC + UINT4 multiplier = 1000; + UINT4 u4Data = 0; + char device_buf[20] = {0}; + switch(local_id) { case THERMAL_1_ON_FAN_BOARD: sprintf(device_buf, "Fan_Temp"); @@ -187,8 +181,11 @@ onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* info) info->mcelsius = u4Data; return 0; } -#endif -#ifdef I2C +#elif defined I2C + int temp_base = 1; + char fullpath[50] = {0}; + int r_data = 0; + switch (local_id) { case THERMAL_1_ON_FAN_BOARD: sprintf(fullpath,"%s%s", PREFIX_PATH, path[local_id]);