Skip to content

Commit e16a716

Browse files
[device][platform] Modify for test_component.py, test_fan_drawer.py, and test_psu.py of testbed
1 parent 4ebb2d9 commit e16a716

File tree

5 files changed

+233
-17
lines changed

5 files changed

+233
-17
lines changed

device/quanta/x86_64-quanta_ix7_rglbmc-r0/platform.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"name": "MB_CPLD_IO_2"
2929
},
3030
{
31-
"name": "MB_CPLD_LED_2"
31+
"name": "MB_CPLD_LED_1"
3232
},
3333
{
3434
"name": "MB_CPLD_LED_2"
@@ -308,7 +308,7 @@
308308
],
309309
"psus": [
310310
{
311-
"name": "PSU 1",
311+
"name": "PSU1",
312312
"status_led": {
313313
"controllable": false
314314
},
@@ -325,7 +325,7 @@
325325
]
326326
},
327327
{
328-
"name": "PSU 2",
328+
"name": "PSU2",
329329
"status_led": {
330330
"controllable": false
331331
},

platform/broadcom/sonic-platform-modules-quanta/ix7-32x/modules/quanta_hwmon_ipmi.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#define __TO_R_EXP(bacc) (int32_t)(tos32(((BSWAP_32(bacc) & 0xf0) >> 4), 4))
2929
#define __TO_B_EXP(bacc) (int32_t)(tos32((BSWAP_32(bacc) & 0xf), 4))
3030

31-
#define SENSOR_ATTR_MAX 19
31+
#define SENSOR_ATTR_MAX 20
3232
#define SENSOR_ATTR_NAME_LENGTH 20
3333

3434
#define SENSOR_GET_CAP_LABEL 0x001
@@ -55,6 +55,7 @@
5555
#define SENSOR_GET_CAP_MFRID 0x10000
5656
#define SENSOR_GET_CAP_VIN_TYPE 0x20000
5757
#define SENSOR_GET_CAP_POUT_MAX 0x40000
58+
#define SENSOR_GET_CAP_HW_REV 0x80000
5859

5960
#define SDR_SENSOR_TYPE_TEMP 0x01
6061
#define SDR_SENSOR_TYPE_VOLT 0x02
@@ -1013,6 +1014,7 @@ void ipmi_sdr_set_sensor_factor(uint8_t idx,
10131014
g_sensor_data[idx].capability |= SENSOR_GET_CAP_PSU_PRESENT;
10141015
g_sensor_data[idx].capability |= SENSOR_GET_CAP_VIN_TYPE;
10151016
g_sensor_data[idx].capability |= SENSOR_GET_CAP_POUT_MAX;
1017+
g_sensor_data[idx].capability |= SENSOR_GET_CAP_HW_REV;
10161018
}
10171019
sprintf(g_sensor_data[idx].attrinfo.attr_type_str, "power");
10181020
}
@@ -1424,6 +1426,13 @@ static ssize_t show_model(struct device *dev, struct device_attribute *devattr,
14241426
return ipmi_get_psu_info(attr->index + DEBUGUSE_SHIFT, 0x9a, buf);
14251427
}
14261428

1429+
static ssize_t show_hw_rev(struct device *dev, struct device_attribute *devattr,
1430+
char *buf)
1431+
{
1432+
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
1433+
return ipmi_get_psu_info(attr->index + DEBUGUSE_SHIFT, 0x9b, buf);
1434+
}
1435+
14271436
static ssize_t show_sn(struct device *dev, struct device_attribute *devattr,
14281437
char *buf)
14291438
{
@@ -1559,7 +1568,7 @@ static ssize_t(*const attr_show_func_ptr[SENSOR_ATTR_MAX])(struct device *dev,
15591568
, show_model, show_sn, show_pwm
15601569
, show_controlmode, show_direction, show_fanpresent
15611570
, show_psupresent, show_mfrid, show_vin_type
1562-
, show_pout_max
1571+
, show_pout_max, show_hw_rev
15631572
};
15641573

15651574
static ssize_t(*const attr_store_func_ptr[SENSOR_ATTR_MAX])(struct device *dev,
@@ -1571,7 +1580,7 @@ static ssize_t(*const attr_store_func_ptr[SENSOR_ATTR_MAX])(struct device *dev,
15711580
, NULL, NULL, store_pwm
15721581
, store_controlmode, NULL, NULL
15731582
, NULL, NULL, NULL
1574-
, NULL
1583+
, NULL, NULL
15751584
};
15761585

15771586
static const char *const sensor_attrnames[SENSOR_ATTR_MAX] =
@@ -1582,7 +1591,7 @@ static const char *const sensor_attrnames[SENSOR_ATTR_MAX] =
15821591
, "%s%d_model", "%s%d_sn", "%s%d_pwm"
15831592
, "%s%d_controlmode", "%s%d_direction", "%s%d_present"
15841593
, "%s%d_present", "%s%d_mfrid", "%s%d_vin_type"
1585-
, "%s%d_pout_max"
1594+
, "%s%d_pout_max", "%s%d_hw_rev"
15861595
};
15871596

15881597
static int32_t create_sensor_attrs(int32_t attr_no)

platform/broadcom/sonic-platform-modules-quanta/ix7-32x/sonic_platform/component.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,94 @@ def __init__(self):
2727
def get_name(self):
2828
return self.name
2929

30+
def get_model(self):
31+
"""
32+
Retrieves the part number of the component
33+
Returns:
34+
string: Part number of component
35+
"""
36+
return 'N/A'
37+
38+
def get_serial(self):
39+
"""
40+
Retrieves the serial number of the component
41+
Returns:
42+
string: Serial number of component
43+
"""
44+
return 'N/A'
45+
46+
def get_presence(self):
47+
"""
48+
Retrieves the presence of the component
49+
Returns:
50+
bool: True if present, False if not
51+
"""
52+
return True
53+
54+
def get_status(self):
55+
"""
56+
Retrieves the operational status of the component
57+
Returns:
58+
bool: True if component is operating properly, False if not
59+
"""
60+
return True
61+
62+
def get_position_in_parent(self):
63+
"""
64+
Retrieves 1-based relative physical position in parent device.
65+
Returns:
66+
integer: The 1-based relative physical position in parent
67+
device or -1 if cannot determine the position
68+
"""
69+
return -1
70+
71+
def is_replaceable(self):
72+
"""
73+
Indicate whether component is replaceable.
74+
Returns:
75+
bool: True if it is replaceable.
76+
"""
77+
return False
78+
3079
def get_description(self):
3180
return self.description
3281

82+
def get_available_firmware_version(self, image_path):
83+
"""
84+
Retrieves the available firmware version of the component
85+
Note: the firmware version will be read from image
86+
Args:
87+
image_path: A string, path to firmware image
88+
Returns:
89+
A string containing the available firmware version of the component
90+
"""
91+
return "N/A"
92+
93+
def get_firmware_update_notification(self, image_path):
94+
"""
95+
Retrieves a notification on what should be done in order to complete
96+
the component firmware update
97+
Args:
98+
image_path: A string, path to firmware image
99+
Returns:
100+
A string containing the component firmware update notification if required.
101+
By default 'None' value will be used, which indicates that no actions are required
102+
"""
103+
return "None"
104+
105+
def update_firmware(self, image_path):
106+
"""
107+
Updates firmware of the component
108+
This API performs firmware update: it assumes firmware installation and loading in a single call.
109+
In case platform component requires some extra steps (apart from calling Low Level Utility)
110+
to load the installed firmware (e.g, reboot, power cycle, etc.) - this will be done automatically by API
111+
Args:
112+
image_path: A string, path to firmware image
113+
Raises:
114+
RuntimeError: update failed
115+
"""
116+
return False
117+
33118
def install_firmware(self, image_path):
34119
"""
35120
Installs firmware to the component

platform/broadcom/sonic-platform-modules-quanta/ix7-32x/sonic_platform/fan_drawer.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ def get_presence(self):
3838
"""
3939
return self._fan_list[0].get_presence()
4040

41+
def get_model(self):
42+
"""
43+
Retrieves the part number of the component
44+
Returns:
45+
string: Part number of component
46+
"""
47+
return 'N/A'
48+
49+
def get_serial(self):
50+
"""
51+
Retrieves the serial number of the component
52+
Returns:
53+
string: Serial number of component
54+
"""
55+
return 'N/A'
56+
4157
def get_status(self):
4258
"""
4359
Retrieves the operational status of the device
@@ -88,4 +104,13 @@ def get_status_led(self):
88104
else:
89105
return self.STATUS_LED_COLOR_RED
90106
else:
91-
return self.STATUS_LED_COLOR_OFF
107+
return self.STATUS_LED_COLOR_OFF
108+
109+
def get_maximum_consumed_power(self):
110+
"""
111+
Retrives the maximum power drawn by Fan Drawer
112+
Returns:
113+
A float, with value of the maximum consumable power of the
114+
component.
115+
"""
116+
return 0.0

platform/broadcom/sonic-platform-modules-quanta/ix7-32x/sonic_platform/psu.py

Lines changed: 106 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,29 @@ def __init__(self, index):
4646
1:46,
4747
2:56,
4848
}
49+
self.psu_temp_index_mapping = {
50+
1:43,
51+
2:53,
52+
}
4953
self.index = index
5054
self.psu_presence_attr = "power{}_present".format(self.psu_index_mapping[self.index])
5155
self.psu_status_attr = "curr{}_input".format(self.psu_currentout_index_mapping[self.index])
5256
self.psu_power_in_attr = "power{}_input".format(self.psu_powerin_index_mapping[self.index])
5357
self.psu_power_out_attr = "power{}_input".format(self.psu_index_mapping[self.index])
5458
self.psu_voltage_out_attr = "in{}_input".format(self.psu_voltageout_index_mapping[self.index])
59+
self.psu_vout_high_th_attr= "in{}_ncrit".format(self.psu_voltageout_index_mapping[self.index])
60+
self.psu_vout_low_th_attr = "in{}_lncrit".format(self.psu_voltageout_index_mapping[self.index])
5561
self.psu_current_out_attr = "curr{}_input".format(self.psu_currentout_index_mapping[self.index])
56-
self.psu_voltage_in_attr = "in{}_input".format(self.psu_voltagein_index_mapping[self.index])
57-
self.psu_current_in_attr = "curr{}_input".format(self.psu_currentin_index_mapping[self.index])
62+
self.psu_voltage_in_attr = "in{}_input".format(self.psu_voltagein_index_mapping[self.index])
63+
self.psu_current_in_attr = "curr{}_input".format(self.psu_currentin_index_mapping[self.index])
5864
self.psu_serial_attr = "power{}_sn".format(self.psu_index_mapping[self.index])
5965
self.psu_model_attr = "power{}_model".format(self.psu_index_mapping[self.index])
6066
self.psu_mfr_id_attr = "power{}_mfrid".format(self.psu_index_mapping[self.index])
6167
self.psu_capacity_attr = "power{}_pout_max".format(self.psu_index_mapping[self.index])
6268
self.psu_type_attr = "power{}_vin_type".format(self.psu_index_mapping[self.index])
69+
self.psu_revision_attr = "power{}_hw_rev".format(self.psu_index_mapping[self.index])
70+
self.psu_temp_attr = "temp{}_input".format(self.psu_temp_index_mapping[self.index])
71+
self.psu_temp_high_th_attr= "temp{}_ncrit".format(self.psu_temp_index_mapping[self.index])
6372

6473
def __get_attr_value(self, attr_path):
6574

@@ -154,6 +163,29 @@ def get_serial(self):
154163

155164
return serial
156165

166+
def get_revision(self):
167+
"""
168+
Retrives thehardware revision of the device
169+
Returns:
170+
String: revision value of device
171+
"""
172+
revision = "N/A"
173+
attr_path = HWMON_DIR+self.psu_revision_attr
174+
175+
attr_rv = self.__get_attr_value(attr_path)
176+
if (attr_rv != 'ERR'):
177+
revision = attr_rv
178+
179+
return revision
180+
181+
def is_replaceable(self):
182+
"""
183+
Indicate whether this PSU is replaceable.
184+
Returns:
185+
bool: True if it is replaceable.
186+
"""
187+
return True
188+
157189
def get_status(self):
158190
"""
159191
Retrieves the operational status of the device
@@ -194,6 +226,34 @@ def get_voltage(self):
194226

195227
return voltage_out
196228

229+
def get_voltage_low_threshold(self):
230+
"""
231+
Returns PSU low threshold in Volts
232+
"""
233+
vout_low_th = 0.0
234+
attr_path = HWMON_DIR+self.psu_vout_low_th_attr
235+
236+
attr_rv = self.__get_attr_value(attr_path)
237+
if (attr_rv != 'ERR'):
238+
attr_rv, dummy = attr_rv.split('.', 1)
239+
vout_low_th = float(attr_rv) / 1000
240+
241+
return vout_low_th
242+
243+
def get_voltage_high_threshold(self):
244+
"""
245+
Returns PSU high threshold in Volts
246+
"""
247+
vout_high_th = 0.0
248+
attr_path = HWMON_DIR+self.psu_vout_high_th_attr
249+
250+
attr_rv = self.__get_attr_value(attr_path)
251+
if (attr_rv != 'ERR'):
252+
attr_rv, dummy = attr_rv.split('.', 1)
253+
vout_high_th = float(attr_rv) / 1000
254+
255+
return vout_high_th
256+
197257
def get_current(self):
198258
"""
199259
Retrieves present electric current supplied by PSU
@@ -259,7 +319,7 @@ def get_power(self):
259319
attr_rv = self.__get_attr_value(attr_path)
260320
if (attr_rv != 'ERR'):
261321
attr_rv, dummy = attr_rv.split('.', 1)
262-
power_out = float(attr_rv) / 1000
322+
power_out = float(attr_rv) / 1000.0
263323

264324
return power_out
265325

@@ -300,21 +360,58 @@ def get_type(self):
300360

301361
return type
302362

303-
def get_capacity(self):
363+
def get_position_in_parent(self):
304364
"""
305-
Gets the capacity (maximum output power) of the PSU in watts
365+
Retrieves 1-based relative physical position in parent device.
366+
Returns:
367+
integer: The 1-based relative physical position in parent
368+
device or -1 if cannot determine the position
369+
"""
370+
return self.index
306371

372+
def get_maximum_supplied_power(self):
373+
"""
374+
Retrieves the maximum supplied power by PSU
307375
Returns:
308-
An integer, the capacity of PSU
376+
A float number, the maximum power output in Watts.
377+
e.g. 1200.1
309378
"""
310-
capacity = 0
379+
capacity = 0.0
311380
attr_path = HWMON_DIR+self.psu_capacity_attr
312381
attr_rv = self.__get_attr_value(attr_path)
313382
if (attr_rv != 'ERR'):
314383
try:
315-
capacity = int(attr_rv)
384+
capacity = float(attr_rv)
316385
except ValueError:
317-
capacity = 0
386+
capacity = 0.0
318387

319388
return capacity
320389

390+
def get_temperature(self):
391+
"""
392+
Retrieves current temperature reading from PSU
393+
Returns:
394+
A float number of current temperature in Celsius up to nearest thousandth
395+
of one degree Celsius, e.g. 30.125
396+
"""
397+
398+
tout = 0.0
399+
attr_path = HWMON_DIR+self.psu_temp_attr
400+
attr_rv = self.__get_attr_value(attr_path)
401+
if (attr_rv != 'ERR'):
402+
tout = float(attr_rv)/1000.0
403+
404+
# tout is in milli degree celcius
405+
return tout
406+
407+
def get_temperature_high_threshold(self):
408+
"""
409+
Returns the high temperature threshold for PSU in Celsius
410+
"""
411+
attr_path = HWMON_DIR+self.psu_temp_high_th_attr
412+
attr_rv = self.__get_attr_value(attr_path)
413+
414+
if (attr_rv != 'ERR'):
415+
return float(attr_rv) / 1000
416+
else:
417+
return None

0 commit comments

Comments
 (0)