From fa1b7807c7d4f2599c8f35a6bc3a3131dc1529e8 Mon Sep 17 00:00:00 2001 From: jostar-yang Date: Wed, 15 Feb 2023 11:43:33 +0800 Subject: [PATCH 01/14] [Edgecore][AS7326/PDDF] Enhance pddf feature Signed-off-by: jostar-yang --- .../x86_64-accton_as7326_56x-r0/pcie.yaml | 459 +++++++++++++ .../pddf/pd-plugin.json | 6 +- .../pddf/pddf-device.json | 42 +- .../x86_64-accton_as7326_56x-r0/platform.json | 600 +++++++++++++++++ .../pmon_daemon_control.json | 3 +- .../sonic_platform/__init__.py | 2 - .../sonic_platform/chassis.py | 264 -------- .../sonic_platform/eeprom.py | 139 ---- .../sonic_platform/fan.py | 270 -------- .../sonic_platform/fan_drawer.py | 90 --- .../sonic_platform/psu.py | 264 -------- .../sonic_platform/sfp.py | 625 ------------------ .../sonic_platform/thermal.py | 232 ------- .../as7326-56x/sonic_platform/chassis.py | 94 +-- .../as7326-56x}/sonic_platform/component.py | 51 +- .../as7326-56x/sonic_platform/eeprom.py | 76 ++- .../as7326-56x}/sonic_platform/event.py | 4 +- .../as7326-56x/sonic_platform/fan.py | 35 +- .../as7326-56x/sonic_platform/fan_drawer.py | 25 + .../as7326-56x/sonic_platform/helper.py | 53 ++ .../as7326-56x/sonic_platform/pcie.py | 16 +- .../as7326-56x/sonic_platform/psu.py | 12 + .../as7326-56x/sonic_platform/sfp.py | 38 ++ .../as7326-56x/sonic_platform/thermal.py | 20 + .../utils/accton_as7326_pddf_monitor.py | 32 + .../utils/pddf_post_device_create.sh | 12 - 26 files changed, 1464 insertions(+), 2000 deletions(-) create mode 100644 device/accton/x86_64-accton_as7326_56x-r0/pcie.yaml create mode 100644 device/accton/x86_64-accton_as7326_56x-r0/platform.json delete mode 100644 device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/__init__.py delete mode 100644 device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/chassis.py delete mode 100644 device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/eeprom.py delete mode 100644 device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan.py delete mode 100644 device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan_drawer.py delete mode 100644 device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/psu.py delete mode 100644 device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/sfp.py delete mode 100644 device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/thermal.py rename {device/accton/x86_64-accton_as7326_56x-r0 => platform/broadcom/sonic-platform-modules-accton/as7326-56x}/sonic_platform/component.py (79%) rename {device/accton/x86_64-accton_as7326_56x-r0 => platform/broadcom/sonic-platform-modules-accton/as7326-56x}/sonic_platform/event.py (94%) create mode 100644 platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/helper.py rename device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/platform.py => platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/pcie.py (51%) delete mode 100755 platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/pddf_post_device_create.sh diff --git a/device/accton/x86_64-accton_as7326_56x-r0/pcie.yaml b/device/accton/x86_64-accton_as7326_56x-r0/pcie.yaml new file mode 100644 index 000000000000..af10930e3e0c --- /dev/null +++ b/device/accton/x86_64-accton_as7326_56x-r0/pcie.yaml @@ -0,0 +1,459 @@ +- bus: '00' + dev: '00' + fn: '0' + id: 6f00 + name: 'Host bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D DMI2 + (rev 03)' +- bus: '00' + dev: '01' + fn: '0' + id: 6f02 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 1 (rev 03)' +- bus: '00' + dev: '01' + fn: '1' + id: 6f03 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 1 (rev 03)' +- bus: '00' + dev: '02' + fn: '0' + id: 6f04 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 2 (rev 03)' +- bus: '00' + dev: '02' + fn: '1' + id: 6f05 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 2 (rev 03)' +- bus: '00' + dev: '02' + fn: '2' + id: 6f06 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 2 (rev 03)' +- bus: '00' + dev: '02' + fn: '3' + id: 6f07 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 2 (rev 03)' +- bus: '00' + dev: '03' + fn: '0' + id: 6f08 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 3 (rev 03)' +- bus: '00' + dev: '03' + fn: '1' + id: 6f09 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 3 (rev 03)' +- bus: '00' + dev: '03' + fn: '2' + id: 6f0a + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 3 (rev 03)' +- bus: '00' + dev: '03' + fn: '3' + id: 6f0b + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 3 (rev 03)' +- bus: '00' + dev: '05' + fn: '0' + id: 6f28 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Map/VTd_Misc/System Management (rev 03)' +- bus: '00' + dev: '05' + fn: '1' + id: 6f29 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D IIO Hot Plug (rev 03)' +- bus: '00' + dev: '05' + fn: '2' + id: 6f2a + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D IIO RAS/Control Status/Global Errors (rev 03)' +- bus: '00' + dev: '05' + fn: '4' + id: 6f2c + name: 'PIC: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D I/O APIC (rev + 03)' +- bus: '00' + dev: '14' + fn: '0' + id: 8c31 + name: 'USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB + xHCI (rev 05)' +- bus: '00' + dev: 1c + fn: '0' + id: 8c10 + name: 'PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express + Root Port #1 (rev d5)' +- bus: '00' + dev: 1c + fn: '1' + id: 8c12 + name: 'PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express + Root Port #2 (rev d5)' +- bus: '00' + dev: 1d + fn: '0' + id: 8c26 + name: 'USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB + EHCI #1 (rev 05)' +- bus: '00' + dev: 1f + fn: '0' + id: 8c54 + name: 'ISA bridge: Intel Corporation C224 Series Chipset Family Server Standard + SKU LPC Controller (rev 05)' +- bus: '00' + dev: 1f + fn: '2' + id: 8c02 + name: 'SATA controller: Intel Corporation 8 Series/C220 Series Chipset Family 6-port + SATA Controller 1 [AHCI mode] (rev 05)' +- bus: '00' + dev: 1f + fn: '3' + id: 8c22 + name: 'SMBus: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller + (rev 05)' +- bus: '00' + dev: 1f + fn: '6' + id: 8c24 + name: 'Signal processing controller: Intel Corporation 8 Series Chipset Family Thermal + Management Controller (rev 05)' +- bus: '03' + dev: '00' + fn: '0' + id: 6f50 + name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology + Register DMA Channel 0' +- bus: '03' + dev: '00' + fn: '1' + id: 6f51 + name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology + Register DMA Channel 1' +- bus: '03' + dev: '00' + fn: '2' + id: 6f52 + name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology + Register DMA Channel 2' +- bus: '03' + dev: '00' + fn: '3' + id: 6f53 + name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology + Register DMA Channel 3' +- bus: '05' + dev: '00' + fn: '0' + id: 15ab + name: 'Ethernet controller: Intel Corporation Ethernet Connection X552 10 GbE Backplane' +- bus: '05' + dev: '00' + fn: '1' + id: 15ab + name: 'Ethernet controller: Intel Corporation Ethernet Connection X552 10 GbE Backplane' +- bus: '07' + dev: '00' + fn: '0' + id: b873 + name: 'Ethernet controller: Broadcom Inc. and subsidiaries Device b873 (rev 01)' +- bus: 0b + dev: '00' + fn: '0' + id: 165f + name: 'Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme BCM5720 2-port + Gigabit Ethernet PCIe' +- bus: ff + dev: 0b + fn: '0' + id: 6f81 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R3 QPI Link 0/1 (rev 03)' +- bus: ff + dev: 0b + fn: '1' + id: 6f36 + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R3 QPI Link 0/1 (rev 03)' +- bus: ff + dev: 0b + fn: '2' + id: 6f37 + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R3 QPI Link 0/1 (rev 03)' +- bus: ff + dev: 0b + fn: '3' + id: 6f76 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R3 QPI Link Debug (rev 03)' +- bus: ff + dev: 0c + fn: '0' + id: 6fe0 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0c + fn: '1' + id: 6fe1 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0c + fn: '2' + id: 6fe2 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0c + fn: '3' + id: 6fe3 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0f + fn: '0' + id: 6ff8 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0f + fn: '4' + id: 6ffc + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0f + fn: '5' + id: 6ffd + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0f + fn: '6' + id: 6ffe + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: '10' + fn: '0' + id: 6f1d + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R2PCIe Agent (rev 03)' +- bus: ff + dev: '10' + fn: '1' + id: 6f34 + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R2PCIe Agent (rev 03)' +- bus: ff + dev: '10' + fn: '5' + id: 6f1e + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Ubox (rev 03)' +- bus: ff + dev: '10' + fn: '6' + id: 6f7d + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Ubox (rev 03)' +- bus: ff + dev: '10' + fn: '7' + id: 6f1f + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Ubox (rev 03)' +- bus: ff + dev: '12' + fn: '0' + id: 6fa0 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Home Agent 0 (rev 03)' +- bus: ff + dev: '12' + fn: '1' + id: 6f30 + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Home Agent 0 (rev 03)' +- bus: ff + dev: '13' + fn: '0' + id: 6fa8 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Target Address/Thermal/RAS (rev 03)' +- bus: ff + dev: '13' + fn: '1' + id: 6f71 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Target Address/Thermal/RAS (rev 03)' +- bus: ff + dev: '13' + fn: '2' + id: 6faa + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel Target Address Decoder (rev 03)' +- bus: ff + dev: '13' + fn: '3' + id: 6fab + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel Target Address Decoder (rev 03)' +- bus: ff + dev: '13' + fn: '4' + id: 6fac + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel Target Address Decoder (rev 03)' +- bus: ff + dev: '13' + fn: '5' + id: 6fad + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel Target Address Decoder (rev 03)' +- bus: ff + dev: '13' + fn: '6' + id: 6fae + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Broadcast (rev 03)' +- bus: ff + dev: '13' + fn: '7' + id: 6faf + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Global Broadcast (rev 03)' +- bus: ff + dev: '14' + fn: '0' + id: 6fb0 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 0 Thermal Control (rev 03)' +- bus: ff + dev: '14' + fn: '1' + id: 6fb1 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 1 Thermal Control (rev 03)' +- bus: ff + dev: '14' + fn: '2' + id: 6fb2 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 0 Error (rev 03)' +- bus: ff + dev: '14' + fn: '3' + id: 6fb3 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 1 Error (rev 03)' +- bus: ff + dev: '14' + fn: '4' + id: 6fbc + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Interface (rev 03)' +- bus: ff + dev: '14' + fn: '5' + id: 6fbd + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Interface (rev 03)' +- bus: ff + dev: '14' + fn: '6' + id: 6fbe + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Interface (rev 03)' +- bus: ff + dev: '14' + fn: '7' + id: 6fbf + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Interface (rev 03)' +- bus: ff + dev: '15' + fn: '0' + id: 6fb4 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 2 Thermal Control (rev 03)' +- bus: ff + dev: '15' + fn: '1' + id: 6fb5 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 3 Thermal Control (rev 03)' +- bus: ff + dev: '15' + fn: '2' + id: 6fb6 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 2 Error (rev 03)' +- bus: ff + dev: '15' + fn: '3' + id: 6fb7 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 3 Error (rev 03)' +- bus: ff + dev: 1e + fn: '0' + id: 6f98 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1e + fn: '1' + id: 6f99 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1e + fn: '2' + id: 6f9a + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1e + fn: '3' + id: 6fc0 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1e + fn: '4' + id: 6f9c + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1f + fn: '0' + id: 6f88 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1f + fn: '2' + id: 6f8a + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' diff --git a/device/accton/x86_64-accton_as7326_56x-r0/pddf/pd-plugin.json b/device/accton/x86_64-accton_as7326_56x-r0/pddf/pd-plugin.json index 317cf23b7362..aacab4674fc4 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/pddf/pd-plugin.json +++ b/device/accton/x86_64-accton_as7326_56x-r0/pddf/pd-plugin.json @@ -34,7 +34,7 @@ { "i2c": { - "valmap": { "F2B":"EXHAUST", "B2F":"INTAKE" } + "valmap": { "F2B":"exhaust", "B2F":"intake" } } }, @@ -47,7 +47,7 @@ { "i2c": { - "valmap": {"1":"INTAKE", "0":"EXHAUST"} + "valmap": {"1":"intake", "0":"exhaust"} } }, @@ -61,7 +61,7 @@ "duty_cycle_to_pwm": "lambda dc: ((dc*100)/625 -1)", - "pwm_to_duty_cycle": "lambda pwm: (((pwm+1)*625+75)/100)" + "pwm_to_duty_cycle": "lambda pwm: (((pwm+1)*625)/100)" } } diff --git a/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json b/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json index 857b4e1c4c8d..3cb36d423757 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json +++ b/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json @@ -207,7 +207,10 @@ { "attr_name":"psu_i_out", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_p_out", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_fan1_speed_rpm", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x90", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, - { "attr_name":"psu_temp1_input", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} + { "attr_name":"psu_temp1_input", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out_min", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xa4", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out_max", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xa5", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_temp1_high_threshold", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xa8", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} ] } }, @@ -256,7 +259,10 @@ { "attr_name":"psu_i_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_p_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_fan1_speed_rpm", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x90", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, - { "attr_name":"psu_temp1_input", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} + { "attr_name":"psu_temp1_input", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out_min", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0xa4", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_v_out_max", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0xa5", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_temp1_high_threshold", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0xa8", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"} ] } }, @@ -2911,36 +2917,36 @@ "LOC_LED": { "dev_info": { "device_type":"LED", "device_name":"LOC_LED"}, - "dev_attr": { "index":"0"}, + "dev_attr": { "index":"0", "flag": "rw"}, "i2c" : { "attr_list": [ - {"attr_name":"STATUS_LED_COLOR_BLUE_BLINK", "descr": "" , "bits" : "5:0", "value" : "0x27", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, - {"attr_name":"STATUS_LED_COLOR_GREEN_BLINK", "descr": "" , "bits" : "5:0", "value" : "0x17", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, - {"attr_name":"STATUS_LED_COLOR_AMBER_BLINK", "descr": "" , "bits" : "5:0", "value" : "0xf", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, - {"attr_name":"STATUS_LED_COLOR_BLUE", "descr": "" , "bits" : "5:0", "value" : "0x3", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, - {"attr_name":"STATUS_LED_COLOR_GREEN", "descr": "" , "bits" : "5:0", "value" : "0x5", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, - {"attr_name":"STATUS_LED_COLOR_AMBER", "descr": "" , "bits" : "5:0", "value" : "0x6", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, - {"attr_name":"STATUS_LED_COLOR_OFF", "descr": "" , "bits" : "5:0", "value" : "0xf", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"} + {"attr_name":"blue_blink", "descr": "" , "bits" : "5:0", "value" : "0x27", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, + {"attr_name":"green_blink", "descr": "" , "bits" : "5:0", "value" : "0x17", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, + {"attr_name":"amber_blink", "descr": "" , "bits" : "5:0", "value" : "0xf", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, + {"attr_name":"blue", "descr": "" , "bits" : "5:0", "value" : "0x3", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, + {"attr_name":"green", "descr": "" , "bits" : "5:0", "value" : "0x5", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, + {"attr_name":"amber", "descr": "" , "bits" : "5:0", "value" : "0x6", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"}, + {"attr_name":"off", "descr": "" , "bits" : "5:0", "value" : "0xf", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x25"} ] } }, "DIAG_LED": { "dev_info": { "device_type":"LED", "device_name":"DIAG_LED"}, - "dev_attr": { "index":"0"}, + "dev_attr": { "index":"0", "flag": "rw"}, "i2c" : { "attr_list": [ - {"attr_name":"STATUS_LED_COLOR_BLUE_BLINK", "descr": "" , "bits" : "5:0", "value" : "0x27", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, - {"attr_name":"STATUS_LED_COLOR_GREEN_BLINK", "descr": "" , "bits" : "5:0", "value" : "0x17", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, - {"attr_name":"STATUS_LED_COLOR_AMBER_BLINK", "descr": "" , "bits" : "5:0", "value" : "0xf", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, - {"attr_name":"STATUS_LED_COLOR_BLUE", "descr": "" , "bits" : "5:0", "value" : "0x3", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, - {"attr_name":"STATUS_LED_COLOR_GREEN", "descr": "" , "bits" : "5:0", "value" : "0x5", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, - {"attr_name":"STATUS_LED_COLOR_AMBER", "descr": "" , "bits" : "5:0", "value" : "0x6", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, - {"attr_name":"STATUS_LED_COLOR_OFF", "descr": "" , "bits" : "5:0", "value" : "0x7", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"} + {"attr_name":"blue_blink", "descr": "" , "bits" : "5:0", "value" : "0x27", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, + {"attr_name":"green_blink", "descr": "" , "bits" : "5:0", "value" : "0x17", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, + {"attr_name":"amber_blink", "descr": "" , "bits" : "5:0", "value" : "0xf", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, + {"attr_name":"blue", "descr": "" , "bits" : "5:0", "value" : "0x3", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, + {"attr_name":"green", "descr": "" , "bits" : "5:0", "value" : "0x5", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, + {"attr_name":"amber", "descr": "" , "bits" : "5:0", "value" : "0x6", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"}, + {"attr_name":"off", "descr": "" , "bits" : "5:0", "value" : "0x7", "swpld_addr" : "0x60", "swpld_addr_offset" : "0x24"} ] } diff --git a/device/accton/x86_64-accton_as7326_56x-r0/platform.json b/device/accton/x86_64-accton_as7326_56x-r0/platform.json new file mode 100644 index 000000000000..29a825ad27e9 --- /dev/null +++ b/device/accton/x86_64-accton_as7326_56x-r0/platform.json @@ -0,0 +1,600 @@ +{ + "chassis": { + "name": "7326-56X", + "components": [ + { + "name": "MB_CPLD1" + }, + { + "name": "MB_CPLD2" + }, + { + "name": "MB_CPLD3" + }, + { + "name": "FAN_CPLD" + }, + { + "name": "CPU_CPLD" + }, + { + "name": "BIOS" + } + ], + "fans": [ + { + "name": "FAN-1F" + }, + { + "name": "FAN-1R" + }, + { + "name": "FAN-2F" + }, + { + "name": "FAN-2R" + }, + { + "name": "FAN-3F" + }, + { + "name": "FAN-3R" + }, + { + "name": "FAN-4F" + }, + { + "name": "FAN-4R" + }, + { + "name": "FAN-5F" + }, + { + "name": "FAN-5R" + }, + { + "name": "FAN-6F" + }, + { + "name": "FAN-6R" + } + ], + "fan_drawers":[ + { + "name": "FanTray1", + "num_fans" : 2, + "fans": [ + { + "name": "FAN-1F" + }, + { + "name": "FAN-1R" + } + ] + }, + { + "name": "FanTray2", + "num_fans" : 2, + "fans": [ + { + "name": "FAN-2F" + }, + { + "name": "FAN-2R" + } + ] + }, + { + "name": "FanTray3", + "num_fans" : 2, + "fans": [ + { + "name": "FAN-3F" + }, + { + "name": "FAN-3R" + } + ] + }, + { + "name": "FanTray4", + "num_fans" : 2, + "fans": [ + { + "name": "FAN-4F" + }, + { + "name": "FAN-4R" + } + ] + }, + { + "name": "FanTray5", + "num_fans" : 2, + "fans": [ + { + "name": "FAN-5F" + }, + { + "name": "FAN-5R" + } + ] + }, + { + "name": "FanTray6", + "num_fans" : 2, + "fans": [ + { + "name": "FAN-6F" + }, + { + "name": "FAN-6R" + } + ] + } + ], + "psus": [ + { + "name": "PSU-1", + "fans": [ + { + "name": "PSU-1 FAN-1" + } + ], + "thermals": [ + { + "name": "PSU-1 temp sensor 1", + "controllable": false, + "low-threshold": false, + "high-threshold": false, + "low-crit-threshold": false, + "high-crit-threshold": false + } + ], + "temperature": true, + "temperature_high_threshold": true + }, + { + "name": "PSU-2", + "fans": [ + { + "name": "PSU-2 FAN-1" + } + ], + "thermals": [ + { + "name": "PSU-2 temp sensor 1", + "controllable": false, + "low-threshold": false, + "high-threshold": false, + "low-crit-threshold": false, + "high-crit-threshold": false + } + ], + "temperature": true, + "temperature_high_threshold": true + } + ], + "thermals": [ + { + "name": "CB_temp(0x4B)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": true + }, + { + "name": "MB_FrontMAC_temp(0x49)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": true + }, + { + "name": "MB_LeftCenter_temp(0x4A)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": true + }, + { + "name": "MB_RearMAC_temp(0x48)", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": true + }, + { + "name": "CPU Temp", + "controllable": true, + "low-threshold": false, + "high-threshold": true, + "low-crit-threshold": false, + "high-crit-threshold": true + } + ], + "sfps": [ + { + "name": "Ethernet0" + }, + { + "name": "Ethernet1" + }, + { + "name": "Ethernet2" + }, + { + "name": "Ethernet3" + }, + { + "name": "Ethernet4" + }, + { + "name": "Ethernet5" + }, + { + "name": "Ethernet6" + }, + { + "name": "Ethernet7" + }, + { + "name": "Ethernet8" + }, + { + "name": "Ethernet9" + }, + { + "name": "Ethernet10" + }, + { + "name": "Ethernet11" + }, + { + "name": "Ethernet12" + }, + { + "name": "Ethernet13" + }, + { + "name": "Ethernet14" + }, + { + "name": "Ethernet15" + }, + { + "name": "Ethernet16" + }, + { + "name": "Ethernet17" + }, + { + "name": "Ethernet18" + }, + { + "name": "Ethernet19" + }, + { + "name": "Ethernet20" + }, + { + "name": "Ethernet21" + }, + { + "name": "Ethernet22" + }, + { + "name": "Ethernet23" + }, + { + "name": "Ethernet24" + }, + { + "name": "Ethernet25" + }, + { + "name": "Ethernet26" + }, + { + "name": "Ethernet27" + }, + { + "name": "Ethernet28" + }, + { + "name": "Ethernet29" + }, + { + "name": "Ethernet30" + }, + { + "name": "Ethernet31" + }, + { + "name": "Ethernet32" + }, + { + "name": "Ethernet33" + }, + { + "name": "Ethernet34" + }, + { + "name": "Ethernet35" + }, + { + "name": "Ethernet36" + }, + { + "name": "Ethernet37" + }, + { + "name": "Ethernet38" + }, + { + "name": "Ethernet39" + }, + { + "name": "Ethernet40" + }, + { + "name": "Ethernet41" + }, + { + "name": "Ethernet42" + }, + { + "name": "Ethernet43" + }, + { + "name": "Ethernet44" + }, + { + "name": "Ethernet45" + }, + { + "name": "Ethernet46" + }, + { + "name": "Ethernet47" + }, + { + "name": "Ethernet48" + }, + { + "name": "Ethernet52" + }, + { + "name": "Ethernet56" + }, + { + "name": "Ethernet60" + }, + { + "name": "Ethernet64" + }, + { + "name": "Ethernet68" + }, + { + "name": "Ethernet72" + }, + { + "name": "Ethernet76" + } + ] + }, + "interfaces": { + "Ethernet5": { + "index": "6,2,1,3", + "lanes": "1,2,3,4", + "breakout_modes": { + "4x25G": ["Eth6/1(Port6)", "Eth6/2(Port2)", "Eth6/3(Port1)", "Eth6/4(Port3)"], + "4x10G[1G]": ["Eth6/1(Port6)", "Eth6/2(Port2)", "Eth6/3(Port1)", "Eth6/4(Port3)"] + }, + "interface_ids": "5,1,0,2" + }, + + "Ethernet6": { + "index": "7,9,5,4", + "lanes": "5,6,7,8", + "breakout_modes": { + "4x25G": ["Eth7/1(Port7)", "Eth7/2(Port9)", "Eth7/3(Port5)", "Eth7/4(Port4)"], + "4x10G[1G]": ["Eth7/1(Port7)", "Eth7/2(Port9)", "Eth7/3(Port5)", "Eth7/4(Port4)"] + }, + "interface_ids": "6,8,4,3" + }, + + "Ethernet10": { + "index": "11,10,12,8", + "lanes": "13,14,15,16", + "breakout_modes": { + "4x25G": ["Eth11/1(Port11)", "Eth11/2(Port10)", "Eth11/3(Port12)", "Eth11/4(Port8)"], + "4x10G[1G]": ["Eth11/1(Port11)", "Eth11/2(Port10)", "Eth11/3(Port12)", "Eth11/4(Port8)"] + }, + "interface_ids": "10,9,11,7" + }, + + "Ethernet17": { + "index": "18,14,13,15", + "lanes": "21,22,23,24", + "breakout_modes": { + "4x25G": ["Eth18/1(Port18)", "Eth18/2(Port14)", "Eth18/3(Port13)", "Eth18/4(Port15)"], + "4x10G[1G]": ["Eth18/1(Port18)", "Eth18/2(Port14)", "Eth18/3(Port13)", "Eth18/4(Port15)"] + }, + "interface_ids": "17,13,12,14" + }, + + "Ethernet18": { + "index": "19,21,17,16", + "lanes": "29,30,31,32", + "breakout_modes": { + "4x25G": ["Eth19/1(Port19)", "Eth19/2(Port21)", "Eth19/3(Port17)", "Eth19/4(Port16)"], + "4x10G[1G]": ["Eth19/1(Port19)", "Eth19/2(Port21)", "Eth19/3(Port17)", "Eth19/4(Port16)"] + }, + "interface_ids": "18,20,16,15" + }, + + "Ethernet22": { + "index": "23,22,24,20", + "lanes": "33,34,35,36", + "breakout_modes": { + "4x25G": ["Eth23/1(Port23)", "Eth23/2(Port22)", "Eth23/3(Port24)", "Eth23/4(Port20)"], + "4x10G[1G]": ["Eth23/1(Port23)", "Eth23/2(Port22)", "Eth23/3(Port24)", "Eth23/4(Port20)"] + }, + "interface_ids": "22,21,23,19" + }, + + "Ethernet29": { + "index": "30,26,25,27", + "lanes": "41,42,43,44", + "breakout_modes": { + "4x25G": ["Eth30/1(Port30)", "Eth30/2(Port26)", "Eth30/3(Port25)", "Eth30/4(Port27)"], + "4x10G[1G]": ["Eth30/1(Port30)", "Eth30/2(Port26)", "Eth30/3(Port25)", "Eth30/4(Port27)"] + }, + "interface_ids": "29,25,24,26" + }, + + "Ethernet30": { + "index": "31,33,29,28", + "lanes": "49,50,51,52", + "breakout_modes": { + "4x25G": ["Eth31/1(Port31)", "Eth31/2(Port33)", "Eth31/3(Port29)", "Eth31/4(Port28)"], + "4x10G[1G]": ["Eth31/1(Port31)", "Eth31/2(Port33)", "Eth31/3(Port29)", "Eth31/4(Port28)"] + }, + "interface_ids": "30,32,28,27" + }, + + "Ethernet34": { + "index": "35,34,36,32", + "lanes": "57,58,59,60", + "breakout_modes": { + "4x25G": ["Eth35/1(Port35)", "Eth35/2(Port34)", "Eth35/3(Port36)", "Eth35/4(Port32)"], + "4x10G[1G]": ["Eth35/1(Port35)", "Eth35/2(Port34)", "Eth35/3(Port36)", "Eth35/4(Port32)"] + }, + "interface_ids": "34,33,35,31" + }, + + "Ethernet39": { + "index": "40,41,45,43", + "lanes": "65,66,67,68", + "breakout_modes": { + "4x25G": ["Eth40/1(Port40)", "Eth40/2(Port41)", "Eth40/3(Port45)", "Eth40/4(Port43)"], + "4x10G[1G]": ["Eth40/1(Port40)", "Eth40/2(Port41)", "Eth40/3(Port45)", "Eth40/4(Port43)"] + }, + "interface_ids": "39,40,44,42" + }, + + "Ethernet41": { + "index": "42,37,38,39", + "lanes": "61,62,63,64", + "breakout_modes": { + "4x25G": ["Eth42/1(Port42)", "Eth42/2(Port37)", "Eth42/3(Port38)", "Eth42/4(Port39)"], + "4x10G[1G]": ["Eth42/1(Port42)", "Eth42/2(Port37)", "Eth42/3(Port38)", "Eth42/4(Port39)"] + }, + "interface_ids": "41,36,37,38" + }, + + "Ethernet43": { + "index": "44,48,46,47", + "lanes": "69,70,71,72", + "breakout_modes": { + "4x25G": ["Eth44/1(Port44)", "Eth44/2(Port48)", "Eth44/3(Port46)", "Eth44/4(Port47)"], + "4x10G[1G]": ["Eth44/1(Port44)", "Eth44/2(Port48)", "Eth44/3(Port46)", "Eth44/4(Port47)"] + }, + "interface_ids": "43,47,45,46" + }, + + "Ethernet48": { + "index": "49,49,49,49", + "lanes": "77,78,79,80", + "breakout_modes": { + "1x100G[40G]": ["Eth49(Port49)"], + "2x50G": ["Eth49/1(Port49)", "Eth49/2(Port49)"], + "4x25G": ["Eth49/1(Port49)", "Eth49/2(Port49)", "Eth49/3(Port49)", "Eth49/4(Port49)"], + "4x10G": ["Eth49/1(Port49)", "Eth49/2(Port49)", "Eth49/3(Port49)", "Eth49/4(Port49)"] + } + }, + + "Ethernet52": { + "index": "50,50,50,50", + "lanes": "85,86,87,88", + "breakout_modes": { + "1x100G[40G]": ["Eth50(Port50)"], + "2x50G": ["Eth50/1(Port50)", "Eth50/2(Port50)"], + "4x25G": ["Eth50/1(Port50)", "Eth50/2(Port50)", "Eth50/3(Port50)", "Eth50/4(Port50)"], + "4x10G": ["Eth50/1(Port50)", "Eth50/2(Port50)", "Eth50/3(Port50)", "Eth50/4(Port50)"] + } + }, + + "Ethernet56": { + "index": "51,51,51,51", + "lanes": "93,94,95,96", + "breakout_modes": { + "1x100G[40G]": ["Eth51(Port51)"], + "2x50G": ["Eth51/1(Port51)", "Eth51/2(Port51)"], + "4x25G": ["Eth51/1(Port51)", "Eth51/2(Port51)", "Eth51/3(Port51)", "Eth51/4(Port51)"], + "4x10G": ["Eth51/1(Port51)", "Eth51/2(Port51)", "Eth51/3(Port51)", "Eth51/4(Port51)"] + } + }, + + "Ethernet60": { + "index": "52,52,52,52", + "lanes": "97,98,99,100", + "breakout_modes": { + "1x100G[40G]": ["Eth52(Port52)"], + "2x50G": ["Eth52/1(Port52)", "Eth52/2(Port52)"], + "4x25G": ["Eth52/1(Port52)", "Eth52/2(Port52)", "Eth52/3(Port52)", "Eth52/4(Port52)"], + "4x10G": ["Eth52/1(Port52)", "Eth52/2(Port52)", "Eth52/3(Port52)", "Eth52/4(Port52)"] + } + }, + + "Ethernet64": { + "index": "53,53,53,53", + "lanes": "105,106,107,108", + "breakout_modes": { + "1x100G[40G]": ["Eth53(Port53)"], + "2x50G": ["Eth53/1(Port53)", "Eth53/2(Port53)"], + "4x25G": ["Eth53/1(Port53)", "Eth53/2(Port53)", "Eth53/3(Port53)", "Eth53/4(Port53)"], + "4x10G": ["Eth53/1(Port53)", "Eth53/2(Port53)", "Eth53/3(Port53)", "Eth53/4(Port53)"] + } + }, + + "Ethernet68": { + "index": "54,54,54,54", + "lanes": "113,114,115,116", + "breakout_modes": { + "1x100G[40G]": ["Eth54(Port54)"], + "2x50G": ["Eth54/1(Port54)", "Eth54/2(Port54)"], + "4x25G": ["Eth54/1(Port54)", "Eth54/2(Port54)", "Eth54/3(Port54)", "Eth54/4(Port54)"], + "4x10G": ["Eth54/1(Port54)", "Eth54/2(Port54)", "Eth54/3(Port54)", "Eth54/4(Port54)"] + } + }, + + "Ethernet72": { + "index": "55,55,55,55", + "lanes": "121,122,123,124", + "breakout_modes": { + "1x100G[40G]": ["Eth55(Port55)"], + "2x50G": ["Eth55/1(Port55)", "Eth55/2(Port55)"], + "4x25G": ["Eth55/1(Port55)", "Eth55/2(Port55)", "Eth55/3(Port55)", "Eth55/4(Port55)"], + "4x10G": ["Eth55/1(Port55)", "Eth55/2(Port55)", "Eth55/3(Port55)", "Eth55/4(Port55)"] + } + }, + + "Ethernet76": { + "index": "56,56,56,56", + "lanes": "125,126,127,128", + "breakout_modes": { + "1x100G[40G]": ["Eth56(Port56)"], + "2x50G": ["Eth56/1(Port56)", "Eth56/2(Port56)"], + "4x25G": ["Eth56/1(Port56)", "Eth56/2(Port56)", "Eth56/3(Port56)", "Eth56/4(Port56)"], + "4x10G": ["Eth56/1(Port56)", "Eth56/2(Port56)", "Eth56/3(Port56)", "Eth56/4(Port56)"] + } + } + } +} diff --git a/device/accton/x86_64-accton_as7326_56x-r0/pmon_daemon_control.json b/device/accton/x86_64-accton_as7326_56x-r0/pmon_daemon_control.json index a3b204e20d8d..44bad6494229 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/pmon_daemon_control.json +++ b/device/accton/x86_64-accton_as7326_56x-r0/pmon_daemon_control.json @@ -1,5 +1,4 @@ { - "skip_ledd": true, - "skip_pcied": true + "skip_ledd": true } diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/__init__.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/__init__.py deleted file mode 100644 index 73a7720e8979..000000000000 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -__all__ = [ "platform", "chassis", "sfp", "eeprom", "component", "psu", "thermal", "fan", "fan_drawer" ] -from . import platform diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/chassis.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/chassis.py deleted file mode 100644 index 1c97d0e878ae..000000000000 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/chassis.py +++ /dev/null @@ -1,264 +0,0 @@ -############################################################################# -# Edgecore -# -# Module contains an implementation of SONiC Platform Base API and -# provides the Chassis information which are available in the platform -# -############################################################################# - -import sys -import subprocess - -try: - from sonic_platform_base.chassis_base import ChassisBase - from .event import SfpEvent - from sonic_py_common import device_info - -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - -NUM_FAN_TRAY = 6 -NUM_PSU = 2 -NUM_THERMAL = 4 -NUM_PORT = 58 -NUM_COMPONENT = 4 - -HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/" -PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/" -REBOOT_CAUSE_FILE = "reboot-cause.txt" -PREV_REBOOT_CAUSE_FILE = "previous-reboot-cause.txt" -HOST_CHK_CMD = ["which", "systemctl"] -SYSLED_FNODE= "/sys/class/leds/accton_as7326_56x_led::diag/brightness" -SYSLED_MODES = { - "0" : "STATUS_LED_COLOR_OFF", - "1" : "STATUS_LED_COLOR_GREEN", - "3" : "STATUS_LED_COLOR_RED", - "5" : "STATUS_LED_COLOR_GREEN_BLINK" -} - - -class Chassis(ChassisBase): - """Platform-specific Chassis class""" - - def __init__(self): - ChassisBase.__init__(self) - self.config_data = {} - (self.platform, self.hwsku) = device_info.get_platform_and_hwsku() - - self.__initialize_fan() - self.__initialize_psu() - self.__initialize_thermals() - self.__initialize_components() - self.__initialize_sfp() - self.__initialize_eeprom() - - def __initialize_sfp(self): - from sonic_platform.sfp import Sfp - for index in range(NUM_PORT): - sfp = Sfp(index) - self._sfp_list.append(sfp) - self._sfpevent = SfpEvent(self._sfp_list) - self.sfp_module_initialized = True - - def __initialize_fan(self): - from sonic_platform.fan_drawer import FanDrawer - for fant_index in range(NUM_FAN_TRAY): - fandrawer = FanDrawer(fant_index) - self._fan_drawer_list.append(fandrawer) - self._fan_list.extend(fandrawer._fan_list) - - def __initialize_psu(self): - from sonic_platform.psu import Psu - for index in range(NUM_PSU): - psu = Psu(index) - self._psu_list.append(psu) - - def __initialize_thermals(self): - from sonic_platform.thermal import Thermal - for index in range(NUM_THERMAL): - thermal = Thermal(index) - self._thermal_list.append(thermal) - - def __initialize_eeprom(self): - from sonic_platform.eeprom import Tlv - self._eeprom = Tlv() - - def __initialize_components(self): - from sonic_platform.component import Component - for index in range(NUM_COMPONENT): - component = Component(index) - self._component_list.append(component) - - def __initialize_watchdog(self): - self._watchdog = Watchdog() - - def __is_host(self): - return subprocess.call(HOST_CHK_CMD) == 0 - - def __read_txt_file(self, file_path): - try: - with open(file_path, 'r') as fd: - return fd.read().strip() - except IOError: - pass - return None - - def __write_txt_file(self, file_path, value): - try: - with open(file_path, 'w') as fd: - fd.write(str(value)) - except Exception: - return False - return True - - def get_name(self): - """ - Retrieves the name of the device - Returns: - string: The name of the device - """ - return self._eeprom.get_product_name() - - def get_presence(self): - """ - Retrieves the presence of the Chassis - Returns: - bool: True if Chassis is present, False if not - """ - return True - - def get_status(self): - """ - Retrieves the operational status of the device - Returns: - A boolean value, True if device is operating properly, False if not - """ - return True - def get_base_mac(self): - """ - Retrieves the base MAC address for the chassis - Returns: - A string containing the MAC address in the format - 'XX:XX:XX:XX:XX:XX' - """ - return self._eeprom.get_mac() - - def get_model(self): - """ - Retrieves the model number (or part number) of the device - Returns: - string: Model/part number of device - """ - return self._eeprom.get_pn() - - def get_serial(self): - """ - Retrieves the hardware serial number for the chassis - Returns: - A string containing the hardware serial number for this chassis. - """ - return self._eeprom.get_serial() - - def get_system_eeprom_info(self): - """ - Retrieves the full content of system EEPROM information for the chassis - Returns: - A dictionary where keys are the type code defined in - OCP ONIE TlvInfo EEPROM format and values are their corresponding - values. - """ - return self._eeprom.get_eeprom() - - def get_reboot_cause(self): - """ - Retrieves the cause of the previous reboot - Returns: - A tuple (string, string) where the first element is a string - containing the cause of the previous reboot. This string must be - one of the predefined strings in this class. If the first string - is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used - to pass a description of the reboot cause. - """ - description = 'None' - - reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE) if self.__is_host( - ) else (PMON_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE) - prev_reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + PREV_REBOOT_CAUSE_FILE) if self.__is_host( - ) else (PMON_REBOOT_CAUSE_PATH + PREV_REBOOT_CAUSE_FILE) - - sw_reboot_cause = self.__read_txt_file(reboot_cause_path) or "Unknown" - prev_sw_reboot_cause = self.__read_txt_file(prev_reboot_cause_path) or "Unknown" - - if sw_reboot_cause != "Unknown": - reboot_cause = self.REBOOT_CAUSE_NON_HARDWARE - description = sw_reboot_cause - elif prev_reboot_cause_path != "Unknown": - reboot_cause = self.REBOOT_CAUSE_NON_HARDWARE - description = prev_sw_reboot_cause - - return (reboot_cause, description) - - def get_change_event(self, timeout=0): - # SFP event - if not self.sfp_module_initialized: - self.__initialize_sfp() - return self._sfpevent.get_sfp_event(timeout) - - def get_sfp(self, index): - """ - Retrieves sfp represented by (1-based) index - Args: - index: An integer, the index (1-based) of the sfp to retrieve. - The index should be the sequence of a physical port in a chassis, - starting from 1. - For example, 1 for Ethernet0, 2 for Ethernet4 and so on. - Returns: - An object dervied from SfpBase representing the specified sfp - """ - sfp = None - if not self.sfp_module_initialized: - self.__initialize_sfp() - - try: - # The index will start from 1 - sfp = self._sfp_list[index-1] - except IndexError: - sys.stderr.write("SFP index {} out of range (1-{})\n".format( - index, len(self._sfp_list))) - return sfp - - def get_position_in_parent(self): - """ - Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position - for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned - Returns: - integer: The 1-based relative physical position in parent device or -1 if cannot determine the position - """ - return -1 - - def is_replaceable(self): - """ - Indicate whether this device is replaceable. - Returns: - bool: True if it is replaceable. - """ - return False - - - def initizalize_system_led(self): - return True - - def get_status_led(self): - val = self.__read_txt_file(SYSLED_FNODE) - return SYSLED_MODES[val] if val in SYSLED_MODES else "UNKNOWN" - - def set_status_led(self, color): - mode = None - for key, val in SYSLED_MODES.items(): - if val == color: - mode = key - break - if mode is None: - return False - else: - return self.__write_txt_file(SYSLED_FNODE, mode) diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/eeprom.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/eeprom.py deleted file mode 100644 index d0bffe53a279..000000000000 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/eeprom.py +++ /dev/null @@ -1,139 +0,0 @@ -try: - import os - import sys - import re - from sonic_platform_base.sonic_eeprom import eeprom_tlvinfo - if sys.version_info[0] >= 3: - from io import StringIO - else: - from cStringIO import StringIO -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - -CACHE_ROOT = '/var/cache/sonic/decode-syseeprom' -CACHE_FILE = 'syseeprom_cache' -NULL = 'N/A' - -class Tlv(eeprom_tlvinfo.TlvInfoDecoder): - - EEPROM_DECODE_HEADLINES = 6 - - def __init__(self): - #self._eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom" - exists = os.path.isfile('/sys/bus/i2c/devices/0-0056/eeprom') - if (exists is True): - self._eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom" - else: - self._eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom" - - super(Tlv, self).__init__(self._eeprom_path, 0, '', True) - self._eeprom = self._load_eeprom() - - def __parse_output(self, decode_output): - decode_output.replace('\0', '') - lines = decode_output.split('\n') - lines = lines[self.EEPROM_DECODE_HEADLINES:] - _eeprom_info_dict = dict() - - for line in lines: - try: - match = re.search('(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)([\S]+)', - line) - if match is not None: - idx = match.group(1) - value = match.group(3).rstrip('\0') - - _eeprom_info_dict[idx] = value - except Exception: - pass - - return _eeprom_info_dict - - def _load_eeprom(self): - original_stdout = sys.stdout - sys.stdout = StringIO() - try: - self.read_eeprom_db() - except Exception: - decode_output = sys.stdout.getvalue() - sys.stdout = original_stdout - return self.__parse_output(decode_output) - - status = self.check_status() - if 'ok' not in status: - return False - - if not os.path.exists(CACHE_ROOT): - try: - os.makedirs(CACHE_ROOT) - except Exception: - pass - - # - # only the eeprom classes that inherit from eeprom_base - # support caching. Others will work normally - # - try: - self.set_cache_name(os.path.join(CACHE_ROOT, CACHE_FILE)) - except Exception: - pass - - e = self.read_eeprom() - if e is None: - return 0 - - try: - self.update_cache(e) - except Exception: - pass - - self.decode_eeprom(e) - decode_output = sys.stdout.getvalue() - sys.stdout = original_stdout - - (is_valid, valid_crc) = self.is_checksum_valid(e) - if not is_valid: - return False - - return self.__parse_output(decode_output) - - def _valid_tlv(self, eeprom_data): - tlvinfo_type_codes_list = [ - self._TLV_CODE_PRODUCT_NAME, - self._TLV_CODE_PART_NUMBER, - self._TLV_CODE_SERIAL_NUMBER, - self._TLV_CODE_MAC_BASE, - self._TLV_CODE_MANUF_DATE, - self._TLV_CODE_DEVICE_VERSION, - self._TLV_CODE_LABEL_REVISION, - self._TLV_CODE_PLATFORM_NAME, - self._TLV_CODE_ONIE_VERSION, - self._TLV_CODE_MAC_SIZE, - self._TLV_CODE_MANUF_NAME, - self._TLV_CODE_MANUF_COUNTRY, - self._TLV_CODE_VENDOR_NAME, - self._TLV_CODE_DIAG_VERSION, - self._TLV_CODE_SERVICE_TAG, - self._TLV_CODE_VENDOR_EXT, - self._TLV_CODE_CRC_32 - ] - - for code in tlvinfo_type_codes_list: - code_str = "0x{:X}".format(code) - eeprom_data[code_str] = eeprom_data.get(code_str, NULL) - return eeprom_data - - def get_eeprom(self): - return self._valid_tlv(self._eeprom) - - def get_pn(self): - return self._eeprom.get('0x22', NULL) - - def get_serial(self): - return self._eeprom.get('0x23', NULL) - - def get_mac(self): - return self._eeprom.get('0x24', NULL) - - def get_product_name(self): - return self._eeprom.get('0x21', NULL) diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan.py deleted file mode 100644 index c64d953b758b..000000000000 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan.py +++ /dev/null @@ -1,270 +0,0 @@ -############################################################################# -# Edgecore -# -# Module contains an implementation of SONiC Platform Base API and -# provides the fan status which are available in the platform -# -############################################################################# - -try: - from sonic_platform_base.fan_base import FanBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - -FAN_MAX_RPM = 25500 -PSU_FAN_MAX_RPM = 25500 -SPEED_TOLERANCE = 15 -CPLD_I2C_PATH = "/sys/bus/i2c/devices/11-0066/fan" -PSU_I2C_PATH = "/sys/bus/i2c/devices/{}-00{}/" -PSU_HWMON_I2C_MAPPING = { - 0: { - "bus": 17, - "addr": "59" - }, - 1: { - "bus": 13, - "addr": "5b" - }, -} - -PSU_CPLD_I2C_MAPPING = { - 0: { - "bus": 17, - "addr": "51" - }, - 1: { - "bus": 13, - "addr": "53" - }, -} - -FAN_NAME_LIST = ["FAN-1F", "FAN-1R", "FAN-2F", "FAN-2R", - "FAN-3F", "FAN-3R", "FAN-4F", "FAN-4R", - "FAN-5F", "FAN-5R", "FAN-6F", "FAN-6R"] - -class Fan(FanBase): - """Platform-specific Fan class""" - - def __init__(self, - fan_tray_index, - fan_index=0, - is_psu_fan=False, - psu_index=0): - self.fan_index = fan_index - self.fan_tray_index = fan_tray_index - self.is_psu_fan = is_psu_fan - self.psu_index = psu_index - - if self.is_psu_fan: - psu_i2c_bus = PSU_HWMON_I2C_MAPPING[psu_index]["bus"] - psu_i2c_addr = PSU_HWMON_I2C_MAPPING[psu_index]["addr"] - self.psu_hwmon_path = PSU_I2C_PATH.format(psu_i2c_bus, - psu_i2c_addr) - psu_i2c_bus = PSU_CPLD_I2C_MAPPING[psu_index]["bus"] - psu_i2c_addr = PSU_CPLD_I2C_MAPPING[psu_index]["addr"] - self.cpld_path = PSU_I2C_PATH.format(psu_i2c_bus, psu_i2c_addr) - - FanBase.__init__(self) - - def __read_txt_file(self, file_path): - try: - with open(file_path, 'r') as fd: - return fd.read().strip() - except IOError: - pass - return "" - - def __write_txt_file(self, file_path, value): - try: - with open(file_path, 'w') as fd: - fd.write(str(value)) - except Exception: - return False - return True - - def get_direction(self): - """ - Retrieves the direction of fan - Returns: - A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST - depending on fan direction - """ - if not self.is_psu_fan: - val = self.__read_txt_file( - CPLD_I2C_PATH + str(self.fan_tray_index+1) + "_direction") - direction = self.FAN_DIRECTION_EXHAUST if ( - val == "0") else self.FAN_DIRECTION_INTAKE - else: - val = self.__read_txt_file(self.psu_hwmon_path + "psu_fan_dir") - direction = self.FAN_DIRECTION_EXHAUST if ( - val == "F2B") else self.FAN_DIRECTION_INTAKE - return direction - - def get_speed(self): - """ - Retrieves the speed of fan as a percentage of full speed - Returns: - An integer, the percentage of full fan speed, in the range 0 (off) - to 100 (full speed) - """ - speed = 0 - if self.is_psu_fan: - speed = self.__read_txt_file( - self.psu_hwmon_path + "psu_fan1_speed_rpm") - speed = (int(speed, 10)) * 100 / PSU_FAN_MAX_RPM - speed = 100 if (speed > 100) else speed - elif self.get_presence(): - speed = self.__read_txt_file(CPLD_I2C_PATH + str( - self.fan_index * 10 + self.fan_tray_index + 1) + "_input") - speed = (int(speed, 10)) * 100 / FAN_MAX_RPM - speed = 100 if (speed > 100) else speed - return int(speed) - - def get_target_speed(self): - """ - Retrieves the target (expected) speed of the fan - Returns: - An integer, the percentage of full fan speed, in the range 0 (off) - to 100 (full speed) - Note: - speed_pc = pwm_target/255*100 - 0 : when PWM mode is use - pwm : when pwm mode is not use - """ - return self.get_speed() - - def get_speed_tolerance(self): - """ - Retrieves the speed tolerance of the fan - Returns: - An integer, the percentage of variance from target speed which is - considered tolerable - """ - return SPEED_TOLERANCE - - def set_speed(self, speed): - """ - Sets the fan speed - Args: - speed: An integer, the percentage of full fan speed to set fan to, - in the range 0 (off) to 100 (full speed) - Returns: - A boolean, True if speed is set successfully, False if not - """ - - if not self.is_psu_fan and self.get_presence(): - return self.__write_txt_file( - CPLD_I2C_PATH + "_duty_cycle_percentage", int(speed)) - - return False - - def set_status_led(self, color): - """ - Sets the state of the fan module status LED - Args: - color: A string representing the color with which to set the - fan module status LED - Returns: - bool: True if status LED state is set successfully, False if not - """ - return False #Not supported - - def get_status_led(self): - """ - Gets the state of the fan status LED - Returns: - A string, one of the predefined STATUS_LED_COLOR_* strings above - """ - status=self.get_presence() - if status is None: - return self.STATUS_LED_COLOR_OFF - - return { - 1: self.STATUS_LED_COLOR_GREEN, - 0: self.STATUS_LED_COLOR_RED - }.get(status, self.STATUS_LED_COLOR_OFF) - - def get_name(self): - """ - Retrieves the name of the device - Returns: - string: The name of the device - """ - fan_name = FAN_NAME_LIST[self.fan_tray_index*2 + self.fan_index] \ - if not self.is_psu_fan \ - else "PSU-{} FAN-{}".format(self.psu_index+1, self.fan_index+1) - - return fan_name - - def get_presence(self): - """ - Retrieves the presence of the PSU - Returns: - bool: True if PSU is present, False if not - """ - if self.is_psu_fan: - val = self.__read_txt_file(self.cpld_path + "psu_present") - return int(val, 10) == 1 - - val = self.__read_txt_file( - CPLD_I2C_PATH + str(self.fan_tray_index + 1) + "_present") - return int(val, 10)==1 - - def get_status(self): - """ - Retrieves the operational status of the device - Returns: - A boolean value, True if device is operating properly, False if not - """ - if self.is_psu_fan: - psu_fan_path= "{}{}".format(self.psu_hwmon_path, 'psu_fan1_fault') - val=self.__read_txt_file(psu_fan_path) - if val is not None: - return int(val, 10)==0 - else: - return False - else: - path = "{}{}{}".format(CPLD_I2C_PATH, self.fan_tray_index+1, '_fault') - val=self.__read_txt_file(path) - if val is not None: - return int(val, 10)==0 - else: - return False - - def get_model(self): - """ - Retrieves the model number (or part number) of the device - Returns: - string: Model/part number of device - """ - - return "N/A" - - def get_serial(self): - """ - Retrieves the serial number of the device - Returns: - string: Serial number of device - """ - return "N/A" - - def get_position_in_parent(self): - """ - Retrieves 1-based relative physical position in parent device. - If the agent cannot determine the parent-relative position - for some reason, or if the associated value of - entPhysicalContainedIn is'0', then the value '-1' is returned - Returns: - integer: The 1-based relative physical position in parent device - or -1 if cannot determine the position - """ - return (self.fan_index+1) \ - if not self.is_psu_fan else (self.psu_index+1) - - def is_replaceable(self): - """ - Indicate whether this device is replaceable. - Returns: - bool: True if it is replaceable. - """ - return True if not self.is_psu_fan else False diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan_drawer.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan_drawer.py deleted file mode 100644 index e21163c106c1..000000000000 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/fan_drawer.py +++ /dev/null @@ -1,90 +0,0 @@ -######################################################################## -# -# Module contains an implementation of SONiC Platform Base API and -# provides the Fan-Drawers' information available in the platform. -# -######################################################################## - -try: - from sonic_platform_base.fan_drawer_base import FanDrawerBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - -FANS_PER_FANTRAY = 2 - - -class FanDrawer(FanDrawerBase): - """Platform-specific Fan class""" - - def __init__(self, fantray_index): - - FanDrawerBase.__init__(self) - # FanTray is 0-based in platforms - self.fantrayindex = fantray_index - self.__initialize_fan_drawer() - - - def __initialize_fan_drawer(self): - from sonic_platform.fan import Fan - for i in range(FANS_PER_FANTRAY): - self._fan_list.append(Fan(self.fantrayindex, i)) - - def get_name(self): - """ - Retrieves the fan drawer name - Returns: - string: The name of the device - """ - return "FanTray{}".format(self.fantrayindex+1) - - def get_presence(self): - """ - Retrieves the presence of the device - Returns: - bool: True if device is present, False if not - """ - return self._fan_list[0].get_presence() - - def get_model(self): - """ - Retrieves the model number (or part number) of the device - Returns: - string: Model/part number of device - """ - return self._fan_list[0].get_model() - - def get_serial(self): - """ - Retrieves the serial number of the device - Returns: - string: Serial number of device - """ - return self._fan_list[0].get_serial() - - def get_status(self): - """ - Retrieves the operational status of the device - Returns: - A boolean value, True if device is operating properly, False if not - """ - return self._fan_list[0].get_status() - - def get_position_in_parent(self): - """ - Retrieves 1-based relative physical position in parent device. - If the agent cannot determine the parent-relative position - for some reason, or if the associated value of - entPhysicalContainedIn is'0', then the value '-1' is returned - Returns: - integer: The 1-based relative physical position in parent device - or -1 if cannot determine the position - """ - return (self.fantrayindex+1) - - def is_replaceable(self): - """ - Indicate whether this device is replaceable. - Returns: - bool: True if it is replaceable. - """ - return True diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/psu.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/psu.py deleted file mode 100644 index 44566aba1f3c..000000000000 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/psu.py +++ /dev/null @@ -1,264 +0,0 @@ -############################################################################# -# Edgecore -# -# Module contains an implementation of SONiC Platform Base API and -# provides the PSUs status which are available in the platform -# -############################################################################# - -#import sonic_platform - -try: - from sonic_platform_base.psu_base import PsuBase - from sonic_platform.thermal import Thermal -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - -I2C_PATH = "/sys/bus/i2c/devices/{}-00{}/" - -PSU_NAME_LIST = ["PSU-1", "PSU-2"] -PSU_NUM_FAN = [1, 1] -PSU_HWMON_I2C_MAPPING = { - 0: { - "bus": 17, - "addr": "59" - }, - 1: { - "bus": 13, - "addr": "5b" - }, -} - -PSU_CPLD_I2C_MAPPING = { - 0: { - "bus": 17, - "addr": "51" - }, - 1: { - "bus": 13, - "addr": "53" - }, -} - -NUM_FAN_TRAY = 6 - - -class Psu(PsuBase): - """Platform-specific Psu class""" - - def __init__(self, psu_index=0): - PsuBase.__init__(self) - self.index = psu_index - - bus = PSU_HWMON_I2C_MAPPING[self.index]["bus"] - addr = PSU_HWMON_I2C_MAPPING[self.index]["addr"] - self.hwmon_path = I2C_PATH.format(bus, addr) - - bus = PSU_CPLD_I2C_MAPPING[self.index]["bus"] - addr = PSU_CPLD_I2C_MAPPING[self.index]["addr"] - self.cpld_path = I2C_PATH.format(bus, addr) - self.__initialize_fan() - - def __initialize_fan(self): - from sonic_platform.fan import Fan - self._fan_list.append( - Fan(NUM_FAN_TRAY + self.index, - is_psu_fan=True, - psu_index=self.index)) - self._thermal_list.append(Thermal(is_psu=True, psu_index=self.index)) - - def __read_txt_file(self, file_path): - try: - with open(file_path, 'r') as fd: - return fd.read().strip() - except IOError: - pass - return None - - def get_voltage(self): - """ - Retrieves current PSU voltage output - Returns: - A float number, the output voltage in volts, - e.g. 12.1 - """ - val = self.__read_txt_file(self.hwmon_path + "psu_v_out") - if val is not None: - return float(val)/ 1000 - else: - return 0 - - def get_current(self): - """ - Retrieves present electric current supplied by PSU - Returns: - A float number, the electric current in amperes, e.g 15.4 - """ - val = self.__read_txt_file(self.hwmon_path + "psu_i_out") - if val is not None: - return float(val)/1000 - else: - return 0 - - def get_power(self): - """ - Retrieves current energy supplied by PSU - Returns: - A float number, the power in watts, e.g. 302.6 - """ - val = self.__read_txt_file(self.hwmon_path + "psu_p_out") - if val is not None: - return float(val)/1000 - else: - return 0 - - def get_powergood_status(self): - """ - Retrieves the powergood status of PSU - Returns: - A boolean, True if PSU has stablized its output voltages and passed all - its internal self-tests, False if not. - """ - return self.get_status() - - def set_status_led(self, color): - """ - Sets the state of the PSU status LED - Args: - color: A string representing the color with which to set the PSU status LED - Note: Only support green and off - Returns: - bool: True if status LED state is set successfully, False if not - """ - - return False #Controlled by HW - - def get_status_led(self): - """ - Gets the state of the PSU status LED - Returns: - A string, one of the predefined STATUS_LED_COLOR_* strings above - """ - status=self.get_status() - if status is None: - return self.STATUS_LED_COLOR_OFF - - return { - 1: self.STATUS_LED_COLOR_GREEN, - 0: self.STATUS_LED_COLOR_RED - }.get(status, self.STATUS_LED_COLOR_OFF) - - def get_temperature(self): - """ - Retrieves current temperature reading from PSU - Returns: - A float number of current temperature in Celsius up to nearest thousandth - of one degree Celsius, e.g. 30.125 - """ - return self._thermal_list[0].get_temperature() - - def get_temperature_high_threshold(self): - """ - Retrieves the high threshold temperature of PSU - Returns: - A float number, the high threshold temperature of PSU in Celsius - up to nearest thousandth of one degree Celsius, e.g. 30.125 - """ - return False #Not supported - - def get_voltage_high_threshold(self): - """ - Retrieves the high threshold PSU voltage output - Returns: - A float number, the high threshold output voltage in volts, - e.g. 12.1 - """ - val = self.__read_txt_file(self.hwmon_path + "psu_mfr_vout_max") - if val is not None: - return float(val)/ 1000 - else: - return 0 - - def get_voltage_low_threshold(self): - """ - Retrieves the low threshold PSU voltage output - Returns: - A float number, the low threshold output voltage in volts, - e.g. 12.1 - """ - val = self.__read_txt_file(self.hwmon_path + "psu_mfr_vout_min") - if val is not None: - return float(val)/ 1000 - else: - return 0 - - def get_name(self): - """ - Retrieves the name of the device - Returns: - string: The name of the device - """ - return PSU_NAME_LIST[self.index] - - def get_presence(self): - """ - Retrieves the presence of the PSU - Returns: - bool: True if PSU is present, False if not - """ - val = self.__read_txt_file(self.cpld_path + "psu_present") - if val is not None: - return int(val, 10) == 1 - else: - return 0 - - def get_status(self): - """ - Retrieves the operational status of the device - Returns: - A boolean value, True if device is operating properly, False if not - """ - val = self.__read_txt_file(self.cpld_path + "psu_power_good") - if val is not None: - return int(val, 10) == 1 - else: - return 0 - - def get_model(self): - """ - Retrieves the model number (or part number) of the device - Returns: - string: Model/part number of device - """ - model = self.__read_txt_file(self.cpld_path + "psu_model_name") - if model is None: - return "N/A" - return model - - def get_serial(self): - """ - Retrieves the serial number of the device - Returns: - string: Serial number of device - """ - serial = self.__read_txt_file(self.cpld_path + "psu_serial_number") - if serial is None: - return "N/A" - return serial - - def get_position_in_parent(self): - """ - Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position - for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned - Returns: - integer: The 1-based relative physical position in parent device or -1 if cannot determine the position - """ - return self.index+1 - - def is_replaceable(self): - """ - Indicate whether this device is replaceable. - Returns: - bool: True if it is replaceable. - """ - return True diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/sfp.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/sfp.py deleted file mode 100644 index 16fe60bfb698..000000000000 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/sfp.py +++ /dev/null @@ -1,625 +0,0 @@ -############################################################################# -# Edgecore -# -# Sfp contains an implementation of SONiC Platform Base API and -# provides the sfp device status which are available in the platform -# -############################################################################# - -import time -import sys -import subprocess -from ctypes import create_string_buffer - -try: - from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase - from sonic_platform_base.sonic_sfp.sfputilhelper import SfpUtilHelper -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - -CPLD_ADDR_MAPPING = { - 0: { - "bus": 18, - "addr": "60" - }, # port 31-56 - 1: { - "bus": 12, - "addr": "62" - }, # port 1-30 -} -CPLD_I2C_PATH = "/sys/bus/i2c/devices/{}-00{}/" - -class Sfp(SfpOptoeBase): - """Platform-specific Sfp class""" - - # Port number - PORT_START = 1 - PORT_END = 58 - - # Path to sysfs - PLATFORM_ROOT_PATH = "/usr/share/sonic/device" - PMON_HWSKU_PATH = "/usr/share/sonic/hwsku" - HOST_CHK_CMD = ["which", "systemctl"] - - PLATFORM = "x86_64-accton_as7326_56x-r0" - HWSKU = "Accton-AS7326-56X" - - _port_to_i2c_mapping = { - 1: [42], - 2: [41], - 3: [44], - 4: [43], - 5: [47], - 6: [45], - 7: [46], - 8: [50], - 9: [48], - 10: [49], - 11: [52], - 12: [51], - 13: [53], - 14: [56], - 15: [55], - 16: [54], - 17: [58], - 18: [57], - 19: [60], - 20: [59], - 21: [61], - 22: [63], - 23: [62], - 24: [64], - 25: [66], - 26: [68], - 27: [65], - 28: [67], - 29: [69], - 30: [71], - 31: [72], - 32: [70], - 33: [74], - 34: [73], - 35: [76], - 36: [75], - 37: [77], - 38: [79], - 39: [78], - 40: [80], - 41: [81], - 42: [82], - 43: [84], - 44: [85], - 45: [83], - 46: [87], - 47: [88], - 48: [86], - 49: [25], - 50: [26], - 51: [27], - 52: [28], - 53: [29], - 54: [30], - 55: [31], - 56: [32], - 57: [22], - 58: [23] - } - - def __init__(self, sfp_index=0): - SfpOptoeBase.__init__(self) - # Init index - self.index = sfp_index - self.port_num = self.index + 1 - - cpld_idx = 0 if self.port_num > 30 else 1 - bus = CPLD_ADDR_MAPPING[cpld_idx]["bus"] - addr = CPLD_ADDR_MAPPING[cpld_idx]["addr"] - self.cpld_path = CPLD_I2C_PATH.format(bus, addr) - - # Init eeprom path - eeprom_path = '/sys/bus/i2c/devices/{0}-0050/eeprom' - self.port_to_eeprom_mapping = {} - for x in range(self.PORT_START, self.PORT_END + 1): - self.port_to_eeprom_mapping[x] = eeprom_path.format( - self._port_to_i2c_mapping[x][0]) - - def get_eeprom_path(self): - return self.port_to_eeprom_mapping[self.port_num] - - def __read_txt_file(self, file_path): - try: - with open(file_path, 'r') as fd: - return fd.read().strip() - except IOError: - pass - return "" - - def __write_txt_file(self, file_path, value): - try: - with open(file_path, 'w') as fd: - fd.write(str(value)) - except Exception: - return False - return True - - def __is_host(self): - return subprocess.call(self.HOST_CHK_CMD) == 0 - - def __get_path_to_port_config_file(self): - platform_path = "/".join([self.PLATFORM_ROOT_PATH, self.PLATFORM]) - hwsku_path = "/".join( - [platform_path, - self.HWSKU]) if self.__is_host() else self.PMON_HWSKU_PATH - return "/".join([hwsku_path, "port_config.ini"]) - - def __read_eeprom_specific_bytes(self, offset, num_bytes): - sysfsfile_eeprom = None - eeprom_raw = [] - for i in range(0, num_bytes): - eeprom_raw.append("0x00") - - sysfs_sfp_i2c_client_eeprom_path = self.port_to_eeprom_mapping[ - self.port_num] - try: - sysfsfile_eeprom = open( - sysfs_sfp_i2c_client_eeprom_path, mode="rb", buffering=0) - sysfsfile_eeprom.seek(offset) - raw = sysfsfile_eeprom.read(num_bytes) - for n in range(0, num_bytes): - if sys.version_info[0] >= 3: - eeprom_raw[n] = hex(raw[n])[2:].zfill(2) - else: - eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2) - except Exception: - pass - finally: - if sysfsfile_eeprom: - sysfsfile_eeprom.close() - - return eeprom_raw - - def get_reset_status(self): - """ - Retrieves the reset status of SFP - Returns: - A Boolean, True if reset enabled, False if disabled - """ - if self.port_num <= 48 or self.port_num >=57: - return False # SPF port doesn't support this feature - - val = self.__read_txt_file( - self.cpld_path + "module_reset_" + str(self.port_num)) - return int(val, 10) == 1 - - def get_rx_los(self): - """ - Retrieves the RX LOS (lost-of-signal) status of SFP - Returns: - A Boolean, True if SFP has RX LOS, False if not. - Note : RX LOS status is latched until a call to get_rx_los or a reset. - """ - if self.port_num <= 48 or self.port_num >=57: - rx_los = self.__read_txt_file( - self.cpld_path + "module_rx_los_" + str(self.port_num)) - if int(rx_los, 10) == 1: - return [True] - else: - return [False] - #status_control_raw = self.__read_eeprom_specific_bytes( - # SFP_STATUS_CONTROL_OFFSET, SFP_STATUS_CONTROL_WIDTH) - #if status_control_raw: - # data = int(status_control_raw[0], 16) - # rx_los = (sffbase().test_bit(data, 1) != 0) - else: - rx_los_list = [] - dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( - QSFP_CHANNL_RX_LOS_STATUS_OFFSET, - QSFP_CHANNL_RX_LOS_STATUS_WIDTH) if self.get_presence( - ) else None - if dom_channel_monitor_raw is not None: - rx_los_data = int(dom_channel_monitor_raw[0], 16) - rx_los_list.append(rx_los_data & 0x01 != 0) - rx_los_list.append(rx_los_data & 0x02 != 0) - rx_los_list.append(rx_los_data & 0x04 != 0) - rx_los_list.append(rx_los_data & 0x08 != 0) - return rx_los_list - else: - return [False]*4 - - def get_tx_fault(self): - """ - Retrieves the TX fault status of SFP - - Returns: - A list of boolean values, representing the TX fault status - of each available channel, value is True if SFP channel - has TX fault, False if not. - E.g., for a tranceiver with four channels: [False, False, True, False] - Note : TX fault status is lached until a call to get_tx_fault or a reset. - """ - tx_fault = False - if self.port_num <= 48 or self.port_num >=57: - tx_fault = self.__read_txt_file( - self.cpld_path + "module_tx_fault_" + str(self.port_num)) - if int(tx_fault, 10) == 1: - return [True] - else: - return [False] - #status_control_raw = self.__read_eeprom_specific_bytes( - # SFP_STATUS_CONTROL_OFFSET, SFP_STATUS_CONTROL_WIDTH) - #if status_control_raw: - # data = int(status_control_raw[0], 16) - # tx_fault = (sffbase().test_bit(data, 2) != 0) - else: - tx_fault_list = [] - dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( - QSFP_CHANNL_TX_FAULT_STATUS_OFFSET, - QSFP_CHANNL_TX_FAULT_STATUS_WIDTH) if self.get_presence( - ) else None - if dom_channel_monitor_raw is not None: - tx_fault_data = int(dom_channel_monitor_raw[0], 16) - tx_fault_list.append(tx_fault_data & 0x01 != 0) - tx_fault_list.append(tx_fault_data & 0x02 != 0) - tx_fault_list.append(tx_fault_data & 0x04 != 0) - tx_fault_list.append(tx_fault_data & 0x08 != 0) - return tx_fault_list - else: - return [False]*4 - - - def get_tx_disable(self): - """ - Retrieves the tx_disable status of this SFP - Returns: - A list of boolean values, representing the TX disable status - of each available channel, value is True if SFP channel - is TX disabled, False if not. - E.g., for a tranceiver with four channels: [False, False, True, False] - """ - if self.port_num <= 48 or self.port_num >=57: - tx_disable = False - - status_control_raw = self.__read_eeprom_specific_bytes( - SFP_STATUS_CONTROL_OFFSET, SFP_STATUS_CONTROL_WIDTH) - if status_control_raw: - cpld_val = self.__read_txt_file( - self.cpld_path + "module_tx_disable_" + str(self.port_num)) - tx_disable_hard = (int(cpld_val, 10) == 1) - data = int(status_control_raw[0], 16) - #tx_disable_hard = (sffbase().test_bit( - # data, SFP_TX_DISABLE_HARD_BIT) != 0) - tx_disable_soft = (sffbase().test_bit( - data, SFP_TX_DISABLE_SOFT_BIT) != 0) - tx_disable = tx_disable_hard | tx_disable_soft - if tx_disable==0: - return [False] - else: - return [True] - - else: - return [False] - - else: - tx_disable_list = [] - - sfpd_obj = sff8436Dom() - if sfpd_obj is None: - return [False] - - dom_control_raw = self.__read_eeprom_specific_bytes( - QSFP_CONTROL_OFFSET, - QSFP_CONTROL_WIDTH) if self.get_presence() else None - if dom_control_raw is not None: - dom_control_data = sfpd_obj.parse_control_bytes( - dom_control_raw, 0) - tx_disable_list.append( - 'On' == dom_control_data['data']['TX1Disable']['value']) - tx_disable_list.append( - 'On' == dom_control_data['data']['TX2Disable']['value']) - tx_disable_list.append( - 'On' == dom_control_data['data']['TX3Disable']['value']) - tx_disable_list.append( - 'On' == dom_control_data['data']['TX4Disable']['value']) - return tx_disable_list - else: - return [False]*4 - - def get_tx_disable_channel(self): - """ - Retrieves the TX disabled channels in this SFP - Returns: - A hex of 4 bits (bit 0 to bit 3 as channel 0 to channel 3) to represent - TX channels which have been disabled in this SFP. - As an example, a returned value of 0x5 indicates that channel 0 - and channel 2 have been disabled. - """ - tx_disable_list = self.get_tx_disable() - if tx_disable_list is None: - return 0 - tx_disabled = 0 - for i in range(len(tx_disable_list)): - if tx_disable_list[i]: - tx_disabled |= 1 << i - return tx_disabled - - def get_lpmode(self): - """ - Retrieves the lpmode (low power mode) status of this SFP - Returns: - A Boolean, True if lpmode is enabled, False if disabled - """ - if self.port_num <= 48 or self.port_num >= 57: - # SFP doesn't support this feature - return False - - power_set = self.get_power_set() - power_override = self.get_power_override() - return power_set and power_override - - def get_power_set(self): - - if self.port_num <= 48 or self.port_num >= 57: - # SFP doesn't support this feature - return False - else: - power_set = False - - sfpd_obj = sff8436Dom() - if sfpd_obj is None: - return False - - dom_control_raw = self.__read_eeprom_specific_bytes( - QSFP_CONTROL_OFFSET, - QSFP_CONTROL_WIDTH) if self.get_presence() else None - if dom_control_raw is not None: - dom_control_data = sfpd_obj.parse_control_bytes( - dom_control_raw, 0) - power_set = ( - 'On' == dom_control_data['data']['PowerSet']['value']) - - return power_set - - def get_power_override(self): - """ - Retrieves the power-override status of this SFP - Returns: - A Boolean, True if power-override is enabled, False if disabled - """ - if self.port_num <= 48 or self.port_num >= 57: - return False # SFP doesn't support this feature - else: - power_override = False - - sfpd_obj = sff8436Dom() - if sfpd_obj is None: - return False - - dom_control_raw = self.__read_eeprom_specific_bytes( - QSFP_CONTROL_OFFSET, - QSFP_CONTROL_WIDTH) if self.get_presence() else None - if dom_control_raw is not None: - dom_control_data = sfpd_obj.parse_control_bytes( - dom_control_raw, 0) - power_override = ( - 'On' == dom_control_data['data']['PowerOverride']['value']) - - return power_override - - def reset(self): - """ - Reset SFP and return all user module settings to their default srate. - Returns: - A boolean, True if successful, False if not - """ - # Check for invalid port_num - if self.port_num <= 48 or self.port_num >=57: - return False # SFP doesn't support this feature - - ret = self.__write_txt_file( - self.cpld_path + "module_reset_" + str(self.port_num), 1) - if ret is not True: - return ret - - time.sleep(0.01) - ret = self.__write_txt_file( - self.cpld_path + "module_reset_" + str(self.port_num), 0) - time.sleep(0.2) - return ret - - def tx_disable(self, tx_disable): - """ - Disable SFP TX for all channels - Args: - tx_disable : A Boolean, True to enable tx_disable mode, False to disable - tx_disable mode. - Returns: - A boolean, True if tx_disable is set successfully, False if not - """ - if self.port_num <= 48 or self.port_num >=57: - ret = self.__write_txt_file( - self.cpld_path + "module_tx_disable_" + str(self.port_num), 1 - if tx_disable else 0) - time.sleep(0.01) - return ret - else: - if not self.get_presence(): - return False - - sysfsfile_eeprom = None - try: - tx_disable_ctl = 0xf if tx_disable else 0x0 - buffer = create_string_buffer(1) - if sys.version_info[0] >= 3: - buffer[0] = tx_disable_ctl - else: - buffer[0] = chr(tx_disable_ctl) - # Write to eeprom - sysfsfile_eeprom = open( - self.port_to_eeprom_mapping[self.port_num], "r+b") - sysfsfile_eeprom.seek(QSFP_CONTROL_OFFSET) - sysfsfile_eeprom.write(buffer[0]) - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - finally: - if sysfsfile_eeprom is not None: - sysfsfile_eeprom.close() - time.sleep(0.01) - return True - - def tx_disable_channel(self, channel, disable): - """ - Sets the tx_disable for specified SFP channels - Args: - channel : A hex of 4 bits (bit 0 to bit 3) which represent channel 0 to 3, - e.g. 0x5 for channel 0 and channel 2. - disable : A boolean, True to disable TX channels specified in channel, - False to enable - Returns: - A boolean, True if successful, False if not - """ - - if self.port_num <= 48 or self.port_num >=57: - return False # SFP doesn't support this feature - else: - if not self.get_presence(): - return False - - sysfsfile_eeprom = None - try: - channel_state = self.get_tx_disable_channel() - - for i in range(4): - channel_mask = (1 << i) - if not (channel & channel_mask): - continue - - if disable: - channel_state |= channel_mask - else: - channel_state &= ~channel_mask - - buffer = create_string_buffer(1) - if sys.version_info[0] >= 3: - buffer[0] = channel_state - else: - buffer[0] = chr(channel_state) - # Write to eeprom - sysfsfile_eeprom = open( - self.port_to_eeprom_mapping[self.port_num], "r+b") - sysfsfile_eeprom.seek(QSFP_CONTROL_OFFSET) - sysfsfile_eeprom.write(buffer[0]) - except IOError as e: - print("Error: unable to open file: %s" % str(e)) - return False - finally: - if sysfsfile_eeprom is not None: - sysfsfile_eeprom.close() - time.sleep(0.01) - return True - - def set_lpmode(self, lpmode): - """ - Sets the lpmode (low power mode) of SFP - Args: - lpmode: A Boolean, True to enable lpmode, False to disable it - Note : lpmode can be overridden by set_power_override - Returns: - A boolean, True if lpmode is set successfully, False if not - """ - if self.port_num <= 48 or self.port_num >=57: - return False # SFP doesn't support this feature - - if lpmode: - return self.set_power_override(True, True) - else: - return self.set_power_override(True, False) - - def set_power_override(self, power_override, power_set): - """ - Sets SFP power level using power_override and power_set - Args: - power_override : - A Boolean, True to override set_lpmode and use power_set - to control SFP power, False to disable SFP power control - through power_override/power_set and use set_lpmode - to control SFP power. - power_set : - Only valid when power_override is True. - A Boolean, True to set SFP to low power mode, False to set - SFP to high power mode. - Returns: - A boolean, True if power-override and power_set are set successfully, - False if not - """ - if self.port_num <= 48 or self.port_num >=57: - return False # SFP doesn't support this feature - else: - if not self.get_presence(): - return False - try: - power_override_bit = (1 << 0) if power_override else 0 - power_set_bit = (1 << 1) if power_set else (1 << 3) - - buffer = create_string_buffer(1) - if sys.version_info[0] >= 3: - buffer[0] = (power_override_bit | power_set_bit) - else: - buffer[0] = chr(power_override_bit | power_set_bit) - # Write to eeprom - with open(self.port_to_eeprom_mapping[self.port_num], - "r+b") as fd: - fd.seek(QSFP_POWEROVERRIDE_OFFSET) - fd.write(buffer[0]) - time.sleep(0.01) - except Exception: - print("Error: unable to open file: %s" % str(e)) - return False - return True - - def get_name(self): - """ - Retrieves the name of the device - Returns: - string: The name of the device - """ - sfputil_helper = SfpUtilHelper() - sfputil_helper.read_porttab_mappings( - self.__get_path_to_port_config_file()) - name = sfputil_helper.logical[self.index] or "Unknown" - return name - - def get_presence(self): - """ - Retrieves the presence of the device - Returns: - bool: True if device is present, False if not - """ - val = self.__read_txt_file( - self.cpld_path + "module_present_" + str(self.port_num)) - return val == '1' - - def get_status(self): - """ - Retrieves the operational status of the device - Returns: - A boolean value, True if device is operating properly, False if not - """ - return self.get_presence() - - def get_position_in_parent(self): - """ - Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position - for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned - Returns: - integer: The 1-based relative physical position in parent device or -1 if cannot determine the position - """ - return self.port_num - - def is_replaceable(self): - """ - Indicate whether this device is replaceable. - Returns: - bool: True if it is replaceable. - """ - return True diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/thermal.py b/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/thermal.py deleted file mode 100644 index b2233e7b5a72..000000000000 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/thermal.py +++ /dev/null @@ -1,232 +0,0 @@ -############################################################################# -# Edgecore -# -# Thermal contains an implementation of SONiC Platform Base API and -# provides the thermal device status which are available in the platform -# -############################################################################# - -import os -import os.path -import glob - -try: - from sonic_platform_base.thermal_base import ThermalBase -except ImportError as e: - raise ImportError(str(e) + "- required module not found") - -PSU_I2C_PATH = "/sys/bus/i2c/devices/{}-00{}/" -PSU_HWMON_I2C_MAPPING = { - 0: { - "bus": 17, - "addr": "59" - }, - 1: { - "bus": 13, - "addr": "5b" - }, -} - -PSU_CPLD_I2C_MAPPING = { - 0: { - "bus": 17, - "addr": "51" - }, - 1: { - "bus": 13, - "addr": "53" - }, -} - - -class Thermal(ThermalBase): - """Platform-specific Thermal class""" - - THERMAL_NAME_LIST = [] - PSU_THERMAL_NAME_LIST = [] - SYSFS_PATH = "/sys/bus/i2c/devices" - - def __init__(self, thermal_index=0, is_psu=False, psu_index=0): - self.index = thermal_index - self.is_psu = is_psu - self.psu_index = psu_index - - if self.is_psu: - psu_i2c_bus = PSU_HWMON_I2C_MAPPING[psu_index]["bus"] - psu_i2c_addr = PSU_HWMON_I2C_MAPPING[psu_index]["addr"] - self.psu_hwmon_path = PSU_I2C_PATH.format(psu_i2c_bus, - psu_i2c_addr) - psu_i2c_bus = PSU_CPLD_I2C_MAPPING[psu_index]["bus"] - psu_i2c_addr = PSU_CPLD_I2C_MAPPING[psu_index]["addr"] - self.cpld_path = PSU_I2C_PATH.format(psu_i2c_bus, psu_i2c_addr) - - # Add thermal name - self.THERMAL_NAME_LIST.append("Temp sensor 1") - self.THERMAL_NAME_LIST.append("Temp sensor 2") - self.THERMAL_NAME_LIST.append("Temp sensor 3") - self.THERMAL_NAME_LIST.append("Temp sensor 4") - self.PSU_THERMAL_NAME_LIST.append("PSU-1 temp sensor 1") - self.PSU_THERMAL_NAME_LIST.append("PSU-2 temp sensor 1") - - # Set hwmon path - i2c_path = { - 0: "15-0048/hwmon/hwmon*/", - 1: "15-0049/hwmon/hwmon*/", - 2: "15-004a/hwmon/hwmon*/", - 3: "15-004b/hwmon/hwmon*/" - }.get(self.index, None) - - self.hwmon_path = "{}/{}".format(self.SYSFS_PATH, i2c_path) - self.ss_key = self.THERMAL_NAME_LIST[self.index] - self.ss_index = 1 - - def __read_txt_file(self, file_path): - for filename in glob.glob(file_path): - try: - with open(filename, 'r') as fd: - return fd.readline().rstrip() - except IOError as e: - pass - - def __get_temp(self, temp_file): - if not self.is_psu: - temp_file_path = os.path.join(self.hwmon_path, temp_file) - else: - temp_file_path = temp_file - - raw_temp = self.__read_txt_file(temp_file_path) - return float(raw_temp) / 1000 - - def __set_threshold(self, file_name, temperature): - if self.is_psu: - return True - - temp_file_path = os.path.join(self.hwmon_path, file_name) - try: - with open(temp_file_path, 'w') as fd: - fd.write(str(temperature)) - return True - except IOError: - return False - - def get_temperature(self): - """ - Retrieves current temperature reading from thermal - Returns: - A float number of current temperature in Celsius up to nearest thousandth - of one degree Celsius, e.g. 30.125 - """ - if not self.is_psu: - temp_file = "temp{}_input".format(self.ss_index) - else: - temp_file = self.psu_hwmon_path + "psu_temp1_input" - - return self.__get_temp(temp_file) - - def get_high_threshold(self): - """ - Retrieves the high threshold temperature of thermal - Returns: - A float number, the high threshold temperature of thermal in Celsius - up to nearest thousandth of one degree Celsius, e.g. 30.125 - """ - if self.is_psu: - return 0 - - temp_file = "temp{}_max".format(self.ss_index) - return self.__get_temp(temp_file) - - def set_high_threshold(self, temperature): - """ - Sets the high threshold temperature of thermal - Args : - temperature: A float number up to nearest thousandth of one degree Celsius, - e.g. 30.125 - Returns: - A boolean, True if threshold is set successfully, False if not - """ - temp_file = "temp{}_max".format(self.ss_index) - temperature = temperature *1000 - self.__set_threshold(temp_file, temperature) - - return True - - def get_name(self): - """ - Retrieves the name of the thermal device - Returns: - string: The name of the thermal device - """ - if self.is_psu: - return self.PSU_THERMAL_NAME_LIST[self.psu_index] - else: - return self.THERMAL_NAME_LIST[self.index] - - def get_presence(self): - """ - Retrieves the presence of the PSU - Returns: - bool: True if PSU is present, False if not - """ - if self.is_psu: - val = self.__read_txt_file(self.cpld_path + "psu_present") - return int(val, 10) == 1 - - temp_file = "temp{}_input".format(self.ss_index) - temp_file_path = os.path.join(self.hwmon_path, temp_file) - raw_txt = self.__read_txt_file(temp_file_path) - return raw_txt != None - - def get_status(self): - """ - Retrieves the operational status of the device - Returns: - A boolean value, True if device is operating properly, False if not - """ - if self.is_psu: - temp_file = self.psu_hwmon_path + "psu_temp_fault" - return self.get_presence() and (not int( - self.__read_txt_file(temp_file))) - - file_str = "temp{}_input".format(self.ss_index) - file_path = os.path.join(self.hwmon_path, file_str) - - raw_txt = self.__read_txt_file(file_path) - if raw_txt is None: - return False - else: - return int(raw_txt) != 0 - - def get_model(self): - """ - Retrieves the model number (or part number) of the device - Returns: - string: Model/part number of device - """ - - return "N/A" - - def get_serial(self): - """ - Retrieves the serial number of the device - Returns: - string: Serial number of device - """ - return "N/A" - - def get_position_in_parent(self): - """ - Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position - for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned - Returns: - integer: The 1-based relative physical position in parent device or -1 if cannot determine the position - """ - return self.index+1 - - def is_replaceable(self): - """ - Retrieves whether thermal module is replaceable - Returns: - A boolean value, True if replaceable, False if not - """ - return False diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/chassis.py index feb1fbdb5620..c579b219c44c 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/chassis.py @@ -8,58 +8,58 @@ try: import sys - import time from sonic_platform_pddf_base.pddf_chassis import PddfChassis + from .event import SfpEvent + from .helper import APIHelper except ImportError as e: raise ImportError(str(e) + "- required module not found") +NUM_COMPONENT = 6 +HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/" +PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/" +REBOOT_CAUSE_FILE = "reboot-cause.txt" class Chassis(PddfChassis): """ PDDF Platform-specific Chassis class """ + SYSLED_DEV_NAME = "DIAG_LED" def __init__(self, pddf_data=None, pddf_plugin_data=None): PddfChassis.__init__(self, pddf_data, pddf_plugin_data) + self.__initialize_components() + self._api_helper = APIHelper() + self._sfpevent = SfpEvent(self.get_all_sfps()) + + def __initialize_components(self): + from sonic_platform.component import Component + for index in range(NUM_COMPONENT): + component = Component(index) + self._component_list.append(component) # Provide the functions/variables below for which implementation is to be overwritten - sfp_change_event_data = {'valid': 0, 'last': 0, 'present': 0} - def get_change_event(self, timeout=2000): - now = time.time() - port_dict = {} - change_dict = {} - change_dict['sfp'] = port_dict - - if timeout < 1000: - timeout = 1000 - timeout = timeout / float(1000) # Convert to secs - - if now < (self.sfp_change_event_data['last'] + timeout) and self.sfp_change_event_data['valid']: - return True, change_dict - - bitmap = 0 - for i in range(58): - modpres = self.get_sfp(i+1).get_presence() - if modpres: - bitmap = bitmap | (1 << i) - - changed_ports = self.sfp_change_event_data['present'] ^ bitmap - if changed_ports: - for i in range(58): - if (changed_ports & (1 << i)): - if (bitmap & (1 << i)) == 0: - port_dict[i+1] = '0' - else: - port_dict[i+1] = '1' - - - # Update teh cache dict - self.sfp_change_event_data['present'] = bitmap - self.sfp_change_event_data['last'] = now - self.sfp_change_event_data['valid'] = 1 - return True, change_dict - else: - return True, change_dict + def get_change_event(self, timeout=0): + return self._sfpevent.get_sfp_event(timeout) + + def get_reboot_cause(self): + """ + Retrieves the cause of the previous reboot + + Returns: + A tuple (string, string) where the first element is a string + containing the cause of the previous reboot. This string must be + one of the predefined strings in this class. If the first string + is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used + to pass a description of the reboot cause. + """ + + reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE) + sw_reboot_cause = self._api_helper.read_txt_file( + reboot_cause_path) or "Unknown" + + + return ('REBOOT_CAUSE_NON_HARDWARE', sw_reboot_cause) + def get_sfp(self, index): """ @@ -83,3 +83,21 @@ def get_sfp(self, index): sys.stderr.write("SFP index {} out of range (1-{})\n".format( index, len(self._sfp_list))) return sfp + + def initizalize_system_led(self): + return + + def get_status_led(self): + return self.get_system_led(self.SYSLED_DEV_NAME) + + def set_status_led(self, color): + return self.set_system_led(self.SYSLED_DEV_NAME, color) + + def get_port_or_cage_type(self, port): + from sonic_platform_base.sfp_base import SfpBase + if port in range(1, 49): + return SfpBase.SFP_PORT_TYPE_BIT_SFP | SfpBase.SFP_PORT_TYPE_BIT_SFP_PLUS | SfpBase.SFP_PORT_TYPE_BIT_SFP28 + elif port in range(49, 57): + return SfpBase.SFP_PORT_TYPE_BIT_QSFP | SfpBase.SFP_PORT_TYPE_BIT_QSFP_PLUS | SfpBase.SFP_PORT_TYPE_BIT_QSFP28 + else: + return SfpBase.SFP_PORT_TYPE_BIT_SFP diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/component.py similarity index 79% rename from device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/component.py rename to platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/component.py index 75c2d3b918d4..8feb4f1c0c2e 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/component.py @@ -1,36 +1,41 @@ ############################################################################# -# Edgecore -# +# # Component contains an implementation of SONiC Platform Base API and # provides the components firmware management function # ############################################################################# try: + import subprocess from sonic_platform_base.component_base import ComponentBase except ImportError as e: raise ImportError(str(e) + "- required module not found") CPLD_ADDR_MAPPING = { - "CPLD-1": "18-0060", - "CPLD-2": "12-0062", - "CPLD-3": "19-0064", + "MB_CPLD1": ['18', '0x60'], + "MB_CPLD2": ['12', '0x62'], + "MB_CPLD3": ['19', '0x64'], + "FAN_CPLD": ['11', '0x66'], + "CPU_CPLD": ['0', '0x65'] } SYSFS_PATH = "/sys/bus/i2c/devices/" BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version" -COMPONENT_NAME_LIST = ["CPLD-1", "CPLD-2", "CPLD-3", "BIOS"] -COMPONENT_DES_LIST = [ - "CPLD-1", "CPLD-2", "CPLD-3", "Basic Input/Output System" +COMPONENT_LIST= [ + ("MB_CPLD1", "Mainboard CPLD(0x60)"), + ("MB_CPLD2", "Mainboard CPLD(0x62)"), + ("MB_CPLD3", "Mainboard CPLD(0x64)"), + ("FAN_CPLD", "Fan board CPLD(0x66)"), + ("CPU_CPLD", "CPU CPLD(0x65)"), + ("BIOS", "Basic Input/Output System") + ] - class Component(ComponentBase): """Platform-specific Component class""" DEVICE_TYPE = "component" def __init__(self, component_index=0): - ComponentBase.__init__(self) self.index = component_index self.name = self.get_name() @@ -42,26 +47,16 @@ def __get_bios_version(self): return bios_version.strip() except Exception as e: return None - - def __get_sysfs_value(self, addr, name): - # Retrieves the cpld register value - try: - with open(SYSFS_PATH + addr + '/' + name, 'r') as fd: - return fd.read().strip() - except Exception as e: - return None - + def __get_cpld_version(self): # Retrieves the CPLD firmware version cpld_version = dict() for cpld_name in CPLD_ADDR_MAPPING: - try: - cpld_addr = CPLD_ADDR_MAPPING[cpld_name] - cpld_version_raw = self.__get_sysfs_value(cpld_addr, "version") - cpld_version[cpld_name] = "{}".format( - int(cpld_version_raw, 16)) - except Exception as e: - cpld_version[cpld_name] = 'None' + cmd = "i2cget -f -y {0} {1} 0x1".format(CPLD_ADDR_MAPPING[cpld_name][0], CPLD_ADDR_MAPPING[cpld_name][1]) + status, value = subprocess.getstatusoutput(cmd) + if not status: + cpld_version_raw = value.rstrip() + cpld_version[cpld_name] = "{}".format(int(cpld_version_raw,16)) return cpld_version @@ -71,7 +66,7 @@ def get_name(self): Returns: A string containing the name of the component """ - return COMPONENT_NAME_LIST[self.index] + return COMPONENT_LIST[self.index][0] def get_description(self): """ @@ -79,7 +74,7 @@ def get_description(self): Returns: A string containing the description of the component """ - return COMPONENT_DES_LIST[self.index] + return COMPONENT_LIST[self.index][1] def get_firmware_version(self): """ diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/eeprom.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/eeprom.py index a87ecc9f6feb..ca9b5ce062d1 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/eeprom.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/eeprom.py @@ -2,13 +2,87 @@ try: from sonic_platform_pddf_base.pddf_eeprom import PddfEeprom + import os except ImportError as e: raise ImportError(str(e) + "- required module not found") +CACHE_ROOT = '/var/cache/sonic/decode-syseeprom' +CACHE_FILE = 'syseeprom_cache' class Eeprom(PddfEeprom): + _TLV_INFO_MAX_LEN = 256 + pddf_obj = {} + plugin_data = {} def __init__(self, pddf_data=None, pddf_plugin_data=None): - PddfEeprom.__init__(self, pddf_data, pddf_plugin_data) + #PddfEeprom.__init__(self, pddf_data, pddf_plugin_data) + if not pddf_data or not pddf_plugin_data: + raise ValueError('PDDF JSON data error') + + self.pddf_obj = pddf_data + self.plugin_data = pddf_plugin_data + + # system EEPROM always has device name EEPROM1 + self.eeprom_path = self.pddf_obj.get_path("EEPROM1", "eeprom") + if self.eeprom_path is None: + return + + super(PddfEeprom, self).__init__(self.eeprom_path, 0, '', True) + self.eeprom_tlv_dict = dict() + + # Create the cache directory if not created + if not os.path.exists(CACHE_ROOT): + try: + os.makedirs(CACHE_ROOT) + except Exception as e: + print("Error in creating Eeprom cache directory - {}".format(str(e))) + + # Assign cache_name in eeprom_base.py + try: + self.set_cache_name(os.path.join(CACHE_ROOT, CACHE_FILE)) + except: + pass + + try: + self.eeprom_data = self.read_eeprom() + except Exception as e: + self.eeprom_data = "N/A" + raise RuntimeError("Eeprom is not Programmed - Error: {}".format(str(e))) + else: + eeprom = self.eeprom_data + + try: + self.update_cache(eeprom) + except: + pass + + if not self.is_valid_tlvinfo_header(eeprom): + return + + total_length = ((eeprom[9]) << 8) | (eeprom[10]) + tlv_index = self._TLV_INFO_HDR_LEN + tlv_end = self._TLV_INFO_HDR_LEN + total_length + + while (tlv_index + 2) < len(eeprom) and tlv_index < tlv_end: + if not self.is_valid_tlv(eeprom[tlv_index:]): + break + + tlv = eeprom[tlv_index:tlv_index + 2 + + (eeprom[tlv_index + 1])] + code = "0x%02X" % ((tlv[0])) + + if (tlv[0]) == self._TLV_CODE_VENDOR_EXT: + value = str(((tlv[2]) << 24) | ((tlv[3]) << 16) | + ((tlv[4]) << 8) | (tlv[5])) + value += str(tlv[6:6 + (tlv[1])]) + else: + name, value = self.decoder(None, tlv) + + self.eeprom_tlv_dict[code] = value + if (eeprom[tlv_index]) == self._TLV_CODE_CRC_32: + break + + tlv_index += (eeprom[tlv_index+1]) + 2 + # Provide the functions/variables below for which implementation is to be overwritten diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/event.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/event.py similarity index 94% rename from device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/event.py rename to platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/event.py index 3d6f81518a26..d5dac6d7f7e0 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/event.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/event.py @@ -18,7 +18,7 @@ def get_presence_bitmap(self): bitmap = 0 for sfp in self._sfp_list: modpres = sfp.get_presence() - i=sfp.port_num-1 + i=sfp.get_position_in_parent() - 1 if modpres: bitmap = bitmap | (1 << i) return bitmap @@ -45,7 +45,7 @@ def get_sfp_event(self, timeout=2000): if changed_ports != 0: for sfp in self._sfp_list: - i=sfp.port_num-1 + i=sfp.get_position_in_parent() - 1 if (changed_ports & (1 << i)): if (bitmap & (1 << i)) == 0: port_dict[i+1] = '0' diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan.py index 23d8be5a8a9e..4e70b961b998 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan.py @@ -6,6 +6,9 @@ except ImportError as e: raise ImportError(str(e) + "- required module not found") +FAN_NAME_LIST = ["FAN-1F", "FAN-1R", "FAN-2F", "FAN-2R", + "FAN-3F", "FAN-3R", "FAN-4F", "FAN-4R", + "FAN-5F", "FAN-5R", "FAN-6F", "FAN-6R"] class Fan(PddfFan): """PDDF Platform-Specific Fan class""" @@ -15,5 +18,35 @@ def __init__(self, tray_idx, fan_idx=0, pddf_data=None, pddf_plugin_data=None, i PddfFan.__init__(self, tray_idx, fan_idx, pddf_data, pddf_plugin_data, is_psu_fan, psu_index) # Provide the functions/variables below for which implementation is to be overwritten - # Since AS4630 psu_fan airflow direction cant be read from sysfs, it is fixed as 'F2B' or 'intake' + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + fan_name = FAN_NAME_LIST[(self.fantray_index-1)*2 + self.fan_index-1] \ + if not self.is_psu_fan \ + else "PSU-{} FAN-{}".format(self.fans_psu_index, self.fan_index) + + return fan_name + + + + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + + return "N/A" + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return "N/A" diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan_drawer.py index 3b9bb607f632..f1e5c6edbcbd 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan_drawer.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan_drawer.py @@ -15,3 +15,28 @@ def __init__(self, tray_idx, pddf_data=None, pddf_plugin_data=None): PddfFanDrawer.__init__(self, tray_idx, pddf_data, pddf_plugin_data) # Provide the functions/variables below for which implementation is to be overwritten + + def get_name(self): + """ + Retrieves the fan drawer name + Returns: + string: The name of the device + """ + return "FanTray{}".format(self.fantray_index) + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + return self._fan_list[0].get_model() + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return self._fan_list[0].get_serial() + diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/helper.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/helper.py new file mode 100644 index 000000000000..09c2af7a8756 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/helper.py @@ -0,0 +1,53 @@ +import os +import struct +import subprocess +from mmap import * +from sonic_py_common import device_info + +HOST_CHK_CMD = ["docker"] +EMPTY_STRING = "" + + +class APIHelper(): + + def __init__(self): + (self.platform, self.hwsku) = device_info.get_platform_and_hwsku() + + def is_host(self): + try: + status, output = getstatusoutput_noshell(HOST_CHK_CMD) + return status == 0 + except Exception: + return False + + def pci_get_value(self, resource, offset): + status = True + result = "" + try: + fd = os.open(resource, os.O_RDWR) + mm = mmap(fd, 0) + mm.seek(int(offset)) + read_data_stream = mm.read(4) + result = struct.unpack('I', read_data_stream) + except Exception: + status = False + return status, result + + def read_txt_file(self, file_path): + try: + with open(file_path, 'r', errors='replace') as fd: + data = fd.read() + ret = data.strip() + if len(ret) > 0: + return ret + except IOError: + pass + return None + + def write_txt_file(self, file_path, value): + try: + with open(file_path, 'w') as fd: + fd.write(str(value)) + except IOError: + return False + return True diff --git a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/platform.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/pcie.py similarity index 51% rename from device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/platform.py rename to platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/pcie.py index 2f2c2a447fcf..e4da32adf9f8 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/sonic_platform/platform.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/pcie.py @@ -2,20 +2,18 @@ # Edgecore # # Module contains an implementation of SONiC Platform Base API and -# provides the platform information -# +# provides the fan status which are available in the platform +# Base PCIe class ############################################################################# try: - from sonic_platform_base.platform_base import PlatformBase - from sonic_platform.chassis import Chassis + from sonic_platform_base.sonic_pcie.pcie_common import PcieUtil except ImportError as e: raise ImportError(str(e) + "- required module not found") -class Platform(PlatformBase): - """Platform-specific Platform class""" +class Pcie(PcieUtil): + """Edgecore Platform-specific PCIe class""" - def __init__(self): - PlatformBase.__init__(self) - self._chassis = Chassis() + def __init__(self, platform_path): + PcieUtil.__init__(self, platform_path) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/psu.py index 1b260fccae63..f39fde167048 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/psu.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/psu.py @@ -26,6 +26,15 @@ def get_maximum_supplied_power(self): """ return float(self.PLATFORM_PSU_CAPACITY) + def get_capacity(self): + """ + Gets the capacity (maximum output power) of the PSU in watts + + Returns: + An integer, the capacity of PSU + """ + return (self.PLATFORM_PSU_CAPACITY) + def get_type(self): """ Gets the type of the PSU @@ -33,3 +42,6 @@ def get_type(self): A string, the type of PSU (AC/DC) """ return "DC" + + def get_name(self): + return "PSU-{}".format(self.psu_index) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/sfp.py index d9b6e491bef4..56de2221fe69 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/sfp.py @@ -1,7 +1,10 @@ #!/usr/bin/env python try: + import natsort from sonic_platform_pddf_base.pddf_sfp import PddfSfp + from sonic_platform_base.sonic_sfp.sfputilhelper import SfpUtilHelper + from sonic_py_common import device_info except ImportError as e: raise ImportError (str(e) + "- required module not found") @@ -15,3 +18,38 @@ def __init__(self, index, pddf_data=None, pddf_plugin_data=None): PddfSfp.__init__(self, index, pddf_data, pddf_plugin_data) # Provide the functions/variables below for which implementation is to be overwritten + def __get_path_to_port_config_file(self): + platform, hwsku = device_info.get_platform_and_hwsku() + hwsku_path = "/".join(["/usr/share/sonic/platform",hwsku]) + return "/".join([hwsku_path, "port_config.ini"]) + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + sfputil_helper = SfpUtilHelper() + sfputil_helper.read_porttab_mappings( + self.__get_path_to_port_config_file()) + + logical_port_list = sfputil_helper.logical + logical_port_list = natsort.natsorted(logical_port_list) + name = logical_port_list[self.port_index-1] or "Unknown" + + return name + + def get_position_in_parent(self): + """Retrieves 1-based relative physical position in parent device.""" + return self.port_index + + def get_error_description(self): + """ + Retrives the error descriptions of the SFP module + + Returns: + String that represents the current error descriptions of vendor specific errors + In case there are multiple errors, they should be joined by '|', + like: "Bad EEPROM|Unsupported cable" + """ + raise NotImplementedError diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/thermal.py index 77d6ec7ae886..90517ba9821b 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/thermal.py @@ -13,5 +13,25 @@ class Thermal(PddfThermal): def __init__(self, index, pddf_data=None, pddf_plugin_data=None, is_psu_thermal=False, psu_index=0): PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data, is_psu_thermal, psu_index) + + self.pddf_obj = pddf_data + self.thermal_obj_name = "TEMP{}".format(self.thermal_index) + self.thermal_obj = self.pddf_obj.data[self.thermal_obj_name] # Provide the functions/variables below for which implementation is to be overwritten + def get_name(self): + if self.is_psu_thermal: + return "PSU-{0} temp sensor 1".format(self.thermals_psu_index) + else: + if 'dev_attr' in self.thermal_obj.keys(): + if 'display_name' in self.thermal_obj['dev_attr']: + return str(self.thermal_obj['dev_attr']['display_name']) + + # In case of errors + return "Temp sensor {0}".format(self.thermal_index) + + def get_status(self): + get_temp=self.get_temperature() + + if get_temp is not None: + return True if get_temp else False diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_pddf_monitor.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_pddf_monitor.py index 7f3add4e4d2b..0db5471b0b85 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_pddf_monitor.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_pddf_monitor.py @@ -30,6 +30,7 @@ import logging.handlers import time from sonic_platform import platform + from sonic_py_common.general import getstatusoutput_noshell except ImportError as e: raise ImportError('%s - required module not found' % str(e)) @@ -294,15 +295,46 @@ def main(argv): global platform_chassis platform_chassis = platform.Platform().get_chassis() + #cmd_str = ["i2cset", "-y", "-f", "11", "0x66", "0x33", "0x0"] + #status, output = getstatusoutput_noshell(cmd_str) + #if status: + # print("Warning: Fan speed watchdog could not be disabled") + + cmd_str = ["i2cset", "-y", "-f", "11", "0x66", "0x33", "0x1"] + status, output = getstatusoutput_noshell(cmd_str) + if status: + print("Warning: Fan speed watchdog could not be enabled") + + #Timer need to be set after enable. + #if set timer is eralier than enable wdt. Speed will become to wdt speed after 6sec. + cmd_str = ["i2cset", "-y", "-f", "11", "0x66", "0x31", "0xF0"] + status, output = getstatusoutput_noshell(cmd_str) + if status: + print("Warning: Fan speed watchdog timer could not be disabled") platform_chassis.get_fan(0).set_speed(38) print("set default fan speed to 37.5%") monitor = device_monitor(log_file, log_level) + + cmd_kick = ["i2cset", "-y", "-f", "11", "0x66", "0x31", "0xF0"] #kick WDT + cmd_check_wdt = ["i2cget", "-y", "-f", "11", "0x66", "0x33"] while True: monitor.manage_fans() + getstatusoutput_noshell(cmd_kick) time.sleep(5) + #polling to check fan-wdt status + status, output = getstatusoutput_noshell(cmd_check_wdt) + if status is not None: + val= int(output,16) + if (val & 0x1) == 0: + logging.warning('Detect Fan-WDT disable') + logging.warning('Try to enable Fan-WDT') + cmd_str = ["i2cset", "-y", "-f", "11", "0x66", "0x33", "0x1"] + getstatusoutput_noshell(cmd_str) + cmd_str = ["i2cset", "-y", "-f", "11", "0x66", "0x31", "0xF0"] + getstatusoutput_noshell(cmd_str) if __name__ == '__main__': diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/pddf_post_device_create.sh b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/pddf_post_device_create.sh deleted file mode 100755 index bfa545595338..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/pddf_post_device_create.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set_pca_mux_idle_disconnect() -{ - echo -2 | tee /sys/bus/i2c/drivers/pca954x/*-00*/idle_state >& /dev/null - if [ $? -ne 0 ]; then - echo Fail to set pca954x mux idle disconnect - exit 2 - fi -} - -set_pca_mux_idle_disconnect From ec1af3dd3b5679cd0e456236e5357fd2e1b7d72e Mon Sep 17 00:00:00 2001 From: jostar-yang Date: Fri, 17 Feb 2023 14:59:29 +0800 Subject: [PATCH 02/14] Modify devices_to_ignore to psu_fan speed --- .../system_health_monitoring_config.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/device/accton/x86_64-accton_as7326_56x-r0/system_health_monitoring_config.json b/device/accton/x86_64-accton_as7326_56x-r0/system_health_monitoring_config.json index 18d47b22a9d3..d68bae87a9bb 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/system_health_monitoring_config.json +++ b/device/accton/x86_64-accton_as7326_56x-r0/system_health_monitoring_config.json @@ -2,8 +2,10 @@ "services_to_ignore": [], "devices_to_ignore": [ "asic", - "psu.temperature" - + "psu.voltage", + "psu.temperature", + "PSU-1 FAN-1.speed", + "PSU-2 FAN-1.speed" ], "user_defined_checkers": [], "polling_interval": 60, From 785adc8cd1735d7f31c1b0ef2106222fae172bfe Mon Sep 17 00:00:00 2001 From: jostar-yang Date: Tue, 21 Feb 2023 14:01:27 +0800 Subject: [PATCH 03/14] Add psu_fan target speed api --- .../pddf/pddf-device.json | 18 +++++++++++- .../x86_64-accton_as7326_56x-r0/platform.json | 2 +- .../system_health_monitoring_config.json | 4 +-- .../as7326-56x/sonic_platform/chassis.py | 29 +++++++++++++++++++ .../as7326-56x/sonic_platform/fan.py | 13 +++++++++ 5 files changed, 61 insertions(+), 5 deletions(-) diff --git a/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json b/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json index 3cb36d423757..94065e4d01d9 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json +++ b/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json @@ -5,7 +5,7 @@ "num_fantrays":6, "num_fans_pertray":2, "num_ports":58, - "num_temps": 4, + "num_temps": 5, "pddf_dev_types": { "description":"AS7326-56X - Below is the list of supported PDDF device types (chip names) for various components. If any component uses some other driver, we will create the client using 'echo > /new_device' method", @@ -366,6 +366,22 @@ ] } }, + "TEMP5" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP5"}, + "dev_attr": { "display_name":"coretemp-isa-0000"}, + "i2c": + { + "path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon0"}, + "attr_list": + [ + { "attr_name": "temp1_high_crit_threshold", "drv_attr_name":"temp1_crit"}, + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp1_max"}, + { "attr_name": "temp1_input"} + ] + } + }, + "FAN-CTRL": { "dev_info": { "device_type":"FAN", "device_name":"FAN-CTRL", "device_parent":"MUX2"}, diff --git a/device/accton/x86_64-accton_as7326_56x-r0/platform.json b/device/accton/x86_64-accton_as7326_56x-r0/platform.json index 29a825ad27e9..9110685614f6 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/platform.json +++ b/device/accton/x86_64-accton_as7326_56x-r0/platform.json @@ -209,7 +209,7 @@ "high-crit-threshold": true }, { - "name": "CPU Temp", + "name": "coretemp-isa-0000", "controllable": true, "low-threshold": false, "high-threshold": true, diff --git a/device/accton/x86_64-accton_as7326_56x-r0/system_health_monitoring_config.json b/device/accton/x86_64-accton_as7326_56x-r0/system_health_monitoring_config.json index d68bae87a9bb..99cd016ec0f6 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/system_health_monitoring_config.json +++ b/device/accton/x86_64-accton_as7326_56x-r0/system_health_monitoring_config.json @@ -3,9 +3,7 @@ "devices_to_ignore": [ "asic", "psu.voltage", - "psu.temperature", - "PSU-1 FAN-1.speed", - "PSU-2 FAN-1.speed" + "psu.temperature" ], "user_defined_checkers": [], "polling_interval": 60, diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/chassis.py index c579b219c44c..a471e3308962 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/chassis.py @@ -101,3 +101,32 @@ def get_port_or_cage_type(self, port): return SfpBase.SFP_PORT_TYPE_BIT_QSFP | SfpBase.SFP_PORT_TYPE_BIT_QSFP_PLUS | SfpBase.SFP_PORT_TYPE_BIT_QSFP28 else: return SfpBase.SFP_PORT_TYPE_BIT_SFP + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. + If the agent cannot determine the parent-relative position + for some reason, or if the associated value of + entPhysicalContainedIn is'0', then the value '-1' is returned + Returns: + integer: The 1-based relative physical position in parent device + or -1 if cannot determine the position + """ + return -1 + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + return 'N/A' \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan.py index 4e70b961b998..694593d03044 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/fan.py @@ -50,3 +50,16 @@ def get_serial(self): string: Serial number of device """ return "N/A" + + def get_target_speed(self): + """ + Retrieves the target (expected) speed of the fan + + Returns: + An integer, the percentage of full fan speed, in the range 0 (off) + to 100 (full speed) + """ + if self.is_psu_fan: + return super().get_speed() + else: + return super().get_target_speed() From ac013c8e835b6d838ec8ba18b8df6955b032f271 Mon Sep 17 00:00:00 2001 From: jostar-yang Date: Tue, 21 Feb 2023 15:17:42 +0800 Subject: [PATCH 04/14] Modify system_health_monitoring_config.json led_color string --- .../system_health_monitoring_config.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/device/accton/x86_64-accton_as7326_56x-r0/system_health_monitoring_config.json b/device/accton/x86_64-accton_as7326_56x-r0/system_health_monitoring_config.json index 99cd016ec0f6..5aacf0c3bb4d 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/system_health_monitoring_config.json +++ b/device/accton/x86_64-accton_as7326_56x-r0/system_health_monitoring_config.json @@ -8,8 +8,8 @@ "user_defined_checkers": [], "polling_interval": 60, "led_color": { - "fault": "STATUS_LED_COLOR_RED", - "normal": "STATUS_LED_COLOR_GREEN", - "booting": "STATUS_LED_COLOR_GREEN_BLINK" + "fault": "red", + "normal": "green", + "booting": "green_blink" } } From 462ea6b27d1002a8fa96206f7b2d561b9f1b3e67 Mon Sep 17 00:00:00 2001 From: michael_shih Date: Tue, 14 Mar 2023 17:49:24 +0800 Subject: [PATCH 05/14] [Edgecore][device][platform] Fixed sonic-mgmt pytest failed items Signed-off-by: michael_shih --- .../x86_64-accton_as7326_56x-r0/pcie.yaml | 18 +- .../x86_64-accton_as7326_56x-r0/platform.json | 411 +++++++++++++++--- .../platform_components.json | 14 + .../as7326-56x/sonic_platform/eeprom.py | 77 +--- .../as7326-56x/sonic_platform/helper.py | 1 + .../as7326-56x/utils/accton_as7326_util.py | 4 +- 6 files changed, 370 insertions(+), 155 deletions(-) create mode 100644 device/accton/x86_64-accton_as7326_56x-r0/platform_components.json diff --git a/device/accton/x86_64-accton_as7326_56x-r0/pcie.yaml b/device/accton/x86_64-accton_as7326_56x-r0/pcie.yaml index af10930e3e0c..6f1be3817af9 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/pcie.yaml +++ b/device/accton/x86_64-accton_as7326_56x-r0/pcie.yaml @@ -94,6 +94,18 @@ id: 8c31 name: 'USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI (rev 05)' +- bus: '00' + dev: '16' + fn: '0' + id: 8c3a + name: 'Communication controller: Intel Corporation 8 Series/C220 Series Chipset + Family MEI Controller #1 (rev 04)' +- bus: '00' + dev: '16' + fn: '1' + id: 8c3b + name: 'Communication controller: Intel Corporation 8 Series/C220 Series Chipset + Family MEI Controller #2 (rev 04)' - bus: '00' dev: 1c fn: '0' @@ -130,12 +142,6 @@ id: 8c22 name: 'SMBus: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller (rev 05)' -- bus: '00' - dev: 1f - fn: '6' - id: 8c24 - name: 'Signal processing controller: Intel Corporation 8 Series Chipset Family Thermal - Management Controller (rev 05)' - bus: '03' dev: '00' fn: '0' diff --git a/device/accton/x86_64-accton_as7326_56x-r0/platform.json b/device/accton/x86_64-accton_as7326_56x-r0/platform.json index 9110685614f6..a10ec3de5d8f 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/platform.json +++ b/device/accton/x86_64-accton_as7326_56x-r0/platform.json @@ -387,126 +387,393 @@ "name": "Ethernet76" } ] + }, + } + ] }, "interfaces": { + "Ethernet0": { + "index": "1", + "lanes": "3", + "breakout_modes": { + "1x25G": ["Eth1(Port1)"] + } + }, + + "Ethernet1": { + "index": "2", + "lanes": "2", + "breakout_modes": { + "1x25G": ["Eth2(Port2)"] + } + }, + + "Ethernet2": { + "index": "3", + "lanes": "4", + "breakout_modes": { + "1x25G": ["Eth3(Port3)"] + } + }, + + "Ethernet3": { + "index": "4", + "lanes": "8", + "breakout_modes": { + "1x25G": ["Eth4(Port4)"] + } + }, + + "Ethernet4": { + "index": "5", + "lanes": "7", + "breakout_modes": { + "1x25G": ["Eth5(Port5)"] + } + }, + "Ethernet5": { - "index": "6,2,1,3", - "lanes": "1,2,3,4", + "index": "6", + "lanes": "1", "breakout_modes": { - "4x25G": ["Eth6/1(Port6)", "Eth6/2(Port2)", "Eth6/3(Port1)", "Eth6/4(Port3)"], - "4x10G[1G]": ["Eth6/1(Port6)", "Eth6/2(Port2)", "Eth6/3(Port1)", "Eth6/4(Port3)"] - }, - "interface_ids": "5,1,0,2" + "1x25G": ["Eth6(Port6)"] + } }, "Ethernet6": { - "index": "7,9,5,4", - "lanes": "5,6,7,8", + "index": "7", + "lanes": "5", "breakout_modes": { - "4x25G": ["Eth7/1(Port7)", "Eth7/2(Port9)", "Eth7/3(Port5)", "Eth7/4(Port4)"], - "4x10G[1G]": ["Eth7/1(Port7)", "Eth7/2(Port9)", "Eth7/3(Port5)", "Eth7/4(Port4)"] - }, - "interface_ids": "6,8,4,3" + "1x25G": ["Eth7(Port7)"] + } + }, + + "Ethernet7": { + "index": "8", + "lanes": "16", + "breakout_modes": { + "1x25G": ["Eth8(Port8)"] + } + }, + + "Ethernet8": { + "index": "9", + "lanes": "6", + "breakout_modes": { + "1x25G": ["Eth9(Port9)"] + } + }, + + "Ethernet9": { + "index": "10", + "lanes": "14", + "breakout_modes": { + "1x25G": ["Eth10(Port10)"] + } }, "Ethernet10": { - "index": "11,10,12,8", - "lanes": "13,14,15,16", + "index": "11", + "lanes": "13", "breakout_modes": { - "4x25G": ["Eth11/1(Port11)", "Eth11/2(Port10)", "Eth11/3(Port12)", "Eth11/4(Port8)"], - "4x10G[1G]": ["Eth11/1(Port11)", "Eth11/2(Port10)", "Eth11/3(Port12)", "Eth11/4(Port8)"] - }, - "interface_ids": "10,9,11,7" + "1x25G": ["Eth11(Port11)"] + } + }, + + "Ethernet11": { + "index": "12", + "lanes": "15", + "breakout_modes": { + "1x25G": ["Eth12(Port12)"] + } + }, + + "Ethernet12": { + "index": "13", + "lanes": "23", + "breakout_modes": { + "1x25G": ["Eth13(Port13)"] + } + }, + + "Ethernet13": { + "index": "14", + "lanes": "22", + "breakout_modes": { + "1x25G": ["Eth14(Port14)"] + } + }, + + "Ethernet14": { + "index": "15", + "lanes": "24", + "breakout_modes": { + "1x25G": ["Eth15(Port15)"] + } + }, + + "Ethernet15": { + "index": "16", + "lanes": "32", + "breakout_modes": { + "1x25G": ["Eth16(Port16)"] + } + }, + + "Ethernet16": { + "index": "17", + "lanes": "31", + "breakout_modes": { + "1x25G": ["Eth17(Port17)"] + } }, "Ethernet17": { - "index": "18,14,13,15", - "lanes": "21,22,23,24", + "index": "18", + "lanes": "21", "breakout_modes": { - "4x25G": ["Eth18/1(Port18)", "Eth18/2(Port14)", "Eth18/3(Port13)", "Eth18/4(Port15)"], - "4x10G[1G]": ["Eth18/1(Port18)", "Eth18/2(Port14)", "Eth18/3(Port13)", "Eth18/4(Port15)"] - }, - "interface_ids": "17,13,12,14" + "1x25G": ["Eth18(Port18)"] + } }, "Ethernet18": { - "index": "19,21,17,16", - "lanes": "29,30,31,32", + "index": "19", + "lanes": "29", "breakout_modes": { - "4x25G": ["Eth19/1(Port19)", "Eth19/2(Port21)", "Eth19/3(Port17)", "Eth19/4(Port16)"], - "4x10G[1G]": ["Eth19/1(Port19)", "Eth19/2(Port21)", "Eth19/3(Port17)", "Eth19/4(Port16)"] - }, - "interface_ids": "18,20,16,15" + "1x25G": ["Eth19(Port19)"] + } + }, + + "Ethernet19": { + "index": "20", + "lanes": "36", + "breakout_modes": { + "1x25G": ["Eth20(Port20)"] + } + }, + + "Ethernet20": { + "index": "21", + "lanes": "30", + "breakout_modes": { + "1x25G": ["Eth21(Port21)"] + } + }, + + "Ethernet21": { + "index": "22", + "lanes": "34", + "breakout_modes": { + "1x25G": ["Eth22(Port22)"] + } }, "Ethernet22": { - "index": "23,22,24,20", - "lanes": "33,34,35,36", + "index": "23", + "lanes": "33", "breakout_modes": { - "4x25G": ["Eth23/1(Port23)", "Eth23/2(Port22)", "Eth23/3(Port24)", "Eth23/4(Port20)"], - "4x10G[1G]": ["Eth23/1(Port23)", "Eth23/2(Port22)", "Eth23/3(Port24)", "Eth23/4(Port20)"] - }, - "interface_ids": "22,21,23,19" + "1x25G": ["Eth23(Port23)"] + } + }, + + "Ethernet23": { + "index": "24", + "lanes": "35", + "breakout_modes": { + "1x25G": ["Eth24(Port24)"] + } + }, + + "Ethernet24": { + "index": "25", + "lanes": "43", + "breakout_modes": { + "1x25G": ["Eth25(Port25)"] + } + }, + + "Ethernet25": { + "index": "26", + "lanes": "42", + "breakout_modes": { + "1x25G": ["Eth26(Port26)"] + } + }, + + "Ethernet26": { + "index": "27", + "lanes": "44", + "breakout_modes": { + "1x25G": ["Eth27(Port27)"] + } + }, + + "Ethernet27": { + "index": "28", + "lanes": "52", + "breakout_modes": { + "1x25G": ["Eth28(Port28)"] + } + }, + + "Ethernet28": { + "index": "29", + "lanes": "51", + "breakout_modes": { + "1x25G": ["Eth29(Port29)"] + } }, "Ethernet29": { - "index": "30,26,25,27", - "lanes": "41,42,43,44", + "index": "30", + "lanes": "41", "breakout_modes": { - "4x25G": ["Eth30/1(Port30)", "Eth30/2(Port26)", "Eth30/3(Port25)", "Eth30/4(Port27)"], - "4x10G[1G]": ["Eth30/1(Port30)", "Eth30/2(Port26)", "Eth30/3(Port25)", "Eth30/4(Port27)"] - }, - "interface_ids": "29,25,24,26" + "1x25G": ["Eth30(Port30)"] + } }, "Ethernet30": { - "index": "31,33,29,28", - "lanes": "49,50,51,52", + "index": "31", + "lanes": "49", "breakout_modes": { - "4x25G": ["Eth31/1(Port31)", "Eth31/2(Port33)", "Eth31/3(Port29)", "Eth31/4(Port28)"], - "4x10G[1G]": ["Eth31/1(Port31)", "Eth31/2(Port33)", "Eth31/3(Port29)", "Eth31/4(Port28)"] - }, - "interface_ids": "30,32,28,27" + "1x25G": ["Eth31(Port31)"] + } + }, + + "Ethernet31": { + "index": "32", + "lanes": "60", + "breakout_modes": { + "1x25G": ["Eth32(Port32)"] + } + }, + + "Ethernet32": { + "index": "33", + "lanes": "50", + "breakout_modes": { + "1x25G": ["Eth33(Port33)"] + } + }, + + "Ethernet33": { + "index": "34", + "lanes": "58", + "breakout_modes": { + "1x25G": ["Eth34(Port34)"] + } }, "Ethernet34": { - "index": "35,34,36,32", - "lanes": "57,58,59,60", + "index": "35", + "lanes": "57", "breakout_modes": { - "4x25G": ["Eth35/1(Port35)", "Eth35/2(Port34)", "Eth35/3(Port36)", "Eth35/4(Port32)"], - "4x10G[1G]": ["Eth35/1(Port35)", "Eth35/2(Port34)", "Eth35/3(Port36)", "Eth35/4(Port32)"] - }, - "interface_ids": "34,33,35,31" + "1x25G": ["Eth35(Port35)"] + } + }, + + "Ethernet35": { + "index": "36", + "lanes": "59", + "breakout_modes": { + "1x25G": ["Eth36(Port36)"] + } + }, + + "Ethernet36": { + "index": "37", + "lanes": "62", + "breakout_modes": { + "1x25G": ["Eth37(Port37)"] + } + }, + + "Ethernet37": { + "index": "38", + "lanes": "63", + "breakout_modes": { + "1x25G": ["Eth38(Port38)"] + } + }, + + "Ethernet38": { + "index": "39", + "lanes": "64", + "breakout_modes": { + "1x25G": ["Eth39(Port39)"] + } }, "Ethernet39": { - "index": "40,41,45,43", - "lanes": "65,66,67,68", + "index": "40", + "lanes": "65", "breakout_modes": { - "4x25G": ["Eth40/1(Port40)", "Eth40/2(Port41)", "Eth40/3(Port45)", "Eth40/4(Port43)"], - "4x10G[1G]": ["Eth40/1(Port40)", "Eth40/2(Port41)", "Eth40/3(Port45)", "Eth40/4(Port43)"] - }, - "interface_ids": "39,40,44,42" + "1x25G": ["Eth40(Port40)"] + } + }, + + "Ethernet40": { + "index": "41", + "lanes": "66", + "breakout_modes": { + "1x25G": ["Eth41(Port41)"] + } }, "Ethernet41": { - "index": "42,37,38,39", - "lanes": "61,62,63,64", + "index": "42", + "lanes": "61", "breakout_modes": { - "4x25G": ["Eth42/1(Port42)", "Eth42/2(Port37)", "Eth42/3(Port38)", "Eth42/4(Port39)"], - "4x10G[1G]": ["Eth42/1(Port42)", "Eth42/2(Port37)", "Eth42/3(Port38)", "Eth42/4(Port39)"] - }, - "interface_ids": "41,36,37,38" + "1x25G": ["Eth42(Port42)"] + } + }, + + "Ethernet42": { + "index": "43", + "lanes": "68", + "breakout_modes": { + "1x25G": ["Eth43(Port43)"] + } }, "Ethernet43": { - "index": "44,48,46,47", - "lanes": "69,70,71,72", + "index": "44", + "lanes": "69", "breakout_modes": { - "4x25G": ["Eth44/1(Port44)", "Eth44/2(Port48)", "Eth44/3(Port46)", "Eth44/4(Port47)"], - "4x10G[1G]": ["Eth44/1(Port44)", "Eth44/2(Port48)", "Eth44/3(Port46)", "Eth44/4(Port47)"] - }, - "interface_ids": "43,47,45,46" + "1x25G": ["Eth44(Port44)"] + } + }, + + "Ethernet44": { + "index": "45", + "lanes": "67", + "breakout_modes": { + "1x25G": ["Eth45(Port45)"] + } + }, + + "Ethernet45": { + "index": "46", + "lanes": "71", + "breakout_modes": { + "1x25G": ["Eth46(Port46)"] + } + }, + + "Ethernet46": { + "index": "47", + "lanes": "72", + "breakout_modes": { + "1x25G": ["Eth47(Port47)"] + } + }, + + "Ethernet47": { + "index": "48", + "lanes": "70", + "breakout_modes": { + "1x25G": ["Eth48(Port48)"] + } }, "Ethernet48": { diff --git a/device/accton/x86_64-accton_as7326_56x-r0/platform_components.json b/device/accton/x86_64-accton_as7326_56x-r0/platform_components.json new file mode 100644 index 000000000000..c32d4ac00d2a --- /dev/null +++ b/device/accton/x86_64-accton_as7326_56x-r0/platform_components.json @@ -0,0 +1,14 @@ +{ + "chassis": { + "7326-56X-O-AC-F": { + "component": { + "MB_CPLD1": { }, + "MB_CPLD2": { }, + "MB_CPLD3": { }, + "FAN_CPLD": { }, + "CPU_CPLD": { }, + "BIOS": { } + } + } + } +} diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/eeprom.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/eeprom.py index ca9b5ce062d1..b0fbd57ac732 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/eeprom.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/eeprom.py @@ -2,87 +2,14 @@ try: from sonic_platform_pddf_base.pddf_eeprom import PddfEeprom - import os except ImportError as e: raise ImportError(str(e) + "- required module not found") -CACHE_ROOT = '/var/cache/sonic/decode-syseeprom' -CACHE_FILE = 'syseeprom_cache' class Eeprom(PddfEeprom): - _TLV_INFO_MAX_LEN = 256 - pddf_obj = {} - plugin_data = {} def __init__(self, pddf_data=None, pddf_plugin_data=None): - #PddfEeprom.__init__(self, pddf_data, pddf_plugin_data) - if not pddf_data or not pddf_plugin_data: - raise ValueError('PDDF JSON data error') - - self.pddf_obj = pddf_data - self.plugin_data = pddf_plugin_data - - # system EEPROM always has device name EEPROM1 - self.eeprom_path = self.pddf_obj.get_path("EEPROM1", "eeprom") - if self.eeprom_path is None: - return - - super(PddfEeprom, self).__init__(self.eeprom_path, 0, '', True) - self.eeprom_tlv_dict = dict() - - # Create the cache directory if not created - if not os.path.exists(CACHE_ROOT): - try: - os.makedirs(CACHE_ROOT) - except Exception as e: - print("Error in creating Eeprom cache directory - {}".format(str(e))) - - # Assign cache_name in eeprom_base.py - try: - self.set_cache_name(os.path.join(CACHE_ROOT, CACHE_FILE)) - except: - pass - - try: - self.eeprom_data = self.read_eeprom() - except Exception as e: - self.eeprom_data = "N/A" - raise RuntimeError("Eeprom is not Programmed - Error: {}".format(str(e))) - else: - eeprom = self.eeprom_data - - try: - self.update_cache(eeprom) - except: - pass - - if not self.is_valid_tlvinfo_header(eeprom): - return - - total_length = ((eeprom[9]) << 8) | (eeprom[10]) - tlv_index = self._TLV_INFO_HDR_LEN - tlv_end = self._TLV_INFO_HDR_LEN + total_length - - while (tlv_index + 2) < len(eeprom) and tlv_index < tlv_end: - if not self.is_valid_tlv(eeprom[tlv_index:]): - break - - tlv = eeprom[tlv_index:tlv_index + 2 - + (eeprom[tlv_index + 1])] - code = "0x%02X" % ((tlv[0])) - - if (tlv[0]) == self._TLV_CODE_VENDOR_EXT: - value = str(((tlv[2]) << 24) | ((tlv[3]) << 16) | - ((tlv[4]) << 8) | (tlv[5])) - value += str(tlv[6:6 + (tlv[1])]) - else: - name, value = self.decoder(None, tlv) - - self.eeprom_tlv_dict[code] = value - if (eeprom[tlv_index]) == self._TLV_CODE_CRC_32: - break - - tlv_index += (eeprom[tlv_index+1]) + 2 - + PddfEeprom.__init__(self, pddf_data, pddf_plugin_data) # Provide the functions/variables below for which implementation is to be overwritten + diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/helper.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/helper.py index 09c2af7a8756..c3b0f1d2f451 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/helper.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/helper.py @@ -3,6 +3,7 @@ import subprocess from mmap import * from sonic_py_common import device_info +from sonic_py_common.general import getstatusoutput_noshell HOST_CHK_CMD = ["docker"] EMPTY_STRING = "" diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_util.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_util.py index f4335bd44566..f934743254f9 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_util.py @@ -100,9 +100,9 @@ def show_help(): def dis_i2c_ir3570a(addr): - cmd = ["i2cset", "-y", "0", "0x"+"%x"%addr, "0xE5", "0x01"] + cmd = ["i2cset", "-y", "-a", "0", "0x"+"%x"%addr, "0xE5", "0x01"] status, output = getstatusoutput_noshell(cmd) - cmd = ["i2cset", "-y", "0", "0x"+"%x"%addr, "0x12", "0x02"] + cmd = ["i2cset", "-y", "-a", "0", "0x"+"%x"%addr, "0x12", "0x02"] status, output = getstatusoutput_noshell(cmd) return status From 7f31b11b07d03df1d5c838a1c6d7748d96ddb33b Mon Sep 17 00:00:00 2001 From: michael_shih Date: Wed, 15 Mar 2023 09:31:57 +0800 Subject: [PATCH 06/14] [Edgecore][device][platform] Fixed platform.json format error Signed-off-by: michael_shih --- device/accton/x86_64-accton_as7326_56x-r0/platform.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/device/accton/x86_64-accton_as7326_56x-r0/platform.json b/device/accton/x86_64-accton_as7326_56x-r0/platform.json index a10ec3de5d8f..c2fa56e3eddd 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/platform.json +++ b/device/accton/x86_64-accton_as7326_56x-r0/platform.json @@ -387,9 +387,6 @@ "name": "Ethernet76" } ] - }, - } - ] }, "interfaces": { "Ethernet0": { From 24b5f9edba5bdc27647225c4de29c58b489daa8d Mon Sep 17 00:00:00 2001 From: jostar-yang Date: Thu, 13 Apr 2023 14:52:10 +0800 Subject: [PATCH 07/14] Add get_error_description() support to sfp.py --- .../as7326-56x/sonic_platform/sfp.py | 147 +++++++++++++++++- 1 file changed, 145 insertions(+), 2 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/sfp.py index 56de2221fe69..837d060e995b 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/sfp.py @@ -14,8 +14,20 @@ class Sfp(PddfSfp): PDDF Platform-Specific Sfp class """ + SFP_TYPE_CODE_LIST = [ + 0x03, # SFP/SFP+/SFP28 + 0x0b # DWDM-SFP/SFP+ + ] + QSFP_TYPE_CODE_LIST = [ + 0x0c, # QSFP + 0x0d, # QSFP+ or later + 0x11, # QSFP28 or later + 0xe1 # QSFP28 EDFA + ] + def __init__(self, index, pddf_data=None, pddf_plugin_data=None): PddfSfp.__init__(self, index, pddf_data, pddf_plugin_data) + self.index = self.port_index # Provide the functions/variables below for which implementation is to be overwritten def __get_path_to_port_config_file(self): @@ -28,7 +40,7 @@ def get_name(self): Retrieves the name of the device Returns: string: The name of the device - """ + """ sfputil_helper = SfpUtilHelper() sfputil_helper.read_porttab_mappings( self.__get_path_to_port_config_file()) @@ -42,6 +54,131 @@ def get_name(self): def get_position_in_parent(self): """Retrieves 1-based relative physical position in parent device.""" return self.port_index + + def __validate_eeprom_sfp(self): + checksum_test = 0 + eeprom_raw = self.read_eeprom(0, 96) + if eeprom_raw is None: + return None + + for i in range(0, 63): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[63]: + return False + + checksum_test = 0 + for i in range(64, 95): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[95]: + return False + + api = self.get_xcvr_api() + if api is None: + return False + + if api.is_flat_memory(): + return True + + checksum_test = 0 + eeprom_raw = self.read_eeprom(384, 96) + if eeprom_raw is None: + return None + + for i in range(0, 95): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[95]: + return False + + return True + + def __validate_eeprom_qsfp(self): + checksum_test = 0 + eeprom_raw = self.read_eeprom(128, 96) + if eeprom_raw is None: + return None + + for i in range(0, 63): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[63]: + return False + + checksum_test = 0 + for i in range(64, 95): + checksum_test = (checksum_test + eeprom_raw[i]) & 0xFF + else: + if checksum_test != eeprom_raw[95]: + return False + + api = self.get_xcvr_api() + if api is None: + return False + + if api.is_flat_memory(): + return True + + return True + + def validate_eeprom(self): + id_byte_raw = self.read_eeprom(0, 1) + if id_byte_raw is None: + return None + + id = id_byte_raw[0] + if id in self.QSFP_TYPE_CODE_LIST: + return self.__validate_eeprom_qsfp() + elif id in self.SFP_TYPE_CODE_LIST: + return self.__validate_eeprom_sfp() + else: + return False + + def validate_temperature(self): + temperature = self.get_temperature() + if temperature is None: + return None + + threshold_dict = self.get_transceiver_threshold_info() + if threshold_dict is None: + return None + + if isinstance(temperature, float) is not True: + return True + + if isinstance(threshold_dict['temphighalarm'], float) is not True: + return True + + return threshold_dict['temphighalarm'] > temperature + + def __get_error_description(self): + if not self.get_presence(): + return self.SFP_STATUS_UNPLUGGED + + err_stat = self.SFP_STATUS_BIT_INSERTED + + status = self.validate_eeprom() + if status is not True: + err_stat = (err_stat | self.SFP_ERROR_BIT_BAD_EEPROM) + + status = self.validate_temperature() + if status is not True: + err_stat = (err_stat | self.SFP_ERROR_BIT_HIGH_TEMP) + + if err_stat is self.SFP_STATUS_BIT_INSERTED: + return self.SFP_STATUS_OK + else: + err_desc = '' + cnt = 0 + for key in self.SFP_ERROR_BIT_TO_DESCRIPTION_DICT: + if (err_stat & key) != 0: + if cnt > 0: + err_desc = err_desc + "|" + cnt = cnt + 1 + err_desc = err_desc + self.SFP_ERROR_BIT_TO_DESCRIPTION_DICT[key] + + return err_desc def get_error_description(self): """ @@ -52,4 +189,10 @@ def get_error_description(self): In case there are multiple errors, they should be joined by '|', like: "Bad EEPROM|Unsupported cable" """ - raise NotImplementedError + try: + ret = super().get_error_description() + if ret is not None: + return ret + except NotImplementedError: + pass + return self.__get_error_description() From 6cac6c1050147ae4c58b1dc2ec59133780664e67 Mon Sep 17 00:00:00 2001 From: jostar-yang Date: Tue, 18 Apr 2023 18:16:45 +0800 Subject: [PATCH 08/14] Support multi psu and psu_fan_dir --- .../pddf/pddf-device.json | 8 +- .../as7326-56x/modules/pddf_custom_psu.c | 247 ++++++++++++------ 2 files changed, 175 insertions(+), 80 deletions(-) diff --git a/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json b/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json index 94065e4d01d9..85d219c3bcae 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json +++ b/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json @@ -202,7 +202,6 @@ { "attr_name":"psu_present", "attr_devaddr":"0x60", "attr_devtype":"cpld", "attr_offset":"0x2", "attr_mask":"0x1", "attr_cmpval":"0x0", "attr_len":"1"}, { "attr_name":"psu_power_good", "attr_devaddr":"0x60", "attr_devtype":"cpld", "attr_offset":"0x2", "attr_mask":"0x4", "attr_cmpval":"0x4", "attr_len":"1"}, { "attr_name":"psu_mfr_id", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0X99", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"10" }, - { "attr_name":"psu_fan_dir", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xc3", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"5"}, { "attr_name":"psu_v_out", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8b", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_i_out", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_p_out", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, @@ -224,7 +223,8 @@ "attr_list": [ { "attr_name":"psu_model_name", "attr_devaddr":"0x53", "attr_devtype":"eeprom", "attr_offset":"0x15", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"11" }, - { "attr_name":"psu_serial_num", "attr_devaddr":"0x53", "attr_devtype":"eeprom", "attr_offset":"0x2e", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"17" } + { "attr_name":"psu_serial_num", "attr_devaddr":"0x53", "attr_devtype":"eeprom", "attr_offset":"0x2e", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"17" }, + { "attr_name":"psu_fan_dir", "attr_devaddr":"0x53", "attr_devtype":"eeprom", "attr_offset":"0xc3", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"5"} ] } @@ -254,7 +254,6 @@ { "attr_name":"psu_present", "attr_devaddr":"0x60", "attr_devtype":"cpld", "attr_offset":"0x2", "attr_mask":"0x2", "attr_cmpval":"0x0", "attr_len":"1"}, { "attr_name":"psu_power_good", "attr_devaddr":"0x60", "attr_devtype":"cpld", "attr_offset":"0x2", "attr_mask":"0x8", "attr_cmpval":"0x8", "attr_len":"1"}, { "attr_name":"psu_mfr_id", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0X99", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"10" }, - { "attr_name":"psu_fan_dir", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0xc3", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"5"}, { "attr_name":"psu_v_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8b", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_i_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_p_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, @@ -275,7 +274,8 @@ "attr_list": [ { "attr_name":"psu_model_name", "attr_devaddr":"0x51", "attr_devtype":"eeprom", "attr_offset":"0x15", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"11" }, - { "attr_name":"psu_serial_num", "attr_devaddr":"0x51", "attr_devtype":"eeprom", "attr_offset":"0x2e", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"17" } + { "attr_name":"psu_serial_num", "attr_devaddr":"0x51", "attr_devtype":"eeprom", "attr_offset":"0x2e", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"17" }, + { "attr_name":"psu_fan_dir", "attr_devaddr":"0x51", "attr_devtype":"eeprom", "attr_offset":"0xc3", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"5"} ] } }, diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/pddf_custom_psu.c b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/pddf_custom_psu.c index 18c3edf72a8c..19d16e08564c 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/pddf_custom_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/pddf_custom_psu.c @@ -13,57 +13,81 @@ ssize_t pddf_get_custom_psu_model_name(struct device *dev, struct device_attribute *da, char *buf); ssize_t pddf_get_custom_psu_serial_num(struct device *dev, struct device_attribute *da, char *buf); +ssize_t pddf_get_custom_psu_fan_dir(struct device *dev, struct device_attribute *da, char *buf); extern PSU_SYSFS_ATTR_DATA access_psu_model_name; extern PSU_SYSFS_ATTR_DATA access_psu_serial_num; +extern PSU_SYSFS_ATTR_DATA access_psu_fan_dir; -#define MAX_MODEL_NAME 16 -#define MAX_SERIAL_NUMBER 19 +#define MAX_MODEL_NAME 13 +#define MAX_SERIAL_NUMBER 18 +#define FAN_DIR_LEN 3 + +const char FAN_DIR_F2B[] = "F2B"; +const char FAN_DIR_B2F[] = "B2F"; +const char FAN_DIR_UNKNOWN[] = ""; enum psu_type { - PSU_TYPE_AC_110V, - PSU_TYPE_DC_48V, - PSU_TYPE_DC_12V, - PSU_TYPE_AC_ACBEL_FSF019, - PSU_TYPE_AC_ACBEL_FSF045 + PSU_TYPE_ACBEL_FSF019_AC_F2B, // FSF019-611G + PSU_TYPE_ACBEL_FSF045_AC_B2F, // FSH045-611G + PSU_TYPE_3Y_YM2651YBR_AC_F2B, // YM-2651Y-BR + PSU_TYPE_3Y_YM2651YB01R_AC_F2B, // YM-2651Y-B01R + PSU_TYPE_3Y_YM2651YCR_AC_B2F, // YM-2651Y-CR + PSU_TYPE_3Y_YM2651YC01R_AC_B2F, // YM-2651Y-C01R + PSU_TYPE_3Y_YM2651VBR_DC_F2B, // YM-2651V-BR + PSU_TYPE_3Y_YM2651VCR_DC_B2F, // YM-2651V-CR + PSU_TYPE_3Y_YM2651_SERIES }; struct model_name_info { + char* model_name; enum psu_type type; u8 offset; u8 length; u8 chk_length; - char* model_name; }; - struct serial_number_info { - enum psu_type type; u8 offset; u8 length; - u8 chk_length; - char* serial_number; }; -struct model_name_info models[] = { -{PSU_TYPE_AC_110V, 0x20, 8, 8, "YM-2651Y"}, -{PSU_TYPE_DC_48V, 0x20, 8, 8, "YM-2651V"}, -{PSU_TYPE_DC_12V, 0x00, 11, 11, "PSU-12V-750"}, -{PSU_TYPE_AC_ACBEL_FSF019, 0x15, 10, 7, "FSF019-"}, -{PSU_TYPE_AC_ACBEL_FSF045, 0x15, 10, 7, "FSF045-"} - +struct fan_dir_info { + char* model_name; + u8 model_length; + enum psu_type type; + const char* fan_dir; +}; +const struct model_name_info models[] = { + { "FSF019", PSU_TYPE_ACBEL_FSF019_AC_F2B, 0x20, 13, 6 }, + { "FSF045", PSU_TYPE_ACBEL_FSF045_AC_B2F, 0x20, 13, 6 }, + { "YM-2651", PSU_TYPE_3Y_YM2651_SERIES, 0x20, 13, 7 } }; -struct serial_number_info serials[] = { -{PSU_TYPE_AC_110V, 0x2e, 18, 18, "YM-2651Y"}, -{PSU_TYPE_DC_48V, 0x2e, 18, 18, "YM-2651V"}, -{PSU_TYPE_DC_12V, 0x2e, 18, 18, "PSU-12V-750"}, -{PSU_TYPE_AC_ACBEL_FSF019, 0x2e, 16, 16, "FSF019-"}, -{PSU_TYPE_AC_ACBEL_FSF019, 0x2e, 16, 16, "FSF045-"} +const struct fan_dir_info fan_dirs[] = { + { "FSF019", 6, PSU_TYPE_ACBEL_FSF019_AC_F2B, FAN_DIR_F2B }, + { "FSF045", 6, PSU_TYPE_ACBEL_FSF045_AC_B2F, FAN_DIR_B2F }, + { "YM-2651Y-BR", 11, PSU_TYPE_3Y_YM2651YBR_AC_F2B, FAN_DIR_F2B }, + { "YM-2651Y-B01R", 13, PSU_TYPE_3Y_YM2651YB01R_AC_F2B, FAN_DIR_F2B }, + { "YM-2651Y-CR", 11, PSU_TYPE_3Y_YM2651YCR_AC_B2F, FAN_DIR_B2F }, + { "YM-2651Y-C01R", 13, PSU_TYPE_3Y_YM2651YC01R_AC_B2F, FAN_DIR_B2F }, + { "YM-2651V-BR", 11, PSU_TYPE_3Y_YM2651VBR_DC_F2B, FAN_DIR_F2B }, + { "YM-2651V-CR", 11, PSU_TYPE_3Y_YM2651VCR_DC_B2F, FAN_DIR_B2F } +}; +const struct serial_number_info serials[] = { + [PSU_TYPE_ACBEL_FSF019_AC_F2B] = { 0x2e, 16 }, + [PSU_TYPE_ACBEL_FSF045_AC_B2F] = { 0x2e, 16 }, + [PSU_TYPE_3Y_YM2651YBR_AC_F2B] = { 0x2e, 18 }, + [PSU_TYPE_3Y_YM2651YB01R_AC_F2B] = { 0x2e, 18 }, + [PSU_TYPE_3Y_YM2651YCR_AC_B2F] = { 0x2e, 18 }, + [PSU_TYPE_3Y_YM2651YC01R_AC_B2F] = { 0x35, 18 }, + [PSU_TYPE_3Y_YM2651VBR_DC_F2B] = { 0x2e, 18 }, + [PSU_TYPE_3Y_YM2651VCR_DC_B2F] = { 0x2e, 18 } }; struct pddf_psu_data { char model_name[MAX_MODEL_NAME+1]; char serial_number[MAX_SERIAL_NUMBER+1]; + char fan_dir[FAN_DIR_LEN+1]; }; @@ -96,53 +120,116 @@ static int pddf_psu_read_block(struct i2c_client *client, u8 command, u8 *data, return result; } -ssize_t pddf_get_custom_psu_serial_num(struct device *dev, struct device_attribute *da, char *buf) +/* Get type and model_name + */ +static int pddf_get_model_name_and_type(struct i2c_client *client, enum psu_type *get_type, struct pddf_psu_data *get_data) { - struct i2c_client *client = to_i2c_client(dev); - struct pddf_psu_data data; + char model_name[MAX_MODEL_NAME+1]; int i, status; - + enum psu_type type; + + get_data->model_name[0]='\0'; + *get_type = PSU_TYPE_ACBEL_FSF019_AC_F2B; for (i = 0; i < ARRAY_SIZE(models); i++) { - memset(data.serial_number, 0, sizeof(data.serial_number)); - + model_name[0]='\0'; + if ((models[i].length+1) > ARRAY_SIZE(model_name)) { + dev_dbg(&client->dev, + "invalid models[%d].length(%d), should not exceed the size of data->model_name(%ld)\n", + i, models[i].length, ARRAY_SIZE(model_name)); + continue; + } + status = pddf_psu_read_block(client, models[i].offset, - data.model_name, models[i].length); + model_name, models[i].length); if (status < 0) { - data.model_name[0] = '\0'; + model_name[0] = '\0'; dev_dbg(&client->dev, "unable to read model name from (0x%x) offset(0x%x)\n", client->addr, models[i].offset); return status; } else { - data.model_name[models[i].length] = '\0'; + model_name[models[i].length>=(sizeof(model_name)-1)?(sizeof(model_name)-1):models[i].length] = '\0'; } /* Determine if the model name is known, if not, read next index */ - if (strncmp(data.model_name, models[i].model_name, models[i].chk_length) == 0) { - status = pddf_psu_read_block(client, serials[i].offset, - data.serial_number, serials[i].length); - - if (status < 0) { - data.serial_number[0] = '\0'; - dev_dbg(&client->dev, "unable to read serial num from (0x%x) offset(0x%x)\n", - client->addr, serials[i].offset); - return status; - } - else { - data.serial_number[serials[i].length] = '\0'; - return sprintf(buf, "%s\n", data.serial_number); - } - - return 0; + if (strncmp(model_name, models[i].model_name, models[i].chk_length) == 0) { + type = models[i].type; + break; } else { - data.serial_number[0] = '\0'; + model_name[0] = '\0'; } } - return -ENODATA; + /* Remove useless characters for PSU_TYPE_3Y_YM2651_SERIES */ + if (type == PSU_TYPE_3Y_YM2651_SERIES) { + model_name[8] = '-'; + if (!isgraph(model_name[11])) + model_name[11] = '\0'; + } + /* Remove useless characters for PSU_TYPE_ACBEL_FSF* */ + else if ((type == PSU_TYPE_ACBEL_FSF019_AC_F2B) || (type == PSU_TYPE_ACBEL_FSF045_AC_B2F)) { + memmove(&model_name[7], &model_name[9], ARRAY_SIZE(model_name)-9); + model_name[6] = '-'; + model_name[11] = '\0'; + } + else + return -ENODEV; + + /* Determine fan direction and correct the PSU type */ + for (i = 0; i < ARRAY_SIZE(fan_dirs); i++) { + if ((fan_dirs[i].model_length+1) > ARRAY_SIZE(model_name)) { + dev_dbg(&client->dev, + "invalid fan_dirs[%d].model_length(%d), should not exceed the size of data->model_name(%ld)\n", + i, fan_dirs[i].model_length, ARRAY_SIZE(model_name)); + continue; + } + + if (strncmp(model_name, fan_dirs[i].model_name, fan_dirs[i].model_length) == 0) { + type = fan_dirs[i].type; + break; + } + } + if (type >= PSU_TYPE_3Y_YM2651_SERIES) + { + return -ENODEV; + } + + *get_type = type; + memcpy(get_data->model_name, model_name, strlen(model_name)>=sizeof(get_data->model_name)?sizeof(get_data->model_name):strlen(model_name)); + + return 0; +} + +ssize_t pddf_get_custom_psu_serial_num(struct device *dev, struct device_attribute *da, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct pddf_psu_data data; + int status; + enum psu_type type; + + data.serial_number[0]='\0'; + + status = pddf_get_model_name_and_type(client, &type, &data); + if (status < 0) + { + return -ENODEV; + } + + status = pddf_psu_read_block(client, serials[type].offset, + data.serial_number, serials[type].length); + if (status < 0) { + data.serial_number[0] = '\0'; + dev_dbg(&client->dev, "unable to read serial num from (0x%x) offset(0x%x)\n", + client->addr, serials[type].offset); + return status; + } + else { + data.serial_number[serials[type].length >= (sizeof(data.serial_number)-1)?(sizeof(data.serial_number)-1):serials[type].length] = '\0'; + } + return sprintf(buf, "%s\n", data.serial_number); } @@ -150,34 +237,39 @@ ssize_t pddf_get_custom_psu_model_name(struct device *dev, struct device_attribu { struct i2c_client *client = to_i2c_client(dev); struct pddf_psu_data data; - int i, status; + int status; + enum psu_type type; + + status = pddf_get_model_name_and_type(client, &type, &data); + if (status < 0) + { + return -ENODEV; + } - for (i = 0; i < ARRAY_SIZE(models); i++) { - memset(data.model_name, 0, sizeof(data.model_name)); + return sprintf(buf, "%s\n", data.model_name); - status = pddf_psu_read_block(client, models[i].offset, - data.model_name, models[i].length); - if (status < 0) { - data.model_name[0] = '\0'; - dev_dbg(&client->dev, "unable to read model name from (0x%x) offset(0x%x)\n", - client->addr, models[i].offset); - return status; - } - else { - data.model_name[models[i].length] = '\0'; - } +} - /* Determine if the model name is known, if not, read next index - */ - if (strncmp(data.model_name, models[i].model_name, models[i].chk_length) == 0) { - return sprintf(buf, "%s\n", data.model_name); - } - else { - data.model_name[0] = '\0'; - } - } +ssize_t pddf_get_custom_psu_fan_dir(struct device *dev, struct device_attribute *da, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct pddf_psu_data data; + int status; + enum psu_type type; - return -ENODATA; + status = pddf_get_model_name_and_type(client, &type, &data); + if (status < 0) + { + return -ENODEV; + } + + if (type < PSU_TYPE_3Y_YM2651_SERIES) + { + memcpy(data.fan_dir, fan_dirs[type].fan_dir, sizeof(data.fan_dir)); + return sprintf(buf, "%s\n", data.fan_dir); + } + else + return -ENODEV; } @@ -188,6 +280,9 @@ static int __init pddf_custom_psu_init(void) access_psu_model_name.show = pddf_get_custom_psu_model_name; access_psu_model_name.do_get = NULL; + + access_psu_fan_dir.show = pddf_get_custom_psu_fan_dir; + access_psu_fan_dir.do_get = NULL; return 0; } From 52491c0ea0cd96b3e6be84783a3d8f1aeb468527 Mon Sep 17 00:00:00 2001 From: jostar-yang Date: Fri, 28 Apr 2023 18:13:55 +0800 Subject: [PATCH 09/14] Add string '\0' to mode_name array --- .../as7326-56x/modules/pddf_custom_psu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/pddf_custom_psu.c b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/pddf_custom_psu.c index 19d16e08564c..54e19007a8c9 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/pddf_custom_psu.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/pddf_custom_psu.c @@ -167,6 +167,8 @@ static int pddf_get_model_name_and_type(struct i2c_client *client, enum psu_typ model_name[8] = '-'; if (!isgraph(model_name[11])) model_name[11] = '\0'; + else + model_name[MAX_MODEL_NAME] = '\0'; } /* Remove useless characters for PSU_TYPE_ACBEL_FSF* */ else if ((type == PSU_TYPE_ACBEL_FSF019_AC_F2B) || (type == PSU_TYPE_ACBEL_FSF045_AC_B2F)) { @@ -198,7 +200,7 @@ static int pddf_get_model_name_and_type(struct i2c_client *client, enum psu_typ *get_type = type; memcpy(get_data->model_name, model_name, strlen(model_name)>=sizeof(get_data->model_name)?sizeof(get_data->model_name):strlen(model_name)); - + get_data->model_name[strlen(model_name)>=(sizeof(get_data->model_name)-1)?(sizeof(get_data->model_name)-1):strlen(model_name)]='\0'; return 0; } From fc5fd746567bc95cc3e9984c89ae419afa614e5c Mon Sep 17 00:00:00 2001 From: roger530-ho Date: Mon, 26 Jun 2023 01:29:38 +0000 Subject: [PATCH 10/14] fix pytest issue --- .../x86_64-accton_as7326_56x-r0/platform.json | 155 ++++++++++++++---- .../as7326-56x/sonic_platform/psu.py | 20 +-- .../as7326-56x/sonic_platform/thermal.py | 57 +++++++ 3 files changed, 189 insertions(+), 43 deletions(-) diff --git a/device/accton/x86_64-accton_as7326_56x-r0/platform.json b/device/accton/x86_64-accton_as7326_56x-r0/platform.json index c2fa56e3eddd..99dd8305c29d 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/platform.json +++ b/device/accton/x86_64-accton_as7326_56x-r0/platform.json @@ -1,6 +1,7 @@ { "chassis": { "name": "7326-56X", + "thermal_manager":false, "components": [ { "name": "MB_CPLD1" @@ -23,40 +24,88 @@ ], "fans": [ { - "name": "FAN-1F" + "name": "FAN-1F", + "speed": { + "controllable": true, + "minimum": 32 + } }, { - "name": "FAN-1R" + "name": "FAN-1R", + "speed": { + "controllable": true, + "minimum": 32 + } }, { - "name": "FAN-2F" + "name": "FAN-2F", + "speed": { + "controllable": true, + "minimum": 32 + } }, { - "name": "FAN-2R" + "name": "FAN-2R", + "speed": { + "controllable": true, + "minimum": 32 + } }, { - "name": "FAN-3F" + "name": "FAN-3F", + "speed": { + "controllable": true, + "minimum": 32 + } }, { - "name": "FAN-3R" + "name": "FAN-3R", + "speed": { + "controllable": true, + "minimum": 32 + } }, { - "name": "FAN-4F" + "name": "FAN-4F", + "speed": { + "controllable": true, + "minimum": 32 + } }, { - "name": "FAN-4R" + "name": "FAN-4R", + "speed": { + "controllable": true, + "minimum": 32 + } }, { - "name": "FAN-5F" + "name": "FAN-5F", + "speed": { + "controllable": true, + "minimum": 32 + } }, { - "name": "FAN-5R" + "name": "FAN-5R", + "speed": { + "controllable": true, + "minimum": 32 + } }, { - "name": "FAN-6F" + "name": "FAN-6F", + "speed": { + "controllable": true, + "minimum": 32 + } }, { - "name": "FAN-6R" + "name": "FAN-6R", + "speed": { + "controllable": true, + "minimum": 32 + } } ], "fan_drawers":[ @@ -65,10 +114,18 @@ "num_fans" : 2, "fans": [ { - "name": "FAN-1F" + "name": "FAN-1F", + "speed": { + "controllable": true, + "minimum": 32 + } }, { - "name": "FAN-1R" + "name": "FAN-1R", + "speed": { + "controllable": true, + "minimum": 32 + } } ] }, @@ -77,10 +134,18 @@ "num_fans" : 2, "fans": [ { - "name": "FAN-2F" + "name": "FAN-2F", + "speed": { + "controllable": true, + "minimum": 32 + } }, { - "name": "FAN-2R" + "name": "FAN-2R", + "speed": { + "controllable": true, + "minimum": 32 + } } ] }, @@ -89,10 +154,18 @@ "num_fans" : 2, "fans": [ { - "name": "FAN-3F" + "name": "FAN-3F", + "speed": { + "controllable": true, + "minimum": 32 + } }, { - "name": "FAN-3R" + "name": "FAN-3R", + "speed": { + "controllable": true, + "minimum": 32 + } } ] }, @@ -101,10 +174,18 @@ "num_fans" : 2, "fans": [ { - "name": "FAN-4F" + "name": "FAN-4F", + "speed": { + "controllable": true, + "minimum": 32 + } }, { - "name": "FAN-4R" + "name": "FAN-4R", + "speed": { + "controllable": true, + "minimum": 32 + } } ] }, @@ -113,10 +194,18 @@ "num_fans" : 2, "fans": [ { - "name": "FAN-5F" + "name": "FAN-5F", + "speed": { + "controllable": true, + "minimum": 32 + } }, { - "name": "FAN-5R" + "name": "FAN-5R", + "speed": { + "controllable": true, + "minimum": 32 + } } ] }, @@ -125,10 +214,18 @@ "num_fans" : 2, "fans": [ { - "name": "FAN-6F" + "name": "FAN-6F", + "speed": { + "controllable": true, + "minimum": 32 + } }, { - "name": "FAN-6R" + "name": "FAN-6R", + "speed": { + "controllable": true, + "minimum": 32 + } } ] } @@ -182,7 +279,7 @@ "low-threshold": false, "high-threshold": true, "low-crit-threshold": false, - "high-crit-threshold": true + "high-crit-threshold": false }, { "name": "MB_FrontMAC_temp(0x49)", @@ -190,7 +287,7 @@ "low-threshold": false, "high-threshold": true, "low-crit-threshold": false, - "high-crit-threshold": true + "high-crit-threshold": false }, { "name": "MB_LeftCenter_temp(0x4A)", @@ -198,7 +295,7 @@ "low-threshold": false, "high-threshold": true, "low-crit-threshold": false, - "high-crit-threshold": true + "high-crit-threshold": false }, { "name": "MB_RearMAC_temp(0x48)", @@ -206,11 +303,11 @@ "low-threshold": false, "high-threshold": true, "low-crit-threshold": false, - "high-crit-threshold": true + "high-crit-threshold": false }, { "name": "coretemp-isa-0000", - "controllable": true, + "controllable": false, "low-threshold": false, "high-threshold": true, "low-crit-threshold": false, diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/psu.py index f39fde167048..c766b3d491b3 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/psu.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/psu.py @@ -26,22 +26,14 @@ def get_maximum_supplied_power(self): """ return float(self.PLATFORM_PSU_CAPACITY) - def get_capacity(self): - """ - Gets the capacity (maximum output power) of the PSU in watts + def get_name(self): + return "PSU-{}".format(self.psu_index) - Returns: - An integer, the capacity of PSU + def get_revision(self): """ - return (self.PLATFORM_PSU_CAPACITY) + Retrieves the hardware revision of the device - def get_type(self): - """ - Gets the type of the PSU Returns: - A string, the type of PSU (AC/DC) + string: Revision value of device """ - return "DC" - - def get_name(self): - return "PSU-{}".format(self.psu_index) + return 'N/A' diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/thermal.py index 90517ba9821b..328ce462e388 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/thermal.py @@ -17,6 +17,8 @@ def __init__(self, index, pddf_data=None, pddf_plugin_data=None, is_psu_thermal= self.pddf_obj = pddf_data self.thermal_obj_name = "TEMP{}".format(self.thermal_index) self.thermal_obj = self.pddf_obj.data[self.thermal_obj_name] + self.min_temperature = None + self.max_temperature = None # Provide the functions/variables below for which implementation is to be overwritten def get_name(self): @@ -35,3 +37,58 @@ def get_status(self): if get_temp is not None: return True if get_temp else False + + def get_temperature(self): + current = super().get_temperature() + + if self.min_temperature is None or \ + current < self.min_temperature: + self.min_temperature = current + + if self.max_temperature is None or \ + current > self.max_temperature: + self.max_temperature = current + + return current + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + + return "N/A" + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return "N/A" + + def get_minimum_recorded(self): + """ + Retrieves the minimum recorded temperature of thermal + Returns: + A float number, the minimum recorded temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if self.min_temperature is None: + self.get_temperature() + + return self.min_temperature + + def get_maximum_recorded(self): + """ + Retrieves the maximum recorded temperature of thermal + Returns: + A float number, the maximum recorded temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if self.max_temperature is None: + self.get_temperature() + + return self.max_temperature + From 4eeea852e8fe4624b6cfad26e4ff0ff9018d8ff8 Mon Sep 17 00:00:00 2001 From: roger530-ho Date: Mon, 14 Aug 2023 09:18:53 +0000 Subject: [PATCH 11/14] [Edgecore][AS7326-56X] Read the data when the PSU is in the power-good state. --- .../as7326-56x/sonic_platform/psu.py | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/psu.py index c766b3d491b3..899d37be992b 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/psu.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/psu.py @@ -37,3 +37,68 @@ def get_revision(self): string: Revision value of device """ return 'N/A' + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + + Returns: + string: Model/part number of device + """ + model = super().get_model() + if model and model.strip() == "": + return None + + return model + + def get_serial(self): + """ + Retrieves the serial number of the device + + Returns: + string: Serial number of device + """ + serial = super().get_serial() + if serial and serial.strip() == "": + return None + + return serial + + def get_voltage(self): + """ + Retrieves current PSU voltage output + + Returns: + A float number, the output voltage in volts, + e.g. 12.1 + """ + if self.get_status() is not True: + return 0.0 + + return super().get_voltage() + + def get_current(self): + """ + Retrieves present electric current supplied by PSU + + Returns: + A float number, electric current in amperes, + e.g. 15.4 + """ + if self.get_status() is not True: + return 0.0 + + return super().get_current() + + def get_power(self): + """ + Retrieves current energy supplied by PSU + + Returns: + A float number, the power in watts, + e.g. 302.6 + """ + if self.get_status() is not True: + return 0.0 + + return super().get_power() From 3cdb61d8bce1ec12a8511e4986c75aec1dbf7d7f Mon Sep 17 00:00:00 2001 From: roger530-ho Date: Mon, 6 Nov 2023 07:58:41 +0000 Subject: [PATCH 12/14] Fix : Incorrect CPLD value for red blinking --- .../as7326-56x/modules/accton_as7326_56x_leds.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_leds.c b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_leds.c index 035f9ad82ec8..b31702ca1366 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_leds.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_leds.c @@ -59,7 +59,7 @@ static struct accton_as7326_56x_led_data *ledctl = NULL; #define LED_MODE_DIAG_RED_VALUE (0x06) #define LED_MODE_DIAG_BLUE_VALUE (0x03) #define LED_MODE_DIAG_GREEN_BLINK_VALUE (0x17) -#define LED_MODE_DIAG_RED_BLINK_VALUE (0x0d) +#define LED_MODE_DIAG_RED_BLINK_VALUE (0x0f) #define LED_MODE_DIAG_BLUE_BLINK_VALUE (0x27) #define LED_MODE_DIAG_OFF_VALUE (0x07) @@ -69,7 +69,7 @@ static struct accton_as7326_56x_led_data *ledctl = NULL; #define LED_MODE_LOC_RED_VALUE (0x06) #define LED_MODE_LOC_BLUE_VALUE (0x03) #define LED_MODE_LOC_GREEN_BLINK_VALUE (0x17) -#define LED_MODE_LOC_RED_BLINK_VALUE (0x0d) +#define LED_MODE_LOC_RED_BLINK_VALUE (0x0f) #define LED_MODE_LOC_BLUE_BLINK_VALUE (0x27) #define LED_MODE_LOC_OFF_VALUE (0x07) From 5a507b8b2b3abc253f7bda1108b868abd8989e31 Mon Sep 17 00:00:00 2001 From: jostar-yang Date: Fri, 19 Jul 2024 17:49:21 +0800 Subject: [PATCH 13/14] Add psu_p_out_max sysfs and support multi cpu core temp --- .../pddf/pddf-device.json | 69 +++++++++++++++++-- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json b/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json index 85d219c3bcae..9505a3719c07 100644 --- a/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json +++ b/device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json @@ -5,7 +5,7 @@ "num_fantrays":6, "num_fans_pertray":2, "num_ports":58, - "num_temps": 5, + "num_temps": 9, "pddf_dev_types": { "description":"AS7326-56X - Below is the list of supported PDDF device types (chip names) for various components. If any component uses some other driver, we will create the client using 'echo > /new_device' method", @@ -26,7 +26,7 @@ "PORT_MODULE": [ "pddf_xcvr" - ] + ] }, "std_kos": [ @@ -205,6 +205,7 @@ { "attr_name":"psu_v_out", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8b", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_i_out", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_p_out", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_p_out_max", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xa7", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_fan1_speed_rpm", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x90", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_temp1_input", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_v_out_min", "attr_devaddr":"0x5b", "attr_devtype":"pmbus", "attr_offset":"0xa4", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, @@ -257,6 +258,7 @@ { "attr_name":"psu_v_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8b", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_i_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8c", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_p_out", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x96", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, + { "attr_name":"psu_p_out_max", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0xa7", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_fan1_speed_rpm", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x90", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_temp1_input", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0x8d", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, { "attr_name":"psu_v_out_min", "attr_devaddr":"0x59", "attr_devtype":"pmbus", "attr_offset":"0xa4", "attr_mask":"0x0", "attr_cmpval":"0xff", "attr_len":"2"}, @@ -369,7 +371,7 @@ "TEMP5" : { "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP5"}, - "dev_attr": { "display_name":"coretemp-isa-0000"}, + "dev_attr": { "display_name":"CPU_Package_temp"}, "i2c": { "path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon0"}, @@ -381,7 +383,66 @@ ] } }, - + "TEMP6" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP6"}, + "dev_attr": { "display_name":"CPU_Core_0_temp"}, + "i2c": + { + "path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon0"}, + "attr_list": + [ + { "attr_name": "temp1_high_crit_threshold", "drv_attr_name":"temp2_crit"}, + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp2_max"}, + { "attr_name": "temp1_input", "drv_attr_name":"temp2_input"} + ] + } + }, + "TEMP7" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP7"}, + "dev_attr": { "display_name":"CPU_Core_1_temp"}, + "i2c": + { + "path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon0"}, + "attr_list": + [ + { "attr_name": "temp1_high_crit_threshold", "drv_attr_name":"temp3_crit"}, + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp3_max"}, + { "attr_name": "temp1_input", "drv_attr_name":"temp3_input"} + ] + } + }, + "TEMP8" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP8"}, + "dev_attr": { "display_name":"CPU_Core_2_temp"}, + "i2c": + { + "path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon0"}, + "attr_list": + [ + { "attr_name": "temp1_high_crit_threshold", "drv_attr_name":"temp4_crit"}, + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp4_max"}, + { "attr_name": "temp1_input", "drv_attr_name":"temp4_input"} + ] + } + }, + "TEMP9" : + { + "dev_info": { "device_type":"TEMP_SENSOR", "device_name":"TEMP9"}, + "dev_attr": { "display_name":"CPU_Core_3_temp"}, + "i2c": + { + "path_info": {"sysfs_base_path": "/sys/class/hwmon/hwmon0"}, + "attr_list": + [ + { "attr_name": "temp1_high_crit_threshold", "drv_attr_name":"temp5_crit"}, + { "attr_name": "temp1_high_threshold", "drv_attr_name":"temp5_max"}, + { "attr_name": "temp1_input", "drv_attr_name":"temp5_input"} + ] + } + }, "FAN-CTRL": { "dev_info": { "device_type":"FAN", "device_name":"FAN-CTRL", "device_parent":"MUX2"}, From 34a532f9c8ac202d8adaa7dc262a6fd3ab1a3eb9 Mon Sep 17 00:00:00 2001 From: jostar-yang Date: Fri, 30 Aug 2024 15:50:49 +0800 Subject: [PATCH 14/14] Add reset() in sfp.py for check sfp_port to avoid error message --- .../as7326-56x/sonic_platform/sfp.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/sfp.py index 837d060e995b..1aacdfa0fb11 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/sonic_platform/sfp.py @@ -196,3 +196,15 @@ def get_error_description(self): except NotImplementedError: pass return self.__get_error_description() + + def get_reset_status(self): + if self.sfp_type == "QSFP28": + return super().get_reset_status() + return False + + + def reset(self): + if self.sfp_type == "QSFP28": + return super().reset() + else: + return False \ No newline at end of file