Skip to content

Commit 85ece2a

Browse files
committed
[Accton][as7535-28xb] Modify what onlpdump -x displays
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 <alex_lai@accton.com>
1 parent 156b59f commit 85ece2a

File tree

4 files changed

+109
-17
lines changed

4 files changed

+109
-17
lines changed

packages/platforms/accton/x86-64/as7535-28xb/modules/builds/x86-64-accton-as7535-28xb-cpld.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ enum as7535_28xb_cpld_sysfs_attributes {
190190
MODULE_PRESENT_ALL,
191191
MODULE_RXLOS_ALL,
192192
CPLD_VERSION,
193+
MINOR_VERSION,
193194
ACCESS,
194195
};
195196

@@ -225,6 +226,10 @@ enum as7535_28xb_cpld_sysfs_attributes {
225226
&sensor_dev_attr_module_rx_los_##index.dev_attr.attr
226227

227228
static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION);
229+
230+
static SENSOR_DEVICE_ATTR(minor_version, S_IRUGO, show_version, NULL, \
231+
MINOR_VERSION);
232+
228233
static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS);
229234

230235
static SENSOR_DEVICE_ATTR(module_present_all, S_IRUGO, show_present_all, \
@@ -293,6 +298,7 @@ static struct attribute *as7535_28xb_cpld_attributes[] = {
293298
DECLARE_SFP_TRANSCEIVER_ATTR(27),
294299
DECLARE_SFP_TRANSCEIVER_ATTR(28),
295300
&sensor_dev_attr_version.dev_attr.attr,
301+
&sensor_dev_attr_minor_version.dev_attr.attr,
296302
&sensor_dev_attr_access.dev_attr.attr,
297303
&sensor_dev_attr_module_present_all.dev_attr.attr,
298304
&sensor_dev_attr_module_rx_los_all.dev_attr.attr,
@@ -707,6 +713,13 @@ static ssize_t show_version(struct device *dev, struct device_attribute *da,
707713
addr = 0x61;
708714
reg = 0x1;
709715
break;
716+
717+
case MINOR_VERSION:
718+
bus = 12;
719+
addr = 0x61;
720+
reg = 0x2;
721+
break;
722+
710723
default:
711724
return -ENXIO;
712725
}

packages/platforms/accton/x86-64/as7535-28xb/modules/builds/x86-64-accton-as7535-28xb-fan.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ struct as7535_28xb_fan_data {
106106
unsigned long last_updated; /* In jiffies */
107107
/* 4 bytes for each fan, the last 2 bytes is fan dir */
108108
unsigned char ipmi_resp[NUM_OF_FAN * FAN_DATA_COUNT + 2];
109-
unsigned char ipmi_resp_cpld;
109+
unsigned char ipmi_resp_cpld[2];
110110
unsigned char ipmi_resp_speed[NUM_OF_FAN * FAN_SPEED_DATA_COUNT];
111111
struct ipmi_data ipmi;
112112
unsigned char ipmi_tx_data[3]; /* 0: FAN id, 1: 0x02, 2: PWM */
@@ -151,6 +151,7 @@ enum as7535_28xb_fan_sysfs_attrs {
151151
FAN_ATTR(6),
152152
NUM_OF_FAN_ATTR,
153153
FAN_VERSION,
154+
FAN_MINOR_VERSION,
154155
FAN_MAX_RPM,
155156
NUM_OF_PER_FAN_ATTR = (NUM_OF_FAN_ATTR/NUM_OF_FAN),
156157
FAN_RPM_THRESHOLD_ATTR(1),
@@ -163,9 +164,14 @@ enum as7535_28xb_fan_sysfs_attrs {
163164

164165
/* fan attributes */
165166
#define DECLARE_FAN_VER_SENSOR_DEVICE_ATTR() \
166-
static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, FAN_VERSION)
167+
static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, \
168+
FAN_VERSION); \
169+
static SENSOR_DEVICE_ATTR(minor_version, S_IRUGO, show_version, NULL, \
170+
FAN_MINOR_VERSION)
171+
167172
#define DECLARE_FAN_VER_ATTR() \
168-
&sensor_dev_attr_version.dev_attr.attr
173+
&sensor_dev_attr_version.dev_attr.attr, \
174+
&sensor_dev_attr_minor_version.dev_attr.attr
169175

170176
#define DECLARE_FAN_SENSOR_DEVICE_ATTR(index) \
171177
static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, show_fan, NULL, \
@@ -511,7 +517,7 @@ static struct as7535_28xb_fan_data *as7535_28xb_fan_update_cpld_ver(void)
511517
data->ipmi_tx_data[0] = 0x66;
512518
status = ipmi_send_message(&data->ipmi, IPMI_FAN_REG_READ_CMD,
513519
data->ipmi_tx_data, 1,
514-
&data->ipmi_resp_cpld,
520+
data->ipmi_resp_cpld,
515521
sizeof(data->ipmi_resp_cpld));
516522
if (unlikely(status != 0))
517523
goto exit;
@@ -531,6 +537,7 @@ static struct as7535_28xb_fan_data *as7535_28xb_fan_update_cpld_ver(void)
531537
static ssize_t show_version(struct device *dev, struct device_attribute *da,
532538
char *buf)
533539
{
540+
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
534541
unsigned char value = 0;
535542
int error = 0;
536543

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

545-
value = data->ipmi_resp_cpld;
552+
if (attr->index == FAN_VERSION) {
553+
value = data->ipmi_resp_cpld[0];
554+
} else if (attr->index == FAN_MINOR_VERSION) {
555+
value = data->ipmi_resp_cpld[1];
556+
546557
mutex_unlock(&data->update_lock);
547558
return sprintf(buf, "%d\n", value);
548559

packages/platforms/accton/x86-64/as7535-28xb/modules/builds/x86-64-accton-as7535-28xb-sys.c

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct as7535_28xb_sys_data {
7474
unsigned long last_updated; /* In jiffies */
7575
struct ipmi_data ipmi;
7676
unsigned char ipmi_resp_eeprom[EEPROM_SIZE];
77-
unsigned char ipmi_resp_cpld;
77+
unsigned char ipmi_resp_cpld[2];
7878
unsigned char ipmi_tx_data[2];
7979
struct bin_attribute eeprom; /* eeprom data */
8080
};
@@ -92,12 +92,25 @@ static struct platform_driver as7535_28xb_sys_driver = {
9292

9393
enum as7535_28xb_sys_sysfs_attrs {
9494
FPGA_VER, /* FPGA version */
95+
FPGA_MINOR_VER, /* FPGA minor version */
96+
CPU_CPLD_VER, /* CPU CPLD version */
97+
CPU_CPLD_MINOR_VER, /* CPU CPLD minor version */
9598
};
9699

97-
static SENSOR_DEVICE_ATTR(fpga_version, S_IRUGO, show_version, NULL, FPGA_VER);
100+
static SENSOR_DEVICE_ATTR(fpga_version, S_IRUGO, show_version, NULL, \
101+
FPGA_VER);
102+
static SENSOR_DEVICE_ATTR(fpga_minor_version, S_IRUGO, show_version, NULL, \
103+
FPGA_MINOR_VER);
104+
static SENSOR_DEVICE_ATTR(cpu_cpld_version, S_IRUGO, show_version, NULL, \
105+
CPU_CPLD_VER);
106+
static SENSOR_DEVICE_ATTR(cpu_cpld_minor_version, S_IRUGO, show_version, NULL, \
107+
CPU_CPLD_MINOR_VER);
98108

99109
static struct attribute *as7535_28xb_sys_attributes[] = {
100110
&sensor_dev_attr_fpga_version.dev_attr.attr,
111+
&sensor_dev_attr_fpga_minor_version.dev_attr.attr,
112+
&sensor_dev_attr_cpu_cpld_version.dev_attr.attr,
113+
&sensor_dev_attr_cpu_cpld_minor_version.dev_attr.attr,
101114
NULL
102115
};
103116

@@ -329,15 +342,17 @@ static int sysfs_eeprom_cleanup(struct kobject *kobj,
329342
return 0;
330343
}
331344

332-
static struct as7535_28xb_sys_data *as7535_28xb_sys_update_fpga_ver(void)
345+
static struct as7535_28xb_sys_data *as7535_28xb_sys_update_ver(
346+
unsigned char reg)
333347
{
334348
int status = 0;
335349

336350
data->valid = 0;
337-
data->ipmi_tx_data[0] = 0x60;
351+
352+
data->ipmi_tx_data[0] = reg;
338353
status = ipmi_send_message(&data->ipmi, IPMI_CPLD_READ_CMD,
339354
data->ipmi_tx_data, 1,
340-
&data->ipmi_resp_cpld,
355+
data->ipmi_resp_cpld,
341356
sizeof(data->ipmi_resp_cpld));
342357
if (unlikely(status != 0))
343358
goto exit;
@@ -357,18 +372,31 @@ static struct as7535_28xb_sys_data *as7535_28xb_sys_update_fpga_ver(void)
357372
static ssize_t show_version(struct device *dev,
358373
struct device_attribute *da, char *buf)
359374
{
375+
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
376+
unsigned char reg;
360377
unsigned char value = 0;
361378
int error = 0;
362379

363380
mutex_lock(&data->update_lock);
364381

365-
data = as7535_28xb_sys_update_fpga_ver();
382+
if ((attr->index == FPGA_VER) || (attr->index == FPGA_MINOR_VER))
383+
reg = 0x60;
384+
else if ((attr->index == CPU_CPLD_VER) ||
385+
(attr->index == CPU_CPLD_MINOR_VER))
386+
reg = 0x65;
387+
388+
data = as7535_28xb_sys_update_ver(reg);
389+
366390
if (!data->valid) {
367391
error = -EIO;
368392
goto exit;
369393
}
370394

371-
value = data->ipmi_resp_cpld;
395+
if ((attr->index == FPGA_VER) || (attr->index == CPU_CPLD_VER))
396+
value = data->ipmi_resp_cpld[0];
397+
else if (attr->index == FPGA_MINOR_VER || attr->index == CPU_CPLD_MINOR_VER)
398+
value = data->ipmi_resp_cpld[1];
399+
372400
mutex_unlock(&data->update_lock);
373401
return sprintf(buf, "%d\n", value);
374402

packages/platforms/accton/x86-64/as7535-28xb/onlp/builds/x86_64_accton_as7535_28xb/module/src/sysi.c

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,22 @@
3434
#include "x86_64_accton_as7535_28xb_int.h"
3535
#include "x86_64_accton_as7535_28xb_log.h"
3636

37-
#define NUM_OF_CPLD_VER 3
37+
38+
#define NUM_OF_CPLD_VER 8
39+
#define BMC_AUX_FW_VER_LEN 20
40+
41+
#define BIOS_VER_PATH "/sys/devices/virtual/dmi/id/bios_version"
42+
#define BMC_VER_PREFIX "/sys/devices/pci0000:00/0000:00:1f.0/IPI0001:00/bmc/"
3843

3944
static char* cpld_ver_path[NUM_OF_CPLD_VER] = {
45+
"/sys/devices/platform/as7535_28xb_sys/cpu_cpld_version",
46+
"/sys/devices/platform/as7535_28xb_sys/cpu_cpld_minor_version",
4047
"/sys/bus/i2c/devices/12-0061/version", /* Main CPLD */
41-
"/sys/devices/platform/as7535_28xb_sys/fpga_version", /* FPGA */
42-
"/sys/devices/platform/as7535_28xb_fan/version", /* Fan CPLD */
48+
"/sys/bus/i2c/devices/12-0061/minor_version",
49+
"/sys/devices/platform/as7535_28xb_fan/version",
50+
"/sys/devices/platform/as7535_28xb_fan/minor_version",
51+
"/sys/devices/platform/as7535_28xb_sys/fpga_version",
52+
"/sys/devices/platform/as7535_28xb_sys/fpga_minor_version",
4353
};
4454

4555
const char*
@@ -110,6 +120,12 @@ int
110120
onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
111121
{
112122
int i, v[NUM_OF_CPLD_VER] = {0};
123+
int len = 0;
124+
onlp_onie_info_t onie;
125+
char *bios_ver = NULL;
126+
char *bmc_fw_ver = NULL;
127+
char *tmp = NULL;
128+
char bmc_aux_fw_ver[BMC_AUX_FW_VER_LEN] = {0};
113129

114130
for (i = 0; i < AIM_ARRAYSIZE(cpld_ver_path); i++) {
115131
v[i] = 0;
@@ -119,8 +135,31 @@ onlp_sysi_platform_info_get(onlp_platform_info_t* pi)
119135
}
120136
}
121137

122-
pi->cpld_versions = aim_fstrdup("\r\nCPLD:%02x\r\nFPGA:%02x\r\nFan CPLD:%02x",
123-
v[0], v[1], v[2]);
138+
onlp_file_read_str(&bios_ver, BIOS_VER_PATH);
139+
onlp_onie_decode_file(&onie, IDPROM_PATH);
140+
onlp_file_read_str(&bmc_fw_ver, BMC_VER_PREFIX"firmware_revision");
141+
len = onlp_file_read_str(&tmp, BMC_VER_PREFIX"aux_firmware_revision");
142+
143+
if(tmp && len){
144+
memcpy(bmc_aux_fw_ver, tmp, len);
145+
bmc_aux_fw_ver[len] = '\0';
146+
}
147+
148+
pi->cpld_versions = aim_fstrdup("\r\n\t CPU CPLD(0x65): %02X.%02X"
149+
"\r\n\t Main CPLD(0x61): %02X.%02X"
150+
"\r\n\t Fan CPLD(0x66): %02X.%02X"
151+
"\r\n\t FPGA(0x60): %02X.%02X\r\n",
152+
v[0], v[1], v[2], v[3],
153+
v[4], v[5], v[6], v[7]);
154+
155+
pi->other_versions = aim_fstrdup("\r\n\t BIOS: %s\r\n\t ONIE: %s"
156+
"\r\n\t BMC: %s.%c%c",
157+
bios_ver, onie.onie_version, bmc_fw_ver,
158+
bmc_aux_fw_ver[17], bmc_aux_fw_ver[18]);
159+
160+
AIM_FREE_IF_PTR(bios_ver);
161+
AIM_FREE_IF_PTR(bmc_fw_ver);
162+
AIM_FREE_IF_PTR(tmp);
124163

125164
return ONLP_STATUS_OK;
126165
}
@@ -129,4 +168,5 @@ void
129168
onlp_sysi_platform_info_free(onlp_platform_info_t* pi)
130169
{
131170
aim_free(pi->cpld_versions);
171+
aim_free(pi->other_versions);
132172
}

0 commit comments

Comments
 (0)