Skip to content

Commit

Permalink
[Accton][as7535-28xb] Modify what onlpdump -x displays
Browse files Browse the repository at this point in the history
1. Add a sysfs, minor_vsrsion, in x86-64-accton-as7535-28xb-cpld.c

2. Add a sysfs, minor_version, in x86-64-accton-as7535-28xb-fan.c

3. Add 3 sysfses, fpga_minor_version, cpu_cpld_version, and
   cpu_cpld_minor_version, in x86-64-accton-as7535-28xb-sys.c

4. Modify what onlpdump -x displays.

Before modification:
        CPLD Versions:
CPLD:0b
FPGA:5b
Fan CPLD:0b

After modification:
        CPLD Versions:
           CPU CPLD(0x65): E1.0A
           Main CPLD(0x61): 0B.04
           Fan CPLD(0x66): 0B.13
           FPGA(0x60): 5B.16

        Other Versions:
           BIOS: v48.0b.03.00
           ONIE: 2020.11.00.14
           BMC: 0.4.00

Signed-off-by: Alex Lai <[email protected]>
  • Loading branch information
Alex Lai committed Sep 13, 2024
1 parent 156b59f commit 58e8b22
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ enum as7535_28xb_cpld_sysfs_attributes {
MODULE_PRESENT_ALL,
MODULE_RXLOS_ALL,
CPLD_VERSION,
MINOR_VERSION,
ACCESS,
};

Expand Down Expand Up @@ -225,6 +226,10 @@ enum as7535_28xb_cpld_sysfs_attributes {
&sensor_dev_attr_module_rx_los_##index.dev_attr.attr

static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION);

static SENSOR_DEVICE_ATTR(minor_version, S_IRUGO, show_version, NULL, \
MINOR_VERSION);

static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS);

static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, \
Expand Down Expand Up @@ -293,6 +298,7 @@ static struct attribute *as7535_28xb_cpld_attributes[] = {
DECLARE_SFP_TRANSCEIVER_ATTR(27),
DECLARE_SFP_TRANSCEIVER_ATTR(28),
&sensor_dev_attr_version.dev_attr.attr,
&sensor_dev_attr_minor_version.dev_attr.attr,
&sensor_dev_attr_access.dev_attr.attr,
&sensor_dev_attr_module_present_all.dev_attr.attr,
&sensor_dev_attr_module_rx_los_all.dev_attr.attr,
Expand Down Expand Up @@ -707,6 +713,13 @@ static ssize_t show_version(struct device *dev, struct device_attribute *da,
addr = 0x61;
reg = 0x1;
break;

case MINOR_VERSION:
bus = 12;
addr = 0x61;
reg = 0x2;
break;

default:
return -ENXIO;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ struct as7535_28xb_fan_data {
unsigned long last_updated; /* In jiffies */
/* 4 bytes for each fan, the last 2 bytes is fan dir */
unsigned char ipmi_resp[NUM_OF_FAN * FAN_DATA_COUNT + 2];
unsigned char ipmi_resp_cpld;
unsigned char ipmi_resp_cpld[2];
unsigned char ipmi_resp_speed[NUM_OF_FAN * FAN_SPEED_DATA_COUNT];
struct ipmi_data ipmi;
unsigned char ipmi_tx_data[3]; /* 0: FAN id, 1: 0x02, 2: PWM */
Expand Down Expand Up @@ -151,6 +151,7 @@ enum as7535_28xb_fan_sysfs_attrs {
FAN_ATTR(6),
NUM_OF_FAN_ATTR,
FAN_VERSION,
FAN_MINOR_VERSION,
FAN_MAX_RPM,
NUM_OF_PER_FAN_ATTR = (NUM_OF_FAN_ATTR/NUM_OF_FAN),
FAN_RPM_THRESHOLD_ATTR(1),
Expand All @@ -163,9 +164,14 @@ enum as7535_28xb_fan_sysfs_attrs {

/* fan attributes */
#define DECLARE_FAN_VER_SENSOR_DEVICE_ATTR() \
static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, FAN_VERSION)
static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, \
FAN_VERSION); \
static SENSOR_DEVICE_ATTR(minor_version, S_IRUGO, show_version, NULL, \
FAN_MINOR_VERSION)

#define DECLARE_FAN_VER_ATTR() \
&sensor_dev_attr_version.dev_attr.attr
&sensor_dev_attr_version.dev_attr.attr, \
&sensor_dev_attr_minor_version.dev_attr.attr

#define DECLARE_FAN_SENSOR_DEVICE_ATTR(index) \
static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, show_fan, NULL, \
Expand Down Expand Up @@ -511,7 +517,7 @@ static struct as7535_28xb_fan_data *as7535_28xb_fan_update_cpld_ver(void)
data->ipmi_tx_data[0] = 0x66;
status = ipmi_send_message(&data->ipmi, IPMI_FAN_REG_READ_CMD,
data->ipmi_tx_data, 1,
&data->ipmi_resp_cpld,
data->ipmi_resp_cpld,
sizeof(data->ipmi_resp_cpld));
if (unlikely(status != 0))
goto exit;
Expand All @@ -531,6 +537,7 @@ static struct as7535_28xb_fan_data *as7535_28xb_fan_update_cpld_ver(void)
static ssize_t show_version(struct device *dev, struct device_attribute *da,
char *buf)
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
unsigned char value = 0;
int error = 0;

Expand All @@ -542,7 +549,11 @@ static ssize_t show_version(struct device *dev, struct device_attribute *da,
goto exit;
}

value = data->ipmi_resp_cpld;
if (attr->index == FAN_VERSION)
value = data->ipmi_resp_cpld[0];
else if (attr->index == FAN_MINOR_VERSION)
value = data->ipmi_resp_cpld[1];

mutex_unlock(&data->update_lock);
return sprintf(buf, "%d\n", value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct as7535_28xb_sys_data {
unsigned long last_updated; /* In jiffies */
struct ipmi_data ipmi;
unsigned char ipmi_resp_eeprom[EEPROM_SIZE];
unsigned char ipmi_resp_cpld;
unsigned char ipmi_resp_cpld[2];
unsigned char ipmi_tx_data[2];
struct bin_attribute eeprom; /* eeprom data */
};
Expand All @@ -92,12 +92,25 @@ static struct platform_driver as7535_28xb_sys_driver = {

enum as7535_28xb_sys_sysfs_attrs {
FPGA_VER, /* FPGA version */
FPGA_MINOR_VER, /* FPGA minor version */
CPU_CPLD_VER, /* CPU CPLD version */
CPU_CPLD_MINOR_VER, /* CPU CPLD minor version */
};

static SENSOR_DEVICE_ATTR(fpga_version, S_IRUGO, show_version, NULL, FPGA_VER);
static SENSOR_DEVICE_ATTR(fpga_version, S_IRUGO, show_version, NULL, \
FPGA_VER);
static SENSOR_DEVICE_ATTR(fpga_minor_version, S_IRUGO, show_version, NULL, \
FPGA_MINOR_VER);
static SENSOR_DEVICE_ATTR(cpu_cpld_version, S_IRUGO, show_version, NULL, \
CPU_CPLD_VER);
static SENSOR_DEVICE_ATTR(cpu_cpld_minor_version, S_IRUGO, show_version, NULL, \
CPU_CPLD_MINOR_VER);

static struct attribute *as7535_28xb_sys_attributes[] = {
&sensor_dev_attr_fpga_version.dev_attr.attr,
&sensor_dev_attr_fpga_minor_version.dev_attr.attr,
&sensor_dev_attr_cpu_cpld_version.dev_attr.attr,
&sensor_dev_attr_cpu_cpld_minor_version.dev_attr.attr,
NULL
};

Expand Down Expand Up @@ -329,15 +342,17 @@ static int sysfs_eeprom_cleanup(struct kobject *kobj,
return 0;
}

static struct as7535_28xb_sys_data *as7535_28xb_sys_update_fpga_ver(void)
static struct as7535_28xb_sys_data *as7535_28xb_sys_update_ver(
unsigned char reg)
{
int status = 0;

data->valid = 0;
data->ipmi_tx_data[0] = 0x60;

data->ipmi_tx_data[0] = reg;
status = ipmi_send_message(&data->ipmi, IPMI_CPLD_READ_CMD,
data->ipmi_tx_data, 1,
&data->ipmi_resp_cpld,
data->ipmi_resp_cpld,
sizeof(data->ipmi_resp_cpld));
if (unlikely(status != 0))
goto exit;
Expand All @@ -357,18 +372,31 @@ static struct as7535_28xb_sys_data *as7535_28xb_sys_update_fpga_ver(void)
static ssize_t show_version(struct device *dev,
struct device_attribute *da, char *buf)
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
unsigned char reg;
unsigned char value = 0;
int error = 0;

mutex_lock(&data->update_lock);

data = as7535_28xb_sys_update_fpga_ver();
if ((attr->index == FPGA_VER) || (attr->index == FPGA_MINOR_VER))
reg = 0x60;
else if ((attr->index == CPU_CPLD_VER) ||
(attr->index == CPU_CPLD_MINOR_VER))
reg = 0x65;

data = as7535_28xb_sys_update_ver(reg);

if (!data->valid) {
error = -EIO;
goto exit;
}

value = data->ipmi_resp_cpld;
if ((attr->index == FPGA_VER) || (attr->index == CPU_CPLD_VER))
value = data->ipmi_resp_cpld[0];
else if (attr->index == FPGA_MINOR_VER || attr->index == CPU_CPLD_MINOR_VER)
value = data->ipmi_resp_cpld[1];

mutex_unlock(&data->update_lock);
return sprintf(buf, "%d\n", value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,22 @@
#include "x86_64_accton_as7535_28xb_int.h"
#include "x86_64_accton_as7535_28xb_log.h"

#define NUM_OF_CPLD_VER 3

#define NUM_OF_CPLD_VER 8
#define BMC_AUX_FW_VER_LEN 20

#define BIOS_VER_PATH "/sys/devices/virtual/dmi/id/bios_version"
#define BMC_VER_PREFIX "/sys/devices/pci0000:00/0000:00:1f.0/IPI0001:00/bmc/"

static char* cpld_ver_path[NUM_OF_CPLD_VER] = {
"/sys/devices/platform/as7535_28xb_sys/cpu_cpld_version",
"/sys/devices/platform/as7535_28xb_sys/cpu_cpld_minor_version",
"/sys/bus/i2c/devices/12-0061/version", /* Main CPLD */
"/sys/devices/platform/as7535_28xb_sys/fpga_version", /* FPGA */
"/sys/devices/platform/as7535_28xb_fan/version", /* Fan CPLD */
"/sys/bus/i2c/devices/12-0061/minor_version",
"/sys/devices/platform/as7535_28xb_fan/version",
"/sys/devices/platform/as7535_28xb_fan/minor_version",
"/sys/devices/platform/as7535_28xb_sys/fpga_version",
"/sys/devices/platform/as7535_28xb_sys/fpga_minor_version",
};

const char*
Expand Down Expand Up @@ -110,6 +120,12 @@ int
onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
{
int i, v[NUM_OF_CPLD_VER] = {0};
int len = 0;
onlp_onie_info_t onie;
char *bios_ver = NULL;
char *bmc_fw_ver = NULL;
char *tmp = NULL;
char bmc_aux_fw_ver[BMC_AUX_FW_VER_LEN] = {0};

for (i = 0; i < AIM_ARRAYSIZE(cpld_ver_path); i++) {
v[i] = 0;
Expand All @@ -119,8 +135,31 @@ onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
}
}

pi->cpld_versions = aim_fstrdup("\r\nCPLD:%02x\r\nFPGA:%02x\r\nFan CPLD:%02x",
v[0], v[1], v[2]);
onlp_file_read_str(&bios_ver, BIOS_VER_PATH);
onlp_onie_decode_file(&onie, IDPROM_PATH);
onlp_file_read_str(&bmc_fw_ver, BMC_VER_PREFIX"firmware_revision");
len = onlp_file_read_str(&tmp, BMC_VER_PREFIX"aux_firmware_revision");

if(tmp && len){
memcpy(bmc_aux_fw_ver, tmp, len);
bmc_aux_fw_ver[len] = '\0';
}

pi->cpld_versions = aim_fstrdup("\r\n\t CPU CPLD(0x65): %02X.%02X"
"\r\n\t Main CPLD(0x61): %02X.%02X"
"\r\n\t Fan CPLD(0x66): %02X.%02X"
"\r\n\t FPGA(0x60): %02X.%02X\r\n",
v[0], v[1], v[2], v[3],
v[4], v[5], v[6], v[7]);

pi->other_versions = aim_fstrdup("\r\n\t BIOS: %s\r\n\t ONIE: %s"
"\r\n\t BMC: %s.%c%c",
bios_ver, onie.onie_version, bmc_fw_ver,
bmc_aux_fw_ver[17], bmc_aux_fw_ver[18]);

AIM_FREE_IF_PTR(bios_ver);
AIM_FREE_IF_PTR(bmc_fw_ver);
AIM_FREE_IF_PTR(tmp);

return ONLP_STATUS_OK;
}
Expand All @@ -129,4 +168,5 @@ void
onlp_sysi_platform_info_free(onlp_platform_info_t* pi)
{
aim_free(pi->cpld_versions);
aim_free(pi->other_versions);
}

0 comments on commit 58e8b22

Please sign in to comment.