diff --git a/.azure-pipelines/azure-pipelines-UpgrateVersion.yml b/.azure-pipelines/azure-pipelines-UpgrateVersion.yml index b0b84cf3b1fb..5cd85ab5520b 100644 --- a/.azure-pipelines/azure-pipelines-UpgrateVersion.yml +++ b/.azure-pipelines/azure-pipelines-UpgrateVersion.yml @@ -11,7 +11,11 @@ schedules: displayName: Daily Build branches: include: - - 202012 + - 20* + exclude: + - 200* + - 201* + - 202006 always: true pool: sonicbld diff --git a/.azure-pipelines/azure-pipelines-repd-build-variables.yml b/.azure-pipelines/azure-pipelines-repd-build-variables.yml new file mode 100644 index 000000000000..7e831109e2ad --- /dev/null +++ b/.azure-pipelines/azure-pipelines-repd-build-variables.yml @@ -0,0 +1,5 @@ +variables: + ${{ if and(ge(variables['Build.SourceBranchName'], '202012'), le(variables['Build.SourceBranchName'], '299999')) }}: + VERSION_CONTROL_OPTIONS: 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web,git,docker' + ${{ if or(lt(variables['Build.SourceBranchName'], '202012'), gt(variables['Build.SourceBranchName'], '299999')) }}: + VERSION_CONTROL_OPTIONS: '' diff --git a/.azure-pipelines/official-build-cache.yml b/.azure-pipelines/official-build-cache.yml index b3c9c6c8767d..4019dbba4f97 100644 --- a/.azure-pipelines/official-build-cache.yml +++ b/.azure-pipelines/official-build-cache.yml @@ -18,7 +18,9 @@ stages: - stage: Build pool: sonicbld variables: - CACHE_MODE: cache + - name: CACHE_MODE + value: cache + - template: azure-pipelines-repd-build-variables.yml jobs: - template: azure-pipelines-build.yml parameters: diff --git a/.azure-pipelines/official-build-multi-asic.yml b/.azure-pipelines/official-build-multi-asic.yml index d220ecc34747..8fe0be32db10 100644 --- a/.azure-pipelines/official-build-multi-asic.yml +++ b/.azure-pipelines/official-build-multi-asic.yml @@ -18,9 +18,9 @@ stages: - stage: Build pool: sonicbld variables: - CACHE_MODE: wcache - ${{ if eq(variables['Build.SourceBranchName'], '202012') }}: - VERSION_CONTROL_OPTIONS: 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web' + - template: azure-pipelines-repd-build-variables.yml + - name: CACHE_MODE + value: wcache jobs: - template: azure-pipelines-build.yml parameters: diff --git a/.azure-pipelines/official-build.yml b/.azure-pipelines/official-build.yml index 8173753e5aa8..f43c6521fc50 100644 --- a/.azure-pipelines/official-build.yml +++ b/.azure-pipelines/official-build.yml @@ -25,9 +25,9 @@ stages: - stage: Build pool: sonicbld variables: - CACHE_MODE: wcache - ${{ if eq(variables['Build.SourceBranchName'], '202012') }}: - VERSION_CONTROL_OPTIONS: 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web' + - name: CACHE_MODE + value: wcache + - template: azure-pipelines-repd-build-variables.yml jobs: - template: azure-pipelines-build.yml parameters: diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a6c046344375..6482f6837d16 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -10,7 +10,7 @@ # a pull request. * @lguohan -/device/ @jleveque +/device/ @sujinmkang @prgeor @vdahiya12 # build /rules/ @qiluo-msft @xumia @lguohan diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index f8ae8e7199a2..5f8c0279b7e1 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -13,6 +13,8 @@ on: - reopened branches: - '202012' + - '202[1-9][0-9][0-9]' + - '20[3-9][0-9][0-9][0-9]' paths: - 'files/build/versions/**' diff --git a/Makefile.cache b/Makefile.cache index 977247174983..2a47c9427eb3 100644 --- a/Makefile.cache +++ b/Makefile.cache @@ -68,6 +68,7 @@ # Run the 'touch cache.skip.common' command in the base directory to exclude the common files from caching SONIC_COMMON_FILES_LIST := $(if $(wildcard cache.skip.common),, .platform slave.mk rules/functions Makefile.cache) SONIC_COMMON_FLAGS_LIST := $(CONFIGURED_PLATFORM) \ + $(CONFIGURED_ARCH) \ $(BLDENV) \ $(SONIC_DEBUGGING_ON) \ $(SONIC_PROFILING_ON) $(SONIC_ENABLE_SYNCD_RPC) diff --git a/Makefile.work b/Makefile.work index d9688a752da2..2ab0ae54d9f4 100644 --- a/Makefile.work +++ b/Makefile.work @@ -185,8 +185,10 @@ ifneq ($(SONIC_DPKG_CACHE_SOURCE),) endif ifeq ($(SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD), y) +ifneq ($(MULTIARCH_QEMU_ENVIRON), y) DOCKER_RUN += -v /var/run/docker.sock:/var/run/docker.sock endif +endif ifeq ($(MULTIARCH_QEMU_ENVIRON), y) ifeq ($(DOCKER_DATA_ROOT_FOR_MULTIARCH),) @@ -211,7 +213,7 @@ endif #Override Native config to prevent docker service SONIC_CONFIG_USE_NATIVE_DOCKERD_FOR_BUILD=y - DOCKER_MULTIARCH_CHECK := docker inspect --type image multiarch/qemu-user-static:register &> /dev/null || (echo "multiarch docker not found ..."; docker run --rm --privileged multiarch/qemu-user-static:register --reset --credential yes) + DOCKER_MULTIARCH_CHECK := docker run --rm --privileged multiarch/qemu-user-static --reset -p yes --credential yes DOCKER_SERVICE_SAFE_KILLER := (MARCH_PID=`ps -eo pid,cmd | grep "[0-9] dockerd.*march" | awk '{print $$1}'`; echo "Killing march docker $$MARCH_PID"; [ -z "$$MARCH_PID" ] || sudo kill -9 "$$MARCH_PID";) DOCKER_SERVICE_MULTIARCH_CHECK := ($(DOCKER_SERVICE_SAFE_KILLER); sudo rm -fr /var/run/march/; (echo "Starting docker march service..."; sudo $(SONIC_NATIVE_DOCKERD_FOR_MUTLIARCH) &) &>/dev/null ; sleep 2; sudo $(SONIC_USERFACL_DOCKERD_FOR_MUTLIARCH);) @@ -336,6 +338,9 @@ sonic-build-hooks: @cp src/sonic-build-hooks/buildinfo/sonic-build-hooks* $(SLAVE_DIR)/buildinfo sonic-slave-base-build : sonic-build-hooks +ifeq ($(MULTIARCH_QEMU_ENVIRON), y) + @$(DOCKER_MULTIARCH_CHECK) +endif @$(OVERLAY_MODULE_CHECK) @echo Checking sonic-slave-base image: $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) @docker inspect --type image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) &> /dev/null || \ diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 22d8046c5e41..6bf2370b1d80 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -35,9 +35,9 @@ stages: - stage: Build pool: sonicbld variables: - CACHE_MODE: rcache - ${{ if eq(variables['Build.SourceBranchName'], '202012') }}: - VERSION_CONTROL_OPTIONS: 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web,git,docker' + - template: .azure-pipelines/azure-pipelines-repd-build-variables.yml + - name: CACHE_MODE + value: rcache jobs: - template: .azure-pipelines/azure-pipelines-build.yml parameters: diff --git a/build_debian.sh b/build_debian.sh index 0c744585f073..61f6912829e9 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -320,13 +320,17 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in python-is-python3 \ cron \ libprotobuf23 \ - libgrpc++ \ + libgrpc++1 \ + libgrpc10 \ haveged \ fdisk \ gpg \ jq \ auditd +# Change auditd log file path to fix auditd can't startup issue. +sudo LANG=C chroot $FILESYSTEM_ROOT /bin/bash -c "sudo sed -i 's/^\s*log_file\s*=.*/log_file = \/var\/log\/audit.log/g' /etc/audit/auditd.conf" + if [[ $CONFIGURED_ARCH == amd64 ]]; then ## Pre-install the fundamental packages for amd64 (x86) sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install \ @@ -582,7 +586,7 @@ sudo rm -f $ONIE_INSTALLER_PAYLOAD $FILESYSTEM_SQUASHFS sudo du -hsx $FILESYSTEM_ROOT sudo mkdir -p $FILESYSTEM_ROOT/var/lib/docker scripts/collect_host_image_version_files.sh $TARGET_PATH $FILESYSTEM_ROOT -sudo mksquashfs $FILESYSTEM_ROOT $FILESYSTEM_SQUASHFS -e boot -e var/lib/docker -e $PLATFORM_DIR +sudo mksquashfs $FILESYSTEM_ROOT $FILESYSTEM_SQUASHFS -comp zstd -b 1M -e boot -e var/lib/docker -e $PLATFORM_DIR # Ensure admin gid is 1000 gid_user=$(sudo LANG=C chroot $FILESYSTEM_ROOT id -g $USERNAME) || gid_user="none" diff --git a/build_image.sh b/build_image.sh index 10c19addc23d..871ba839a901 100755 --- a/build_image.sh +++ b/build_image.sh @@ -97,7 +97,7 @@ generate_device_list() for d in `find -L ./device -maxdepth 2 -mindepth 2 -type d`; do if [ -f $d/platform_asic ]; then - if [ "$CONFIGURED_PLATFORM" = "generic" ] || grep -Fxq "$CONFIGURED_PLATFORM" $d/platform_asic; then + if [ "$TARGET_MACHINE" = "generic" ] || grep -Fxq "$TARGET_MACHINE" $d/platform_asic; then echo "${d##*/}" >> "$platforms_asic"; fi; fi; diff --git a/device/accton/x86_64-accton_as7315_27xb-r0/installer.conf b/device/accton/x86_64-accton_as7315_27xb-r0/installer.conf index 9fa12f888545..f7358371b583 100644 --- a/device/accton/x86_64-accton_as7315_27xb-r0/installer.conf +++ b/device/accton/x86_64-accton_as7315_27xb-r0/installer.conf @@ -1,2 +1,2 @@ CONSOLE_SPEED=115200 -ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="tg3.short_preamble=1 tg3.bcm5718s_reset=1" +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="tg3.short_preamble=1 tg3.bcm5718s_reset=1 intel_iommu=off modprobe.blacklist=i2c-ismt,i2c_ismt,i2c-i801,i2c_i801" 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 301e1663bff3..78be7f2b61c9 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 @@ -32,7 +32,7 @@ [ "i2c-i801", "i2c_dev", - "i2c_mux_pca954x force_deselect_on_exit=1", + "i2c_mux_pca954x", "optoe" ], "pddf_kos": diff --git a/device/accton/x86_64-accton_as7726_32x-r0/pddf/pddf-device.json b/device/accton/x86_64-accton_as7726_32x-r0/pddf/pddf-device.json index 82295f93b04b..8a4caec27722 100644 --- a/device/accton/x86_64-accton_as7726_32x-r0/pddf/pddf-device.json +++ b/device/accton/x86_64-accton_as7726_32x-r0/pddf/pddf-device.json @@ -33,7 +33,7 @@ [ "i2c-i801", "i2c_dev", - "i2c_mux_pca954x force_deselect_on_exit=1", + "i2c_mux_pca954x", "optoe" ], "pddf_kos": diff --git a/device/accton/x86_64-accton_as7816_64x-r0/pddf/pddf-device.json b/device/accton/x86_64-accton_as7816_64x-r0/pddf/pddf-device.json index d5461804b656..12d6c3a115e2 100644 --- a/device/accton/x86_64-accton_as7816_64x-r0/pddf/pddf-device.json +++ b/device/accton/x86_64-accton_as7816_64x-r0/pddf/pddf-device.json @@ -32,7 +32,7 @@ [ "i2c-i801", "i2c_dev", - "i2c_mux_pca954x force_deselect_on_exit=1", + "i2c_mux_pca954x", "optoe" ], "pddf_kos": diff --git a/device/accton/x86_64-accton_as9716_32d-r0/pddf/pddf-device.json b/device/accton/x86_64-accton_as9716_32d-r0/pddf/pddf-device.json index 21a9bef87b70..ce592286078c 100644 --- a/device/accton/x86_64-accton_as9716_32d-r0/pddf/pddf-device.json +++ b/device/accton/x86_64-accton_as9716_32d-r0/pddf/pddf-device.json @@ -33,7 +33,7 @@ "i2c-ismt", "i2c-i801", "i2c_dev", - "i2c_mux_pca954x force_deselect_on_exit=1", + "i2c_mux_pca954x", "optoe" ], "pddf_kos": diff --git a/device/arista/x86_64-arista_7050_qx32s/default_sku b/device/arista/x86_64-arista_7050_qx32s/default_sku index 657093e0b603..3d463dfd4580 100644 --- a/device/arista/x86_64-arista_7050_qx32s/default_sku +++ b/device/arista/x86_64-arista_7050_qx32s/default_sku @@ -1 +1 @@ -Arista-7050-QX-32S t1 +Arista-7050QX-32S t1 diff --git a/device/arista/x86_64-arista_7060_cx32s/platform-init b/device/arista/x86_64-arista_7060_cx32s/platform-init new file mode 100755 index 000000000000..e31a7a0db4c7 --- /dev/null +++ b/device/arista/x86_64-arista_7060_cx32s/platform-init @@ -0,0 +1,3 @@ +# Increase PCIe timeout value to 210ms +setpci -s01:00.0 CAP_EXP+0x28.B=6 +setpci -s01:00.1 CAP_EXP+0x28.B=6 diff --git a/device/arista/x86_64-arista_7800_sup/platform.json b/device/arista/x86_64-arista_7800_sup/platform.json new file mode 100644 index 000000000000..3afdaa3eb88b --- /dev/null +++ b/device/arista/x86_64-arista_7800_sup/platform.json @@ -0,0 +1,12 @@ +{ + "chassis": { + "name": "DCS-7800A-SUP1A", + "components": [], + "fans": [], + "fan_drawers": [], + "psus": [], + "thermals": [], + "sfps": [] + }, + "interfaces": {} +} diff --git a/device/arista/x86_64-arista_7800r3_48cq2_lc/platform.json b/device/arista/x86_64-arista_7800r3_48cq2_lc/platform.json new file mode 100644 index 000000000000..edd9039804d7 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3_48cq2_lc/platform.json @@ -0,0 +1,173 @@ +{ + "chassis": { + "name": "7800R3-48CQ2-LC", + "components": [], + "fans": [], + "fan_drawers": [], + "psus": [], + "thermals": [ + { + "name": "Cpu temp sensor" + }, + { + "name": "Center back" + }, + { + "name": "Fap0 core0" + }, + { + "name": "Fap0 core1" + }, + { + "name": "PCIE" + } + ], + "sfps": [ + { + "name": "qsfp1" + }, + { + "name": "qsfp2" + }, + { + "name": "qsfp3" + }, + { + "name": "qsfp4" + }, + { + "name": "qsfp5" + }, + { + "name": "qsfp6" + }, + { + "name": "qsfp7" + }, + { + "name": "qsfp8" + }, + { + "name": "qsfp9" + }, + { + "name": "qsfp10" + }, + { + "name": "qsfp11" + }, + { + "name": "qsfp12" + }, + { + "name": "qsfp13" + }, + { + "name": "qsfp14" + }, + { + "name": "qsfp15" + }, + { + "name": "qsfp16" + }, + { + "name": "qsfp17" + }, + { + "name": "qsfp18" + }, + { + "name": "qsfp19" + }, + { + "name": "qsfp20" + }, + { + "name": "qsfp21" + }, + { + "name": "qsfp22" + }, + { + "name": "qsfp23" + }, + { + "name": "qsfp24" + }, + { + "name": "qsfp25" + }, + { + "name": "qsfp26" + }, + { + "name": "qsfp27" + }, + { + "name": "qsfp28" + }, + { + "name": "qsfp29" + }, + { + "name": "qsfp30" + }, + { + "name": "qsfp31" + }, + { + "name": "qsfp32" + }, + { + "name": "qsfp33" + }, + { + "name": "qsfp34" + }, + { + "name": "qsfp35" + }, + { + "name": "qsfp36" + }, + { + "name": "qsfp37" + }, + { + "name": "qsfp38" + }, + { + "name": "qsfp39" + }, + { + "name": "qsfp40" + }, + { + "name": "qsfp41" + }, + { + "name": "qsfp42" + }, + { + "name": "qsfp43" + }, + { + "name": "qsfp44" + }, + { + "name": "qsfp45" + }, + { + "name": "qsfp46" + }, + { + "name": "qsfp47" + }, + { + "name": "qsfp48" + } + ] + }, + "interfaces": {} +} diff --git a/device/arista/x86_64-arista_7800r3_48cqm2_lc/platform.json b/device/arista/x86_64-arista_7800r3_48cqm2_lc/platform.json new file mode 120000 index 000000000000..2b84d998cf25 --- /dev/null +++ b/device/arista/x86_64-arista_7800r3_48cqm2_lc/platform.json @@ -0,0 +1 @@ +../x86_64-arista_7800r3_48cq2_lc/platform.json \ No newline at end of file diff --git a/device/barefoot/x86_64-accton_as9516_32d-r0/platform.json b/device/barefoot/x86_64-accton_as9516_32d-r0/platform.json index 2b67ee684d81..b92b929fb997 100644 --- a/device/barefoot/x86_64-accton_as9516_32d-r0/platform.json +++ b/device/barefoot/x86_64-accton_as9516_32d-r0/platform.json @@ -21,10 +21,9 @@ "name": "counter-rotating-fan-6" } ], - "fan_drawers":[ + "fan_drawers": [ { - "name": "fantray", - "num_fans" : 6, + "name": "fantray-1", "fans": [ { "name": "counter-rotating-fan-1" @@ -57,147 +56,159 @@ ], "thermals": [ { - "name": "tmp75-i2c-3-4b:switch-temp" + "name": "com_e_driver-i2c-4-33:cpu-temp" }, { "name": "com_e_driver-i2c-4-33:memory-temp" }, { - "name": "com_e_driver-i2c-4-33:cpu-temp" + "name": "psu_driver-i2c-7-59:psu2-temp1" }, { - "name": "coretemp-isa-0000:core-0" + "name": "psu_driver-i2c-7-59:psu2-temp2" }, { - "name": "coretemp-isa-0000:core-1" + "name": "psu_driver-i2c-7-59:psu2-temp3" }, { - "name": "coretemp-isa-0000:core-2" + "name": "psu_driver-i2c-7-5a:psu1-temp1" }, { - "name": "coretemp-isa-0000:core-3" + "name": "psu_driver-i2c-7-5a:psu1-temp2" }, { - "name": "coretemp-isa-0000:package-id-0" + "name": "psu_driver-i2c-7-5a:psu1-temp3" }, { - "name": "psu_driver-i2c-7-5a:psu1-temp1" + "name": "tmp75-i2c-3-48:chip-temp" }, { - "name": "psu_driver-i2c-7-5a:psu1-temp2" + "name": "tmp75-i2c-3-49:exhaust2-temp" }, { - "name": "psu_driver-i2c-7-5a:psu1-temp3" + "name": "tmp75-i2c-3-4a:exhaust-temp" }, { - "name": "tmp75-i2c-3-4a:inlet-left-temp" + "name": "tmp75-i2c-3-4b:intake-temp" }, { - "name": "tmp75-i2c-3-4c:inlet-right-temp" + "name": "tmp75-i2c-3-4c:tofino-temp" }, { - "name": "tmp75-i2c-3-4d:temp1" + "name": "tmp75-i2c-3-4d:intake2-temp" }, { - "name": "tmp75-i2c-3-48:outlet-middle-temp" + "name": "coretemp-isa-0000:package-id-0" + }, + { + "name": "coretemp-isa-0000:core-0" + }, + { + "name": "coretemp-isa-0000:core-1" }, { - "name": "tmp75-i2c-3-49:inlet-middle-temp" + "name": "coretemp-isa-0000:core-2" + }, + { + "name": "coretemp-isa-0000:core-3" } ], "sfps": [ { - "name": "Ethernet0" + "name": "sfp1" + }, + { + "name": "sfp2" }, { - "name": "Ethernet8" + "name": "sfp3" }, { - "name": "Ethernet16" + "name": "sfp4" }, { - "name": "Ethernet32" + "name": "sfp5" }, { - "name": "Ethernet40" + "name": "sfp6" }, { - "name": "Ethernet48" + "name": "sfp7" }, { - "name": "Ethernet56" + "name": "sfp8" }, { - "name": "Ethernet64" + "name": "sfp9" }, { - "name": "Ethernet72" + "name": "sfp10" }, { - "name": "Ethernet80" + "name": "sfp11" }, { - "name": "Ethernet88" + "name": "sfp12" }, { - "name": "Ethernet96" + "name": "sfp13" }, { - "name": "Ethernet104" + "name": "sfp14" }, { - "name": "Ethernet112" + "name": "sfp15" }, { - "name": "Ethernet120" + "name": "sfp16" }, { - "name": "Ethernet128" + "name": "sfp17" }, { - "name": "Ethernet136" + "name": "sfp18" }, { - "name": "Ethernet144" + "name": "sfp19" }, { - "name": "Ethernet152" + "name": "sfp20" }, { - "name": "Ethernet160" + "name": "sfp21" }, { - "name": "Ethernet168" + "name": "sfp22" }, { - "name": "Ethernet176" + "name": "sfp23" }, { - "name": "Ethernet184" + "name": "sfp24" }, { - "name": "Ethernet192" + "name": "sfp25" }, { - "name": "Ethernet200" + "name": "sfp26" }, { - "name": "Ethernet208" + "name": "sfp27" }, { - "name": "Ethernet216" + "name": "sfp28" }, { - "name": "Ethernet224" + "name": "sfp29" }, { - "name": "Ethernet232" + "name": "sfp30" }, { - "name": "Ethernet240" + "name": "sfp31" }, { - "name": "Ethernet248" + "name": "sfp32" } ] }, @@ -207,7 +218,7 @@ "lanes": "0,1,2,3,4,5,6,7", "breakout_modes": { "1x400G[200G]": ["Ethernet0"], - "2x200G[100G,40G]": ["Ethernet0, Ethernet4"], + "2x200G[100G,40G]": ["Ethernet0", "Ethernet4"], "4x100G[50G]": ["Ethernet0", "Ethernet2", "Ethernet4", "Ethernet6"], "8x50G[25G,10G]": ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3", "Ethernet4", "Ethernet5", "Ethernet6", "Ethernet7"], "1x200G[100G,40G](4)+4x50G[25G,10G](4)": ["Ethernet0", "Ethernet4", "Ethernet5", "Ethernet6", "Ethernet7"], @@ -587,4 +598,4 @@ } } } -} \ No newline at end of file +} diff --git a/device/barefoot/x86_64-accton_as9516_32d-r0/pmon_daemon_control.json b/device/barefoot/x86_64-accton_as9516_32d-r0/pmon_daemon_control.json index 1059cddb4fa2..a0431d47812a 100644 --- a/device/barefoot/x86_64-accton_as9516_32d-r0/pmon_daemon_control.json +++ b/device/barefoot/x86_64-accton_as9516_32d-r0/pmon_daemon_control.json @@ -4,6 +4,6 @@ "skip_thermalctld": false, "skip_ledd": true, "skip_xcvrd": false, - "skip_psud": true, + "skip_psud": false, "skip_syseepromd": false } diff --git a/device/barefoot/x86_64-accton_as9516_32d-r0/system_health_monitoring_config.json b/device/barefoot/x86_64-accton_as9516_32d-r0/system_health_monitoring_config.json new file mode 100644 index 000000000000..654d43d81096 --- /dev/null +++ b/device/barefoot/x86_64-accton_as9516_32d-r0/system_health_monitoring_config.json @@ -0,0 +1,11 @@ +{ + "services_to_ignore": [], + "devices_to_ignore": [], + "user_defined_checkers": [], + "polling_interval": 60, + "led_color": { + "fault": "amber", + "normal": "green", + "booting": "orange_blink" + } +} diff --git a/device/barefoot/x86_64-accton_wedge100bf_32x-r0/platform.json b/device/barefoot/x86_64-accton_wedge100bf_32x-r0/platform.json index 825f60c604ae..769386a14ce0 100644 --- a/device/barefoot/x86_64-accton_wedge100bf_32x-r0/platform.json +++ b/device/barefoot/x86_64-accton_wedge100bf_32x-r0/platform.json @@ -18,10 +18,9 @@ "name": "counter-rotating-fan-5" } ], - "fan_drawers":[ + "fan_drawers": [ { - "name": "fantray", - "num_fans" : 5, + "name": "fantray-1", "fans": [ { "name": "counter-rotating-fan-1" @@ -110,100 +109,100 @@ ], "sfps": [ { - "name": "Ethernet0" + "name": "sfp1" }, { - "name": "Ethernet4" + "name": "sfp2" }, { - "name": "Ethernet8" + "name": "sfp3" }, { - "name": "Ethernet12" + "name": "sfp4" }, { - "name": "Ethernet16" + "name": "sfp5" }, { - "name": "Ethernet20" + "name": "sfp6" }, { - "name": "Ethernet24" + "name": "sfp7" }, { - "name": "Ethernet28" + "name": "sfp8" }, { - "name": "Ethernet32" + "name": "sfp9" }, { - "name": "Ethernet36" + "name": "sfp10" }, { - "name": "Ethernet40" + "name": "sfp11" }, { - "name": "Ethernet44" + "name": "sfp12" }, { - "name": "Ethernet48" + "name": "sfp13" }, { - "name": "Ethernet52" + "name": "sfp14" }, { - "name": "Ethernet56" + "name": "sfp15" }, { - "name": "Ethernet60" + "name": "sfp16" }, { - "name": "Ethernet64" + "name": "sfp17" }, { - "name": "Ethernet68" + "name": "sfp18" }, { - "name": "Ethernet72" + "name": "sfp19" }, { - "name": "Ethernet76" + "name": "sfp20" }, { - "name": "Ethernet80" + "name": "sfp21" }, { - "name": "Ethernet84" + "name": "sfp22" }, { - "name": "Ethernet88" + "name": "sfp23" }, { - "name": "Ethernet92" + "name": "sfp24" }, { - "name": "Ethernet96" + "name": "sfp25" }, { - "name": "Ethernet100" + "name": "sfp26" }, { - "name": "Ethernet104" + "name": "sfp27" }, { - "name": "Ethernet108" + "name": "sfp28" }, { - "name": "Ethernet112" + "name": "sfp29" }, { - "name": "Ethernet116" + "name": "sfp30" }, { - "name": "Ethernet120" + "name": "sfp31" }, { - "name": "Ethernet124" + "name": "sfp32" } ] }, diff --git a/device/barefoot/x86_64-accton_wedge100bf_32x-r0/system_health_monitoring_config.json b/device/barefoot/x86_64-accton_wedge100bf_32x-r0/system_health_monitoring_config.json new file mode 100644 index 000000000000..654d43d81096 --- /dev/null +++ b/device/barefoot/x86_64-accton_wedge100bf_32x-r0/system_health_monitoring_config.json @@ -0,0 +1,11 @@ +{ + "services_to_ignore": [], + "devices_to_ignore": [], + "user_defined_checkers": [], + "polling_interval": 60, + "led_color": { + "fault": "amber", + "normal": "green", + "booting": "orange_blink" + } +} diff --git a/device/barefoot/x86_64-accton_wedge100bf_65x-r0/platform.json b/device/barefoot/x86_64-accton_wedge100bf_65x-r0/platform.json index a2394135c0fc..73bb6008dbba 100644 --- a/device/barefoot/x86_64-accton_wedge100bf_65x-r0/platform.json +++ b/device/barefoot/x86_64-accton_wedge100bf_65x-r0/platform.json @@ -1,4 +1,89 @@ { + "chassis": { + "name": "Mavericks", + "fans": [ + { + "name": "counter-rotating-fan-1" + }, + { + "name": "counter-rotating-fan-2" + }, + { + "name": "counter-rotating-fan-3" + }, + { + "name": "counter-rotating-fan-4" + }, + { + "name": "counter-rotating-fan-5" + }, + { + "name": "counter-rotating-fan-6" + }, + { + "name": "counter-rotating-fan-7" + }, + { + "name": "counter-rotating-fan-8" + }, + { + "name": "counter-rotating-fan-9" + }, + { + "name": "counter-rotating-fan-10" + } + ], + "fan_drawers": [ + { + "name": "fantray-1", + "fans": [ + { + "name": "counter-rotating-fan-1" + }, + { + "name": "counter-rotating-fan-2" + }, + { + "name": "counter-rotating-fan-3" + }, + { + "name": "counter-rotating-fan-4" + }, + { + "name": "counter-rotating-fan-5" + } + ] + }, + { + "name": "fantray-2", + "fans": [ + { + "name": "counter-rotating-fan-6" + }, + { + "name": "counter-rotating-fan-7" + }, + { + "name": "counter-rotating-fan-8" + }, + { + "name": "counter-rotating-fan-9" + }, + { + "name": "counter-rotating-fan-10" + } + ] + } + ] + }, + "psus": [ + { + "name": "psu-1" + }, + { + "name": "psu-2" + } + ], "interfaces": { "Ethernet0": { "index": "1,1,1,1", diff --git a/device/barefoot/x86_64-accton_wedge100bf_65x-r0/system_health_monitoring_config.json b/device/barefoot/x86_64-accton_wedge100bf_65x-r0/system_health_monitoring_config.json new file mode 100644 index 000000000000..654d43d81096 --- /dev/null +++ b/device/barefoot/x86_64-accton_wedge100bf_65x-r0/system_health_monitoring_config.json @@ -0,0 +1,11 @@ +{ + "services_to_ignore": [], + "devices_to_ignore": [], + "user_defined_checkers": [], + "polling_interval": 60, + "led_color": { + "fault": "amber", + "normal": "green", + "booting": "orange_blink" + } +} diff --git a/device/celestica/x86_64-cel_seastone_2-r0/led_proc_init.soc b/device/celestica/x86_64-cel_seastone_2-r0/led_proc_init.soc index a47644c032e1..b6b474bd53d6 100644 --- a/device/celestica/x86_64-cel_seastone_2-r0/led_proc_init.soc +++ b/device/celestica/x86_64-cel_seastone_2-r0/led_proc_init.soc @@ -1,9 +1,5 @@ -#Enable all ports -port all en=1 -sleep 6 -#linkscan 250000; port xe,ce linkscan=on - -#Load LED +linkscan off +m0 load 0 0x3800 /usr/share/sonic/platform/custom.bin +sleep 10 led auto on; led start - - +linkscan on diff --git a/device/celestica/x86_64-cel_seastone_2-r0/plugins/sfputil.py b/device/celestica/x86_64-cel_seastone_2-r0/plugins/sfputil.py index 6f05527621fe..88c4d9a26e88 100755 --- a/device/celestica/x86_64-cel_seastone_2-r0/plugins/sfputil.py +++ b/device/celestica/x86_64-cel_seastone_2-r0/plugins/sfputil.py @@ -47,16 +47,16 @@ def get_port_name(self, port_num): if port_num in self.qsfp_ports: self._port_name = "QSFP" + str(port_num - self.QSFP_PORT_START + 1) else: - self._port_name = "SFP" + str(port_num) + self._port_name = "SFP" + str(port_num - self.QSFP_PORT_END) return self._port_name - # def get_eeprom_dom_raw(self, port_num): - # if port_num in self.qsfp_ports: - # # QSFP DOM EEPROM is also at addr 0x50 and thus also stored in eeprom_ifraw - # return None - # else: - # # Read dom eeprom at addr 0x51 - # return self._read_eeprom_devid(port_num, self.DOM_EEPROM_ADDR, 256) + def get_eeprom_dom_raw(self, port_num): + if port_num in self.qsfp_ports: + # QSFP DOM EEPROM is also at addr 0x50 and thus also stored in eeprom_ifraw + return None + else: + # Read dom eeprom as offset 0x100 on optoe eeprom + return self._read_eeprom_devid(port_num, self.DOM_EEPROM_ADDR, 256) def __init__(self): # Override port_to_eeprom_mapping for class initialization diff --git a/device/celestica/x86_64-cel_seastone_2-r0/sonic_platform_config/event.py b/device/celestica/x86_64-cel_seastone_2-r0/sonic_platform_config/event.py index ed3b78cf7fd6..32073479a1e6 100644 --- a/device/celestica/x86_64-cel_seastone_2-r0/sonic_platform_config/event.py +++ b/device/celestica/x86_64-cel_seastone_2-r0/sonic_platform_config/event.py @@ -38,9 +38,14 @@ def _initialize_interrupts(self): for index in range(self.num_sfp): port_num = index + 1 - port_name = "QSFP{}".format(port_num) - port_type = "qsfp" - sysfs_prs_file = "{}_modprs".format(port_type) + if port_num <= 32: + port_name = "QSFP{}".format(port_num) + port_type = "qsfp" + sysfs_prs_file = "{}_modprs".format(port_type) + else: + port_name = "SFP{}".format(port_num - 32) + port_type = "sfp" + sysfs_prs_file = "{}_modabs".format(port_type) sfp_info_obj[index] = {} sfp_info_obj[index]['intmask_sysfs'] = self.PATH_INTMASK_SYSFS.format( diff --git a/device/celestica/x86_64-cel_seastone_2-r0/sonic_platform_config/sfp.json b/device/celestica/x86_64-cel_seastone_2-r0/sonic_platform_config/sfp.json index d77e75e50e2f..d12f0c3ffc1b 100644 --- a/device/celestica/x86_64-cel_seastone_2-r0/sonic_platform_config/sfp.json +++ b/device/celestica/x86_64-cel_seastone_2-r0/sonic_platform_config/sfp.json @@ -1,5 +1,5 @@ { - "port_num": 32, + "port_num": 33, "eeprom_path": "/sys/bus/i2c/devices/i2c-{0}/{0}-0050/eeprom", "port_i2c_mapping": [ 2, @@ -33,12 +33,13 @@ 30, 31, 32, - 33 + 33, + 34 ], "get_presence": { "output_source": "sysfs_value", - "sysfs_path": "/sys/devices/platform/switchboard/SFF/{}/qsfp_modprs", - "argument": "$ref:_port_name", + "sysfs_path": "/sys/devices/platform/switchboard/SFF/{}", + "argument": "$ref:_presence_file", "output_translator": "False if '{}' == '1' else True" }, "get_lpmode": { @@ -101,6 +102,42 @@ "QSFP29", "QSFP30", "QSFP31", - "QSFP32" + "QSFP32", + "SFP1" + ], + "_presence_file": [ + "QSFP1/qsfp_modprs", + "QSFP2/qsfp_modprs", + "QSFP3/qsfp_modprs", + "QSFP4/qsfp_modprs", + "QSFP5/qsfp_modprs", + "QSFP6/qsfp_modprs", + "QSFP7/qsfp_modprs", + "QSFP8/qsfp_modprs", + "QSFP9/qsfp_modprs", + "QSFP10/qsfp_modprs", + "QSFP11/qsfp_modprs", + "QSFP12/qsfp_modprs", + "QSFP13/qsfp_modprs", + "QSFP14/qsfp_modprs", + "QSFP15/qsfp_modprs", + "QSFP16/qsfp_modprs", + "QSFP17/qsfp_modprs", + "QSFP18/qsfp_modprs", + "QSFP19/qsfp_modprs", + "QSFP20/qsfp_modprs", + "QSFP21/qsfp_modprs", + "QSFP22/qsfp_modprs", + "QSFP23/qsfp_modprs", + "QSFP24/qsfp_modprs", + "QSFP25/qsfp_modprs", + "QSFP26/qsfp_modprs", + "QSFP27/qsfp_modprs", + "QSFP28/qsfp_modprs", + "QSFP29/qsfp_modprs", + "QSFP30/qsfp_modprs", + "QSFP31/qsfp_modprs", + "QSFP32/qsfp_modprs", + "SFP1/sfp_modabs" ] -} \ No newline at end of file +} diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/V682-48x8c-board.json b/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/V682-48x8c-board.json new file mode 100644 index 000000000000..435ab418aaba --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/V682-48x8c-board.json @@ -0,0 +1,597 @@ +{ + "macleds" : { + "polarity" : 1, + "cpumode" : 1, + "maps" : [ + { + "port_id" : 32, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port0/brightness" + }, + { + "port_id" : 33, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port1/brightness" + }, + { + "port_id" : 34, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port2/brightness" + }, + { + "port_id" : 35, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port3/brightness" + }, + { + "port_id" : 0, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port4/brightness" + }, + { + "port_id" : 4, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port5/brightness" + }, + { + "port_id" : 8, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port6/brightness" + }, + { + "port_id" : 12, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port7/brightness" + }, + { + "port_id" : 16, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port8/brightness" + }, + { + "port_id" : 20, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port9/brightness" + }, + { + "port_id" : 24, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port10/brightness" + }, + { + "port_id" : 28, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port11/brightness" + }, + { + "port_id" : 40, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port12/brightness" + }, + { + "port_id" : 44, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port13/brightness" + }, + { + "port_id" : 48, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port14/brightness" + }, + { + "port_id" : 52, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port15/brightness" + }, + { + "port_id" : 56, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port16/brightness" + }, + { + "port_id" : 60, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port17/brightness" + }, + { + "port_id" : 64, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port18/brightness" + }, + { + "port_id" : 68, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port19/brightness" + }, + { + "port_id" : 72, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port20/brightness" + }, + { + "port_id" : 73, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port21/brightness" + }, + { + "port_id" : 74, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port22/brightness" + }, + { + "port_id" : 75, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port23/brightness" + }, + + { + "port_id" : 120, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port48/brightness" + }, + { + "port_id" : 124, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port49/brightness" + }, + { + "port_id" : 80, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port50/brightness" + }, + { + "port_id" : 84, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port51/brightness" + }, + + { + "port_id" : 232, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port24/brightness" + }, + { + "port_id" : 233, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port25/brightness" + }, + { + "port_id" : 234, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port26/brightness" + }, + { + "port_id" : 235, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port27/brightness" + }, + { + "port_id" : 200, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port28/brightness" + }, + { + "port_id" : 204, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port29/brightness" + }, + { + "port_id" : 208, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port30/brightness" + }, + { + "port_id" : 212, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port31/brightness" + }, + { + "port_id" : 216, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port32/brightness" + }, + { + "port_id" : 220, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port33/brightness" + }, + { + "port_id" : 224, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port34/brightness" + }, + { + "port_id" : 228, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port35/brightness" + }, + { + "port_id" : 160, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port36/brightness" + }, + { + "port_id" : 164, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port37/brightness" + }, + { + "port_id" : 168, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port38/brightness" + }, + { + "port_id" : 172, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port39/brightness" + }, + { + "port_id" : 176, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port40/brightness" + }, + { + "port_id" : 180, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port41/brightness" + }, + { + "port_id" : 184, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port42/brightness" + }, + { + "port_id" : 188, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port43/brightness" + }, + { + "port_id" : 192, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port44/brightness" + }, + { + "port_id" : 193, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port45/brightness" + }, + { + "port_id" : 194, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port46/brightness" + }, + { + "port_id" : 195, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port47/brightness" + }, + + { + "port_id" : 240, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port52/brightness" + }, + { + "port_id" : 244, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 1, + "sysfs_path" : "/sys/class/leds/port53/brightness" + }, + { + "port_id" : 280, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 1, + "sysfs_path" : "/sys/class/leds/port54/brightness" + }, + { + "port_id" : 284, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 1, + "sysfs_path" : "/sys/class/leds/port55/brightness" + }, + + { + "port_id" : 161, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_1_FORCE_OFF", + "fixed" : 0 + }, + { + "port_id" : 162, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_1_FORCE_OFF", + "fixed" : 0 + }, + { + "port_id" : 165, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_1_FORCE_OFF", + "fixed" : 0 + }, + { + "port_id" : 166, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_1_FORCE_OFF", + "fixed" : 0 + } + ] + }, + "ffe" : { + "board_material" : "BOARD_MATERIAL_M4", + "config" : [ + { + "serdes_id" : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75], + "is_dac" : 1, + "speed" : [10000, 25000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [2, -13, 46, 0, 0] + }, + { + "serdes_id" : [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 50, 52, 53, 54, 55, 56, 57, 58, 59], + "is_dac" : 0, + "speed" : [10000, 1000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 46, -8, 0] + }, + { + "serdes_id" : [0, 1, 16, 17, 18, 19, 20, 21, 22, 23], + "is_dac" : 0, + "speed" : [10000, 1000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 42, -6, 0] + }, + { + "serdes_id" : [24, 25, 26, 27, 72, 74, 75], + "is_dac" : 0, + "speed" : [10000, 1000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 42, -4, 0] + }, + { + "serdes_id" : [48, 49, 51, 64, 65, 66, 67, 68, 69, 70, 71, 73], + "is_dac" : 0, + "speed" : [10000, 1000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 42, -6, 0] + }, + { + "serdes_id" : [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 50, 52, 53, 54, 55, 56, 57, 58, 59], + "is_dac" : 0, + "speed" : [25000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 44, -14, -1] + }, + { + "serdes_id" : [0, 1, 16, 17, 18, 19, 20, 21, 22, 23], + "is_dac" : 0, + "speed" : [25000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 38, -10, -2] + }, + { + "serdes_id" : [24, 25, 26, 27, 72, 74, 75], + "is_dac" : 0, + "speed" : [25000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 36, -6, -2] + }, + { + "serdes_id" : [48, 49, 51, 64, 65, 66, 67, 68, 69, 70, 71, 73], + "is_dac" : 0, + "speed" : [25000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 38, -10, -2] + }, + { + "serdes_id" : [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95], + "is_dac" : 1, + "speed" : [100000, 25000, 40000, 10000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [2, -13, 46, 0, 0] + }, + { + "serdes_id" : [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95], + "is_dac" : 1, + "speed" : [1000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 42, -4, 0] + }, + { + "serdes_id" : [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95], + "is_dac" : 0, + "speed" : [100000, 25000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 36, -6, -2] + }, + { + "serdes_id" : [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95], + "is_dac" : 0, + "speed" : [40000, 10000, 1000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 42, -4, 0] + } + ] + } +} diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/V682-48x8c-chip-profile.txt b/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/V682-48x8c-chip-profile.txt new file mode 100644 index 000000000000..9fadec5d5f6b --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/V682-48x8c-chip-profile.txt @@ -0,0 +1,116 @@ +#----------------- SDK Feature Support -------------- +[MPLS_SUPPORT] = 1; +[APS_SUPPORT] = 1; +[OAM_SUPPORT] = 1; +[PTP_SUPPORT] = 0; +[SYNCE_SUPPORT] = 0; +[STACKING_SUPPORT] = 1; +[BPE_SUPPORT] = 0; +[IPFIX_SUPPORT] = 1; +[MONITOR_SUPPORT] = 1; +[OVERLAY_SUPPORT] = 1; +[EFD_SUPPORT] = 1; +[FCOE_SUPPORT] = 0; +[TRILL_SUPPORT] = 0; +[WLAN_SUPPORT] = 0; +[NPM_SUPPORT] = 1; +[DOT1AE_SUPPORT] = 1; +[SRV6_SUPPORT] = 0; +[DTEL_SUPPORT] = 1; +[FLEXE_SUPPORT] = 0; +[FDBTOKEN_SUPPORT] = 1; + +#----------------- Chip Init Parameter -------------- +#Local chip number and global chip id +[Local chip_num] = 1 +[Local chip0] = 0 +[Local chip1] = 1 +[Port_phy_mapping] = 1 + +#Cut through mode 0: Disable; 1:10/40/100G; 2:1/10/100G; 3:1/10/40G; other:Flex, refer to CUT_THROUGH_BITMAP +[CUT_THROUGH_SPEED] = 0 +#Flex cut through mode, speed enable by bitmap, refer to ctc_port_speed_t, Notice: 10M/100M/1G treat as the same speed +[CUT_THROUGH_BITMAP] = 0 + +#Network cpu port +[CPU_NETWORK_PORT_EN] = 0 +[CPU_NETWORK_PORT_ID] = 47 + +#Enable parity error and multi-bit ecc recover +[ECC_RECOVER_EN] = 0 +[TCAM_SCAN_EN] = 0 +[SDB_EN] = 0 + +#----------------- KNET Init Parameter -------------- +[KNET_EN] = 0 + +#----------------- FTM Init Parameter -------------- +#0: not use; 1: default; 2: layer3; 3: ipv6 +[FTM Profile] = 0 + +#----------------- Interrupt Init Parameter -------------- +#0: pin, 1: msi +[Interrupt_mode] = 1 + +#----------------- NextHop Init Parameter -------------- +#0: SDK work in pizzbox (single chip system), 1: SDK work in multi-chip system +[Nexthop Edit Mode] = 0 +[External Nexthop Number] = 16384 +[MPLS Tunnel Number] = 1024 +[H_ECMP_EN] = 0 + +#----------------- L2 Init Parameter -------------- +[FDB Hw Learning] = 0 +[Logic Port Num] = 1024 +#0: 128 instance per port, 1: 64 instance per port, 2: 32 instance per port +[STP MODE] = 0 +[MAX_FID_NUM] = 5120 + +#----------------- Stats Init Parameter -------------- +[STATS_QUEUE_DEQ_EN] = 1 +[STATS_QUEUE_DROP_EN] = 1 +[STATS_FLOW_POLICER_EN] = 1 +[STATS_VLAN_EN] = 0 +[STATS_VRF_EN] = 0 +[STATS_POLICER_NUM] = 1024 +[STATS_PORT_EN] = 0 +[STATS_ECMP_EN] = 0 + +#----------------- BPE Init Parameter -------------- +[BPE_BR_PORT_EXTENDER_EN] = 0 +[BPE_BR_UC_MAX_ECID] = 1024 +[BPE_BR_MC_MAX_ECID] = 4096 +[BPE_BR_PORT_BASE] = 0 + +#----------------- Ipuc Init Parameter -------------- +#0: tcam use prefix 16; 1: tcam use prefix 8 +[IPUC_TCAM_PREFIX_8] = 1 + +#----------------- QoS Init Parameter -------------- +#QoS policer number support 1K/2K/4K/8K, default 4K +[QOS_POLICER_NUM] = 4096 +#qos queue mode 0: 8(basic)+1(cpu) +#qos queue mode 1: 8(basic)+1(span)+1(mcast) +[QOS_QUEUE_MODE] = 0 +#QoS port extend queue number support 0/4, default 0 +[QOS_PORT_EXT_QUEUE_NUM] = 0 +#QoS CPU reason queue number support 128/64/32, default 128 +[QOS_CPU_QUEUE_NUM] = 128 +[QOS_INGRESS_VLAN_POLICER_NUM] = 0 +[QOS_EGRESS_VLAN_POLICER_NUM] = 0 +#QoS the max number of igs/egs reserve macro policer,which ACL entry support micro and macro at the same time +[QOS_INGRESS_MACRO_POLICER_NUM] = 0 +[QOS_EGRESS_MACRO_POLICER_NUM] = 0 +#QOS service queue mode, default 0,0:logic scr port + dstport enq 1:service id + dstport enq +[QOS_SERVICE_QUEUE_MODE] = 0 +#mode 0:svc policer used for service policer +#mode 1:svc policer used for stormctl +[QOS_POLICER_SVC_MODE] = 0 + +#----------------- Stacking Init Parameter -------------- +#0: normal mode; 1: spine-leaf mode +[FABRIC MODE] = 0 +[STACKING VERSION] = 1 +#----------------- LB hash Init Parameter -------------- +#0: support 4 select num; 1: support 8 select num; only TM2 support mode 1 +[LB_HASH_MODE] = 0 diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/V682-48x8c-datapath.txt b/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/V682-48x8c-datapath.txt new file mode 100644 index 000000000000..c77ae26c389d --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/V682-48x8c-datapath.txt @@ -0,0 +1,1022 @@ +#SERDES_MODE: 0-NONE, 1-XFI, 2-SGMII, 3-Not Support, 4-QSGMII, 7-XLG, 8-100GR4, 9-SGMII2G5 +# 13-XXVG, 14-50GR2, 16-50GR1, 17-100GR2, 18-200G, 19-400G +#SERDES_POLY: 0-No Inverse, 1-Inverse +#SERDES_SWITCH: 0-Not Support Dynamic Switch, 1-Support Dynamic Switch exclude QSGMII, 2-Support Dynamic Switch include QSGMII + +[CORE_PLL] = 1050 +[DP0_FLEXE_CLIENT_NUM] = 0 +[DP1_FLEXE_CLIENT_NUM] = 0 +[DP0_XPIPE_PORT_NUM] = 0 +[DP1_XPIPE_PORT_NUM] = 0 +[DOT1AE_ENABLE] = 1 + +#{ +[SERDES_ITEM] + +[SERDES_ID] = 7 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 0 + +[SERDES_ID] = 6 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 1 + +[SERDES_ID] = 5 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 2 + +[SERDES_ID] = 4 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 3 + +[SERDES_ID] = 3 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 4 + +[SERDES_ID] = 2 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 5 + +[SERDES_ID] = 1 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 6 + +[SERDES_ID] = 0 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 7 + +[SERDES_ID] = 11 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 8 + +[SERDES_ID] = 10 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 9 + +[SERDES_ID] = 9 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 10 + +[SERDES_ID] = 8 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 11 + +[SERDES_ID] = 12 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 12 + +[SERDES_ID] = 13 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 13 + +[SERDES_ID] = 14 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 14 + +[SERDES_ID] = 15 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 15 + +[SERDES_ID] = 16 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 16 + +[SERDES_ID] = 17 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 17 + +[SERDES_ID] = 18 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 18 + +[SERDES_ID] = 19 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 19 + +[SERDES_ID] = 20 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 20 + +[SERDES_ID] = 21 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 21 + +[SERDES_ID] = 22 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 22 + +[SERDES_ID] = 23 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 23 + +[SERDES_ID] = 24 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 24 + +[SERDES_ID] = 25 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 25 + +[SERDES_ID] = 26 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 26 + +[SERDES_ID] = 27 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 27 + +[SERDES_ID] = 28 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 28 + +[SERDES_ID] = 29 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 29 + +[SERDES_ID] = 30 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 30 + +[SERDES_ID] = 31 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 31 + +[SERDES_ID] = 36 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 32 + +[SERDES_ID] = 37 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 33 + +[SERDES_ID] = 38 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 34 + +[SERDES_ID] = 32 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 35 + +[SERDES_ID] = 39 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 36 + +[SERDES_ID] = 34 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 37 + +[SERDES_ID] = 35 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 38 + +[SERDES_ID] = 33 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 39 + +[SERDES_ID] = 40 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 40 + +[SERDES_ID] = 44 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 41 + +[SERDES_ID] = 42 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 42 + +[SERDES_ID] = 41 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 43 + +[SERDES_ID] = 43 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 44 + +[SERDES_ID] = 46 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 45 + +[SERDES_ID] = 47 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 46 + +[SERDES_ID] = 45 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 47 + +[SERDES_ID] = 49 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 48 + +[SERDES_ID] = 48 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 49 + +[SERDES_ID] = 51 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 50 + +[SERDES_ID] = 50 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 51 + +[SERDES_ID] = 53 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 52 + +[SERDES_ID] = 52 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 53 + +[SERDES_ID] = 55 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 54 + +[SERDES_ID] = 54 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 55 + +[SERDES_ID] = 57 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 56 + +[SERDES_ID] = 56 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 57 + +[SERDES_ID] = 59 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 58 + +[SERDES_ID] = 58 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 59 + +[SERDES_ID] = 60 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 60 + +[SERDES_ID] = 61 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 61 + +[SERDES_ID] = 62 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 62 + +[SERDES_ID] = 63 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 63 + +[SERDES_ID] = 70 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 64 + +[SERDES_ID] = 71 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 65 + +[SERDES_ID] = 68 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 66 + +[SERDES_ID] = 69 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 67 + +[SERDES_ID] = 66 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 68 + +[SERDES_ID] = 67 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 69 + +[SERDES_ID] = 64 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 70 + +[SERDES_ID] = 65 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 71 + +[SERDES_ID] = 74 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 72 + +[SERDES_ID] = 75 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 73 + +[SERDES_ID] = 72 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 74 + +[SERDES_ID] = 73 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 75 + +[SERDES_ID] = 76 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 76 + +[SERDES_ID] = 77 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 77 + +[SERDES_ID] = 78 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 78 + +[SERDES_ID] = 79 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 79 + +[SERDES_ID] = 83 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 80 + +[SERDES_ID] = 81 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 81 + +[SERDES_ID] = 87 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 82 + +[SERDES_ID] = 82 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 83 + +[SERDES_ID] = 86 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 84 + +[SERDES_ID] = 80 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 85 + +[SERDES_ID] = 84 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 86 + +[SERDES_ID] = 85 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 87 + +[SERDES_ID] = 95 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 88 + +[SERDES_ID] = 93 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 89 + +[SERDES_ID] = 91 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 90 + +[SERDES_ID] = 94 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 91 + +[SERDES_ID] = 90 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 92 + +[SERDES_ID] = 89 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 93 + +[SERDES_ID] = 88 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 94 + +[SERDES_ID] = 92 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 95 + +[SERDES_ID] = 96 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 96 + +[SERDES_ID] = 97 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 97 + +[SERDES_ID] = 98 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 98 + +[SERDES_ID] = 99 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 99 + +#} +[SERDES_TO_LPORT] +#{ +#index |serdes |QSGMII |SGMII/SGMII2G5/XFI/XXVG |XLG |50GR1 |50GR2 |100GR4 |100GR2 |200G |400G +#----------|----------|------------|------------------------|--------|--------|--------|--------|--------|--------|-------- +#0 |7 |NA |0 |0 |0 |0 |0 |0 |NA |NA +#1 |6 |NA |1 |0 |NA |0 |0 |NA |NA |NA +#2 |5 |NA |2 |0 |2 |2 |0 |0 |NA |NA +#3 |4 |NA |3 |0 |NA |2 |0 |NA |NA |NA +#4 |3 |NA |4 |4 |4 |4 |4 |4 |NA |NA +#5 |2 |NA |5 |4 |NA |4 |4 |NA |NA |NA +#6 |1 |NA |6 |4 |6 |6 |4 |4 |NA |NA +#7 |0 |NA |7 |4 |NA |6 |4 |NA |NA |NA +#8 |11 |NA |8 |8 |8 |8 |8 |8 |NA |NA +#9 |10 |NA |9 |8 |NA |8 |8 |NA |NA |NA +#10 |9 |NA |10 |8 |10 |10 |8 |8 |NA |NA +#11 |8 |NA |11 |8 |NA |10 |8 |NA |NA |NA +#12 |12 |NA |12 |12 |12 |12 |12 |12 |NA |NA +#13 |13 |NA |13 |12 |NA |12 |12 |NA |NA |NA +#14 |14 |NA |14 |12 |14 |14 |12 |12 |NA |NA +#15 |15 |NA |15 |12 |NA |14 |12 |NA |NA |NA +#16 |16 |NA |16 |16 |16 |16 |16 |16 |NA |NA +#17 |17 |NA |17 |16 |NA |16 |16 |NA |NA |NA +#18 |18 |NA |18 |16 |18 |18 |16 |16 |NA |NA +#19 |19 |NA |19 |16 |NA |18 |16 |NA |NA |NA +#20 |20 |NA |20 |20 |20 |20 |20 |20 |NA |NA +#21 |21 |NA |21 |20 |NA |20 |20 |NA |NA |NA +#22 |22 |NA |22 |20 |22 |22 |20 |20 |NA |NA +#23 |23 |NA |23 |20 |NA |22 |20 |NA |NA |NA +#24 |24 |NA |24 |24 |24 |24 |24 |24 |NA |NA +#25 |25 |NA |25 |24 |NA |24 |24 |NA |NA |NA +#26 |26 |NA |26 |24 |26 |26 |24 |24 |NA |NA +#27 |27 |NA |27 |24 |NA |26 |24 |NA |NA |NA +#28 |28 |NA |28 |28 |28 |28 |28 |28 |NA |NA +#29 |29 |NA |29 |28 |NA |28 |28 |NA |NA |NA +#30 |30 |NA |30 |28 |30 |30 |28 |28 |NA |NA +#31 |31 |NA |31 |28 |NA |30 |28 |NA |NA |NA +#32 |36 |NA |32 |32 |32 |32 |32 |32 |32 |32 +#33 |37 |NA |33 |32 |33 |32 |32 |32 |32 |32 +#34 |38 |NA |34 |32 |34 |34 |32 |34 |32 |32 +#35 |32 |NA |35 |32 |35 |34 |32 |34 |32 |32 +#36 |39 |NA |36 |36 |36 |36 |36 |36 |36 |32 +#37 |34 |NA |37 |36 |37 |36 |36 |36 |36 |32 +#38 |35 |NA |38 |36 |38 |38 |36 |38 |36 |32 +#39 |33 |NA |39 |36 |39 |38 |36 |38 |36 |32 +#40 |40 |NA |40 |40 |40 |40 |40 |40 |40 |40 +#41 |44 |NA |41 |40 |41 |40 |40 |40 |40 |40 +#42 |42 |NA |42 |40 |42 |42 |40 |42 |40 |40 +#43 |41 |NA |43 |40 |43 |42 |40 |42 |40 |40 +#44 |43 |NA |44 |44 |44 |44 |44 |44 |44 |40 +#45 |46 |NA |45 |44 |45 |44 |44 |44 |44 |40 +#46 |47 |NA |46 |44 |46 |46 |44 |46 |44 |40 +#47 |45 |NA |47 |44 |47 |46 |44 |46 |44 |40 +#48 |49 |NA |48 |48 |48 |48 |48 |48 |NA |NA +#49 |48 |NA |49 |48 |NA |48 |48 |NA |NA |NA +#50 |51 |NA |50 |48 |50 |50 |48 |48 |NA |NA +#51 |50 |NA |51 |48 |NA |50 |48 |NA |NA |NA +#52 |53 |NA |52 |52 |52 |52 |52 |52 |NA |NA +#53 |52 |NA |53 |52 |NA |52 |52 |NA |NA |NA +#54 |55 |NA |54 |52 |54 |54 |52 |52 |NA |NA +#55 |54 |NA |55 |52 |NA |54 |52 |NA |NA |NA +#56 |57 |NA |56 |56 |56 |56 |56 |56 |NA |NA +#57 |56 |NA |57 |56 |NA |56 |56 |NA |NA |NA +#58 |59 |NA |58 |56 |58 |58 |56 |56 |NA |NA +#59 |58 |NA |59 |56 |NA |58 |56 |NA |NA |NA +#60 |60 |NA |60 |60 |60 |60 |60 |60 |NA |NA +#61 |61 |NA |61 |60 |NA |60 |60 |NA |NA |NA +#62 |62 |NA |62 |60 |62 |62 |60 |60 |NA |NA +#63 |63 |NA |63 |60 |NA |62 |60 |NA |NA |NA +#64 |70 |NA |64 |64 |64 |64 |64 |64 |NA |NA +#65 |71 |NA |65 |64 |NA |64 |64 |NA |NA |NA +#66 |68 |NA |66 |64 |66 |66 |64 |64 |NA |NA +#67 |69 |NA |67 |64 |NA |66 |64 |NA |NA |NA +#68 |66 |NA |68 |68 |68 |68 |68 |68 |NA |NA +#69 |67 |NA |69 |68 |NA |68 |68 |NA |NA |NA +#70 |64 |NA |70 |68 |70 |70 |68 |68 |NA |NA +#71 |65 |NA |71 |68 |NA |70 |68 |NA |NA |NA +#72 |74 |NA |72 |72 |72 |72 |72 |72 |NA |NA +#73 |75 |NA |73 |72 |NA |72 |72 |NA |NA |NA +#74 |72 |NA |74 |72 |74 |74 |72 |72 |NA |NA +#75 |73 |NA |75 |72 |NA |74 |72 |NA |NA |NA +#76 |76 |NA |76 |76 |76 |76 |76 |76 |NA |NA +#77 |77 |NA |77 |76 |NA |76 |76 |NA |NA |NA +#78 |78 |NA |78 |76 |78 |78 |76 |76 |NA |NA +#79 |79 |NA |79 |76 |NA |78 |76 |NA |NA |NA +#80 |83 |NA |80 |80 |80 |80 |80 |80 |80 |80 +#81 |81 |NA |81 |80 |81 |80 |80 |80 |80 |80 +#82 |87 |NA |82 |80 |82 |82 |80 |82 |80 |80 +#83 |82 |NA |83 |80 |83 |82 |80 |82 |80 |80 +#84 |86 |NA |84 |84 |84 |84 |84 |84 |84 |80 +#85 |80 |NA |85 |84 |85 |84 |84 |84 |84 |80 +#86 |84 |NA |86 |84 |86 |86 |84 |86 |84 |80 +#87 |85 |NA |87 |84 |87 |86 |84 |86 |84 |80 +#88 |95 |NA |88 |88 |88 |88 |88 |88 |88 |88 +#89 |93 |NA |89 |88 |89 |88 |88 |88 |88 |88 +#90 |91 |NA |90 |88 |90 |90 |88 |90 |88 |88 +#91 |94 |NA |91 |88 |91 |90 |88 |90 |88 |88 +#92 |90 |NA |92 |92 |92 |92 |92 |92 |92 |88 +#93 |89 |NA |93 |92 |93 |92 |92 |92 |92 |88 +#94 |88 |NA |94 |92 |94 |94 |92 |94 |92 |88 +#95 |92 |NA |95 |92 |95 |94 |92 |94 |92 |88 +#96 |96 |NA |232 |232 |232 |232 |232 |232 |NA |NA +#97 |97 |NA |233 |232 |NA |232 |232 |NA |NA |NA +#98 |98 |NA |243 |232 |243 |243 |232 |232 |NA |NA +#99 |99 |NA |244 |232 |NA |243 |232 |NA |NA |NA +#} + diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/buffers.json.j2 b/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/buffers.json.j2 new file mode 100644 index 000000000000..08e21e428b6c --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/buffers.json.j2 @@ -0,0 +1,70 @@ +{# Default values which will be used if no actual configura available #} +{% set default_cable = '40m' %} +{% set default_ports_num = 54 -%} + +{# Port configuration to cable length look-up table #} +{# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #} +{# Roles described in the minigraph #} +{% set ports2cable = { + 'torrouter_server' : '5m', + 'leafrouter_torrouter' : '40m', + 'spinerouter_leafrouter' : '300m' + } +%} + +{%- macro cable_length(port_name) -%} + {%- set cable_len = [] -%} + {%- for local_port in DEVICE_NEIGHBOR -%} + {%- if local_port == port_name -%} + {%- if DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%} + {%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%} + {%- set neighbor_role = neighbor.type -%} + {%- set roles1 = switch_role + '_' + neighbor_role %} + {%- set roles2 = neighbor_role + '_' + switch_role -%} + {%- set roles1 = roles1 | lower -%} + {%- set roles2 = roles2 | lower -%} + {%- if roles1 in ports2cable -%} + {%- if cable_len.append(ports2cable[roles1]) -%}{%- endif -%} + {%- elif roles2 in ports2cable -%} + {%- if cable_len.append(ports2cable[roles2]) -%}{%- endif -%} + {%- endif -%} + {%- endif -%} + {%- endif -%} + {%- endfor -%} + {%- if cable_len -%} + {{ cable_len.0 }} + {%- else -%} + {{ default_cable }} + {%- endif -%} +{% endmacro %} + +{%- if DEVICE_METADATA is defined %} +{%- set switch_role = DEVICE_METADATA['localhost']['type'] %} +{%- endif -%} + +{# Generate list of ports if not defined #} +{% if PORT is not defined %} + {% set PORT = [] %} + {% for port_idx in range(1,default_ports_num+1) %} + {% if PORT.append("Ethernet%d" % (port_idx)) %}{% endif %} + {% endfor %} +{% endif -%} + +{% set port_names_list = [] %} +{% for port in PORT %} + {%- if port_names_list.append(port) %}{% endif %} +{% endfor %} +{% set port_names = port_names_list | join(',') -%} + +{ + "CABLE_LENGTH": { + "AZURE": { + {% for port in PORT %} + {% set cable = cable_length(port) -%} + "{{ port }}": "{{ cable }}"{%- if not loop.last -%},{% endif %} + + {% endfor %} + } + } +} + diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/pg_profile_lookup.ini b/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/pg_profile_lookup.ini new file mode 100644 index 000000000000..a65244e69b5b --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/pg_profile_lookup.ini @@ -0,0 +1,21 @@ +# PG lossless profiles. +# speed cable size xon xoff threshold + 1000 5m 34816 18432 16384 0 + 10000 5m 34816 18432 16384 0 + 25000 5m 34816 18432 16384 0 + 40000 5m 34816 18432 16384 0 + 50000 5m 34816 18432 16384 0 + 100000 5m 36864 18432 18432 0 + 1000 40m 36864 18432 18432 0 + 10000 40m 36864 18432 18432 0 + 25000 40m 39936 18432 21504 0 + 40000 40m 41984 18432 23552 0 + 50000 40m 41984 18432 23552 0 + 100000 40m 54272 18432 35840 0 + 1000 300m 49152 18432 30720 0 + 10000 300m 49152 18432 30720 0 + 25000 300m 71680 18432 53248 0 + 40000 300m 94208 18432 75776 0 + 50000 300m 94208 18432 75776 0 + 100000 300m 184320 18432 165888 0 + diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/port_config.ini b/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/port_config.ini new file mode 100644 index 000000000000..1dca36d97f66 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/port_config.ini @@ -0,0 +1,57 @@ +# name lanes alias index speed fec +Ethernet0 32 eth-0-1 0 10000 none +Ethernet1 33 eth-0-2 1 10000 none +Ethernet2 34 eth-0-3 2 10000 none +Ethernet3 35 eth-0-4 3 10000 none +Ethernet4 0 eth-0-5 4 10000 none +Ethernet5 4 eth-0-6 5 10000 none +Ethernet6 8 eth-0-7 6 10000 none +Ethernet7 12 eth-0-8 7 10000 none +Ethernet8 16 eth-0-9 8 10000 none +Ethernet9 20 eth-0-10 9 10000 none +Ethernet10 24 eth-0-11 10 10000 none +Ethernet11 28 eth-0-12 11 10000 none +Ethernet12 40 eth-0-13 12 10000 none +Ethernet13 44 eth-0-14 13 10000 none +Ethernet14 48 eth-0-15 14 10000 none +Ethernet15 52 eth-0-16 15 10000 none +Ethernet16 56 eth-0-17 16 10000 none +Ethernet17 60 eth-0-18 17 10000 none +Ethernet18 64 eth-0-19 18 10000 none +Ethernet19 68 eth-0-20 19 10000 none +Ethernet20 72 eth-0-21 20 10000 none +Ethernet21 73 eth-0-22 21 10000 none +Ethernet22 74 eth-0-23 22 10000 none +Ethernet23 75 eth-0-24 23 10000 none +Ethernet24 232 eth-0-25 24 10000 none +Ethernet25 233 eth-0-26 25 10000 none +Ethernet26 234 eth-0-27 26 10000 none +Ethernet27 235 eth-0-28 27 10000 none +Ethernet28 200 eth-0-29 28 10000 none +Ethernet29 204 eth-0-30 29 10000 none +Ethernet30 208 eth-0-31 30 10000 none +Ethernet31 212 eth-0-32 31 10000 none +Ethernet32 216 eth-0-33 32 10000 none +Ethernet33 220 eth-0-34 33 10000 none +Ethernet34 224 eth-0-35 34 10000 none +Ethernet35 228 eth-0-36 35 10000 none +Ethernet36 160 eth-0-37 36 10000 none +Ethernet37 164 eth-0-38 37 10000 none +Ethernet38 168 eth-0-39 38 10000 none +Ethernet39 172 eth-0-40 39 10000 none +Ethernet40 176 eth-0-41 40 10000 none +Ethernet41 180 eth-0-42 41 10000 none +Ethernet42 184 eth-0-43 42 10000 none +Ethernet43 188 eth-0-44 43 10000 none +Ethernet44 192 eth-0-45 44 10000 none +Ethernet45 193 eth-0-46 45 10000 none +Ethernet46 194 eth-0-47 46 10000 none +Ethernet47 195 eth-0-48 47 10000 none +Ethernet48 120,121,122,123 eth-0-49 48 100000 none +Ethernet49 124,125,126,127 eth-0-50 49 100000 none +Ethernet50 80,81,82,83 eth-0-51 50 100000 none +Ethernet51 84,85,86,87 eth-0-52 51 100000 none +Ethernet52 240,241,242,243 eth-0-53 52 100000 none +Ethernet53 244,245,246,247 eth-0-54 53 100000 none +Ethernet54 280,281,282,283 eth-0-55 54 100000 none +Ethernet55 284,285,286,287 eth-0-56 55 100000 none diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/qos.json.j2 b/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/qos.json.j2 new file mode 100644 index 000000000000..3e548325ea30 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/qos.json.j2 @@ -0,0 +1 @@ +{%- include 'qos_config.j2' %} diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/sai.profile b/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/sai.profile new file mode 100644 index 000000000000..314a045bffcc --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/V682-48x8c/sai.profile @@ -0,0 +1,3 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/V682-48x8c-chip-profile.txt +SAI_HW_PORT_PROFILE_ID_CONFIG_FILE=/usr/share/sonic/hwsku/V682-48x8c-datapath.txt +SAI_PLATFORM_CFG_FILE=/usr/share/sonic/hwsku/V682-48x8c-board.json diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/default_sku b/device/centec/x86_64-centec_v682_48x8c-r0/default_sku new file mode 100644 index 000000000000..a3168b7a0c3c --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/default_sku @@ -0,0 +1 @@ +V682-48x8c l2 diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/fancontrol b/device/centec/x86_64-centec_v682_48x8c-r0/fancontrol new file mode 100644 index 000000000000..07420a6dba06 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/fancontrol @@ -0,0 +1,10 @@ +# Configuration file generated by pwmconfig, changes will be lost +INTERVAL=10 +DEVPATH=hwmon1=devices/pci0000:00/0000:00:1f.3/i2c-0/0-0049 hwmon2=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-9/9-002c hwmon3=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-9/9-002e +DEVNAME=hwmon1=lm77 hwmon2=adt7470 hwmon3=adt7470 +FCTEMPS=hwmon2/pwm1=hwmon1/temp1_input hwmon2/pwm2=hwmon1/temp1_input hwmon2/pwm3=hwmon1/temp1_input hwmon2/pwm4=hwmon1/temp1_input hwmon3/pwm1=hwmon1/temp1_input hwmon3/pwm2=hwmon1/temp1_input hwmon3/pwm3=hwmon1/temp1_input hwmon3/pwm4=hwmon1/temp1_input +FCFANS=hwmon2/pwm1=hwmon2/fan1_input hwmon2/pwm2=hwmon2/fan2_input hwmon2/pwm3=hwmon2/fan3_input hwmon2/pwm4=hwmon2/fan4_input hwmon3/pwm1=hwmon3/fan1_input hwmon3/pwm2=hwmon3/fan2_input hwmon3/pwm3=hwmon3/fan3_input hwmon3/pwm4=hwmon3/fan4_input +MINTEMP=hwmon2/pwm1=20 hwmon2/pwm2=20 hwmon2/pwm3=20 hwmon2/pwm4=20 hwmon3/pwm1=20 hwmon3/pwm2=20 hwmon3/pwm3=20 hwmon3/pwm4=20 +MAXTEMP=hwmon2/pwm1=60 hwmon2/pwm2=60 hwmon2/pwm3=60 hwmon2/pwm4=60 hwmon3/pwm1=60 hwmon3/pwm2=60 hwmon3/pwm3=60 hwmon3/pwm4=60 +MINSTART=hwmon2/pwm1=150 hwmon2/pwm2=150 hwmon2/pwm3=150 hwmon2/pwm4=150 hwmon3/pwm1=150 hwmon3/pwm2=150 hwmon3/pwm3=150 hwmon3/pwm4=150 +MINSTOP=hwmon2/pwm1=0 hwmon2/pwm2=0 hwmon2/pwm3=0 hwmon2/pwm4=0 hwmon3/pwm1=0 hwmon3/pwm2=0 hwmon3/pwm3=0 hwmon3/pwm4=0 diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/installer.conf b/device/centec/x86_64-centec_v682_48x8c-r0/installer.conf new file mode 100644 index 000000000000..3b97b7f99da2 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/installer.conf @@ -0,0 +1 @@ +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="iommu=pt" diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/pcie.yaml b/device/centec/x86_64-centec_v682_48x8c-r0/pcie.yaml new file mode 100644 index 000000000000..5e00e24bc079 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/pcie.yaml @@ -0,0 +1,5 @@ +- bus: '05' + dev: '00' + fn: '0' + id: 8180 + name: 'Communication controller: Device cb10:8180' diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/platform_asic b/device/centec/x86_64-centec_v682_48x8c-r0/platform_asic new file mode 100644 index 000000000000..74dac3505ea6 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/platform_asic @@ -0,0 +1 @@ +centec diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/platform_components.json b/device/centec/x86_64-centec_v682_48x8c-r0/platform_components.json new file mode 100644 index 000000000000..4eb9f0277b9b --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/platform_components.json @@ -0,0 +1,8 @@ +{ + "chassis": { + "V682-48X8C": { + "component": { + } + } + } +} diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/platform_reboot b/device/centec/x86_64-centec_v682_48x8c-r0/platform_reboot new file mode 100755 index 000000000000..5e49eecb61ca --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/platform_reboot @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +import os +import time + +def main(): + os.system('hwclock -w -f /dev/rtc1') + time.sleep(1) + + os.system('i2cset -y 0 0x36 0x23 0') + time.sleep(1) + os.system('i2cset -y 0 0x36 0x23 1') + +if __name__ == '__main__': + main() diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/plugins/eeprom.py b/device/centec/x86_64-centec_v682_48x8c-r0/plugins/eeprom.py new file mode 100644 index 000000000000..7093e4b0f825 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/plugins/eeprom.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +############################################################################# +# Centec V682-48X8C +# +# Platform and model specific eeprom subclass, inherits from the base class, +# and provides the followings: +# - the eeprom format definition +# - specific encoder/decoder if there is special need +############################################################################# + +try: + import os + from sonic_eeprom import eeprom_tlvinfo + from sonic_py_common import device_info +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +USR_SHARE_SONIC_PATH = "/usr/share/sonic" +HOST_DEVICE_PATH = USR_SHARE_SONIC_PATH + "/device" +CONTAINER_PLATFORM_PATH = USR_SHARE_SONIC_PATH + "/platform" + +class board(eeprom_tlvinfo.TlvInfoDecoder): + + def __init__(self, name, path, cpld_root, ro): + if os.path.isdir(CONTAINER_PLATFORM_PATH): + platform_path = CONTAINER_PLATFORM_PATH + else: + platform = device_info.get_platform() + if platform is None: + raise + platform_path = os.path.join(HOST_DEVICE_PATH, platform) + + self.eeprom_path = platform_path + '/eeprom_file' + super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/plugins/led_control.py b/device/centec/x86_64-centec_v682_48x8c-r0/plugins/led_control.py new file mode 100644 index 000000000000..b787320d7840 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/plugins/led_control.py @@ -0,0 +1,214 @@ +#!/usr/bin/env python +# +# led_control.py +# +# Platform-specific LED control functionality for SONiC +# + +try: + import os + import re + import syslog + import collections + from sonic_led.led_control_base import LedControlBase + from sonic_py_common import device_info + from subprocess import Popen +except ImportError as e: + raise ImportError(str(e) + " - required module not found") + +USR_SHARE_SONIC_PATH = "/usr/share/sonic" +HOST_DEVICE_PATH = USR_SHARE_SONIC_PATH + "/device" +CONTAINER_PLATFORM_PATH = USR_SHARE_SONIC_PATH + "/platform" + +def DBG_PRINT(str): + syslog.openlog("centec-led") + syslog.syslog(syslog.LOG_INFO, str) + syslog.closelog() + +class LedControl(LedControlBase): + """Platform specific LED control class""" + + # Constructor + def __init__(self): + + self.mac_to_led = { + 32 : 0, + 33 : 1, + 34 : 2, + 35 : 3, + 0 : 4, + 4 : 5, + 8 : 6, + 12 : 7, + 16 : 8, + 20 : 9, + 24 : 10, + 28 : 11, + 40 : 12, + 44 : 13, + 48 : 14, + 52 : 15, + 56 : 16, + 60 : 17, + 64 : 18, + 68 : 19, + 72 : 20, + 73 : 21, + 74 : 22, + 75 : 23, + 232: 24, + 233: 25, + 234: 26, + 235: 27, + 200: 28, + 204: 29, + 208: 30, + 212: 31, + 216: 32, + 220: 33, + 224: 34, + 228: 35, + 160: 36, + 164: 37, + 168: 38, + 172: 39, + 176: 40, + 180: 41, + 184: 42, + 188: 43, + 192: 44, + 193: 45, + 194: 46, + 195: 47, + 120: 48, + 121: -1, + 122: -1, + 123: -1, + 124: 49, + 125: -1, + 126: -1, + 127: -1, + 80 : 50, + 81 : -1, + 82 : -1, + 83 : -1, + 84 : 51, + 85 : -1, + 86 : -1, + 87 : -1, + 240: 52, + 241: -1, + 242: -1, + 243: -1, + 244: 53, + 245: -1, + 246: -1, + 247: -1, + 280: 54, + 281: -1, + 282: -1, + 283: -1, + 284: 55, + 285: -1, + 286: -1, + 287: -1, + } + + if os.path.isdir(CONTAINER_PLATFORM_PATH): + platform_path = CONTAINER_PLATFORM_PATH + else: + platform = device_info.get_platform() + if platform is None: + raise + platform_path = os.path.join(HOST_DEVICE_PATH, platform) + + port_config_file = "/".join([platform_path, "V682-48x8c", "port_config.ini"]) + try: + f = open(port_config_file) + except: + raise + for line in f: + line.strip() + if re.search('^#', line) is not None: + Port_cfg = collections.namedtuple('Port_cfg', line.split()[1:]) + break + f.close() + f = open(port_config_file) + self._port_cfgs = [Port_cfg(*tuple((line.strip().split()))) + for line in f if re.search('^#', line) is None] + f.close() + + self.LED_MODE_UP = [5, 5] + self.LED_MODE_DOWN = [7, 7] + self.f_led = "/sys/class/leds/{}/brightness" + self._initDefaultConfig() + + # Helper method to map SONiC port name to index + def _port_name_to_index(self, port_name): + for port_cfg in self._port_cfgs: + if port_name == port_cfg.name: + macs = [int(x) for x in (port_cfg.lanes.split(','))] + led = self.mac_to_led[min(macs)] + if led < 0: + return None + return led + return None + + def _port_state_to_mode(self, port_idx, state): + if state == "up": + return self.LED_MODE_UP[1] if port_idx >= 48 else self.LED_MODE_UP[0] + else: + return self.LED_MODE_DOWN[1] if port_idx >= 48 else self.LED_MODE_DOWN[0] + + def _port_led_mode_update(self, port_idx, ledMode): + with open(self.f_led.format("port{}".format(port_idx)), 'w') as led_file: + led_file.write(str(ledMode)) + + def _initSystemLed(self): + try: + cmd = 'i2cset -y 0 0x36 0x2 0x5' + Popen(cmd, shell=True) + DBG_PRINT("init system led to normal") + cmd = 'i2cset -y 0 0x36 0x3 0x1' + Popen(cmd, shell=True) + DBG_PRINT("init idn led to off") + except IOError as e: + DBG_PRINT(str(e)) + + def _initPanelLed(self): + with open(self.f_led.format("port1"), 'r') as led_file: + shouldInit = (int(led_file.read()) == 0) + + if shouldInit == True: + for port_cfg in self._port_cfgs: + macs = [int(x) for x in (port_cfg.lanes.split(','))] + led = self.mac_to_led[min(macs)] + if led < 0: + continue + defmode = self._port_state_to_mode(led, "down") + with open(self.f_led.format("port{}".format(led)), 'w') as led_file: + led_file.write(str(defmode)) + DBG_PRINT("init port{} led to mode={}".format(led, defmode)) + + def _initDefaultConfig(self): + DBG_PRINT("start init led") + + self._initSystemLed() + self._initPanelLed() + + DBG_PRINT("init led done") + + # Concrete implementation of port_link_state_change() method + def port_link_state_change(self, portname, state): + port_idx = self._port_name_to_index(portname) + if port_idx is None: + return + ledMode = self._port_state_to_mode(port_idx, state) + with open(self.f_led.format("port{}".format(port_idx)), 'r') as led_file: + saveMode = int(led_file.read()) + + if ledMode == saveMode: + return + + self._port_led_mode_update(port_idx, ledMode) + DBG_PRINT("update {} led mode from {} to {}".format(portname, saveMode, ledMode)) diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/plugins/psuutil.py b/device/centec/x86_64-centec_v682_48x8c-r0/plugins/psuutil.py new file mode 100644 index 000000000000..9e311d9b4f5a --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/plugins/psuutil.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python + +############################################################################# +# Centec +# +# Module contains an implementation of SONiC PSU Base API and +# provides the PSUs status which are available in the platform +# +############################################################################# + +from subprocess import Popen, PIPE, STDOUT + +try: + from sonic_psu.psu_base import PsuBase +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +class PsuUtil(PsuBase): + """Platform-specific PSUutil class""" + + def __init__(self): + PsuBase.__init__(self) + + def get_num_psus(self): + """ + Retrieves the number of PSUs available on the device + + :return: An integer, the number of PSUs available on the device + """ + return 2 + + def get_psu_status(self, index): + """ + Retrieves the oprational status of power supply unit (PSU) defined + by 1-based index + + :param index: An integer, 1-based index of the PSU of which to query status + :return: Boolean, True if PSU is operating properly, False if PSU is faulty + """ + if index is None: + return False + + cmd = 'i2cget -y 0 0x36 0x1e' + status = int(Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True).stdout.readline(), 16) + powergood = ((status & (1 << (3 * (index - 1) + 2))) != 0) + return powergood + + def get_psu_presence(self, index): + """ + Retrieves the presence status of power supply unit (PSU) defined + by 1-based index + + :param index: An integer, 1-based index of the PSU of which to query status + :return: Boolean, True if PSU is plugged, False if not + """ + if index is None: + return False + + cmd = 'i2cget -y 0 0x36 0x1e' + status = int(Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True).stdout.readline(), 16) + presence = ((status & (1 << (3 * (index - 1) + 1))) == 0) + return presence diff --git a/device/centec/x86_64-centec_v682_48x8c-r0/pmon_daemon_control.json b/device/centec/x86_64-centec_v682_48x8c-r0/pmon_daemon_control.json new file mode 100644 index 000000000000..0db3279e44b0 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48x8c-r0/pmon_daemon_control.json @@ -0,0 +1,3 @@ +{ + +} diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/V682-48y8c-board.json b/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/V682-48y8c-board.json new file mode 100644 index 000000000000..435ab418aaba --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/V682-48y8c-board.json @@ -0,0 +1,597 @@ +{ + "macleds" : { + "polarity" : 1, + "cpumode" : 1, + "maps" : [ + { + "port_id" : 32, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port0/brightness" + }, + { + "port_id" : 33, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port1/brightness" + }, + { + "port_id" : 34, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port2/brightness" + }, + { + "port_id" : 35, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port3/brightness" + }, + { + "port_id" : 0, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port4/brightness" + }, + { + "port_id" : 4, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port5/brightness" + }, + { + "port_id" : 8, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port6/brightness" + }, + { + "port_id" : 12, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port7/brightness" + }, + { + "port_id" : 16, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port8/brightness" + }, + { + "port_id" : 20, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port9/brightness" + }, + { + "port_id" : 24, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port10/brightness" + }, + { + "port_id" : 28, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port11/brightness" + }, + { + "port_id" : 40, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port12/brightness" + }, + { + "port_id" : 44, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port13/brightness" + }, + { + "port_id" : 48, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port14/brightness" + }, + { + "port_id" : 52, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port15/brightness" + }, + { + "port_id" : 56, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port16/brightness" + }, + { + "port_id" : 60, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port17/brightness" + }, + { + "port_id" : 64, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port18/brightness" + }, + { + "port_id" : 68, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port19/brightness" + }, + { + "port_id" : 72, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port20/brightness" + }, + { + "port_id" : 73, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port21/brightness" + }, + { + "port_id" : 74, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port22/brightness" + }, + { + "port_id" : 75, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port23/brightness" + }, + + { + "port_id" : 120, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port48/brightness" + }, + { + "port_id" : 124, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port49/brightness" + }, + { + "port_id" : 80, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port50/brightness" + }, + { + "port_id" : 84, + "lchip" : 0, + "ctl_id" : 0, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port51/brightness" + }, + + { + "port_id" : 232, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port24/brightness" + }, + { + "port_id" : 233, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port25/brightness" + }, + { + "port_id" : 234, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port26/brightness" + }, + { + "port_id" : 235, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port27/brightness" + }, + { + "port_id" : 200, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port28/brightness" + }, + { + "port_id" : 204, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port29/brightness" + }, + { + "port_id" : 208, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port30/brightness" + }, + { + "port_id" : 212, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port31/brightness" + }, + { + "port_id" : 216, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port32/brightness" + }, + { + "port_id" : 220, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port33/brightness" + }, + { + "port_id" : 224, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port34/brightness" + }, + { + "port_id" : 228, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port35/brightness" + }, + { + "port_id" : 160, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port36/brightness" + }, + { + "port_id" : 164, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port37/brightness" + }, + { + "port_id" : 168, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port38/brightness" + }, + { + "port_id" : 172, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port39/brightness" + }, + { + "port_id" : 176, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port40/brightness" + }, + { + "port_id" : 180, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port41/brightness" + }, + { + "port_id" : 184, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port42/brightness" + }, + { + "port_id" : 188, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port43/brightness" + }, + { + "port_id" : 192, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port44/brightness" + }, + { + "port_id" : 193, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port45/brightness" + }, + { + "port_id" : 194, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port46/brightness" + }, + { + "port_id" : 195, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port47/brightness" + }, + + { + "port_id" : 240, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 0, + "sysfs_path" : "/sys/class/leds/port52/brightness" + }, + { + "port_id" : 244, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 1, + "sysfs_path" : "/sys/class/leds/port53/brightness" + }, + { + "port_id" : 280, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 1, + "sysfs_path" : "/sys/class/leds/port54/brightness" + }, + { + "port_id" : 284, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_2_FORCE_OFF", + "fixed" : 1, + "sysfs_path" : "/sys/class/leds/port55/brightness" + }, + + { + "port_id" : 161, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_1_FORCE_OFF", + "fixed" : 0 + }, + { + "port_id" : 162, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_1_FORCE_OFF", + "fixed" : 0 + }, + { + "port_id" : 165, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_1_FORCE_OFF", + "fixed" : 0 + }, + { + "port_id" : 166, + "lchip" : 0, + "ctl_id" : 1, + "mode" : "LED_MODE_1_FORCE_OFF", + "fixed" : 0 + } + ] + }, + "ffe" : { + "board_material" : "BOARD_MATERIAL_M4", + "config" : [ + { + "serdes_id" : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75], + "is_dac" : 1, + "speed" : [10000, 25000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [2, -13, 46, 0, 0] + }, + { + "serdes_id" : [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 50, 52, 53, 54, 55, 56, 57, 58, 59], + "is_dac" : 0, + "speed" : [10000, 1000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 46, -8, 0] + }, + { + "serdes_id" : [0, 1, 16, 17, 18, 19, 20, 21, 22, 23], + "is_dac" : 0, + "speed" : [10000, 1000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 42, -6, 0] + }, + { + "serdes_id" : [24, 25, 26, 27, 72, 74, 75], + "is_dac" : 0, + "speed" : [10000, 1000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 42, -4, 0] + }, + { + "serdes_id" : [48, 49, 51, 64, 65, 66, 67, 68, 69, 70, 71, 73], + "is_dac" : 0, + "speed" : [10000, 1000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 42, -6, 0] + }, + { + "serdes_id" : [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 50, 52, 53, 54, 55, 56, 57, 58, 59], + "is_dac" : 0, + "speed" : [25000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 44, -14, -1] + }, + { + "serdes_id" : [0, 1, 16, 17, 18, 19, 20, 21, 22, 23], + "is_dac" : 0, + "speed" : [25000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 38, -10, -2] + }, + { + "serdes_id" : [24, 25, 26, 27, 72, 74, 75], + "is_dac" : 0, + "speed" : [25000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 36, -6, -2] + }, + { + "serdes_id" : [48, 49, 51, 64, 65, 66, 67, 68, 69, 70, 71, 73], + "is_dac" : 0, + "speed" : [25000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 38, -10, -2] + }, + { + "serdes_id" : [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95], + "is_dac" : 1, + "speed" : [100000, 25000, 40000, 10000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [2, -13, 46, 0, 0] + }, + { + "serdes_id" : [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95], + "is_dac" : 1, + "speed" : [1000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 42, -4, 0] + }, + { + "serdes_id" : [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95], + "is_dac" : 0, + "speed" : [100000, 25000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 36, -6, -2] + }, + { + "serdes_id" : [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95], + "is_dac" : 0, + "speed" : [40000, 10000, 1000], + + "mode" : "CTC_CHIP_SERDES_FFE_MODE_DEFINE", + "cfg" : [0, 0, 42, -4, 0] + } + ] + } +} diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/V682-48y8c-chip-profile.txt b/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/V682-48y8c-chip-profile.txt new file mode 100644 index 000000000000..9fadec5d5f6b --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/V682-48y8c-chip-profile.txt @@ -0,0 +1,116 @@ +#----------------- SDK Feature Support -------------- +[MPLS_SUPPORT] = 1; +[APS_SUPPORT] = 1; +[OAM_SUPPORT] = 1; +[PTP_SUPPORT] = 0; +[SYNCE_SUPPORT] = 0; +[STACKING_SUPPORT] = 1; +[BPE_SUPPORT] = 0; +[IPFIX_SUPPORT] = 1; +[MONITOR_SUPPORT] = 1; +[OVERLAY_SUPPORT] = 1; +[EFD_SUPPORT] = 1; +[FCOE_SUPPORT] = 0; +[TRILL_SUPPORT] = 0; +[WLAN_SUPPORT] = 0; +[NPM_SUPPORT] = 1; +[DOT1AE_SUPPORT] = 1; +[SRV6_SUPPORT] = 0; +[DTEL_SUPPORT] = 1; +[FLEXE_SUPPORT] = 0; +[FDBTOKEN_SUPPORT] = 1; + +#----------------- Chip Init Parameter -------------- +#Local chip number and global chip id +[Local chip_num] = 1 +[Local chip0] = 0 +[Local chip1] = 1 +[Port_phy_mapping] = 1 + +#Cut through mode 0: Disable; 1:10/40/100G; 2:1/10/100G; 3:1/10/40G; other:Flex, refer to CUT_THROUGH_BITMAP +[CUT_THROUGH_SPEED] = 0 +#Flex cut through mode, speed enable by bitmap, refer to ctc_port_speed_t, Notice: 10M/100M/1G treat as the same speed +[CUT_THROUGH_BITMAP] = 0 + +#Network cpu port +[CPU_NETWORK_PORT_EN] = 0 +[CPU_NETWORK_PORT_ID] = 47 + +#Enable parity error and multi-bit ecc recover +[ECC_RECOVER_EN] = 0 +[TCAM_SCAN_EN] = 0 +[SDB_EN] = 0 + +#----------------- KNET Init Parameter -------------- +[KNET_EN] = 0 + +#----------------- FTM Init Parameter -------------- +#0: not use; 1: default; 2: layer3; 3: ipv6 +[FTM Profile] = 0 + +#----------------- Interrupt Init Parameter -------------- +#0: pin, 1: msi +[Interrupt_mode] = 1 + +#----------------- NextHop Init Parameter -------------- +#0: SDK work in pizzbox (single chip system), 1: SDK work in multi-chip system +[Nexthop Edit Mode] = 0 +[External Nexthop Number] = 16384 +[MPLS Tunnel Number] = 1024 +[H_ECMP_EN] = 0 + +#----------------- L2 Init Parameter -------------- +[FDB Hw Learning] = 0 +[Logic Port Num] = 1024 +#0: 128 instance per port, 1: 64 instance per port, 2: 32 instance per port +[STP MODE] = 0 +[MAX_FID_NUM] = 5120 + +#----------------- Stats Init Parameter -------------- +[STATS_QUEUE_DEQ_EN] = 1 +[STATS_QUEUE_DROP_EN] = 1 +[STATS_FLOW_POLICER_EN] = 1 +[STATS_VLAN_EN] = 0 +[STATS_VRF_EN] = 0 +[STATS_POLICER_NUM] = 1024 +[STATS_PORT_EN] = 0 +[STATS_ECMP_EN] = 0 + +#----------------- BPE Init Parameter -------------- +[BPE_BR_PORT_EXTENDER_EN] = 0 +[BPE_BR_UC_MAX_ECID] = 1024 +[BPE_BR_MC_MAX_ECID] = 4096 +[BPE_BR_PORT_BASE] = 0 + +#----------------- Ipuc Init Parameter -------------- +#0: tcam use prefix 16; 1: tcam use prefix 8 +[IPUC_TCAM_PREFIX_8] = 1 + +#----------------- QoS Init Parameter -------------- +#QoS policer number support 1K/2K/4K/8K, default 4K +[QOS_POLICER_NUM] = 4096 +#qos queue mode 0: 8(basic)+1(cpu) +#qos queue mode 1: 8(basic)+1(span)+1(mcast) +[QOS_QUEUE_MODE] = 0 +#QoS port extend queue number support 0/4, default 0 +[QOS_PORT_EXT_QUEUE_NUM] = 0 +#QoS CPU reason queue number support 128/64/32, default 128 +[QOS_CPU_QUEUE_NUM] = 128 +[QOS_INGRESS_VLAN_POLICER_NUM] = 0 +[QOS_EGRESS_VLAN_POLICER_NUM] = 0 +#QoS the max number of igs/egs reserve macro policer,which ACL entry support micro and macro at the same time +[QOS_INGRESS_MACRO_POLICER_NUM] = 0 +[QOS_EGRESS_MACRO_POLICER_NUM] = 0 +#QOS service queue mode, default 0,0:logic scr port + dstport enq 1:service id + dstport enq +[QOS_SERVICE_QUEUE_MODE] = 0 +#mode 0:svc policer used for service policer +#mode 1:svc policer used for stormctl +[QOS_POLICER_SVC_MODE] = 0 + +#----------------- Stacking Init Parameter -------------- +#0: normal mode; 1: spine-leaf mode +[FABRIC MODE] = 0 +[STACKING VERSION] = 1 +#----------------- LB hash Init Parameter -------------- +#0: support 4 select num; 1: support 8 select num; only TM2 support mode 1 +[LB_HASH_MODE] = 0 diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/V682-48y8c-datapath.txt b/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/V682-48y8c-datapath.txt new file mode 100644 index 000000000000..c3bf7e2d4abf --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/V682-48y8c-datapath.txt @@ -0,0 +1,1022 @@ +#SERDES_MODE: 0-NONE, 1-XFI, 2-SGMII, 3-Not Support, 4-QSGMII, 7-XLG, 8-100GR4, 9-SGMII2G5 +# 13-XXVG, 14-50GR2, 16-50GR1, 17-100GR2, 18-200G, 19-400G +#SERDES_POLY: 0-No Inverse, 1-Inverse +#SERDES_SWITCH: 0-Not Support Dynamic Switch, 1-Support Dynamic Switch exclude QSGMII, 2-Support Dynamic Switch include QSGMII + +[CORE_PLL] = 1050 +[DP0_FLEXE_CLIENT_NUM] = 0 +[DP1_FLEXE_CLIENT_NUM] = 0 +[DP0_XPIPE_PORT_NUM] = 0 +[DP1_XPIPE_PORT_NUM] = 0 +[DOT1AE_ENABLE] = 1 + +#{ +[SERDES_ITEM] + +[SERDES_ID] = 7 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 0 + +[SERDES_ID] = 6 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 1 + +[SERDES_ID] = 5 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 2 + +[SERDES_ID] = 4 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 3 + +[SERDES_ID] = 3 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 4 + +[SERDES_ID] = 2 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 5 + +[SERDES_ID] = 1 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 6 + +[SERDES_ID] = 0 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 7 + +[SERDES_ID] = 11 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 8 + +[SERDES_ID] = 10 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 9 + +[SERDES_ID] = 9 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 10 + +[SERDES_ID] = 8 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 11 + +[SERDES_ID] = 12 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 12 + +[SERDES_ID] = 13 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 13 + +[SERDES_ID] = 14 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 14 + +[SERDES_ID] = 15 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 15 + +[SERDES_ID] = 16 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 16 + +[SERDES_ID] = 17 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 17 + +[SERDES_ID] = 18 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 18 + +[SERDES_ID] = 19 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 19 + +[SERDES_ID] = 20 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 20 + +[SERDES_ID] = 21 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 21 + +[SERDES_ID] = 22 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 22 + +[SERDES_ID] = 23 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 23 + +[SERDES_ID] = 24 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 24 + +[SERDES_ID] = 25 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 25 + +[SERDES_ID] = 26 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 26 + +[SERDES_ID] = 27 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 27 + +[SERDES_ID] = 28 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 28 + +[SERDES_ID] = 29 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 29 + +[SERDES_ID] = 30 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 30 + +[SERDES_ID] = 31 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 31 + +[SERDES_ID] = 36 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 32 + +[SERDES_ID] = 37 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 33 + +[SERDES_ID] = 38 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 34 + +[SERDES_ID] = 32 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 35 + +[SERDES_ID] = 39 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 36 + +[SERDES_ID] = 34 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 37 + +[SERDES_ID] = 35 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 38 + +[SERDES_ID] = 33 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 39 + +[SERDES_ID] = 40 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 40 + +[SERDES_ID] = 44 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 41 + +[SERDES_ID] = 42 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 42 + +[SERDES_ID] = 41 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 43 + +[SERDES_ID] = 43 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 44 + +[SERDES_ID] = 46 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 45 + +[SERDES_ID] = 47 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 46 + +[SERDES_ID] = 45 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 47 + +[SERDES_ID] = 49 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 48 + +[SERDES_ID] = 48 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 49 + +[SERDES_ID] = 51 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 50 + +[SERDES_ID] = 50 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 51 + +[SERDES_ID] = 53 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 52 + +[SERDES_ID] = 52 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 53 + +[SERDES_ID] = 55 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 54 + +[SERDES_ID] = 54 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 55 + +[SERDES_ID] = 57 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 56 + +[SERDES_ID] = 56 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 57 + +[SERDES_ID] = 59 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 58 + +[SERDES_ID] = 58 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 59 + +[SERDES_ID] = 60 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 60 + +[SERDES_ID] = 61 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 61 + +[SERDES_ID] = 62 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 62 + +[SERDES_ID] = 63 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 63 + +[SERDES_ID] = 70 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 64 + +[SERDES_ID] = 71 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 65 + +[SERDES_ID] = 68 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 66 + +[SERDES_ID] = 69 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 67 + +[SERDES_ID] = 66 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 68 + +[SERDES_ID] = 67 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 69 + +[SERDES_ID] = 64 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 70 + +[SERDES_ID] = 65 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 1 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 71 + +[SERDES_ID] = 74 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 72 + +[SERDES_ID] = 75 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 73 + +[SERDES_ID] = 72 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 74 + +[SERDES_ID] = 73 +[SERDES_MODE] = 13 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 75 + +[SERDES_ID] = 76 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 76 + +[SERDES_ID] = 77 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 77 + +[SERDES_ID] = 78 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 78 + +[SERDES_ID] = 79 +[SERDES_MODE] = 0 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 79 + +[SERDES_ID] = 83 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 80 + +[SERDES_ID] = 81 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 81 + +[SERDES_ID] = 87 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 82 + +[SERDES_ID] = 82 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 83 + +[SERDES_ID] = 86 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 84 + +[SERDES_ID] = 80 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 85 + +[SERDES_ID] = 84 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 86 + +[SERDES_ID] = 85 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 87 + +[SERDES_ID] = 95 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 88 + +[SERDES_ID] = 93 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 89 + +[SERDES_ID] = 91 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 90 + +[SERDES_ID] = 94 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 91 + +[SERDES_ID] = 90 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 92 + +[SERDES_ID] = 89 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 93 + +[SERDES_ID] = 88 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 94 + +[SERDES_ID] = 92 +[SERDES_MODE] = 8 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 95 + +[SERDES_ID] = 96 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 96 + +[SERDES_ID] = 97 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 97 + +[SERDES_ID] = 98 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 98 + +[SERDES_ID] = 99 +[SERDES_MODE] = 1 +[SERDES_RX_POLY] = 0 +[SERDES_TX_POLY] = 0 +[SERDES_SWITCH] = 1 +[SERDES_GROUP] = 0 +[SERDES_XPIPE] = 0 +[INDEX] = 99 + +#} +[SERDES_TO_LPORT] +#{ +#index |serdes |QSGMII |SGMII/SGMII2G5/XFI/XXVG |XLG |50GR1 |50GR2 |100GR4 |100GR2 |200G |400G +#----------|----------|------------|------------------------|--------|--------|--------|--------|--------|--------|-------- +#0 |7 |NA |0 |0 |0 |0 |0 |0 |NA |NA +#1 |6 |NA |1 |0 |NA |0 |0 |NA |NA |NA +#2 |5 |NA |2 |0 |2 |2 |0 |0 |NA |NA +#3 |4 |NA |3 |0 |NA |2 |0 |NA |NA |NA +#4 |3 |NA |4 |4 |4 |4 |4 |4 |NA |NA +#5 |2 |NA |5 |4 |NA |4 |4 |NA |NA |NA +#6 |1 |NA |6 |4 |6 |6 |4 |4 |NA |NA +#7 |0 |NA |7 |4 |NA |6 |4 |NA |NA |NA +#8 |11 |NA |8 |8 |8 |8 |8 |8 |NA |NA +#9 |10 |NA |9 |8 |NA |8 |8 |NA |NA |NA +#10 |9 |NA |10 |8 |10 |10 |8 |8 |NA |NA +#11 |8 |NA |11 |8 |NA |10 |8 |NA |NA |NA +#12 |12 |NA |12 |12 |12 |12 |12 |12 |NA |NA +#13 |13 |NA |13 |12 |NA |12 |12 |NA |NA |NA +#14 |14 |NA |14 |12 |14 |14 |12 |12 |NA |NA +#15 |15 |NA |15 |12 |NA |14 |12 |NA |NA |NA +#16 |16 |NA |16 |16 |16 |16 |16 |16 |NA |NA +#17 |17 |NA |17 |16 |NA |16 |16 |NA |NA |NA +#18 |18 |NA |18 |16 |18 |18 |16 |16 |NA |NA +#19 |19 |NA |19 |16 |NA |18 |16 |NA |NA |NA +#20 |20 |NA |20 |20 |20 |20 |20 |20 |NA |NA +#21 |21 |NA |21 |20 |NA |20 |20 |NA |NA |NA +#22 |22 |NA |22 |20 |22 |22 |20 |20 |NA |NA +#23 |23 |NA |23 |20 |NA |22 |20 |NA |NA |NA +#24 |24 |NA |24 |24 |24 |24 |24 |24 |NA |NA +#25 |25 |NA |25 |24 |NA |24 |24 |NA |NA |NA +#26 |26 |NA |26 |24 |26 |26 |24 |24 |NA |NA +#27 |27 |NA |27 |24 |NA |26 |24 |NA |NA |NA +#28 |28 |NA |28 |28 |28 |28 |28 |28 |NA |NA +#29 |29 |NA |29 |28 |NA |28 |28 |NA |NA |NA +#30 |30 |NA |30 |28 |30 |30 |28 |28 |NA |NA +#31 |31 |NA |31 |28 |NA |30 |28 |NA |NA |NA +#32 |36 |NA |32 |32 |32 |32 |32 |32 |32 |32 +#33 |37 |NA |33 |32 |33 |32 |32 |32 |32 |32 +#34 |38 |NA |34 |32 |34 |34 |32 |34 |32 |32 +#35 |32 |NA |35 |32 |35 |34 |32 |34 |32 |32 +#36 |39 |NA |36 |36 |36 |36 |36 |36 |36 |32 +#37 |34 |NA |37 |36 |37 |36 |36 |36 |36 |32 +#38 |35 |NA |38 |36 |38 |38 |36 |38 |36 |32 +#39 |33 |NA |39 |36 |39 |38 |36 |38 |36 |32 +#40 |40 |NA |40 |40 |40 |40 |40 |40 |40 |40 +#41 |44 |NA |41 |40 |41 |40 |40 |40 |40 |40 +#42 |42 |NA |42 |40 |42 |42 |40 |42 |40 |40 +#43 |41 |NA |43 |40 |43 |42 |40 |42 |40 |40 +#44 |43 |NA |44 |44 |44 |44 |44 |44 |44 |40 +#45 |46 |NA |45 |44 |45 |44 |44 |44 |44 |40 +#46 |47 |NA |46 |44 |46 |46 |44 |46 |44 |40 +#47 |45 |NA |47 |44 |47 |46 |44 |46 |44 |40 +#48 |49 |NA |48 |48 |48 |48 |48 |48 |NA |NA +#49 |48 |NA |49 |48 |NA |48 |48 |NA |NA |NA +#50 |51 |NA |50 |48 |50 |50 |48 |48 |NA |NA +#51 |50 |NA |51 |48 |NA |50 |48 |NA |NA |NA +#52 |53 |NA |52 |52 |52 |52 |52 |52 |NA |NA +#53 |52 |NA |53 |52 |NA |52 |52 |NA |NA |NA +#54 |55 |NA |54 |52 |54 |54 |52 |52 |NA |NA +#55 |54 |NA |55 |52 |NA |54 |52 |NA |NA |NA +#56 |57 |NA |56 |56 |56 |56 |56 |56 |NA |NA +#57 |56 |NA |57 |56 |NA |56 |56 |NA |NA |NA +#58 |59 |NA |58 |56 |58 |58 |56 |56 |NA |NA +#59 |58 |NA |59 |56 |NA |58 |56 |NA |NA |NA +#60 |60 |NA |60 |60 |60 |60 |60 |60 |NA |NA +#61 |61 |NA |61 |60 |NA |60 |60 |NA |NA |NA +#62 |62 |NA |62 |60 |62 |62 |60 |60 |NA |NA +#63 |63 |NA |63 |60 |NA |62 |60 |NA |NA |NA +#64 |70 |NA |64 |64 |64 |64 |64 |64 |NA |NA +#65 |71 |NA |65 |64 |NA |64 |64 |NA |NA |NA +#66 |68 |NA |66 |64 |66 |66 |64 |64 |NA |NA +#67 |69 |NA |67 |64 |NA |66 |64 |NA |NA |NA +#68 |66 |NA |68 |68 |68 |68 |68 |68 |NA |NA +#69 |67 |NA |69 |68 |NA |68 |68 |NA |NA |NA +#70 |64 |NA |70 |68 |70 |70 |68 |68 |NA |NA +#71 |65 |NA |71 |68 |NA |70 |68 |NA |NA |NA +#72 |74 |NA |72 |72 |72 |72 |72 |72 |NA |NA +#73 |75 |NA |73 |72 |NA |72 |72 |NA |NA |NA +#74 |72 |NA |74 |72 |74 |74 |72 |72 |NA |NA +#75 |73 |NA |75 |72 |NA |74 |72 |NA |NA |NA +#76 |76 |NA |76 |76 |76 |76 |76 |76 |NA |NA +#77 |77 |NA |77 |76 |NA |76 |76 |NA |NA |NA +#78 |78 |NA |78 |76 |78 |78 |76 |76 |NA |NA +#79 |79 |NA |79 |76 |NA |78 |76 |NA |NA |NA +#80 |83 |NA |80 |80 |80 |80 |80 |80 |80 |80 +#81 |81 |NA |81 |80 |81 |80 |80 |80 |80 |80 +#82 |87 |NA |82 |80 |82 |82 |80 |82 |80 |80 +#83 |82 |NA |83 |80 |83 |82 |80 |82 |80 |80 +#84 |86 |NA |84 |84 |84 |84 |84 |84 |84 |80 +#85 |80 |NA |85 |84 |85 |84 |84 |84 |84 |80 +#86 |84 |NA |86 |84 |86 |86 |84 |86 |84 |80 +#87 |85 |NA |87 |84 |87 |86 |84 |86 |84 |80 +#88 |95 |NA |88 |88 |88 |88 |88 |88 |88 |88 +#89 |93 |NA |89 |88 |89 |88 |88 |88 |88 |88 +#90 |91 |NA |90 |88 |90 |90 |88 |90 |88 |88 +#91 |94 |NA |91 |88 |91 |90 |88 |90 |88 |88 +#92 |90 |NA |92 |92 |92 |92 |92 |92 |92 |88 +#93 |89 |NA |93 |92 |93 |92 |92 |92 |92 |88 +#94 |88 |NA |94 |92 |94 |94 |92 |94 |92 |88 +#95 |92 |NA |95 |92 |95 |94 |92 |94 |92 |88 +#96 |96 |NA |232 |232 |232 |232 |232 |232 |NA |NA +#97 |97 |NA |233 |232 |NA |232 |232 |NA |NA |NA +#98 |98 |NA |243 |232 |243 |243 |232 |232 |NA |NA +#99 |99 |NA |244 |232 |NA |243 |232 |NA |NA |NA +#} + diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/buffers.json.j2 b/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/buffers.json.j2 new file mode 100644 index 000000000000..08e21e428b6c --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/buffers.json.j2 @@ -0,0 +1,70 @@ +{# Default values which will be used if no actual configura available #} +{% set default_cable = '40m' %} +{% set default_ports_num = 54 -%} + +{# Port configuration to cable length look-up table #} +{# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #} +{# Roles described in the minigraph #} +{% set ports2cable = { + 'torrouter_server' : '5m', + 'leafrouter_torrouter' : '40m', + 'spinerouter_leafrouter' : '300m' + } +%} + +{%- macro cable_length(port_name) -%} + {%- set cable_len = [] -%} + {%- for local_port in DEVICE_NEIGHBOR -%} + {%- if local_port == port_name -%} + {%- if DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%} + {%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%} + {%- set neighbor_role = neighbor.type -%} + {%- set roles1 = switch_role + '_' + neighbor_role %} + {%- set roles2 = neighbor_role + '_' + switch_role -%} + {%- set roles1 = roles1 | lower -%} + {%- set roles2 = roles2 | lower -%} + {%- if roles1 in ports2cable -%} + {%- if cable_len.append(ports2cable[roles1]) -%}{%- endif -%} + {%- elif roles2 in ports2cable -%} + {%- if cable_len.append(ports2cable[roles2]) -%}{%- endif -%} + {%- endif -%} + {%- endif -%} + {%- endif -%} + {%- endfor -%} + {%- if cable_len -%} + {{ cable_len.0 }} + {%- else -%} + {{ default_cable }} + {%- endif -%} +{% endmacro %} + +{%- if DEVICE_METADATA is defined %} +{%- set switch_role = DEVICE_METADATA['localhost']['type'] %} +{%- endif -%} + +{# Generate list of ports if not defined #} +{% if PORT is not defined %} + {% set PORT = [] %} + {% for port_idx in range(1,default_ports_num+1) %} + {% if PORT.append("Ethernet%d" % (port_idx)) %}{% endif %} + {% endfor %} +{% endif -%} + +{% set port_names_list = [] %} +{% for port in PORT %} + {%- if port_names_list.append(port) %}{% endif %} +{% endfor %} +{% set port_names = port_names_list | join(',') -%} + +{ + "CABLE_LENGTH": { + "AZURE": { + {% for port in PORT %} + {% set cable = cable_length(port) -%} + "{{ port }}": "{{ cable }}"{%- if not loop.last -%},{% endif %} + + {% endfor %} + } + } +} + diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/pg_profile_lookup.ini b/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/pg_profile_lookup.ini new file mode 100644 index 000000000000..a65244e69b5b --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/pg_profile_lookup.ini @@ -0,0 +1,21 @@ +# PG lossless profiles. +# speed cable size xon xoff threshold + 1000 5m 34816 18432 16384 0 + 10000 5m 34816 18432 16384 0 + 25000 5m 34816 18432 16384 0 + 40000 5m 34816 18432 16384 0 + 50000 5m 34816 18432 16384 0 + 100000 5m 36864 18432 18432 0 + 1000 40m 36864 18432 18432 0 + 10000 40m 36864 18432 18432 0 + 25000 40m 39936 18432 21504 0 + 40000 40m 41984 18432 23552 0 + 50000 40m 41984 18432 23552 0 + 100000 40m 54272 18432 35840 0 + 1000 300m 49152 18432 30720 0 + 10000 300m 49152 18432 30720 0 + 25000 300m 71680 18432 53248 0 + 40000 300m 94208 18432 75776 0 + 50000 300m 94208 18432 75776 0 + 100000 300m 184320 18432 165888 0 + diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/port_config.ini b/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/port_config.ini new file mode 100644 index 000000000000..45206015c94e --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/port_config.ini @@ -0,0 +1,57 @@ +# name lanes alias index speed fec +Ethernet0 32 eth-0-1 0 25000 none +Ethernet1 33 eth-0-2 1 25000 none +Ethernet2 34 eth-0-3 2 25000 none +Ethernet3 35 eth-0-4 3 25000 none +Ethernet4 0 eth-0-5 4 25000 none +Ethernet5 4 eth-0-6 5 25000 none +Ethernet6 8 eth-0-7 6 25000 none +Ethernet7 12 eth-0-8 7 25000 none +Ethernet8 16 eth-0-9 8 25000 none +Ethernet9 20 eth-0-10 9 25000 none +Ethernet10 24 eth-0-11 10 25000 none +Ethernet11 28 eth-0-12 11 25000 none +Ethernet12 40 eth-0-13 12 25000 none +Ethernet13 44 eth-0-14 13 25000 none +Ethernet14 48 eth-0-15 14 25000 none +Ethernet15 52 eth-0-16 15 25000 none +Ethernet16 56 eth-0-17 16 25000 none +Ethernet17 60 eth-0-18 17 25000 none +Ethernet18 64 eth-0-19 18 25000 none +Ethernet19 68 eth-0-20 19 25000 none +Ethernet20 72 eth-0-21 20 25000 none +Ethernet21 73 eth-0-22 21 25000 none +Ethernet22 74 eth-0-23 22 25000 none +Ethernet23 75 eth-0-24 23 25000 none +Ethernet24 232 eth-0-25 24 25000 none +Ethernet25 233 eth-0-26 25 25000 none +Ethernet26 234 eth-0-27 26 25000 none +Ethernet27 235 eth-0-28 27 25000 none +Ethernet28 200 eth-0-29 28 25000 none +Ethernet29 204 eth-0-30 29 25000 none +Ethernet30 208 eth-0-31 30 25000 none +Ethernet31 212 eth-0-32 31 25000 none +Ethernet32 216 eth-0-33 32 25000 none +Ethernet33 220 eth-0-34 33 25000 none +Ethernet34 224 eth-0-35 34 25000 none +Ethernet35 228 eth-0-36 35 25000 none +Ethernet36 160 eth-0-37 36 25000 none +Ethernet37 164 eth-0-38 37 25000 none +Ethernet38 168 eth-0-39 38 25000 none +Ethernet39 172 eth-0-40 39 25000 none +Ethernet40 176 eth-0-41 40 25000 none +Ethernet41 180 eth-0-42 41 25000 none +Ethernet42 184 eth-0-43 42 25000 none +Ethernet43 188 eth-0-44 43 25000 none +Ethernet44 192 eth-0-45 44 25000 none +Ethernet45 193 eth-0-46 45 25000 none +Ethernet46 194 eth-0-47 46 25000 none +Ethernet47 195 eth-0-48 47 25000 none +Ethernet48 120,121,122,123 eth-0-49 48 100000 none +Ethernet49 124,125,126,127 eth-0-50 49 100000 none +Ethernet50 80,81,82,83 eth-0-51 50 100000 none +Ethernet51 84,85,86,87 eth-0-52 51 100000 none +Ethernet52 240,241,242,243 eth-0-53 52 100000 none +Ethernet53 244,245,246,247 eth-0-54 53 100000 none +Ethernet54 280,281,282,283 eth-0-55 54 100000 none +Ethernet55 284,285,286,287 eth-0-56 55 100000 none diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/qos.json.j2 b/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/qos.json.j2 new file mode 100644 index 000000000000..3e548325ea30 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/qos.json.j2 @@ -0,0 +1 @@ +{%- include 'qos_config.j2' %} diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/sai.profile b/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/sai.profile new file mode 100644 index 000000000000..9a3643c35b20 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/V682-48y8c/sai.profile @@ -0,0 +1,3 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/V682-48y8c-chip-profile.txt +SAI_HW_PORT_PROFILE_ID_CONFIG_FILE=/usr/share/sonic/hwsku/V682-48y8c-datapath.txt +SAI_PLATFORM_CFG_FILE=/usr/share/sonic/hwsku/V682-48y8c-board.json diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/default_sku b/device/centec/x86_64-centec_v682_48y8c-r0/default_sku new file mode 100644 index 000000000000..d169d9636002 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/default_sku @@ -0,0 +1 @@ +V682-48y8c l2 diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/fancontrol b/device/centec/x86_64-centec_v682_48y8c-r0/fancontrol new file mode 100644 index 000000000000..07420a6dba06 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/fancontrol @@ -0,0 +1,10 @@ +# Configuration file generated by pwmconfig, changes will be lost +INTERVAL=10 +DEVPATH=hwmon1=devices/pci0000:00/0000:00:1f.3/i2c-0/0-0049 hwmon2=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-9/9-002c hwmon3=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-9/9-002e +DEVNAME=hwmon1=lm77 hwmon2=adt7470 hwmon3=adt7470 +FCTEMPS=hwmon2/pwm1=hwmon1/temp1_input hwmon2/pwm2=hwmon1/temp1_input hwmon2/pwm3=hwmon1/temp1_input hwmon2/pwm4=hwmon1/temp1_input hwmon3/pwm1=hwmon1/temp1_input hwmon3/pwm2=hwmon1/temp1_input hwmon3/pwm3=hwmon1/temp1_input hwmon3/pwm4=hwmon1/temp1_input +FCFANS=hwmon2/pwm1=hwmon2/fan1_input hwmon2/pwm2=hwmon2/fan2_input hwmon2/pwm3=hwmon2/fan3_input hwmon2/pwm4=hwmon2/fan4_input hwmon3/pwm1=hwmon3/fan1_input hwmon3/pwm2=hwmon3/fan2_input hwmon3/pwm3=hwmon3/fan3_input hwmon3/pwm4=hwmon3/fan4_input +MINTEMP=hwmon2/pwm1=20 hwmon2/pwm2=20 hwmon2/pwm3=20 hwmon2/pwm4=20 hwmon3/pwm1=20 hwmon3/pwm2=20 hwmon3/pwm3=20 hwmon3/pwm4=20 +MAXTEMP=hwmon2/pwm1=60 hwmon2/pwm2=60 hwmon2/pwm3=60 hwmon2/pwm4=60 hwmon3/pwm1=60 hwmon3/pwm2=60 hwmon3/pwm3=60 hwmon3/pwm4=60 +MINSTART=hwmon2/pwm1=150 hwmon2/pwm2=150 hwmon2/pwm3=150 hwmon2/pwm4=150 hwmon3/pwm1=150 hwmon3/pwm2=150 hwmon3/pwm3=150 hwmon3/pwm4=150 +MINSTOP=hwmon2/pwm1=0 hwmon2/pwm2=0 hwmon2/pwm3=0 hwmon2/pwm4=0 hwmon3/pwm1=0 hwmon3/pwm2=0 hwmon3/pwm3=0 hwmon3/pwm4=0 diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/installer.conf b/device/centec/x86_64-centec_v682_48y8c-r0/installer.conf new file mode 100644 index 000000000000..3b97b7f99da2 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/installer.conf @@ -0,0 +1 @@ +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="iommu=pt" diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/pcie.yaml b/device/centec/x86_64-centec_v682_48y8c-r0/pcie.yaml new file mode 100644 index 000000000000..5e00e24bc079 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/pcie.yaml @@ -0,0 +1,5 @@ +- bus: '05' + dev: '00' + fn: '0' + id: 8180 + name: 'Communication controller: Device cb10:8180' diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/platform_asic b/device/centec/x86_64-centec_v682_48y8c-r0/platform_asic new file mode 100644 index 000000000000..74dac3505ea6 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/platform_asic @@ -0,0 +1 @@ +centec diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/platform_components.json b/device/centec/x86_64-centec_v682_48y8c-r0/platform_components.json new file mode 100644 index 000000000000..15c644f6b461 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/platform_components.json @@ -0,0 +1,8 @@ +{ + "chassis": { + "V682-48Y8C": { + "component": { + } + } + } +} diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/platform_reboot b/device/centec/x86_64-centec_v682_48y8c-r0/platform_reboot new file mode 100755 index 000000000000..5e49eecb61ca --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/platform_reboot @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +import os +import time + +def main(): + os.system('hwclock -w -f /dev/rtc1') + time.sleep(1) + + os.system('i2cset -y 0 0x36 0x23 0') + time.sleep(1) + os.system('i2cset -y 0 0x36 0x23 1') + +if __name__ == '__main__': + main() diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/plugins/eeprom.py b/device/centec/x86_64-centec_v682_48y8c-r0/plugins/eeprom.py new file mode 100644 index 000000000000..1651279722ee --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/plugins/eeprom.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +############################################################################# +# Centec V682-48Y8C +# +# Platform and model specific eeprom subclass, inherits from the base class, +# and provides the followings: +# - the eeprom format definition +# - specific encoder/decoder if there is special need +############################################################################# + +try: + import os + from sonic_eeprom import eeprom_tlvinfo + from sonic_py_common import device_info +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +USR_SHARE_SONIC_PATH = "/usr/share/sonic" +HOST_DEVICE_PATH = USR_SHARE_SONIC_PATH + "/device" +CONTAINER_PLATFORM_PATH = USR_SHARE_SONIC_PATH + "/platform" + +class board(eeprom_tlvinfo.TlvInfoDecoder): + + def __init__(self, name, path, cpld_root, ro): + if os.path.isdir(CONTAINER_PLATFORM_PATH): + platform_path = CONTAINER_PLATFORM_PATH + else: + platform = device_info.get_platform() + if platform is None: + raise + platform_path = os.path.join(HOST_DEVICE_PATH, platform) + + self.eeprom_path = platform_path + '/eeprom_file' + super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/plugins/led_control.py b/device/centec/x86_64-centec_v682_48y8c-r0/plugins/led_control.py new file mode 100644 index 000000000000..973a9354fbc6 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/plugins/led_control.py @@ -0,0 +1,214 @@ +#!/usr/bin/env python +# +# led_control.py +# +# Platform-specific LED control functionality for SONiC +# + +try: + import os + import re + import syslog + import collections + from sonic_led.led_control_base import LedControlBase + from sonic_py_common import device_info + from subprocess import Popen +except ImportError as e: + raise ImportError(str(e) + " - required module not found") + +USR_SHARE_SONIC_PATH = "/usr/share/sonic" +HOST_DEVICE_PATH = USR_SHARE_SONIC_PATH + "/device" +CONTAINER_PLATFORM_PATH = USR_SHARE_SONIC_PATH + "/platform" + +def DBG_PRINT(str): + syslog.openlog("centec-led") + syslog.syslog(syslog.LOG_INFO, str) + syslog.closelog() + +class LedControl(LedControlBase): + """Platform specific LED control class""" + + # Constructor + def __init__(self): + + self.mac_to_led = { + 32 : 0, + 33 : 1, + 34 : 2, + 35 : 3, + 0 : 4, + 4 : 5, + 8 : 6, + 12 : 7, + 16 : 8, + 20 : 9, + 24 : 10, + 28 : 11, + 40 : 12, + 44 : 13, + 48 : 14, + 52 : 15, + 56 : 16, + 60 : 17, + 64 : 18, + 68 : 19, + 72 : 20, + 73 : 21, + 74 : 22, + 75 : 23, + 232: 24, + 233: 25, + 234: 26, + 235: 27, + 200: 28, + 204: 29, + 208: 30, + 212: 31, + 216: 32, + 220: 33, + 224: 34, + 228: 35, + 160: 36, + 164: 37, + 168: 38, + 172: 39, + 176: 40, + 180: 41, + 184: 42, + 188: 43, + 192: 44, + 193: 45, + 194: 46, + 195: 47, + 120: 48, + 121: -1, + 122: -1, + 123: -1, + 124: 49, + 125: -1, + 126: -1, + 127: -1, + 80 : 50, + 81 : -1, + 82 : -1, + 83 : -1, + 84 : 51, + 85 : -1, + 86 : -1, + 87 : -1, + 240: 52, + 241: -1, + 242: -1, + 243: -1, + 244: 53, + 245: -1, + 246: -1, + 247: -1, + 280: 54, + 281: -1, + 282: -1, + 283: -1, + 284: 55, + 285: -1, + 286: -1, + 287: -1, + } + + if os.path.isdir(CONTAINER_PLATFORM_PATH): + platform_path = CONTAINER_PLATFORM_PATH + else: + platform = device_info.get_platform() + if platform is None: + raise + platform_path = os.path.join(HOST_DEVICE_PATH, platform) + + port_config_file = "/".join([platform_path, "V682-48y8c", "port_config.ini"]) + try: + f = open(port_config_file) + except: + raise + for line in f: + line.strip() + if re.search('^#', line) is not None: + Port_cfg = collections.namedtuple('Port_cfg', line.split()[1:]) + break + f.close() + f = open(port_config_file) + self._port_cfgs = [Port_cfg(*tuple((line.strip().split()))) + for line in f if re.search('^#', line) is None] + f.close() + + self.LED_MODE_UP = [5, 5] + self.LED_MODE_DOWN = [7, 7] + self.f_led = "/sys/class/leds/{}/brightness" + self._initDefaultConfig() + + # Helper method to map SONiC port name to index + def _port_name_to_index(self, port_name): + for port_cfg in self._port_cfgs: + if port_name == port_cfg.name: + macs = [int(x) for x in (port_cfg.lanes.split(','))] + led = self.mac_to_led[min(macs)] + if led < 0: + return None + return led + return None + + def _port_state_to_mode(self, port_idx, state): + if state == "up": + return self.LED_MODE_UP[1] if port_idx >= 48 else self.LED_MODE_UP[0] + else: + return self.LED_MODE_DOWN[1] if port_idx >= 48 else self.LED_MODE_DOWN[0] + + def _port_led_mode_update(self, port_idx, ledMode): + with open(self.f_led.format("port{}".format(port_idx)), 'w') as led_file: + led_file.write(str(ledMode)) + + def _initSystemLed(self): + try: + cmd = 'i2cset -y 0 0x36 0x2 0x5' + Popen(cmd, shell=True) + DBG_PRINT("init system led to normal") + cmd = 'i2cset -y 0 0x36 0x3 0x1' + Popen(cmd, shell=True) + DBG_PRINT("init idn led to off") + except IOError as e: + DBG_PRINT(str(e)) + + def _initPanelLed(self): + with open(self.f_led.format("port1"), 'r') as led_file: + shouldInit = (int(led_file.read()) == 0) + + if shouldInit == True: + for port_cfg in self._port_cfgs: + macs = [int(x) for x in (port_cfg.lanes.split(','))] + led = self.mac_to_led[min(macs)] + if led < 0: + continue + defmode = self._port_state_to_mode(led, "down") + with open(self.f_led.format("port{}".format(led)), 'w') as led_file: + led_file.write(str(defmode)) + DBG_PRINT("init port{} led to mode={}".format(led, defmode)) + + def _initDefaultConfig(self): + DBG_PRINT("start init led") + + self._initSystemLed() + self._initPanelLed() + + DBG_PRINT("init led done") + + # Concrete implementation of port_link_state_change() method + def port_link_state_change(self, portname, state): + port_idx = self._port_name_to_index(portname) + if port_idx is None: + return + ledMode = self._port_state_to_mode(port_idx, state) + with open(self.f_led.format("port{}".format(port_idx)), 'r') as led_file: + saveMode = int(led_file.read()) + + if ledMode == saveMode: + return + + self._port_led_mode_update(port_idx, ledMode) + DBG_PRINT("update {} led mode from {} to {}".format(portname, saveMode, ledMode)) diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/plugins/psuutil.py b/device/centec/x86_64-centec_v682_48y8c-r0/plugins/psuutil.py new file mode 100644 index 000000000000..9e311d9b4f5a --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/plugins/psuutil.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python + +############################################################################# +# Centec +# +# Module contains an implementation of SONiC PSU Base API and +# provides the PSUs status which are available in the platform +# +############################################################################# + +from subprocess import Popen, PIPE, STDOUT + +try: + from sonic_psu.psu_base import PsuBase +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +class PsuUtil(PsuBase): + """Platform-specific PSUutil class""" + + def __init__(self): + PsuBase.__init__(self) + + def get_num_psus(self): + """ + Retrieves the number of PSUs available on the device + + :return: An integer, the number of PSUs available on the device + """ + return 2 + + def get_psu_status(self, index): + """ + Retrieves the oprational status of power supply unit (PSU) defined + by 1-based index + + :param index: An integer, 1-based index of the PSU of which to query status + :return: Boolean, True if PSU is operating properly, False if PSU is faulty + """ + if index is None: + return False + + cmd = 'i2cget -y 0 0x36 0x1e' + status = int(Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True).stdout.readline(), 16) + powergood = ((status & (1 << (3 * (index - 1) + 2))) != 0) + return powergood + + def get_psu_presence(self, index): + """ + Retrieves the presence status of power supply unit (PSU) defined + by 1-based index + + :param index: An integer, 1-based index of the PSU of which to query status + :return: Boolean, True if PSU is plugged, False if not + """ + if index is None: + return False + + cmd = 'i2cget -y 0 0x36 0x1e' + status = int(Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True).stdout.readline(), 16) + presence = ((status & (1 << (3 * (index - 1) + 1))) == 0) + return presence diff --git a/device/centec/x86_64-centec_v682_48y8c-r0/pmon_daemon_control.json b/device/centec/x86_64-centec_v682_48y8c-r0/pmon_daemon_control.json new file mode 100644 index 000000000000..0db3279e44b0 --- /dev/null +++ b/device/centec/x86_64-centec_v682_48y8c-r0/pmon_daemon_control.json @@ -0,0 +1,3 @@ +{ + +} diff --git a/device/centec/x86_64-centec_v682_48y8c_d-r0/installer.conf b/device/centec/x86_64-centec_v682_48y8c_d-r0/installer.conf index e69de29bb2d1..3b97b7f99da2 100644 --- a/device/centec/x86_64-centec_v682_48y8c_d-r0/installer.conf +++ b/device/centec/x86_64-centec_v682_48y8c_d-r0/installer.conf @@ -0,0 +1 @@ +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="iommu=pt" diff --git a/device/centec/x86_64-centec_v682_48y8c_d-r0/platform_reboot b/device/centec/x86_64-centec_v682_48y8c_d-r0/platform_reboot index 89e521978cba..a1dff65154bf 100755 --- a/device/centec/x86_64-centec_v682_48y8c_d-r0/platform_reboot +++ b/device/centec/x86_64-centec_v682_48y8c_d-r0/platform_reboot @@ -1,9 +1,9 @@ -#!/usr/bin/python2 +#!/usr/bin/env python import os import sys -susi4_lib = '/usr/local/lib/python2.7/dist-packages' +susi4_lib = '/usr/local/lib/python3.9/dist-packages' if not susi4_lib in os.environ.setdefault('LD_LIBRARY_PATH', ''): os.environ['LD_LIBRARY_PATH'] += (':' + susi4_lib) try: diff --git a/device/dell/x86_64-dell_s6000_s1220-r0/platform.json b/device/dell/x86_64-dell_s6000_s1220-r0/platform.json index c64bff2b22e3..283906c407e0 100644 --- a/device/dell/x86_64-dell_s6000_s1220-r0/platform.json +++ b/device/dell/x86_64-dell_s6000_s1220-r0/platform.json @@ -25,6 +25,9 @@ "speed": { "controllable": true, "minimum": 40 + }, + "status_led": { + "available": false } }, { @@ -32,6 +35,9 @@ "speed": { "controllable": true, "minimum": 40 + }, + "status_led": { + "available": false } }, { @@ -39,6 +45,9 @@ "speed": { "controllable": true, "minimum": 40 + }, + "status_led": { + "available": false } }, { @@ -46,6 +55,9 @@ "speed": { "controllable": true, "minimum": 40 + }, + "status_led": { + "available": false } }, { @@ -53,6 +65,9 @@ "speed": { "controllable": true, "minimum": 40 + }, + "status_led": { + "available": false } }, { @@ -60,6 +75,9 @@ "speed": { "controllable": true, "minimum": 40 + }, + "status_led": { + "available": false } } ], @@ -76,6 +94,9 @@ "speed": { "controllable": true, "minimum": 40 + }, + "status_led": { + "available": false } }, { @@ -83,6 +104,9 @@ "speed": { "controllable": true, "minimum": 40 + }, + "status_led": { + "available": false } } ] @@ -99,6 +123,9 @@ "speed": { "controllable": true, "minimum": 40 + }, + "status_led": { + "available": false } }, { @@ -106,6 +133,9 @@ "speed": { "controllable": true, "minimum": 40 + }, + "status_led": { + "available": false } } ] @@ -122,6 +152,9 @@ "speed": { "controllable": true, "minimum": 40 + }, + "status_led": { + "available": false } }, { @@ -129,6 +162,9 @@ "speed": { "controllable": true, "minimum": 40 + }, + "status_led": { + "available": false } } ] @@ -146,17 +182,28 @@ "speed": { "controllable": true, "minimum": 40 + }, + "status_led": { + "available": false } } ], "thermals": [ { "name": "PSU1-Sensor 1", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "PSU1-Sensor 2", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false } ] }, @@ -171,17 +218,28 @@ "speed": { "controllable": true, "minimum": 40 + }, + "status_led": { + "available": false } } ], "thermals": [ { "name": "PSU2-Sensor 1", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "PSU2-Sensor 2", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false } ] } @@ -189,27 +247,51 @@ "thermals": [ { "name": "ASIC On-board", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "NIC", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "System Front", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "DIMM", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "CPU Core 0", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "CPU Core 1", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false } ], "modules": [], diff --git a/device/dell/x86_64-dell_s6100_c2538-r0/platform.json b/device/dell/x86_64-dell_s6100_c2538-r0/platform.json index 51222aa095b8..e9fbeaeff804 100644 --- a/device/dell/x86_64-dell_s6100_c2538-r0/platform.json +++ b/device/dell/x86_64-dell_s6100_c2538-r0/platform.json @@ -5,15 +5,19 @@ "controllable": true, "colors": ["amber", "blinking amber", "green", "blinking green"] }, + "thermal_manager" : false, "components": [ { "name": "BIOS" }, + { + "name": "FPGA" + }, { "name": "CPLD" }, { - "name": "FPGA" + "name": "SSD" } ], "fans": [ @@ -21,24 +25,36 @@ "name": "FanTray1-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray2-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray3-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray4-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } } ], @@ -53,6 +69,9 @@ "name": "FanTray1-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } } ] @@ -67,6 +86,9 @@ "name": "FanTray2-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } } ] @@ -81,6 +103,9 @@ "name": "FanTray3-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } } ] @@ -95,6 +120,9 @@ "name": "FanTray4-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } } ] @@ -111,6 +139,9 @@ "name": "PSU1 Fan", "speed": { "controllable": false + }, + "status_led": { + "available": false } } ] @@ -125,6 +156,9 @@ "name": "PSU2 Fan", "speed": { "controllable": false + }, + "status_led": { + "available": false } } ] @@ -133,43 +167,77 @@ "thermals": [ { "name": "CPU On-board", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "ASIC On-board Front", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "System Front", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "ASIC On-board Rear", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "Front GE board", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "Front SFP+ board", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "CPU Core 0", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "CPU Core 1", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "CPU Core 2", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "CPU Core 3", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false } ], "modules": [ diff --git a/device/dell/x86_64-dellemc_n3248pxe_c3338-r0/installer.conf b/device/dell/x86_64-dellemc_n3248pxe_c3338-r0/installer.conf index 8e3add013c31..26e95228d292 100644 --- a/device/dell/x86_64-dellemc_n3248pxe_c3338-r0/installer.conf +++ b/device/dell/x86_64-dellemc_n3248pxe_c3338-r0/installer.conf @@ -1,3 +1,4 @@ CONSOLE_PORT=0x3f8 CONSOLE_DEV=0 VAR_LOG_SIZE=512 +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off" diff --git a/device/dell/x86_64-dellemc_n3248te_c3338-r0/installer.conf b/device/dell/x86_64-dellemc_n3248te_c3338-r0/installer.conf index 8e3add013c31..26e95228d292 100644 --- a/device/dell/x86_64-dellemc_n3248te_c3338-r0/installer.conf +++ b/device/dell/x86_64-dellemc_n3248te_c3338-r0/installer.conf @@ -1,3 +1,4 @@ CONSOLE_PORT=0x3f8 CONSOLE_DEV=0 VAR_LOG_SIZE=512 +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off" diff --git a/device/dell/x86_64-dellemc_s5212f_c3538-r0/installer.conf b/device/dell/x86_64-dellemc_s5212f_c3538-r0/installer.conf index 925a32fc0c3a..a5d5517008b1 100644 --- a/device/dell/x86_64-dellemc_s5212f_c3538-r0/installer.conf +++ b/device/dell/x86_64-dellemc_s5212f_c3538-r0/installer.conf @@ -1,3 +1,4 @@ CONSOLE_PORT=0x3f8 CONSOLE_DEV=0 CONSOLE_SPEED=115200 +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off" diff --git a/device/dell/x86_64-dellemc_s5224f_c3538-r0/installer.conf b/device/dell/x86_64-dellemc_s5224f_c3538-r0/installer.conf index 924e0fb81963..ff014aa8c25e 100644 --- a/device/dell/x86_64-dellemc_s5224f_c3538-r0/installer.conf +++ b/device/dell/x86_64-dellemc_s5224f_c3538-r0/installer.conf @@ -1,2 +1,3 @@ CONSOLE_PORT=0x3f8 CONSOLE_DEV=0 +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off" diff --git a/device/dell/x86_64-dellemc_s5232f_c3538-r0/installer.conf b/device/dell/x86_64-dellemc_s5232f_c3538-r0/installer.conf index 924e0fb81963..ff014aa8c25e 100644 --- a/device/dell/x86_64-dellemc_s5232f_c3538-r0/installer.conf +++ b/device/dell/x86_64-dellemc_s5232f_c3538-r0/installer.conf @@ -1,2 +1,3 @@ CONSOLE_PORT=0x3f8 CONSOLE_DEV=0 +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off" diff --git a/device/dell/x86_64-dellemc_s5248f_c3538-r0/installer.conf b/device/dell/x86_64-dellemc_s5248f_c3538-r0/installer.conf index 925a32fc0c3a..a5d5517008b1 100644 --- a/device/dell/x86_64-dellemc_s5248f_c3538-r0/installer.conf +++ b/device/dell/x86_64-dellemc_s5248f_c3538-r0/installer.conf @@ -1,3 +1,4 @@ CONSOLE_PORT=0x3f8 CONSOLE_DEV=0 CONSOLE_SPEED=115200 +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off" diff --git a/device/dell/x86_64-dellemc_s5296f_c3538-r0/installer.conf b/device/dell/x86_64-dellemc_s5296f_c3538-r0/installer.conf index 924e0fb81963..ff014aa8c25e 100644 --- a/device/dell/x86_64-dellemc_s5296f_c3538-r0/installer.conf +++ b/device/dell/x86_64-dellemc_s5296f_c3538-r0/installer.conf @@ -1,2 +1,3 @@ CONSOLE_PORT=0x3f8 CONSOLE_DEV=0 +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off" diff --git a/device/dell/x86_64-dellemc_z9264f_c3538-r0/installer.conf b/device/dell/x86_64-dellemc_z9264f_c3538-r0/installer.conf index 924e0fb81963..ff014aa8c25e 100644 --- a/device/dell/x86_64-dellemc_z9264f_c3538-r0/installer.conf +++ b/device/dell/x86_64-dellemc_z9264f_c3538-r0/installer.conf @@ -1,2 +1,3 @@ CONSOLE_PORT=0x3f8 CONSOLE_DEV=0 +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off" diff --git a/device/dell/x86_64-dellemc_z9332f_d1508-r0/platform.json b/device/dell/x86_64-dellemc_z9332f_d1508-r0/platform.json index 5f21372da0e5..98a3322bf334 100644 --- a/device/dell/x86_64-dellemc_z9332f_d1508-r0/platform.json +++ b/device/dell/x86_64-dellemc_z9332f_d1508-r0/platform.json @@ -5,6 +5,7 @@ "controllable": true, "colors": ["green", "flashing green", "yellow", "flashing yellow"] }, + "thermal_manager" : false, "components": [ { "name": "BIOS" @@ -36,84 +37,126 @@ "name": "FanTray1-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray1-Fan2", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray2-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray2-Fan2", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray3-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray3-Fan2", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray4-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray4-Fan2", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray5-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray5-Fan2", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray6-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray6-Fan2", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray7-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray7-Fan2", "speed": { "controllable": false + }, + "status_led": { + "available": false } } ], @@ -128,12 +171,18 @@ "name": "FanTray1-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray1-Fan2", "speed": { "controllable": false + }, + "status_led": { + "available": false } } ] @@ -148,12 +197,18 @@ "name": "FanTray2-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray2-Fan2", "speed": { "controllable": false + }, + "status_led": { + "available": false } } ] @@ -168,12 +223,18 @@ "name": "FanTray3-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray3-Fan2", "speed": { "controllable": false + }, + "status_led": { + "available": false } } ] @@ -188,12 +249,18 @@ "name": "FanTray4-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray4-Fan2", "speed": { "controllable": false + }, + "status_led": { + "available": false } } ] @@ -208,12 +275,18 @@ "name": "FanTray5-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray5-Fan2", "speed": { "controllable": false + }, + "status_led": { + "available": false } } ] @@ -228,12 +301,18 @@ "name": "FanTray6-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray6-Fan2", "speed": { "controllable": false + }, + "status_led": { + "available": false } } ] @@ -248,12 +327,18 @@ "name": "FanTray7-Fan1", "speed": { "controllable": false + }, + "status_led": { + "available": false } }, { "name": "FanTray7-Fan2", "speed": { "controllable": false + }, + "status_led": { + "available": false } } ] @@ -270,6 +355,9 @@ "name": "PSU1 Fan", "speed": { "controllable": false + }, + "status_led": { + "available": false } } ] @@ -284,6 +372,9 @@ "name": "PSU2 Fan", "speed": { "controllable": false + }, + "status_led": { + "available": false } } ] @@ -292,59 +383,122 @@ "thermals": [ { "name": "CPU On-board", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "Baseboard U3", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "SW Internal", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "Fan U52", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "Fan U17", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "SW U52", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "SW U16", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "PSU1 Inlet", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "PSU1 Hotspot", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "PSU2 Inlet", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "PSU2 Hotspot", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "SW U04", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "SW U14", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false }, { "name": "SW U4403", - "controllable": false + "controllable": false, + "low-crit-threshold": false, + "high-threshold": false, + "high-crit-threshold": false, + "minimum-recorded": false, + "maximum-recorded": false } ], "modules": [], diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/platform_reboot b/device/mellanox/x86_64-mlnx_msn2700-r0/platform_reboot index 28c5aedc4e32..7a38268ff09c 100755 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/platform_reboot +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/platform_reboot @@ -3,6 +3,7 @@ declare -r EXIT_SUCCESS="0" declare -r EXIT_ERROR="1" +declare -r PENDING_COMPONENT_FW="/usr/bin/install-pending-fw.py" declare -r FW_UPGRADE_SCRIPT="/usr/bin/mlnx-fw-upgrade.sh" declare -r SYSFS_PWR_CYCLE="/sys/devices/platform/mlxplat/mlxreg-io/hwmon/hwmon*/pwr_cycle" @@ -40,4 +41,6 @@ if [[ "${EXIT_CODE}" != "${EXIT_SUCCESS}" ]]; then fi fi +${PENDING_COMPONENT_FW} + SafePwrCycle diff --git a/device/mellanox/x86_64-mlnx_msn2700_simx-r0/platform.json b/device/mellanox/x86_64-mlnx_msn2700_simx-r0/platform.json new file mode 120000 index 000000000000..e5572096d1a5 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2700_simx-r0/platform.json @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/platform.json \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn3700_simx-r0/platform.json b/device/mellanox/x86_64-mlnx_msn3700_simx-r0/platform.json new file mode 120000 index 000000000000..e32316c3be95 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn3700_simx-r0/platform.json @@ -0,0 +1 @@ +../x86_64-mlnx_msn3700-r0/platform.json \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/buffers_defaults_t0.j2 index fa9a1c4d1049..88a9cc20732e 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/buffers_defaults_t0.j2 @@ -16,7 +16,7 @@ #} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '20664320' %} -{% set ingress_lossless_xoff_size = '3321856' %} +{% set ingress_lossless_pool_xoff = '3321856' %} {% set egress_lossless_pool_size = '34287552' %} {% set egress_lossy_pool_size = '20664320' %} diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/buffers_defaults_t1.j2 index eb2094ddfed6..0e805a09a933 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/buffers_defaults_t1.j2 @@ -16,7 +16,7 @@ #} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '19601408' %} -{% set ingress_lossless_xoff_size = '4384768' %} +{% set ingress_lossless_pool_xoff = '4384768' %} {% set egress_lossless_pool_size = '34287552' %} {% set egress_lossy_pool_size = '19601408' %} diff --git a/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/hwsku.json b/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/hwsku.json index f170ecd32b98..13eceb4baba5 100644 --- a/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/hwsku.json +++ b/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/hwsku.json @@ -1,76 +1,76 @@ { "interfaces": { "Ethernet0": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet8": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet16": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet24": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet32": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet40": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet48": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet56": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet64": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet72": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet80": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet88": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet96": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet104": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet112": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet120": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet128": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet136": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet144": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet152": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet160": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet168": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet176": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet184": { - "default_brkout_mode": "1x100G[50G,40G,25G,10G,1G]" + "default_brkout_mode": "2x100G[50G,40G,25G,10G,1G]" }, "Ethernet192": { "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" diff --git a/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/port_config.ini b/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/port_config.ini index deb97c92170e..a43476ca0cbd 100644 --- a/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/port_config.ini @@ -14,36 +14,60 @@ ## See the License for the specific language governing permissions and ## limitations under the License. ## -# name lanes alias index -Ethernet0 0,1,2,3,4,5,6,7 etp1 1 -Ethernet8 8,9,10,11,12,13,14,15 etp2 2 -Ethernet16 16,17,18,19,20,21,22,23 etp3 3 -Ethernet24 24,25,26,27,28,29,30,31 etp4 4 -Ethernet32 32,33,34,35,36,37,38,39 etp5 5 -Ethernet40 40,41,42,43,44,45,46,47 etp6 6 -Ethernet48 48,49,50,51,52,53,54,55 etp7 7 -Ethernet56 56,57,58,59,60,61,62,63 etp8 8 -Ethernet64 64,65,66,67,68,69,70,71 etp9 9 -Ethernet72 72,73,74,75,76,77,78,79 etp10 10 -Ethernet80 80,81,82,83,84,85,86,87 etp11 11 -Ethernet88 88,89,90,91,92,93,94,95 etp12 12 -Ethernet96 96,97,98,99,100,101,102,103 etp13 13 -Ethernet104 104,105,106,107,108,109,110,111 etp14 14 -Ethernet112 112,113,114,115,116,117,118,119 etp15 15 -Ethernet120 120,121,122,123,124,125,126,127 etp16 16 -Ethernet128 128,129,130,131,132,133,134,135 etp17 17 -Ethernet136 136,137,138,139,140,141,142,143 etp18 18 -Ethernet144 144,145,146,147,148,149,150,151 etp19 19 -Ethernet152 152,153,154,155,156,157,158,159 etp20 20 -Ethernet160 160,161,162,163,164,165,166,167 etp21 21 -Ethernet168 168,169,170,171,172.173,174,175 etp22 22 -Ethernet176 176,177,178,179,180,181,182,183 etp23 23 -Ethernet184 184,185,186,187,188,189,190,191 etp24 24 -Ethernet192 192,193,194,195,196,197,198,199 etp25 25 -Ethernet200 200,201,202,203,204,205,206,207 etp26 26 -Ethernet208 208,209,210,211,212,213,214,215 etp27 27 -Ethernet216 216,217,218,219,220,221,222,223 etp28 28 -Ethernet224 224,225,226,227,228,229,230,231 etp29 29 -Ethernet232 232,233,234,235,236,237,238,239 etp30 30 -Ethernet240 240,241,242,243,244,245,246,247 etp31 31 -Ethernet248 248,249,250,251,252,253,254,255 etp32 32 +# name lanes alias index speed +Ethernet0 0,1,2,3 etp1a 1 100000 +Ethernet4 4,5,6,7 etp1b 1 100000 +Ethernet8 8,9,10,11 etp2a 2 100000 +Ethernet12 12,13,14,15 etp2b 2 100000 +Ethernet16 16,17,18,19 etp3a 3 100000 +Ethernet20 20,21,22,23 etp3b 3 100000 +Ethernet24 24,25,26,27 etp4a 4 100000 +Ethernet28 28,29,30,31 etp4b 4 100000 +Ethernet32 32,33,34,35 etp5a 5 100000 +Ethernet36 36,37,38,39 etp5b 5 100000 +Ethernet40 40,41,42,43 etp6a 6 100000 +Ethernet44 44,45,46,47 etp6b 6 100000 +Ethernet48 48,49,50,51 etp7a 7 100000 +Ethernet52 52,53,54,55 etp7b 7 100000 +Ethernet56 56,57,58,59 etp8a 8 100000 +Ethernet60 60,61,62,63 etp8b 8 100000 +Ethernet64 64,65,66,67 etp9a 9 100000 +Ethernet68 68,69,70,71 etp9b 9 100000 +Ethernet72 72,73,74,75 etp10a 10 100000 +Ethernet76 76,77,78,79 etp10b 10 100000 +Ethernet80 80,81,82,83 etp11a 11 100000 +Ethernet84 84,85,86,87 etp11b 11 100000 +Ethernet88 88,89,90,91 etp12a 12 100000 +Ethernet92 92,93,94,95 etp12b 12 100000 +Ethernet96 96,97,98,99 etp13a 13 100000 +Ethernet100 100,101,102,103 etp13b 13 100000 +Ethernet104 104,105,106,107 etp14a 14 100000 +Ethernet108 108,109,110,111 etp14b 14 100000 +Ethernet112 112,113,114,115 etp15a 15 100000 +Ethernet116 116,117,118,119 etp15b 15 100000 +Ethernet120 120,121,122,123 etp16a 16 100000 +Ethernet124 124,125,126,127 etp16b 16 100000 +Ethernet128 128,129,130,131 etp17a 17 100000 +Ethernet132 132,133,134,135 etp17b 17 100000 +Ethernet136 136,137,138,139 etp18a 18 100000 +Ethernet140 140,141,142,143 etp18b 18 100000 +Ethernet144 144,145,146,147 etp19a 19 100000 +Ethernet148 148,149,150,151 etp19b 19 100000 +Ethernet152 152,153,154,155 etp20a 20 100000 +Ethernet156 156,157,158,159 etp20b 20 100000 +Ethernet160 160,161,162,163 etp21a 21 100000 +Ethernet164 164,165,166,167 etp21b 21 100000 +Ethernet168 168,169,170,171 etp22a 22 100000 +Ethernet172 172,173,174,175 etp22b 22 100000 +Ethernet176 176,177,178,179 etp23a 23 100000 +Ethernet180 180,181,182,183 etp23b 23 100000 +Ethernet184 184,185,186,187 etp24a 24 100000 +Ethernet188 188,189,190,191 etp24b 24 100000 +Ethernet192 192,193,194,195,196,197,198,199 etp25 25 400000 +Ethernet200 200,201,202,203,204,205,206,207 etp26 26 400000 +Ethernet208 208,209,210,211,212,213,214,215 etp27 27 400000 +Ethernet216 216,217,218,219,220,221,222,223 etp28 28 400000 +Ethernet224 224,225,226,227,228,229,230,231 etp29 29 400000 +Ethernet232 232,233,234,235,236,237,238,239 etp30 30 400000 +Ethernet240 240,241,242,243,244,245,246,247 etp31 31 400000 +Ethernet248 248,249,250,251,252,253,254,255 etp32 32 400000 diff --git a/device/mellanox/x86_64-mlnx_msn4410-r0/platform.json b/device/mellanox/x86_64-mlnx_msn4410-r0/platform.json index 80c532b175e4..bf9b9ea30247 100644 --- a/device/mellanox/x86_64-mlnx_msn4410-r0/platform.json +++ b/device/mellanox/x86_64-mlnx_msn4410-r0/platform.json @@ -412,7 +412,7 @@ "lanes": "0,1,2,3,4,5,6,7", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp1"], - "2x100G[50G,25G,10G,1G]": ["etp1a", "etp1b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp1a", "etp1b"], "4x50G[25G,10G,1G]": ["etp1a", "etp1b", "etp1c", "etp1d"] } }, @@ -421,7 +421,7 @@ "lanes": "8,9,10,11,12,13,14,15", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp2"], - "2x100G[50G,25G,10G,1G]": ["etp2a", "etp2b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp2a", "etp2b"], "4x50G[25G,10G,1G]": ["etp2a", "etp2b", "etp2c", "etp2d"] } }, @@ -430,7 +430,7 @@ "lanes": "16,17,18,19,20,21,22,23", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp3"], - "2x100G[50G,25G,10G,1G]": ["etp3a", "etp3b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp3a", "etp3b"], "4x50G[25G,10G,1G]": ["etp3a", "etp3b", "etp3c", "etp3d"] } }, @@ -439,7 +439,7 @@ "lanes": "24,25,26,27,28,29,30,31", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp4"], - "2x100G[50G,25G,10G,1G]": ["etp4a", "etp4b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp4a", "etp4b"], "4x50G[25G,10G,1G]": ["etp4a", "etp4b", "etp4c", "etp4d"] } }, @@ -448,7 +448,7 @@ "lanes": "32,33,34,35,36,37,38,39", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp5"], - "2x100G[50G,25G,10G,1G]": ["etp5a", "etp5b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp5a", "etp5b"], "4x50G[25G,10G,1G]": ["etp5a", "etp5b", "etp5c", "etp5d"] } }, @@ -457,7 +457,7 @@ "lanes": "40,41,42,43,44,45,46,47", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp6"], - "2x100G[50G,25G,10G,1G]": ["etp6a", "etp6b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp6a", "etp6b"], "4x50G[25G,10G,1G]": ["etp6a", "etp6b", "etp6c", "etp6d"] } }, @@ -466,7 +466,7 @@ "lanes": "48,49,50,51,52,53,54,55", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp7"], - "2x100G[50G,25G,10G,1G]": ["etp7a", "etp7b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp7a", "etp7b"], "4x50G[25G,10G,1G]": ["etp7a", "etp7b", "etp7c", "etp7d"] } }, @@ -475,7 +475,7 @@ "lanes": "56,57,58,59,60,61,62,63", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp8"], - "2x100G[50G,25G,10G,1G]": ["etp8a", "etp8b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp8a", "etp8b"], "4x50G[25G,10G,1G]": ["etp8a", "etp8b", "etp8c", "etp8d"] } }, @@ -484,7 +484,7 @@ "lanes": "64,65,66,67,68,69,70,71", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp9"], - "2x100G[50G,25G,10G,1G]": ["etp9a", "etp9b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp9a", "etp9b"], "4x50G[25G,10G,1G]": ["etp9a", "etp9b", "etp9c", "etp9d"] } }, @@ -493,7 +493,7 @@ "lanes": "72,73,74,75,76,77,78,79", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp10"], - "2x100G[50G,25G,10G,1G]": ["etp10a", "etp10b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp10a", "etp10b"], "4x50G[25G,10G,1G]": ["etp10a", "etp10b", "etp10c", "etp10d"] } }, @@ -502,7 +502,7 @@ "lanes": "80,81,82,83,84,85,86,87", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp11"], - "2x100G[50G,25G,10G,1G]": ["etp11a", "etp11b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp11a", "etp11b"], "4x50G[25G,10G,1G]": ["etp11a", "etp11b", "etp11c", "etp11d"] } }, @@ -511,7 +511,7 @@ "lanes": "88,89,90,91,92,93,94,95", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp12"], - "2x100G[50G,25G,10G,1G]": ["etp12a", "etp12b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp12a", "etp12b"], "4x50G[25G,10G,1G]": ["etp12a", "etp12b", "etp12c", "etp12d"] } }, @@ -520,7 +520,7 @@ "lanes": "96,97,98,99,100,101,102,103", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp13"], - "2x100G[50G,25G,10G,1G]": ["etp13a", "etp13b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp13a", "etp13b"], "4x50G[25G,10G,1G]": ["etp13a", "etp13b", "etp13c", "etp13d"] } }, @@ -529,7 +529,7 @@ "lanes": "104,105,106,107,108,109,110,111", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp14"], - "2x100G[50G,25G,10G,1G]": ["etp14a", "etp14b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp14a", "etp14b"], "4x50G[25G,10G,1G]": ["etp14a", "etp14b", "etp14c", "etp14d"] } }, @@ -538,7 +538,7 @@ "lanes": "112,113,114,115,116,117,118,119", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp15"], - "2x100G[50G,25G,10G,1G]": ["etp15a", "etp15b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp15a", "etp15b"], "4x50G[25G,10G,1G]": ["etp15a", "etp15b", "etp15c", "etp15d"] } }, @@ -547,7 +547,7 @@ "lanes": "120,121,122,123,124,125,126,127", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp16"], - "2x100G[50G,25G,10G,1G]": ["etp16a", "etp16b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp16a", "etp16b"], "4x50G[25G,10G,1G]": ["etp16a", "etp16b", "etp16c", "etp16d"] } }, @@ -556,7 +556,7 @@ "lanes": "128,129,130,131,132,133,134,135", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp17"], - "2x100G[50G,25G,10G,1G]": ["etp17a", "etp17b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp17a", "etp17b"], "4x50G[25G,10G,1G]": ["etp17a", "etp17b", "etp17c", "etp17d"] } }, @@ -565,7 +565,7 @@ "lanes": "136,137,138,139,140,141,142,143", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp18"], - "2x100G[50G,25G,10G,1G]": ["etp18a", "etp18b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp18a", "etp18b"], "4x50G[25G,10G,1G]": ["etp18a", "etp18b", "etp18c", "etp18d"] } }, @@ -574,7 +574,7 @@ "lanes": "144,145,146,147,148,149,150,151", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp19"], - "2x100G[50G,25G,10G,1G]": ["etp19a", "etp19b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp19a", "etp19b"], "4x50G[25G,10G,1G]": ["etp19a", "etp19b", "etp19c", "etp19d"] } }, @@ -583,7 +583,7 @@ "lanes": "152,153,154,155,156,157,158,159", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp20"], - "2x100G[50G,25G,10G,1G]": ["etp20a", "etp20b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp20a", "etp20b"], "4x50G[25G,10G,1G]": ["etp20a", "etp20b", "etp20c", "etp20d"] } }, @@ -592,7 +592,7 @@ "lanes": "160,161,162,163,164,165,166,167", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp21"], - "2x100G[50G,25G,10G,1G]": ["etp21a", "etp21b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp21a", "etp21b"], "4x50G[25G,10G,1G]": ["etp21a", "etp21b", "etp21c", "etp21d"] } }, @@ -601,7 +601,7 @@ "lanes": "168,169,170,171,172,173,174,175", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp22"], - "2x100G[50G,25G,10G,1G]": ["etp22a", "etp22b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp22a", "etp22b"], "4x50G[25G,10G,1G]": ["etp22a", "etp22b", "etp22c", "etp22d"] } }, @@ -610,7 +610,7 @@ "lanes": "176,177,178,179,180,181,182,183", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp23"], - "2x100G[50G,25G,10G,1G]": ["etp23a", "etp23b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp23a", "etp23b"], "4x50G[25G,10G,1G]": ["etp23a", "etp23b", "etp23c", "etp23d"] } }, @@ -619,7 +619,7 @@ "lanes": "184,185,186,187,188,189,190,191", "breakout_modes": { "1x100G[50G,40G,25G,10G,1G]": ["etp24"], - "2x100G[50G,25G,10G,1G]": ["etp24a", "etp24b"], + "2x100G[50G,40G,25G,10G,1G]": ["etp24a", "etp24b"], "4x50G[25G,10G,1G]": ["etp24a", "etp24b", "etp24c", "etp24d"] } }, @@ -628,7 +628,7 @@ "lanes": "192,193,194,195,196,197,198,199", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp25"], - "2x200G[100G,50G,25G,10G,1G]": ["etp25a", "etp25b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp25a", "etp25b"], "4x100G[50G,25G,10G,1G]": ["etp25a", "etp25b", "etp25c", "etp25d"] } }, @@ -637,7 +637,7 @@ "lanes": "200,201,202,203,204,205,206,207", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp26"], - "2x200G[100G,50G,25G,10G,1G]": ["etp26a", "etp26b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp26a", "etp26b"], "4x100G[50G,25G,10G,1G]": ["etp26a", "etp26b", "etp26c", "etp26d"] } }, @@ -646,7 +646,7 @@ "lanes": "208,209,210,211,212,213,214,215", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp27"], - "2x200G[100G,50G,25G,10G,1G]": ["etp27a", "etp27b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp27a", "etp27b"], "4x100G[50G,25G,10G,1G]": ["etp27a", "etp27b", "etp27c", "etp27d"] } }, @@ -655,7 +655,7 @@ "lanes": "216,217,218,219,220,221,222,223", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp28"], - "2x200G[100G,50G,25G,10G,1G]": ["etp28a", "etp28b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp28a", "etp28b"], "4x100G[50G,25G,10G,1G]": ["etp28a", "etp28b", "etp28c", "etp28d"] } }, @@ -664,7 +664,7 @@ "lanes": "224,225,226,227,228,229,230,231", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp29"], - "2x200G[100G,50G,25G,10G,1G]": ["etp29a", "etp29b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp29a", "etp29b"], "4x100G[50G,25G,10G,1G]": ["etp29a", "etp29b", "etp29c", "etp29d"] } }, @@ -673,7 +673,7 @@ "lanes": "232,233,234,235,236,237,238,239", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp30"], - "2x200G[100G,50G,25G,10G,1G]": ["etp30a", "etp30b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp30a", "etp30b"], "4x100G[50G,25G,10G,1G]": ["etp30a", "etp30b", "etp30c", "etp30d"] } }, @@ -682,7 +682,7 @@ "lanes": "240,241,242,243,244,245,246,247", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp31"], - "2x200G[100G,50G,25G,10G,1G]": ["etp31a", "etp31b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp31a", "etp31b"], "4x100G[50G,25G,10G,1G]": ["etp31a", "etp31b", "etp31c", "etp31d"] } }, @@ -691,7 +691,7 @@ "lanes": "248,249,250,251,252,253,254,255", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp32"], - "2x200G[100G,50G,25G,10G,1G]": ["etp32a", "etp32b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp32a", "etp32b"], "4x100G[50G,25G,10G,1G]": ["etp32a", "etp32b", "etp32c", "etp32d"] } } diff --git a/device/mellanox/x86_64-mlnx_msn4410-r0/system_health_monitoring_config.json b/device/mellanox/x86_64-mlnx_msn4410-r0/system_health_monitoring_config.json index 98df66c27ca5..27d507cf56e1 120000 --- a/device/mellanox/x86_64-mlnx_msn4410-r0/system_health_monitoring_config.json +++ b/device/mellanox/x86_64-mlnx_msn4410-r0/system_health_monitoring_config.json @@ -1 +1 @@ -../x86_64-mlnx_msn2700-r0/system_health_monitoring_config.json \ No newline at end of file +../x86_64-mlnx_msn4700-r0/system_health_monitoring_config.json \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/system_health_monitoring_config.json b/device/mellanox/x86_64-mlnx_msn4600-r0/system_health_monitoring_config.json index 98df66c27ca5..27d507cf56e1 120000 --- a/device/mellanox/x86_64-mlnx_msn4600-r0/system_health_monitoring_config.json +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/system_health_monitoring_config.json @@ -1 +1 @@ -../x86_64-mlnx_msn2700-r0/system_health_monitoring_config.json \ No newline at end of file +../x86_64-mlnx_msn4700-r0/system_health_monitoring_config.json \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t0.j2 index 75d516771771..a66a404bb2c2 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t0.j2 @@ -16,7 +16,7 @@ #} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '49905664' %} -{% set ingress_lossless_xoff_size = '3702784' %} +{% set ingress_lossless_pool_xoff = '3702784' %} {% set egress_lossless_pool_size = '60817392' %} {% set egress_lossy_pool_size = '49905664' %} diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t1.j2 index bc0f20966944..d77d5cc1f136 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t1.j2 @@ -16,7 +16,7 @@ #} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '48332800' %} -{% set ingress_lossless_xoff_size = '5275648' %} +{% set ingress_lossless_pool_xoff = '5275648' %} {% set egress_lossless_pool_size = '60817392' %} {% set egress_lossy_pool_size = '48332800' %} diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D100C12S2/buffers_default_objects.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D100C12S2/buffers_default_objects.j2 new file mode 120000 index 000000000000..c01aebb7ae12 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D100C12S2/buffers_default_objects.j2 @@ -0,0 +1 @@ +../../x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_objects.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D100C12S2/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D100C12S2/buffers_defaults_t0.j2 index fb4cff886aa8..c4fdce6ef4cf 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D100C12S2/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D100C12S2/buffers_defaults_t0.j2 @@ -17,105 +17,22 @@ {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '44566528' %} -{% set ingress_lossless_xoff_size = '3614720' %} +{% set ingress_lossless_pool_xoff = '3614720' %} {% set egress_lossless_pool_size = '60817392' %} {% set egress_lossy_pool_size = '44566528' %} -{%- macro generate_port_lists(PORT_ALL) %} - {# Generate list of ports #} - {%- for port_idx in range(0, 32) %} - {%- if PORT_ALL.append("Ethernet%d" % (port_idx)) %}{%- endif %} - {%- endfor %} +{%- macro generate_buffer_pool_and_profiles_with_inactive_ports(port_names_inactive) %} +{{ defs.generate_buffer_pool_and_profiles_with_inactive_ports(port_names_inactive) }} {%- endmacro %} -{%- macro generate_buffer_pool_and_profiles() %} - "BUFFER_POOL": { - "ingress_lossless_pool": { - {%- if dynamic_mode is not defined %} - "size": "{{ ingress_lossless_pool_size }}", - "xoff": "{{ ingress_lossless_xoff_size }}", - {%- endif %} - "type": "ingress", - "mode": "dynamic" - }, - "egress_lossless_pool": { - "size": "{{ egress_lossless_pool_size }}", - "type": "egress", - "mode": "dynamic" - }, - "egress_lossy_pool": { - {%- if dynamic_mode is not defined %} - "size": "{{ egress_lossy_pool_size }}", - {%- endif %} - "type": "egress", - "mode": "dynamic" - } - }, - "BUFFER_PROFILE": { - "ingress_lossless_profile": { - "pool":"[BUFFER_POOL|ingress_lossless_pool]", - "size":"0", - "dynamic_th":"7" - }, - "ingress_lossy_profile": { - "pool":"[BUFFER_POOL|ingress_lossless_pool]", - "size":"0", - "dynamic_th":"3" - }, - "egress_lossless_profile": { - "pool":"[BUFFER_POOL|egress_lossless_pool]", - "size":"0", - "dynamic_th":"7" - }, - "egress_lossy_profile": { - "pool":"[BUFFER_POOL|egress_lossy_pool]", - "size":"9216", - "dynamic_th":"7" - }, - "q_lossy_profile": { - "pool":"[BUFFER_POOL|egress_lossy_pool]", - "size":"0", - "dynamic_th":"3" - } - }, +{%- macro generate_profile_lists_with_inactive_ports(port_names_active, port_names_inactive) %} +{{ defs.generate_profile_lists(port_names_active, port_names_inactive) }} {%- endmacro %} -{%- macro generate_profile_lists(port_names) %} - "BUFFER_PORT_INGRESS_PROFILE_LIST": { -{% for port in port_names.split(',') %} - "{{ port }}": { - "profile_list" : "[BUFFER_PROFILE|ingress_lossless_profile]" - }{% if not loop.last %},{% endif %} - -{% endfor %} - }, - "BUFFER_PORT_EGRESS_PROFILE_LIST": { -{% for port in port_names.split(',') %} - "{{ port }}": { - "profile_list" : "[BUFFER_PROFILE|egress_lossless_profile],[BUFFER_PROFILE|egress_lossy_profile]" - }{% if not loop.last %},{% endif %} - -{% endfor %} - } +{%- macro generate_queue_buffers_with_inactive_ports(port_names_active, port_names_inactive) %} +{{ defs.generate_queue_buffers(port_names_active, port_names_inactive) }} {%- endmacro %} -{%- macro generate_queue_buffers(port_names) %} - "BUFFER_QUEUE": { -{% for port in port_names.split(',') %} - "{{ port }}|3-4": { - "profile" : "[BUFFER_PROFILE|egress_lossless_profile]" - }, -{% endfor %} -{% for port in port_names.split(',') %} - "{{ port }}|0-2": { - "profile" : "[BUFFER_PROFILE|q_lossy_profile]" - }, -{% endfor %} -{% for port in port_names.split(',') %} - "{{ port }}|5-6": { - "profile" : "[BUFFER_PROFILE|q_lossy_profile]" - }{% if not loop.last %},{% endif %} - -{% endfor %} - } +{%- macro generate_pg_profiles_with_inactive_ports(port_names_active, port_names_inactive) %} +{{ defs.generate_pg_profiles(port_names_active, port_names_inactive) }} {%- endmacro %} diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D100C12S2/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D100C12S2/buffers_defaults_t1.j2 index f4cd4b4b47d9..278172ce12fd 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D100C12S2/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D100C12S2/buffers_defaults_t1.j2 @@ -17,105 +17,24 @@ {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '43794432' %} -{% set ingress_lossless_xoff_size = '4386816' %} +{% set ingress_lossless_pool_xoff = '4386816' %} {% set egress_lossless_pool_size = '60817392' %} {% set egress_lossy_pool_size = '43794432' %} -{%- macro generate_port_lists(PORT_ALL) %} - {# Generate list of ports #} - {%- for port_idx in range(0, 32) %} - {%- if PORT_ALL.append("Ethernet%d" % (port_idx)) %}{%- endif %} - {%- endfor %} -{%- endmacro %} +{% import 'buffers_defaults_objects.j2' as defs with context %} -{%- macro generate_buffer_pool_and_profiles() %} - "BUFFER_POOL": { - "ingress_lossless_pool": { - {%- if dynamic_mode is not defined %} - "size": "{{ ingress_lossless_pool_size }}", - "xoff": "{{ ingress_lossless_xoff_size }}", - {%- endif %} - "type": "ingress", - "mode": "dynamic" - }, - "egress_lossless_pool": { - "size": "{{ egress_lossless_pool_size }}", - "type": "egress", - "mode": "dynamic" - }, - "egress_lossy_pool": { - {%- if dynamic_mode is not defined %} - "size": "{{ egress_lossy_pool_size }}", - {%- endif %} - "type": "egress", - "mode": "dynamic" - } - }, - "BUFFER_PROFILE": { - "ingress_lossless_profile": { - "pool":"[BUFFER_POOL|ingress_lossless_pool]", - "size":"0", - "dynamic_th":"7" - }, - "ingress_lossy_profile": { - "pool":"[BUFFER_POOL|ingress_lossless_pool]", - "size":"0", - "dynamic_th":"3" - }, - "egress_lossless_profile": { - "pool":"[BUFFER_POOL|egress_lossless_pool]", - "size":"0", - "dynamic_th":"7" - }, - "egress_lossy_profile": { - "pool":"[BUFFER_POOL|egress_lossy_pool]", - "size":"9216", - "dynamic_th":"7" - }, - "q_lossy_profile": { - "pool":"[BUFFER_POOL|egress_lossy_pool]", - "size":"0", - "dynamic_th":"3" - } - }, +{%- macro generate_buffer_pool_and_profiles_with_inactive_ports(port_names_inactive) %} +{{ defs.generate_buffer_pool_and_profiles_with_inactive_ports(port_names_inactive) }} {%- endmacro %} -{%- macro generate_profile_lists(port_names) %} - "BUFFER_PORT_INGRESS_PROFILE_LIST": { -{% for port in port_names.split(',') %} - "{{ port }}": { - "profile_list" : "[BUFFER_PROFILE|ingress_lossless_profile]" - }{% if not loop.last %},{% endif %} - -{% endfor %} - }, - "BUFFER_PORT_EGRESS_PROFILE_LIST": { -{% for port in port_names.split(',') %} - "{{ port }}": { - "profile_list" : "[BUFFER_PROFILE|egress_lossless_profile],[BUFFER_PROFILE|egress_lossy_profile]" - }{% if not loop.last %},{% endif %} - -{% endfor %} - } +{%- macro generate_profile_lists_with_inactive_ports(port_names_active, port_names_inactive) %} +{{ defs.generate_profile_lists(port_names_active, port_names_inactive) }} {%- endmacro %} -{%- macro generate_queue_buffers(port_names) %} - "BUFFER_QUEUE": { -{% for port in port_names.split(',') %} - "{{ port }}|3-4": { - "profile" : "[BUFFER_PROFILE|egress_lossless_profile]" - }, -{% endfor %} -{% for port in port_names.split(',') %} - "{{ port }}|0-2": { - "profile" : "[BUFFER_PROFILE|q_lossy_profile]" - }, -{% endfor %} -{% for port in port_names.split(',') %} - "{{ port }}|5-6": { - "profile" : "[BUFFER_PROFILE|q_lossy_profile]" - }{% if not loop.last %},{% endif %} +{%- macro generate_queue_buffers_with_inactive_ports(port_names_active, port_names_inactive) %} +{{ defs.generate_queue_buffers(port_names_active, port_names_inactive) }} +{%- endmacro %} -{% endfor %} - } +{%- macro generate_pg_profiles_with_inactive_ports(port_names_active, port_names_inactive) %} +{{ defs.generate_pg_profiles(port_names_active, port_names_inactive) }} {%- endmacro %} diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/buffers_defaults_t0.j2 index 16d56b62cd5f..eede5087d0f6 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/buffers_defaults_t0.j2 @@ -16,7 +16,7 @@ #} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '43827200' %} -{% set ingress_lossless_xoff_size = '3702784' %} +{% set ingress_lossless_pool_xoff = '3702784' %} {% set egress_lossless_pool_size = '60817392' %} {% set egress_lossy_pool_size = '43827200' %} diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/buffers_defaults_t1.j2 index 34faa886e253..317d1a56994f 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/buffers_defaults_t1.j2 @@ -16,7 +16,7 @@ #} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '43048960' %} -{% set ingress_lossless_xoff_size = '4481024' %} +{% set ingress_lossless_pool_xoff = '4481024' %} {% set egress_lossless_pool_size = '60817392' %} {% set egress_lossy_pool_size = '43048960' %} diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t0.j2 index 09138bb9bf7f..87d8bda4c55f 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t0.j2 @@ -16,7 +16,7 @@ #} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '47398912' %} -{% set ingress_lossless_xoff_size = '3604480' %} +{% set ingress_lossless_pool_xoff = '3604480' %} {% set egress_lossless_pool_size = '60817392' %} {% set egress_lossy_pool_size = '47398912' %} diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t1.j2 index ea9038f3ea5e..6cf1904e30c7 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t1.j2 @@ -16,7 +16,7 @@ #} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '46587904' %} -{% set ingress_lossless_xoff_size = '4415488' %} +{% set ingress_lossless_pool_xoff = '4415488' %} {% set egress_lossless_pool_size = '60817392' %} {% set egress_lossy_pool_size = '46587904' %} diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/get_sensors_conf_path b/device/mellanox/x86_64-mlnx_msn4600c-r0/get_sensors_conf_path new file mode 120000 index 000000000000..f1509a1e1d3d --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/get_sensors_conf_path @@ -0,0 +1 @@ +../x86_64-mlnx_msn4700-r0/get_sensors_conf_path \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/sensors.conf.a1 b/device/mellanox/x86_64-mlnx_msn4600c-r0/sensors.conf.a1 new file mode 100644 index 000000000000..44fff272e544 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/sensors.conf.a1 @@ -0,0 +1,146 @@ +## +## Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## + + +# Temperature sensors +bus "i2c-2" "i2c-1-mux (chan_id 1)" + chip "mlxsw-i2c-*-48" + label temp1 "Ambient ASIC Temp" + +bus "i2c-7" "i2c-1-mux (chan_id 6)" + chip "tmp102-i2c-*-49" + label temp1 "Ambient Fan Side Temp (air intake)" + chip "tmp102-i2c-*-4a" + label temp1 "Ambient Port Side Temp (air exhaust)" + +bus "i2c-15" "i2c-1-mux (chan_id 6)" + chip "tmp102-i2c-15-49" + label temp1 "Ambient COMEX Temp" + +# Power controllers +bus "i2c-5" "i2c-1-mux (chan_id 4)" + chip "mp2975-i2c-*-62" + label in1 "PMIC-1 PSU 12V Rail (in1)" + label in2 "PMIC-1 ASIC 0.8V VCORE MAIN Rail (out)" + label temp1 "PMIC-1 Temp 1" + label power1 "PMIC-1 PSU 12V Rail Pwr (in1)" + label power2 "PMIC-1 ASIC 0.8V VCORE MAIN Rail Pwr (out)" + label curr1 "PMIC-1 PSU 12V Rail Curr (in1)" + label curr2 "PMIC-1 ASIC 0.8V VCORE MAIN Rail Curr (out)" + chip "mp2975-i2c-*-64" + label in1 "PMIC-2 PSU 12V Rail (in1)" + label in2 "PMIC-2 ASIC 1.8V VCORE MAIN Rail (out)" + label in3 "PMIC-2 ASIC 1.2V VCORE MAIN Rail (out)" + label temp1 "PMIC-2 Temp 1" + label power1 "PMIC-2 PSU 12V Rail Pwr (in1)" + label power2 "PMIC-2 ASIC 1.8V VCORE MAIN Rail Pwr (out)" + label curr1 "PMIC-2 PSU 12V Rail Curr (in1)" + label curr2 "PMIC-2 ASIC 1.8V VCORE MAIN Rail Curr (out)" + label curr3 "PMIC-2 ASIC 1.2V VCORE MAIN Rail Curr (out)" + chip "mp2975-i2c-*-66" + label in1 "PMIC-3 PSU 12V Rail (in1)" + label in2 "PMIC-3 ASIC 0.85V T0_1 Rail (out)" + label in3 "PMIC-3 ASIC 1.8V T0_1 Rail (out)" + label temp1 "PMIC-3 Temp 1" + label power1 "PMIC-3 PSU 12V Rail Pwr (in1)" + label power2 "PMIC-3 ASIC 0.85V T0_1 Rail Pwr (out)" + label curr1 "PMIC-3 PSU 12V Rail Curr (in1)" + label curr2 "PMIC-3 ASIC 0.85V T0_1 Rail Curr (out)" + label curr3 "PMIC-3 ASIC 1.8V T0_1 Rail Curr (out)" + chip "mp2975-i2c-*-6a" + label in1 "PMIC-4 PSU 12V Rail (in1)" + label in2 "PMIC-4 ASIC 0.85V T2_3 Rail (out)" + label in3 "PMIC-4 ASIC 1.8V T2_3 Rail (out)" + label temp1 "PMIC-4 Temp 1" + label power1 "PMIC-4 PSU 12V Rail Pwr (in1)" + label power2 "PMIC-4 ASIC 0.85V T2_3 Rail Pwr (out)" + label curr1 "PMIC-4 PSU 12V Rail Curr (in1)" + label curr2 "PMIC-4 ASIC 0.85V T2_3 Rail Curr (out)" + label curr3 "PMIC-4 ASIC 1.8V T2_3 Rail Curr (out)" + chip "mp2975-i2c-*-6e" + label in1 "PMIC-5 PSU 12V Rail (in1)" + label in2 "PMIC-5 ASIC 1.2V T0_3 Rail_1 (out)" + label in3 "PMIC-5 ASIC 1.2V T4_7 Rail_2 (out)" + label temp1 "PMIC-5 Temp 1" + label power1 "PMIC-5 PSU 12V Rail Pwr (in1)" + label power2 "PMIC-5 ASIC 1.2V T0_3 Rail_1 Pwr (out)" + label power3 "PMIC-5 ASIC 1.2V T4_7 Rail_2 Pwr (out)" + label curr1 "PMIC-5 PSU 12V Rail Curr (in1)" + label curr2 "PMIC-5 ASIC 1.2V T0_3 Rail_1 Curr (out)" + label curr3 "PMIC-5 ASIC 1.2V T4_7 Rail_2 Curr (out)" + +bus "i2c-15" "i2c-1-mux (chan_id 6)" + chip "tps53679-i2c-*-58" + label in1 "PMIC-6 PSU 12V Rail (in1)" + label in2 "PMIC-6 PSU 12V Rail (in2)" + label in3 "PMIC-6 COMEX 1.8V Rail (out)" + label in4 "PMIC-6 COMEX 1.05V Rail (out)" + label temp1 "PMIC-6 Temp 1" + label temp2 "PMIC-6 Temp 2" + label power1 "PMIC-6 COMEX 1.8V Rail Pwr (out)" + label power2 "PMIC-6 COMEX 1.05V Rail Pwr (out)" + label curr1 "PMIC-6 COMEX 1.8V Rail Curr (out)" + label curr2 "PMIC-6 COMEX 1.05V Rail Curr (out)" + chip "tps53679-i2c-*-61" + label in1 "PMIC-7 PSU 12V Rail (in1)" + label in2 "PMIC-7 PSU 12V Rail (in2)" + label in3 "PMIC-7 COMEX 1.2V Rail (out)" + ignore in4 + label temp1 "PMIC-7 Temp 1" + label temp2 "PMIC-7 Temp 2" + label power1 "PMIC-7 COMEX 1.2V Rail Pwr (out)" + ignore power2 + label curr1 "PMIC-7 COMEX 1.2V Rail Curr (out)" + ignore curr2 + +# Power supplies +bus "i2c-4" "i2c-1-mux (chan_id 3)" + chip "dps460-i2c-*-58" + label in1 "PSU-1(L) 220V Rail (in)" + ignore in2 + label in3 "PSU-1(L) 12V Rail (out)" + label fan1 "PSU-1(L) Fan 1" + ignore fan2 + ignore fan3 + label temp1 "PSU-1(L) Temp 1" + label temp2 "PSU-1(L) Temp 2" + label temp3 "PSU-1(L) Temp 3" + label power1 "PSU-1(L) 220V Rail Pwr (in)" + label power2 "PSU-1(L) 12V Rail Pwr (out)" + label curr1 "PSU-1(L) 220V Rail Curr (in)" + label curr2 "PSU-1(L) 12V Rail Curr (out)" + chip "dps460-i2c-*-59" + label in1 "PSU-2(R) 220V Rail (in)" + ignore in2 + label in3 "PSU-2(R) 12V Rail (out)" + label fan1 "PSU-2(R) Fan 1" + ignore fan2 + ignore fan3 + label temp1 "PSU-2(R) Temp 1" + label temp2 "PSU-2(R) Temp 2" + label temp3 "PSU-2(R) Temp 3" + label power1 "PSU-2(R) 220V Rail Pwr (in)" + label power2 "PSU-2(R) 12V Rail Pwr (out)" + label curr1 "PSU-2(R) 220V Rail Curr (in)" + label curr2 "PSU-2(R) 12V Rail Curr (out)" + +# Chassis fans +chip "mlxreg_fan-isa-*" + label fan1 "Chassis Fan Drawer-1" + label fan2 "Chassis Fan Drawer-2" + label fan3 "Chassis Fan Drawer-3" + diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/platform.json b/device/mellanox/x86_64-mlnx_msn4700-r0/platform.json index 88b5045afadc..58fd5d08c6e1 100644 --- a/device/mellanox/x86_64-mlnx_msn4700-r0/platform.json +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/platform.json @@ -412,7 +412,7 @@ "lanes": "0,1,2,3,4,5,6,7", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp1"], - "2x200G[100G,50G,25G,10G,1G]": ["etp1a", "etp1b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp1a", "etp1b"], "4x100G[50G,25G,10G,1G]": ["etp1a", "etp1b", "etp1c", "etp1d"] } }, @@ -421,7 +421,7 @@ "lanes": "8,9,10,11,12,13,14,15", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp2"], - "2x200G[100G,50G,25G,10G,1G]": ["etp2a", "etp2b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp2a", "etp2b"], "4x100G[50G,25G,10G,1G]": ["etp2a", "etp2b", "etp2c", "etp2d"] } }, @@ -430,7 +430,7 @@ "lanes": "16,17,18,19,20,21,22,23", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp3"], - "2x200G[100G,50G,25G,10G,1G]": ["etp3a", "etp3b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp3a", "etp3b"], "4x100G[50G,25G,10G,1G]": ["etp3a", "etp3b", "etp3c", "etp3d"] } }, @@ -439,7 +439,7 @@ "lanes": "24,25,26,27,28,29,30,31", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp4"], - "2x200G[100G,50G,25G,10G,1G]": ["etp4a", "etp4b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp4a", "etp4b"], "4x100G[50G,25G,10G,1G]": ["etp4a", "etp4b", "etp4c", "etp4d"] } }, @@ -448,7 +448,7 @@ "lanes": "32,33,34,35,36,37,38,39", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp5"], - "2x200G[100G,50G,25G,10G,1G]": ["etp5a", "etp5b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp5a", "etp5b"], "4x100G[50G,25G,10G,1G]": ["etp5a", "etp5b", "etp5c", "etp5d"] } }, @@ -457,7 +457,7 @@ "lanes": "40,41,42,43,44,45,46,47", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp6"], - "2x200G[100G,50G,25G,10G,1G]": ["etp6a", "etp6b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp6a", "etp6b"], "4x100G[50G,25G,10G,1G]": ["etp6a", "etp6b", "etp6c", "etp6d"] } }, @@ -466,7 +466,7 @@ "lanes": "48,49,50,51,52,53,54,55", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp7"], - "2x200G[100G,50G,25G,10G,1G]": ["etp7a", "etp7b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp7a", "etp7b"], "4x100G[50G,25G,10G,1G]": ["etp7a", "etp7b", "etp7c", "etp7d"] } }, @@ -475,7 +475,7 @@ "lanes": "56,57,58,59,60,61,62,63", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp8"], - "2x200G[100G,50G,25G,10G,1G]": ["etp8a", "etp8b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp8a", "etp8b"], "4x100G[50G,25G,10G,1G]": ["etp8a", "etp8b", "etp8c", "etp8d"] } }, @@ -484,7 +484,7 @@ "lanes": "64,65,66,67,68,69,70,71", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp9"], - "2x200G[100G,50G,25G,10G,1G]": ["etp9a", "etp9b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp9a", "etp9b"], "4x100G[50G,25G,10G,1G]": ["etp9a", "etp9b", "etp9c", "etp9d"] } }, @@ -493,7 +493,7 @@ "lanes": "72,73,74,75,76,77,78,79", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp10"], - "2x200G[100G,50G,25G,10G,1G]": ["etp10a", "etp10b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp10a", "etp10b"], "4x100G[50G,25G,10G,1G]": ["etp10a", "etp10b", "etp10c", "etp10d"] } }, @@ -502,7 +502,7 @@ "lanes": "80,81,82,83,84,85,86,87", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp11"], - "2x200G[100G,50G,25G,10G,1G]": ["etp11a", "etp11b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp11a", "etp11b"], "4x100G[50G,25G,10G,1G]": ["etp11a", "etp11b", "etp11c", "etp11d"] } }, @@ -511,7 +511,7 @@ "lanes": "88,89,90,91,92,93,94,95", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp12"], - "2x200G[100G,50G,25G,10G,1G]": ["etp12a", "etp12b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp12a", "etp12b"], "4x100G[50G,25G,10G,1G]": ["etp12a", "etp12b", "etp12c", "etp12d"] } }, @@ -520,7 +520,7 @@ "lanes": "96,97,98,99,100,101,102,103", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp13"], - "2x200G[100G,50G,25G,10G,1G]": ["etp13a", "etp13b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp13a", "etp13b"], "4x100G[50G,25G,10G,1G]": ["etp13a", "etp13b", "etp13c", "etp13d"] } }, @@ -529,7 +529,7 @@ "lanes": "104,105,106,107,108,109,110,111", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp14"], - "2x200G[100G,50G,25G,10G,1G]": ["etp14a", "etp14b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp14a", "etp14b"], "4x100G[50G,25G,10G,1G]": ["etp14a", "etp14b", "etp14c", "etp14d"] } }, @@ -538,7 +538,7 @@ "lanes": "112,113,114,115,116,117,118,119", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp15"], - "2x200G[100G,50G,25G,10G,1G]": ["etp15a", "etp15b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp15a", "etp15b"], "4x100G[50G,25G,10G,1G]": ["etp15a", "etp15b", "etp15c", "etp15d"] } }, @@ -547,7 +547,7 @@ "lanes": "120,121,122,123,124,125,126,127", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp16"], - "2x200G[100G,50G,25G,10G,1G]": ["etp16a", "etp16b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp16a", "etp16b"], "4x100G[50G,25G,10G,1G]": ["etp16a", "etp16b", "etp16c", "etp16d"] } }, @@ -556,7 +556,7 @@ "lanes": "128,129,130,131,132,133,134,135", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp17"], - "2x200G[100G,50G,25G,10G,1G]": ["etp17a", "etp17b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp17a", "etp17b"], "4x100G[50G,25G,10G,1G]": ["etp17a", "etp17b", "etp17c", "etp17d"] } }, @@ -565,7 +565,7 @@ "lanes": "136,137,138,139,140,141,142,143", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp18"], - "2x200G[100G,50G,25G,10G,1G]": ["etp18a", "etp18b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp18a", "etp18b"], "4x100G[50G,25G,10G,1G]": ["etp18a", "etp18b", "etp18c", "etp18d"] } }, @@ -574,7 +574,7 @@ "lanes": "144,145,146,147,148,149,150,151", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp19"], - "2x200G[100G,50G,25G,10G,1G]": ["etp19a", "etp19b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp19a", "etp19b"], "4x100G[50G,25G,10G,1G]": ["etp19a", "etp19b", "etp19c", "etp19d"] } }, @@ -583,7 +583,7 @@ "lanes": "152,153,154,155,156,157,158,159", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp20"], - "2x200G[100G,50G,25G,10G,1G]": ["etp20a", "etp20b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp20a", "etp20b"], "4x100G[50G,25G,10G,1G]": ["etp20a", "etp20b", "etp20c", "etp20d"] } }, @@ -592,7 +592,7 @@ "lanes": "160,161,162,163,164,165,166,167", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp21"], - "2x200G[100G,50G,25G,10G,1G]": ["etp21a", "etp21b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp21a", "etp21b"], "4x100G[50G,25G,10G,1G]": ["etp21a", "etp21b", "etp21c", "etp21d"] } }, @@ -601,7 +601,7 @@ "lanes": "168,169,170,171,172,173,174,175", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp22"], - "2x200G[100G,50G,25G,10G,1G]": ["etp22a", "etp22b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp22a", "etp22b"], "4x100G[50G,25G,10G,1G]": ["etp22a", "etp22b", "etp22c", "etp22d"] } }, @@ -610,7 +610,7 @@ "lanes": "176,177,178,179,180,181,182,183", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp23"], - "2x200G[100G,50G,25G,10G,1G]": ["etp23a", "etp23b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp23a", "etp23b"], "4x100G[50G,25G,10G,1G]": ["etp23a", "etp23b", "etp23c", "etp23d"] } }, @@ -619,7 +619,7 @@ "lanes": "184,185,186,187,188,189,190,191", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp24"], - "2x200G[100G,50G,25G,10G,1G]": ["etp24a", "etp24b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp24a", "etp24b"], "4x100G[50G,25G,10G,1G]": ["etp24a", "etp24b", "etp24c", "etp24d"] } }, @@ -628,7 +628,7 @@ "lanes": "192,193,194,195,196,197,198,199", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp25"], - "2x200G[100G,50G,25G,10G,1G]": ["etp25a", "etp25b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp25a", "etp25b"], "4x100G[50G,25G,10G,1G]": ["etp25a", "etp25b", "etp25c", "etp25d"] } }, @@ -637,7 +637,7 @@ "lanes": "200,201,202,203,204,205,206,207", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp26"], - "2x200G[100G,50G,25G,10G,1G]": ["etp26a", "etp26b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp26a", "etp26b"], "4x100G[50G,25G,10G,1G]": ["etp26a", "etp26b", "etp26c", "etp26d"] } }, @@ -646,7 +646,7 @@ "lanes": "208,209,210,211,212,213,214,215", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp27"], - "2x200G[100G,50G,25G,10G,1G]": ["etp27a", "etp27b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp27a", "etp27b"], "4x100G[50G,25G,10G,1G]": ["etp27a", "etp27b", "etp27c", "etp27d"] } }, @@ -655,7 +655,7 @@ "lanes": "216,217,218,219,220,221,222,223", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp28"], - "2x200G[100G,50G,25G,10G,1G]": ["etp28a", "etp28b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp28a", "etp28b"], "4x100G[50G,25G,10G,1G]": ["etp28a", "etp28b", "etp28c", "etp28d"] } }, @@ -664,7 +664,7 @@ "lanes": "224,225,226,227,228,229,230,231", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp29"], - "2x200G[100G,50G,25G,10G,1G]": ["etp29a", "etp29b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp29a", "etp29b"], "4x100G[50G,25G,10G,1G]": ["etp29a", "etp29b", "etp29c", "etp29d"] } }, @@ -673,7 +673,7 @@ "lanes": "232,233,234,235,236,237,238,239", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp30"], - "2x200G[100G,50G,25G,10G,1G]": ["etp30a", "etp30b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp30a", "etp30b"], "4x100G[50G,25G,10G,1G]": ["etp30a", "etp30b", "etp30c", "etp30d"] } }, @@ -682,7 +682,7 @@ "lanes": "240,241,242,243,244,245,246,247", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp31"], - "2x200G[100G,50G,25G,10G,1G]": ["etp31a", "etp31b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp31a", "etp31b"], "4x100G[50G,25G,10G,1G]": ["etp31a", "etp31b", "etp31c", "etp31d"] } }, @@ -691,7 +691,7 @@ "lanes": "248,249,250,251,252,253,254,255", "breakout_modes": { "1x400G[200G,100G,50G,40G,25G,10G,1G]": ["etp32"], - "2x200G[100G,50G,25G,10G,1G]": ["etp32a", "etp32b"], + "2x200G[100G,50G,40G,25G,10G,1G]": ["etp32a", "etp32b"], "4x100G[50G,25G,10G,1G]": ["etp32a", "etp32b", "etp32c", "etp32d"] } } diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/system_health_monitoring_config.json b/device/mellanox/x86_64-mlnx_msn4700-r0/system_health_monitoring_config.json deleted file mode 120000 index 98df66c27ca5..000000000000 --- a/device/mellanox/x86_64-mlnx_msn4700-r0/system_health_monitoring_config.json +++ /dev/null @@ -1 +0,0 @@ -../x86_64-mlnx_msn2700-r0/system_health_monitoring_config.json \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/system_health_monitoring_config.json b/device/mellanox/x86_64-mlnx_msn4700-r0/system_health_monitoring_config.json new file mode 100644 index 000000000000..6a5d7d19e9b4 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/system_health_monitoring_config.json @@ -0,0 +1,11 @@ +{ + "services_to_ignore": [], + "devices_to_ignore": [], + "user_defined_checkers": [], + "polling_interval": 60, + "led_color": { + "fault": "orange", + "normal": "green", + "booting": "orange_blink" + } +} diff --git a/device/mellanox/x86_64-mlnx_msn4700_simx-r0/platform.json b/device/mellanox/x86_64-mlnx_msn4700_simx-r0/platform.json new file mode 120000 index 000000000000..ae928545f4ba --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4700_simx-r0/platform.json @@ -0,0 +1 @@ +../x86_64-mlnx_msn4700-r0/platform.json \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/default_sku b/device/mellanox/x86_64-mlnx_msn4800-r0/default_sku deleted file mode 100644 index f50c8b52baa3..000000000000 --- a/device/mellanox/x86_64-mlnx_msn4800-r0/default_sku +++ /dev/null @@ -1 +0,0 @@ -ACS-MSN4800 t1 diff --git a/device/mellanox/x86_64-mlnx_msn4800_simx-r0/ACS-MSN4800 b/device/mellanox/x86_64-mlnx_msn4800_simx-r0/ACS-MSN4800 deleted file mode 120000 index c91b607a31cc..000000000000 --- a/device/mellanox/x86_64-mlnx_msn4800_simx-r0/ACS-MSN4800 +++ /dev/null @@ -1 +0,0 @@ -../x86_64-mlnx_msn4800-r0/ACS-MSN4800/ \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4800_simx-r0/default_sku b/device/mellanox/x86_64-mlnx_msn4800_simx-r0/default_sku deleted file mode 120000 index a81dbe5c2475..000000000000 --- a/device/mellanox/x86_64-mlnx_msn4800_simx-r0/default_sku +++ /dev/null @@ -1 +0,0 @@ -../x86_64-mlnx_msn4800-r0/default_sku \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4800_simx-r0/plugins b/device/mellanox/x86_64-mlnx_msn4800_simx-r0/plugins deleted file mode 120000 index 92912a201dd1..000000000000 --- a/device/mellanox/x86_64-mlnx_msn4800_simx-r0/plugins +++ /dev/null @@ -1 +0,0 @@ -../x86_64-mlnx_msn4800-r0/plugins/ \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/buffers.json.j2 b/device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/buffers.json.j2 similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/buffers.json.j2 rename to device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/buffers.json.j2 diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/buffers_defaults_objects.j2 b/device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/buffers_defaults_objects.j2 similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/buffers_defaults_objects.j2 rename to device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/buffers_defaults_objects.j2 diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/buffers_defaults_t0.j2 b/device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/buffers_defaults_t0.j2 similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/buffers_defaults_t0.j2 rename to device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/buffers_defaults_t0.j2 diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/buffers_defaults_t1.j2 b/device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/buffers_defaults_t1.j2 similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/buffers_defaults_t1.j2 rename to device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/buffers_defaults_t1.j2 diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/buffers_dynamic.json.j2 b/device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/buffers_dynamic.json.j2 similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/buffers_dynamic.json.j2 rename to device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/buffers_dynamic.json.j2 diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/hwsku.json b/device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/hwsku.json similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/hwsku.json rename to device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/hwsku.json diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/pg_profile_lookup.ini b/device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/pg_profile_lookup.ini similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/pg_profile_lookup.ini rename to device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/pg_profile_lookup.ini diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/port_config.ini b/device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/port_config.ini similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/port_config.ini rename to device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/port_config.ini diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/qos.json.j2 b/device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/qos.json.j2 similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/qos.json.j2 rename to device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/qos.json.j2 diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/sai.profile b/device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/sai.profile similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/sai.profile rename to device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/sai.profile diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/sai_4800.xml b/device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/sai_4800.xml similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/sai_4800.xml rename to device/mellanox/x86_64-nvidia_sn4800-r0/ACS-SN4800/sai_4800.xml diff --git a/device/mellanox/x86_64-nvidia_sn4800-r0/default_sku b/device/mellanox/x86_64-nvidia_sn4800-r0/default_sku new file mode 100644 index 000000000000..50dfa0dc6ddf --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn4800-r0/default_sku @@ -0,0 +1 @@ +ACS-SN4800 t1 diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/pcie.yaml b/device/mellanox/x86_64-nvidia_sn4800-r0/pcie.yaml similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/pcie.yaml rename to device/mellanox/x86_64-nvidia_sn4800-r0/pcie.yaml diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/platform.json b/device/mellanox/x86_64-nvidia_sn4800-r0/platform.json similarity index 99% rename from device/mellanox/x86_64-mlnx_msn4800-r0/platform.json rename to device/mellanox/x86_64-nvidia_sn4800-r0/platform.json index 2b75ae2ab775..69dc1afcf386 100644 --- a/device/mellanox/x86_64-mlnx_msn4800-r0/platform.json +++ b/device/mellanox/x86_64-nvidia_sn4800-r0/platform.json @@ -1,6 +1,6 @@ { "chassis": { - "name": "MSN4800", + "name": "SN4800", "components": [ { "name": "ONIE" diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/platform_asic b/device/mellanox/x86_64-nvidia_sn4800-r0/platform_asic similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/platform_asic rename to device/mellanox/x86_64-nvidia_sn4800-r0/platform_asic diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/platform_components.json b/device/mellanox/x86_64-nvidia_sn4800-r0/platform_components.json similarity index 92% rename from device/mellanox/x86_64-mlnx_msn4800-r0/platform_components.json rename to device/mellanox/x86_64-nvidia_sn4800-r0/platform_components.json index cdd08c656105..80736e44e317 100644 --- a/device/mellanox/x86_64-mlnx_msn4800-r0/platform_components.json +++ b/device/mellanox/x86_64-nvidia_sn4800-r0/platform_components.json @@ -1,6 +1,6 @@ { "chassis": { - "MSN4800": { + "SN4800": { "component": { "ONIE": { }, "SSD": { }, diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/platform_reboot b/device/mellanox/x86_64-nvidia_sn4800-r0/platform_reboot similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/platform_reboot rename to device/mellanox/x86_64-nvidia_sn4800-r0/platform_reboot diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/platform_wait b/device/mellanox/x86_64-nvidia_sn4800-r0/platform_wait similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/platform_wait rename to device/mellanox/x86_64-nvidia_sn4800-r0/platform_wait diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/plugins/eeprom.py b/device/mellanox/x86_64-nvidia_sn4800-r0/plugins/eeprom.py similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/plugins/eeprom.py rename to device/mellanox/x86_64-nvidia_sn4800-r0/plugins/eeprom.py diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/plugins/psuutil.py b/device/mellanox/x86_64-nvidia_sn4800-r0/plugins/psuutil.py similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/plugins/psuutil.py rename to device/mellanox/x86_64-nvidia_sn4800-r0/plugins/psuutil.py diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/plugins/sfplpmget.py b/device/mellanox/x86_64-nvidia_sn4800-r0/plugins/sfplpmget.py similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/plugins/sfplpmget.py rename to device/mellanox/x86_64-nvidia_sn4800-r0/plugins/sfplpmget.py diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/plugins/sfplpmset.py b/device/mellanox/x86_64-nvidia_sn4800-r0/plugins/sfplpmset.py similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/plugins/sfplpmset.py rename to device/mellanox/x86_64-nvidia_sn4800-r0/plugins/sfplpmset.py diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/plugins/sfpreset.py b/device/mellanox/x86_64-nvidia_sn4800-r0/plugins/sfpreset.py similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/plugins/sfpreset.py rename to device/mellanox/x86_64-nvidia_sn4800-r0/plugins/sfpreset.py diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/plugins/sfputil.py b/device/mellanox/x86_64-nvidia_sn4800-r0/plugins/sfputil.py similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/plugins/sfputil.py rename to device/mellanox/x86_64-nvidia_sn4800-r0/plugins/sfputil.py diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/pmon_daemon_control.json b/device/mellanox/x86_64-nvidia_sn4800-r0/pmon_daemon_control.json similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/pmon_daemon_control.json rename to device/mellanox/x86_64-nvidia_sn4800-r0/pmon_daemon_control.json diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/sensors.conf b/device/mellanox/x86_64-nvidia_sn4800-r0/sensors.conf similarity index 94% rename from device/mellanox/x86_64-mlnx_msn4800-r0/sensors.conf rename to device/mellanox/x86_64-nvidia_sn4800-r0/sensors.conf index f4c981f5ecac..3cf718641a81 100644 --- a/device/mellanox/x86_64-mlnx_msn4800-r0/sensors.conf +++ b/device/mellanox/x86_64-nvidia_sn4800-r0/sensors.conf @@ -141,16 +141,17 @@ bus "i2c-5" "i2c-1-mux (chan_id 3)" ignore curr4 bus "i2c-56" "i2c-1-mux (chan_id 6)" chip "mp2975-i2c-*-6b" - label in1 "PMIC-6 PSU 12V Rail (in1)" - label in2 "PMIC-6 PSU 12V Rail (in2)" - label in3 "PMIC-6 COMEX 1.8V Rail (out1)" - label in4 "PMIC-6 COMEX 1.05V Rail (out2)" - label temp1 "PMIC-6 Temp 1" - label temp2 "PMIC-6 Temp 2" - label power1 "PMIC-6 COMEX 1.8V Rail Pwr (out1)" - label power2 "PMIC-6 COMEX 1.05V Rail Pwr (out2)" - label curr1 "PMIC-6 COMEX 1.8V Rail Curr (out1)" - label curr2 "PMIC-6 COMEX 1.05V Rail Curr (out2)" + label in1 "PMIC-6 PSU 12V Rail (vin)" + ignore in2 + label in3 "PMIC-6 COMEX VCORE (out1)" + label in4 "PMIC-6 COMEX VCCSA (out2)" + label temp1 "PMIC-6 Temp" + label power1 "PMIC-6 COMEX Pwr (pin)" + label power2 "PMIC-6 COMEX VCORE Pwr (pout1)" + label power3 "PMIC-6 COMEX VCCSA Pwr (pout2)" + label curr1 "PMIC-6 COMEX Curr (iin)" + label curr2 "PMIC-6 COMEX VCORE Rail Curr (out1)" + label curr3 "PMIC-6 COMEX VCCSA Rail Curr (out2)" # Power supplies bus "i2c-4" "i2c-1-mux (chan_id 3)" diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/system_health_monitoring_config.json b/device/mellanox/x86_64-nvidia_sn4800-r0/system_health_monitoring_config.json similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/system_health_monitoring_config.json rename to device/mellanox/x86_64-nvidia_sn4800-r0/system_health_monitoring_config.json diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/thermal_policy.json b/device/mellanox/x86_64-nvidia_sn4800-r0/thermal_policy.json similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800-r0/thermal_policy.json rename to device/mellanox/x86_64-nvidia_sn4800-r0/thermal_policy.json diff --git a/device/mellanox/x86_64-nvidia_sn4800_simx-r0/ACS-SN4800 b/device/mellanox/x86_64-nvidia_sn4800_simx-r0/ACS-SN4800 new file mode 120000 index 000000000000..9a7b8fc17cc8 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn4800_simx-r0/ACS-SN4800 @@ -0,0 +1 @@ +../x86_64-nvidia_sn4800-r0/ACS-SN4800 \ No newline at end of file diff --git a/device/mellanox/x86_64-nvidia_sn4800_simx-r0/default_sku b/device/mellanox/x86_64-nvidia_sn4800_simx-r0/default_sku new file mode 120000 index 000000000000..2aee4b06cc35 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn4800_simx-r0/default_sku @@ -0,0 +1 @@ +../x86_64-nvidia_sn4800-r0/default_sku \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4800_simx-r0/platform_asic b/device/mellanox/x86_64-nvidia_sn4800_simx-r0/platform_asic similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800_simx-r0/platform_asic rename to device/mellanox/x86_64-nvidia_sn4800_simx-r0/platform_asic diff --git a/device/mellanox/x86_64-mlnx_msn4800_simx-r0/platform_reboot b/device/mellanox/x86_64-nvidia_sn4800_simx-r0/platform_reboot similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800_simx-r0/platform_reboot rename to device/mellanox/x86_64-nvidia_sn4800_simx-r0/platform_reboot diff --git a/device/mellanox/x86_64-nvidia_sn4800_simx-r0/plugins b/device/mellanox/x86_64-nvidia_sn4800_simx-r0/plugins new file mode 120000 index 000000000000..568d16ab2902 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn4800_simx-r0/plugins @@ -0,0 +1 @@ +../x86_64-nvidia_sn4800-r0/plugins \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4800_simx-r0/pmon_daemon_control.json b/device/mellanox/x86_64-nvidia_sn4800_simx-r0/pmon_daemon_control.json similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800_simx-r0/pmon_daemon_control.json rename to device/mellanox/x86_64-nvidia_sn4800_simx-r0/pmon_daemon_control.json diff --git a/device/mellanox/x86_64-mlnx_msn4800_simx-r0/syseeprom.hex b/device/mellanox/x86_64-nvidia_sn4800_simx-r0/syseeprom.hex similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800_simx-r0/syseeprom.hex rename to device/mellanox/x86_64-nvidia_sn4800_simx-r0/syseeprom.hex diff --git a/device/mellanox/x86_64-mlnx_msn4800_simx-r0/system_health_monitoring_config.json b/device/mellanox/x86_64-nvidia_sn4800_simx-r0/system_health_monitoring_config.json similarity index 100% rename from device/mellanox/x86_64-mlnx_msn4800_simx-r0/system_health_monitoring_config.json rename to device/mellanox/x86_64-nvidia_sn4800_simx-r0/system_health_monitoring_config.json diff --git a/device/mellanox/x86_64-nvidia_sn5600_simx-r0/platform.json b/device/mellanox/x86_64-nvidia_sn5600_simx-r0/platform.json new file mode 100644 index 000000000000..fdc689855c80 --- /dev/null +++ b/device/mellanox/x86_64-nvidia_sn5600_simx-r0/platform.json @@ -0,0 +1,1282 @@ +{ + "chassis": { + "name": "SN5600", + "components": [ + { + "name": "ONIE" + }, + { + "name": "SSD" + }, + { + "name": "BIOS" + }, + { + "name": "CPLD1" + }, + { + "name": "CPLD2" + }, + { + "name": "CPLD3" + }, + { + "name": "CPLD4" + }, + { + "name": "CPLD5" + }, + { + "name": "CPLD6" + } + ], + "fans": [], + "fan_drawers": [ + { + "name": "drawer1", + "fans": [ + { + "name": "fan1" + } + ] + }, + { + "name": "drawer2", + "fans": [ + { + "name": "fan2" + } + ] + }, + { + "name": "drawer3", + "fans": [ + { + "name": "fan3" + } + ] + }, + { + "name": "drawer4", + "fans": [ + { + "name": "fan4" + } + ] + } + ], + "psus": [ + { + "name": "PSU 1", + "fans": [ + { + "name": "psu1_fan1" + } + ], + "thermals": [ + { + "name": "PSU-1 Temp" + } + ] + }, + { + "name": "PSU 2", + "fans": [ + { + "name": "psu2_fan1" + } + ], + "thermals": [ + { + "name": "PSU-2 Temp" + } + ] + } + ], + "thermals": [ + { + "name": "ASIC" + }, + { + "name": "Ambient COMEX Temp" + }, + { + "name": "Ambient Fan Side Temp" + }, + { + "name": "Ambient Port Side Temp" + }, + { + "name": "CPU Core 0 Temp" + }, + { + "name": "CPU Core 1 Temp" + }, + { + "name": "CPU Core 2 Temp" + }, + { + "name": "CPU Core 3 Temp" + }, + { + "name": "CPU Pack Temp" + } + ], + "sfps": [ + { + "name": "sfp1", + "thermals": [ + { + "name": "xSFP module 1 Temp" + } + ] + }, + { + "name": "sfp2", + "thermals": [ + { + "name": "xSFP module 2 Temp" + } + ] + }, + { + "name": "sfp3", + "thermals": [ + { + "name": "xSFP module 3 Temp" + } + ] + }, + { + "name": "sfp4", + "thermals": [ + { + "name": "xSFP module 4 Temp" + } + ] + }, + { + "name": "sfp5", + "thermals": [ + { + "name": "xSFP module 5 Temp" + } + ] + }, + { + "name": "sfp6", + "thermals": [ + { + "name": "xSFP module 6 Temp" + } + ] + }, + { + "name": "sfp7", + "thermals": [ + { + "name": "xSFP module 7 Temp" + } + ] + }, + { + "name": "sfp8", + "thermals": [ + { + "name": "xSFP module 8 Temp" + } + ] + }, + { + "name": "sfp9", + "thermals": [ + { + "name": "xSFP module 9 Temp" + } + ] + }, + { + "name": "sfp10", + "thermals": [ + { + "name": "xSFP module 10 Temp" + } + ] + }, + { + "name": "sfp11", + "thermals": [ + { + "name": "xSFP module 11 Temp" + } + ] + }, + { + "name": "sfp12", + "thermals": [ + { + "name": "xSFP module 12 Temp" + } + ] + }, + { + "name": "sfp13", + "thermals": [ + { + "name": "xSFP module 13 Temp" + } + ] + }, + { + "name": "sfp14", + "thermals": [ + { + "name": "xSFP module 14 Temp" + } + ] + }, + { + "name": "sfp15", + "thermals": [ + { + "name": "xSFP module 15 Temp" + } + ] + }, + { + "name": "sfp16", + "thermals": [ + { + "name": "xSFP module 16 Temp" + } + ] + }, + { + "name": "sfp17", + "thermals": [ + { + "name": "xSFP module 17 Temp" + } + ] + }, + { + "name": "sfp18", + "thermals": [ + { + "name": "xSFP module 18 Temp" + } + ] + }, + { + "name": "sfp19", + "thermals": [ + { + "name": "xSFP module 19 Temp" + } + ] + }, + { + "name": "sfp20", + "thermals": [ + { + "name": "xSFP module 20 Temp" + } + ] + }, + { + "name": "sfp21", + "thermals": [ + { + "name": "xSFP module 21 Temp" + } + ] + }, + { + "name": "sfp22", + "thermals": [ + { + "name": "xSFP module 22 Temp" + } + ] + }, + { + "name": "sfp23", + "thermals": [ + { + "name": "xSFP module 23 Temp" + } + ] + }, + { + "name": "sfp24", + "thermals": [ + { + "name": "xSFP module 24 Temp" + } + ] + }, + { + "name": "sfp25", + "thermals": [ + { + "name": "xSFP module 25 Temp" + } + ] + }, + { + "name": "sfp26", + "thermals": [ + { + "name": "xSFP module 26 Temp" + } + ] + }, + { + "name": "sfp27", + "thermals": [ + { + "name": "xSFP module 27 Temp" + } + ] + }, + { + "name": "sfp28", + "thermals": [ + { + "name": "xSFP module 28 Temp" + } + ] + }, + { + "name": "sfp29", + "thermals": [ + { + "name": "xSFP module 29 Temp" + } + ] + }, + { + "name": "sfp30", + "thermals": [ + { + "name": "xSFP module 30 Temp" + } + ] + }, + { + "name": "sfp31", + "thermals": [ + { + "name": "xSFP module 31 Temp" + } + ] + }, + { + "name": "sfp32", + "thermals": [ + { + "name": "xSFP module 32 Temp" + } + ] + }, + { + "name": "sfp33", + "thermals": [ + { + "name": "xSFP module 33 Temp" + } + ] + }, + { + "name": "sfp34", + "thermals": [ + { + "name": "xSFP module 34 Temp" + } + ] + }, + { + "name": "sfp35", + "thermals": [ + { + "name": "xSFP module 35 Temp" + } + ] + }, + { + "name": "sfp36", + "thermals": [ + { + "name": "xSFP module 36 Temp" + } + ] + }, + { + "name": "sfp37", + "thermals": [ + { + "name": "xSFP module 37 Temp" + } + ] + }, + { + "name": "sfp38", + "thermals": [ + { + "name": "xSFP module 38 Temp" + } + ] + }, + { + "name": "sfp39", + "thermals": [ + { + "name": "xSFP module 39 Temp" + } + ] + }, + { + "name": "sfp40", + "thermals": [ + { + "name": "xSFP module 40 Temp" + } + ] + }, + { + "name": "sfp41", + "thermals": [ + { + "name": "xSFP module 41 Temp" + } + ] + }, + { + "name": "sfp42", + "thermals": [ + { + "name": "xSFP module 42 Temp" + } + ] + }, + { + "name": "sfp43", + "thermals": [ + { + "name": "xSFP module 43 Temp" + } + ] + }, + { + "name": "sfp44", + "thermals": [ + { + "name": "xSFP module 44 Temp" + } + ] + }, + { + "name": "sfp45", + "thermals": [ + { + "name": "xSFP module 45 Temp" + } + ] + }, + { + "name": "sfp46", + "thermals": [ + { + "name": "xSFP module 46 Temp" + } + ] + }, + { + "name": "sfp47", + "thermals": [ + { + "name": "xSFP module 47 Temp" + } + ] + }, + { + "name": "sfp48", + "thermals": [ + { + "name": "xSFP module 48 Temp" + } + ] + }, + { + "name": "sfp49", + "thermals": [ + { + "name": "xSFP module 49 Temp" + } + ] + }, + { + "name": "sfp50", + "thermals": [ + { + "name": "xSFP module 50 Temp" + } + ] + }, + { + "name": "sfp51", + "thermals": [ + { + "name": "xSFP module 51 Temp" + } + ] + }, + { + "name": "sfp52", + "thermals": [ + { + "name": "xSFP module 52 Temp" + } + ] + }, + { + "name": "sfp53", + "thermals": [ + { + "name": "xSFP module 53 Temp" + } + ] + }, + { + "name": "sfp54", + "thermals": [ + { + "name": "xSFP module 54 Temp" + } + ] + }, + { + "name": "sfp55", + "thermals": [ + { + "name": "xSFP module 55 Temp" + } + ] + }, + { + "name": "sfp56", + "thermals": [ + { + "name": "xSFP module 56 Temp" + } + ] + }, + { + "name": "sfp57", + "thermals": [ + { + "name": "xSFP module 57 Temp" + } + ] + }, + { + "name": "sfp58", + "thermals": [ + { + "name": "xSFP module 58 Temp" + } + ] + }, + { + "name": "sfp59", + "thermals": [ + { + "name": "xSFP module 59 Temp" + } + ] + }, + { + "name": "sfp60", + "thermals": [ + { + "name": "xSFP module 60 Temp" + } + ] + }, + { + "name": "sfp61", + "thermals": [ + { + "name": "xSFP module 61 Temp" + } + ] + }, + { + "name": "sfp62", + "thermals": [ + { + "name": "xSFP module 62 Temp" + } + ] + }, + { + "name": "sfp63", + "thermals": [ + { + "name": "xSFP module 63 Temp" + } + ] + }, + { + "name": "sfp64", + "thermals": [ + { + "name": "xSFP module 64 Temp" + } + ] + } + ] + }, + "interfaces": { + "Ethernet0": { + "index": "1,1,1,1,1,1,1,1", + "lanes": "0,1,2,3,4,5,6,7", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp1"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp1a", "etp1b"], + "4x200G[100G,50G,25G,10G]": ["etp1a", "etp1b", "etp1c", "etp1d"], + "8x100G[50G,25G,10G]": ["etp1a", "etp1b", "etp1c", "etp1d", "etp1e", "etp1f", "etp1g", "etp1h"] + } + }, + "Ethernet8": { + "index": "2,2,2,2,2,2,2,2", + "lanes": "8,9,10,11,12,13,14,15", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp2"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp2a", "etp2b"], + "4x200G[100G,50G,25G,10G]": ["etp2a", "etp2b", "etp2c", "etp2d"], + "8x100G[50G,25G,10G]": ["etp2a", "etp2b", "etp2c", "etp2d", "etp2e", "etp2f", "etp2g", "etp2h"] + } + }, + "Ethernet16": { + "index": "3,3,3,3,3,3,3,3", + "lanes": "16,17,18,19,20,21,22,23", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp3"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp3a", "etp3b"], + "4x200G[100G,50G,25G,10G]": ["etp3a", "etp3b", "etp3c", "etp3d"], + "8x100G[50G,25G,10G]": ["etp3a", "etp3b", "etp3c", "etp3d", "etp3e", "etp3f", "etp3g", "etp3h"] + } + }, + "Ethernet24": { + "index": "4,4,4,4,4,4,4,4", + "lanes": "24,25,26,27,28,29,30,31", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp4"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp4a", "etp4b"], + "4x200G[100G,50G,25G,10G]": ["etp4a", "etp4b", "etp4c", "etp4d"], + "8x100G[50G,25G,10G]": ["etp4a", "etp4b", "etp4c", "etp4d", "etp4e", "etp4f", "etp4g", "etp4h"] + } + }, + "Ethernet32": { + "index": "5,5,5,5,5,5,5,5", + "lanes": "32,33,34,35,36,37,38,39", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp5"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp5a", "etp5b"], + "4x200G[100G,50G,25G,10G]": ["etp5a", "etp5b", "etp5c", "etp5d"], + "8x100G[50G,25G,10G]": ["etp5a", "etp5b", "etp5c", "etp5d", "etp5e", "etp5f", "etp5g", "etp5h"] + } + }, + "Ethernet40": { + "index": "6,6,6,6,6,6,6,6", + "lanes": "40,41,42,43,44,45,46,47", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp6"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp6a", "etp6b"], + "4x200G[100G,50G,25G,10G]": ["etp6a", "etp6b", "etp6c", "etp6d"], + "8x100G[50G,25G,10G]": ["etp6a", "etp6b", "etp6c", "etp6d", "etp6e", "etp6f", "etp6g", "etp6h"] + } + }, + "Ethernet48": { + "index": "7,7,7,7,7,7,7,7", + "lanes": "48,49,50,51,52,53,54,55", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp7"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp7a", "etp7b"], + "4x200G[100G,50G,25G,10G]": ["etp7a", "etp7b", "etp7c", "etp7d"], + "8x100G[50G,25G,10G]": ["etp7a", "etp7b", "etp7c", "etp7d", "etp7e", "etp7f", "etp7g", "etp7h"] + } + }, + "Ethernet56": { + "index": "8,8,8,8,8,8,8,8", + "lanes": "56,57,58,59,60,61,62,63", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp8"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp8a", "etp8b"], + "4x200G[100G,50G,25G,10G]": ["etp8a", "etp8b", "etp8c", "etp8d"], + "8x100G[50G,25G,10G]": ["etp8a", "etp8b", "etp8c", "etp8d", "etp8e", "etp8f", "etp8g", "etp8h"] + } + }, + "Ethernet64": { + "index": "9,9,9,9,9,9,9,9", + "lanes": "64,65,66,67,68,69,70,71", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp9"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp9a", "etp9b"], + "4x200G[100G,50G,25G,10G]": ["etp9a", "etp9b", "etp9c", "etp9d"], + "8x100G[50G,25G,10G]": ["etp9a", "etp9b", "etp9c", "etp9d", "etp9e", "etp9f", "etp9g", "etp9h"] + } + }, + "Ethernet72": { + "index": "10,10,10,10,10,10,10,10", + "lanes": "72,73,74,75,76,77,78,79", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp10"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp10a", "etp10b"], + "4x200G[100G,50G,25G,10G]": ["etp10a", "etp10b", "etp10c", "etp10d"], + "8x100G[50G,25G,10G]": ["etp10a", "etp10b", "etp10c", "etp10d", "etp10e", "etp10f", "etp10g", "etp10h"] + } + }, + "Ethernet80": { + "index": "11,11,11,11,11,11,11,11", + "lanes": "80,81,82,83,84,85,86,87", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp11"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp11a", "etp11b"], + "4x200G[100G,50G,25G,10G]": ["etp11a", "etp11b", "etp11c", "etp11d"], + "8x100G[50G,25G,10G]": ["etp11a", "etp11b", "etp11c", "etp11d", "etp11e", "etp11f", "etp11g", "etp11h"] + } + }, + "Ethernet88": { + "index": "12,12,12,12,12,12,12,12", + "lanes": "88,89,90,91,92,93,94,95", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp12"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp12a", "etp12b"], + "4x200G[100G,50G,25G,10G]": ["etp12a", "etp12b", "etp12c", "etp12d"], + "8x100G[50G,25G,10G]": ["etp12a", "etp12b", "etp12c", "etp12d", "etp12e", "etp12f", "etp12g", "etp12h"] + } + }, + "Ethernet96": { + "index": "13,13,13,13,13,13,13,13", + "lanes": "96,97,98,99,100,101,102,103", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp13"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp13a", "etp13b"], + "4x200G[100G,50G,25G,10G]": ["etp13a", "etp13b", "etp13c", "etp13d"], + "8x100G[50G,25G,10G]": ["etp13a", "etp13b", "etp13c", "etp13d", "etp13e", "etp13f", "etp13g", "etp13h"] + } + }, + "Ethernet104": { + "index": "14,14,14,14,14,14,14,14", + "lanes": "104,105,106,107,108,109,110,111", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp14"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp14a", "etp14b"], + "4x200G[100G,50G,25G,10G]": ["etp14a", "etp14b", "etp14c", "etp14d"], + "8x100G[50G,25G,10G]": ["etp14a", "etp14b", "etp14c", "etp14d", "etp14e", "etp14f", "etp14g", "etp14h"] + } + }, + "Ethernet112": { + "index": "15,15,15,15,15,15,15,15", + "lanes": "112,113,114,115,116,117,118,119", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp15"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp15a", "etp15b"], + "4x200G[100G,50G,25G,10G]": ["etp15a", "etp15b", "etp15c", "etp15d"], + "8x100G[50G,25G,10G]": ["etp15a", "etp15b", "etp15c", "etp15d", "etp15e", "etp15f", "etp15g", "etp15h"] + } + }, + "Ethernet120": { + "index": "16,16,16,16,16,16,16,16", + "lanes": "120,121,122,123,124,125,126,127", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp16"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp16a", "etp16b"], + "4x200G[100G,50G,25G,10G]": ["etp16a", "etp16b", "etp16c", "etp16d"], + "8x100G[50G,25G,10G]": ["etp16a", "etp16b", "etp16c", "etp16d", "etp16e", "etp16f", "etp16g", "etp16h"] + } + }, + "Ethernet128": { + "index": "17,17,17,17,17,17,17,17", + "lanes": "128,129,130,131,132,133,134,135", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp17"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp17a", "etp17b"], + "4x200G[100G,50G,25G,10G]": ["etp17a", "etp17b", "etp17c", "etp17d"], + "8x100G[50G,25G,10G]": ["etp17a", "etp17b", "etp17c", "etp17d", "etp17e", "etp17f", "etp17g", "etp17h"] + } + }, + "Ethernet136": { + "index": "18,18,18,18,18,18,18,18", + "lanes": "136,137,138,139,140,141,142,143", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp18"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp18a", "etp18b"], + "4x200G[100G,50G,25G,10G]": ["etp18a", "etp18b", "etp18c", "etp18d"], + "8x100G[50G,25G,10G]": ["etp18a", "etp18b", "etp18c", "etp18d", "etp18e", "etp18f", "etp18g", "etp18h"] + } + }, + "Ethernet144": { + "index": "19,19,19,19,19,19,19,19", + "lanes": "144,145,146,147,148,149,150,151", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp19"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp19a", "etp19b"], + "4x200G[100G,50G,25G,10G]": ["etp19a", "etp19b", "etp19c", "etp19d"], + "8x100G[50G,25G,10G]": ["etp19a", "etp19b", "etp19c", "etp19d", "etp19e", "etp19f", "etp19g", "etp19h"] + } + }, + "Ethernet152": { + "index": "20,20,20,20,20,20,20,20", + "lanes": "152,153,154,155,156,157,158,159", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp20"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp20a", "etp20b"], + "4x200G[100G,50G,25G,10G]": ["etp20a", "etp20b", "etp20c", "etp20d"], + "8x100G[50G,25G,10G]": ["etp20a", "etp20b", "etp20c", "etp20d", "etp20e", "etp20f", "etp20g", "etp20h"] + } + }, + "Ethernet160": { + "index": "21,21,21,21,21,21,21,21", + "lanes": "160,161,162,163,164,165,166,167", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp21"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp21a", "etp21b"], + "4x200G[100G,50G,25G,10G]": ["etp21a", "etp21b", "etp21c", "etp21d"], + "8x100G[50G,25G,10G]": ["etp21a", "etp21b", "etp21c", "etp21d", "etp21e", "etp21f", "etp21g", "etp21h"] + } + }, + "Ethernet168": { + "index": "22,22,22,22,22,22,22,22", + "lanes": "168,169,170,171,172,173,174,175", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp22"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp22a", "etp22b"], + "4x200G[100G,50G,25G,10G]": ["etp22a", "etp22b", "etp22c", "etp22d"], + "8x100G[50G,25G,10G]": ["etp22a", "etp22b", "etp22c", "etp22d", "etp22e", "etp22f", "etp22g", "etp22h"] + } + }, + "Ethernet176": { + "index": "23,23,23,23,23,23,23,23", + "lanes": "176,177,178,179,180,181,182,183", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp23"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp23a", "etp23b"], + "4x200G[100G,50G,25G,10G]": ["etp23a", "etp23b", "etp23c", "etp23d"], + "8x100G[50G,25G,10G]": ["etp23a", "etp23b", "etp23c", "etp23d", "etp23e", "etp23f", "etp23g", "etp23h"] + } + }, + "Ethernet184": { + "index": "24,24,24,24,24,24,24,24", + "lanes": "184,185,186,187,188,189,190,191", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp24"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp24a", "etp24b"], + "4x200G[100G,50G,25G,10G]": ["etp24a", "etp24b", "etp24c", "etp24d"], + "8x100G[50G,25G,10G]": ["etp24a", "etp24b", "etp24c", "etp24d", "etp24e", "etp24f", "etp24g", "etp24h"] + } + }, + "Ethernet192": { + "index": "25,25,25,25,25,25,25,25", + "lanes": "192,193,194,195,196,197,198,199", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp25"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp25a", "etp25b"], + "4x200G[100G,50G,25G,10G]": ["etp25a", "etp25b", "etp25c", "etp25d"], + "8x100G[50G,25G,10G]": ["etp25a", "etp25b", "etp25c", "etp25d", "etp25e", "etp25f", "etp25g", "etp25h"] + } + }, + "Ethernet200": { + "index": "26,26,26,26,26,26,26,26", + "lanes": "200,201,202,203,204,205,206,207", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp26"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp26a", "etp26b"], + "4x200G[100G,50G,25G,10G]": ["etp26a", "etp26b", "etp26c", "etp26d"], + "8x100G[50G,25G,10G]": ["etp26a", "etp26b", "etp26c", "etp26d", "etp26e", "etp26f", "etp26g", "etp26h"] + } + }, + "Ethernet208": { + "index": "27,27,27,27,27,27,27,27", + "lanes": "208,209,210,211,212,213,214,215", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp27"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp27a", "etp27b"], + "4x200G[100G,50G,25G,10G]": ["etp27a", "etp27b", "etp27c", "etp27d"], + "8x100G[50G,25G,10G]": ["etp27a", "etp27b", "etp27c", "etp27d", "etp27e", "etp27f", "etp27g", "etp27h"] + } + }, + "Ethernet216": { + "index": "28,28,28,28,28,28,28,28", + "lanes": "216,217,218,219,220,221,222,223", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp28"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp28a", "etp28b"], + "4x200G[100G,50G,25G,10G]": ["etp28a", "etp28b", "etp28c", "etp28d"], + "8x100G[50G,25G,10G]": ["etp28a", "etp28b", "etp28c", "etp28d", "etp28e", "etp28f", "etp28g", "etp28h"] + } + }, + "Ethernet224": { + "index": "29,29,29,29,29,29,29,29", + "lanes": "224,225,226,227,228,229,230,231", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp29"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp29a", "etp29b"], + "4x200G[100G,50G,25G,10G]": ["etp29a", "etp29b", "etp29c", "etp29d"], + "8x100G[50G,25G,10G]": ["etp29a", "etp29b", "etp29c", "etp29d", "etp29e", "etp29f", "etp29g", "etp29h"] + } + }, + "Ethernet232": { + "index": "30,30,30,30,30,30,30,30", + "lanes": "232,233,234,235,236,237,238,239", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp30"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp30a", "etp30b"], + "4x200G[100G,50G,25G,10G]": ["etp30a", "etp30b", "etp30c", "etp30d"], + "8x100G[50G,25G,10G]": ["etp30a", "etp30b", "etp30c", "etp30d", "etp30e", "etp30f", "etp30g", "etp30h"] + } + }, + "Ethernet240": { + "index": "31,31,31,31,31,31,31,31", + "lanes": "240,241,242,243,244,245,246,247", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp31"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp31a", "etp31b"], + "4x200G[100G,50G,25G,10G]": ["etp31a", "etp31b", "etp31c", "etp31d"], + "8x100G[50G,25G,10G]": ["etp31a", "etp31b", "etp31c", "etp31d", "etp31e", "etp31f", "etp31g", "etp31h"] + } + }, + "Ethernet248": { + "index": "32,32,32,32,32,32,32,32", + "lanes": "248,249,250,251,252,253,254,255", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp32"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp32a", "etp32b"], + "4x200G[100G,50G,25G,10G]": ["etp32a", "etp32b", "etp32c", "etp32d"], + "8x100G[50G,25G,10G]": ["etp32a", "etp32b", "etp32c", "etp32d", "etp32e", "etp32f", "etp32g", "etp32h"] + } + }, + "Ethernet256": { + "index": "33,33,33,33,33,33,33,33", + "lanes": "256,257,258,259,260,261,262,263", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp33"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp33a", "etp33b"], + "4x200G[100G,50G,25G,10G]": ["etp33a", "etp33b", "etp33c", "etp33d"], + "8x100G[50G,25G,10G]": ["etp33a", "etp33b", "etp33c", "etp33d", "etp33e", "etp33f", "etp33g", "etp33h"] + } + }, + "Ethernet264": { + "index": "34,34,34,34,34,34,34,34", + "lanes": "264,265,266,267,268,269,270,271", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp34"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp34a", "etp34b"], + "4x200G[100G,50G,25G,10G]": ["etp34a", "etp34b", "etp34c", "etp34d"], + "8x100G[50G,25G,10G]": ["etp34a", "etp34b", "etp34c", "etp34d", "etp34e", "etp34f", "etp34g", "etp34h"] + } + }, + "Ethernet272": { + "index": "35,35,35,35,35,35,35,35", + "lanes": "272,273,274,275,276,277,278,279", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp35"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp35a", "etp35b"], + "4x200G[100G,50G,25G,10G]": ["etp35a", "etp35b", "etp35c", "etp35d"], + "8x100G[50G,25G,10G]": ["etp35a", "etp35b", "etp35c", "etp35d", "etp35e", "etp35f", "etp35g", "etp35h"] + } + }, + "Ethernet280": { + "index": "36,36,36,36,36,36,36,36", + "lanes": "280,281,282,283,284,285,286,287", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp36"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp36a", "etp36b"], + "4x200G[100G,50G,25G,10G]": ["etp36a", "etp36b", "etp36c", "etp36d"], + "8x100G[50G,25G,10G]": ["etp36a", "etp36b", "etp36c", "etp36d", "etp36e", "etp36f", "etp36g", "etp36h"] + } + }, + "Ethernet288": { + "index": "37,37,37,37,37,37,37,37", + "lanes": "288,289,290,291,292,293,294,295", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp37"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp37a", "etp37b"], + "4x200G[100G,50G,25G,10G]": ["etp37a", "etp37b", "etp37c", "etp37d"], + "8x100G[50G,25G,10G]": ["etp37a", "etp37b", "etp37c", "etp37d", "etp37e", "etp37f", "etp37g", "etp37h"] + } + }, + "Ethernet296": { + "index": "38,38,38,38,38,38,38,38", + "lanes": "296,297,298,299,300,301,302,303", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp38"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp38a", "etp38b"], + "4x200G[100G,50G,25G,10G]": ["etp38a", "etp38b", "etp38c", "etp38d"], + "8x100G[50G,25G,10G]": ["etp38a", "etp38b", "etp38c", "etp38d", "etp38e", "etp38f", "etp38g", "etp38h"] + } + }, + "Ethernet304": { + "index": "39,39,39,39,39,39,39,39", + "lanes": "304,305,306,307,308,309,310,311", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp39"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp39a", "etp39b"], + "4x200G[100G,50G,25G,10G]": ["etp39a", "etp39b", "etp39c", "etp39d"], + "8x100G[50G,25G,10G]": ["etp39a", "etp39b", "etp39c", "etp39d", "etp39e", "etp39f", "etp39g", "etp39h"] + } + }, + "Ethernet312": { + "index": "40,40,40,40,40,40,40,40", + "lanes": "312,313,314,315,316,317,318,319", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp40"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp40a", "etp40b"], + "4x200G[100G,50G,25G,10G]": ["etp40a", "etp40b", "etp40c", "etp40d"], + "8x100G[50G,25G,10G]": ["etp40a", "etp40b", "etp40c", "etp40d", "etp40e", "etp40f", "etp40g", "etp40h"] + } + }, + "Ethernet320": { + "index": "41,41,41,41,41,41,41,41", + "lanes": "320,321,322,323,324,325,326,327", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp41"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp41a", "etp41b"], + "4x200G[100G,50G,25G,10G]": ["etp41a", "etp41b", "etp41c", "etp41d"], + "8x100G[50G,25G,10G]": ["etp41a", "etp41b", "etp41c", "etp41d", "etp41e", "etp41f", "etp41g", "etp41h"] + } + }, + "Ethernet328": { + "index": "42,42,42,42,42,42,42,42", + "lanes": "328,329,330,331,332,333,334,335", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp42"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp42a", "etp42b"], + "4x200G[100G,50G,25G,10G]": ["etp42a", "etp42b", "etp42c", "etp42d"], + "8x100G[50G,25G,10G]": ["etp42a", "etp42b", "etp42c", "etp42d", "etp42e", "etp42f", "etp42g", "etp42h"] + } + }, + "Ethernet336": { + "index": "43,43,43,43,43,43,43,43", + "lanes": "336,337,338,339,340,341,342,343", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp43"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp43a", "etp43b"], + "4x200G[100G,50G,25G,10G]": ["etp43a", "etp43b", "etp43c", "etp43d"], + "8x100G[50G,25G,10G]": ["etp43a", "etp43b", "etp43c", "etp43d", "etp43e", "etp43f", "etp43g", "etp43h"] + } + }, + "Ethernet344": { + "index": "44,44,44,44,44,44,44,44", + "lanes": "344,345,346,347,348,349,350,351", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp44"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp44a", "etp44b"], + "4x200G[100G,50G,25G,10G]": ["etp44a", "etp44b", "etp44c", "etp44d"], + "8x100G[50G,25G,10G]": ["etp44a", "etp44b", "etp44c", "etp44d", "etp44e", "etp44f", "etp44g", "etp44h"] + } + }, + "Ethernet352": { + "index": "45,45,45,45,45,45,45,45", + "lanes": "352,353,354,355,356,357,358,359", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp45"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp45a", "etp45b"], + "4x200G[100G,50G,25G,10G]": ["etp45a", "etp45b", "etp45c", "etp45d"], + "8x100G[50G,25G,10G]": ["etp45a", "etp45b", "etp45c", "etp45d", "etp45e", "etp45f", "etp45g", "etp45h"] + } + }, + "Ethernet360": { + "index": "46,46,46,46,46,46,46,46", + "lanes": "360,361,362,363,364,365,366,367", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp46"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp46a", "etp46b"], + "4x200G[100G,50G,25G,10G]": ["etp46a", "etp46b", "etp46c", "etp46d"], + "8x100G[50G,25G,10G]": ["etp46a", "etp46b", "etp46c", "etp46d", "etp46e", "etp46f", "etp46g", "etp46h"] + } + }, + "Ethernet368": { + "index": "47,47,47,47,47,47,47,47", + "lanes": "368,369,370,371,372,373,374,375", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp47"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp47a", "etp47b"], + "4x200G[100G,50G,25G,10G]": ["etp47a", "etp47b", "etp47c", "etp47d"], + "8x100G[50G,25G,10G]": ["etp47a", "etp47b", "etp47c", "etp47d", "etp47e", "etp47f", "etp47g", "etp47h"] + } + }, + "Ethernet376": { + "index": "48,48,48,48,48,48,48,48", + "lanes": "376,377,378,379,380,381,382,383", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp48"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp48a", "etp48b"], + "4x200G[100G,50G,25G,10G]": ["etp48a", "etp48b", "etp48c", "etp48d"], + "8x100G[50G,25G,10G]": ["etp48a", "etp48b", "etp48c", "etp48d", "etp48e", "etp48f", "etp48g", "etp48h"] + } + }, + "Ethernet384": { + "index": "49,49,49,49,49,49,49,49", + "lanes": "384,385,386,387,388,389,390,391", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp49"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp49a", "etp49b"], + "4x200G[100G,50G,25G,10G]": ["etp49a", "etp49b", "etp49c", "etp49d"], + "8x100G[50G,25G,10G]": ["etp49a", "etp49b", "etp49c", "etp49d", "etp49e", "etp49f", "etp49g", "etp49h"] + } + }, + "Ethernet392": { + "index": "50,50,50,50,50,50,50,50", + "lanes": "392,393,394,395,396,397,398,399", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp50"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp50a", "etp50b"], + "4x200G[100G,50G,25G,10G]": ["etp50a", "etp50b", "etp50c", "etp50d"], + "8x100G[50G,25G,10G]": ["etp50a", "etp50b", "etp50c", "etp50d", "etp50e", "etp50f", "etp50g", "etp50h"] + } + }, + "Ethernet400": { + "index": "51,51,51,51,51,51,51,51", + "lanes": "400,401,402,403,404,405,406,407", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp51"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp51a", "etp51b"], + "4x200G[100G,50G,25G,10G]": ["etp51a", "etp51b", "etp51c", "etp51d"], + "8x100G[50G,25G,10G]": ["etp51a", "etp51b", "etp51c", "etp51d", "etp51e", "etp51f", "etp51g", "etp51h"] + } + }, + "Ethernet408": { + "index": "52,52,52,52,52,52,52,52", + "lanes": "408,409,410,411,412,413,414,415", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp52"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp52a", "etp52b"], + "4x200G[100G,50G,25G,10G]": ["etp52a", "etp52b", "etp52c", "etp52d"], + "8x100G[50G,25G,10G]": ["etp52a", "etp52b", "etp52c", "etp52d", "etp52e", "etp52f", "etp52g", "etp52h"] + } + }, + "Ethernet416": { + "index": "53,53,53,53,53,53,53,53", + "lanes": "416,417,418,419,420,421,422,423", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp53"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp53a", "etp53b"], + "4x200G[100G,50G,25G,10G]": ["etp53a", "etp53b", "etp53c", "etp53d"], + "8x100G[50G,25G,10G]": ["etp53a", "etp53b", "etp53c", "etp53d", "etp53e", "etp53f", "etp53g", "etp53h"] + } + }, + "Ethernet424": { + "index": "54,54,54,54,54,54,54,54", + "lanes": "424,425,426,427,428,429,430,431", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp54"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp54a", "etp54b"], + "4x200G[100G,50G,25G,10G]": ["etp54a", "etp54b", "etp54c", "etp54d"], + "8x100G[50G,25G,10G]": ["etp54a", "etp54b", "etp54c", "etp54d", "etp54e", "etp54f", "etp54g", "etp54h"] + } + }, + "Ethernet432": { + "index": "55,55,55,55,55,55,55,55", + "lanes": "432,433,434,435,436,437,438,439", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp55"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp55a", "etp55b"], + "4x200G[100G,50G,25G,10G]": ["etp55a", "etp55b", "etp55c", "etp55d"], + "8x100G[50G,25G,10G]": ["etp55a", "etp55b", "etp55c", "etp55d", "etp55e", "etp55f", "etp55g", "etp55h"] + } + }, + "Ethernet440": { + "index": "56,56,56,56,56,56,56,56", + "lanes": "440,441,442,443,444,445,446,447", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp56"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp56a", "etp56b"], + "4x200G[100G,50G,25G,10G]": ["etp56a", "etp56b", "etp56c", "etp56d"], + "8x100G[50G,25G,10G]": ["etp56a", "etp56b", "etp56c", "etp56d", "etp56e", "etp56f", "etp56g", "etp56h"] + } + }, + "Ethernet448": { + "index": "57,57,57,57,57,57,57,57", + "lanes": "448,449,450,451,452,453,454,455", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp57"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp57a", "etp57b"], + "4x200G[100G,50G,25G,10G]": ["etp57a", "etp57b", "etp57c", "etp57d"], + "8x100G[50G,25G,10G]": ["etp57a", "etp57b", "etp57c", "etp57d", "etp57e", "etp57f", "etp57g", "etp57h"] + } + }, + "Ethernet456": { + "index": "58,58,58,58,58,58,58,58", + "lanes": "456,457,458,459,460,461,462,463", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp58"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp58a", "etp58b"], + "4x200G[100G,50G,25G,10G]": ["etp58a", "etp58b", "etp58c", "etp58d"], + "8x100G[50G,25G,10G]": ["etp58a", "etp58b", "etp58c", "etp58d", "etp58e", "etp58f", "etp58g", "etp58h"] + } + }, + "Ethernet464": { + "index": "59,59,59,59,59,59,59,59", + "lanes": "464,465,466,467,468,469,470,471", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp59"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp59a", "etp59b"], + "4x200G[100G,50G,25G,10G]": ["etp59a", "etp59b", "etp59c", "etp59d"], + "8x100G[50G,25G,10G]": ["etp59a", "etp59b", "etp59c", "etp59d", "etp59e", "etp59f", "etp59g", "etp59h"] + } + }, + "Ethernet472": { + "index": "60,60,60,60,60,60,60,60", + "lanes": "472,473,474,475,476,477,478,479", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp60"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp60a", "etp60b"], + "4x200G[100G,50G,25G,10G]": ["etp60a", "etp60b", "etp60c", "etp60d"], + "8x100G[50G,25G,10G]": ["etp60a", "etp60b", "etp60c", "etp60d", "etp60e", "etp60f", "etp60g", "etp60h"] + } + }, + "Ethernet480": { + "index": "61,61,61,61,61,61,61,61", + "lanes": "480,481,482,483,484,485,486,487", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp61"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp61a", "etp61b"], + "4x200G[100G,50G,25G,10G]": ["etp61a", "etp61b", "etp61c", "etp61d"], + "8x100G[50G,25G,10G]": ["etp61a", "etp61b", "etp61c", "etp61d", "etp61e", "etp61f", "etp61g", "etp61h"] + } + }, + "Ethernet488": { + "index": "62,62,62,62,62,62,62,62", + "lanes": "488,489,490,491,492,493,494,495", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp62"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp62a", "etp62b"], + "4x200G[100G,50G,25G,10G]": ["etp62a", "etp62b", "etp62c", "etp62d"], + "8x100G[50G,25G,10G]": ["etp62a", "etp62b", "etp62c", "etp62d", "etp62e", "etp62f", "etp62g", "etp62h"] + } + }, + "Ethernet496": { + "index": "63,63,63,63,63,63,63,63", + "lanes": "496,497,498,499,500,501,502,503", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp63"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp63a", "etp63b"], + "4x200G[100G,50G,25G,10G]": ["etp63a", "etp63b", "etp63c", "etp63d"], + "8x100G[50G,25G,10G]": ["etp63a", "etp63b", "etp63c", "etp63d", "etp63e", "etp63f", "etp63g", "etp63h"] + } + }, + "Ethernet504": { + "index": "64,64,64,64,64,64,64,64", + "lanes": "504,505,506,507,508,509,510,511", + "breakout_modes": { + "1x800G[400G,200G,100G,50G,40G,25G,10G]": ["etp64"], + "2x400G[200G,100G,50G,40G,25G,10G]": ["etp64a", "etp64b"], + "4x200G[100G,50G,25G,10G]": ["etp64a", "etp64b", "etp64c", "etp64d"], + "8x100G[50G,25G,10G]": ["etp64a", "etp64b", "etp64c", "etp64d", "etp64e", "etp64f", "etp64g", "etp64h"] + } + } + } +} diff --git a/dockers/docker-base-bullseye/Dockerfile.j2 b/dockers/docker-base-bullseye/Dockerfile.j2 new file mode 100644 index 000000000000..3ac14a4841c4 --- /dev/null +++ b/dockers/docker-base-bullseye/Dockerfile.j2 @@ -0,0 +1,112 @@ +{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} +{% if CONFIGURED_ARCH == "armhf" and MULTIARCH_QEMU_ENVIRON == "y" %} +FROM multiarch/debian-debootstrap:armhf-bullseye +{% elif CONFIGURED_ARCH == "arm64" and MULTIARCH_QEMU_ENVIRON == "y" %} +FROM multiarch/debian-debootstrap:arm64-bullseye +{% else %} +FROM {{DOCKER_BASE_ARCH}}/debian:bullseye +{% endif %} + +# Clean documentation in FROM image +RUN find /usr/share/doc -depth \( -type f -o -type l \) ! -name copyright | xargs rm || true + +# Clean doc directories that are empty or only contain empty directories +RUN while [ -n "$(find /usr/share/doc -depth -type d -empty -print -exec rmdir {} +)" ]; do :; done && \ + rm -rf \ + /usr/share/man/* \ + /usr/share/groff/* \ + /usr/share/info/* \ + /usr/share/lintian/* \ + /usr/share/linda/* \ + /var/cache/man/* \ + /usr/share/locale/* + +# Make apt-get non-interactive +ENV DEBIAN_FRONTEND=noninteractive + +# Configure data sources for apt/dpkg +COPY ["dpkg_01_drop", "/etc/dpkg/dpkg.cfg.d/01_drop"] +{% if CONFIGURED_ARCH == "armhf" %} +COPY ["sources.list.armhf", "/etc/apt/sources.list"] +{% elif CONFIGURED_ARCH == "arm64" %} +COPY ["sources.list.arm64", "/etc/apt/sources.list"] +{% else %} +COPY ["sources.list", "/etc/apt/sources.list"] +{% endif %} +COPY ["no_install_recommend_suggest", "/etc/apt/apt.conf.d"] +COPY ["no-check-valid-until", "/etc/apt/apt.conf.d"] + +# Update apt cache and +# pre-install fundamental packages +RUN apt-get update && \ + apt-get -y install \ + curl \ + less \ + perl \ + procps \ + python3 \ + python3-distutils \ + python3-pip \ + rsyslog \ + vim-tiny \ +# Install redis-tools + redis-tools \ +# common dependencies + libdaemon0 \ + libdbus-1-3 \ + libjansson4 \ +# ip and ifconfig utility missing in docker for arm arch + iproute2 \ + net-tools \ +# for processing/handling json files in bash environment + jq \ +# for sairedis zmq rpc channel + libzmq5 + +# Upgrade pip via PyPI and uninstall the Debian version +RUN pip3 install --upgrade pip +RUN apt-get purge -y python3-pip + +# setuptools and wheel are necessary for installing some Python wheel packages +RUN pip3 install --no-cache-dir setuptools==49.6.00 +RUN pip3 install --no-cache-dir wheel==0.35.1 + +# For templating +RUN pip3 install j2cli + +# Install supervisor +RUN pip3 install supervisor==4.2.1 + +# Add support for supervisord to handle startup dependencies +RUN pip3 install supervisord-dependent-startup==1.4.0 + +RUN mkdir -p /etc/supervisor /var/log/supervisor + +RUN apt-get -y purge \ + exim4 \ + exim4-base \ + exim4-config \ + exim4-daemon-light + +{% if docker_base_bullseye_debs.strip() -%} +# Copy locally-built Debian package dependencies +{{ copy_files("debs/", docker_base_bullseye_debs.split(' '), "/debs/") }} + +# Install built Debian packages and implicitly install their dependencies +{{ install_debian_packages(docker_base_bullseye_debs.split(' ')) }} +{%- endif %} + +# Clean up apt +# Remove /var/lib/apt/lists/*, could be obsoleted for derived images +RUN apt-get clean -y && \ + apt-get autoclean -y && \ + apt-get autoremove -y && \ + rm -rf /var/lib/apt/lists/* /tmp/* + +COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"] +COPY ["etc/rsyslog.d/*", "/etc/rsyslog.d/"] +COPY ["root/.vimrc", "/root/.vimrc"] + +RUN ln /usr/bin/vim.tiny /usr/bin/vim + +COPY ["etc/supervisor/supervisord.conf", "/etc/supervisor/"] diff --git a/dockers/docker-base-bullseye/LICENSE b/dockers/docker-base-bullseye/LICENSE new file mode 100644 index 000000000000..03d8f31e513c --- /dev/null +++ b/dockers/docker-base-bullseye/LICENSE @@ -0,0 +1,13 @@ +Copyright 2016 Microsoft, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/dockers/docker-base-bullseye/dpkg_01_drop b/dockers/docker-base-bullseye/dpkg_01_drop new file mode 100644 index 000000000000..d238f4049aff --- /dev/null +++ b/dockers/docker-base-bullseye/dpkg_01_drop @@ -0,0 +1,29 @@ +## Drop unnecessary files +## ref: https://wiki.ubuntu.com/ReducingDiskFootprint + +## Documentation +path-exclude /usr/share/doc/* +# we need to keep copyright files for legal reasons +path-include /usr/share/doc/*/copyright +path-exclude /usr/share/man/* +path-exclude /usr/share/groff/* +path-exclude /usr/share/info/* +# lintian stuff is small, but really unnecessary +path-exclude /usr/share/lintian/* +path-exclude /usr/share/linda/* + +## Translations +path-exclude /usr/share/locale/* + +## Landscape +path-exclude /usr/share/pyshared/twisted/test* +path-exclude /usr/lib/python*/dist-packages/twisted/test* +path-exclude /usr/share/pyshared/twisted/*/test* +path-exclude /usr/lib/python*/dist-packages/twisted/*/test* + +## install the configuration file if it’s currently missing +force-confmiss +## combined with confold: overwrite configuration files that you have not modified +force-confdef +## do not modify the current configuration file, the new version is installed with a .dpkg-dist suffix +force-confold diff --git a/dockers/docker-base-bullseye/etc/rsyslog.conf b/dockers/docker-base-bullseye/etc/rsyslog.conf new file mode 100644 index 000000000000..ef249229ab1e --- /dev/null +++ b/dockers/docker-base-bullseye/etc/rsyslog.conf @@ -0,0 +1,76 @@ +# +# /etc/rsyslog.conf Configuration file for rsyslog. +# +# For more information see +# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html + + +################# +#### MODULES #### +################# + +$ModLoad imuxsock # provides support for local system logging + +# +# Set a rate limit on messages from the container +# +$SystemLogRateLimitInterval 300 +$SystemLogRateLimitBurst 20000 + +#$ModLoad imklog # provides kernel logging support +#$ModLoad immark # provides --MARK-- message capability + +# provides UDP syslog reception +#$ModLoad imudp +#$UDPServerRun 514 + +# provides TCP syslog reception +#$ModLoad imtcp +#$InputTCPServerRun 514 + + +########################### +#### GLOBAL DIRECTIVES #### +########################### + +# Set remote syslog server +template (name="ForwardFormatInContainer" type="string" string="<%PRI%>%TIMESTAMP:::date-rfc3339% %HOSTNAME% %syslogtag%%msg:::sp-if-no-1st-sp%%msg%") +*.* action(type="omfwd" target="127.0.0.1" port="514" protocol="udp" Template="ForwardFormatInContainer") + +# +# Use traditional timestamp format. +# To enable high precision timestamps, comment out the following line. +# +#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat + +# Define a custom template +$template SONiCFileFormat,"%TIMESTAMP%.%timestamp:::date-subseconds% %HOSTNAME% %syslogseverity-text:::uppercase% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n" +$ActionFileDefaultTemplate SONiCFileFormat + +# +# Set the default permissions for all log files. +# +$FileOwner root +$FileGroup adm +$FileCreateMode 0640 +$DirCreateMode 0755 +$Umask 0022 + +# +# Where to place spool and state files +# +$WorkDirectory /var/spool/rsyslog + +# +# Include all config files in /etc/rsyslog.d/ +# +$IncludeConfig /etc/rsyslog.d/*.conf + +# +# Suppress duplicate messages and report "message repeated n times" +# +$RepeatedMsgReduction on + +############### +#### RULES #### +############### diff --git a/dockers/docker-base-bullseye/etc/rsyslog.d/supervisor.conf b/dockers/docker-base-bullseye/etc/rsyslog.d/supervisor.conf new file mode 100644 index 000000000000..fde8d8a6c994 --- /dev/null +++ b/dockers/docker-base-bullseye/etc/rsyslog.d/supervisor.conf @@ -0,0 +1,9 @@ +module(load="imfile" mode="inotify") # Ensure "inotify" mode is used +$WorkDirectory /var/log/supervisor +# Start Monitoring the file +input(type="imfile" + File="/var/log/supervisor/supervisord.log" + Tag="supervisord" + Severity="info" + Facility="local0" + PersistStateInterval="1") diff --git a/dockers/docker-base-bullseye/etc/supervisor/supervisord.conf b/dockers/docker-base-bullseye/etc/supervisor/supervisord.conf new file mode 100644 index 000000000000..6d7d7390e854 --- /dev/null +++ b/dockers/docker-base-bullseye/etc/supervisor/supervisord.conf @@ -0,0 +1,29 @@ +; supervisor config file + +[unix_http_server] +file=/var/run/supervisor.sock ; (the path to the socket file) +chmod=0700 ; socket file mode (default 0700) + +[supervisord] +logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) +pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) +childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP) +user=root + +; the below section must remain in the config file for RPC +; (supervisorctl/web interface) to work, additional interfaces may be +; added by defining them in separate rpcinterface: sections +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[supervisorctl] +serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket + +; The [include] section can just contain the "files" setting. This +; setting can list multiple files (separated by whitespace or +; newlines). It can also contain wildcards. The filenames are +; interpreted as relative to this file. Included files *cannot* +; include files themselves. + +[include] +files = /etc/supervisor/conf.d/*.conf diff --git a/dockers/docker-base-bullseye/no-check-valid-until b/dockers/docker-base-bullseye/no-check-valid-until new file mode 100644 index 000000000000..c7c25d017f7f --- /dev/null +++ b/dockers/docker-base-bullseye/no-check-valid-until @@ -0,0 +1,4 @@ +# Instruct apt-get to NOT check the "Valid Until" date in Release files +# Once the Debian team archives a repo, they stop updating this date + +Acquire::Check-Valid-Until "false"; diff --git a/dockers/docker-base-bullseye/no_install_recommend_suggest b/dockers/docker-base-bullseye/no_install_recommend_suggest new file mode 100644 index 000000000000..b5bca577de1e --- /dev/null +++ b/dockers/docker-base-bullseye/no_install_recommend_suggest @@ -0,0 +1,5 @@ +# Instruct apt-get to NOT install "recommended" or "suggested" packages by +# default when installing a package. + +APT::Install-Recommends "false"; +APT::Install-Suggests "false"; diff --git a/dockers/docker-base-bullseye/root/.vimrc b/dockers/docker-base-bullseye/root/.vimrc new file mode 100644 index 000000000000..5c1ba8a04f47 --- /dev/null +++ b/dockers/docker-base-bullseye/root/.vimrc @@ -0,0 +1,2 @@ +" enable vim features +set nocompatible diff --git a/dockers/docker-base-bullseye/sources.list b/dockers/docker-base-bullseye/sources.list new file mode 100644 index 000000000000..4a68761df7c8 --- /dev/null +++ b/dockers/docker-base-bullseye/sources.list @@ -0,0 +1,13 @@ +## Debian mirror on Microsoft Azure +## Ref: http://debian-archive.trafficmanager.net/ + +deb [arch=amd64] http://debian-archive.trafficmanager.net/debian/ bullseye main contrib non-free +deb-src [arch=amd64] http://debian-archive.trafficmanager.net/debian/ bullseye main contrib non-free +deb [arch=amd64] http://debian-archive.trafficmanager.net/debian-security/ bullseye-security main contrib non-free +deb-src [arch=amd64] http://debian-archive.trafficmanager.net/debian-security/ bullseye-security main contrib non-free +deb [arch=amd64] http://debian-archive.trafficmanager.net/debian/ bullseye-backports main contrib non-free + +# Debian mirror supports multiple versions for a package +deb [arch=amd64] http://packages.trafficmanager.net/debian/debian bullseye main contrib non-free +deb [arch=amd64] http://packages.trafficmanager.net/debian/debian bullseye-updates main contrib non-free +deb [arch=amd64] http://packages.trafficmanager.net/debian/debian bullseye-backports main contrib non-free diff --git a/dockers/docker-base-bullseye/sources.list.arm64 b/dockers/docker-base-bullseye/sources.list.arm64 new file mode 100644 index 000000000000..5a0652aa3c7e --- /dev/null +++ b/dockers/docker-base-bullseye/sources.list.arm64 @@ -0,0 +1,9 @@ +## Debian mirror for ARM repo + +# ARM repo +deb [arch=arm64] http://deb.debian.org/debian bullseye main contrib non-free +deb [arch=arm64] http://deb.debian.org/debian bullseye-updates main contrib non-free +deb [arch=arm64] http://security.debian.org bullseye-security main contrib non-free +deb [arch=arm64] http://deb.debian.org/debian bullseye-backports main +deb [arch=arm64] http://packages.trafficmanager.net/debian/debian bullseye main contrib non-free +deb [arch=arm64] http://packages.trafficmanager.net/debian/debian bullseye-updates main contrib non-free diff --git a/dockers/docker-base-bullseye/sources.list.armhf b/dockers/docker-base-bullseye/sources.list.armhf new file mode 100644 index 000000000000..435f4692de9f --- /dev/null +++ b/dockers/docker-base-bullseye/sources.list.armhf @@ -0,0 +1,9 @@ +## Debian mirror for ARM repo + +# ARM repo +deb [arch=armhf] http://deb.debian.org/debian bullseye main contrib non-free +deb [arch=armhf] http://deb.debian.org/debian bullseye-updates main contrib non-free +deb [arch=armhf] http://security.debian.org bullseye-security main contrib non-free +deb [arch=armhf] http://deb.debian.org/debian bullseye-backports main +deb [arch=armhf] http://packages.trafficmanager.net/debian/debian bullseye main contrib non-free +deb [arch=armhf] http://packages.trafficmanager.net/debian/debian bullseye-updates main contrib non-free diff --git a/dockers/docker-config-engine-bullseye/Dockerfile.j2 b/dockers/docker-config-engine-bullseye/Dockerfile.j2 new file mode 100644 index 000000000000..84785d0669f1 --- /dev/null +++ b/dockers/docker-config-engine-bullseye/Dockerfile.j2 @@ -0,0 +1,52 @@ +{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} +FROM docker-base-bullseye + +## Make apt-get non-interactive +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && \ + apt-get install -y \ + apt-utils \ + build-essential \ + python3-dev + +{%- if CONFIGURED_ARCH == "armhf" or CONFIGURED_ARCH == "arm64" %} +RUN apt-get install -y \ + libxslt-dev \ + libz-dev +{%- endif %} + +# For sonic-config-engine Python 3 package +# Explicitly install pyangbind here, as pyangbind causes enum34 to be installed. +# enum34 causes Python 're' package to not work properly as it redefines an incompatible enum.py module +# https://github.com/robshakir/pyangbind/issues/232 +RUN pip3 install pyangbind==0.8.1 +RUN pip3 uninstall -y enum34 + +{% if docker_config_engine_bullseye_debs.strip() %} +# Copy locally-built Debian package dependencies +{{ copy_files("debs/", docker_config_engine_bullseye_debs.split(' '), "/debs/") }} + +# Install locally-built Debian packages and implicitly install their dependencies +{{ install_debian_packages(docker_config_engine_bullseye_debs.split(' ')) }} +{% endif %} + +{% if docker_config_engine_bullseye_whls.strip() %} +# Copy locally-built Python wheel dependencies +{{ copy_files("python-wheels/", docker_config_engine_bullseye_whls.split(' '), "/python-wheels/") }} + +# Install locally-built Python wheel dependencies +{{ install_python_wheels(docker_config_engine_bullseye_whls.split(' ')) }} +{% endif %} + +# Copy files +COPY ["files/swss_vars.j2", "/usr/share/sonic/templates/"] + +## Clean up +RUN apt-get purge -y \ + python3-dev \ + build-essential && \ + apt-get clean -y && \ + apt-get autoclean -y && \ + apt-get autoremove -y && \ + rm -rf /debs /python-wheels diff --git a/dockers/docker-dhcp-relay/Dockerfile.j2 b/dockers/docker-dhcp-relay/Dockerfile.j2 index a08e74145fe1..2d2afd922471 100644 --- a/dockers/docker-dhcp-relay/Dockerfile.j2 +++ b/dockers/docker-dhcp-relay/Dockerfile.j2 @@ -1,5 +1,5 @@ {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} -FROM docker-config-engine-buster +FROM docker-config-engine-bullseye ARG docker_container_name ARG image_version diff --git a/dockers/docker-dhcp-relay/cli-plugin-tests/test_show_dhcp_relay.py b/dockers/docker-dhcp-relay/cli-plugin-tests/test_show_dhcp_relay.py index 2636a43c7d37..b8219fcc6ad3 100644 --- a/dockers/docker-dhcp-relay/cli-plugin-tests/test_show_dhcp_relay.py +++ b/dockers/docker-dhcp-relay/cli-plugin-tests/test_show_dhcp_relay.py @@ -20,9 +20,9 @@ def test_plugin_registration(self): def test_dhcp_relay_column_output(self): ctx = ( - ({'Vlan100': {'dhcp_servers': ['192.0.0.1', '192.168.0.2'], 'dhcpv6_servers': ['fc02:2000::1', 'fc02:2000::2']}}, {}, {}), + ({'Vlan100': {'dhcp_servers': ['192.0.0.1', '192.168.0.2']}}, {}, {}), (), ) - assert show_dhcp_relay.get_dhcp_helper_address(ctx, 'Vlan100') == '192.0.0.1\n192.168.0.2\nfc02:2000::1\nfc02:2000::2' + assert show_dhcp_relay.get_dhcp_helper_address(ctx, 'Vlan100') == '192.0.0.1\n192.168.0.2' diff --git a/dockers/docker-dhcp-relay/cli/clear/plugins/clear_dhcp6relay_counter.py b/dockers/docker-dhcp-relay/cli/clear/plugins/clear_dhcp6relay_counter.py index b4e158ce7f79..048a83901574 100644 --- a/dockers/docker-dhcp-relay/cli/clear/plugins/clear_dhcp6relay_counter.py +++ b/dockers/docker-dhcp-relay/cli/clear/plugins/clear_dhcp6relay_counter.py @@ -1,6 +1,7 @@ import sys import click -from show.plugins.dhcprelay import DHCPv6_Counter +import importlib +importlib.import_module('show.plugins.dhcp-relay') import utilities_common.cli as clicommon diff --git a/dockers/docker-dhcp-relay/cli/show/plugins/show_dhcp_relay.py b/dockers/docker-dhcp-relay/cli/show/plugins/show_dhcp_relay.py index ffcecaf6017a..2e641c4c4233 100644 --- a/dockers/docker-dhcp-relay/cli/show/plugins/show_dhcp_relay.py +++ b/dockers/docker-dhcp-relay/cli/show/plugins/show_dhcp_relay.py @@ -26,9 +26,8 @@ def get_dhcp_helper_address(ctx, vlan): return "" dhcp_helpers = vlan_config.get('dhcp_servers', []) - dhcpv6_helpers = vlan_config.get('dhcpv6_servers', []) - return '\n'.join(natsorted(dhcp_helpers) + natsorted(dhcpv6_helpers)) + return '\n'.join(natsorted(dhcp_helpers)) vlan.VlanBrief.register_column('DHCP Helper Address', get_dhcp_helper_address) diff --git a/dockers/docker-fpm-frr/Dockerfile.j2 b/dockers/docker-fpm-frr/Dockerfile.j2 index 42df1c6f38f8..f392d4d3a7a6 100644 --- a/dockers/docker-fpm-frr/Dockerfile.j2 +++ b/dockers/docker-fpm-frr/Dockerfile.j2 @@ -1,5 +1,5 @@ {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} -FROM docker-config-engine-buster +FROM docker-swss-layer-buster ARG docker_container_name ARG frr_user_uid diff --git a/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 b/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 index c1616c043f2e..c6643f185742 100644 --- a/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 +++ b/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 @@ -67,7 +67,7 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} bgp bestpath as-path multipath-relax {% endif %} ! -{% if constants.bgp.graceful_restart.enabled is defined and constants.bgp.graceful_restart.enabled %} +{% if constants.bgp.graceful_restart.enabled is defined and constants.bgp.graceful_restart.enabled and DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %} bgp graceful-restart restart-time {{ constants.bgp.graceful_restart.restart_time | default(240) }} bgp graceful-restart bgp graceful-restart preserve-fw-state diff --git a/dockers/docker-macsec/Dockerfile.j2 b/dockers/docker-macsec/Dockerfile.j2 index 9bbfd69e8d5b..0239d6529096 100644 --- a/dockers/docker-macsec/Dockerfile.j2 +++ b/dockers/docker-macsec/Dockerfile.j2 @@ -1,5 +1,5 @@ {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} -FROM docker-config-engine-buster +FROM docker-swss-layer-buster ARG docker_container_name RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf diff --git a/dockers/docker-nat/Dockerfile.j2 b/dockers/docker-nat/Dockerfile.j2 index 36a178a68af2..066de0a70ed0 100644 --- a/dockers/docker-nat/Dockerfile.j2 +++ b/dockers/docker-nat/Dockerfile.j2 @@ -1,5 +1,5 @@ {% from "dockers/dockerfile-macros.j2" import install_debian_packages, copy_files %} -FROM docker-config-engine-buster +FROM docker-swss-layer-buster ARG docker_container_name RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf diff --git a/dockers/docker-orchagent/Dockerfile.j2 b/dockers/docker-orchagent/Dockerfile.j2 index 2a927b5f2b69..bf86e70d520f 100755 --- a/dockers/docker-orchagent/Dockerfile.j2 +++ b/dockers/docker-orchagent/Dockerfile.j2 @@ -1,5 +1,5 @@ {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} -FROM docker-config-engine-buster +FROM docker-swss-layer-buster ARG docker_container_name RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf @@ -19,6 +19,7 @@ RUN apt-get update && \ bridge-utils \ conntrack \ ndppd \ + pciutils \ # Needed for installing netifaces Python package build-essential \ python3-dev @@ -68,7 +69,7 @@ RUN apt-get purge -y \ COPY ["files/arp_update", "/usr/bin"] COPY ["arp_update.conf", "files/arp_update_vars.j2", "/usr/share/sonic/templates/"] COPY ["ndppd.conf", "/usr/share/sonic/templates/"] -COPY ["enable_counters.py", "/usr/bin"] +COPY ["enable_counters.py", "tunnel_packet_handler.py", "/usr/bin/"] COPY ["docker-init.sh", "orchagent.sh", "swssconfig.sh", "buffermgrd.sh", "/usr/bin/"] COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] diff --git a/dockers/docker-orchagent/docker-init.sh b/dockers/docker-orchagent/docker-init.sh index d395f2076e47..86070ff24db9 100755 --- a/dockers/docker-orchagent/docker-init.sh +++ b/dockers/docker-orchagent/docker-init.sh @@ -17,6 +17,11 @@ CFGGEN_PARAMS=" \ " VLAN=$(sonic-cfggen $CFGGEN_PARAMS) +# Executed platform specific initialization tasks. +if [ -x /usr/share/sonic/platform/platform-init ]; then + /usr/share/sonic/platform/platform-init +fi + # Executed HWSKU specific initialization tasks. if [ -x /usr/share/sonic/hwsku/hwsku-init ]; then /usr/share/sonic/hwsku/hwsku-init diff --git a/dockers/docker-orchagent/supervisord.conf.j2 b/dockers/docker-orchagent/supervisord.conf.j2 index 0ba9b8f48015..51ead0db7c3f 100644 --- a/dockers/docker-orchagent/supervisord.conf.j2 +++ b/dockers/docker-orchagent/supervisord.conf.j2 @@ -242,3 +242,15 @@ stderr_logfile=syslog dependent_startup=true dependent_startup_wait_for=swssconfig:exited {%- endif %} + +{% if is_fabric_asic == 0 %} +[program:tunnel_packet_handler] +command=/usr/bin/tunnel_packet_handler.py +priority=12 +autostart=false +autorestart=unexpected +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=swssconfig:exited +{%- endif %} diff --git a/dockers/docker-orchagent/switch.json.j2 b/dockers/docker-orchagent/switch.json.j2 index 4d2a0be1b051..fa0ef4b44ed7 100644 --- a/dockers/docker-orchagent/switch.json.j2 +++ b/dockers/docker-orchagent/switch.json.j2 @@ -20,7 +20,12 @@ "SWITCH_TABLE:switch": { "ecmp_hash_seed": "{{ hash_seed_value }}", "lag_hash_seed": "{{ hash_seed_value }}", - "fdb_aging_time": "600" + "fdb_aging_time": "600", +{% if DEVICE_METADATA.localhost.type and "LeafRouter" in DEVICE_METADATA.localhost.type %} + "ordered_ecmp": "true" +{% else %} + "ordered_ecmp": "false" +{% endif %} }, "OP": "SET" } diff --git a/dockers/docker-orchagent/tunnel_packet_handler.py b/dockers/docker-orchagent/tunnel_packet_handler.py new file mode 100755 index 000000000000..7d9f7f561260 --- /dev/null +++ b/dockers/docker-orchagent/tunnel_packet_handler.py @@ -0,0 +1,326 @@ +#! /usr/bin/env python3 +""" +Adds neighbor to kernel for undeliverable tunnel packets + +When receiving tunnel packets, if the hardware doesn't contain neighbor +information for the inner packet's destination IP, the entire encapsulated +packet is trapped to the CPU. In this case, we should ping the inner +destination IP to trigger the process of obtaining neighbor information +""" +import subprocess +import time + +from datetime import datetime +from ipaddress import ip_interface +from pyroute2 import IPRoute +from scapy.layers.inet import IP +from scapy.layers.inet6 import IPv6 +from scapy.sendrecv import AsyncSniffer +from swsssdk import ConfigDBConnector, SonicV2Connector +from sonic_py_common import logger as log + +logger = log.Logger() + +STATE_DB = 'STATE_DB' +PORTCHANNEL_INTERFACE_TABLE = 'PORTCHANNEL_INTERFACE' +TUNNEL_TABLE = 'TUNNEL' +PEER_SWITCH_TABLE = 'PEER_SWITCH' +INTF_TABLE_TEMPLATE = 'INTERFACE_TABLE|{}|{}' +STATE_KEY = 'state' +TUNNEL_TYPE_KEY = 'tunnel_type' +DST_IP_KEY = 'dst_ip' +ADDRESS_IPV4_KEY = 'address_ipv4' +IPINIP_TUNNEL = 'ipinip' + +RTM_NEWLINK = 'RTM_NEWLINK' + + +class TunnelPacketHandler(object): + + def __init__(self): + self.config_db = ConfigDBConnector() + self.config_db.connect() + self.state_db = SonicV2Connector() + self.state_db.connect(STATE_DB) + self._portchannel_intfs = None + self.up_portchannels = None + self.netlink_api = IPRoute() + + @property + def portchannel_intfs(self): + """ + Gets all portchannel interfaces and IPv4 addresses in config DB + + Returns: + (list) Tuples of a portchannel interface name (str) and + associated IPv4 address (str) + """ + if self._portchannel_intfs is None: + intf_keys = self.config_db.get_keys(PORTCHANNEL_INTERFACE_TABLE) + portchannel_intfs = [] + + for key in intf_keys: + if isinstance(key, tuple) and len(key) > 1: + if ip_interface(key[1]).version == 4: + portchannel_intfs.append(key) + + self._portchannel_intfs = portchannel_intfs + + return self._portchannel_intfs + + def get_portchannel_index_mapping(self): + """ + Gets a mapping of interface kernel indices to portchannel interfaces + + Returns: + (list) integers representing kernel indices + """ + index_map = {} + for portchannel in self.portchannel_intfs: + index = self.netlink_api.link_lookup(ifname=portchannel[0])[0] + index_map[index] = portchannel + + return index_map + + def get_up_portchannels(self): + """ + Returns the portchannels which are operationally up + + Returns: + (list) of interface names which are up, as strings + """ + pc_index_map = self.get_portchannel_index_mapping() + pc_indices = list(pc_index_map.keys()) + link_statuses = self.netlink_api.get_links(*pc_indices) + up_portchannels = [] + + for status in link_statuses: + if status['state'] == 'up': + port_index = status['index'] + up_portchannels.append(pc_index_map[port_index][0]) + + return up_portchannels + + def all_portchannels_established(self): + """ + Checks if the portchannel interfaces are established + + Note that this status does not indicate operational state + Returns: + (bool) True, if all interfaces are established + False, otherwise + """ + intfs = self.portchannel_intfs + for intf in intfs: + intf_table_name = INTF_TABLE_TEMPLATE.format(intf[0], intf[1]) + intf_state = self.state_db.get( + STATE_DB, + intf_table_name, + STATE_KEY + ) + + if intf_state and intf_state.lower() != 'ok': + return False + + return True + + def wait_for_portchannels(self, interval=5, timeout=60): + """ + Continuosly checks if all portchannel host interfaces are established + + Args: + interval: the interval (in seconds) at which to perform the check + timeout: maximum allowed duration (in seconds) to wait for + interfaces to come up + + Raises: + RuntimeError if the timeout duration is reached and interfaces are + still not up + """ + start = datetime.now() + + while (datetime.now() - start).seconds < timeout: + if self.all_portchannels_established(): + logger.log_info("All portchannel intfs are established") + return None + logger.log_info("Not all portchannel intfs are established") + time.sleep(interval) + + raise RuntimeError('Portchannel intfs were not established ' + 'within {}'.format(timeout)) + + def get_ipinip_tunnel_addrs(self): + """ + Get the IP addresses used for the IPinIP tunnel + + These should be the Loopback0 addresses for this device and the + peer device + + Returns: + ((str) self_loopback_ip, (str) peer_loopback_ip) + or + (None, None) If the tunnel type is not IPinIP + or + if an error is encountered. This most likely means + the host device is not a dual ToR device + """ + try: + peer_switch = self.config_db.get_keys(PEER_SWITCH_TABLE)[0] + tunnel = self.config_db.get_keys(TUNNEL_TABLE)[0] + except IndexError: + logger.log_warning('PEER_SWITCH or TUNNEL table' + 'not found in config DB') + return None, None + + try: + tunnel_table = self.config_db.get_entry(TUNNEL_TABLE, tunnel) + tunnel_type = tunnel_table[TUNNEL_TYPE_KEY].lower() + self_loopback_ip = tunnel_table[DST_IP_KEY] + peer_loopback_ip = self.config_db.get_entry( + PEER_SWITCH_TABLE, peer_switch + )[ADDRESS_IPV4_KEY] + except KeyError as e: + logger.log_warning( + 'PEER_SWITCH or TUNNEL table missing data, ' + 'could not find key {}' + .format(e) + ) + return None, None + + if tunnel_type == IPINIP_TUNNEL: + return self_loopback_ip, peer_loopback_ip + + return None, None + + def get_inner_pkt_type(self, packet): + """ + Get the type of an inner encapsulated packet + + Returns: + (str) 'v4' if the inner packet is IPv4 + (str) 'v6' if the inner packet is IPv6 + (bool) False if `packet` is not an IPinIP packet + """ + if packet.haslayer(IP): + # Determine inner packet type based on IP protocol number + # The outer packet type should always be IPv4 + if packet[IP].proto == 4: + return IP + elif packet[IP].proto == 41: + return IPv6 + return False + + def wait_for_netlink_msgs(self): + """ + Gathers any RTM_NEWLINK messages + + Returns: + (list) containing any received messages + """ + msgs = [] + with IPRoute() as ipr: + ipr.bind() + for msg in ipr.get(): + if msg['event'] == RTM_NEWLINK: + msgs.append(msg) + + return msgs + + def sniffer_restart_required(self, messages): + """ + Determines if the packet sniffer needs to be restarted + + A restart is required if all of the following conditions are met: + 1. A netlink message of type RTM_NEWLINK is received + (this is checked by `wait_for_netlink_msgs`) + 2. The interface index of the message corresponds to a portchannel + interface + 3. The state of the interface in the message is 'up' + Here, we do not care about an interface going down since + the sniffer is able to continue sniffing on the other + interfaces. However, if an interface has gone down and + come back up, we need to restart the sniffer to be able + to sniff traffic on the interface that has come back up. + """ + pc_index_map = self.get_portchannel_index_mapping() + for msg in messages: + if msg['index'] in pc_index_map: + if msg['state'] == 'up': + logger.log_info('{} came back up, sniffer restart required' + .format(pc_index_map[msg['index']])) + return True + return False + + def listen_for_tunnel_pkts(self): + """ + Listens for tunnel packets that are trapped to CPU + + These packets may be trapped if there is no neighbor info for the + inner packet destination IP in the hardware. + """ + + def _ping_inner_dst(packet): + """ + Pings the inner destination IP for an encapsulated packet + + Args: + packet: The encapsulated packet received + """ + inner_packet_type = self.get_inner_pkt_type(packet) + if inner_packet_type and packet[IP].dst == self_ip: + cmds = ['timeout', '0.2', 'ping', '-c1', + '-W1', '-i0', '-n', '-q'] + if inner_packet_type == IPv6: + cmds.append('-6') + dst_ip = packet[IP].payload[inner_packet_type].dst + cmds.append(dst_ip) + logger.log_info("Running command '{}'".format(' '.join(cmds))) + subprocess.run(cmds, stdout=subprocess.DEVNULL) + + self_ip, peer_ip = self.get_ipinip_tunnel_addrs() + if self_ip is None or peer_ip is None: + logger.log_notice('Could not get tunnel addresses from ' + 'config DB, exiting...') + return None + + packet_filter = 'host {} and host {}'.format(self_ip, peer_ip) + logger.log_notice('Starting tunnel packet handler for {}' + .format(packet_filter)) + + sniff_intfs = self.get_up_portchannels() + logger.log_info("Listening on interfaces {}".format(sniff_intfs)) + + sniffer = AsyncSniffer( + iface=sniff_intfs, + filter=packet_filter, + prn=_ping_inner_dst + + ) + sniffer.start() + while True: + msgs = self.wait_for_netlink_msgs() + if self.sniffer_restart_required(msgs): + sniffer.stop() + sniff_intfs = self.get_up_portchannels() + logger.log_notice('Restarting tunnel packet handler on ' + 'interfaces {}'.format(sniff_intfs)) + sniffer = AsyncSniffer( + iface=sniff_intfs, + filter=packet_filter, + prn=_ping_inner_dst + ) + sniffer.start() + + def run(self): + self.wait_for_portchannels() + self.listen_for_tunnel_pkts() + + +def main(): + logger.set_min_log_priority_info() + handler = TunnelPacketHandler() + handler.run() + + +if __name__ == "__main__": + main() diff --git a/dockers/docker-platform-monitor/Dockerfile.j2 b/dockers/docker-platform-monitor/Dockerfile.j2 index 21536f43c013..4f5e941dd92a 100755 --- a/dockers/docker-platform-monitor/Dockerfile.j2 +++ b/dockers/docker-platform-monitor/Dockerfile.j2 @@ -20,7 +20,6 @@ RUN apt-get update && \ librrd8 \ librrd-dev \ rrdtool \ - python-smbus \ python3-smbus \ dmidecode \ i2c-tools \ @@ -28,29 +27,15 @@ RUN apt-get update && \ python3-jsonschema \ libpci3 -# TODO: Remove these lines once we no longer need Python 2 -RUN apt-get install -f -y python-dev python-pip -RUN pip2 install --upgrade 'pip<21' -RUN apt-get purge -y python-pip -RUN pip2 install 'setuptools==40.8.0' - # On Arista devices, the sonic_platform wheel is not installed in the container. # Instead, the installation directory is mounted from the host OS. However, this method # doesn't ensure all dependencies are installed in the container. So here we # install any dependencies required by the Arista sonic_platform package. # TODO: eliminate the need to install these explicitly. -# NOTE: Only install enum34 for Python 2, as our version of Python 3 is 3.7, which -# contains 'enum' as part of the standard library. Installing enum34 there will -# cause conflicts. -RUN pip2 install enum34 \ - grpcio==1.39.0 \ - grpcio-tools==1.39.0 - RUN pip3 install grpcio==1.39.0 \ grpcio-tools==1.39.0 # Barefoot platform vendors' sonic_platform packages import the Python 'thrift' library -RUN pip2 install thrift==0.13.0 RUN pip3 install thrift==0.13.0 {% if docker_platform_monitor_debs.strip() -%} @@ -78,9 +63,6 @@ RUN pip3 install thrift==0.13.0 {% endif %} -# TODO: Remove this line once we no longer need Python 2 -RUN apt-get purge -y python-dev - # Clean up RUN apt-get purge -y \ build-essential \ diff --git a/dockers/docker-ptf/Dockerfile.j2 b/dockers/docker-ptf/Dockerfile.j2 index f403054dbb37..b152e94e99b0 100644 --- a/dockers/docker-ptf/Dockerfile.j2 +++ b/dockers/docker-ptf/Dockerfile.j2 @@ -85,6 +85,14 @@ RUN rm -rf /debs \ && make install \ && cd .. \ && rm -fr sflowtool \ + && git clone https://github.com/dyninc/OpenBFDD.git \ + && cd OpenBFDD \ + && ./autogen.sh \ + && ./configure \ + && make \ + && make install \ + && cd .. \ + && rm -fr OpenBFDD \ && wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ && tar xvfz 1.0.0.tar.gz \ && cd nanomsg-1.0.0 \ diff --git a/dockers/docker-sflow/Dockerfile.j2 b/dockers/docker-sflow/Dockerfile.j2 index 476ff3514ace..c8d0757d5fc5 100644 --- a/dockers/docker-sflow/Dockerfile.j2 +++ b/dockers/docker-sflow/Dockerfile.j2 @@ -1,5 +1,5 @@ {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} -FROM docker-config-engine-buster +FROM docker-swss-layer-buster ARG docker_container_name RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf diff --git a/dockers/docker-snmp/supervisord.conf b/dockers/docker-snmp/supervisord.conf index 06e11eb5fbed..3d11cc48eafd 100644 --- a/dockers/docker-snmp/supervisord.conf +++ b/dockers/docker-snmp/supervisord.conf @@ -40,7 +40,7 @@ dependent_startup=true dependent_startup_wait_for=rsyslogd:running [program:snmpd] -command=/usr/sbin/snmpd -f -LS4d -u Debian-snmp -g Debian-snmp -I -smux,mteTrigger,mteTriggerConf,ifTable,ifXTable,inetCidrRouteTable,ipCidrRouteTable,ip,disk_hw -p /run/snmpd.pid +command=/usr/sbin/snmpd -f -LS0-2d -u Debian-snmp -g Debian-snmp -I -smux,mteTrigger,mteTriggerConf,ifTable,ifXTable,inetCidrRouteTable,ipCidrRouteTable,ip,disk_hw -p /run/snmpd.pid priority=3 autostart=false autorestart=false diff --git a/dockers/docker-sonic-mgmt/Dockerfile.j2 b/dockers/docker-sonic-mgmt/Dockerfile.j2 index 23470367ca14..aa0e18ab255f 100755 --- a/dockers/docker-sonic-mgmt/Dockerfile.j2 +++ b/dockers/docker-sonic-mgmt/Dockerfile.j2 @@ -56,6 +56,7 @@ RUN pip install cffi==1.10.0 \ psutil \ pyasn1==0.1.9 \ pyfiglet \ + lazy-object-proxy==1.6.0 \ pylint==1.8.1 \ pyro4 \ pysnmp==4.2.5 \ diff --git a/dockers/docker-sonic-restapi/Dockerfile.j2 b/dockers/docker-sonic-restapi/Dockerfile.j2 index 837796e66d82..43bc86ee6b68 100644 --- a/dockers/docker-sonic-restapi/Dockerfile.j2 +++ b/dockers/docker-sonic-restapi/Dockerfile.j2 @@ -1,5 +1,5 @@ {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} -FROM docker-config-engine-stretch +FROM docker-config-engine-bullseye ARG docker_container_name RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf diff --git a/dockers/docker-sonic-telemetry/Dockerfile.j2 b/dockers/docker-sonic-telemetry/Dockerfile.j2 index 88ff94318208..a7a45ab48c22 100644 --- a/dockers/docker-sonic-telemetry/Dockerfile.j2 +++ b/dockers/docker-sonic-telemetry/Dockerfile.j2 @@ -1,5 +1,5 @@ {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} -FROM docker-config-engine-buster +FROM docker-config-engine-bullseye ARG docker_container_name ARG image_version diff --git a/dockers/docker-swss-layer-buster/Dockerfile.j2 b/dockers/docker-swss-layer-buster/Dockerfile.j2 new file mode 100644 index 000000000000..e8dcb9472a26 --- /dev/null +++ b/dockers/docker-swss-layer-buster/Dockerfile.j2 @@ -0,0 +1,22 @@ +{% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} +FROM docker-config-engine-buster + +## Make apt-get non-interactive +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update + +{% if docker_swss_layer_buster_debs.strip() -%} +# Copy locally-built Debian package dependencies +{{ copy_files("debs/", docker_swss_layer_buster_debs.split(' '), "/debs/") }} + +# Install locally-built Debian packages and implicitly install their dependencies +{{ install_debian_packages(docker_swss_layer_buster_debs.split(' ')) }} +{%- endif %} + +RUN apt-get clean -y && \ + apt-get autoclean -y && \ + apt-get autoremove -y && \ + rm -rf /debs + +ENTRYPOINT ["/usr/local/bin/supervisord"] diff --git a/dockers/docker-teamd/Dockerfile.j2 b/dockers/docker-teamd/Dockerfile.j2 index 7f4db2936857..e02000abb1c6 100644 --- a/dockers/docker-teamd/Dockerfile.j2 +++ b/dockers/docker-teamd/Dockerfile.j2 @@ -1,5 +1,5 @@ {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} -FROM docker-config-engine-buster +FROM docker-swss-layer-buster ARG docker_container_name RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index be0a851fc2f5..e16ec4e20eee 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -368,6 +368,7 @@ start() { fi {%- if docker_container_name == "database" %} + NET="bridge" DB_OPT=$DB_OPT" -v /var/run/redis$DEV:/var/run/redis:rw " {%- else %} NET="container:database$DEV" diff --git a/files/build_templates/gbsyncd.service.j2 b/files/build_templates/gbsyncd.service.j2 deleted file mode 100644 index 732d9c893367..000000000000 --- a/files/build_templates/gbsyncd.service.j2 +++ /dev/null @@ -1,22 +0,0 @@ -[Unit] -Description={{docker_container_name}} service -Requires=database.service updategraph.service -ConditionPathExists=!/usr/share/sonic/hwsku/gearbox_config.json -After=database.service updategraph.service -After=interfaces-config.service -After=swss.service -BindsTo=sonic.target -After=sonic.target -Before=ntp-config.service - -[Service] -User=root -Environment=sonic_asic_platform={{ sonic_asic_platform }} -Environment=gbsyncd_platform={{ docker_container_name }} -ExecCondition=/usr/bin/gbsyncd-platform.sh -ExecStartPre=/usr/local/bin/gbsyncd.sh start -ExecStart=/usr/local/bin/gbsyncd.sh wait -ExecStop=/usr/local/bin/gbsyncd.sh stop - -[Install] -WantedBy=sonic.target diff --git a/files/build_templates/init_cfg.json.j2 b/files/build_templates/init_cfg.json.j2 index 741f31281555..e1320214e02c 100644 --- a/files/build_templates/init_cfg.json.j2 +++ b/files/build_templates/init_cfg.json.j2 @@ -13,7 +13,7 @@ {%- for crm_res in ["ipv4_route", "ipv6_route", "ipv4_nexthop", "ipv6_nexthop", "ipv4_neighbor", "ipv6_neighbor", "nexthop_group_member", "nexthop_group", "acl_table", "acl_group", "acl_entry", "acl_counter", "fdb_entry", "snat_entry", "dnat_entry", - "ipmc_entry", "mpls_inseg", "mpls_nexthop", "srv6_my_sid_entry", "srv6_nexthop"] %} + "ipmc_entry", "mpls_inseg", "mpls_nexthop"] %} "{{crm_res}}_threshold_type": "percentage", "{{crm_res}}_low_threshold": "70", "{{crm_res}}_high_threshold": "85"{% if not loop.last %},{% endif -%} diff --git a/files/build_templates/per_namespace/gbsyncd.service.j2 b/files/build_templates/per_namespace/gbsyncd.service.j2 new file mode 100644 index 000000000000..90a92b7e8506 --- /dev/null +++ b/files/build_templates/per_namespace/gbsyncd.service.j2 @@ -0,0 +1,22 @@ +[Unit] +Description={{docker_container_name}} service +Requires=database{% if multi_instance == 'true' %}@%i{% endif %}.service updategraph.service +ConditionPathExists=!/usr/share/sonic/hwsku/gearbox_config.json +After=database{% if multi_instance == 'true' %}@%i{% endif %}.service updategraph.service +After=interfaces-config.service +After=swss{% if multi_instance == 'true' %}@%i{% endif %}.service +BindsTo=sonic.target +After=sonic.target +Before=ntp-config.service + +[Service] +User=root +Environment=sonic_asic_platform={{ sonic_asic_platform }} +Environment=gbsyncd_platform={{ docker_container_name }} +ExecCondition=/usr/bin/gbsyncd-platform.sh +ExecStartPre=/usr/local/bin/gbsyncd.sh start{% if multi_instance == 'true' %} %i{% endif %} +ExecStart=/usr/local/bin/gbsyncd.sh wait{% if multi_instance == 'true' %} %i{% endif %} +ExecStop=/usr/local/bin/gbsyncd.sh stop{% if multi_instance == 'true' %} %i{% endif %} + +[Install] +WantedBy=sonic.target diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 6cd852e6e8ea..3efb5ae0690b 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -327,6 +327,8 @@ sudo chmod 755 $FILESYSTEM_ROOT/usr/bin/memory_checker sudo cp $IMAGE_CONFIGS/monit/restart_service $FILESYSTEM_ROOT/usr/bin/ sudo chmod 755 $FILESYSTEM_ROOT/usr/bin/restart_service +# Install custom-built smartmontools +sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/smartmontools_*.deb # Install custom-built openssh sshd sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/openssh-server_*.deb @@ -377,6 +379,10 @@ echo "system-health.service" | sudo tee -a $GENERATED_SERVICE_FILE # Copy logrotate.d configuration files sudo cp -f $IMAGE_CONFIGS/logrotate/logrotate.d/* $FILESYSTEM_ROOT/etc/logrotate.d/ +sudo cp $IMAGE_CONFIGS/logrotate/rsyslog.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/ +sudo cp $IMAGE_CONFIGS/logrotate/logrotate-config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM +sudo cp $IMAGE_CONFIGS/logrotate/logrotate-config.sh $FILESYSTEM_ROOT/usr/bin/ +echo "logrotate-config.service" | sudo tee -a $GENERATED_SERVICE_FILE # Copy systemd-journald configuration files sudo cp -f $IMAGE_CONFIGS/systemd/journald.conf $FILESYSTEM_ROOT/etc/systemd/ @@ -836,6 +842,7 @@ sudo cp $files_path/$ISSU_VERSION_FILE $FILESYSTEM_ROOT/etc/mlnx/issu-version sudo cp $files_path/$MLNX_FFB_SCRIPT $FILESYSTEM_ROOT/usr/bin/mlnx-ffb.sh sudo cp $files_path/$MLNX_ONIE_FW_UPDATE $FILESYSTEM_ROOT/usr/bin/$MLNX_ONIE_FW_UPDATE sudo cp $files_path/$MLNX_SSD_FW_UPDATE $FILESYSTEM_ROOT/usr/bin/$MLNX_SSD_FW_UPDATE +sudo cp $files_path/$MLNX_INSTALL_PENDING_FW $FILESYSTEM_ROOT/usr/bin/$MLNX_INSTALL_PENDING_FW j2 platform/mellanox/mlnx-fw-upgrade.j2 | sudo tee $FILESYSTEM_ROOT/usr/bin/mlnx-fw-upgrade.sh sudo chmod 755 $FILESYSTEM_ROOT/usr/bin/mlnx-fw-upgrade.sh diff --git a/files/image_config/logrotate/logrotate-config.service b/files/image_config/logrotate/logrotate-config.service new file mode 100644 index 000000000000..b965e4b32425 --- /dev/null +++ b/files/image_config/logrotate/logrotate-config.service @@ -0,0 +1,12 @@ +[Unit] +Description=Update logrotate configuration +Requires=updategraph.service +After=updategraph.service + +[Service] +Type=oneshot +ExecStart=/usr/bin/logrotate-config.sh + +[Install] +WantedBy=multi-user.target + diff --git a/files/image_config/logrotate/logrotate-config.sh b/files/image_config/logrotate/logrotate-config.sh new file mode 100755 index 000000000000..76caec6f035d --- /dev/null +++ b/files/image_config/logrotate/logrotate-config.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog.j2 -a "{\"var_log_kb\":$(df -k /var/log | sed -n 2p | awk '{ print $2 }') }" > /etc/logrotate.d/rsyslog + diff --git a/files/image_config/logrotate/logrotate.d/rsyslog b/files/image_config/logrotate/rsyslog.j2 similarity index 97% rename from files/image_config/logrotate/logrotate.d/rsyslog rename to files/image_config/logrotate/rsyslog.j2 index 60894a00f769..dd360dc8608e 100644 --- a/files/image_config/logrotate/logrotate.d/rsyslog +++ b/files/image_config/logrotate/rsyslog.j2 @@ -35,7 +35,11 @@ /var/log/swss/swss*.rec /var/log/swss/responsepublisher.rec { +{% if var_log_kb <= 204800 %} size 1M +{% else %} + size 16M +{% endif %} rotate 5000 missingok notifempty @@ -53,7 +57,7 @@ # should be disabled, just in case they get created and rotated RESERVED_SPACE_KB=4096 - VAR_LOG_SIZE_KB=$(df -k /var/log | sed -n 2p | awk '{ print $2 }') + VARL_LOG_SIZE_KB={{var_log_kb}} # Limit usable space to 90% of the partition minus the reserved space for other logs USABLE_SPACE_KB=$(( (VAR_LOG_SIZE_KB * 90 / 100) - RESERVED_SPACE_KB)) diff --git a/files/image_config/platform/rc.local b/files/image_config/platform/rc.local index 57fd8c4b062b..b01c802f086f 100755 --- a/files/image_config/platform/rc.local +++ b/files/image_config/platform/rc.local @@ -373,7 +373,7 @@ if [ -f $FIRST_BOOT_FILE ]; then mkdir -p /var/platform # Kdump tools configuration - sed -i -e "s/__PLATFORM__/$platform/g" /etc/default/kdump-tools + [ -f /etc/default/kdump-tools ] && sed -i -e "s/__PLATFORM__/$platform/g" /etc/default/kdump-tools firsttime_exit fi diff --git a/files/image_config/sudoers/sudoers b/files/image_config/sudoers/sudoers index 42dd6d5ec751..f09445e1ed67 100644 --- a/files/image_config/sudoers/sudoers +++ b/files/image_config/sudoers/sudoers @@ -46,6 +46,10 @@ Cmnd_Alias READ_ONLY_CMDS = /bin/cat /var/log/syslog*, \ Cmnd_Alias PASSWD_CMDS = /usr/local/bin/config tacacs passkey *, \ + /usr/local/bin/config radius passkey *, \ + /usr/local/bin/config snmp community add *, \ + /usr/local/bin/config snmp community del *, \ + /usr/local/bin/config snmp community replace * *, \ /usr/sbin/chpasswd * # User privilege specification diff --git a/platform/barefoot/bfn-modules/debian/control b/platform/barefoot/bfn-modules/debian/control index 88c1e9458862..9023bdd63474 100644 --- a/platform/barefoot/bfn-modules/debian/control +++ b/platform/barefoot/bfn-modules/debian/control @@ -2,7 +2,7 @@ Source: bfn-modules Section: main Priority: extra Maintainer: support -Build-Depends: debhelper (>= 8.0.0), bzip2 +Build-Depends: debhelper (>= 8.0.0), bzip2, python3 Standards-Version: 3.9.3 Package: bfn-modules diff --git a/platform/barefoot/bfn-modules/debian/rules b/platform/barefoot/bfn-modules/debian/rules index c588b075e5e7..ca467222d4a6 100755 --- a/platform/barefoot/bfn-modules/debian/rules +++ b/platform/barefoot/bfn-modules/debian/rules @@ -8,7 +8,7 @@ KERNEL_SRC := /lib/modules/$(KVERSION) MODULE_SRC := $(shell pwd)/modules %: - dh $@ + dh $@ --with python3 override_dh_auto_build: make -C $(KERNEL_SRC)/build M=$(MODULE_SRC) diff --git a/platform/barefoot/bfn-platform.mk b/platform/barefoot/bfn-platform.mk index 6e7960277265..077ee109f9cd 100644 --- a/platform/barefoot/bfn-platform.mk +++ b/platform/barefoot/bfn-platform.mk @@ -1,4 +1,4 @@ -BFN_PLATFORM = bfnplatform_20211117_sai_1.9.1_deb10.deb +BFN_PLATFORM = bfnplatform_20211216_sai_1.9.1_deb10.deb $(BFN_PLATFORM)_URL = "https://github.com/barefootnetworks/sonic-release-pkgs/raw/dev/$(BFN_PLATFORM)" SONIC_ONLINE_DEBS += $(BFN_PLATFORM) diff --git a/platform/barefoot/bfn-sai.mk b/platform/barefoot/bfn-sai.mk index 4129dc8530c7..1e837ba4a90c 100644 --- a/platform/barefoot/bfn-sai.mk +++ b/platform/barefoot/bfn-sai.mk @@ -1,4 +1,4 @@ -BFN_SAI = bfnsdk_20211117_sai_1.9.1_deb10.deb +BFN_SAI = bfnsdk_20211216_sai_1.9.1_deb10.deb $(BFN_SAI)_URL = "https://github.com/barefootnetworks/sonic-release-pkgs/raw/dev/$(BFN_SAI)" $(BFN_SAI)_DEPENDS += $(LIBNL_GENL3_DEV) diff --git a/platform/barefoot/sonic-platform-modules-arista b/platform/barefoot/sonic-platform-modules-arista index 65399c088de6..376e6a22debb 160000 --- a/platform/barefoot/sonic-platform-modules-arista +++ b/platform/barefoot/sonic-platform-modules-arista @@ -1 +1 @@ -Subproject commit 65399c088de6f79161752659e2a0dd1cec1fecd0 +Subproject commit 376e6a22debbc5880ee91fd02c0c2023d347884e diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/debian/control b/platform/barefoot/sonic-platform-modules-bfn-montara/debian/control index ebafd6a52ba1..5c5d58b9bd53 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/debian/control +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/debian/control @@ -2,7 +2,7 @@ Source: sonic-platform-modules-bfn-montara Section: main Priority: extra Maintainer: Support -Build-Depends: debhelper (>= 9.0.0), bzip2 +Build-Depends: debhelper (>= 9.0.0), bzip2, python3 Standards-Version: 3.9.3 Package: sonic-platform-modules-bfn-montara diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/debian/rules b/platform/barefoot/sonic-platform-modules-bfn-montara/debian/rules index 32036bb90803..5e14ab42f75d 100755 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/debian/rules +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/debian/rules @@ -8,7 +8,7 @@ BUILD_DIR := $(shell pwd)/build WHEEL_BUILD_DIR := $(BUILD_DIR)/wheel %: - dh $@ + dh $@ --with python3 --buildsystem=pybuild override_dh_auto_build: set -e diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/chassis.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/chassis.py index 319d29ef1727..85f860b377f5 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/chassis.py +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/chassis.py @@ -1,13 +1,22 @@ #!/usr/bin/env python try: - import sys + import time + import syslog + from sonic_platform_base.chassis_base import ChassisBase - from sonic_platform.sfp import Sfp, sfp_list_get + from sonic_platform.sfp import Sfp from sonic_platform.psu import psu_list_get from sonic_platform.fan_drawer import fan_drawer_list_get from sonic_platform.thermal import thermal_list_get from eeprom import Eeprom + from sonic_platform.thermal_manager import ThermalManager + + from sonic_platform.platform_thrift_client import pltfm_mgr_ready + from sonic_platform.platform_thrift_client import thrift_try + + from sonic_py_common import device_info + except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -15,14 +24,29 @@ class Chassis(ChassisBase): """ Platform-specific Chassis class """ + + PORT_START = 1 + PORT_END = 0 + PORTS_IN_BLOCK = 0 + QSFP_PORT_START = 1 + QSFP_PORT_END = 0 + QSFP_CHECK_INTERVAL = 4 + def __init__(self): ChassisBase.__init__(self) self.__eeprom = None self.__fan_drawers = None + self.__fan_list = None self.__thermals = None self.__psu_list = None self.__sfp_list = None + self.__thermal_mngr = None + self.__polling_thermal_time = 30 + + self.ready = False + self.phy_port_cur_state = {} + self.qsfp_interval = self.QSFP_CHECK_INTERVAL @property def _eeprom(self): @@ -44,6 +68,18 @@ def _fan_drawer_list(self): def _fan_drawer_list(self, value): pass + @property + def _fan_list(self): + if self.__fan_list is None: + self.__fan_list = [] + for fan_drawer in self._fan_drawer_list: + self.__fan_list.extend(fan_drawer._fan_list) + return self.__fan_list + + @_fan_list.setter + def _fan_list(self, value): + pass + @property def _thermal_list(self): if self.__thermals is None: @@ -67,13 +103,44 @@ def _psu_list(self, value): @property def _sfp_list(self): if self.__sfp_list is None: - self.__sfp_list = sfp_list_get() + self.__update_port_info() + self.__sfp_list = [] + for index in range(self.PORT_START, self.PORT_END + 1): + sfp_node = Sfp(index) + self.__sfp_list.append(sfp_node) return self.__sfp_list @_sfp_list.setter def _sfp_list(self, value): pass + @property + def _thermal_mngr(self): + if self.__thermal_mngr is None: + self.__thermal_mngr = ThermalManager(self.__polling_thermal_time) + return self.__thermal_mngr + + @_thermal_mngr.setter + def _thermal_mngr(self, value): + self.__thermal_mngr = ThermalManager(value) + + def __update_port_info(self): + def qsfp_max_port_get(client): + return client.pltfm_mgr.pltfm_mgr_qsfp_get_max_port() + + if self.QSFP_PORT_END == 0: + platform = device_info.get_platform() + self.QSFP_PORT_END = thrift_try(qsfp_max_port_get) + exclude_cpu_port = [ + "x86_64-accton_as9516_32d-r0", + "x86_64-accton_as9516bf_32d-r0", + "x86_64-accton_wedge100bf_32x-r0" + ] + if platform in exclude_cpu_port: + self.QSFP_PORT_END -= 1 + self.PORT_END = self.QSFP_PORT_END + self.PORTS_IN_BLOCK = self.QSFP_PORT_END + def get_name(self): """ Retrieves the name of the chassis @@ -106,6 +173,14 @@ def get_serial(self): """ return self._eeprom.serial_number_str() + def get_revision(self): + """ + Retrieves the revision number of the chassis (Service tag) + Returns: + string: Revision number of chassis + """ + return self._eeprom.revision_str() + def get_sfp(self, index): """ Retrieves sfp represented by (1-based) index @@ -124,7 +199,7 @@ def get_sfp(self, index): try: sfp = self._sfp_list[index-1] except IndexError: - sys.stderr.write("SFP index {} out of range (1-{})\n".format( + syslog.syslog(syslog.LOG_ERR, "SFP index {} out of range (1-{})\n".format( index, len(self._sfp_list)-1)) return sfp @@ -158,8 +233,60 @@ def get_system_eeprom_info(self): """ return self._eeprom.system_eeprom_info() + def __get_transceiver_change_event(self, timeout=0): + forever = False + if timeout == 0: + forever = True + elif timeout > 0: + timeout = timeout / float(1000) # Convert to secs + else: + syslog.syslog(syslog.LOG_ERR, "Invalid timeout value {}".format(timeout)) + return False, {} + + phy_port_dict = {} if self.ready else {'-1': 'system_not_ready'} + + while forever or timeout > 0: + if not self.ready: + if pltfm_mgr_ready(): + self.ready = True + phy_port_dict = {} + + if self.ready and self.qsfp_interval == 0: + self.qsfp_interval = self.QSFP_CHECK_INTERVAL + + # Get presence of each SFP + for port in range(self.PORT_START, self.PORT_END + 1): + try: + sfp_resent = self.get_sfp(port).get_presence() + except Exception: + sfp_resent = False + sfp_state = '1' if sfp_resent else '0' + + if port in self.phy_port_cur_state: + if self.phy_port_cur_state[port] != sfp_state: + phy_port_dict[port] = sfp_state + else: + phy_port_dict[port] = sfp_state + + # Update port current state + self.phy_port_cur_state[port] = sfp_state + + # Break if tranceiver state has changed + if phy_port_dict: + break + + if timeout: + timeout -= 1 + + if self.qsfp_interval: + self.qsfp_interval -= 1 + + time.sleep(1) + + return self.ready, phy_port_dict + def get_change_event(self, timeout=0): - ready, event_sfp = Sfp.get_transceiver_change_event(timeout) + ready, event_sfp = self.__get_transceiver_change_event(timeout) return ready, { 'sfp': event_sfp } if ready else {} def get_reboot_cause(self): @@ -174,3 +301,55 @@ def get_reboot_cause(self): to pass a description of the reboot cause. """ return self.REBOOT_CAUSE_NON_HARDWARE, '' + + 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): + self.system_led = "" + return True + + def set_status_led(self, color): + """ + Sets the state of the system LED + + Args: + color: A string representing the color with which to set the + system LED + + Returns: + bool: True if system LED state is set successfully, False if not + """ + self.system_led = color + return True + + def get_status_led(self): + """ + Gets the state of the system LED + + Returns: + A string, one of the valid LED color strings which could be vendor + specified. + """ + return self.system_led + + def get_thermal_manager(self): + return self._thermal_mngr + + def __del__(self): + if self.__thermal_mngr is not None: + self.__thermal_mngr.stop() diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/eeprom.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/eeprom.py index 00e6e54fb33f..ec7112b3c093 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/eeprom.py +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/eeprom.py @@ -24,20 +24,21 @@ _platform_eeprom_map = { - "prod_name" : ("Product Name", "0x21", 12), - "odm_pcba_part_num" : ("Part Number", "0x22", 13), - "prod_ser_num" : ("Serial Number", "0x23", 12), - "ext_mac_addr" : ("Extended MAC Address Base", "0x24", 12), - "sys_mfg_date" : ("System Manufacturing Date", "0x25", 4), - "prod_ver" : ("Product Version", "0x26", 1), - "ext_mac_addr_size" : ("Extende MAC Address Size", "0x2A", 2), - "sys_mfger" : ("Manufacturer", "0x2B", 8) + "prod_name" : ("Product Name", "0x21", 12), + "odm_pcba_part_num" : ("Part Number", "0x22", 13), + "prod_ser_num" : ("Serial Number", "0x23", 12), + "ext_mac_addr" : ("Extended MAC Address Base", "0x24", 12), + "sys_mfg_date" : ("System Manufacturing Date", "0x25", 4), + "prod_ver" : ("Product Version", "0x26", 1), + "ext_mac_addr_size" : ("Extende MAC Address Size", "0x2A", 2), + "sys_mfger" : ("Manufacturer", "0x2B", 8) } -_product_dict = { "Montara" : "Wedge100BF-32X-O-AC-F-BF", - "Lower MAV" : "Wedge100BF-65X-O-AC-F-BF", - "Upper MAV" : "Wedge100BF-65X-O-AC-F-BF" - } +_product_dict = { + "Montara" : "Wedge100BF-32X-O-AC-F-BF", + "Lower MAV" : "Wedge100BF-65X-O-AC-F-BF", + "Upper MAV" : "Wedge100BF-65X-O-AC-F-BF" +} _EEPROM_SYMLINK = "/var/run/platform/eeprom/syseeprom" _EEPROM_STATUS = "/var/run/platform/eeprom/status" @@ -148,3 +149,6 @@ def part_number_str(self): def modelstr(self): return self.__tlv_get(self._TLV_CODE_PRODUCT_NAME) + + def revision_str(self): + return self.__tlv_get(self._TLV_CODE_LABEL_REVISION) diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/fan.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/fan.py new file mode 100644 index 000000000000..c13382fddb55 --- /dev/null +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/fan.py @@ -0,0 +1,105 @@ +try: + from sonic_platform.platform_thrift_client import thrift_try + from sonic_platform_base.fan_base import FanBase + from sonic_py_common import device_info +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +def _fan_info_get(fan_num, cb, default=None): + def get_data(client): + return client.pltfm_mgr.pltfm_mgr_fan_info_get(fan_num) + fan_info = thrift_try(get_data) + if fan_num == fan_info.fan_num: + return cb(fan_info) + if default is None: + raise LookupError + return default + +# Fan -> FanBase -> DeviceBase +class Fan(FanBase): + def __init__(self, index, fantrayindex): + self.__index = index + self.__fantrayindex = fantrayindex + + # FanBase interface methods: + # returns speed in percents + def get_speed(self): + def cb(info): return info.percent + return _fan_info_get(self.__index, cb, 0) + + def set_speed(self, percent): + # Fan tray speed controlled by BMC + return False + + # DeviceBase interface methods: + def get_name(self): + return "counter-rotating-fan-{}".format((self.__fantrayindex - 1) * self.__index + self.__index) + + def get_presence(self): + return _fan_info_get(self.__index, lambda _: True, False) + + def get_position_in_parent(self): + return self.__index + + def is_replaceable(self): + return False + + def get_status(self): + return (self.get_presence() and self.get_presence() > 0) + + def get_model(self): + """ + Retrieves the part number of the fan drawer + Returns: + string: Part number of fan drawer + """ + return 'N/A' + + def get_direction(self): + """ + Retrieves the direction of fan + Returns: + A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST + depending on fan direction + """ + 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) + """ + 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 + """ + if device_info.get_platform() in ["x86_64-accton_as9516_32d-r0", "x86_64-accton_as9516bf_32d-r0"]: + return 6 + return 3 + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return 'N/A' + + 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 + """ + # Fan tray status LED controlled by BMC + return False diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/fan_drawer.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/fan_drawer.py index b30ea24e0e41..269d3d43b0bf 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/fan_drawer.py +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/fan_drawer.py @@ -1,71 +1,20 @@ try: - from sonic_platform.platform_thrift_client import thrift_try from sonic_platform_base.fan_drawer_base import FanDrawerBase - from sonic_platform_base.fan_base import FanBase + from sonic_py_common import device_info + from sonic_platform.fan import Fan except ImportError as e: raise ImportError (str(e) + "- required module not found") -_MAX_FAN = 10 - -def _fan_info_get(fan_num, cb, default=None): - def get_data(client): - return client.pltfm_mgr.pltfm_mgr_fan_info_get(fan_num) - fan_info = thrift_try(get_data) - if fan_num == fan_info.fan_num: - return cb(fan_info) - if default is None: - raise LookupError - return default - -def _fan_info_get_all(): - for fan_num in range(1, _MAX_FAN + 1): - def get_data(client, fan_num=fan_num): - return client.pltfm_mgr.pltfm_mgr_fan_info_get(fan_num) - fan_info = thrift_try(get_data) - if fan_info.fan_num == fan_num: - yield fan_info - -# Fan -> FanBase -> DeviceBase -class Fan(FanBase): - def __init__(self, num): - self.__num = num - - # FanBase interface methods: - # returns speed in percents - def get_speed(self): - def cb(info): return info.percent - return _fan_info_get(self.__num, cb, 0) - - def set_speed(self, percent): - def set_fan_speed(client): - return client.pltfm_mgr.pltfm_mgr_fan_speed_set(self.__num, percent) - return thrift_try(set_fan_speed) - - # DeviceBase interface methods: - def get_name(self): - return f"counter-rotating-fan-{self.__num}" - - def get_presence(self): - return _fan_info_get(self.__num, lambda _: True, False) - - def get_position_in_parent(self): - return self.__num - - def is_replaceable(self): - return True - - def get_status(self): - return True - # FanDrawer -> FanDrawerBase -> DeviceBase class FanDrawer(FanDrawerBase): - def __init__(self): + def __init__(self, fantray_index, max_fan): # For now we return only present fans - self._fan_list = [Fan(i.fan_num) for i in _fan_info_get_all()] + self.fantrayindex = fantray_index + self._fan_list = [Fan(i, self.fantrayindex) for i in range(1, max_fan + 1)] # DeviceBase interface methods: def get_name(self): - return 'fantray' + return f"fantray-{self.fantrayindex}" def get_presence(self): return True @@ -73,5 +22,78 @@ def get_presence(self): def get_status(self): return True + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. + Returns: + integer: The 1-based relative physical position in parent + device or -1 if cannot determine the position + """ + return self.fantrayindex + + def is_replaceable(self): + """ + Indicate whether this fan drawer is replaceable. + Returns: + bool: True if it is replaceable, False if not + """ + return False + + def get_model(self): + """ + Retrieves the part number of the fan drawer + Returns: + string: Part number of fan drawer + """ + return 'N/A' + + def get_serial(self): + """ + Retrieves the serial number of the fan drawer + Returns: + string: Serial number of the fan drawer + """ + return 'N/A' + + def set_status_led(self, color): + """ + Set led to expected color + Args: + color: A string representing the color with which to set the + fan module status LED + Returns: + bool: True if set success, False if fail. + """ + # Fan tray status LED controlled by BMC + return False + + def get_status_led(self): + """ + Gets the state of the fan drawer LED + Returns: + A string, one of the predefined STATUS_LED_COLOR_* strings above + """ + return "N/A" + + def get_maximum_consumed_power(self): + """ + Retrives the maximum power drawn by Fan Drawer + Returns: + A float, with value of the maximum consumable power of the + component. + """ + return 36.0 + def fan_drawer_list_get(): - return [FanDrawer()] + platform = device_info.get_platform() + if platform in ["x86_64-accton_as9516_32d-r0", "x86_64-accton_as9516bf_32d-r0"]: + max_fantray = 1 + max_fan = 6 + elif platform == "x86_64-accton_wedge100bf_65x-r0": + max_fantray = 2 + max_fan = 5 + else: + max_fantray = 1 + max_fan = 5 + + return [FanDrawer(i, max_fan) for i in range(1, max_fantray + 1)] diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/platform_thrift_client.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/platform_thrift_client.py index 96c0e09ba1c0..dff16577de74 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/platform_thrift_client.py +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/platform_thrift_client.py @@ -25,9 +25,9 @@ def open(self): self.transport = TTransport.TBufferedTransport(self.transport) bprotocol = TBinaryProtocol.TBinaryProtocol(self.transport) - pltfm_mgr_client_module = importlib.import_module(".".join(["pltfm_mgr_rpc", "pltfm_mgr_rpc"])) + self.pltfm_mgr_module = importlib.import_module(".".join(["pltfm_mgr_rpc", "pltfm_mgr_rpc"])) pltfm_mgr_protocol = TMultiplexedProtocol.TMultiplexedProtocol(bprotocol, "pltfm_mgr_rpc") - self.pltfm_mgr = pltfm_mgr_client_module.Client(pltfm_mgr_protocol) + self.pltfm_mgr = self.pltfm_mgr_module.Client(pltfm_mgr_protocol) self.transport.open() return self @@ -38,6 +38,13 @@ def __enter__(self): def __exit__(self, exc_type, exc_value, tb): self.close() +def pltfm_mgr_ready(): + try: + with ThriftClient(): + return True + except Exception: + return False + def thrift_try(func, attempts=35): for attempt in range(attempts): try: @@ -47,3 +54,12 @@ def thrift_try(func, attempts=35): if attempt + 1 == attempts: raise e time.sleep(1) + +def pltfm_mgr_try(func, default=None, thrift_attempts=35): + def pm_cb_run(client): + try: + return (None, func(client.pltfm_mgr)) + except client.pltfm_mgr_module.InvalidPltfmMgrOperation as ouch: + return (ouch.code, default) + + return thrift_try(pm_cb_run) diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/pltfm_mgr_rpc/pltfm_mgr_rpc.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/pltfm_mgr_rpc/pltfm_mgr_rpc.py index b256b6285fc3..419ac57ebb22 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/pltfm_mgr_rpc/pltfm_mgr_rpc.py +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/pltfm_mgr_rpc/pltfm_mgr_rpc.py @@ -1,5 +1,5 @@ # -# Autogenerated by Thrift Compiler (0.10.0) +# Autogenerated by Thrift Compiler (0.13.0) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # @@ -8,11 +8,14 @@ from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException from thrift.protocol.TProtocol import TProtocolException +from thrift.TRecursive import fix_spec + import sys import logging from .ttypes import * from thrift.Thrift import TProcessor from thrift.transport import TTransport +all_structs = [] class Iface(object): @@ -20,6 +23,7 @@ def pltfm_mgr_dummy(self, device): """ Parameters: - device + """ pass @@ -33,6 +37,7 @@ def pltfm_mgr_pwr_supply_present_get(self, ps_num): """ Parameters: - ps_num + """ pass @@ -40,6 +45,7 @@ def pltfm_mgr_pwr_supply_info_get(self, ps_num): """ Parameters: - ps_num + """ pass @@ -47,6 +53,7 @@ def pltfm_mgr_pwr_rail_info_get(self, ps_num): """ Parameters: - ps_num + """ pass @@ -55,6 +62,7 @@ def pltfm_mgr_fan_speed_set(self, fan_num, percent): Parameters: - fan_num - percent + """ pass @@ -62,6 +70,7 @@ def pltfm_mgr_fan_info_get(self, fan_num): """ Parameters: - fan_num + """ pass @@ -69,6 +78,15 @@ def pltfm_mgr_qsfp_presence_get(self, port_num): """ Parameters: - port_num + + """ + pass + + def pltfm_mgr_qsfp_detect_transceiver(self, port_num): + """ + Parameters: + - port_num + """ pass @@ -76,6 +94,7 @@ def pltfm_mgr_qsfp_info_get(self, port_num): """ Parameters: - port_num + """ pass @@ -87,6 +106,138 @@ def pltfm_mgr_qsfp_reset(self, port_num, reset): Parameters: - port_num - reset + + """ + pass + + def pltfm_mgr_qsfp_reset_get(self, port_num): + """ + Parameters: + - port_num + + """ + pass + + def pltfm_mgr_qsfp_tx_disable(self, port_num, channel_mask, disable): + """ + Parameters: + - port_num + - channel_mask + - disable + + """ + pass + + def pltfm_mgr_qsfp_chan_count_get(self, port_num): + """ + Parameters: + - port_num + + """ + pass + + def pltfm_mgr_qsfp_chan_rx_pwr_get(self, port_num): + """ + Parameters: + - port_num + + """ + pass + + def pltfm_mgr_qsfp_chan_tx_bias_get(self, port_num): + """ + Parameters: + - port_num + + """ + pass + + def pltfm_mgr_qsfp_chan_tx_pwr_get(self, port_num): + """ + Parameters: + - port_num + + """ + pass + + def pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get(self, port_num): + """ + Parameters: + - port_num + + """ + pass + + def pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get(self, port_num): + """ + Parameters: + - port_num + + """ + pass + + def pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get(self, port_num): + """ + Parameters: + - port_num + + """ + pass + + def pltfm_mgr_qsfp_chan_rx_los_get(self, port_num): + """ + Parameters: + - port_num + + """ + pass + + def pltfm_mgr_qsfp_chan_tx_los_get(self, port_num): + """ + Parameters: + - port_num + + """ + pass + + def pltfm_mgr_qsfp_chan_tx_fault_get(self, port_num): + """ + Parameters: + - port_num + + """ + pass + + def pltfm_mgr_qsfp_temperature_get(self, port_num): + """ + Parameters: + - port_num + + """ + pass + + def pltfm_mgr_qsfp_voltage_get(self, port_num): + """ + Parameters: + - port_num + + """ + pass + + def pltfm_mgr_qsfp_thresholds_get(self, port_num): + """ + Parameters: + - port_num + + """ + pass + + def pltfm_mgr_qsfp_tx_is_disabled(self, port_num, channel): + """ + Parameters: + - port_num + - channel + """ pass @@ -94,6 +245,25 @@ def pltfm_mgr_qsfp_lpmode_get(self, port_num): """ Parameters: - port_num + + """ + pass + + def pltfm_mgr_qsfp_pwr_override_get(self, port_num): + """ + Parameters: + - port_num + + """ + pass + + def pltfm_mgr_qsfp_pwr_override_set(self, port_num, power_override, power_set): + """ + Parameters: + - port_num + - power_override + - power_set + """ pass @@ -102,6 +272,7 @@ def pltfm_mgr_qsfp_lpmode_set(self, port_num, lpmode): Parameters: - port_num - lpmode + """ pass @@ -109,6 +280,7 @@ def pltfm_mgr_sensor_info_get(self, options): """ Parameters: - options + """ pass @@ -124,6 +296,7 @@ def pltfm_mgr_dummy(self, device): """ Parameters: - device + """ self.send_pltfm_mgr_dummy(device) return self.recv_pltfm_mgr_dummy() @@ -211,6 +384,7 @@ def pltfm_mgr_pwr_supply_present_get(self, ps_num): """ Parameters: - ps_num + """ self.send_pltfm_mgr_pwr_supply_present_get(ps_num) return self.recv_pltfm_mgr_pwr_supply_present_get() @@ -244,6 +418,7 @@ def pltfm_mgr_pwr_supply_info_get(self, ps_num): """ Parameters: - ps_num + """ self.send_pltfm_mgr_pwr_supply_info_get(ps_num) return self.recv_pltfm_mgr_pwr_supply_info_get() @@ -277,6 +452,7 @@ def pltfm_mgr_pwr_rail_info_get(self, ps_num): """ Parameters: - ps_num + """ self.send_pltfm_mgr_pwr_rail_info_get(ps_num) return self.recv_pltfm_mgr_pwr_rail_info_get() @@ -311,6 +487,7 @@ def pltfm_mgr_fan_speed_set(self, fan_num, percent): Parameters: - fan_num - percent + """ self.send_pltfm_mgr_fan_speed_set(fan_num, percent) return self.recv_pltfm_mgr_fan_speed_set() @@ -345,6 +522,7 @@ def pltfm_mgr_fan_info_get(self, fan_num): """ Parameters: - fan_num + """ self.send_pltfm_mgr_fan_info_get(fan_num) return self.recv_pltfm_mgr_fan_info_get() @@ -378,6 +556,7 @@ def pltfm_mgr_qsfp_presence_get(self, port_num): """ Parameters: - port_num + """ self.send_pltfm_mgr_qsfp_presence_get(port_num) return self.recv_pltfm_mgr_qsfp_presence_get() @@ -407,10 +586,45 @@ def recv_pltfm_mgr_qsfp_presence_get(self): raise result.ouch raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_presence_get failed: unknown result") + def pltfm_mgr_qsfp_detect_transceiver(self, port_num): + """ + Parameters: + - port_num + + """ + self.send_pltfm_mgr_qsfp_detect_transceiver(port_num) + return self.recv_pltfm_mgr_qsfp_detect_transceiver() + + def send_pltfm_mgr_qsfp_detect_transceiver(self, port_num): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_detect_transceiver', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_detect_transceiver_args() + args.port_num = port_num + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_qsfp_detect_transceiver(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_qsfp_detect_transceiver_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_detect_transceiver failed: unknown result") + def pltfm_mgr_qsfp_info_get(self, port_num): """ Parameters: - port_num + """ self.send_pltfm_mgr_qsfp_info_get(port_num) return self.recv_pltfm_mgr_qsfp_info_get() @@ -473,6 +687,7 @@ def pltfm_mgr_qsfp_reset(self, port_num, reset): Parameters: - port_num - reset + """ self.send_pltfm_mgr_qsfp_reset(port_num, reset) return self.recv_pltfm_mgr_qsfp_reset() @@ -503,23 +718,24 @@ def recv_pltfm_mgr_qsfp_reset(self): raise result.ouch raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_reset failed: unknown result") - def pltfm_mgr_qsfp_lpmode_get(self, port_num): + def pltfm_mgr_qsfp_reset_get(self, port_num): """ Parameters: - port_num + """ - self.send_pltfm_mgr_qsfp_lpmode_get(port_num) - return self.recv_pltfm_mgr_qsfp_lpmode_get() + self.send_pltfm_mgr_qsfp_reset_get(port_num) + return self.recv_pltfm_mgr_qsfp_reset_get() - def send_pltfm_mgr_qsfp_lpmode_get(self, port_num): - self._oprot.writeMessageBegin('pltfm_mgr_qsfp_lpmode_get', TMessageType.CALL, self._seqid) - args = pltfm_mgr_qsfp_lpmode_get_args() + def send_pltfm_mgr_qsfp_reset_get(self, port_num): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_reset_get', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_reset_get_args() args.port_num = port_num args.write(self._oprot) self._oprot.writeMessageEnd() self._oprot.trans.flush() - def recv_pltfm_mgr_qsfp_lpmode_get(self): + def recv_pltfm_mgr_qsfp_reset_get(self): iprot = self._iprot (fname, mtype, rseqid) = iprot.readMessageBegin() if mtype == TMessageType.EXCEPTION: @@ -527,34 +743,37 @@ def recv_pltfm_mgr_qsfp_lpmode_get(self): x.read(iprot) iprot.readMessageEnd() raise x - result = pltfm_mgr_qsfp_lpmode_get_result() + result = pltfm_mgr_qsfp_reset_get_result() result.read(iprot) iprot.readMessageEnd() if result.success is not None: return result.success if result.ouch is not None: raise result.ouch - raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_lpmode_get failed: unknown result") + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_reset_get failed: unknown result") - def pltfm_mgr_qsfp_lpmode_set(self, port_num, lpmode): + def pltfm_mgr_qsfp_tx_disable(self, port_num, channel_mask, disable): """ Parameters: - port_num - - lpmode + - channel_mask + - disable + """ - self.send_pltfm_mgr_qsfp_lpmode_set(port_num, lpmode) - return self.recv_pltfm_mgr_qsfp_lpmode_set() + self.send_pltfm_mgr_qsfp_tx_disable(port_num, channel_mask, disable) + return self.recv_pltfm_mgr_qsfp_tx_disable() - def send_pltfm_mgr_qsfp_lpmode_set(self, port_num, lpmode): - self._oprot.writeMessageBegin('pltfm_mgr_qsfp_lpmode_set', TMessageType.CALL, self._seqid) - args = pltfm_mgr_qsfp_lpmode_set_args() + def send_pltfm_mgr_qsfp_tx_disable(self, port_num, channel_mask, disable): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_tx_disable', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_tx_disable_args() args.port_num = port_num - args.lpmode = lpmode + args.channel_mask = channel_mask + args.disable = disable args.write(self._oprot) self._oprot.writeMessageEnd() self._oprot.trans.flush() - def recv_pltfm_mgr_qsfp_lpmode_set(self): + def recv_pltfm_mgr_qsfp_tx_disable(self): iprot = self._iprot (fname, mtype, rseqid) = iprot.readMessageBegin() if mtype == TMessageType.EXCEPTION: @@ -562,32 +781,33 @@ def recv_pltfm_mgr_qsfp_lpmode_set(self): x.read(iprot) iprot.readMessageEnd() raise x - result = pltfm_mgr_qsfp_lpmode_set_result() + result = pltfm_mgr_qsfp_tx_disable_result() result.read(iprot) iprot.readMessageEnd() if result.success is not None: return result.success if result.ouch is not None: raise result.ouch - raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_lpmode_set failed: unknown result") + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_tx_disable failed: unknown result") - def pltfm_mgr_sensor_info_get(self, options): + def pltfm_mgr_qsfp_chan_count_get(self, port_num): """ Parameters: - - options + - port_num + """ - self.send_pltfm_mgr_sensor_info_get(options) - return self.recv_pltfm_mgr_sensor_info_get() + self.send_pltfm_mgr_qsfp_chan_count_get(port_num) + return self.recv_pltfm_mgr_qsfp_chan_count_get() - def send_pltfm_mgr_sensor_info_get(self, options): - self._oprot.writeMessageBegin('pltfm_mgr_sensor_info_get', TMessageType.CALL, self._seqid) - args = pltfm_mgr_sensor_info_get_args() - args.options = options + def send_pltfm_mgr_qsfp_chan_count_get(self, port_num): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_chan_count_get', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_chan_count_get_args() + args.port_num = port_num args.write(self._oprot) self._oprot.writeMessageEnd() self._oprot.trans.flush() - def recv_pltfm_mgr_sensor_info_get(self): + def recv_pltfm_mgr_qsfp_chan_count_get(self): iprot = self._iprot (fname, mtype, rseqid) = iprot.readMessageBegin() if mtype == TMessageType.EXCEPTION: @@ -595,398 +815,4185 @@ def recv_pltfm_mgr_sensor_info_get(self): x.read(iprot) iprot.readMessageEnd() raise x - result = pltfm_mgr_sensor_info_get_result() + result = pltfm_mgr_qsfp_chan_count_get_result() result.read(iprot) iprot.readMessageEnd() if result.success is not None: return result.success if result.ouch is not None: raise result.ouch - raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_sensor_info_get failed: unknown result") + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_chan_count_get failed: unknown result") + def pltfm_mgr_qsfp_chan_rx_pwr_get(self, port_num): + """ + Parameters: + - port_num -class Processor(Iface, TProcessor): - def __init__(self, handler): - self._handler = handler - self._processMap = {} - self._processMap["pltfm_mgr_dummy"] = Processor.process_pltfm_mgr_dummy - self._processMap["pltfm_mgr_sys_tmp_get"] = Processor.process_pltfm_mgr_sys_tmp_get - self._processMap["pltfm_mgr_sys_eeprom_get"] = Processor.process_pltfm_mgr_sys_eeprom_get - self._processMap["pltfm_mgr_pwr_supply_present_get"] = Processor.process_pltfm_mgr_pwr_supply_present_get - self._processMap["pltfm_mgr_pwr_supply_info_get"] = Processor.process_pltfm_mgr_pwr_supply_info_get - self._processMap["pltfm_mgr_pwr_rail_info_get"] = Processor.process_pltfm_mgr_pwr_rail_info_get - self._processMap["pltfm_mgr_fan_speed_set"] = Processor.process_pltfm_mgr_fan_speed_set - self._processMap["pltfm_mgr_fan_info_get"] = Processor.process_pltfm_mgr_fan_info_get - self._processMap["pltfm_mgr_qsfp_presence_get"] = Processor.process_pltfm_mgr_qsfp_presence_get - self._processMap["pltfm_mgr_qsfp_info_get"] = Processor.process_pltfm_mgr_qsfp_info_get - self._processMap["pltfm_mgr_qsfp_get_max_port"] = Processor.process_pltfm_mgr_qsfp_get_max_port - self._processMap["pltfm_mgr_qsfp_reset"] = Processor.process_pltfm_mgr_qsfp_reset - self._processMap["pltfm_mgr_qsfp_lpmode_get"] = Processor.process_pltfm_mgr_qsfp_lpmode_get - self._processMap["pltfm_mgr_qsfp_lpmode_set"] = Processor.process_pltfm_mgr_qsfp_lpmode_set - self._processMap["pltfm_mgr_sensor_info_get"] = Processor.process_pltfm_mgr_sensor_info_get + """ + self.send_pltfm_mgr_qsfp_chan_rx_pwr_get(port_num) + return self.recv_pltfm_mgr_qsfp_chan_rx_pwr_get() - def process(self, iprot, oprot): - (name, type, seqid) = iprot.readMessageBegin() - if name not in self._processMap: - iprot.skip(TType.STRUCT) + def send_pltfm_mgr_qsfp_chan_rx_pwr_get(self, port_num): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_chan_rx_pwr_get', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_chan_rx_pwr_get_args() + args.port_num = port_num + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_qsfp_chan_rx_pwr_get(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) iprot.readMessageEnd() - x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) - oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) - x.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - return - else: - self._processMap[name](self, seqid, iprot, oprot) - return True - - def process_pltfm_mgr_dummy(self, seqid, iprot, oprot): - args = pltfm_mgr_dummy_args() - args.read(iprot) + raise x + result = pltfm_mgr_qsfp_chan_rx_pwr_get_result() + result.read(iprot) iprot.readMessageEnd() - result = pltfm_mgr_dummy_result() - try: - result.success = self._handler.pltfm_mgr_dummy(args.device) - msg_type = TMessageType.REPLY - except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): - raise - except Exception as ex: - msg_type = TMessageType.EXCEPTION - logging.exception(ex) - result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') - oprot.writeMessageBegin("pltfm_mgr_dummy", msg_type, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_chan_rx_pwr_get failed: unknown result") - def process_pltfm_mgr_sys_tmp_get(self, seqid, iprot, oprot): - args = pltfm_mgr_sys_tmp_get_args() - args.read(iprot) - iprot.readMessageEnd() - result = pltfm_mgr_sys_tmp_get_result() - try: - result.success = self._handler.pltfm_mgr_sys_tmp_get() - msg_type = TMessageType.REPLY - except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): - raise - except InvalidPltfmMgrOperation as ouch: - msg_type = TMessageType.REPLY - result.ouch = ouch - except Exception as ex: - msg_type = TMessageType.EXCEPTION - logging.exception(ex) - result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') - oprot.writeMessageBegin("pltfm_mgr_sys_tmp_get", msg_type, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() + def pltfm_mgr_qsfp_chan_tx_bias_get(self, port_num): + """ + Parameters: + - port_num - def process_pltfm_mgr_sys_eeprom_get(self, seqid, iprot, oprot): - args = pltfm_mgr_sys_eeprom_get_args() - args.read(iprot) - iprot.readMessageEnd() - result = pltfm_mgr_sys_eeprom_get_result() - try: - result.success = self._handler.pltfm_mgr_sys_eeprom_get() - msg_type = TMessageType.REPLY - except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): - raise - except InvalidPltfmMgrOperation as ouch: - msg_type = TMessageType.REPLY - result.ouch = ouch - except Exception as ex: - msg_type = TMessageType.EXCEPTION - logging.exception(ex) - result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') - oprot.writeMessageBegin("pltfm_mgr_sys_eeprom_get", msg_type, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() + """ + self.send_pltfm_mgr_qsfp_chan_tx_bias_get(port_num) + return self.recv_pltfm_mgr_qsfp_chan_tx_bias_get() - def process_pltfm_mgr_pwr_supply_present_get(self, seqid, iprot, oprot): - args = pltfm_mgr_pwr_supply_present_get_args() - args.read(iprot) - iprot.readMessageEnd() - result = pltfm_mgr_pwr_supply_present_get_result() - try: - result.success = self._handler.pltfm_mgr_pwr_supply_present_get(args.ps_num) - msg_type = TMessageType.REPLY - except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): - raise - except InvalidPltfmMgrOperation as ouch: - msg_type = TMessageType.REPLY - result.ouch = ouch - except Exception as ex: - msg_type = TMessageType.EXCEPTION - logging.exception(ex) - result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') - oprot.writeMessageBegin("pltfm_mgr_pwr_supply_present_get", msg_type, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() + def send_pltfm_mgr_qsfp_chan_tx_bias_get(self, port_num): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_chan_tx_bias_get', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_chan_tx_bias_get_args() + args.port_num = port_num + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() - def process_pltfm_mgr_pwr_supply_info_get(self, seqid, iprot, oprot): - args = pltfm_mgr_pwr_supply_info_get_args() - args.read(iprot) + def recv_pltfm_mgr_qsfp_chan_tx_bias_get(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_qsfp_chan_tx_bias_get_result() + result.read(iprot) iprot.readMessageEnd() - result = pltfm_mgr_pwr_supply_info_get_result() - try: - result.success = self._handler.pltfm_mgr_pwr_supply_info_get(args.ps_num) - msg_type = TMessageType.REPLY - except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): - raise - except InvalidPltfmMgrOperation as ouch: - msg_type = TMessageType.REPLY - result.ouch = ouch - except Exception as ex: - msg_type = TMessageType.EXCEPTION - logging.exception(ex) - result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') - oprot.writeMessageBegin("pltfm_mgr_pwr_supply_info_get", msg_type, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_chan_tx_bias_get failed: unknown result") - def process_pltfm_mgr_pwr_rail_info_get(self, seqid, iprot, oprot): - args = pltfm_mgr_pwr_rail_info_get_args() - args.read(iprot) - iprot.readMessageEnd() - result = pltfm_mgr_pwr_rail_info_get_result() - try: - result.success = self._handler.pltfm_mgr_pwr_rail_info_get(args.ps_num) - msg_type = TMessageType.REPLY - except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): - raise - except InvalidPltfmMgrOperation as ouch: - msg_type = TMessageType.REPLY - result.ouch = ouch - except Exception as ex: - msg_type = TMessageType.EXCEPTION - logging.exception(ex) - result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') - oprot.writeMessageBegin("pltfm_mgr_pwr_rail_info_get", msg_type, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() + def pltfm_mgr_qsfp_chan_tx_pwr_get(self, port_num): + """ + Parameters: + - port_num - def process_pltfm_mgr_fan_speed_set(self, seqid, iprot, oprot): - args = pltfm_mgr_fan_speed_set_args() - args.read(iprot) + """ + self.send_pltfm_mgr_qsfp_chan_tx_pwr_get(port_num) + return self.recv_pltfm_mgr_qsfp_chan_tx_pwr_get() + + def send_pltfm_mgr_qsfp_chan_tx_pwr_get(self, port_num): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_chan_tx_pwr_get', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_chan_tx_pwr_get_args() + args.port_num = port_num + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_qsfp_chan_tx_pwr_get(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_qsfp_chan_tx_pwr_get_result() + result.read(iprot) iprot.readMessageEnd() - result = pltfm_mgr_fan_speed_set_result() - try: - result.success = self._handler.pltfm_mgr_fan_speed_set(args.fan_num, args.percent) - msg_type = TMessageType.REPLY - except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): - raise - except InvalidPltfmMgrOperation as ouch: - msg_type = TMessageType.REPLY - result.ouch = ouch - except Exception as ex: - msg_type = TMessageType.EXCEPTION - logging.exception(ex) - result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') - oprot.writeMessageBegin("pltfm_mgr_fan_speed_set", msg_type, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_chan_tx_pwr_get failed: unknown result") - def process_pltfm_mgr_fan_info_get(self, seqid, iprot, oprot): - args = pltfm_mgr_fan_info_get_args() - args.read(iprot) + def pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get(self, port_num): + """ + Parameters: + - port_num + + """ + self.send_pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get(port_num) + return self.recv_pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get() + + def send_pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get(self, port_num): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get_args() + args.port_num = port_num + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get_result() + result.read(iprot) iprot.readMessageEnd() - result = pltfm_mgr_fan_info_get_result() - try: - result.success = self._handler.pltfm_mgr_fan_info_get(args.fan_num) - msg_type = TMessageType.REPLY - except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): - raise - except InvalidPltfmMgrOperation as ouch: - msg_type = TMessageType.REPLY - result.ouch = ouch - except Exception as ex: - msg_type = TMessageType.EXCEPTION - logging.exception(ex) - result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') - oprot.writeMessageBegin("pltfm_mgr_fan_info_get", msg_type, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get failed: unknown result") - def process_pltfm_mgr_qsfp_presence_get(self, seqid, iprot, oprot): - args = pltfm_mgr_qsfp_presence_get_args() - args.read(iprot) + def pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get(self, port_num): + """ + Parameters: + - port_num + + """ + self.send_pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get(port_num) + return self.recv_pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get() + + def send_pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get(self, port_num): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get_args() + args.port_num = port_num + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get_result() + result.read(iprot) iprot.readMessageEnd() - result = pltfm_mgr_qsfp_presence_get_result() - try: - result.success = self._handler.pltfm_mgr_qsfp_presence_get(args.port_num) - msg_type = TMessageType.REPLY - except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): - raise - except InvalidPltfmMgrOperation as ouch: - msg_type = TMessageType.REPLY - result.ouch = ouch - except Exception as ex: - msg_type = TMessageType.EXCEPTION - logging.exception(ex) - result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') - oprot.writeMessageBegin("pltfm_mgr_qsfp_presence_get", msg_type, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get failed: unknown result") + + def pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get(self, port_num): + """ + Parameters: + - port_num + + """ + self.send_pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get(port_num) + return self.recv_pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get() + + def send_pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get(self, port_num): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get_args() + args.port_num = port_num + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get failed: unknown result") + + def pltfm_mgr_qsfp_chan_rx_los_get(self, port_num): + """ + Parameters: + - port_num + + """ + self.send_pltfm_mgr_qsfp_chan_rx_los_get(port_num) + return self.recv_pltfm_mgr_qsfp_chan_rx_los_get() + + def send_pltfm_mgr_qsfp_chan_rx_los_get(self, port_num): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_chan_rx_los_get', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_chan_rx_los_get_args() + args.port_num = port_num + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_qsfp_chan_rx_los_get(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_qsfp_chan_rx_los_get_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_chan_rx_los_get failed: unknown result") + + def pltfm_mgr_qsfp_chan_tx_los_get(self, port_num): + """ + Parameters: + - port_num + + """ + self.send_pltfm_mgr_qsfp_chan_tx_los_get(port_num) + return self.recv_pltfm_mgr_qsfp_chan_tx_los_get() + + def send_pltfm_mgr_qsfp_chan_tx_los_get(self, port_num): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_chan_tx_los_get', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_chan_tx_los_get_args() + args.port_num = port_num + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_qsfp_chan_tx_los_get(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_qsfp_chan_tx_los_get_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_chan_tx_los_get failed: unknown result") + + def pltfm_mgr_qsfp_chan_tx_fault_get(self, port_num): + """ + Parameters: + - port_num + + """ + self.send_pltfm_mgr_qsfp_chan_tx_fault_get(port_num) + return self.recv_pltfm_mgr_qsfp_chan_tx_fault_get() + + def send_pltfm_mgr_qsfp_chan_tx_fault_get(self, port_num): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_chan_tx_fault_get', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_chan_tx_fault_get_args() + args.port_num = port_num + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_qsfp_chan_tx_fault_get(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_qsfp_chan_tx_fault_get_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_chan_tx_fault_get failed: unknown result") + + def pltfm_mgr_qsfp_temperature_get(self, port_num): + """ + Parameters: + - port_num + + """ + self.send_pltfm_mgr_qsfp_temperature_get(port_num) + return self.recv_pltfm_mgr_qsfp_temperature_get() + + def send_pltfm_mgr_qsfp_temperature_get(self, port_num): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_temperature_get', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_temperature_get_args() + args.port_num = port_num + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_qsfp_temperature_get(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_qsfp_temperature_get_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_temperature_get failed: unknown result") + + def pltfm_mgr_qsfp_voltage_get(self, port_num): + """ + Parameters: + - port_num + + """ + self.send_pltfm_mgr_qsfp_voltage_get(port_num) + return self.recv_pltfm_mgr_qsfp_voltage_get() + + def send_pltfm_mgr_qsfp_voltage_get(self, port_num): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_voltage_get', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_voltage_get_args() + args.port_num = port_num + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_qsfp_voltage_get(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_qsfp_voltage_get_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_voltage_get failed: unknown result") + + def pltfm_mgr_qsfp_thresholds_get(self, port_num): + """ + Parameters: + - port_num + + """ + self.send_pltfm_mgr_qsfp_thresholds_get(port_num) + return self.recv_pltfm_mgr_qsfp_thresholds_get() + + def send_pltfm_mgr_qsfp_thresholds_get(self, port_num): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_thresholds_get', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_thresholds_get_args() + args.port_num = port_num + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_qsfp_thresholds_get(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_qsfp_thresholds_get_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_thresholds_get failed: unknown result") + + def pltfm_mgr_qsfp_tx_is_disabled(self, port_num, channel): + """ + Parameters: + - port_num + - channel + + """ + self.send_pltfm_mgr_qsfp_tx_is_disabled(port_num, channel) + return self.recv_pltfm_mgr_qsfp_tx_is_disabled() + + def send_pltfm_mgr_qsfp_tx_is_disabled(self, port_num, channel): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_tx_is_disabled', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_tx_is_disabled_args() + args.port_num = port_num + args.channel = channel + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_qsfp_tx_is_disabled(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_qsfp_tx_is_disabled_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_tx_is_disabled failed: unknown result") + + def pltfm_mgr_qsfp_lpmode_get(self, port_num): + """ + Parameters: + - port_num + + """ + self.send_pltfm_mgr_qsfp_lpmode_get(port_num) + return self.recv_pltfm_mgr_qsfp_lpmode_get() + + def send_pltfm_mgr_qsfp_lpmode_get(self, port_num): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_lpmode_get', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_lpmode_get_args() + args.port_num = port_num + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_qsfp_lpmode_get(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_qsfp_lpmode_get_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_lpmode_get failed: unknown result") + + def pltfm_mgr_qsfp_pwr_override_get(self, port_num): + """ + Parameters: + - port_num + + """ + self.send_pltfm_mgr_qsfp_pwr_override_get(port_num) + return self.recv_pltfm_mgr_qsfp_pwr_override_get() + + def send_pltfm_mgr_qsfp_pwr_override_get(self, port_num): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_pwr_override_get', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_pwr_override_get_args() + args.port_num = port_num + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_qsfp_pwr_override_get(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_qsfp_pwr_override_get_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_pwr_override_get failed: unknown result") + + def pltfm_mgr_qsfp_pwr_override_set(self, port_num, power_override, power_set): + """ + Parameters: + - port_num + - power_override + - power_set + + """ + self.send_pltfm_mgr_qsfp_pwr_override_set(port_num, power_override, power_set) + return self.recv_pltfm_mgr_qsfp_pwr_override_set() + + def send_pltfm_mgr_qsfp_pwr_override_set(self, port_num, power_override, power_set): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_pwr_override_set', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_pwr_override_set_args() + args.port_num = port_num + args.power_override = power_override + args.power_set = power_set + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_qsfp_pwr_override_set(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_qsfp_pwr_override_set_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_pwr_override_set failed: unknown result") + + def pltfm_mgr_qsfp_lpmode_set(self, port_num, lpmode): + """ + Parameters: + - port_num + - lpmode + + """ + self.send_pltfm_mgr_qsfp_lpmode_set(port_num, lpmode) + return self.recv_pltfm_mgr_qsfp_lpmode_set() + + def send_pltfm_mgr_qsfp_lpmode_set(self, port_num, lpmode): + self._oprot.writeMessageBegin('pltfm_mgr_qsfp_lpmode_set', TMessageType.CALL, self._seqid) + args = pltfm_mgr_qsfp_lpmode_set_args() + args.port_num = port_num + args.lpmode = lpmode + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_qsfp_lpmode_set(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_qsfp_lpmode_set_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_qsfp_lpmode_set failed: unknown result") + + def pltfm_mgr_sensor_info_get(self, options): + """ + Parameters: + - options + + """ + self.send_pltfm_mgr_sensor_info_get(options) + return self.recv_pltfm_mgr_sensor_info_get() + + def send_pltfm_mgr_sensor_info_get(self, options): + self._oprot.writeMessageBegin('pltfm_mgr_sensor_info_get', TMessageType.CALL, self._seqid) + args = pltfm_mgr_sensor_info_get_args() + args.options = options + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_pltfm_mgr_sensor_info_get(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = pltfm_mgr_sensor_info_get_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.ouch is not None: + raise result.ouch + raise TApplicationException(TApplicationException.MISSING_RESULT, "pltfm_mgr_sensor_info_get failed: unknown result") + + +class Processor(Iface, TProcessor): + def __init__(self, handler): + self._handler = handler + self._processMap = {} + self._processMap["pltfm_mgr_dummy"] = Processor.process_pltfm_mgr_dummy + self._processMap["pltfm_mgr_sys_tmp_get"] = Processor.process_pltfm_mgr_sys_tmp_get + self._processMap["pltfm_mgr_sys_eeprom_get"] = Processor.process_pltfm_mgr_sys_eeprom_get + self._processMap["pltfm_mgr_pwr_supply_present_get"] = Processor.process_pltfm_mgr_pwr_supply_present_get + self._processMap["pltfm_mgr_pwr_supply_info_get"] = Processor.process_pltfm_mgr_pwr_supply_info_get + self._processMap["pltfm_mgr_pwr_rail_info_get"] = Processor.process_pltfm_mgr_pwr_rail_info_get + self._processMap["pltfm_mgr_fan_speed_set"] = Processor.process_pltfm_mgr_fan_speed_set + self._processMap["pltfm_mgr_fan_info_get"] = Processor.process_pltfm_mgr_fan_info_get + self._processMap["pltfm_mgr_qsfp_presence_get"] = Processor.process_pltfm_mgr_qsfp_presence_get + self._processMap["pltfm_mgr_qsfp_detect_transceiver"] = Processor.process_pltfm_mgr_qsfp_detect_transceiver + self._processMap["pltfm_mgr_qsfp_info_get"] = Processor.process_pltfm_mgr_qsfp_info_get + self._processMap["pltfm_mgr_qsfp_get_max_port"] = Processor.process_pltfm_mgr_qsfp_get_max_port + self._processMap["pltfm_mgr_qsfp_reset"] = Processor.process_pltfm_mgr_qsfp_reset + self._processMap["pltfm_mgr_qsfp_reset_get"] = Processor.process_pltfm_mgr_qsfp_reset_get + self._processMap["pltfm_mgr_qsfp_tx_disable"] = Processor.process_pltfm_mgr_qsfp_tx_disable + self._processMap["pltfm_mgr_qsfp_chan_count_get"] = Processor.process_pltfm_mgr_qsfp_chan_count_get + self._processMap["pltfm_mgr_qsfp_chan_rx_pwr_get"] = Processor.process_pltfm_mgr_qsfp_chan_rx_pwr_get + self._processMap["pltfm_mgr_qsfp_chan_tx_bias_get"] = Processor.process_pltfm_mgr_qsfp_chan_tx_bias_get + self._processMap["pltfm_mgr_qsfp_chan_tx_pwr_get"] = Processor.process_pltfm_mgr_qsfp_chan_tx_pwr_get + self._processMap["pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get"] = Processor.process_pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get + self._processMap["pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get"] = Processor.process_pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get + self._processMap["pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get"] = Processor.process_pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get + self._processMap["pltfm_mgr_qsfp_chan_rx_los_get"] = Processor.process_pltfm_mgr_qsfp_chan_rx_los_get + self._processMap["pltfm_mgr_qsfp_chan_tx_los_get"] = Processor.process_pltfm_mgr_qsfp_chan_tx_los_get + self._processMap["pltfm_mgr_qsfp_chan_tx_fault_get"] = Processor.process_pltfm_mgr_qsfp_chan_tx_fault_get + self._processMap["pltfm_mgr_qsfp_temperature_get"] = Processor.process_pltfm_mgr_qsfp_temperature_get + self._processMap["pltfm_mgr_qsfp_voltage_get"] = Processor.process_pltfm_mgr_qsfp_voltage_get + self._processMap["pltfm_mgr_qsfp_thresholds_get"] = Processor.process_pltfm_mgr_qsfp_thresholds_get + self._processMap["pltfm_mgr_qsfp_tx_is_disabled"] = Processor.process_pltfm_mgr_qsfp_tx_is_disabled + self._processMap["pltfm_mgr_qsfp_lpmode_get"] = Processor.process_pltfm_mgr_qsfp_lpmode_get + self._processMap["pltfm_mgr_qsfp_pwr_override_get"] = Processor.process_pltfm_mgr_qsfp_pwr_override_get + self._processMap["pltfm_mgr_qsfp_pwr_override_set"] = Processor.process_pltfm_mgr_qsfp_pwr_override_set + self._processMap["pltfm_mgr_qsfp_lpmode_set"] = Processor.process_pltfm_mgr_qsfp_lpmode_set + self._processMap["pltfm_mgr_sensor_info_get"] = Processor.process_pltfm_mgr_sensor_info_get + self._on_message_begin = None + + def on_message_begin(self, func): + self._on_message_begin = func + + def process(self, iprot, oprot): + (name, type, seqid) = iprot.readMessageBegin() + if self._on_message_begin: + self._on_message_begin(name, type, seqid) + if name not in self._processMap: + iprot.skip(TType.STRUCT) + iprot.readMessageEnd() + x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) + oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) + x.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + return + else: + self._processMap[name](self, seqid, iprot, oprot) + return True + + def process_pltfm_mgr_dummy(self, seqid, iprot, oprot): + args = pltfm_mgr_dummy_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_dummy_result() + try: + result.success = self._handler.pltfm_mgr_dummy(args.device) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_dummy", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_sys_tmp_get(self, seqid, iprot, oprot): + args = pltfm_mgr_sys_tmp_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_sys_tmp_get_result() + try: + result.success = self._handler.pltfm_mgr_sys_tmp_get() + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_sys_tmp_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_sys_eeprom_get(self, seqid, iprot, oprot): + args = pltfm_mgr_sys_eeprom_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_sys_eeprom_get_result() + try: + result.success = self._handler.pltfm_mgr_sys_eeprom_get() + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_sys_eeprom_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_pwr_supply_present_get(self, seqid, iprot, oprot): + args = pltfm_mgr_pwr_supply_present_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_pwr_supply_present_get_result() + try: + result.success = self._handler.pltfm_mgr_pwr_supply_present_get(args.ps_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_pwr_supply_present_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_pwr_supply_info_get(self, seqid, iprot, oprot): + args = pltfm_mgr_pwr_supply_info_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_pwr_supply_info_get_result() + try: + result.success = self._handler.pltfm_mgr_pwr_supply_info_get(args.ps_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_pwr_supply_info_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_pwr_rail_info_get(self, seqid, iprot, oprot): + args = pltfm_mgr_pwr_rail_info_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_pwr_rail_info_get_result() + try: + result.success = self._handler.pltfm_mgr_pwr_rail_info_get(args.ps_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_pwr_rail_info_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_fan_speed_set(self, seqid, iprot, oprot): + args = pltfm_mgr_fan_speed_set_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_fan_speed_set_result() + try: + result.success = self._handler.pltfm_mgr_fan_speed_set(args.fan_num, args.percent) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_fan_speed_set", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_fan_info_get(self, seqid, iprot, oprot): + args = pltfm_mgr_fan_info_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_fan_info_get_result() + try: + result.success = self._handler.pltfm_mgr_fan_info_get(args.fan_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_fan_info_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_presence_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_presence_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_presence_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_presence_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_presence_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_detect_transceiver(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_detect_transceiver_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_detect_transceiver_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_detect_transceiver(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_detect_transceiver", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_info_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_info_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_info_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_info_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_info_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_get_max_port(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_get_max_port_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_get_max_port_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_get_max_port() + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_get_max_port", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_reset(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_reset_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_reset_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_reset(args.port_num, args.reset) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_reset", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_reset_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_reset_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_reset_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_reset_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_reset_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_tx_disable(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_tx_disable_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_tx_disable_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_tx_disable(args.port_num, args.channel_mask, args.disable) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_tx_disable", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_chan_count_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_chan_count_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_chan_count_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_chan_count_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_chan_count_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_chan_rx_pwr_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_chan_rx_pwr_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_chan_rx_pwr_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_chan_rx_pwr_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_chan_rx_pwr_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_chan_tx_bias_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_chan_tx_bias_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_chan_tx_bias_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_chan_tx_bias_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_chan_tx_bias_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_chan_tx_pwr_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_chan_tx_pwr_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_chan_tx_pwr_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_chan_tx_pwr_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_chan_tx_pwr_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_chan_rx_los_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_chan_rx_los_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_chan_rx_los_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_chan_rx_los_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_chan_rx_los_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_chan_tx_los_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_chan_tx_los_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_chan_tx_los_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_chan_tx_los_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_chan_tx_los_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_chan_tx_fault_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_chan_tx_fault_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_chan_tx_fault_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_chan_tx_fault_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_chan_tx_fault_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_temperature_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_temperature_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_temperature_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_temperature_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_temperature_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_voltage_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_voltage_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_voltage_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_voltage_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_voltage_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_thresholds_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_thresholds_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_thresholds_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_thresholds_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_thresholds_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_tx_is_disabled(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_tx_is_disabled_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_tx_is_disabled_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_tx_is_disabled(args.port_num, args.channel) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_tx_is_disabled", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_lpmode_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_lpmode_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_lpmode_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_lpmode_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_lpmode_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_pwr_override_get(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_pwr_override_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_pwr_override_get_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_pwr_override_get(args.port_num) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_pwr_override_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_pwr_override_set(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_pwr_override_set_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_pwr_override_set_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_pwr_override_set(args.port_num, args.power_override, args.power_set) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_pwr_override_set", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_qsfp_lpmode_set(self, seqid, iprot, oprot): + args = pltfm_mgr_qsfp_lpmode_set_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_qsfp_lpmode_set_result() + try: + result.success = self._handler.pltfm_mgr_qsfp_lpmode_set(args.port_num, args.lpmode) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_qsfp_lpmode_set", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_pltfm_mgr_sensor_info_get(self, seqid, iprot, oprot): + args = pltfm_mgr_sensor_info_get_args() + args.read(iprot) + iprot.readMessageEnd() + result = pltfm_mgr_sensor_info_get_result() + try: + result.success = self._handler.pltfm_mgr_sensor_info_get(args.options) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except InvalidPltfmMgrOperation as ouch: + msg_type = TMessageType.REPLY + result.ouch = ouch + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("pltfm_mgr_sensor_info_get", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + +# HELPER FUNCTIONS AND STRUCTURES + + +class pltfm_mgr_dummy_args(object): + """ + Attributes: + - device + + """ + + + def __init__(self, device=None,): + self.device = device + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.BYTE: + self.device = iprot.readByte() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_dummy_args') + if self.device is not None: + oprot.writeFieldBegin('device', TType.BYTE, 1) + oprot.writeByte(self.device) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_dummy_args) +pltfm_mgr_dummy_args.thrift_spec = ( + None, # 0 + (1, TType.BYTE, 'device', None, None, ), # 1 +) + + +class pltfm_mgr_dummy_result(object): + """ + Attributes: + - success + + """ + + + def __init__(self, success=None,): + self.success = success + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.I32: + self.success = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_dummy_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.I32, 0) + oprot.writeI32(self.success) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_dummy_result) +pltfm_mgr_dummy_result.thrift_spec = ( + (0, TType.I32, 'success', None, None, ), # 0 +) + + +class pltfm_mgr_sys_tmp_get_args(object): + + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_sys_tmp_get_args') + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_sys_tmp_get_args) +pltfm_mgr_sys_tmp_get_args.thrift_spec = ( +) + + +class pltfm_mgr_sys_tmp_get_result(object): + """ + Attributes: + - success + - ouch + + """ + + + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRUCT: + self.success = pltfm_mgr_sys_tmp_t() + self.success.read(iprot) + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_sys_tmp_get_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_sys_tmp_get_result) +pltfm_mgr_sys_tmp_get_result.thrift_spec = ( + (0, TType.STRUCT, 'success', [pltfm_mgr_sys_tmp_t, None], None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_sys_eeprom_get_args(object): + + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_sys_eeprom_get_args') + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_sys_eeprom_get_args) +pltfm_mgr_sys_eeprom_get_args.thrift_spec = ( +) + + +class pltfm_mgr_sys_eeprom_get_result(object): + """ + Attributes: + - success + - ouch + + """ + + + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRUCT: + self.success = pltfm_mgr_eeprom_t() + self.success.read(iprot) + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_sys_eeprom_get_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_sys_eeprom_get_result) +pltfm_mgr_sys_eeprom_get_result.thrift_spec = ( + (0, TType.STRUCT, 'success', [pltfm_mgr_eeprom_t, None], None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_pwr_supply_present_get_args(object): + """ + Attributes: + - ps_num + + """ + + + def __init__(self, ps_num=None,): + self.ps_num = ps_num + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I16: + self.ps_num = iprot.readI16() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_pwr_supply_present_get_args') + if self.ps_num is not None: + oprot.writeFieldBegin('ps_num', TType.I16, 1) + oprot.writeI16(self.ps_num) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_pwr_supply_present_get_args) +pltfm_mgr_pwr_supply_present_get_args.thrift_spec = ( + None, # 0 + (1, TType.I16, 'ps_num', None, None, ), # 1 +) + + +class pltfm_mgr_pwr_supply_present_get_result(object): + """ + Attributes: + - success + - ouch + + """ + + + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.BOOL: + self.success = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_pwr_supply_present_get_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.BOOL, 0) + oprot.writeBool(self.success) + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_pwr_supply_present_get_result) +pltfm_mgr_pwr_supply_present_get_result.thrift_spec = ( + (0, TType.BOOL, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_pwr_supply_info_get_args(object): + """ + Attributes: + - ps_num + + """ + + + def __init__(self, ps_num=None,): + self.ps_num = ps_num + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I16: + self.ps_num = iprot.readI16() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_pwr_supply_info_get_args') + if self.ps_num is not None: + oprot.writeFieldBegin('ps_num', TType.I16, 1) + oprot.writeI16(self.ps_num) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_pwr_supply_info_get_args) +pltfm_mgr_pwr_supply_info_get_args.thrift_spec = ( + None, # 0 + (1, TType.I16, 'ps_num', None, None, ), # 1 +) + + +class pltfm_mgr_pwr_supply_info_get_result(object): + """ + Attributes: + - success + - ouch + + """ + + + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRUCT: + self.success = pltfm_mgr_pwr_supply_info_t() + self.success.read(iprot) + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_pwr_supply_info_get_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_pwr_supply_info_get_result) +pltfm_mgr_pwr_supply_info_get_result.thrift_spec = ( + (0, TType.STRUCT, 'success', [pltfm_mgr_pwr_supply_info_t, None], None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_pwr_rail_info_get_args(object): + """ + Attributes: + - ps_num + + """ + + + def __init__(self, ps_num=None,): + self.ps_num = ps_num + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I16: + self.ps_num = iprot.readI16() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_pwr_rail_info_get_args') + if self.ps_num is not None: + oprot.writeFieldBegin('ps_num', TType.I16, 1) + oprot.writeI16(self.ps_num) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_pwr_rail_info_get_args) +pltfm_mgr_pwr_rail_info_get_args.thrift_spec = ( + None, # 0 + (1, TType.I16, 'ps_num', None, None, ), # 1 +) + + +class pltfm_mgr_pwr_rail_info_get_result(object): + """ + Attributes: + - success + - ouch + + """ + + + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRUCT: + self.success = pltfm_mgr_pwr_rail_info_t() + self.success.read(iprot) + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_pwr_rail_info_get_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_pwr_rail_info_get_result) +pltfm_mgr_pwr_rail_info_get_result.thrift_spec = ( + (0, TType.STRUCT, 'success', [pltfm_mgr_pwr_rail_info_t, None], None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_fan_speed_set_args(object): + """ + Attributes: + - fan_num + - percent + + """ + + + def __init__(self, fan_num=None, percent=None,): + self.fan_num = fan_num + self.percent = percent + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I32: + self.fan_num = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.I32: + self.percent = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_fan_speed_set_args') + if self.fan_num is not None: + oprot.writeFieldBegin('fan_num', TType.I32, 1) + oprot.writeI32(self.fan_num) + oprot.writeFieldEnd() + if self.percent is not None: + oprot.writeFieldBegin('percent', TType.I32, 2) + oprot.writeI32(self.percent) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_fan_speed_set_args) +pltfm_mgr_fan_speed_set_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'fan_num', None, None, ), # 1 + (2, TType.I32, 'percent', None, None, ), # 2 +) + + +class pltfm_mgr_fan_speed_set_result(object): + """ + Attributes: + - success + - ouch + + """ + + + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.I32: + self.success = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_fan_speed_set_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.I32, 0) + oprot.writeI32(self.success) + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_fan_speed_set_result) +pltfm_mgr_fan_speed_set_result.thrift_spec = ( + (0, TType.I32, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_fan_info_get_args(object): + """ + Attributes: + - fan_num + + """ + + + def __init__(self, fan_num=None,): + self.fan_num = fan_num + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I32: + self.fan_num = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_fan_info_get_args') + if self.fan_num is not None: + oprot.writeFieldBegin('fan_num', TType.I32, 1) + oprot.writeI32(self.fan_num) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_fan_info_get_args) +pltfm_mgr_fan_info_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'fan_num', None, None, ), # 1 +) + + +class pltfm_mgr_fan_info_get_result(object): + """ + Attributes: + - success + - ouch + + """ + + + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRUCT: + self.success = pltfm_mgr_fan_info_t() + self.success.read(iprot) + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_fan_info_get_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_fan_info_get_result) +pltfm_mgr_fan_info_get_result.thrift_spec = ( + (0, TType.STRUCT, 'success', [pltfm_mgr_fan_info_t, None], None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_qsfp_presence_get_args(object): + """ + Attributes: + - port_num + + """ + + + def __init__(self, port_num=None,): + self.port_num = port_num + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I32: + self.port_num = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_presence_get_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_presence_get_args) +pltfm_mgr_qsfp_presence_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) + + +class pltfm_mgr_qsfp_presence_get_result(object): + """ + Attributes: + - success + - ouch + + """ + + + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.BOOL: + self.success = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_presence_get_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.BOOL, 0) + oprot.writeBool(self.success) + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_presence_get_result) +pltfm_mgr_qsfp_presence_get_result.thrift_spec = ( + (0, TType.BOOL, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_qsfp_detect_transceiver_args(object): + """ + Attributes: + - port_num + + """ + + + def __init__(self, port_num=None,): + self.port_num = port_num + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I32: + self.port_num = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_detect_transceiver_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_detect_transceiver_args) +pltfm_mgr_qsfp_detect_transceiver_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) + + +class pltfm_mgr_qsfp_detect_transceiver_result(object): + """ + Attributes: + - success + - ouch + + """ + + + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.BOOL: + self.success = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_detect_transceiver_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.BOOL, 0) + oprot.writeBool(self.success) + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_detect_transceiver_result) +pltfm_mgr_qsfp_detect_transceiver_result.thrift_spec = ( + (0, TType.BOOL, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_qsfp_info_get_args(object): + """ + Attributes: + - port_num + + """ + + + def __init__(self, port_num=None,): + self.port_num = port_num + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I32: + self.port_num = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_info_get_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_info_get_args) +pltfm_mgr_qsfp_info_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) + + +class pltfm_mgr_qsfp_info_get_result(object): + """ + Attributes: + - success + - ouch + + """ + + + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.STRING: + self.success = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_info_get_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRING, 0) + oprot.writeString(self.success.encode('utf-8') if sys.version_info[0] == 2 else self.success) + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_info_get_result) +pltfm_mgr_qsfp_info_get_result.thrift_spec = ( + (0, TType.STRING, 'success', 'UTF8', None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_qsfp_get_max_port_args(object): + + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_get_max_port_args') + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_get_max_port_args) +pltfm_mgr_qsfp_get_max_port_args.thrift_spec = ( +) + + +class pltfm_mgr_qsfp_get_max_port_result(object): + """ + Attributes: + - success + - ouch + + """ + + + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.I32: + self.success = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_get_max_port_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.I32, 0) + oprot.writeI32(self.success) + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_get_max_port_result) +pltfm_mgr_qsfp_get_max_port_result.thrift_spec = ( + (0, TType.I32, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_qsfp_reset_args(object): + """ + Attributes: + - port_num + - reset + + """ + + + def __init__(self, port_num=None, reset=None,): + self.port_num = port_num + self.reset = reset + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I32: + self.port_num = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.BOOL: + self.reset = iprot.readBool() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_reset_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) + oprot.writeFieldEnd() + if self.reset is not None: + oprot.writeFieldBegin('reset', TType.BOOL, 2) + oprot.writeBool(self.reset) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_reset_args) +pltfm_mgr_qsfp_reset_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 + (2, TType.BOOL, 'reset', None, None, ), # 2 +) + + +class pltfm_mgr_qsfp_reset_result(object): + """ + Attributes: + - success + - ouch + + """ + + + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.I32: + self.success = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_reset_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.I32, 0) + oprot.writeI32(self.success) + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_reset_result) +pltfm_mgr_qsfp_reset_result.thrift_spec = ( + (0, TType.I32, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_qsfp_reset_get_args(object): + """ + Attributes: + - port_num + + """ + + + def __init__(self, port_num=None,): + self.port_num = port_num + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I32: + self.port_num = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_reset_get_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_reset_get_args) +pltfm_mgr_qsfp_reset_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) + + +class pltfm_mgr_qsfp_reset_get_result(object): + """ + Attributes: + - success + - ouch + + """ + + + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.BOOL: + self.success = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_reset_get_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.BOOL, 0) + oprot.writeBool(self.success) + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_reset_get_result) +pltfm_mgr_qsfp_reset_get_result.thrift_spec = ( + (0, TType.BOOL, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_qsfp_tx_disable_args(object): + """ + Attributes: + - port_num + - channel_mask + - disable + + """ + + + def __init__(self, port_num=None, channel_mask=None, disable=None,): + self.port_num = port_num + self.channel_mask = channel_mask + self.disable = disable + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I32: + self.port_num = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.I32: + self.channel_mask = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.BOOL: + self.disable = iprot.readBool() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_tx_disable_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) + oprot.writeFieldEnd() + if self.channel_mask is not None: + oprot.writeFieldBegin('channel_mask', TType.I32, 2) + oprot.writeI32(self.channel_mask) + oprot.writeFieldEnd() + if self.disable is not None: + oprot.writeFieldBegin('disable', TType.BOOL, 3) + oprot.writeBool(self.disable) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_tx_disable_args) +pltfm_mgr_qsfp_tx_disable_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 + (2, TType.I32, 'channel_mask', None, None, ), # 2 + (3, TType.BOOL, 'disable', None, None, ), # 3 +) + + +class pltfm_mgr_qsfp_tx_disable_result(object): + """ + Attributes: + - success + - ouch + + """ + + + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.I32: + self.success = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_tx_disable_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.I32, 0) + oprot.writeI32(self.success) + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_tx_disable_result) +pltfm_mgr_qsfp_tx_disable_result.thrift_spec = ( + (0, TType.I32, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_qsfp_chan_count_get_args(object): + """ + Attributes: + - port_num + + """ + + + def __init__(self, port_num=None,): + self.port_num = port_num + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I32: + self.port_num = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_count_get_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_count_get_args) +pltfm_mgr_qsfp_chan_count_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) + + +class pltfm_mgr_qsfp_chan_count_get_result(object): + """ + Attributes: + - success + - ouch + + """ + + + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.I32: + self.success = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_count_get_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.I32, 0) + oprot.writeI32(self.success) + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_count_get_result) +pltfm_mgr_qsfp_chan_count_get_result.thrift_spec = ( + (0, TType.I32, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_qsfp_chan_rx_pwr_get_args(object): + """ + Attributes: + - port_num + + """ + + + def __init__(self, port_num=None,): + self.port_num = port_num + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I32: + self.port_num = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_rx_pwr_get_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_rx_pwr_get_args) +pltfm_mgr_qsfp_chan_rx_pwr_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) + + +class pltfm_mgr_qsfp_chan_rx_pwr_get_result(object): + """ + Attributes: + - success + - ouch + + """ + + + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype3, _size0) = iprot.readListBegin() + for _i4 in range(_size0): + _elem5 = iprot.readDouble() + self.success.append(_elem5) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_rx_pwr_get_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.DOUBLE, len(self.success)) + for iter6 in self.success: + oprot.writeDouble(iter6) + oprot.writeListEnd() + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_rx_pwr_get_result) +pltfm_mgr_qsfp_chan_rx_pwr_get_result.thrift_spec = ( + (0, TType.LIST, 'success', (TType.DOUBLE, None, False), None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_qsfp_chan_tx_bias_get_args(object): + """ + Attributes: + - port_num + + """ + + + def __init__(self, port_num=None,): + self.port_num = port_num + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I32: + self.port_num = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_tx_bias_get_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_tx_bias_get_args) +pltfm_mgr_qsfp_chan_tx_bias_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) + + +class pltfm_mgr_qsfp_chan_tx_bias_get_result(object): + """ + Attributes: + - success + - ouch + + """ + + + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype10, _size7) = iprot.readListBegin() + for _i11 in range(_size7): + _elem12 = iprot.readDouble() + self.success.append(_elem12) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_tx_bias_get_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.DOUBLE, len(self.success)) + for iter13 in self.success: + oprot.writeDouble(iter13) + oprot.writeListEnd() + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_tx_bias_get_result) +pltfm_mgr_qsfp_chan_tx_bias_get_result.thrift_spec = ( + (0, TType.LIST, 'success', (TType.DOUBLE, None, False), None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_qsfp_chan_tx_pwr_get_args(object): + """ + Attributes: + - port_num + + """ + + + def __init__(self, port_num=None,): + self.port_num = port_num + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.I32: + self.port_num = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_tx_pwr_get_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_tx_pwr_get_args) +pltfm_mgr_qsfp_chan_tx_pwr_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) + - def process_pltfm_mgr_qsfp_info_get(self, seqid, iprot, oprot): - args = pltfm_mgr_qsfp_info_get_args() - args.read(iprot) - iprot.readMessageEnd() - result = pltfm_mgr_qsfp_info_get_result() - try: - result.success = self._handler.pltfm_mgr_qsfp_info_get(args.port_num) - msg_type = TMessageType.REPLY - except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): - raise - except InvalidPltfmMgrOperation as ouch: - msg_type = TMessageType.REPLY - result.ouch = ouch - except Exception as ex: - msg_type = TMessageType.EXCEPTION - logging.exception(ex) - result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') - oprot.writeMessageBegin("pltfm_mgr_qsfp_info_get", msg_type, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() +class pltfm_mgr_qsfp_chan_tx_pwr_get_result(object): + """ + Attributes: + - success + - ouch - def process_pltfm_mgr_qsfp_get_max_port(self, seqid, iprot, oprot): - args = pltfm_mgr_qsfp_get_max_port_args() - args.read(iprot) - iprot.readMessageEnd() - result = pltfm_mgr_qsfp_get_max_port_result() - try: - result.success = self._handler.pltfm_mgr_qsfp_get_max_port() - msg_type = TMessageType.REPLY - except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): - raise - except InvalidPltfmMgrOperation as ouch: - msg_type = TMessageType.REPLY - result.ouch = ouch - except Exception as ex: - msg_type = TMessageType.EXCEPTION - logging.exception(ex) - result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') - oprot.writeMessageBegin("pltfm_mgr_qsfp_get_max_port", msg_type, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() + """ - def process_pltfm_mgr_qsfp_reset(self, seqid, iprot, oprot): - args = pltfm_mgr_qsfp_reset_args() - args.read(iprot) - iprot.readMessageEnd() - result = pltfm_mgr_qsfp_reset_result() - try: - result.success = self._handler.pltfm_mgr_qsfp_reset(args.port_num, args.reset) - msg_type = TMessageType.REPLY - except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): - raise - except InvalidPltfmMgrOperation as ouch: - msg_type = TMessageType.REPLY - result.ouch = ouch - except Exception as ex: - msg_type = TMessageType.EXCEPTION - logging.exception(ex) - result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') - oprot.writeMessageBegin("pltfm_mgr_qsfp_reset", msg_type, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() - def process_pltfm_mgr_qsfp_lpmode_get(self, seqid, iprot, oprot): - args = pltfm_mgr_qsfp_lpmode_get_args() - args.read(iprot) - iprot.readMessageEnd() - result = pltfm_mgr_qsfp_lpmode_get_result() - try: - result.success = self._handler.pltfm_mgr_qsfp_lpmode_get(args.port_num) - msg_type = TMessageType.REPLY - except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): - raise - except InvalidPltfmMgrOperation as ouch: - msg_type = TMessageType.REPLY - result.ouch = ouch - except Exception as ex: - msg_type = TMessageType.EXCEPTION - logging.exception(ex) - result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') - oprot.writeMessageBegin("pltfm_mgr_qsfp_lpmode_get", msg_type, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() + def __init__(self, success=None, ouch=None,): + self.success = success + self.ouch = ouch - def process_pltfm_mgr_qsfp_lpmode_set(self, seqid, iprot, oprot): - args = pltfm_mgr_qsfp_lpmode_set_args() - args.read(iprot) - iprot.readMessageEnd() - result = pltfm_mgr_qsfp_lpmode_set_result() - try: - result.success = self._handler.pltfm_mgr_qsfp_lpmode_set(args.port_num, args.lpmode) - msg_type = TMessageType.REPLY - except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): - raise - except InvalidPltfmMgrOperation as ouch: - msg_type = TMessageType.REPLY - result.ouch = ouch - except Exception as ex: - msg_type = TMessageType.EXCEPTION - logging.exception(ex) - result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') - oprot.writeMessageBegin("pltfm_mgr_qsfp_lpmode_set", msg_type, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 0: + if ftype == TType.LIST: + self.success = [] + (_etype17, _size14) = iprot.readListBegin() + for _i18 in range(_size14): + _elem19 = iprot.readDouble() + self.success.append(_elem19) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() - def process_pltfm_mgr_sensor_info_get(self, seqid, iprot, oprot): - args = pltfm_mgr_sensor_info_get_args() - args.read(iprot) - iprot.readMessageEnd() - result = pltfm_mgr_sensor_info_get_result() - try: - result.success = self._handler.pltfm_mgr_sensor_info_get(args.options) - msg_type = TMessageType.REPLY - except (TTransport.TTransportException, KeyboardInterrupt, SystemExit): - raise - except InvalidPltfmMgrOperation as ouch: - msg_type = TMessageType.REPLY - result.ouch = ouch - except Exception as ex: - msg_type = TMessageType.EXCEPTION - logging.exception(ex) - result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') - oprot.writeMessageBegin("pltfm_mgr_sensor_info_get", msg_type, seqid) - result.write(oprot) - oprot.writeMessageEnd() - oprot.trans.flush() + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_tx_pwr_get_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.DOUBLE, len(self.success)) + for iter20 in self.success: + oprot.writeDouble(iter20) + oprot.writeListEnd() + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() -# HELPER FUNCTIONS AND STRUCTURES + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ -class pltfm_mgr_dummy_args(object): + def __ne__(self, other): + return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_tx_pwr_get_result) +pltfm_mgr_qsfp_chan_tx_pwr_get_result.thrift_spec = ( + (0, TType.LIST, 'success', (TType.DOUBLE, None, False), None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) + + +class pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get_args(object): """ Attributes: - - device + - port_num + """ - thrift_spec = ( - None, # 0 - (1, TType.BYTE, 'device', None, None, ), # 1 - ) - def __init__(self, device=None,): - self.device = device + def __init__(self, port_num=None,): + self.port_num = port_num def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -994,8 +5001,8 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 1: - if ftype == TType.BYTE: - self.device = iprot.readByte() + if ftype == TType.I32: + self.port_num = iprot.readI32() else: iprot.skip(ftype) else: @@ -1005,12 +5012,12 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_dummy_args') - if self.device is not None: - oprot.writeFieldBegin('device', TType.BYTE, 1) - oprot.writeByte(self.device) + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() @@ -1028,24 +5035,29 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get_args) +pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) -class pltfm_mgr_dummy_result(object): +class pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get_result(object): """ Attributes: - success + - ouch + """ - thrift_spec = ( - (0, TType.I32, 'success', None, None, ), # 0 - ) - def __init__(self, success=None,): + def __init__(self, success=None, ouch=None,): self.success = success + self.ouch = ouch def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -1053,8 +5065,20 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 0: - if ftype == TType.I32: - self.success = iprot.readI32() + if ftype == TType.LIST: + self.success = [] + (_etype24, _size21) = iprot.readListBegin() + for _i25 in range(_size21): + _elem26 = pltfm_mgr_qsfp_alarm_flags_t() + _elem26.read(iprot) + self.success.append(_elem26) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.ouch = InvalidPltfmMgrOperation() + self.ouch.read(iprot) else: iprot.skip(ftype) else: @@ -1064,12 +5088,19 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_dummy_result') + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get_result') if self.success is not None: - oprot.writeFieldBegin('success', TType.I32, 0) - oprot.writeI32(self.success) + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.STRUCT, len(self.success)) + for iter27 in self.success: + iter27.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + if self.ouch is not None: + oprot.writeFieldBegin('ouch', TType.STRUCT, 1) + self.ouch.write(oprot) oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() @@ -1087,22 +5118,38 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get_result) +pltfm_mgr_qsfp_chan_rx_pwr_alarm_flags_get_result.thrift_spec = ( + (0, TType.LIST, 'success', (TType.STRUCT, [pltfm_mgr_qsfp_alarm_flags_t, None], False), None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) -class pltfm_mgr_sys_tmp_get_args(object): +class pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get_args(object): + """ + Attributes: + - port_num + + """ - thrift_spec = ( - ) + + def __init__(self, port_num=None,): + self.port_num = port_num def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: (fname, ftype, fid) = iprot.readFieldBegin() if ftype == TType.STOP: break + if fid == 1: + if ftype == TType.I32: + self.port_num = iprot.readI32() + else: + iprot.skip(ftype) else: iprot.skip(ftype) iprot.readFieldEnd() @@ -1110,9 +5157,13 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_sys_tmp_get_args') + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) + oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() @@ -1129,19 +5180,21 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get_args) +pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) -class pltfm_mgr_sys_tmp_get_result(object): +class pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get_result(object): """ Attributes: - success - ouch + """ - thrift_spec = ( - (0, TType.STRUCT, 'success', (pltfm_mgr_sys_tmp_t, pltfm_mgr_sys_tmp_t.thrift_spec), None, ), # 0 - (1, TType.STRUCT, 'ouch', (InvalidPltfmMgrOperation, InvalidPltfmMgrOperation.thrift_spec), None, ), # 1 - ) def __init__(self, success=None, ouch=None,): self.success = success @@ -1149,7 +5202,7 @@ def __init__(self, success=None, ouch=None,): def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -1157,9 +5210,14 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 0: - if ftype == TType.STRUCT: - self.success = pltfm_mgr_sys_tmp_t() - self.success.read(iprot) + if ftype == TType.LIST: + self.success = [] + (_etype31, _size28) = iprot.readListBegin() + for _i32 in range(_size28): + _elem33 = pltfm_mgr_qsfp_alarm_flags_t() + _elem33.read(iprot) + self.success.append(_elem33) + iprot.readListEnd() else: iprot.skip(ftype) elif fid == 1: @@ -1175,12 +5233,15 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_sys_tmp_get_result') + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get_result') if self.success is not None: - oprot.writeFieldBegin('success', TType.STRUCT, 0) - self.success.write(oprot) + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.STRUCT, len(self.success)) + for iter34 in self.success: + iter34.write(oprot) + oprot.writeListEnd() oprot.writeFieldEnd() if self.ouch is not None: oprot.writeFieldBegin('ouch', TType.STRUCT, 1) @@ -1202,22 +5263,38 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get_result) +pltfm_mgr_qsfp_chan_tx_bias_alarm_flags_get_result.thrift_spec = ( + (0, TType.LIST, 'success', (TType.STRUCT, [pltfm_mgr_qsfp_alarm_flags_t, None], False), None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) -class pltfm_mgr_sys_eeprom_get_args(object): +class pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get_args(object): + """ + Attributes: + - port_num + + """ + - thrift_spec = ( - ) + def __init__(self, port_num=None,): + self.port_num = port_num def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: (fname, ftype, fid) = iprot.readFieldBegin() if ftype == TType.STOP: break + if fid == 1: + if ftype == TType.I32: + self.port_num = iprot.readI32() + else: + iprot.skip(ftype) else: iprot.skip(ftype) iprot.readFieldEnd() @@ -1225,9 +5302,13 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_sys_eeprom_get_args') + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) + oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() @@ -1244,19 +5325,21 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get_args) +pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) -class pltfm_mgr_sys_eeprom_get_result(object): +class pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get_result(object): """ Attributes: - success - ouch + """ - thrift_spec = ( - (0, TType.STRUCT, 'success', (pltfm_mgr_eeprom_t, pltfm_mgr_eeprom_t.thrift_spec), None, ), # 0 - (1, TType.STRUCT, 'ouch', (InvalidPltfmMgrOperation, InvalidPltfmMgrOperation.thrift_spec), None, ), # 1 - ) def __init__(self, success=None, ouch=None,): self.success = success @@ -1264,7 +5347,7 @@ def __init__(self, success=None, ouch=None,): def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -1272,9 +5355,14 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 0: - if ftype == TType.STRUCT: - self.success = pltfm_mgr_eeprom_t() - self.success.read(iprot) + if ftype == TType.LIST: + self.success = [] + (_etype38, _size35) = iprot.readListBegin() + for _i39 in range(_size35): + _elem40 = pltfm_mgr_qsfp_alarm_flags_t() + _elem40.read(iprot) + self.success.append(_elem40) + iprot.readListEnd() else: iprot.skip(ftype) elif fid == 1: @@ -1290,12 +5378,15 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_sys_eeprom_get_result') + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get_result') if self.success is not None: - oprot.writeFieldBegin('success', TType.STRUCT, 0) - self.success.write(oprot) + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.STRUCT, len(self.success)) + for iter41 in self.success: + iter41.write(oprot) + oprot.writeListEnd() oprot.writeFieldEnd() if self.ouch is not None: oprot.writeFieldBegin('ouch', TType.STRUCT, 1) @@ -1317,25 +5408,27 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get_result) +pltfm_mgr_qsfp_chan_tx_pwr_alarm_flags_get_result.thrift_spec = ( + (0, TType.LIST, 'success', (TType.STRUCT, [pltfm_mgr_qsfp_alarm_flags_t, None], False), None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) -class pltfm_mgr_pwr_supply_present_get_args(object): +class pltfm_mgr_qsfp_chan_rx_los_get_args(object): """ Attributes: - - ps_num + - port_num + """ - thrift_spec = ( - None, # 0 - (1, TType.I16, 'ps_num', None, None, ), # 1 - ) - def __init__(self, ps_num=None,): - self.ps_num = ps_num + def __init__(self, port_num=None,): + self.port_num = port_num def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -1343,8 +5436,8 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 1: - if ftype == TType.I16: - self.ps_num = iprot.readI16() + if ftype == TType.I32: + self.port_num = iprot.readI32() else: iprot.skip(ftype) else: @@ -1354,12 +5447,12 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_pwr_supply_present_get_args') - if self.ps_num is not None: - oprot.writeFieldBegin('ps_num', TType.I16, 1) - oprot.writeI16(self.ps_num) + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_rx_los_get_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() @@ -1377,19 +5470,21 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_rx_los_get_args) +pltfm_mgr_qsfp_chan_rx_los_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) -class pltfm_mgr_pwr_supply_present_get_result(object): +class pltfm_mgr_qsfp_chan_rx_los_get_result(object): """ Attributes: - success - ouch + """ - thrift_spec = ( - (0, TType.BOOL, 'success', None, None, ), # 0 - (1, TType.STRUCT, 'ouch', (InvalidPltfmMgrOperation, InvalidPltfmMgrOperation.thrift_spec), None, ), # 1 - ) def __init__(self, success=None, ouch=None,): self.success = success @@ -1397,7 +5492,7 @@ def __init__(self, success=None, ouch=None,): def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -1405,8 +5500,13 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 0: - if ftype == TType.BOOL: - self.success = iprot.readBool() + if ftype == TType.LIST: + self.success = [] + (_etype45, _size42) = iprot.readListBegin() + for _i46 in range(_size42): + _elem47 = iprot.readBool() + self.success.append(_elem47) + iprot.readListEnd() else: iprot.skip(ftype) elif fid == 1: @@ -1422,12 +5522,15 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_pwr_supply_present_get_result') + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_rx_los_get_result') if self.success is not None: - oprot.writeFieldBegin('success', TType.BOOL, 0) - oprot.writeBool(self.success) + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.BOOL, len(self.success)) + for iter48 in self.success: + oprot.writeBool(iter48) + oprot.writeListEnd() oprot.writeFieldEnd() if self.ouch is not None: oprot.writeFieldBegin('ouch', TType.STRUCT, 1) @@ -1449,25 +5552,27 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_rx_los_get_result) +pltfm_mgr_qsfp_chan_rx_los_get_result.thrift_spec = ( + (0, TType.LIST, 'success', (TType.BOOL, None, False), None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) -class pltfm_mgr_pwr_supply_info_get_args(object): +class pltfm_mgr_qsfp_chan_tx_los_get_args(object): """ Attributes: - - ps_num + - port_num + """ - thrift_spec = ( - None, # 0 - (1, TType.I16, 'ps_num', None, None, ), # 1 - ) - def __init__(self, ps_num=None,): - self.ps_num = ps_num + def __init__(self, port_num=None,): + self.port_num = port_num def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -1475,8 +5580,8 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 1: - if ftype == TType.I16: - self.ps_num = iprot.readI16() + if ftype == TType.I32: + self.port_num = iprot.readI32() else: iprot.skip(ftype) else: @@ -1486,12 +5591,12 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_pwr_supply_info_get_args') - if self.ps_num is not None: - oprot.writeFieldBegin('ps_num', TType.I16, 1) - oprot.writeI16(self.ps_num) + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_tx_los_get_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() @@ -1509,19 +5614,21 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_tx_los_get_args) +pltfm_mgr_qsfp_chan_tx_los_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) -class pltfm_mgr_pwr_supply_info_get_result(object): +class pltfm_mgr_qsfp_chan_tx_los_get_result(object): """ Attributes: - success - ouch + """ - thrift_spec = ( - (0, TType.STRUCT, 'success', (pltfm_mgr_pwr_supply_info_t, pltfm_mgr_pwr_supply_info_t.thrift_spec), None, ), # 0 - (1, TType.STRUCT, 'ouch', (InvalidPltfmMgrOperation, InvalidPltfmMgrOperation.thrift_spec), None, ), # 1 - ) def __init__(self, success=None, ouch=None,): self.success = success @@ -1529,7 +5636,7 @@ def __init__(self, success=None, ouch=None,): def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -1537,9 +5644,13 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 0: - if ftype == TType.STRUCT: - self.success = pltfm_mgr_pwr_supply_info_t() - self.success.read(iprot) + if ftype == TType.LIST: + self.success = [] + (_etype52, _size49) = iprot.readListBegin() + for _i53 in range(_size49): + _elem54 = iprot.readBool() + self.success.append(_elem54) + iprot.readListEnd() else: iprot.skip(ftype) elif fid == 1: @@ -1555,12 +5666,15 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_pwr_supply_info_get_result') + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_tx_los_get_result') if self.success is not None: - oprot.writeFieldBegin('success', TType.STRUCT, 0) - self.success.write(oprot) + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.BOOL, len(self.success)) + for iter55 in self.success: + oprot.writeBool(iter55) + oprot.writeListEnd() oprot.writeFieldEnd() if self.ouch is not None: oprot.writeFieldBegin('ouch', TType.STRUCT, 1) @@ -1582,25 +5696,27 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_tx_los_get_result) +pltfm_mgr_qsfp_chan_tx_los_get_result.thrift_spec = ( + (0, TType.LIST, 'success', (TType.BOOL, None, False), None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) -class pltfm_mgr_pwr_rail_info_get_args(object): +class pltfm_mgr_qsfp_chan_tx_fault_get_args(object): """ Attributes: - - ps_num + - port_num + """ - thrift_spec = ( - None, # 0 - (1, TType.I16, 'ps_num', None, None, ), # 1 - ) - def __init__(self, ps_num=None,): - self.ps_num = ps_num + def __init__(self, port_num=None,): + self.port_num = port_num def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -1608,8 +5724,8 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 1: - if ftype == TType.I16: - self.ps_num = iprot.readI16() + if ftype == TType.I32: + self.port_num = iprot.readI32() else: iprot.skip(ftype) else: @@ -1619,12 +5735,12 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_pwr_rail_info_get_args') - if self.ps_num is not None: - oprot.writeFieldBegin('ps_num', TType.I16, 1) - oprot.writeI16(self.ps_num) + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_tx_fault_get_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() @@ -1642,19 +5758,21 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_tx_fault_get_args) +pltfm_mgr_qsfp_chan_tx_fault_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) -class pltfm_mgr_pwr_rail_info_get_result(object): +class pltfm_mgr_qsfp_chan_tx_fault_get_result(object): """ Attributes: - success - ouch + """ - thrift_spec = ( - (0, TType.STRUCT, 'success', (pltfm_mgr_pwr_rail_info_t, pltfm_mgr_pwr_rail_info_t.thrift_spec), None, ), # 0 - (1, TType.STRUCT, 'ouch', (InvalidPltfmMgrOperation, InvalidPltfmMgrOperation.thrift_spec), None, ), # 1 - ) def __init__(self, success=None, ouch=None,): self.success = success @@ -1662,7 +5780,7 @@ def __init__(self, success=None, ouch=None,): def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -1670,9 +5788,13 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 0: - if ftype == TType.STRUCT: - self.success = pltfm_mgr_pwr_rail_info_t() - self.success.read(iprot) + if ftype == TType.LIST: + self.success = [] + (_etype59, _size56) = iprot.readListBegin() + for _i60 in range(_size56): + _elem61 = iprot.readBool() + self.success.append(_elem61) + iprot.readListEnd() else: iprot.skip(ftype) elif fid == 1: @@ -1688,12 +5810,15 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_pwr_rail_info_get_result') + oprot.writeStructBegin('pltfm_mgr_qsfp_chan_tx_fault_get_result') if self.success is not None: - oprot.writeFieldBegin('success', TType.STRUCT, 0) - self.success.write(oprot) + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.BOOL, len(self.success)) + for iter62 in self.success: + oprot.writeBool(iter62) + oprot.writeListEnd() oprot.writeFieldEnd() if self.ouch is not None: oprot.writeFieldBegin('ouch', TType.STRUCT, 1) @@ -1715,28 +5840,27 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_chan_tx_fault_get_result) +pltfm_mgr_qsfp_chan_tx_fault_get_result.thrift_spec = ( + (0, TType.LIST, 'success', (TType.BOOL, None, False), None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) -class pltfm_mgr_fan_speed_set_args(object): +class pltfm_mgr_qsfp_temperature_get_args(object): """ Attributes: - - fan_num - - percent + - port_num + """ - thrift_spec = ( - None, # 0 - (1, TType.I32, 'fan_num', None, None, ), # 1 - (2, TType.I32, 'percent', None, None, ), # 2 - ) - def __init__(self, fan_num=None, percent=None,): - self.fan_num = fan_num - self.percent = percent + def __init__(self, port_num=None,): + self.port_num = port_num def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -1745,12 +5869,7 @@ def read(self, iprot): break if fid == 1: if ftype == TType.I32: - self.fan_num = iprot.readI32() - else: - iprot.skip(ftype) - elif fid == 2: - if ftype == TType.I32: - self.percent = iprot.readI32() + self.port_num = iprot.readI32() else: iprot.skip(ftype) else: @@ -1760,16 +5879,12 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_fan_speed_set_args') - if self.fan_num is not None: - oprot.writeFieldBegin('fan_num', TType.I32, 1) - oprot.writeI32(self.fan_num) - oprot.writeFieldEnd() - if self.percent is not None: - oprot.writeFieldBegin('percent', TType.I32, 2) - oprot.writeI32(self.percent) + oprot.writeStructBegin('pltfm_mgr_qsfp_temperature_get_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() @@ -1787,19 +5902,21 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_temperature_get_args) +pltfm_mgr_qsfp_temperature_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) -class pltfm_mgr_fan_speed_set_result(object): +class pltfm_mgr_qsfp_temperature_get_result(object): """ Attributes: - success - ouch + """ - thrift_spec = ( - (0, TType.I32, 'success', None, None, ), # 0 - (1, TType.STRUCT, 'ouch', (InvalidPltfmMgrOperation, InvalidPltfmMgrOperation.thrift_spec), None, ), # 1 - ) def __init__(self, success=None, ouch=None,): self.success = success @@ -1807,7 +5924,7 @@ def __init__(self, success=None, ouch=None,): def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -1815,8 +5932,8 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 0: - if ftype == TType.I32: - self.success = iprot.readI32() + if ftype == TType.DOUBLE: + self.success = iprot.readDouble() else: iprot.skip(ftype) elif fid == 1: @@ -1832,12 +5949,12 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_fan_speed_set_result') + oprot.writeStructBegin('pltfm_mgr_qsfp_temperature_get_result') if self.success is not None: - oprot.writeFieldBegin('success', TType.I32, 0) - oprot.writeI32(self.success) + oprot.writeFieldBegin('success', TType.DOUBLE, 0) + oprot.writeDouble(self.success) oprot.writeFieldEnd() if self.ouch is not None: oprot.writeFieldBegin('ouch', TType.STRUCT, 1) @@ -1859,25 +5976,27 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_temperature_get_result) +pltfm_mgr_qsfp_temperature_get_result.thrift_spec = ( + (0, TType.DOUBLE, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) -class pltfm_mgr_fan_info_get_args(object): +class pltfm_mgr_qsfp_voltage_get_args(object): """ Attributes: - - fan_num + - port_num + """ - thrift_spec = ( - None, # 0 - (1, TType.I32, 'fan_num', None, None, ), # 1 - ) - def __init__(self, fan_num=None,): - self.fan_num = fan_num + def __init__(self, port_num=None,): + self.port_num = port_num def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -1886,7 +6005,7 @@ def read(self, iprot): break if fid == 1: if ftype == TType.I32: - self.fan_num = iprot.readI32() + self.port_num = iprot.readI32() else: iprot.skip(ftype) else: @@ -1896,12 +6015,12 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_fan_info_get_args') - if self.fan_num is not None: - oprot.writeFieldBegin('fan_num', TType.I32, 1) - oprot.writeI32(self.fan_num) + oprot.writeStructBegin('pltfm_mgr_qsfp_voltage_get_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() @@ -1919,19 +6038,21 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_voltage_get_args) +pltfm_mgr_qsfp_voltage_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) -class pltfm_mgr_fan_info_get_result(object): +class pltfm_mgr_qsfp_voltage_get_result(object): """ Attributes: - success - ouch + """ - thrift_spec = ( - (0, TType.STRUCT, 'success', (pltfm_mgr_fan_info_t, pltfm_mgr_fan_info_t.thrift_spec), None, ), # 0 - (1, TType.STRUCT, 'ouch', (InvalidPltfmMgrOperation, InvalidPltfmMgrOperation.thrift_spec), None, ), # 1 - ) def __init__(self, success=None, ouch=None,): self.success = success @@ -1939,7 +6060,7 @@ def __init__(self, success=None, ouch=None,): def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -1947,9 +6068,8 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 0: - if ftype == TType.STRUCT: - self.success = pltfm_mgr_fan_info_t() - self.success.read(iprot) + if ftype == TType.DOUBLE: + self.success = iprot.readDouble() else: iprot.skip(ftype) elif fid == 1: @@ -1965,12 +6085,12 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_fan_info_get_result') + oprot.writeStructBegin('pltfm_mgr_qsfp_voltage_get_result') if self.success is not None: - oprot.writeFieldBegin('success', TType.STRUCT, 0) - self.success.write(oprot) + oprot.writeFieldBegin('success', TType.DOUBLE, 0) + oprot.writeDouble(self.success) oprot.writeFieldEnd() if self.ouch is not None: oprot.writeFieldBegin('ouch', TType.STRUCT, 1) @@ -1992,25 +6112,27 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_voltage_get_result) +pltfm_mgr_qsfp_voltage_get_result.thrift_spec = ( + (0, TType.DOUBLE, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) -class pltfm_mgr_qsfp_presence_get_args(object): +class pltfm_mgr_qsfp_thresholds_get_args(object): """ Attributes: - port_num + """ - thrift_spec = ( - None, # 0 - (1, TType.I32, 'port_num', None, None, ), # 1 - ) def __init__(self, port_num=None,): self.port_num = port_num def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -2029,9 +6151,9 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_qsfp_presence_get_args') + oprot.writeStructBegin('pltfm_mgr_qsfp_thresholds_get_args') if self.port_num is not None: oprot.writeFieldBegin('port_num', TType.I32, 1) oprot.writeI32(self.port_num) @@ -2052,19 +6174,21 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_thresholds_get_args) +pltfm_mgr_qsfp_thresholds_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) -class pltfm_mgr_qsfp_presence_get_result(object): +class pltfm_mgr_qsfp_thresholds_get_result(object): """ Attributes: - success - ouch + """ - thrift_spec = ( - (0, TType.BOOL, 'success', None, None, ), # 0 - (1, TType.STRUCT, 'ouch', (InvalidPltfmMgrOperation, InvalidPltfmMgrOperation.thrift_spec), None, ), # 1 - ) def __init__(self, success=None, ouch=None,): self.success = success @@ -2072,7 +6196,7 @@ def __init__(self, success=None, ouch=None,): def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -2080,8 +6204,9 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 0: - if ftype == TType.BOOL: - self.success = iprot.readBool() + if ftype == TType.STRUCT: + self.success = pltfm_mgr_qsfp_thresholds_t() + self.success.read(iprot) else: iprot.skip(ftype) elif fid == 1: @@ -2097,12 +6222,12 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_qsfp_presence_get_result') + oprot.writeStructBegin('pltfm_mgr_qsfp_thresholds_get_result') if self.success is not None: - oprot.writeFieldBegin('success', TType.BOOL, 0) - oprot.writeBool(self.success) + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) oprot.writeFieldEnd() if self.ouch is not None: oprot.writeFieldBegin('ouch', TType.STRUCT, 1) @@ -2124,25 +6249,29 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_thresholds_get_result) +pltfm_mgr_qsfp_thresholds_get_result.thrift_spec = ( + (0, TType.STRUCT, 'success', [pltfm_mgr_qsfp_thresholds_t, None], None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) -class pltfm_mgr_qsfp_info_get_args(object): +class pltfm_mgr_qsfp_tx_is_disabled_args(object): """ Attributes: - port_num + - channel + """ - thrift_spec = ( - None, # 0 - (1, TType.I32, 'port_num', None, None, ), # 1 - ) - def __init__(self, port_num=None,): + def __init__(self, port_num=None, channel=None,): self.port_num = port_num + self.channel = channel def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -2154,6 +6283,11 @@ def read(self, iprot): self.port_num = iprot.readI32() else: iprot.skip(ftype) + elif fid == 2: + if ftype == TType.I32: + self.channel = iprot.readI32() + else: + iprot.skip(ftype) else: iprot.skip(ftype) iprot.readFieldEnd() @@ -2161,13 +6295,17 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_qsfp_info_get_args') + oprot.writeStructBegin('pltfm_mgr_qsfp_tx_is_disabled_args') if self.port_num is not None: oprot.writeFieldBegin('port_num', TType.I32, 1) oprot.writeI32(self.port_num) oprot.writeFieldEnd() + if self.channel is not None: + oprot.writeFieldBegin('channel', TType.I32, 2) + oprot.writeI32(self.channel) + oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() @@ -2184,19 +6322,22 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_tx_is_disabled_args) +pltfm_mgr_qsfp_tx_is_disabled_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 + (2, TType.I32, 'channel', None, None, ), # 2 +) -class pltfm_mgr_qsfp_info_get_result(object): +class pltfm_mgr_qsfp_tx_is_disabled_result(object): """ Attributes: - success - ouch + """ - thrift_spec = ( - (0, TType.STRING, 'success', 'UTF8', None, ), # 0 - (1, TType.STRUCT, 'ouch', (InvalidPltfmMgrOperation, InvalidPltfmMgrOperation.thrift_spec), None, ), # 1 - ) def __init__(self, success=None, ouch=None,): self.success = success @@ -2204,7 +6345,7 @@ def __init__(self, success=None, ouch=None,): def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -2212,8 +6353,8 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 0: - if ftype == TType.STRING: - self.success = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + if ftype == TType.BOOL: + self.success = iprot.readBool() else: iprot.skip(ftype) elif fid == 1: @@ -2229,12 +6370,12 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_qsfp_info_get_result') + oprot.writeStructBegin('pltfm_mgr_qsfp_tx_is_disabled_result') if self.success is not None: - oprot.writeFieldBegin('success', TType.STRING, 0) - oprot.writeString(self.success.encode('utf-8') if sys.version_info[0] == 2 else self.success) + oprot.writeFieldBegin('success', TType.BOOL, 0) + oprot.writeBool(self.success) oprot.writeFieldEnd() if self.ouch is not None: oprot.writeFieldBegin('ouch', TType.STRUCT, 1) @@ -2256,22 +6397,38 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_tx_is_disabled_result) +pltfm_mgr_qsfp_tx_is_disabled_result.thrift_spec = ( + (0, TType.BOOL, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) -class pltfm_mgr_qsfp_get_max_port_args(object): +class pltfm_mgr_qsfp_lpmode_get_args(object): + """ + Attributes: + - port_num + + """ + - thrift_spec = ( - ) + def __init__(self, port_num=None,): + self.port_num = port_num def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: (fname, ftype, fid) = iprot.readFieldBegin() if ftype == TType.STOP: break + if fid == 1: + if ftype == TType.I32: + self.port_num = iprot.readI32() + else: + iprot.skip(ftype) else: iprot.skip(ftype) iprot.readFieldEnd() @@ -2279,9 +6436,13 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_qsfp_get_max_port_args') + oprot.writeStructBegin('pltfm_mgr_qsfp_lpmode_get_args') + if self.port_num is not None: + oprot.writeFieldBegin('port_num', TType.I32, 1) + oprot.writeI32(self.port_num) + oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() @@ -2298,19 +6459,21 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_lpmode_get_args) +pltfm_mgr_qsfp_lpmode_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) -class pltfm_mgr_qsfp_get_max_port_result(object): +class pltfm_mgr_qsfp_lpmode_get_result(object): """ Attributes: - success - ouch + """ - thrift_spec = ( - (0, TType.I32, 'success', None, None, ), # 0 - (1, TType.STRUCT, 'ouch', (InvalidPltfmMgrOperation, InvalidPltfmMgrOperation.thrift_spec), None, ), # 1 - ) def __init__(self, success=None, ouch=None,): self.success = success @@ -2318,7 +6481,7 @@ def __init__(self, success=None, ouch=None,): def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -2326,8 +6489,8 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 0: - if ftype == TType.I32: - self.success = iprot.readI32() + if ftype == TType.BOOL: + self.success = iprot.readBool() else: iprot.skip(ftype) elif fid == 1: @@ -2343,12 +6506,12 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_qsfp_get_max_port_result') + oprot.writeStructBegin('pltfm_mgr_qsfp_lpmode_get_result') if self.success is not None: - oprot.writeFieldBegin('success', TType.I32, 0) - oprot.writeI32(self.success) + oprot.writeFieldBegin('success', TType.BOOL, 0) + oprot.writeBool(self.success) oprot.writeFieldEnd() if self.ouch is not None: oprot.writeFieldBegin('ouch', TType.STRUCT, 1) @@ -2370,28 +6533,27 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_lpmode_get_result) +pltfm_mgr_qsfp_lpmode_get_result.thrift_spec = ( + (0, TType.BOOL, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) -class pltfm_mgr_qsfp_reset_args(object): +class pltfm_mgr_qsfp_pwr_override_get_args(object): """ Attributes: - port_num - - reset + """ - thrift_spec = ( - None, # 0 - (1, TType.I32, 'port_num', None, None, ), # 1 - (2, TType.BOOL, 'reset', None, None, ), # 2 - ) - def __init__(self, port_num=None, reset=None,): + def __init__(self, port_num=None,): self.port_num = port_num - self.reset = reset def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -2403,11 +6565,6 @@ def read(self, iprot): self.port_num = iprot.readI32() else: iprot.skip(ftype) - elif fid == 2: - if ftype == TType.BOOL: - self.reset = iprot.readBool() - else: - iprot.skip(ftype) else: iprot.skip(ftype) iprot.readFieldEnd() @@ -2415,17 +6572,13 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_qsfp_reset_args') + oprot.writeStructBegin('pltfm_mgr_qsfp_pwr_override_get_args') if self.port_num is not None: oprot.writeFieldBegin('port_num', TType.I32, 1) oprot.writeI32(self.port_num) oprot.writeFieldEnd() - if self.reset is not None: - oprot.writeFieldBegin('reset', TType.BOOL, 2) - oprot.writeBool(self.reset) - oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() @@ -2442,19 +6595,21 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_pwr_override_get_args) +pltfm_mgr_qsfp_pwr_override_get_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 +) -class pltfm_mgr_qsfp_reset_result(object): +class pltfm_mgr_qsfp_pwr_override_get_result(object): """ Attributes: - success - ouch + """ - thrift_spec = ( - (0, TType.I32, 'success', None, None, ), # 0 - (1, TType.STRUCT, 'ouch', (InvalidPltfmMgrOperation, InvalidPltfmMgrOperation.thrift_spec), None, ), # 1 - ) def __init__(self, success=None, ouch=None,): self.success = success @@ -2462,7 +6617,7 @@ def __init__(self, success=None, ouch=None,): def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -2470,8 +6625,8 @@ def read(self, iprot): if ftype == TType.STOP: break if fid == 0: - if ftype == TType.I32: - self.success = iprot.readI32() + if ftype == TType.BOOL: + self.success = iprot.readBool() else: iprot.skip(ftype) elif fid == 1: @@ -2487,12 +6642,12 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_qsfp_reset_result') + oprot.writeStructBegin('pltfm_mgr_qsfp_pwr_override_get_result') if self.success is not None: - oprot.writeFieldBegin('success', TType.I32, 0) - oprot.writeI32(self.success) + oprot.writeFieldBegin('success', TType.BOOL, 0) + oprot.writeBool(self.success) oprot.writeFieldEnd() if self.ouch is not None: oprot.writeFieldBegin('ouch', TType.STRUCT, 1) @@ -2514,25 +6669,31 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_pwr_override_get_result) +pltfm_mgr_qsfp_pwr_override_get_result.thrift_spec = ( + (0, TType.BOOL, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) -class pltfm_mgr_qsfp_lpmode_get_args(object): +class pltfm_mgr_qsfp_pwr_override_set_args(object): """ Attributes: - port_num + - power_override + - power_set + """ - thrift_spec = ( - None, # 0 - (1, TType.I32, 'port_num', None, None, ), # 1 - ) - def __init__(self, port_num=None,): + def __init__(self, port_num=None, power_override=None, power_set=None,): self.port_num = port_num + self.power_override = power_override + self.power_set = power_set def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -2544,6 +6705,16 @@ def read(self, iprot): self.port_num = iprot.readI32() else: iprot.skip(ftype) + elif fid == 2: + if ftype == TType.BOOL: + self.power_override = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.BOOL: + self.power_set = iprot.readBool() + else: + iprot.skip(ftype) else: iprot.skip(ftype) iprot.readFieldEnd() @@ -2551,13 +6722,21 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_qsfp_lpmode_get_args') + oprot.writeStructBegin('pltfm_mgr_qsfp_pwr_override_set_args') if self.port_num is not None: oprot.writeFieldBegin('port_num', TType.I32, 1) oprot.writeI32(self.port_num) oprot.writeFieldEnd() + if self.power_override is not None: + oprot.writeFieldBegin('power_override', TType.BOOL, 2) + oprot.writeBool(self.power_override) + oprot.writeFieldEnd() + if self.power_set is not None: + oprot.writeFieldBegin('power_set', TType.BOOL, 3) + oprot.writeBool(self.power_set) + oprot.writeFieldEnd() oprot.writeFieldStop() oprot.writeStructEnd() @@ -2574,19 +6753,23 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_pwr_override_set_args) +pltfm_mgr_qsfp_pwr_override_set_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 + (2, TType.BOOL, 'power_override', None, None, ), # 2 + (3, TType.BOOL, 'power_set', None, None, ), # 3 +) -class pltfm_mgr_qsfp_lpmode_get_result(object): +class pltfm_mgr_qsfp_pwr_override_set_result(object): """ Attributes: - success - ouch + """ - thrift_spec = ( - (0, TType.BOOL, 'success', None, None, ), # 0 - (1, TType.STRUCT, 'ouch', (InvalidPltfmMgrOperation, InvalidPltfmMgrOperation.thrift_spec), None, ), # 1 - ) def __init__(self, success=None, ouch=None,): self.success = success @@ -2594,7 +6777,7 @@ def __init__(self, success=None, ouch=None,): def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -2619,9 +6802,9 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return - oprot.writeStructBegin('pltfm_mgr_qsfp_lpmode_get_result') + oprot.writeStructBegin('pltfm_mgr_qsfp_pwr_override_set_result') if self.success is not None: oprot.writeFieldBegin('success', TType.BOOL, 0) oprot.writeBool(self.success) @@ -2646,6 +6829,11 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_pwr_override_set_result) +pltfm_mgr_qsfp_pwr_override_set_result.thrift_spec = ( + (0, TType.BOOL, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) class pltfm_mgr_qsfp_lpmode_set_args(object): @@ -2653,13 +6841,9 @@ class pltfm_mgr_qsfp_lpmode_set_args(object): Attributes: - port_num - lpmode + """ - thrift_spec = ( - None, # 0 - (1, TType.I32, 'port_num', None, None, ), # 1 - (2, TType.BOOL, 'lpmode', None, None, ), # 2 - ) def __init__(self, port_num=None, lpmode=None,): self.port_num = port_num @@ -2667,7 +6851,7 @@ def __init__(self, port_num=None, lpmode=None,): def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -2691,7 +6875,7 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return oprot.writeStructBegin('pltfm_mgr_qsfp_lpmode_set_args') if self.port_num is not None: @@ -2718,6 +6902,12 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_lpmode_set_args) +pltfm_mgr_qsfp_lpmode_set_args.thrift_spec = ( + None, # 0 + (1, TType.I32, 'port_num', None, None, ), # 1 + (2, TType.BOOL, 'lpmode', None, None, ), # 2 +) class pltfm_mgr_qsfp_lpmode_set_result(object): @@ -2725,12 +6915,9 @@ class pltfm_mgr_qsfp_lpmode_set_result(object): Attributes: - success - ouch + """ - thrift_spec = ( - (0, TType.I32, 'success', None, None, ), # 0 - (1, TType.STRUCT, 'ouch', (InvalidPltfmMgrOperation, InvalidPltfmMgrOperation.thrift_spec), None, ), # 1 - ) def __init__(self, success=None, ouch=None,): self.success = success @@ -2738,7 +6925,7 @@ def __init__(self, success=None, ouch=None,): def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -2763,7 +6950,7 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return oprot.writeStructBegin('pltfm_mgr_qsfp_lpmode_set_result') if self.success is not None: @@ -2790,25 +6977,27 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_qsfp_lpmode_set_result) +pltfm_mgr_qsfp_lpmode_set_result.thrift_spec = ( + (0, TType.I32, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) class pltfm_mgr_sensor_info_get_args(object): """ Attributes: - options + """ - thrift_spec = ( - None, # 0 - (1, TType.STRING, 'options', 'UTF8', None, ), # 1 - ) def __init__(self, options=None,): self.options = options def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -2827,7 +7016,7 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return oprot.writeStructBegin('pltfm_mgr_sensor_info_get_args') if self.options is not None: @@ -2850,6 +7039,11 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_sensor_info_get_args) +pltfm_mgr_sensor_info_get_args.thrift_spec = ( + None, # 0 + (1, TType.STRING, 'options', 'UTF8', None, ), # 1 +) class pltfm_mgr_sensor_info_get_result(object): @@ -2857,12 +7051,9 @@ class pltfm_mgr_sensor_info_get_result(object): Attributes: - success - ouch + """ - thrift_spec = ( - (0, TType.STRING, 'success', 'UTF8', None, ), # 0 - (1, TType.STRUCT, 'ouch', (InvalidPltfmMgrOperation, InvalidPltfmMgrOperation.thrift_spec), None, ), # 1 - ) def __init__(self, success=None, ouch=None,): self.success = success @@ -2870,7 +7061,7 @@ def __init__(self, success=None, ouch=None,): def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -2895,7 +7086,7 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return oprot.writeStructBegin('pltfm_mgr_sensor_info_get_result') if self.success is not None: @@ -2922,3 +7113,11 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_sensor_info_get_result) +pltfm_mgr_sensor_info_get_result.thrift_spec = ( + (0, TType.STRING, 'success', 'UTF8', None, ), # 0 + (1, TType.STRUCT, 'ouch', [InvalidPltfmMgrOperation, None], None, ), # 1 +) +fix_spec(all_structs) +del all_structs + diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/pltfm_mgr_rpc/ttypes.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/pltfm_mgr_rpc/ttypes.py index ce03e14f8691..da4a62d4eeff 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/pltfm_mgr_rpc/ttypes.py +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/pltfm_mgr_rpc/ttypes.py @@ -1,5 +1,5 @@ # -# Autogenerated by Thrift Compiler (0.10.0) +# Autogenerated by Thrift Compiler (0.13.0) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # @@ -8,9 +8,12 @@ from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException from thrift.protocol.TProtocol import TProtocolException +from thrift.TRecursive import fix_spec + import sys from thrift.transport import TTransport +all_structs = [] class pltfm_mgr_sys_tmp_t(object): @@ -26,21 +29,9 @@ class pltfm_mgr_sys_tmp_t(object): - tmp8 - tmp9 - tmp10 + """ - thrift_spec = ( - None, # 0 - (1, TType.DOUBLE, 'tmp1', None, None, ), # 1 - (2, TType.DOUBLE, 'tmp2', None, None, ), # 2 - (3, TType.DOUBLE, 'tmp3', None, None, ), # 3 - (4, TType.DOUBLE, 'tmp4', None, None, ), # 4 - (5, TType.DOUBLE, 'tmp5', None, None, ), # 5 - (6, TType.DOUBLE, 'tmp6', None, None, ), # 6 - (7, TType.DOUBLE, 'tmp7', None, None, ), # 7 - (8, TType.DOUBLE, 'tmp8', None, None, ), # 8 - (9, TType.DOUBLE, 'tmp9', None, None, ), # 9 - (10, TType.DOUBLE, 'tmp10', None, None, ), # 10 - ) def __init__(self, tmp1=None, tmp2=None, tmp3=None, tmp4=None, tmp5=None, tmp6=None, tmp7=None, tmp8=None, tmp9=None, tmp10=None,): self.tmp1 = tmp1 @@ -56,7 +47,7 @@ def __init__(self, tmp1=None, tmp2=None, tmp3=None, tmp4=None, tmp5=None, tmp6=N def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -120,7 +111,7 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return oprot.writeStructBegin('pltfm_mgr_sys_tmp_t') if self.tmp1 is not None: @@ -206,33 +197,9 @@ class pltfm_mgr_eeprom_t(object): - ext_mac_addr_size - location - crc8 + """ - thrift_spec = ( - None, # 0 - (1, TType.I16, 'version', None, None, ), # 1 - (2, TType.STRING, 'prod_name', 'UTF8', None, ), # 2 - (3, TType.STRING, 'prod_part_num', 'UTF8', None, ), # 3 - (4, TType.STRING, 'sys_asm_part_num', 'UTF8', None, ), # 4 - (5, TType.STRING, 'bfn_pcba_part_num', 'UTF8', None, ), # 5 - (6, TType.STRING, 'bfn_pcbb_part_num', 'UTF8', None, ), # 6 - (7, TType.STRING, 'odm_pcba_part_num', 'UTF8', None, ), # 7 - (8, TType.STRING, 'odm_pcba_ser_num', 'UTF8', None, ), # 8 - (9, TType.I16, 'prod_state', None, None, ), # 9 - (10, TType.I16, 'prod_ver', None, None, ), # 10 - (11, TType.I16, 'prod_sub_ver', None, None, ), # 11 - (12, TType.STRING, 'prod_ser_num', 'UTF8', None, ), # 12 - (13, TType.STRING, 'prod_ast_tag', 'UTF8', None, ), # 13 - (14, TType.STRING, 'sys_mfger', 'UTF8', None, ), # 14 - (15, TType.STRING, 'sys_mfg_date', 'UTF8', None, ), # 15 - (16, TType.STRING, 'pcb_mfger', 'UTF8', None, ), # 16 - (17, TType.STRING, 'assembled_at', 'UTF8', None, ), # 17 - (18, TType.STRING, 'loc_mac_addr', 'UTF8', None, ), # 18 - (19, TType.STRING, 'ext_mac_addr', 'UTF8', None, ), # 19 - (20, TType.I32, 'ext_mac_addr_size', None, None, ), # 20 - (21, TType.STRING, 'location', 'UTF8', None, ), # 21 - (22, TType.I16, 'crc8', None, None, ), # 22 - ) def __init__(self, version=None, prod_name=None, prod_part_num=None, sys_asm_part_num=None, bfn_pcba_part_num=None, bfn_pcbb_part_num=None, odm_pcba_part_num=None, odm_pcba_ser_num=None, prod_state=None, prod_ver=None, prod_sub_ver=None, prod_ser_num=None, prod_ast_tag=None, sys_mfger=None, sys_mfg_date=None, pcb_mfger=None, assembled_at=None, loc_mac_addr=None, ext_mac_addr=None, ext_mac_addr_size=None, location=None, crc8=None,): self.version = version @@ -260,7 +227,7 @@ def __init__(self, version=None, prod_name=None, prod_part_num=None, sys_asm_par def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -384,7 +351,7 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return oprot.writeStructBegin('pltfm_mgr_eeprom_t') if self.version is not None: @@ -506,21 +473,9 @@ class pltfm_mgr_pwr_supply_info_t(object): - model - serial - rev + """ - thrift_spec = ( - None, # 0 - (1, TType.I32, 'vin', None, None, ), # 1 - (2, TType.I32, 'vout', None, None, ), # 2 - (3, TType.I32, 'iout', None, None, ), # 3 - (4, TType.I32, 'pwr_out', None, None, ), # 4 - (5, TType.I32, 'fspeed', None, None, ), # 5 - (6, TType.BOOL, 'ffault', None, None, ), # 6 - (7, TType.BOOL, 'load_sharing', None, None, ), # 7 - (8, TType.STRING, 'model', 'UTF8', None, ), # 8 - (9, TType.STRING, 'serial', 'UTF8', None, ), # 9 - (10, TType.STRING, 'rev', 'UTF8', None, ), # 10 - ) def __init__(self, vin=None, vout=None, iout=None, pwr_out=None, fspeed=None, ffault=None, load_sharing=None, model=None, serial=None, rev=None,): self.vin = vin @@ -536,7 +491,7 @@ def __init__(self, vin=None, vout=None, iout=None, pwr_out=None, fspeed=None, ff def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -600,7 +555,7 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return oprot.writeStructBegin('pltfm_mgr_pwr_supply_info_t') if self.vin is not None: @@ -680,27 +635,9 @@ class pltfm_mgr_pwr_rail_info_t(object): - vrail14 - vrail15 - vrail16 + """ - thrift_spec = ( - None, # 0 - (1, TType.I32, 'vrail1', None, None, ), # 1 - (2, TType.I32, 'vrail2', None, None, ), # 2 - (3, TType.I32, 'vrail3', None, None, ), # 3 - (4, TType.I32, 'vrail4', None, None, ), # 4 - (5, TType.I32, 'vrail5', None, None, ), # 5 - (6, TType.I32, 'vrail6', None, None, ), # 6 - (7, TType.I32, 'vrail7', None, None, ), # 7 - (8, TType.I32, 'vrail8', None, None, ), # 8 - (9, TType.I32, 'vrail9', None, None, ), # 9 - (10, TType.I32, 'vrail10', None, None, ), # 10 - (11, TType.I32, 'vrail11', None, None, ), # 11 - (12, TType.I32, 'vrail12', None, None, ), # 12 - (13, TType.I32, 'vrail13', None, None, ), # 13 - (14, TType.I32, 'vrail14', None, None, ), # 14 - (15, TType.I32, 'vrail15', None, None, ), # 15 - (16, TType.I32, 'vrail16', None, None, ), # 16 - ) def __init__(self, vrail1=None, vrail2=None, vrail3=None, vrail4=None, vrail5=None, vrail6=None, vrail7=None, vrail8=None, vrail9=None, vrail10=None, vrail11=None, vrail12=None, vrail13=None, vrail14=None, vrail15=None, vrail16=None,): self.vrail1 = vrail1 @@ -722,7 +659,7 @@ def __init__(self, vrail1=None, vrail2=None, vrail3=None, vrail4=None, vrail5=No def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -816,7 +753,7 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return oprot.writeStructBegin('pltfm_mgr_pwr_rail_info_t') if self.vrail1 is not None: @@ -908,15 +845,9 @@ class pltfm_mgr_fan_info_t(object): - front_rpm - rear_rpm - percent + """ - thrift_spec = ( - None, # 0 - (1, TType.I32, 'fan_num', None, None, ), # 1 - (2, TType.I32, 'front_rpm', None, None, ), # 2 - (3, TType.I32, 'rear_rpm', None, None, ), # 3 - (4, TType.I32, 'percent', None, None, ), # 4 - ) def __init__(self, fan_num=None, front_rpm=None, rear_rpm=None, percent=None,): self.fan_num = fan_num @@ -926,7 +857,7 @@ def __init__(self, fan_num=None, front_rpm=None, rear_rpm=None, percent=None,): def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -960,7 +891,7 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return oprot.writeStructBegin('pltfm_mgr_fan_info_t') if self.fan_num is not None: @@ -997,23 +928,361 @@ def __ne__(self, other): return not (self == other) +class pltfm_mgr_qsfp_alarm_flags_t(object): + """ + Attributes: + - highalarm + - lowalarm + - highwarning + - lowwarning + + """ + + + def __init__(self, highalarm=None, lowalarm=None, highwarning=None, lowwarning=None,): + self.highalarm = highalarm + self.lowalarm = lowalarm + self.highwarning = highwarning + self.lowwarning = lowwarning + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.BOOL: + self.highalarm = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.BOOL: + self.lowalarm = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.BOOL: + self.highwarning = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.BOOL: + self.lowwarning = iprot.readBool() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_alarm_flags_t') + if self.highalarm is not None: + oprot.writeFieldBegin('highalarm', TType.BOOL, 1) + oprot.writeBool(self.highalarm) + oprot.writeFieldEnd() + if self.lowalarm is not None: + oprot.writeFieldBegin('lowalarm', TType.BOOL, 2) + oprot.writeBool(self.lowalarm) + oprot.writeFieldEnd() + if self.highwarning is not None: + oprot.writeFieldBegin('highwarning', TType.BOOL, 3) + oprot.writeBool(self.highwarning) + oprot.writeFieldEnd() + if self.lowwarning is not None: + oprot.writeFieldBegin('lowwarning', TType.BOOL, 4) + oprot.writeBool(self.lowwarning) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class pltfm_mgr_qsfp_threshold_t(object): + """ + Attributes: + - highalarm + - lowalarm + - highwarning + - lowwarning + + """ + + + def __init__(self, highalarm=None, lowalarm=None, highwarning=None, lowwarning=None,): + self.highalarm = highalarm + self.lowalarm = lowalarm + self.highwarning = highwarning + self.lowwarning = lowwarning + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.DOUBLE: + self.highalarm = iprot.readDouble() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.DOUBLE: + self.lowalarm = iprot.readDouble() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.DOUBLE: + self.highwarning = iprot.readDouble() + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.DOUBLE: + self.lowwarning = iprot.readDouble() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_threshold_t') + if self.highalarm is not None: + oprot.writeFieldBegin('highalarm', TType.DOUBLE, 1) + oprot.writeDouble(self.highalarm) + oprot.writeFieldEnd() + if self.lowalarm is not None: + oprot.writeFieldBegin('lowalarm', TType.DOUBLE, 2) + oprot.writeDouble(self.lowalarm) + oprot.writeFieldEnd() + if self.highwarning is not None: + oprot.writeFieldBegin('highwarning', TType.DOUBLE, 3) + oprot.writeDouble(self.highwarning) + oprot.writeFieldEnd() + if self.lowwarning is not None: + oprot.writeFieldBegin('lowwarning', TType.DOUBLE, 4) + oprot.writeDouble(self.lowwarning) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class pltfm_mgr_qsfp_thresholds_t(object): + """ + Attributes: + - rx_pwr + - temp + - tx_bias + - tx_pwr + - vcc + - rx_pwr_is_set + - temp_is_set + - tx_bias_is_set + - tx_pwr_is_set + - vcc_is_set + + """ + + + def __init__(self, rx_pwr=None, temp=None, tx_bias=None, tx_pwr=None, vcc=None, rx_pwr_is_set=None, temp_is_set=None, tx_bias_is_set=None, tx_pwr_is_set=None, vcc_is_set=None,): + self.rx_pwr = rx_pwr + self.temp = temp + self.tx_bias = tx_bias + self.tx_pwr = tx_pwr + self.vcc = vcc + self.rx_pwr_is_set = rx_pwr_is_set + self.temp_is_set = temp_is_set + self.tx_bias_is_set = tx_bias_is_set + self.tx_pwr_is_set = tx_pwr_is_set + self.vcc_is_set = vcc_is_set + + def read(self, iprot): + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) + return + iprot.readStructBegin() + while True: + (fname, ftype, fid) = iprot.readFieldBegin() + if ftype == TType.STOP: + break + if fid == 1: + if ftype == TType.STRUCT: + self.rx_pwr = pltfm_mgr_qsfp_threshold_t() + self.rx_pwr.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRUCT: + self.temp = pltfm_mgr_qsfp_threshold_t() + self.temp.read(iprot) + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRUCT: + self.tx_bias = pltfm_mgr_qsfp_threshold_t() + self.tx_bias.read(iprot) + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.STRUCT: + self.tx_pwr = pltfm_mgr_qsfp_threshold_t() + self.tx_pwr.read(iprot) + else: + iprot.skip(ftype) + elif fid == 5: + if ftype == TType.STRUCT: + self.vcc = pltfm_mgr_qsfp_threshold_t() + self.vcc.read(iprot) + else: + iprot.skip(ftype) + elif fid == 6: + if ftype == TType.BOOL: + self.rx_pwr_is_set = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 7: + if ftype == TType.BOOL: + self.temp_is_set = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 8: + if ftype == TType.BOOL: + self.tx_bias_is_set = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 9: + if ftype == TType.BOOL: + self.tx_pwr_is_set = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 10: + if ftype == TType.BOOL: + self.vcc_is_set = iprot.readBool() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + def write(self, oprot): + if oprot._fast_encode is not None and self.thrift_spec is not None: + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) + return + oprot.writeStructBegin('pltfm_mgr_qsfp_thresholds_t') + if self.rx_pwr is not None: + oprot.writeFieldBegin('rx_pwr', TType.STRUCT, 1) + self.rx_pwr.write(oprot) + oprot.writeFieldEnd() + if self.temp is not None: + oprot.writeFieldBegin('temp', TType.STRUCT, 2) + self.temp.write(oprot) + oprot.writeFieldEnd() + if self.tx_bias is not None: + oprot.writeFieldBegin('tx_bias', TType.STRUCT, 3) + self.tx_bias.write(oprot) + oprot.writeFieldEnd() + if self.tx_pwr is not None: + oprot.writeFieldBegin('tx_pwr', TType.STRUCT, 4) + self.tx_pwr.write(oprot) + oprot.writeFieldEnd() + if self.vcc is not None: + oprot.writeFieldBegin('vcc', TType.STRUCT, 5) + self.vcc.write(oprot) + oprot.writeFieldEnd() + if self.rx_pwr_is_set is not None: + oprot.writeFieldBegin('rx_pwr_is_set', TType.BOOL, 6) + oprot.writeBool(self.rx_pwr_is_set) + oprot.writeFieldEnd() + if self.temp_is_set is not None: + oprot.writeFieldBegin('temp_is_set', TType.BOOL, 7) + oprot.writeBool(self.temp_is_set) + oprot.writeFieldEnd() + if self.tx_bias_is_set is not None: + oprot.writeFieldBegin('tx_bias_is_set', TType.BOOL, 8) + oprot.writeBool(self.tx_bias_is_set) + oprot.writeFieldEnd() + if self.tx_pwr_is_set is not None: + oprot.writeFieldBegin('tx_pwr_is_set', TType.BOOL, 9) + oprot.writeBool(self.tx_pwr_is_set) + oprot.writeFieldEnd() + if self.vcc_is_set is not None: + oprot.writeFieldBegin('vcc_is_set', TType.BOOL, 10) + oprot.writeBool(self.vcc_is_set) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + class InvalidPltfmMgrOperation(TException): """ Attributes: - code + """ - thrift_spec = ( - None, # 0 - (1, TType.I32, 'code', None, None, ), # 1 - ) def __init__(self, code=None,): self.code = code def read(self, iprot): if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: - iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec)) + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) return iprot.readStructBegin() while True: @@ -1032,7 +1301,7 @@ def read(self, iprot): def write(self, oprot): if oprot._fast_encode is not None and self.thrift_spec is not None: - oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec))) + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) return oprot.writeStructBegin('InvalidPltfmMgrOperation') if self.code is not None: @@ -1058,3 +1327,122 @@ def __eq__(self, other): def __ne__(self, other): return not (self == other) +all_structs.append(pltfm_mgr_sys_tmp_t) +pltfm_mgr_sys_tmp_t.thrift_spec = ( + None, # 0 + (1, TType.DOUBLE, 'tmp1', None, None, ), # 1 + (2, TType.DOUBLE, 'tmp2', None, None, ), # 2 + (3, TType.DOUBLE, 'tmp3', None, None, ), # 3 + (4, TType.DOUBLE, 'tmp4', None, None, ), # 4 + (5, TType.DOUBLE, 'tmp5', None, None, ), # 5 + (6, TType.DOUBLE, 'tmp6', None, None, ), # 6 + (7, TType.DOUBLE, 'tmp7', None, None, ), # 7 + (8, TType.DOUBLE, 'tmp8', None, None, ), # 8 + (9, TType.DOUBLE, 'tmp9', None, None, ), # 9 + (10, TType.DOUBLE, 'tmp10', None, None, ), # 10 +) +all_structs.append(pltfm_mgr_eeprom_t) +pltfm_mgr_eeprom_t.thrift_spec = ( + None, # 0 + (1, TType.I16, 'version', None, None, ), # 1 + (2, TType.STRING, 'prod_name', 'UTF8', None, ), # 2 + (3, TType.STRING, 'prod_part_num', 'UTF8', None, ), # 3 + (4, TType.STRING, 'sys_asm_part_num', 'UTF8', None, ), # 4 + (5, TType.STRING, 'bfn_pcba_part_num', 'UTF8', None, ), # 5 + (6, TType.STRING, 'bfn_pcbb_part_num', 'UTF8', None, ), # 6 + (7, TType.STRING, 'odm_pcba_part_num', 'UTF8', None, ), # 7 + (8, TType.STRING, 'odm_pcba_ser_num', 'UTF8', None, ), # 8 + (9, TType.I16, 'prod_state', None, None, ), # 9 + (10, TType.I16, 'prod_ver', None, None, ), # 10 + (11, TType.I16, 'prod_sub_ver', None, None, ), # 11 + (12, TType.STRING, 'prod_ser_num', 'UTF8', None, ), # 12 + (13, TType.STRING, 'prod_ast_tag', 'UTF8', None, ), # 13 + (14, TType.STRING, 'sys_mfger', 'UTF8', None, ), # 14 + (15, TType.STRING, 'sys_mfg_date', 'UTF8', None, ), # 15 + (16, TType.STRING, 'pcb_mfger', 'UTF8', None, ), # 16 + (17, TType.STRING, 'assembled_at', 'UTF8', None, ), # 17 + (18, TType.STRING, 'loc_mac_addr', 'UTF8', None, ), # 18 + (19, TType.STRING, 'ext_mac_addr', 'UTF8', None, ), # 19 + (20, TType.I32, 'ext_mac_addr_size', None, None, ), # 20 + (21, TType.STRING, 'location', 'UTF8', None, ), # 21 + (22, TType.I16, 'crc8', None, None, ), # 22 +) +all_structs.append(pltfm_mgr_pwr_supply_info_t) +pltfm_mgr_pwr_supply_info_t.thrift_spec = ( + None, # 0 + (1, TType.I32, 'vin', None, None, ), # 1 + (2, TType.I32, 'vout', None, None, ), # 2 + (3, TType.I32, 'iout', None, None, ), # 3 + (4, TType.I32, 'pwr_out', None, None, ), # 4 + (5, TType.I32, 'fspeed', None, None, ), # 5 + (6, TType.BOOL, 'ffault', None, None, ), # 6 + (7, TType.BOOL, 'load_sharing', None, None, ), # 7 + (8, TType.STRING, 'model', 'UTF8', None, ), # 8 + (9, TType.STRING, 'serial', 'UTF8', None, ), # 9 + (10, TType.STRING, 'rev', 'UTF8', None, ), # 10 +) +all_structs.append(pltfm_mgr_pwr_rail_info_t) +pltfm_mgr_pwr_rail_info_t.thrift_spec = ( + None, # 0 + (1, TType.I32, 'vrail1', None, None, ), # 1 + (2, TType.I32, 'vrail2', None, None, ), # 2 + (3, TType.I32, 'vrail3', None, None, ), # 3 + (4, TType.I32, 'vrail4', None, None, ), # 4 + (5, TType.I32, 'vrail5', None, None, ), # 5 + (6, TType.I32, 'vrail6', None, None, ), # 6 + (7, TType.I32, 'vrail7', None, None, ), # 7 + (8, TType.I32, 'vrail8', None, None, ), # 8 + (9, TType.I32, 'vrail9', None, None, ), # 9 + (10, TType.I32, 'vrail10', None, None, ), # 10 + (11, TType.I32, 'vrail11', None, None, ), # 11 + (12, TType.I32, 'vrail12', None, None, ), # 12 + (13, TType.I32, 'vrail13', None, None, ), # 13 + (14, TType.I32, 'vrail14', None, None, ), # 14 + (15, TType.I32, 'vrail15', None, None, ), # 15 + (16, TType.I32, 'vrail16', None, None, ), # 16 +) +all_structs.append(pltfm_mgr_fan_info_t) +pltfm_mgr_fan_info_t.thrift_spec = ( + None, # 0 + (1, TType.I32, 'fan_num', None, None, ), # 1 + (2, TType.I32, 'front_rpm', None, None, ), # 2 + (3, TType.I32, 'rear_rpm', None, None, ), # 3 + (4, TType.I32, 'percent', None, None, ), # 4 +) +all_structs.append(pltfm_mgr_qsfp_alarm_flags_t) +pltfm_mgr_qsfp_alarm_flags_t.thrift_spec = ( + None, # 0 + (1, TType.BOOL, 'highalarm', None, None, ), # 1 + (2, TType.BOOL, 'lowalarm', None, None, ), # 2 + (3, TType.BOOL, 'highwarning', None, None, ), # 3 + (4, TType.BOOL, 'lowwarning', None, None, ), # 4 +) +all_structs.append(pltfm_mgr_qsfp_threshold_t) +pltfm_mgr_qsfp_threshold_t.thrift_spec = ( + None, # 0 + (1, TType.DOUBLE, 'highalarm', None, None, ), # 1 + (2, TType.DOUBLE, 'lowalarm', None, None, ), # 2 + (3, TType.DOUBLE, 'highwarning', None, None, ), # 3 + (4, TType.DOUBLE, 'lowwarning', None, None, ), # 4 +) +all_structs.append(pltfm_mgr_qsfp_thresholds_t) +pltfm_mgr_qsfp_thresholds_t.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'rx_pwr', [pltfm_mgr_qsfp_threshold_t, None], None, ), # 1 + (2, TType.STRUCT, 'temp', [pltfm_mgr_qsfp_threshold_t, None], None, ), # 2 + (3, TType.STRUCT, 'tx_bias', [pltfm_mgr_qsfp_threshold_t, None], None, ), # 3 + (4, TType.STRUCT, 'tx_pwr', [pltfm_mgr_qsfp_threshold_t, None], None, ), # 4 + (5, TType.STRUCT, 'vcc', [pltfm_mgr_qsfp_threshold_t, None], None, ), # 5 + (6, TType.BOOL, 'rx_pwr_is_set', None, None, ), # 6 + (7, TType.BOOL, 'temp_is_set', None, None, ), # 7 + (8, TType.BOOL, 'tx_bias_is_set', None, None, ), # 8 + (9, TType.BOOL, 'tx_pwr_is_set', None, None, ), # 9 + (10, TType.BOOL, 'vcc_is_set', None, None, ), # 10 +) +all_structs.append(InvalidPltfmMgrOperation) +InvalidPltfmMgrOperation.thrift_spec = ( + None, # 0 + (1, TType.I32, 'code', None, None, ), # 1 +) +fix_spec(all_structs) +del all_structs diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/psu.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/psu.py index c63bb6528dae..fb9bce50e071 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/psu.py +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/psu.py @@ -3,6 +3,7 @@ try: import os import sys + import time sys.path.append(os.path.dirname(__file__)) @@ -18,6 +19,10 @@ class Psu(PsuBase): def __init__(self, index): PsuBase.__init__(self) self.__index = index + self.__info = None + self.__ts = 0 + # STUB IMPLEMENTATION + self.color = "" ''' Units of returned info object values: @@ -31,7 +36,16 @@ def __info_get(self): def psu_info_get(client): return client.pltfm_mgr.pltfm_mgr_pwr_supply_info_get(self.__index) - return thrift_try(psu_info_get) + # Update cache once per 2 seconds + if self.__ts + 2 < time.time(): + self.__info = None + try: + self.__info = thrift_try(psu_info_get, attempts=1) + finally: + self.__ts = time.time() + return self.__info + return self.__info + @staticmethod def get_num_psus(): @@ -52,6 +66,8 @@ def get_powergood_status(self): :return: Boolean, True if PSU is operating properly, False if PSU is faulty """ info = self.__info_get() + if info is None: + return False return info.ffault == False and info.vout != 0 def get_voltage(self): @@ -62,7 +78,8 @@ def get_voltage(self): A float number, the output voltage in volts, e.g. 12.1 """ - return float(self.__info_get().vout) + info = self.__info_get() + return float(info.vout) if info else 0 def get_current(self): """ @@ -71,7 +88,8 @@ def get_current(self): Returns: A float number, the electric current in amperes, e.g 15.4 """ - return self.__info_get().iout / 1000. + info = self.__info_get() + return info.iout / 1000 if info else 0 def get_power(self): """ @@ -80,7 +98,8 @@ def get_power(self): Returns: A float number, the power in watts, e.g. 302.6 """ - return self.__info_get().pwr_out / 1000. + info = self.__info_get() + return info.pwr_out / 1000 if info else 0 def get_presence(self): """ @@ -92,19 +111,94 @@ def get_presence(self): def psu_present_get(client): return client.pltfm_mgr.pltfm_mgr_pwr_supply_present_get(self.__index) - status = thrift_try(psu_present_get) - return status + status = False + try: + status = thrift_try(psu_present_get) + finally: + return 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 + + Returns: + bool: True if status LED state is set successfully, False if not + """ + # STUB IMPLEMENTATION + self.color = color + return True + + 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 + """ + # STUB IMPLEMENTATION + return self.color # DeviceBase iface: def get_serial(self): - return self.__info_get().serial + """ + Retrieves the serial number of the device + + Returns: + string: Serial number of device + """ + info = self.__info_get() + return info.serial if info else "N/A" def get_model(self): - return self.__info_get().model + """ + Retrieves the model number (or part number) of the device + + Returns: + string: Model/part number of device + """ + info = self.__info_get() + return info.model if info else "N/A" def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ return True + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + info = self.__info_get() + return info.rev if info else "N/A" + + 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_powergood_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.__index + def psu_list_get(): psu_list = [] for i in range(1, Psu.get_num_psus() + 1): diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/sfp.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/sfp.py index 640b1c41948c..f5d800b749c9 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/sfp.py +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/sfp.py @@ -2,80 +2,47 @@ try: import os - import sys - import time + from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase + from sonic_platform.platform_thrift_client import thrift_try + from sonic_platform.platform_thrift_client import pltfm_mgr_try +except ImportError as e: + raise ImportError (str(e) + "- required module not found") - import tempfile - from contextlib import contextmanager - from copy import copy +SFP_TYPE = "SFP" +QSFP_TYPE = "QSFP" +QSFP_DD_TYPE = "QSFP_DD" - sys.path.append(os.path.dirname(__file__)) - from .platform_thrift_client import ThriftClient - from .platform_thrift_client import thrift_try +class Sfp(SfpOptoeBase): + """ + BFN Platform-specific SFP class + """ - from sonic_platform_base.sfp_base import SfpBase - from sonic_platform_base.sonic_sfp.sfputilbase import SfpUtilBase -except ImportError as e: - raise ImportError (str(e) + "- required module not found") + SFP_EEPROM_PATH = "/var/run/platform/sfp/" -class SfpUtil(SfpUtilBase): - """Platform-specific SfpUtil class""" - - PORT_START = 1 - PORT_END = 0 - PORTS_IN_BLOCK = 0 - QSFP_PORT_START = 1 - QSFP_PORT_END = 0 - EEPROM_OFFSET = 0 - QSFP_CHECK_INTERVAL = 4 - - @property - def port_start(self): - self.update_port_info() - return self.PORT_START - - @property - def port_end(self): - self.update_port_info() - return self.PORT_END - - @property - def qsfp_ports(self): - self.update_port_info() - return range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1) - - @property - def port_to_eeprom_mapping(self): - print("dependency on sysfs has been removed") - raise Exception() - - def __init__(self): - self.ready = False - self.phy_port_dict = {'-1': 'system_not_ready'} - self.phy_port_cur_state = {} - self.qsfp_interval = self.QSFP_CHECK_INTERVAL - - SfpUtilBase.__init__(self) - - def update_port_info(self): - def qsfp_max_port_get(client): - return client.pltfm_mgr.pltfm_mgr_qsfp_get_max_port(); - - if self.QSFP_PORT_END == 0: - self.QSFP_PORT_END = thrift_try(qsfp_max_port_get) - self.PORT_END = self.QSFP_PORT_END - self.PORTS_IN_BLOCK = self.QSFP_PORT_END - - def get_presence(self, port_num): - # Check for invalid port_num - if port_num < self.port_start or port_num > self.port_end: - return False + def __init__(self, port_num): + SfpOptoeBase.__init__(self) + self.index = port_num + self.port_num = port_num + self.sfp_type = QSFP_TYPE + if not os.path.exists(self.SFP_EEPROM_PATH): + try: + os.makedirs(self.SFP_EEPROM_PATH) + except OSError as e: + if e.errno != errno.EEXIST: + raise + + self.eeprom_path = self.SFP_EEPROM_PATH + "sfp{}-eeprom-cache".format(self.index) + + def get_presence(self): + """ + Retrieves the presence of the sfp + """ presence = False def qsfp_presence_get(client): - return client.pltfm_mgr.pltfm_mgr_qsfp_presence_get(port_num) + return client.pltfm_mgr.pltfm_mgr_qsfp_presence_get(self.index) try: presence = thrift_try(qsfp_presence_get) @@ -85,194 +52,156 @@ def qsfp_presence_get(client): return presence - def get_low_power_mode(self, port_num): - # Check for invalid port_num - if port_num < self.port_start or port_num > self.port_end: - return False - + def get_lpmode(self): + """ + Retrieves the lpmode (low power mode) status of this SFP + """ def qsfp_lpmode_get(client): - return client.pltfm_mgr.pltfm_mgr_qsfp_lpmode_get(port_num) - - lpmode = thrift_try(qsfp_lpmode_get) + return client.pltfm_mgr.pltfm_mgr_qsfp_lpmode_get(self.index) - return lpmode - - def set_low_power_mode(self, port_num, lpmode): - # Check for invalid port_num - if port_num < self.port_start or port_num > self.port_end: - return False + return thrift_try(qsfp_lpmode_get) + def set_lpmode(self, lpmode): + """ + Sets the lpmode (low power mode) of SFP + """ def qsfp_lpmode_set(client): - return client.pltfm_mgr.pltfm_mgr_qsfp_lpmode_set(port_num, lpmode) + return client.pltfm_mgr.pltfm_mgr_qsfp_lpmode_set(self.index, lpmode) status = thrift_try(qsfp_lpmode_set) - return (status == 0) - def reset(self, port_num): - # Check for invalid port_num - if port_num < self.port_start or port_num > self.port_end: - return False - - def qsfp_reset(client): - client.pltfm_mgr.pltfm_mgr_qsfp_reset(port_num, True) - return client.pltfm_mgr.pltfm_mgr_qsfp_reset(port_num, False) - - err = thrift_try(qsfp_reset) - - return not err - - def check_transceiver_change(self): - if not self.ready: - return - - self.phy_port_dict = {} - - try: - client = ThriftClient().open() - except Exception: - return - - # Get presence of each SFP - for port in range(self.port_start, self.port_end + 1): - try: - sfp_resent = client.pltfm_mgr.pltfm_mgr_qsfp_presence_get(port) - except Exception: - sfp_resent = False - sfp_state = '1' if sfp_resent else '0' - - if port in self.phy_port_cur_state: - if self.phy_port_cur_state[port] != sfp_state: - self.phy_port_dict[port] = sfp_state - else: - self.phy_port_dict[port] = sfp_state - - # Update port current state - self.phy_port_cur_state[port] = sfp_state - - client.close() - - def get_transceiver_change_event(self, timeout=0): - forever = False - if timeout == 0: - forever = True - elif timeout > 0: - timeout = timeout / float(1000) # Convert to secs - else: - print("get_transceiver_change_event:Invalid timeout value", timeout) - return False, {} - - while forever or timeout > 0: - if not self.ready: - try: - with ThriftClient(): pass - except Exception: - pass - else: - self.ready = True - self.phy_port_dict = {} - break - elif self.qsfp_interval == 0: - self.qsfp_interval = self.QSFP_CHECK_INTERVAL - - # Process transceiver plug-in/out event - self.check_transceiver_change() - - # Break if tranceiver state has changed - if bool(self.phy_port_dict): - break - - if timeout: - timeout -= 1 - - if self.qsfp_interval: - self.qsfp_interval -= 1 - - time.sleep(1) - - return self.ready, self.phy_port_dict - - @contextmanager - def eeprom_action(self): - u = copy(self) - with tempfile.NamedTemporaryFile() as f: - u.eeprom_path = f.name - yield u - - def _sfp_eeprom_present(self, client_eeprompath, offset): - return client_eeprompath and super(SfpUtil, self)._sfp_eeprom_present(client_eeprompath, offset) - - def _get_port_eeprom_path(self, port_num, devid): + def get_eeprom_path(self): def qsfp_info_get(client): - return client.pltfm_mgr.pltfm_mgr_qsfp_info_get(port_num) + return client.pltfm_mgr.pltfm_mgr_qsfp_info_get(self.index) - if self.get_presence(port_num): + if self.get_presence(): eeprom_hex = thrift_try(qsfp_info_get) eeprom_raw = bytearray.fromhex(eeprom_hex) - with open(self.eeprom_path, 'wb') as eeprom_cache: - eeprom_cache.write(eeprom_raw) + with open(self.eeprom_path, 'wb') as fp: + fp.write(eeprom_raw) return self.eeprom_path return None -class Sfp(SfpBase): - """Platform-specific Sfp class""" - - sfputil = SfpUtil() - - @staticmethod - def port_start(): - return Sfp.sfputil.port_start - - @staticmethod - def port_end(): - return Sfp.sfputil.port_end - - @staticmethod - def qsfp_ports(): - return Sfp.sfputil.qsfp_ports() - - @staticmethod - def get_transceiver_change_event(timeout=0): - return Sfp.sfputil.get_transceiver_change_event() - - def __init__(self, port_num): - self.port_num = port_num - SfpBase.__init__(self) - - def get_presence(self): - with Sfp.sfputil.eeprom_action() as u: - return u.get_presence(self.port_num) - - def get_lpmode(self): - with Sfp.sfputil.eeprom_action() as u: - return u.get_low_power_mode(self.port_num) - - def set_lpmode(self, lpmode): - with Sfp.sfputil.eeprom_action() as u: - return u.set_low_power_mode(self.port_num, lpmode) + def write_eeprom(self, offset, num_bytes, write_buffer): + # Not supported at the moment + return False + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + return "sfp{}".format(self.index) + + def get_reset_status(self): + """ + Retrieves the reset status of SFP + """ + def get_qsfp_reset(pltfm_mgr): + return pltfm_mgr.pltfm_mgr_qsfp_reset_get(self.index) + _, status = pltfm_mgr_try(get_qsfp_reset, False) + return status def reset(self): - return Sfp.sfputil.reset(self.port_num) - - def get_transceiver_info(self): - with Sfp.sfputil.eeprom_action() as u: - return u.get_transceiver_info_dict(self.port_num) - - def get_transceiver_bulk_status(self): - with Sfp.sfputil.eeprom_action() as u: - return u.get_transceiver_dom_info_dict(self.port_num) + """ + Reset SFP and return all user module settings to their default srate. + """ + def qsfp_reset(client): + client.pltfm_mgr.pltfm_mgr_qsfp_reset(self.index, True) + return client.pltfm_mgr.pltfm_mgr_qsfp_reset(self.index, False) - def get_transceiver_threshold_info(self): - with Sfp.sfputil.eeprom_action() as u: - return u.get_transceiver_dom_threshold_info_dict(self.port_num) + err = thrift_try(qsfp_reset) + return not err - def get_change_event(self, timeout=0): - return Sfp.get_transceiver_change_event(timeout) + def get_status(self): + """ + Retrieves the operational status of the device + """ + reset = self.get_reset_status() -def sfp_list_get(): - sfp_list = [] - for index in range(Sfp.port_start(), Sfp.port_end() + 1): - sfp_node = Sfp(index) - sfp_list.append(sfp_node) - return sfp_list + if reset: + status = False + else: + status = True + + return status + + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device. + Returns: + integer: The 1-based relative physical position in parent + device or -1 if cannot determine the position + """ + return self.index + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return True + + 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" + """ + if not self.get_presence(): + return self.SFP_STATUS_UNPLUGGED + return self.SFP_STATUS_OK + + 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.sfp_type == QSFP_TYPE: + return self.tx_disable_channel(0xF, tx_disable) + return False + + 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 + """ + def qsfp_tx_disable_channel(client): + return client.pltfm_mgr.pltfm_mgr_qsfp_tx_disable(self.index, channel, disable) + + if self.sfp_type == QSFP_TYPE: + status = thrift_try(qsfp_tx_disable_channel) + return (status == 0) + return False + + def get_power_override(self): + def get_qsfp_power_override(pltfm_mgr): + return pltfm_mgr.pltfm_mgr_qsfp_pwr_override_get(self.index) + _, pwr_override = pltfm_mgr_try(get_qsfp_power_override) + return pwr_override + + def set_power_override(self, power_override, power_set): + def set_qsfp_power_override(pltfm_mgr): + return pltfm_mgr.pltfm_mgr_qsfp_pwr_override_set( + self.index, power_override, power_set + ) + _, status = pltfm_mgr_try(set_qsfp_power_override) + return status diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/thermal.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/thermal.py index 3a39c10a1e1f..ef3c571ac301 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/thermal.py +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/thermal.py @@ -1,7 +1,7 @@ try: import subprocess - from sonic_platform.bfn_extensions.platform_sensors import platform_sensors_get + from bfn_extensions.platform_sensors import platform_sensors_get from sonic_platform_base.thermal_base import ThermalBase except ImportError as e: raise ImportError (str(e) + "- required module not found") @@ -68,20 +68,24 @@ def _value_get(d: dict, key_prefix, key_suffix=''): # Thermal -> ThermalBase -> DeviceBase class Thermal(ThermalBase): - def __init__(self, chip, label): + def __init__(self, chip, label, index = 0): self.__chip = chip self.__label = label self.__name = f"{chip}:{label}".lower().replace(' ', '-') + self.__collect_temp = [] + self.__index = index def __get(self, attr_prefix, attr_suffix): sensor_data = _sensors_get().get(self.__chip, {}).get(self.__label, {}) value = _value_get(sensor_data, attr_prefix, attr_suffix) - if value is not None: return value - raise NotImplementedError + return value if value is not None else -999.9 # ThermalBase interface methods: def get_temperature(self) -> float: - return float(self.__get('temp', 'input')) + temp = self.__get('temp', 'input') + self.__collect_temp.append(float(temp)) + self.__collect_temp.sort() + return float(temp) def get_high_threshold(self) -> float: return float(self.__get('temp', 'max')) @@ -89,6 +93,12 @@ def get_high_threshold(self) -> float: def get_high_critical_threshold(self) -> float: return float(self.__get('temp', 'crit')) + def get_low_critical_threshold(self) -> float: + return float(self.__get('temp', 'alarm')) + + def get_model(self): + return f"{self.__label}".lower() + # DeviceBase interface methods: def get_name(self): return self.__name @@ -99,11 +109,41 @@ def get_presence(self): def get_status(self): return True + def is_replaceable(self): + return False + + def get_low_threshold(self) -> float: + return float(self.__get('temp', 'min')) + + def get_serial(self): + return 'N/A' + + def get_minimum_recorded(self) -> float: + temp = self.__collect_temp[0] if len(self.__collect_temp) > 0 else 0.1 + temp = temp if temp > 0.0 else 0.1 + return float(temp) + + def get_maximum_recorded(self) -> float: + temp = self.__collect_temp[-1] if len(self.__collect_temp) > 0 else 100.0 + temp = temp if temp <= 100.0 else 100.0 + return float(temp) + + def get_position_in_parent(self): + return self.__index + + def set_high_threshold(self, temperature): + return False + + def set_low_threshold(self, temperature): + return False + def thermal_list_get(): l = [] + index = 0 for chip, chip_data in _sensors_get().items(): for sensor, sensor_data in chip_data.items(): # add only temperature sensors if _value_get(sensor_data, "temp") is not None: - l.append(Thermal(chip, sensor)) + l.append(Thermal(chip, sensor, index)) + index += 1 return l diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/thermal_manager.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/thermal_manager.py new file mode 100644 index 000000000000..1f932f2d3ce6 --- /dev/null +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/thermal_manager.py @@ -0,0 +1,67 @@ +try: + from threading import Timer +except ImportError as e: + raise ImportError (str(e) + "- required module not found") + +class ThermalManager(): + def __init__(self, polling_time = 30.0): + self.__polling_thermal_time = polling_time + self.__thermals = None + self.__timer = None + self.__chassis = None + + def start(self): + self.work() + self.__timer = Timer(self.__polling_thermal_time, self.start) + self.__timer.start() + + def work(self): + if self.__chassis is not None: + self.__thermals = self.__chassis._thermal_list + for term in self.__thermals: + self.check(term) + + def check(self, sensor): + temperature = sensor.get_temperature() + if temperature is not None: + temp_high = sensor.get_high_threshold() + temp_low = sensor.get_low_threshold() + if temp_high > -999.0: + if temperature > temp_high: + print('Sensor ', sensor.get_name(), ' temperature more then', temp_high, '!!!') + else: + print('Sensor ', sensor.get_name(), ' has no high temperature threshold') + + if temp_low > -999.0: + if temperature < temp_low: + print('Sensor ', sensor.get_name(), ' temperature less then', temp_low, '!!!') + else: + print('Sensor ', sensor.get_name(), ' has no low temperature threshold') + + def stop(self): + if self.__timer is not None: + self.__timer.cancel() + + def __del__(self): + if self.__timer is not None: + self.__timer.cancel() + + # for compatibility with old version + def run_policy(self, chassis_def): + self.__chassis = chassis_def + + def get_interval(self): + return self.__polling_thermal_time + + def initialize(self): + pass + + def load(self, json_file): + pass + + def init_thermal_algorithm(self, chassis_def): + self.__chassis = chassis_def + self.start() + + def deinitialize(self): + self.stop() diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/debian/control b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/control index 999ca7c70e3e..9663cc3f644a 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-newport/debian/control +++ b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/control @@ -2,7 +2,7 @@ Source: sonic-platform-modules-bfn-newport Section: main Priority: extra Maintainer: Support -Build-Depends: debhelper (>= 9.0.0), bzip2 +Build-Depends: debhelper (>= 9.0.0), bzip2, python3 Standards-Version: 3.9.3 Package: sonic-platform-modules-bfn-newport-as9516 diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/debian/rules b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/rules index 9edb45b497ab..540bdcafb6fd 100755 --- a/platform/barefoot/sonic-platform-modules-bfn-newport/debian/rules +++ b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/rules @@ -13,13 +13,13 @@ WHEEL_BUILD_DIR := $(BUILD_DIR)/wheel MODULE_NAMES := as9516 as9516bf %: - dh $@ + dh $@ --with python3 --buildsystem=pybuild override_dh_auto_build: make -C $(KERNEL_SRC)/build M=$(MODULE_SRC) set -e python3 setup.py bdist_wheel -d $(WHEEL_BUILD_DIR) - set +e + set +e override_dh_auto_install: (for mod in $(MODULE_NAMES); do \ @@ -39,8 +39,8 @@ override_dh_pysupport: override_dh_clean: dh_clean - rm -fr $(WHEEL_BUILD_DIR) - rm -fr *.egg-info + rm -fr $(WHEEL_BUILD_DIR) + rm -fr *.egg-info rm -fr $(BUILD) rm -f $(MODULE_SRC)/*.o $(MODULE_SRC)/*.ko $(MODULE_SRC)/*.mod.c $(MODULE_SRC)/.*.cmd rm -f $(MODULE_SRC)/Module.markers $(MODULE_SRC)/Module.symvers $(MODULE_SRC)/modules.order diff --git a/platform/barefoot/sonic-platform-modules-bfn/debian/control b/platform/barefoot/sonic-platform-modules-bfn/debian/control index 5f4dffdc9323..de1a22fdb1b5 100644 --- a/platform/barefoot/sonic-platform-modules-bfn/debian/control +++ b/platform/barefoot/sonic-platform-modules-bfn/debian/control @@ -2,7 +2,7 @@ Source: sonic-platform-modules-bfn Section: main Priority: extra Maintainer: support -Build-Depends: debhelper (>= 9.0.0), bzip2 +Build-Depends: debhelper (>= 9.0.0), bzip2, python3 Standards-Version: 3.9.3 Package: sonic-platform-modules-bfn diff --git a/platform/barefoot/sonic-platform-modules-bfn/debian/rules b/platform/barefoot/sonic-platform-modules-bfn/debian/rules index e52ae2c95074..7af5c9f8de65 100755 --- a/platform/barefoot/sonic-platform-modules-bfn/debian/rules +++ b/platform/barefoot/sonic-platform-modules-bfn/debian/rules @@ -8,7 +8,7 @@ BUILD_DIR := $(shell pwd)/build WHEEL_BUILD_DIR := $(BUILD_DIR)/wheel %: - dh $@ + dh $@ --with python3 --buildsystem=pybuild override_dh_auto_build: set -e @@ -28,8 +28,8 @@ override_dh_usrlocal: override_dh_pysupport: override_dh_clean: - rm -fr $(WHEEL_BUILD_DIR) - rm -fr *.egg-info + rm -fr $(WHEEL_BUILD_DIR) + rm -fr *.egg-info rm -fr $(BUILD) dh_clean diff --git a/platform/barefoot/sonic-platform-modules-wnc-osw1800/debian/control b/platform/barefoot/sonic-platform-modules-wnc-osw1800/debian/control index d4d4f7b49988..bed8117da850 100644 --- a/platform/barefoot/sonic-platform-modules-wnc-osw1800/debian/control +++ b/platform/barefoot/sonic-platform-modules-wnc-osw1800/debian/control @@ -2,7 +2,7 @@ Source: platform-modules-wnc-osw1800 Section: main Priority: extra Maintainer: WNC -Build-Depends: debhelper (>= 8.0.0), bzip2 +Build-Depends: debhelper (>= 8.0.0), bzip2, python3 Standards-Version: 3.9.3 Package: platform-modules-wnc-osw1800 diff --git a/platform/barefoot/sonic-platform-modules-wnc-osw1800/debian/rules b/platform/barefoot/sonic-platform-modules-wnc-osw1800/debian/rules index 644ab1ade433..87a468a2900d 100755 --- a/platform/barefoot/sonic-platform-modules-wnc-osw1800/debian/rules +++ b/platform/barefoot/sonic-platform-modules-wnc-osw1800/debian/rules @@ -10,7 +10,7 @@ SCRIPT_SRC := $(shell pwd)/scripts SERVICE_SRC := $(shell pwd)/service %: - dh $@ + dh $@ --with python3 override_dh_auto_build: make -C $(KERNEL_SRC)/build M=$(MODULE_SRC) diff --git a/platform/broadcom/sai-modules.mk b/platform/broadcom/sai-modules.mk index d4a523c949b5..b4f28f125687 100644 --- a/platform/broadcom/sai-modules.mk +++ b/platform/broadcom/sai-modules.mk @@ -1,6 +1,6 @@ # Broadcom SAI modules -BRCM_OPENNSL_KERNEL_VERSION = 6.0.0.10 +BRCM_OPENNSL_KERNEL_VERSION = 6.0.0.13 BRCM_OPENNSL_KERNEL = opennsl-modules_$(BRCM_OPENNSL_KERNEL_VERSION)_amd64.deb $(BRCM_OPENNSL_KERNEL)_SRC_PATH = $(PLATFORM_PATH)/saibcm-modules @@ -10,7 +10,7 @@ $(BRCM_OPENNSL_KERNEL)_MACHINE = broadcom SONIC_DPKG_DEBS += $(BRCM_OPENNSL_KERNEL) # SAI bcm modules for DNX family ASIC -BRCM_DNX_OPENNSL_KERNEL_VERSION = 6.0.0.10 +BRCM_DNX_OPENNSL_KERNEL_VERSION = 6.0.0.13 BRCM_DNX_OPENNSL_KERNEL = opennsl-modules-dnx_$(BRCM_DNX_OPENNSL_KERNEL_VERSION)_amd64.deb $(BRCM_DNX_OPENNSL_KERNEL)_SRC_PATH = $(PLATFORM_PATH)/saibcm-modules-dnx diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index 45e3a0114aa3..fd3b3627235f 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,4 +1,4 @@ -LIBSAIBCM_VERSION = 6.0.0.10-1 +LIBSAIBCM_VERSION = 6.0.0.13 LIBSAIBCM_BRANCH_NAME = REL_6.0 LIBSAIBCM_URL_PREFIX = "https://sonicstorage.blob.core.windows.net/public/sai/bcmsai/$(LIBSAIBCM_BRANCH_NAME)/$(LIBSAIBCM_VERSION)" diff --git a/platform/broadcom/saibcm-modules-dnx b/platform/broadcom/saibcm-modules-dnx index be53f7910a9e..3fc83d5e5f9d 160000 --- a/platform/broadcom/saibcm-modules-dnx +++ b/platform/broadcom/saibcm-modules-dnx @@ -1 +1 @@ -Subproject commit be53f7910a9e8b37bf191527a6da3aba0414d4b8 +Subproject commit 3fc83d5e5f9d1abad3ddf7fa6767b8cdd6121232 diff --git a/platform/broadcom/saibcm-modules/debian/changelog b/platform/broadcom/saibcm-modules/debian/changelog index 127dce8af622..e9e36aaaf302 100644 --- a/platform/broadcom/saibcm-modules/debian/changelog +++ b/platform/broadcom/saibcm-modules/debian/changelog @@ -1,3 +1,9 @@ +opennsl (6.0.0.13) unstable; urgency=medium + + * Update to Broadcom SAI 6.0.0.13 + + -- Judy Joseph Fri, 14 Jan 2022 18:36:38 +0000 + opennsl (6.0.0.10) unstable; urgency=medium * Update to Broadcom SAI 6.0.0.10 diff --git a/platform/broadcom/saibcm-modules/debian/opennsl-modules.install b/platform/broadcom/saibcm-modules/debian/opennsl-modules.install index 2d773b896116..59bf020cb22c 100644 --- a/platform/broadcom/saibcm-modules/debian/opennsl-modules.install +++ b/platform/broadcom/saibcm-modules/debian/opennsl-modules.install @@ -2,6 +2,5 @@ systems/linux/user/x86-smp_generic_64-2_6/linux-bcm-knet.ko lib/modules/5.10.0-8 systems/linux/user/x86-smp_generic_64-2_6/linux-kernel-bde.ko lib/modules/5.10.0-8-2-amd64/extra systems/linux/user/x86-smp_generic_64-2_6/linux-user-bde.ko lib/modules/5.10.0-8-2-amd64/extra systems/linux/user/x86-smp_generic_64-2_6/linux-knet-cb.ko lib/modules/5.10.0-8-2-amd64/extra -systems/linux/user/x86-smp_generic_64-2_6/linux-bcm-ptp-clock.ko lib/modules/5.10.0-8-2-amd64/extra systemd/opennsl-modules.service lib/systemd/system sdklt/linux/bde/linux_ngbde.ko lib/modules/5.10.0-8-2-amd64/extra diff --git a/platform/broadcom/saibcm-modules/include/ibde.h b/platform/broadcom/saibcm-modules/include/ibde.h index 1716a18f39ca..d71d487f03e5 100644 --- a/platform/broadcom/saibcm-modules/include/ibde.h +++ b/platform/broadcom/saibcm-modules/include/ibde.h @@ -182,6 +182,10 @@ typedef struct ibde_s { uint32 addr, /* The address to access in the internal device address space */ uint32 value); /* the value to be written. */ + /* 64 bit read/write */ + uint64 (*read64)(int d, uint32 addr); + void (*write64)(int d, uint32 addr, uint64 data); + } ibde_t; diff --git a/platform/broadcom/saibcm-modules/include/soc/devids.h b/platform/broadcom/saibcm-modules/include/soc/devids.h index 0347f84710dd..8a67d385d930 100644 --- a/platform/broadcom/saibcm-modules/include/soc/devids.h +++ b/platform/broadcom/saibcm-modules/include/soc/devids.h @@ -1842,6 +1842,22 @@ #define BCM8884E_DEVICE_ID 0x884E #define BCM8884F_DEVICE_ID 0x884F +#define BCM88831_DEVICE_ID 0x8831 +#define BCM88832_DEVICE_ID 0x8832 +#define BCM88833_DEVICE_ID 0x8833 +#define BCM88834_DEVICE_ID 0x8834 +#define BCM88835_DEVICE_ID 0x8835 +#define BCM88836_DEVICE_ID 0x8836 +#define BCM88837_DEVICE_ID 0x8837 +#define BCM88838_DEVICE_ID 0x8838 +#define BCM88839_DEVICE_ID 0x8839 +#define BCM8883A_DEVICE_ID 0x883A +#define BCM8883B_DEVICE_ID 0x883B +#define BCM8883C_DEVICE_ID 0x883C +#define BCM8883D_DEVICE_ID 0x883D +#define BCM8883E_DEVICE_ID 0x883E +#define BCM8883F_DEVICE_ID 0x883F + #define Q2A_DEVICE_ID 0x8480 #define Q2A_A0_REV_ID DNXC_A0_REV_ID diff --git a/platform/broadcom/saibcm-modules/make/Make.config b/platform/broadcom/saibcm-modules/make/Make.config index 2d4536285a48..b6f42bf65c48 100644 --- a/platform/broadcom/saibcm-modules/make/Make.config +++ b/platform/broadcom/saibcm-modules/make/Make.config @@ -171,9 +171,11 @@ INCFLAGS = -I${INCDIR} -I${SDK}/systems CFLAGS += ${INCFLAGS} CXXFLAGS += ${INCFLAGS} CPPFLAGS += ${INCFLAGS} - CFLAGS += -DSAI_FIXUP -UKCOM_FILTER_MAX -DKCOM_FILTER_MAX=1025 -UKCOM_NETIF_MAX -DKCOM_NETIF_MAX=1056 +# Flag to enable multi instance support +CFLAGS += -DBCM_INSTANCE_SUPPORT + # # Debug #ifdef control # diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc index 183f7f274203..9b08d0b2a3d4 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc @@ -42,12 +42,14 @@ ifeq (BE,$(ENDIAN_MODE)) #request for BE support but don't currently mainstream it. So a 5.1.0 version #has not been built. Continue using 5.0.3 for any BE support TOOLCHAIN_BASE_DIR ?= /projects/ntsw-tools/linux/iproc_ldks/xldk61-be/XLDK32 +KERN_BASE_DIR ?= $(TOOLCHAIN_BASE_DIR) TARGET_ARCHITECTURE:=armeb-broadcom-linux-uclibcgnueabi KERNDIR ?= $(TOOLCHAIN_BASE_DIR)/kernel/linux else -TOOLCHAIN_BASE_DIR ?= /projects/ntsw-tools/linux/iproc_ldks/xldk61/XLDK32 +TOOLCHAIN_BASE_DIR ?= /projects/ntsw-tools/linux/iproc_ldks/XLDK_GCC10/XLDK32 +KERN_BASE_DIR ?= /projects/ntsw-tools/linux/iproc_ldks/xldk61/XLDK32 TARGET_ARCHITECTURE:= arm-broadcom-linux-uclibcgnueabi -KERNDIR ?= $(TOOLCHAIN_BASE_DIR)/kernel/linux +KERNDIR ?= $(KERN_BASE_DIR)/kernel/linux endif ifeq (,$(CROSS_COMPILE)) diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc_64 b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc_64 index 121ccc2f3ac4..bfb6cd48dda8 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc_64 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc_64 @@ -41,12 +41,14 @@ ifeq (BE,$(ENDIAN_MODE)) #We've never actually built a 64 BE executable. Just here for any future #customer requirements. TOOLCHAIN_BASE_DIR ?= /projects/ntsw-tools/linux/iproc_ldks/xldk61-be/XLDK64 +KERN_BASE_DIR ?= $(TOOLCHAIN_BASE_DIR) TARGET_ARCHITECTURE ?= aarch64_be-broadcom-linux-uclibc -KERNDIR ?= $(TOOLCHAIN_BASE_DIR)/kernel/linux +KERNDIR ?= $(KERN_BASE_DIR)/kernel/linux else -TOOLCHAIN_BASE_DIR ?= /projects/ntsw-tools/linux/iproc_ldks/xldk61/XLDK64 +TOOLCHAIN_BASE_DIR ?= /projects/ntsw-tools/linux/iproc_ldks/XLDK_GCC10/XLDK64 +KERN_BASE_DIR ?= /projects/ntsw-tools/linux/iproc_ldks/xldk61/XLDK64 TARGET_ARCHITECTURE ?= aarch64-broadcom-linux-uclibc -KERNDIR ?= $(TOOLCHAIN_BASE_DIR)/kernel/linux +KERNDIR ?= $(KERN_BASE_DIR)/kernel/linux endif ifeq (,$(CROSS_COMPILE)) diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-smp_generic_64-2_6 b/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-smp_generic_64-2_6 index 80dd9c97c07a..2f6b54f1b994 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-smp_generic_64-2_6 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-smp_generic_64-2_6 @@ -39,11 +39,6 @@ ifeq (,$(KFLAGS)) KFLAGS := -nostdinc -isystem $(SYSINC) -I$(KERNDIR)/include -I$(KERNDIR)/arch/x86/include -include $(AUTOCONF) -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -m64 -mtune=generic -mno-red-zone -fno-pie -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-stack-protector -fomit-frame-pointer -g -Wdeclaration-after-statement -Wno-pointer-sign endif -ifeq ($(LINUX_MAKE_SHARED_LIB), 1) - KFLAGS += -fPIC -mcmodel=small -else - KFLAGS += -fno-pie -mcmodel=kernel -endif LINUX_UAPI = $(LINUX_INCLUDE)/uapi ifneq (,$(shell ls $(LINUX_UAPI) 2>/dev/null)) diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_buff.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_buff.h new file mode 120000 index 000000000000..b4bc2b7ffe74 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_buff.h @@ -0,0 +1 @@ +/sonic/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_cmicd.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_cmicd.h new file mode 120000 index 000000000000..cface69c6365 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_cmicd.h @@ -0,0 +1 @@ +/sonic/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicd.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_cmicx.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_cmicx.h new file mode 120000 index 000000000000..ee9f52060eae --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_cmicx.h @@ -0,0 +1 @@ +/sonic/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicx.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_core.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_core.h new file mode 120000 index 000000000000..83e0769b2b5e --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_core.h @@ -0,0 +1 @@ +/sonic/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_core.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_dep.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_dep.h new file mode 120000 index 000000000000..8a9a6c6f6582 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_dep.h @@ -0,0 +1 @@ +/sonic/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_dep.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_dev.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_dev.h new file mode 120000 index 000000000000..4ba5f9aefbaa --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_dev.h @@ -0,0 +1 @@ +/sonic/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_dev.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_internal.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_internal.h new file mode 120000 index 000000000000..e9c65317d643 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_internal.h @@ -0,0 +1 @@ +/sonic/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_internal.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_rxtx.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_rxtx.h new file mode 120000 index 000000000000..7bfe68f89882 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_rxtx.h @@ -0,0 +1 @@ +/sonic/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_rxtx.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_types.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_types.h new file mode 120000 index 000000000000..f2e6649cd0da --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_types.h @@ -0,0 +1 @@ +/sonic/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_types.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/include/linux_dma.h b/platform/broadcom/saibcm-modules/systems/bde/linux/include/linux_dma.h index a1f7920b6b93..c2730c140b6e 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/include/linux_dma.h +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/include/linux_dma.h @@ -45,13 +45,6 @@ #define KMALLOC(size, flags) kmalloc(size, flags) #endif -#if defined(CONFIG_IDT_79EB334) || defined(CONFIG_BCM4702) -/* ioremap is broken in kernel */ -#define IOREMAP(addr, size) ((void *)KSEG1ADDR(addr)) -#else -#define IOREMAP(addr, size) ioremap(addr, size) -#endif - #if defined (__mips__) #if defined(CONFIG_NONCOHERENT_IO) || defined(CONFIG_DMA_NONCOHERENT) /* Use flush/invalidate for cached memory */ diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/Makefile b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/Makefile index 2aa3bec11d73..bc7b6fef5f15 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/Makefile +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/Makefile @@ -66,16 +66,16 @@ THIS_MOD_NAME := linux-kernel-bde MODULE = $(LIBDIR)/$(THIS_MOD_NAME).o KMODULE = $(LIBDIR)/$(THIS_MOD_NAME).ko -build: kernel_libs module $(KMODULE) +build: $(KMODULE) else MODULE = $(LIBDIR)/linux-kernel-bde.o -build: kernel_libs module +build: module endif -module: kernel_libs $(MODULE) +module: $(MODULE) -$(MODULE): $(BLDDIR)/.tree $(BOBJS) +$(MODULE): $(BLDDIR)/.tree $(BOBJS) kernel_libs mkdir -p $(@D) $(LD) $(MODULE_LDFLAGS) -r -d $(BOBJS) $(LIBS) -o $@ ifneq ($(kernel_version),2_4) diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux-kernel-bde.c b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux-kernel-bde.c index b7c422e04e8b..be5b6282396d 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux-kernel-bde.c +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux-kernel-bde.c @@ -166,14 +166,6 @@ MODULE_PARM_DESC(spifreq, #endif -/* Compatibility */ -#ifdef LKM_2_4 -#define _ISR_RET void -#define _ISR_PARAMS(_i,_d,_r) int _i, void *_d, struct pt_regs *_r -#define IRQ_NONE -#define IRQ_HANDLED -#define SYNC_IRQ(_i) synchronize_irq() -#else /* LKM_2_6 */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)) #define _ISR_RET irqreturn_t #else @@ -207,7 +199,6 @@ char * strtok(char * s,const char * ct) } LKM_EXPORT_SYM(___strtok); LKM_EXPORT_SYM(strtok); -#endif /* LKM_2_x */ /* PCIe capabilities */ #ifndef PCI_CAP_ID_EXP @@ -585,7 +576,7 @@ _eb_device_create(resource_size_t paddr, int irq, int rd_hw, int wr_hw) } /* Map in the device */ - ctrl->bde_dev.base_address = (sal_vaddr_t)IOREMAP(paddr, 0x10000); + ctrl->bde_dev.base_address = (sal_vaddr_t)ioremap(paddr, 0x10000); ctrl->iowin[0].addr = paddr; ctrl->iowin[0].size = 0x10000; @@ -622,7 +613,7 @@ sand_device_create(void) ctrl->pci_device = NULL; /* No PCI bus */ /* Map in the device */ /* FIX_ME: not realy map anything */ - ctrl->bde_dev.base_address = (sal_vaddr_t)IOREMAP(0x40000000, 0x100000); + ctrl->bde_dev.base_address = (sal_vaddr_t)ioremap(0x40000000, 0x100000); ctrl->iowin[0].addr = 0x40000000; ctrl->iowin[0].size = 0x100000; @@ -636,17 +627,17 @@ sand_device_create(void) /* Map CPU regs */ #ifdef __DUNE_WRX_BCM_CPU__ - cpu_address = IOREMAP(0x18000000, 0x4000000); + cpu_address = ioremap(0x18000000, 0x4000000); #elif defined(__DUNE_GTO_BCM_CPU__) - cpu_address = IOREMAP(0xe0000000, 0x100000); + cpu_address = ioremap(0xe0000000, 0x100000); #endif - if ((ctrl->bde_dev.device == PCP_PCI_DEVICE_ID)) { + if (ctrl->bde_dev.device == PCP_PCI_DEVICE_ID) { ctrl->bde_dev.device = GEDI_DEVICE_ID; ctrl->bde_dev.rev = GEDI_REV_ID; } - if ((ctrl->bde_dev.device == ACP_PCI_DEVICE_ID)) { + if (ctrl->bde_dev.device == ACP_PCI_DEVICE_ID) { ctrl->dev_type |= BDE_PCI_DEV_TYPE | BDE_SWITCH_DEV_TYPE; } @@ -724,7 +715,7 @@ iproc_cmicd_probe(struct platform_device *pldev) ctrl->pci_device = NULL; /* No PCI bus */ /* Map CMIC block in the AXI memory space into CPU address space */ - ctrl->bde_dev.base_address = (sal_vaddr_t)IOREMAP(memres->start, size); + ctrl->bde_dev.base_address = (sal_vaddr_t)ioremap(memres->start, size); if (!ctrl->bde_dev.base_address) { gprintk("Error mapping iProc CMIC registers"); return -1; @@ -735,7 +726,7 @@ iproc_cmicd_probe(struct platform_device *pldev) #ifdef CONFIG_OF if (of_find_compatible_node(NULL, NULL, IPROC_CMICX_COMPATIBLE)) { uint32 *icfg_chip_id; - icfg_chip_id = (uint32 *)IOREMAP(ICFG_CHIP_ID_REG, 2 * sizeof(uint32)); + icfg_chip_id = (uint32 *)ioremap(ICFG_CHIP_ID_REG, 2 * sizeof(uint32)); if (icfg_chip_id == NULL) { gprintk("Error mapping ICFG_CHIP_ID_REG\n"); return -1; @@ -746,12 +737,12 @@ iproc_cmicd_probe(struct platform_device *pldev) /* Map GICD block in the AXI memory space into CPU address space */ memres = iproc_platform_get_resource(pldev, IORESOURCE_MEM, 1); if (memres) { - ctrl->bde_dev.base_address1 = (sal_vaddr_t)IOREMAP(memres->start, memres->end - memres->start + 1); + ctrl->bde_dev.base_address1 = (sal_vaddr_t)ioremap(memres->start, memres->end - memres->start + 1); ctrl->iowin[1].addr = memres->start; ctrl->iowin[1].size = memres->end - memres->start + 1; } else { /* Use default address if not available in DTB */ - ctrl->bde_dev.base_address1 = (sal_vaddr_t)IOREMAP(IHOST_GICD_REG_ADDR, IHOST_GICD_REG_REMAP_LEN); + ctrl->bde_dev.base_address1 = (sal_vaddr_t)ioremap(IHOST_GICD_REG_ADDR, IHOST_GICD_REG_REMAP_LEN); ctrl->iowin[1].addr = IHOST_GICD_REG_ADDR; ctrl->iowin[1].size = IHOST_GICD_REG_REMAP_LEN; } @@ -914,7 +905,7 @@ iproc_has_cmicd(void) void *iproc_cca_base; /* Read ChipcommonA chip id register to identify current SOC */ - iproc_cca_base = IOREMAP(IPROC_CHIPCOMMONA_BASE, 0x3000); + iproc_cca_base = ioremap(IPROC_CHIPCOMMONA_BASE, 0x3000); if (iproc_cca_base == NULL) { gprintk("iproc_has_cmicd: ioremap of ChipcommonA registers failed"); return 0; @@ -969,12 +960,12 @@ iproc_cmicd_get_memregion(struct resource *res_mem) uint8_t size_type = 0; bool is_compident_a = 1; /* 1: CompidentA; o/w: CompidentB */ - erom_ptr_oft = IOREMAP(IPROC_CHIPCOMMONA_EROM_PTR_OFFSET, 0x100); + erom_ptr_oft = ioremap(IPROC_CHIPCOMMONA_EROM_PTR_OFFSET, 0x100); erom_phy_addr = readl((uint32 *)(erom_ptr_oft)); iounmap(erom_ptr_oft); - erom_base = IOREMAP(erom_phy_addr, EROM_MAX_SIZE); + erom_base = ioremap(erom_phy_addr, EROM_MAX_SIZE); while (1) { word = readl((uint32 *)(erom_base + i)); @@ -1071,7 +1062,7 @@ _ics_bde_create(void) /* Map in the device */ paddr = BCM_ICS_CMIC_BASE; - ctrl->bde_dev.base_address = (sal_vaddr_t)IOREMAP(paddr, 0x10000); + ctrl->bde_dev.base_address = (sal_vaddr_t)ioremap(paddr, 0x10000); ctrl->iowin[0].addr = paddr; ctrl->iowin[0].size = 0x10000; @@ -1662,6 +1653,21 @@ static const struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM8884D_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM8884E_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM8884F_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88831_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88832_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88833_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88834_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88835_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88836_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88837_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88838_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88839_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8883A_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8883B_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8883C_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8883D_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8883E_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8883F_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, #endif /* BCM_DNX_SUPPORT */ #ifdef BCM_DFE_SUPPORT { BROADCOM_VENDOR_ID, BCM88770_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -2072,7 +2078,7 @@ _plx_las_bar_get(struct pci_dev *dev) void *local_config_addr; int bar = -1; - local_config_addr = IOREMAP(pci_resource_start(dev, PLX_MMAP_PCIBAR0), + local_config_addr = ioremap(pci_resource_start(dev, PLX_MMAP_PCIBAR0), pci_resource_len(dev, PLX_MMAP_PCIBAR0)); if (local_config_addr) { uint32 las_remap_reg; @@ -2578,7 +2584,7 @@ _pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) * system performance. This change significantly reduces the * number of PCI retries from other devices on the PCI bus. */ - void * _mc_vbase = IOREMAP(BCM4704_MEMC_BASE, 0x1000); + void * _mc_vbase = ioremap(BCM4704_MEMC_BASE, 0x1000); int priorinv = 0x80; static int done = 0; if (!done) { @@ -2726,7 +2732,7 @@ _pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) break; } - ctrl->bde_dev.base_address = (sal_vaddr_t)IOREMAP(paddr, bar_len); + ctrl->bde_dev.base_address = (sal_vaddr_t)ioremap(paddr, bar_len); ctrl->iowin[0].addr = paddr; ctrl->iowin[0].size = bar_len; @@ -2749,7 +2755,7 @@ _pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) ) { paddr = pci_resource_start(dev, 0); bar_len = pci_resource_len(dev, 0); - ctrl->bde_dev.base_address1 = (sal_vaddr_t)IOREMAP(paddr, bar_len); + ctrl->bde_dev.base_address1 = (sal_vaddr_t)ioremap(paddr, bar_len); ctrl->iowin[1].addr = paddr; ctrl->iowin[1].size = PAGE_ALIGN(bar_len); if (debug >= 3) { @@ -2959,7 +2965,7 @@ map_local_bus(uint64_t addr, uint32_t size) ctrl->pci_device = NULL; /* No PCI bus */ /* Map in the device */ - ctrl->bde_dev.base_address = (sal_vaddr_t)IOREMAP(addr, size); + ctrl->bde_dev.base_address = (sal_vaddr_t)ioremap(addr, size); ctrl->iowin[0].addr = addr; ctrl->iowin[0].size = size; @@ -3424,12 +3430,12 @@ _bde_mmap(struct file *filp, struct vm_area_struct *vma) static char _modname[] = LINUX_KERNEL_BDE_NAME; static gmodule_t _gmodule = { - name: LINUX_KERNEL_BDE_NAME, - major: LINUX_KERNEL_BDE_MAJOR, - init: _init, - cleanup: _cleanup, - pprint: _pprint, - mmap: _bde_mmap, + .name = LINUX_KERNEL_BDE_NAME, + .major = LINUX_KERNEL_BDE_MAJOR, + .init = _init, + .cleanup = _cleanup, + .pprint = _pprint, + .mmap = _bde_mmap, }; gmodule_t * @@ -3906,7 +3912,7 @@ _iproc_ihost_read(int d, uint32_t addr) { uint32_t *mapaddr; uint32_t reg_val; - mapaddr = IOREMAP(addr, sizeof(uint32_t)); + mapaddr = ioremap(addr, sizeof(uint32_t)); if (mapaddr == NULL) { return -1; } @@ -3919,7 +3925,7 @@ static int _iproc_ihost_write(int d, uint32_t addr, uint32_t data) { uint32_t *mapaddr; - mapaddr = IOREMAP(addr, sizeof(uint32_t)); + mapaddr = ioremap(addr, sizeof(uint32_t)); if (mapaddr == NULL) { return -1; } @@ -4219,7 +4225,7 @@ lkbde_cpu_pci_register(int d) if (ctrl->bde_dev.base_address) { iounmap((void *)ctrl->bde_dev.base_address); } - ctrl->bde_dev.base_address = (sal_vaddr_t)IOREMAP(ctrl->iowin[0].addr, 0x1000000); + ctrl->bde_dev.base_address = (sal_vaddr_t)ioremap(ctrl->iowin[0].addr, 0x1000000); if (debug >= 1) { gprintk("%s, %s(): info:\n", __FILE__, __FUNCTION__); @@ -4271,29 +4277,29 @@ LKM_EXPORT_SYM(lkbde_mem_read); #endif /* BCM_SAND_SUPPORT */ static ibde_t _ibde = { - name: _name, - num_devices: _num_devices, - get_dev: _get_dev, - get_dev_type: _get_dev_type, - pci_conf_read: _pci_conf_read, - pci_conf_write: _pci_conf_write, - pci_bus_features: _pci_bus_features, - read: _read, - write: _write, - salloc: _salloc, - sfree: _sfree, - sinval: _sinval, - sflush: _sflush, - interrupt_connect: _interrupt_connect, - interrupt_disconnect: _interrupt_disconnect, - l2p: _l2p, - p2l: _p2l, + .name = _name, + .num_devices = _num_devices, + .get_dev = _get_dev, + .get_dev_type = _get_dev_type, + .pci_conf_read = _pci_conf_read, + .pci_conf_write = _pci_conf_write, + .pci_bus_features = _pci_bus_features, + .read = _read, + .write = _write, + .salloc = _salloc, + .sfree = _sfree, + .sinval = _sinval, + .sflush = _sflush, + .interrupt_connect = _interrupt_connect, + .interrupt_disconnect = _interrupt_disconnect, + .l2p = _l2p, + .p2l = _p2l, NULL, NULL, - iproc_read: _iproc_read, - iproc_write: _iproc_write, - get_cmic_ver: _get_cmic_ver, + .iproc_read = _iproc_read, + .iproc_write = _iproc_write, + .get_cmic_ver = _get_cmic_ver, }; /* diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_dma.c b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_dma.c index 53a31f859cf3..be46282e7f8d 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_dma.c +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_dma.c @@ -716,7 +716,7 @@ _edk_mpool_alloc(int dev_id, size_t size) dma_pbase = pbase; #ifdef REMAP_DMA_NONCACHED - _dma_vbase = IOREMAP(dma_pbase, size); + _dma_vbase = ioremap(dma_pbase, size); #endif _edk_dma_pool[dev_id].cpu_pbase = cpu_pbase; _edk_dma_pool[dev_id].dma_pbase = dma_pbase; @@ -1044,7 +1044,7 @@ void _dma_per_device_init(int dev_index) gprintk("remapping DMA buffer pool from physical:0x%lx original kernel_virt:0x%lx\n", (unsigned long)_dma_pbase, (unsigned long)_dma_vbase); } - _dma_vbase = IOREMAP(_dma_pbase, _dma_mem_size); + _dma_vbase = ioremap(_dma_pbase, _dma_mem_size); } if (dma_debug >= 1) { @@ -1270,13 +1270,8 @@ _sinval(int d, void *ptr, int length) #if defined(dma_cache_wback_inv) dma_cache_wback_inv((unsigned long)ptr, length); #else -#if defined(IPROC_CMICD) || defined(BCM958525) /* FIXME: need proper function to replace dma_cache_sync */ dma_sync_single_for_cpu(NULL, (unsigned long)ptr, length, DMA_BIDIRECTIONAL); -#else - // TODO: This needs to be verified - dma_sync_single_for_device(NULL, ptr, length, DMA_BIDIRECTIONAL); -#endif #endif return 0; } @@ -1287,13 +1282,8 @@ _sflush(int d, void *ptr, int length) #if defined(dma_cache_wback_inv) dma_cache_wback_inv((unsigned long)ptr, length); #else -#if defined(IPROC_CMICD) || defined(BCM958525) /* FIXME: need proper function to replace dma_cache_sync */ dma_sync_single_for_cpu(NULL, (unsigned long)ptr, length, DMA_BIDIRECTIONAL); -#else - // TODO: This needs to be verified - dma_sync_single_for_device(NULL, ptr, length, DMA_BIDIRECTIONAL); -#endif #endif return 0; diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/linux-user-bde.c b/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/linux-user-bde.c index 7ed387b0e1a4..7677aa5d4394 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/linux-user-bde.c +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/linux-user-bde.c @@ -71,6 +71,7 @@ MODULE_LICENSE("GPL"); /* CMICX defines */ #define INTC_INTR_REG_NUM (8) #define PAXB_INTRCLR_DELAY_REG_NUM (16) + /* TODO:HX5 The INTR base address values are changed for HX5, @@ -109,6 +110,29 @@ be made. #define INTC_INTR_STATUS_BASE (INTC_INTR_STATUS_REG0) #define INTC_INTR_RAW_STATUS_BASE (INTC_INTR_RAW_STATUS_REG0) +/** CMICX Gen2 defines*/ +#define CMICX_GEN2_INTC_INTR_REG_NUM (10) +#define CMICX_GEN2_PAXB_0_PAXB_IC_INTRCLR_0 (0x0292C3A0) +#define CMICX_GEN2_PAXB_0_PAXB_IC_INTRCLR_1 (0x0292C3A4) +#define CMICX_GEN2_PAXB_0_PAXB_IC_INTRCLR_MODE_0 (0x0292C3A8) +#define CMICX_GEN2_PAXB_0_PAXB_IC_INTRCLR_MODE_1 (0x0292C3AC) +#define CMICX_GEN2_PAXB_0_PAXB_INTR_STATUS (0x0292CF38) +#define CMICX_GEN2_PAXB_0_PAXB_IC_INTR_PACING_CTRL (0x0292C398) +#define CMICX_GEN2_PAXB_0_PAXB_INTRCLR_DELAY_UNIT (0x0292C39c) +#define CMICX_GEN2_PAXB_0_PAXB_IC_INTRCLR_DELAY_REG0 (0x0292C3b0) +#define CMICX_GEN2_PAXB_0_PAXB_IC_INTRCLR_DELAY_BASE (CMICX_GEN2_PAXB_0_PAXB_IC_INTRCLR_DELAY_REG0) +#define CMICX_GEN2_PAXB_0_PCIE_ERROR_STATUS (0x0292C024) +#define CMICX_GEN2_PAXB_0_INTC_INTR_ENABLE_REG0 (0x0292D100) +#define CMICX_GEN2_PAXB_0_INTC_INTR_STATUS_REG0 (0x0292D1A0) +#define CMICX_GEN2_PAXB_0_INTC_INTR_RAW_STATUS_REG0 (0x0292D178) +#define CMICX_GEN2_PAXB_0_INTC_INTR_ENABLE_BASE (CMICX_GEN2_PAXB_0_INTC_INTR_ENABLE_REG0) +#define CMICX_GEN2_PAXB_0_INTC_INTR_STATUS_BASE (CMICX_GEN2_PAXB_0_INTC_INTR_STATUS_REG0) +#define CMICX_GEN2_PAXB_0_INTC_INTR_RAW_STATUS_BASE (CMICX_GEN2_PAXB_0_INTC_INTR_RAW_STATUS_REG0) +#define CMICX_GEN2_INTC_PDMA_INTR_REG_IND_0 5 +#define CMICX_GEN2_INTC_PDMA_INTR_REG_IND_1 6 + + + #define HX5_INTC_INTR_ENABLE_REG0 (0x102310f0) #define HX5_INTC_INTR_STATUS_REG0 (0x10231190) #define HX5_INTC_INTR_RAW_STATUS_REG0 (0x10231140) @@ -117,8 +141,6 @@ be made. #define HX5_INTC_INTR_STATUS_BASE (HX5_INTC_INTR_STATUS_REG0) #define HX5_INTC_INTR_RAW_STATUS_BASE (HX5_INTC_INTR_RAW_STATUS_REG0) -#define IOREMAP(addr, size) ioremap(addr, size) - #define HX5_IHOST_GICD_ISENABLERN_0 (0x10781100) #define HX5_IHOST_GICD_ISENABLERN_1 (0x10781104) #define HX5_IHOST_GICD_ICENABLERN_1 (0x10781184) @@ -205,6 +227,7 @@ typedef struct _intr_regs_s { uint32 intc_intr_clear_delay_unit; uint32 intc_intr_clear_delay_base; uint32 intc_intr_pcie_err_status; + uint32 intc_intr_nof_regs; } _intr_regs_t; typedef struct bde_ctrl_s { @@ -351,7 +374,7 @@ dump_interrupt_regs(bde_ctrl_t *ctrl , int dev) if (debug >= 2) { gprintk("Interrupt timeout count = %lu\n", intr_timeout_count); gprintk("Interrupt count = %lu\n", intr_count); - for (ind = 0; ind < INTC_INTR_REG_NUM; ind++) { + for (ind = 0; ind < ctrl->intr_regs.intc_intr_nof_regs; ind++) { IPROC_READ(dev, ctrl->intr_regs.intc_intr_status_base + 4 * ind, val); gprintk("INTC_INTR_STATUS_REG_%d = 0x%x\n", ind, val); IPROC_READ(dev, ctrl->intr_regs.intc_intr_raw_status_base + 4 * ind, val); @@ -375,7 +398,7 @@ dump_interrupt_regs(bde_ctrl_t *ctrl , int dev) } } /* Clear interrupt enable registers */ - for (ind = 0; ind < INTC_INTR_REG_NUM; ind++) { + for (ind = 0; ind < ctrl->intr_regs.intc_intr_nof_regs; ind++) { IPROC_WRITE(dev, ctrl->intr_regs.intc_intr_enable_base + 4 * ind, 0); } } @@ -580,6 +603,85 @@ _cmicx_interrupt(bde_ctrl_t *ctrl) } } +#ifdef NEED_CMICX_GEN2_INTERRUPT +static void +_cmicx_gen2_interrupt(bde_ctrl_t *ctrl) +{ + int d, ind ; + uint32 stat, iena, mask, fmask; + int active_interrupts = 0; + bde_inst_resource_t *res; + + intr_count++; + d = (((uint8 *)ctrl - (uint8 *)_devices) / sizeof (bde_ctrl_t)); + res = &_bde_inst_resource[ctrl->inst]; + + /** Get MSI clear mode, auto clear or SW clear, must be configure same for 64 MSI/MSIx vectors */ + IPROC_READ(d, ctrl->intr_regs.intc_intr_clear_mode_0, stat); + /* Clear MSI interrupts immediately to prevent spurious interrupts */ + if (stat == 0) { + IPROC_WRITE(d, ctrl->intr_regs.intc_intr_clear_0, 0xFFFFFFFF); + IPROC_WRITE(d, ctrl->intr_regs.intc_intr_clear_1, 0xFFFFFFFF); + } + + lkbde_irq_mask_get(d, &mask, &fmask); + for (ind = 0; ind < CMICX_GEN2_INTC_INTR_REG_NUM; ind++) { + IPROC_READ(d, ctrl->intr_regs.intc_intr_status_base + 4 * ind, stat); + if (stat == 0) { + continue; + } + + if (fmask) { + /** Packet DMA 8 - 31 bits on IPROC_IRQ_BASE5 */ + if ((ind == CMICX_GEN2_INTC_PDMA_INTR_REG_IND_0) && !(stat & 0xFF)) { + continue; + } else if ((ind == CMICX_GEN2_INTC_PDMA_INTR_REG_IND_1) && !(stat & 0xFFFFFF00)) { + /** Packet DMA 0 - 7 bits on IPROC_IRQ_BASE6 */ + continue; + } + } + IPROC_READ(d, ctrl->intr_regs.intc_intr_enable_base + 4 * ind, iena); + if (stat & iena) { + active_interrupts = 1; + break; + } + } + + /* No active interrupts to service */ + if (!active_interrupts) { + return; + } + + /* Disable all interrupts.. Re-enable unserviced interrupts later + * So as to avoid getting new interrupts until the user level driver + * enumerates the interrupts to be serviced + */ + for (ind = 0; ind < CMICX_GEN2_INTC_INTR_REG_NUM; ind++) { + if (fmask) { + /** TODO? change by KNET */ + if (ind == CMICX_GEN2_INTC_PDMA_INTR_REG_IND_0) { + IPROC_READ(d, ctrl->intr_regs.intc_intr_enable_base + 4 * ind, iena); + IPROC_WRITE(d, ctrl->intr_regs.intc_intr_enable_base + (4 * ind), iena & ((fmask & 0xFFFFFF) << 8)); + continue; + } else if (ind == CMICX_GEN2_INTC_PDMA_INTR_REG_IND_1) { + IPROC_READ(d, ctrl->intr_regs.intc_intr_enable_base + 4 * ind, iena); + IPROC_WRITE(d, ctrl->intr_regs.intc_intr_enable_base + (4 * ind), iena & ((fmask & 0xFF) << 24)); + continue; + } + } + IPROC_WRITE(d, ctrl->intr_regs.intc_intr_enable_base + (4 * ind), 0); + } + + /* Notify */ + atomic_set(&res->intr, 1); +#ifdef BDE_LINUX_NON_INTERRUPTIBLE + wake_up(&res->intr_wq); +#else + wake_up_interruptible(&res->intr_wq); +#endif +} +#endif /* NEED_CMICX_GEN2_INTERRUPT */ + static void _cmicm_interrupt(bde_ctrl_t *ctrl) { @@ -925,9 +1027,9 @@ _intr_mode_str(void *isr) } static void -_intr_regs_init(bde_ctrl_t *ctrl, int hx5_intr) +_intr_regs_init(bde_ctrl_t *ctrl, int flag) { - if (hx5_intr) { + if (flag == 1) { ctrl->intr_regs.intc_intr_status_base = HX5_INTC_INTR_STATUS_BASE; ctrl->intr_regs.intc_intr_enable_base = HX5_INTC_INTR_ENABLE_BASE; ctrl->intr_regs.intc_intr_raw_status_base = HX5_INTC_INTR_RAW_STATUS_BASE; @@ -940,7 +1042,21 @@ _intr_regs_init(bde_ctrl_t *ctrl, int hx5_intr) ctrl->intr_regs.intc_intr_clear_delay_unit = HX5_PAXB_0_PAXB_INTRCLR_DELAY_UNIT; ctrl->intr_regs.intc_intr_clear_delay_base = HX5_PAXB_0_PAXB_IC_INTRCLR_DELAY_BASE; ctrl->intr_regs.intc_intr_pcie_err_status = HX5_PAXB_0_PCIE_ERROR_STATUS; - + ctrl->intr_regs.intc_intr_nof_regs = INTC_INTR_REG_NUM; + } else if (flag == 2){ + ctrl->intr_regs.intc_intr_status_base = CMICX_GEN2_PAXB_0_INTC_INTR_STATUS_BASE; + ctrl->intr_regs.intc_intr_raw_status_base = CMICX_GEN2_PAXB_0_INTC_INTR_RAW_STATUS_BASE; + ctrl->intr_regs.intc_intr_enable_base = CMICX_GEN2_PAXB_0_INTC_INTR_ENABLE_BASE; + ctrl->intr_regs.intc_intr_clear_0 = CMICX_GEN2_PAXB_0_PAXB_IC_INTRCLR_0; + ctrl->intr_regs.intc_intr_clear_1 = CMICX_GEN2_PAXB_0_PAXB_IC_INTRCLR_1; + ctrl->intr_regs.intc_intr_clear_mode_0 = CMICX_GEN2_PAXB_0_PAXB_IC_INTRCLR_MODE_0; + ctrl->intr_regs.intc_intr_clear_mode_1 = CMICX_GEN2_PAXB_0_PAXB_IC_INTRCLR_MODE_1; + ctrl->intr_regs.intc_intr_status = CMICX_GEN2_PAXB_0_PAXB_INTR_STATUS; + ctrl->intr_regs.intc_intr_pacing_ctrl = CMICX_GEN2_PAXB_0_PAXB_IC_INTR_PACING_CTRL; + ctrl->intr_regs.intc_intr_clear_delay_unit = CMICX_GEN2_PAXB_0_PAXB_INTRCLR_DELAY_UNIT; + ctrl->intr_regs.intc_intr_clear_delay_base = CMICX_GEN2_PAXB_0_PAXB_IC_INTRCLR_DELAY_BASE; + ctrl->intr_regs.intc_intr_pcie_err_status = CMICX_GEN2_PAXB_0_PCIE_ERROR_STATUS; + ctrl->intr_regs.intc_intr_nof_regs = CMICX_GEN2_INTC_INTR_REG_NUM; } else { ctrl->intr_regs.intc_intr_status_base = INTC_INTR_STATUS_BASE; ctrl->intr_regs.intc_intr_raw_status_base = INTC_INTR_RAW_STATUS_BASE; @@ -954,7 +1070,7 @@ _intr_regs_init(bde_ctrl_t *ctrl, int hx5_intr) ctrl->intr_regs.intc_intr_clear_delay_unit = PAXB_0_PAXB_INTRCLR_DELAY_UNIT; ctrl->intr_regs.intc_intr_clear_delay_base = PAXB_0_PAXB_IC_INTRCLR_DELAY_BASE; ctrl->intr_regs.intc_intr_pcie_err_status = PAXB_0_PCIE_ERROR_STATUS; - + ctrl->intr_regs.intc_intr_nof_regs = INTC_INTR_REG_NUM; } } @@ -1074,11 +1190,11 @@ _devices_init(int d) ctrl->isr = (isr_f)_cmicx_interrupt; if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { if (!ihost_intr_enable_base) { - ihost_intr_enable_base = (uint32_t *)IOREMAP(HX5_IHOST_GICD_ISENABLERN_1, + ihost_intr_enable_base = (uint32_t *)ioremap(HX5_IHOST_GICD_ISENABLERN_1, HX5_IHOST_INTR_MAP_NUM); } if (!ihost_intr_status_base) { - ihost_intr_status_base = (uint32_t *)IOREMAP(HX5_INTC_INTR_RAW_STATUS_REG0, + ihost_intr_status_base = (uint32_t *)ioremap(HX5_INTC_INTR_RAW_STATUS_REG0, HX5_IHOST_INTR_STATUS_MAP_NUM); } } @@ -1131,6 +1247,7 @@ _devices_init(int d) ctrl->isr = (isr_f)_cmicx_interrupt; _intr_regs_init(ctrl, 0); break; + } #endif /* defined(BCM_DNXF_SUPPORT) || defined(BCM_DNX_SUPPORT) */ @@ -1867,7 +1984,7 @@ _ioctl(unsigned int cmd, unsigned long arg) return -EINVAL; } if (_devices[io.dev].dev_type & BDE_AXI_DEV_TYPE) { - mapaddr = IOREMAP(io.d0, sizeof(uint32_t)); + mapaddr = ioremap(io.d0, sizeof(uint32_t)); if (mapaddr == NULL) { io.rc = LUBDE_FAIL; return -1; @@ -1920,12 +2037,12 @@ static char _modname[] = LINUX_USER_BDE_NAME; static gmodule_t _gmodule = { - name: LINUX_USER_BDE_NAME, - major: LINUX_USER_BDE_MAJOR, - init: _init, - cleanup: _cleanup, - pprint: _pprint, - ioctl: _ioctl, + .name = LINUX_USER_BDE_NAME, + .major = LINUX_USER_BDE_MAJOR, + .init = _init, + .cleanup = _cleanup, + .pprint = _pprint, + .ioctl = _ioctl, }; gmodule_t* diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-knet/bcm-knet.c b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-knet/bcm-knet.c index dbb3de5f9e94..b93f1e913fd9 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-knet/bcm-knet.c +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-knet/bcm-knet.c @@ -5477,6 +5477,12 @@ bkn_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) bkn_switch_info_t *sinfo; struct hwtstamp_config config; + DBG_PTP(("bkn_ioctl: module_initialized:%d\n", module_initialized)); + + if (!module_initialized) { + return -EINVAL; + } + if (!dev) return -EINVAL; @@ -6608,6 +6614,12 @@ static const struct net_device_ops bkn_netdev_ops = { static void bkn_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) { + DBG_PTP(("bkn_get_drv_info: module_initialized:%d\n", module_initialized)); + + if (!module_initialized) { + return; + } + strlcpy(drvinfo->driver, "bcm-knet", sizeof(drvinfo->driver)); snprintf(drvinfo->version, sizeof(drvinfo->version), "%d", KCOM_VERSION); strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); @@ -6621,6 +6633,12 @@ bkn_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info) bkn_priv_t *priv; bkn_switch_info_t *sinfo; + DBG_PTP(("bkn_get_ts_info: module_initialized:%d\n", module_initialized)); + + if (!module_initialized) { + return -EINVAL; + } + if (!dev) return -EINVAL; @@ -6631,6 +6649,9 @@ bkn_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info) sinfo = priv->sinfo; + if (!sinfo) + return -EINVAL; + switch (sinfo->dcb_type) { case 28: /* dpp */ case 26: @@ -6734,6 +6755,7 @@ bkn_init_ndev(u8 *mac, char *name) dev->mtu = rx_buffer_size; } #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) + dev->min_mtu = 68; dev->max_mtu = rx_buffer_size; #endif @@ -6885,24 +6907,14 @@ bkn_proc_link_write(struct file *file, const char *buf, return count; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) -struct file_operations bkn_proc_link_file_ops = { - owner: THIS_MODULE, - open: bkn_proc_link_open, - read: seq_read, - llseek: seq_lseek, - write: bkn_proc_link_write, - release: single_release, -}; -#else struct proc_ops bkn_proc_link_file_ops = { - proc_open: bkn_proc_link_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_write: bkn_proc_link_write, - proc_release: single_release, + PROC_OWNER(THIS_MODULE) + .proc_open = bkn_proc_link_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = bkn_proc_link_write, + .proc_release = single_release, }; -#endif /* * Device Rate Control Proc Read Entry @@ -7005,24 +7017,14 @@ bkn_proc_rate_write(struct file *file, const char *buf, return count; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) -struct file_operations bkn_proc_rate_file_ops = { - owner: THIS_MODULE, - open: bkn_proc_rate_open, - read: seq_read, - llseek: seq_lseek, - write: bkn_proc_rate_write, - release: single_release, -}; -#else struct proc_ops bkn_proc_rate_file_ops = { - proc_open: bkn_proc_rate_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_write: bkn_proc_rate_write, - proc_release: single_release, + PROC_OWNER(THIS_MODULE) + .proc_open = bkn_proc_rate_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = bkn_proc_rate_write, + .proc_release = single_release, }; -#endif /* * Driver DMA Proc Entry @@ -7265,22 +7267,13 @@ bkn_seq_dma_open(struct inode *inode, struct file *file) return seq_open(file, &bkn_seq_dma_ops); }; -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) -static struct file_operations bkn_seq_dma_file_ops = { - .owner = THIS_MODULE, - .open = bkn_seq_dma_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release -}; -#else static struct proc_ops bkn_seq_dma_file_ops = { + PROC_OWNER(THIS_MODULE) .proc_open = bkn_seq_dma_open, .proc_read = seq_read, - .proc_lseek = seq_lseek, + .proc_lseek = seq_lseek, .proc_release = seq_release }; -#endif /* * Device Debug Control Proc Write Entry @@ -7411,24 +7404,14 @@ static int bkn_proc_debug_open(struct inode * inode, struct file * file) return single_open(file, bkn_proc_debug_show, NULL); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) -struct file_operations bkn_proc_debug_file_ops = { - owner: THIS_MODULE, - open: bkn_proc_debug_open, - read: seq_read, - llseek: seq_lseek, - write: bkn_proc_debug_write, - release: single_release, -}; -#else struct proc_ops bkn_proc_debug_file_ops = { - proc_open: bkn_proc_debug_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_write: bkn_proc_debug_write, - proc_release: single_release, + PROC_OWNER(THIS_MODULE) + .proc_open = bkn_proc_debug_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = bkn_proc_debug_write, + .proc_release = single_release, }; -#endif /* * Device Statistics Proc Entry @@ -7550,24 +7533,14 @@ bkn_proc_stats_write(struct file *file, const char *buf, return count; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) -struct file_operations bkn_proc_stats_file_ops = { - owner: THIS_MODULE, - open: bkn_proc_stats_open, - read: seq_read, - llseek: seq_lseek, - write: bkn_proc_stats_write, - release: single_release, -}; -#else struct proc_ops bkn_proc_stats_file_ops = { - proc_open: bkn_proc_stats_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_write: bkn_proc_stats_write, - proc_release: single_release, + PROC_OWNER(THIS_MODULE) + .proc_open = bkn_proc_stats_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = bkn_proc_stats_write, + .proc_release = single_release, }; -#endif /* @@ -7737,24 +7710,14 @@ bkn_proc_dstats_write(struct file *file, const char *buf, return count; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) -struct file_operations bkn_proc_dstats_file_ops = { - owner: THIS_MODULE, - open: bkn_proc_dstats_open, - read: seq_read, - llseek: seq_lseek, - write: bkn_proc_dstats_write, - release: single_release, -}; -#else struct proc_ops bkn_proc_dstats_file_ops = { - proc_open: bkn_proc_dstats_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_write: bkn_proc_dstats_write, - proc_release: single_release, + PROC_OWNER(THIS_MODULE) + .proc_open = bkn_proc_dstats_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = bkn_proc_dstats_write, + .proc_release = single_release, }; -#endif /* * PTP Statistics Proc Entry @@ -7779,16 +7742,15 @@ bkn_proc_ptp_stats_show(struct seq_file *m, void *v) if (priv->tx_hwts || priv->rx_hwts) { if (!print_hdr_done) { seq_printf(m, "PTP message stats (unit %d):\n", unit); - seq_printf(m, "=============================\n\n"); - seq_printf(m, " %-10s| %-8s| %-8s| %-8s| %-12s| %-12s\n", - "intf", "tx_hwts", "rx_hwts", "phc_type", "tx_pkts", "rx_pkts"); + seq_printf(m, " %-10s| %8s| %12s| %12s| %8s| %8s\n", + "intf", "phc_type", "tx_pkts", "rx_pkts", "tx_hwts", "rx_hwts"); seq_printf(m, "======================================================================\n"); print_hdr_done = 1; } - seq_printf(m, " %-10s| %8d| %8d| %-8s| %12d| %12d\n", - dev->name, priv->tx_hwts, priv->rx_hwts, - (priv->tx_hwts & HWTSTAMP_TX_ONESTEP_SYNC ? "1-step": "2-step"), - priv->ptp_stats_tx, priv->ptp_stats_rx); + seq_printf(m, " %-10s| %8s| %12d| %12d| %8d| %8d\n", + dev->name, (priv->tx_hwts & HWTSTAMP_TX_ONESTEP_SYNC ? "1-step": "2-step"), + priv->ptp_stats_tx, priv->ptp_stats_rx, + priv->tx_hwts, priv->rx_hwts); } } } @@ -7856,13 +7818,13 @@ bkn_proc_ptp_stats_write(struct file *file, const char *buf, size_t count, loff_ return count; } -struct file_operations bkn_proc_ptp_stats_file_ops = { - owner: THIS_MODULE, - open: bkn_proc_ptp_stats_open, - read: seq_read, - llseek: seq_lseek, - write: bkn_proc_ptp_stats_write, - release: single_release, +struct proc_ops bkn_proc_ptp_stats_file_ops = { + PROC_OWNER(THIS_MODULE) + .proc_open = bkn_proc_ptp_stats_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = bkn_proc_ptp_stats_write, + .proc_release = single_release, }; diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/lkm.h b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/lkm.h index 9ea8fc5896d8..3d66635977b2 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/lkm.h +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/lkm.h @@ -42,8 +42,8 @@ #include #include -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +#error Kernel too old #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) /* The version kconfig.h became available in. */ @@ -63,11 +63,7 @@ #include /* Helper defines for multi-version kernel support */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -#define LKM_2_4 -#else #define LKM_2_6 -#endif #include /* printk() */ #include /* everything... */ @@ -96,24 +92,11 @@ /* Compatibility Macros */ -#ifdef LKM_2_4 - -#include -#include -#define LKM_MOD_PARAM(n,ot,nt,d) MODULE_PARM(n,ot) -#define LKM_MOD_PARAM_ARRAY(n,ot,nt,c,d) MODULE_PARM(n,ot) -#define LKM_EXPORT_SYM(s) -#define _free_netdev kfree - -#else /* LKM_2_6 */ - #define LKM_MOD_PARAM(n,ot,nt,d) module_param(n,nt,d) #define LKM_MOD_PARAM_ARRAY(n,ot,nt,c,d) module_param_array(n,nt,c,d) #define LKM_EXPORT_SYM(s) EXPORT_SYMBOL(s) #define _free_netdev free_netdev -#endif /* LKM_2_x */ - #ifndef list_for_each_safe #define list_for_each_safe(l,t,i) t = 0; list_for_each((l),(i)) #endif @@ -162,6 +145,18 @@ #define CONFIG_BMW #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,5,0) +#define PROC_OWNER(_m) +#else +#define PROC_OWNER(_m) .owner = _m, +#define proc_ops file_operations +#define proc_open open +#define proc_read read +#define proc_write write +#define proc_lseek llseek +#define proc_release release +#endif + #if PROC_INTERFACE_KERN_VER_3_10 #define PROC_CREATE(_entry, _name, _acc, _path, _fops) \ do { \ diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/Makefile b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/Makefile index e0711db022b2..d888820fafba 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/Makefile @@ -61,6 +61,9 @@ $(KMODULE): $(MODULE) rm -fr $(BLDDIR)/$(KERNEL_MODULE_DIR) mkdir $(BLDDIR)/$(KERNEL_MODULE_DIR) cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/$(KERNEL_MODULE_DIR)/Makefile +ifeq ($(BUILD_PSAMPLE),1) + sed -i 's/0x......../0x00000000/' ${BLDDIR}/../psample/kernel_module/Module.symvers +endif cat ${KBUILD_EXTRA_SYMBOLS} > $(BLDDIR)/$(KERNEL_MODULE_DIR)/Module.symvers MOD_NAME=$(THIS_MOD_NAME) KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko endif diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/psample-cb.c b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/psample-cb.c index fd69d64ddb70..e67f9191d45e 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/psample-cb.c +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/psample-cb.c @@ -715,11 +715,12 @@ psample_proc_rate_write(struct file *file, const char *buf, } struct proc_ops psample_proc_rate_file_ops = { - proc_open: psample_proc_rate_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_write: psample_proc_rate_write, - proc_release: single_release, + PROC_OWNER(THIS_MODULE) + .proc_open = psample_proc_rate_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = psample_proc_rate_write, + .proc_release = single_release, }; /* @@ -813,11 +814,12 @@ psample_proc_size_write(struct file *file, const char *buf, } struct proc_ops psample_proc_size_file_ops = { - proc_open: psample_proc_size_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_write: psample_proc_size_write, - proc_release: single_release, + PROC_OWNER(THIS_MODULE) + .proc_open = psample_proc_size_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = psample_proc_size_write, + .proc_release = single_release, }; /* @@ -853,11 +855,12 @@ psample_proc_map_open(struct inode * inode, struct file * file) } struct proc_ops psample_proc_map_file_ops = { - proc_open: psample_proc_map_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_write: NULL, - proc_release: single_release, + PROC_OWNER(THIS_MODULE) + .proc_open = psample_proc_map_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = NULL, + .proc_release = single_release, }; /* @@ -922,11 +925,12 @@ psample_proc_debug_write(struct file *file, const char *buf, } struct proc_ops psample_proc_debug_file_ops = { - proc_open: psample_proc_debug_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_write: psample_proc_debug_write, - proc_release: single_release, + PROC_OWNER(THIS_MODULE) + .proc_open = psample_proc_debug_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = psample_proc_debug_write, + .proc_release = single_release, }; static int @@ -981,11 +985,12 @@ psample_proc_stats_write(struct file *file, const char *buf, return count; } struct proc_ops psample_proc_stats_file_ops = { - proc_open: psample_proc_stats_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_write: psample_proc_stats_write, - proc_release: single_release, + PROC_OWNER(THIS_MODULE) + .proc_open = psample_proc_stats_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = psample_proc_stats_write, + .proc_release = single_release, }; int psample_cleanup(void) diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/psample/Makefile b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/psample/Makefile index 631590104cd8..53293a7ac93b 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/psample/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/psample/Makefile @@ -48,7 +48,7 @@ $(KMODULE): $(MODULE) mkdir $(BLDDIR)/$(KERNEL_MODULE_DIR) cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/$(KERNEL_MODULE_DIR)/Makefile cat ${KBUILD_EXTRA_SYMBOLS} > $(BLDDIR)/$(KERNEL_MODULE_DIR)/Module.symvers - MOD_NAME=$(THIS_MOD_NAME) $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko + MOD_NAME=$(THIS_MOD_NAME) KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko endif # Make.depend is before clean:: so that Make.depend's clean:: runs first. diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/gmodule.c b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/gmodule.c index 5b2d5d959a1b..df6e2d6bb681 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/gmodule.c +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/gmodule.c @@ -41,16 +41,6 @@ static gmodule_t* _gmodule = NULL; -/* Allow DEVFS Support on 2.4 Kernels */ -#if defined(LKM_2_4) && defined(CONFIG_DEVFS_FS) -#define GMODULE_CONFIG_DEVFS_FS -#endif - - -#ifdef GMODULE_CONFIG_DEVFS_FS -devfs_handle_t devfs_handle = NULL; -#endif - /* FIXME: support dynamic debugging */ static int _dbg_enable = 0; @@ -149,24 +139,14 @@ static int _gmodule_proc_release(struct inode * inode, struct file * file) { return single_release(inode, file); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) -struct file_operations _gmodule_proc_fops = { - owner: THIS_MODULE, - open: _gmodule_proc_open, - read: seq_read, - llseek: seq_lseek, - write: _gmodule_proc_write, - release: _gmodule_proc_release, -}; -#else struct proc_ops _gmodule_proc_fops = { - proc_open: _gmodule_proc_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_write: _gmodule_proc_write, - proc_release: _gmodule_proc_release, + PROC_OWNER(THIS_MODULE) + .proc_open = _gmodule_proc_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = _gmodule_proc_write, + .proc_release = _gmodule_proc_release, }; -#endif #else int gmodule_vpprintf(char** page_ptr, const char* fmt, va_list args) @@ -281,7 +261,6 @@ _gmodule_release(struct inode *inode, struct file *filp) return 0; } -#if defined(HAVE_UNLOCKED_IOCTL) || LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0) static long _gmodule_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) @@ -292,20 +271,7 @@ _gmodule_unlocked_ioctl(struct file *filp, return -1; } } -#else -static int -_gmodule_ioctl(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) -{ - if(_gmodule->ioctl) { - return _gmodule->ioctl(cmd, arg); - } else { - return -1; - } -} -#endif -#ifdef HAVE_COMPAT_IOCTL static long _gmodule_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -315,7 +281,6 @@ _gmodule_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return -1; } } -#endif static int @@ -344,17 +309,11 @@ _gmodule_mmap(struct file *filp, struct vm_area_struct *vma) /* FILE OPERATIONS */ struct file_operations _gmodule_fops = { -#if defined(HAVE_UNLOCKED_IOCTL) || LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0) - unlocked_ioctl: _gmodule_unlocked_ioctl, -#else - ioctl: _gmodule_ioctl, -#endif - open: _gmodule_open, - release: _gmodule_release, - mmap: _gmodule_mmap, -#ifdef HAVE_COMPAT_IOCTL - compat_ioctl: _gmodule_compat_ioctl, -#endif + .unlocked_ioctl = _gmodule_unlocked_ioctl, + .open = _gmodule_open, + .release = _gmodule_release, + .mmap = _gmodule_mmap, + .compat_ioctl = _gmodule_compat_ioctl, }; @@ -374,11 +333,7 @@ cleanup_module(void) } /* Finally, remove ourselves from the universe */ -#ifdef GMODULE_CONFIG_DEVFS_FS - if(devfs_handle) devfs_unregister(devfs_handle); -#else unregister_chrdev(_gmodule->major, _gmodule->name); -#endif } int __init @@ -392,21 +347,6 @@ init_module(void) /* Register ourselves */ -#ifdef GMODULE_CONFIG_DEVFS_FS - devfs_handle = devfs_register(NULL, - _gmodule->name, - DEVFS_FL_NONE, - _gmodule->major, - _gmodule->minor, - S_IFCHR | S_IRUGO | S_IWUGO, - &_gmodule_fops, - NULL); - if(!devfs_handle) { - printk(KERN_WARNING "%s: can't register device with devfs", - _gmodule->name); - } - rc = 0; -#else rc = register_chrdev(_gmodule->major, _gmodule->name, &_gmodule_fops); @@ -419,17 +359,12 @@ init_module(void) if(_gmodule->major == 0) { _gmodule->major = rc; } -#endif /* Specific module Initialization */ if(_gmodule->init) { int rc; if((rc = _gmodule->init()) < 0) { -#ifdef GMODULE_CONFIG_DEVFS_FS - if(devfs_handle) devfs_unregister(devfs_handle); -#else unregister_chrdev(_gmodule->major, _gmodule->name); -#endif return rc; } } diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/ksal.c b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/ksal.c index e34e18cdafb1..2161b287f687 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/ksal.c +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/ksal.c @@ -191,9 +191,15 @@ sal_sem_give(sal_sem_t b) uint32 sal_time_usecs(void) { - // ktime_to_us and ktime_get_real_ns return 64-bit integets, but this - // function is returning a 32-bit integer. This should be fine until 2038. +#if !defined(SAI_FIXUP) + struct timeval ltv; + do_gettimeofday(<v); + return (ltv.tv_sec * SECOND_USEC + ltv.tv_usec); +#else + /* ktime_to_us and ktime_get_real_ns return 64-bit integets, but this */ + /* function is returning a 32-bit integer. This should be fine until 2038. */ return ktime_to_us(ktime_get_real_ns()); +#endif } void diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/common/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/common/Makefile index 8f59a763e314..3dc6425e6ee0 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/common/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/common/Makefile @@ -105,9 +105,6 @@ BCM_KNET=$(DEST_DIR)/$(BCM_KNET_LOCAL) PSAMPLE_LOCAL := psample.$(KOBJ) PSAMPLE := $(DEST_DIR)/$(PSAMPLE_LOCAL) -BCM_LPTP_LOCAL :=linux-bcm-ptp-clock.$(KOBJ) -BCM_LPTP=$(DEST_DIR)/$(BCM_LPTP_LOCAL) - ifeq (,$(findstring DELIVER,$(MAKECMDGOALS))) .DEFAULT_GOAL := all all_targets := kernel_modules $(KERNEL_BDE) $(USER_BDE) @@ -125,12 +122,6 @@ ifndef BUILD_KNET BUILD_KNET = 1 endif -# Remove this when LinuxPTP support becomes optional. -ifndef BUILD_LPTP -BUILD_LPTP = 1 -BUILD_KNETSYNC = 1 -endif - ifeq ($(BUILD_KNET),1) # Kernel network support all_targets += $(BCM_KNET) @@ -152,30 +143,7 @@ endif ifdef BUILD_PSAMPLE all_targets += $(PSAMPLE) ADD_TO_CFLAGS += -DPSAMPLE_SUPPORT - -# KnetSync support -ifdef BUILD_KNETSYNC - -KERNEL_TARGETS += $(BCM_PTP_CLOCK) -LOCAL_KERNEL_TARGETS += $(patsubst %,$(realpath ..)/$(platform)/%,$(BCM_PTP_CLOCK_LOCAL)) - -endif # BUILD_KNETSYNC - -ifeq ($(NO_LOCAL_TARGETS),) - LOCAL_TARGETS +=$(patsubst %,../$(platform)/%,$(PSAMPLE_LOCAL)) - all_targets +=$(LOCAL_TARGETS) -endif -endif - -ifdef BUILD_LPTP - all_targets += $(BCM_LPTP) - -ifeq ($(NO_LOCAL_TARGETS),) - LOCAL_TARGETS +=$(patsubst %,../$(platform)/%,$(BCM_LPTP_LOCAL)) - all_targets +=$(LOCAL_TARGETS) endif -endif - ADD_TO_CFLAGS += -I$(SDK)/systems/linux/kernel/modules/include COND_KNET_LIBS = libuser.$(libext) endif @@ -200,11 +168,6 @@ CFLAGS += $(ADD_TO_CFLAGS) #SAI_FIXUP CFLAGS:=$(filter-out -fPIC, $(CFLAGS)) -# KnetSync Support -ifdef BUILD_KNETSYNC - knetsync_subdirs = bcm-ptp-clock -endif # BUILD_KNETSYNC - kernel_modules: $(MAKE) -C $(SDK)/systems/bde/linux/kernel kernel_version=$(kernel_version) $(MAKE) -C $(SDK)/systems/bde/linux/user/kernel kernel_version=$(kernel_version) @@ -219,10 +182,6 @@ ifdef BUILD_KNET_CB $(MAKE) -C $(SDK)/systems/linux/kernel/modules kernel_version=$(kernel_version) \ subdirs="knet-cb" override-target=linux-$(platform) CFLAGS="$(CFLAGS)" endif -ifdef BUILD_LPTP - $(MAKE) -C $(SDK)/systems/linux/kernel/modules kernel_version=$(kernel_version) \ - subdirs="bcm-ptp-clock" override-target=linux-$(platform) CFLAGS="$(CFLAGS)" -endif endif $(KERNEL_BDE): $(KERN_BLDROOT)/linux-kernel-bde.$(KOBJ) @@ -241,8 +200,7 @@ $(KNET_CB): $(KERN_BLDROOT)/linux-knet-cb.$(KOBJ) $(PSAMPLE): $(KERN_BLDROOT)/psample.$(KOBJ) $(OBJCOPY) --strip-debug $< $@ -$(BCM_LPTP): $(KERN_BLDROOT)/linux-bcm-ptp-clock.$(KOBJ) - $(OBJCOPY) --strip-debug $< $@ + ifeq ($(NO_LOCAL_TARGETS),) $(foreach targ,$(LOCAL_TARGETS),$(eval $(call LOCAL_TARGET_DEF,$(targ)))) @@ -252,10 +210,10 @@ clean:: $(MAKE) -C $(SDK)/systems/bde/linux/kernel $@ $(MAKE) -C $(SDK)/systems/bde/linux/user/kernel $@ $(MAKE) -C $(SDK)/systems/linux/kernel/modules \ - subdirs="shared bcm-knet knet-cb psample bcm-ptp-clock" \ + subdirs="shared bcm-knet knet-cb psample" \ override-target=linux-$(platform) $@ $(RM) $(KERNEL_BDE) $(USER_BDE) - $(RM) $(BCM_KNET) $(KNET_CB) $(PSAMPLE) $(BCM_LPTP) + $(RM) $(BCM_KNET) $(KNET_CB) $(PSAMPLE) $(RM) $(KERN_BLDROOT)/linux-kernel-bde.$(KOBJ) $(RM) $(KERN_BLDROOT)/linux-user-bde.$(KOBJ) $(RM) $(KERN_BLDROOT)/linux-bcm-knet.$(KOBJ) diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54pe/modules/x86-64-accton-as4630-54pe-cpld.c b/platform/broadcom/sonic-platform-modules-accton/as4630-54pe/modules/x86-64-accton-as4630-54pe-cpld.c index f7a438feed7f..3a3c594f9fa8 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as4630-54pe/modules/x86-64-accton-as4630-54pe-cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54pe/modules/x86-64-accton-as4630-54pe-cpld.c @@ -47,7 +47,6 @@ #define FAN_REG_VAL_TO_SPEED_RPM_STEP 114 // R.P.M value = read value x3.79*60/2 #define NUM_THERMAL_SENSORS (3) /* Get sum of this number of sensors.*/ -#define THERMAL_SENSORS_DRIVER "lm75" #define THERMAL_SENSORS_ADDRS {0x48, 0x4a, 0x4b} static LIST_HEAD(cpld_client_list); @@ -168,7 +167,6 @@ static struct as4630_54pe_cpld_data *as4630_54pe_fan_update_device(struct device static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, char *buf); /* transceiver attributes */ #define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ @@ -212,10 +210,6 @@ static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, cha static SENSOR_DEVICE_ATTR(fan_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN_DUTY_CYCLE_PERCENTAGE); #define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan_duty_cycle_percentage.dev_attr.attr -#define DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR() \ - static SENSOR_DEVICE_ATTR(sys_temp, S_IRUGO, get_sys_temp, NULL, FAN_DUTY_CYCLE_PERCENTAGE) - -#define DECLARE_FAN_SYSTEM_TEMP_ATTR() &sensor_dev_attr_sys_temp.dev_attr.attr static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); @@ -571,7 +565,7 @@ static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, static u8 reg_val_to_direction(u8 reg_val, enum fan_id id) { - u8 mask = (1 << id); + u8 mask = (1 << (id+4)); reg_val &= mask; @@ -604,267 +598,6 @@ static u8 is_fan_fault(struct as4630_54pe_cpld_data *data, enum fan_id id) return ret; } -/* Due to this struct is declared at lm75.c, it cannot be include - * under Sonic environment. I duplicate it from lm75.c. - */ -struct lm75_data { - struct i2c_client *client; - struct device *hwmon_dev; - struct thermal_zone_device *tz; - struct mutex update_lock; - u8 orig_conf; - u8 resolution; /* In bits, between 9 and 12 */ - u8 resolution_limits; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - unsigned long sample_time; /* In jiffies */ - s16 temp[3]; /* Register values, - 0 = input - 1 = max - 2 = hyst */ -}; - -/*Copied from lm75.c*/ -static inline long lm75_reg_to_mc(s16 temp, u8 resolution) -{ - return ((temp >> (16 - resolution)) * 1000) >> (resolution - 8); -} - -/*Get hwmon_dev from i2c_client, set hwmon_dev = NULL is failed.*/ -static struct device * get_hwmon_dev( - struct i2c_client *client) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - if(data) - { - if( data->valid == 1 && data->hwmon_dev) - { - return data->hwmon_dev; - } - - } - return NULL; -} - -/* To find hwmon index by opening hwmon under that i2c address. - */ -static int find_hwmon_index_by_FileOpen( - int bus_nr, - unsigned short addr, - int *index) -{ -#define MAX_HWMON_DEVICE (10) /* Find hwmon device in 0~10*/ - struct file *sfd; - char client_name[96]; - int i=0; - - do { - snprintf(client_name, sizeof(client_name), - "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", - bus_nr, addr, i); - - sfd = filp_open(client_name, O_RDONLY, 0); - i++; - } while( IS_ERR(sfd) && i < MAX_HWMON_DEVICE); - - if (IS_ERR(sfd)) { - pr_err("Failed to open file(%s)#%d\r\n", client_name, __LINE__); - return -ENOENT; - } - filp_close(sfd, 0); - *index = i - 1; - return 0; - -#undef MAX_HWMON_DEVICE -} - -static int get_temp_file_path( - int bus_nr, unsigned short addr, - struct device *hwmon_dev - ,char *path, int max_len) -{ - - if(hwmon_dev && strlen(dev_name(hwmon_dev))) - { - snprintf(path, max_len, - "/sys/bus/i2c/devices/%d-%04x/hwmon/%s/temp1_input", - bus_nr, addr, dev_name(hwmon_dev)); - } - else - { - int i=0; - if(find_hwmon_index_by_FileOpen( bus_nr, addr, &i)) - { - return -EIO; - } - snprintf(path, max_len, - "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", - bus_nr, addr, i); - } - - return 0; -} - -/*File read the dev file at user space.*/ -static int read_devfile_temp1_input( - struct device *dev, - int bus_nr, - unsigned short addr, - struct device *hwmon_dev, - int *miniCelsius) -{ - struct file *sfd; - char buffer[96]; - char devfile[96]; - int rc, status; - int rdlen, value; - mm_segment_t old_fs; - - rc = 0; - get_temp_file_path(bus_nr, addr, hwmon_dev, devfile, sizeof(devfile)); - sfd = filp_open(devfile, O_RDONLY, 0); - if (IS_ERR(sfd)) { - pr_err("Failed to open file(%s)#%d\r\n", devfile, __LINE__); - return -ENOENT; - } - dev_dbg(dev, "Found device:%s\n",devfile); - - if(!(sfd->f_op) || !(sfd->f_op->read) ) { - pr_err("file %s cann't readable ?\n",devfile); - return -ENOENT; - } - - old_fs = get_fs(); - set_fs(KERNEL_DS); - rdlen = sfd->f_op->read(sfd, buffer, sizeof(buffer), &sfd->f_pos); - if (rdlen == 0) { - pr_err( "File(%s) empty!\n", devfile); - rc = -EIO; - goto exit; - } - status = sscanf(buffer, "%d", &value); - if (status != 1) { - rc = -EIO; - goto exit; - } - *miniCelsius = value; - dev_dbg(dev,"found sensors: %d @i2c %d-%04x\n", value, bus_nr, addr); - -exit: - set_fs(old_fs); - filp_close(sfd, 0); - return rc; -} - -static u8 is_lm75_data_due(struct i2c_client *client) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - if (time_after(jiffies, data->last_updated + data->sample_time)) - { - return 1; - } - return 0; -} -static int get_lm75_temp(struct i2c_client *client, int *miniCelsius) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - *miniCelsius = lm75_reg_to_mc(data->temp[0], data->resolution); - - return 0; -} - -static bool lm75_addr_mached(unsigned short addr) -{ - int i; - unsigned short addrs[] = THERMAL_SENSORS_ADDRS; - - for (i = 0; i < ARRAY_SIZE(addrs); i++) - { - if( addr == addrs[i]) - return 1; - } - return 0; -} - -static int _find_lm75_device(struct device *dev, void *data) -{ - struct device_driver *driver; - struct as4630_54pe_cpld_data *prv = data; - char *driver_name = THERMAL_SENSORS_DRIVER; - - driver = dev->driver; - if (driver && driver->name && - strcmp(driver->name, driver_name) == 0) - { - struct i2c_client *client; - client = to_i2c_client(dev); - if (client) - { - /*cannot use "struct i2c_adapter *adap = to_i2c_adapter(dev);"*/ - struct i2c_adapter *adap = client->adapter; - int miniCelsius = 0; - - if (! lm75_addr_mached(client->addr)) - { - return 0; - } - - if (!adap) { - return -ENXIO; - } - - /* If the data is not updated, read them from devfile - to drive them updateing data from chip.*/ - if (is_lm75_data_due(client)) - { - struct device *hwmon_dev; - - hwmon_dev = get_hwmon_dev(client); - if(0 == read_devfile_temp1_input(dev, adap->nr, - client->addr, hwmon_dev, &miniCelsius)) - { - prv->system_temp += miniCelsius; - prv->sensors_found++; - } - - } - else - { - get_lm75_temp(client, &miniCelsius); - prv->system_temp += miniCelsius; - prv->sensors_found++; - - } - } - } - return 0; -} - -/*Find all lm75 devices and return sum of temperatures.*/ -static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, - char *buf) -{ - ssize_t ret = 0; - struct as4630_54pe_cpld_data *data = as4630_54pe_fan_update_device(dev); - - data->system_temp=0; - data->sensors_found=0; - i2c_for_each_dev(data, _find_lm75_device); - if (NUM_THERMAL_SENSORS != data->sensors_found) - { - dev_dbg(dev,"only %d of %d temps are found\n", - data->sensors_found, NUM_THERMAL_SENSORS); - data->system_temp = INT_MAX; - } - ret = sprintf(buf, "%d\n",data->system_temp); - return ret; -} static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf) diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-cpld.c b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-cpld.c index 98b855329c64..317eac3a4cbb 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-cpld.c +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-cpld.c @@ -97,13 +97,16 @@ static const struct i2c_device_id as4630_54te_cpld_id[] = { MODULE_DEVICE_TABLE(i2c, as4630_54te_cpld_id); #define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index +#define TRANSCEIVER_RESET_ATTR_ID(index) MODULE_RESET_##index +#define TRANSCEIVER_LPMODE_ATTR_ID(index) MODULE_LPMODE_##index +#define TRANSCEIVER_PRESENT_ATTR_ID(index) MODULE_PRESENT_##index #define TRANSCEIVER_TXDISABLE_ATTR_ID(index) MODULE_TXDISABLE_##index -#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index -#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index +#define TRANSCEIVER_RXLOS_ATTR_ID(index) MODULE_RXLOS_##index +#define TRANSCEIVER_TXFAULT_ATTR_ID(index) MODULE_TXFAULT_##index #define FAN_SPEED_RPM_ATTR_ID(index) FAN_SPEED_RPM_##index -#define FAN_DIRECTION_ID(index) FAN_DIRECTION_##index +#define FAN_DIRECTION_ID(index) FAN_DIRECTION_##index #define FAN_PRESENT_ATTR_ID(index) FAN_PRESENT_##index -#define FAN_FAULT_ATTR_ID(index) FAN_FAULT_##index +#define FAN_FAULT_ATTR_ID(index) FAN_FAULT_##index enum as4630_54te_cpld_sysfs_attributes { CPLD_VERSION, @@ -123,6 +126,10 @@ enum as4630_54te_cpld_sysfs_attributes { TRANSCEIVER_PRESENT_ATTR_ID(52), TRANSCEIVER_PRESENT_ATTR_ID(53), TRANSCEIVER_PRESENT_ATTR_ID(54), + TRANSCEIVER_RESET_ATTR_ID(53), + TRANSCEIVER_RESET_ATTR_ID(54), + TRANSCEIVER_LPMODE_ATTR_ID(53), + TRANSCEIVER_LPMODE_ATTR_ID(54), TRANSCEIVER_TXDISABLE_ATTR_ID(49), TRANSCEIVER_TXDISABLE_ATTR_ID(50), TRANSCEIVER_TXDISABLE_ATTR_ID(51), @@ -148,6 +155,8 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); +static ssize_t set_qsfp(struct device *dev, struct device_attribute *da, + const char *buf, size_t count); static ssize_t access(struct device *dev, struct device_attribute *da, const char *buf, size_t count); static ssize_t show_version(struct device *dev, struct device_attribute *da, @@ -160,11 +169,6 @@ static struct as4630_54te_cpld_data *as4630_54te_fan_update_device(struct device static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, char *buf); -//static ssize_t show_power(struct device *dev, struct device_attribute *da, - // char *buf); - - /* transceiver attributes */ #define DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ @@ -180,9 +184,13 @@ static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, cha &sensor_dev_attr_module_tx_fault_##index.dev_attr.attr #define DECLARE_QSFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(index) \ + static SENSOR_DEVICE_ATTR(module_lpmode_##index, S_IRUGO | S_IWUSR, show_status, set_qsfp, MODULE_LPMODE_##index); \ + static SENSOR_DEVICE_ATTR(module_reset_##index, S_IRUGO | S_IWUSR, show_status, set_qsfp, MODULE_RESET_##index); \ static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index); #define DECLARE_QSFP_TRANSCEIVER_ATTR(index) \ + &sensor_dev_attr_module_lpmode_##index.dev_attr.attr, \ + &sensor_dev_attr_module_reset_##index.dev_attr.attr, \ &sensor_dev_attr_module_present_##index.dev_attr.attr @@ -204,10 +212,7 @@ static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, cha static SENSOR_DEVICE_ATTR(fan_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN_DUTY_CYCLE_PERCENTAGE); #define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan_duty_cycle_percentage.dev_attr.attr -#define DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR() \ - static SENSOR_DEVICE_ATTR(sys_temp, S_IRUGO, get_sys_temp, NULL, FAN_DUTY_CYCLE_PERCENTAGE) -#define DECLARE_FAN_SYSTEM_TEMP_ATTR() &sensor_dev_attr_sys_temp.dev_attr.attr static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, NULL, CPLD_VERSION); static SENSOR_DEVICE_ATTR(access, S_IWUSR, NULL, access, ACCESS); @@ -273,7 +278,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, break; case MODULE_TXDISABLE_49 ... MODULE_TXDISABLE_50: reg=0x5; - mask=0x1 << (attr->index==MODULE_TXFAULT_49?7:3); + mask=0x1 << (attr->index==MODULE_TXDISABLE_49?7:3); break; case MODULE_RXLOS_51 ... MODULE_RXLOS_52: @@ -290,12 +295,22 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, break; case MODULE_TXDISABLE_51 ... MODULE_TXDISABLE_52: reg=0x6; - mask=0x1 << (attr->index==MODULE_TXFAULT_51?7:3); + mask=0x1 << (attr->index==MODULE_TXDISABLE_51?7:3); break; case MODULE_PRESENT_53 ... MODULE_PRESENT_54: reg=0x21; mask=0x1 << (attr->index==MODULE_PRESENT_53?0:4); break; + case MODULE_RESET_53 ... MODULE_RESET_54: + reg=0x21; + mask=0x1 << (attr->index==MODULE_RESET_53?3:7); + revert = 1; + break; + case MODULE_LPMODE_53 ... MODULE_LPMODE_54: + reg = 0x21; + mask = 0x1 << (attr->index==MODULE_LPMODE_53?2:6); + revert = 0; + break; default: return 0; } @@ -319,6 +334,61 @@ static ssize_t show_status(struct device *dev, struct device_attribute *da, return status; } +static ssize_t set_qsfp(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct i2c_client *client = to_i2c_client(dev); + struct as4630_54te_cpld_data *data = i2c_get_clientdata(client); + long disable; + int status; + u8 reg = 0, mask = 0, revert = 0; + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + reg = 0x21; + switch (attr->index) + { + case MODULE_RESET_53 ... MODULE_RESET_54: + mask=0x1 << (attr->index==MODULE_RESET_53?3:7); + revert = 1; + break; + case MODULE_LPMODE_53 ... MODULE_LPMODE_54: + mask=0x1 << (attr->index==MODULE_LPMODE_53?2:6); + revert = 0; + break; + default: + return 0; + } + + disable = revert ? disable : !disable; + /* Read current status */ + mutex_lock(&data->update_lock); + status = as4630_54te_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + if (disable) { + status &= ~mask; + } + else { + status |= mask; + } + status = as4630_54te_cpld_write_internal(client, reg, status); + if (unlikely(status < 0)) { + goto exit; + } + + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, const char *buf, size_t count) { @@ -338,7 +408,7 @@ static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, { case MODULE_TXDISABLE_49 ... MODULE_TXDISABLE_50: reg=0x5; - mask=0x1 << (attr->index==MODULE_TXFAULT_49?7:3); + mask=0x1 << (attr->index==MODULE_TXDISABLE_49?7:3); break; case MODULE_TXDISABLE_51 ... MODULE_TXDISABLE_52: reg=0x6; @@ -357,10 +427,10 @@ static ssize_t set_tx_disable(struct device *dev, struct device_attribute *da, } /* Update tx_disable status */ if (disable) { - status &= ~mask; + status |= mask; } else { - status |= mask; + status &= ~mask; } status = as4630_54te_cpld_write_internal(client, reg, status); if (unlikely(status < 0)) { @@ -498,7 +568,7 @@ static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, static u8 reg_val_to_direction(u8 reg_val, enum fan_id id) { - u8 mask = (1 << id); + u8 mask = (1 << id+4); reg_val &= mask; @@ -531,268 +601,6 @@ static u8 is_fan_fault(struct as4630_54te_cpld_data *data, enum fan_id id) return ret; } -/* Due to this struct is declared at lm75.c, it cannot be include - * under Sonic environment. I duplicate it from lm75.c. - */ -struct lm75_data { - struct i2c_client *client; - struct device *hwmon_dev; - struct thermal_zone_device *tz; - struct mutex update_lock; - u8 orig_conf; - u8 resolution; /* In bits, between 9 and 12 */ - u8 resolution_limits; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - unsigned long sample_time; /* In jiffies */ - s16 temp[3]; /* Register values, - 0 = input - 1 = max - 2 = hyst */ -}; - -/*Copied from lm75.c*/ -static inline long lm75_reg_to_mc(s16 temp, u8 resolution) -{ - return ((temp >> (16 - resolution)) * 1000) >> (resolution - 8); -} - -/*Get hwmon_dev from i2c_client, set hwmon_dev = NULL is failed.*/ -static struct device * get_hwmon_dev( - struct i2c_client *client) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - if(data) - { - if( data->valid == 1 && data->hwmon_dev) - { - return data->hwmon_dev; - } - - } - return NULL; -} - -/* To find hwmon index by opening hwmon under that i2c address. - */ -static int find_hwmon_index_by_FileOpen( - int bus_nr, - unsigned short addr, - int *index) -{ -#define MAX_HWMON_DEVICE (10) /* Find hwmon device in 0~10*/ - struct file *sfd; - char client_name[96]; - int i=0; - - do { - snprintf(client_name, sizeof(client_name), - "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", - bus_nr, addr, i); - - sfd = filp_open(client_name, O_RDONLY, 0); - i++; - } while( IS_ERR(sfd) && i < MAX_HWMON_DEVICE); - - if (IS_ERR(sfd)) { - pr_err("Failed to open file(%s)#%d\r\n", client_name, __LINE__); - return -ENOENT; - } - filp_close(sfd, 0); - *index = i - 1; - return 0; - -#undef MAX_HWMON_DEVICE -} - -static int get_temp_file_path( - int bus_nr, unsigned short addr, - struct device *hwmon_dev - ,char *path, int max_len) -{ - - if(hwmon_dev && strlen(dev_name(hwmon_dev))) - { - snprintf(path, max_len, - "/sys/bus/i2c/devices/%d-%04x/hwmon/%s/temp1_input", - bus_nr, addr, dev_name(hwmon_dev)); - } - else - { - int i=0; - if(find_hwmon_index_by_FileOpen( bus_nr, addr, &i)) - { - return -EIO; - } - snprintf(path, max_len, - "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", - bus_nr, addr, i); - } - - return 0; -} - -/*File read the dev file at user space.*/ -static int read_devfile_temp1_input( - struct device *dev, - int bus_nr, - unsigned short addr, - struct device *hwmon_dev, - int *miniCelsius) -{ - struct file *sfd; - char buffer[96]; - char devfile[96]; - int rc, status; - int rdlen, value; - mm_segment_t old_fs; - - rc = 0; - get_temp_file_path(bus_nr, addr, hwmon_dev, devfile, sizeof(devfile)); - sfd = filp_open(devfile, O_RDONLY, 0); - if (IS_ERR(sfd)) { - pr_err("Failed to open file(%s)#%d\r\n", devfile, __LINE__); - return -ENOENT; - } - dev_dbg(dev, "Found device:%s\n",devfile); - - if(!(sfd->f_op) || !(sfd->f_op->read) ) { - pr_err("file %s cann't readable ?\n",devfile); - return -ENOENT; - } - - old_fs = get_fs(); - set_fs(KERNEL_DS); - rdlen = sfd->f_op->read(sfd, buffer, sizeof(buffer), &sfd->f_pos); - if (rdlen == 0) { - pr_err( "File(%s) empty!\n", devfile); - rc = -EIO; - goto exit; - } - status = sscanf(buffer, "%d", &value); - if (status != 1) { - rc = -EIO; - goto exit; - } - *miniCelsius = value; - dev_dbg(dev,"found sensors: %d @i2c %d-%04x\n", value, bus_nr, addr); - -exit: - set_fs(old_fs); - filp_close(sfd, 0); - return rc; -} - -static u8 is_lm75_data_due(struct i2c_client *client) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - if (time_after(jiffies, data->last_updated + data->sample_time)) - { - return 1; - } - return 0; -} -static int get_lm75_temp(struct i2c_client *client, int *miniCelsius) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - *miniCelsius = lm75_reg_to_mc(data->temp[0], data->resolution); - - return 0; -} - -static bool lm75_addr_mached(unsigned short addr) -{ - int i; - unsigned short addrs[] = THERMAL_SENSORS_ADDRS; - - for (i = 0; i < ARRAY_SIZE(addrs); i++) - { - if( addr == addrs[i]) - return 1; - } - return 0; -} - -static int _find_lm75_device(struct device *dev, void *data) -{ - struct device_driver *driver; - struct as4630_54te_cpld_data *prv = data; - char *driver_name = THERMAL_SENSORS_DRIVER; - - driver = dev->driver; - if (driver && driver->name && - strcmp(driver->name, driver_name) == 0) - { - struct i2c_client *client; - client = to_i2c_client(dev); - if (client) - { - /*cannot use "struct i2c_adapter *adap = to_i2c_adapter(dev);"*/ - struct i2c_adapter *adap = client->adapter; - int miniCelsius = 0; - - if (! lm75_addr_mached(client->addr)) - { - return 0; - } - - if (!adap) { - return -ENXIO; - } - - /* If the data is not updated, read them from devfile - to drive them updateing data from chip.*/ - if (is_lm75_data_due(client)) - { - struct device *hwmon_dev; - - hwmon_dev = get_hwmon_dev(client); - if(0 == read_devfile_temp1_input(dev, adap->nr, - client->addr, hwmon_dev, &miniCelsius)) - { - prv->system_temp += miniCelsius; - prv->sensors_found++; - } - - } - else - { - get_lm75_temp(client, &miniCelsius); - prv->system_temp += miniCelsius; - prv->sensors_found++; - - } - } - } - return 0; -} - -/*Find all lm75 devices and return sum of temperatures.*/ -static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, - char *buf) -{ - ssize_t ret = 0; - struct as4630_54te_cpld_data *data = as4630_54te_fan_update_device(dev); - - data->system_temp=0; - data->sensors_found=0; - i2c_for_each_dev(data, _find_lm75_device); - if (NUM_THERMAL_SENSORS != data->sensors_found) - { - dev_dbg(dev,"only %d of %d temps are found\n", - data->sensors_found, NUM_THERMAL_SENSORS); - data->system_temp = INT_MAX; - } - ret = sprintf(buf, "%d\n",data->system_temp); - return ret; -} - static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf) { diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_util.py b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_util.py index 21e8ecb30c95..7e325ed429c0 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_util.py @@ -274,7 +274,7 @@ def driver_inserted(): kos = [ 'depmod -ae', 'modprobe i2c_dev', - 'modprobe i2c_mux_pca954x force_deselect_on_exit=1', + 'modprobe i2c_mux_pca954x', 'modprobe ym2651y', 'modprobe x86_64_accton_as4630_54te_cpld', 'modprobe x86_64_accton_as4630_54te_leds', @@ -330,6 +330,15 @@ def device_install(): print(output) if FORCE == 0: return status + + # set all pca954x idle_disconnect + cmd = 'echo -2 | tee /sys/bus/i2c/drivers/pca954x/*-00*/idle_state' + status, output = log_os_system(cmd, 1) + if status: + print(output) + if FORCE == 0: + return status + print("Check SFP") for i in range(0, len(sfp_map)): if(i < 4): diff --git a/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_as7312_54x_fan.c b/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_as7312_54x_fan.c index 8764ec8a3176..9e7be492b734 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_as7312_54x_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7312-54x/modules/accton_as7312_54x_fan.c @@ -48,7 +48,7 @@ static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, static ssize_t get_enable(struct device *dev, struct device_attribute *da, char *buf); static ssize_t set_enable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, char *buf); + extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); @@ -150,11 +150,6 @@ enum sysfs_fan_attributes { &sensor_dev_attr_pwm##index.dev_attr.attr, \ &sensor_dev_attr_pwm##index##_enable.dev_attr.attr -#define DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR() \ - static SENSOR_DEVICE_ATTR(sys_temp, S_IRUGO, get_sys_temp, NULL, FAN_DUTY_CYCLE_PERCENTAGE) - -#define DECLARE_FAN_SYSTEM_TEMP_ATTR() &sensor_dev_attr_sys_temp.dev_attr.attr - #define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(index) \ static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT) @@ -200,8 +195,6 @@ DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(5); DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(6); /* 1 fan duty cycle attribute in this platform */ DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(1); -/* System temperature for fancontrol */ -DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR(); static struct attribute *as7312_54x_fan_attributes[] = { /* fan related attributes */ @@ -230,7 +223,6 @@ static struct attribute *as7312_54x_fan_attributes[] = { DECLARE_FAN_DIRECTION_ATTR(5), DECLARE_FAN_DIRECTION_ATTR(6), DECLARE_FAN_DUTY_CYCLE_ATTR(1), - DECLARE_FAN_SYSTEM_TEMP_ATTR(), NULL }; @@ -348,267 +340,6 @@ static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, return count; } -/* Due to this struct is declared at lm75.c, it cannot be include - * under Sonic environment. I duplicate it from lm75.c. - */ -struct lm75_data { - struct i2c_client *client; - struct device *hwmon_dev; - struct thermal_zone_device *tz; - struct mutex update_lock; - u8 orig_conf; - u8 resolution; /* In bits, between 9 and 12 */ - u8 resolution_limits; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - unsigned long sample_time; /* In jiffies */ - s16 temp[3]; /* Register values, - 0 = input - 1 = max - 2 = hyst */ -}; - -/*Copied from lm75.c*/ -static inline long lm75_reg_to_mc(s16 temp, u8 resolution) -{ - return ((temp >> (16 - resolution)) * 1000) >> (resolution - 8); -} - -/*Get hwmon_dev from i2c_client, set hwmon_dev = NULL is failed.*/ -static struct device * get_hwmon_dev( - struct i2c_client *client) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - if(data) - { - if( data->valid == 1 && data->hwmon_dev) - { - return data->hwmon_dev; - } - - } - return NULL; -} - -/* To find hwmon index by opening hwmon under that i2c address. - */ -static int find_hwmon_index_by_FileOpen( - int bus_nr, - unsigned short addr, - OUT int *index) -{ -#define MAX_HWMON_DEVICE (10) /* Find hwmon device in 0~10*/ - struct file *sfd; - char client_name[96]; - int i=0; - - do { - snprintf(client_name, sizeof(client_name), - "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", - bus_nr, addr, i); - - sfd = filp_open(client_name, O_RDONLY, 0); - i++; - } while( IS_ERR(sfd) && i < MAX_HWMON_DEVICE); - - if (IS_ERR(sfd)) { - pr_err("Failed to open file(%s)#%d\r\n", client_name, __LINE__); - return -ENOENT; - } - filp_close(sfd, 0); - *index = i - 1; - return 0; - -#undef MAX_HWMON_DEVICE -} - -static int get_temp_file_path( - int bus_nr, unsigned short addr, - struct device *hwmon_dev - ,char *path, int max_len) -{ - - if(hwmon_dev && strlen(dev_name(hwmon_dev))) - { - snprintf(path, max_len, - "/sys/bus/i2c/devices/%d-%04x/hwmon/%s/temp1_input", - bus_nr, addr, dev_name(hwmon_dev)); - } - else - { - int i=0; - if(find_hwmon_index_by_FileOpen( bus_nr, addr, &i)) - { - return -EIO; - } - snprintf(path, max_len, - "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", - bus_nr, addr, i); - } - return 0; -} - -/*File read the dev file at user space.*/ -static int read_devfile_temp1_input( - struct device *dev, - int bus_nr, - unsigned short addr, - struct device *hwmon_dev, - int *miniCelsius) -{ - struct file *sfd; - char buffer[96]; - char devfile[96]; - int rc, status; - int rdlen, value; - mm_segment_t old_fs; - - rc = 0; - get_temp_file_path(bus_nr, addr, hwmon_dev, devfile, sizeof(devfile)); - sfd = filp_open(devfile, O_RDONLY, 0); - if (IS_ERR(sfd)) { - pr_err("Failed to open file(%s)#%d\r\n", devfile, __LINE__); - return -ENOENT; - } - dev_dbg(dev, "Found device:%s\n",devfile); - - if(!(sfd->f_op) || !(sfd->f_op->read) ) { - pr_err("file %s cann't readable ?\n",devfile); - return -ENOENT; - } - - old_fs = get_fs(); - set_fs(KERNEL_DS); - rdlen = sfd->f_op->read(sfd, buffer, sizeof(buffer), &sfd->f_pos); - if (rdlen == 0) { - pr_err( "File(%s) empty!\n", devfile); - rc = -EIO; - goto exit; - } - status = sscanf(buffer, "%d", &value); - if (status != 1) { - rc = -EIO; - goto exit; - } - *miniCelsius = value; - dev_dbg(dev,"found sensors: %d @i2c %d-%04x\n", value, bus_nr, addr); - -exit: - set_fs(old_fs); - filp_close(sfd, 0); - return rc; -} - -static u8 is_lm75_data_due(struct i2c_client *client) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - if (time_after(jiffies, data->last_updated + data->sample_time)) - { - return 1; - } - return 0; -} -static int get_lm75_temp(struct i2c_client *client, int *miniCelsius) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - *miniCelsius = lm75_reg_to_mc(data->temp[0], data->resolution); - - return 0; -} - -static bool lm75_addr_mached(unsigned short addr) -{ - int i; - unsigned short addrs[] = THERMAL_SENSORS_ADDRS; - - for (i = 0; i < ARRAY_SIZE(addrs); i++) - { - if( addr == addrs[i]) - return 1; - } - return 0; -} - -static int _find_lm75_device(struct device *dev, void *data) -{ - struct device_driver *driver; - struct as7312_54x_fan_data *prv = data; - char *driver_name = THERMAL_SENSORS_DRIVER; - - driver = dev->driver; - if (driver && driver->name && - strcmp(driver->name, driver_name) == 0) - { - struct i2c_client *client; - client = to_i2c_client(dev); - if (client) - { - /*cannot use "struct i2c_adapter *adap = to_i2c_adapter(dev);"*/ - struct i2c_adapter *adap = client->adapter; - int miniCelsius = 0; - - if (! lm75_addr_mached(client->addr)) - { - return 0; - } - - if (!adap) { - return -ENXIO; - } - - /* If the data is not updated, read them from devfile - to drive them updateing data from chip.*/ - if (is_lm75_data_due(client)) - { - struct device *hwmon_dev; - - hwmon_dev = get_hwmon_dev(client); - if(0 == read_devfile_temp1_input(dev, adap->nr, - client->addr, hwmon_dev, &miniCelsius)) - { - prv->system_temp += miniCelsius; - prv->sensors_found++; - } - - } - else - { - get_lm75_temp(client, &miniCelsius); - prv->system_temp += miniCelsius; - prv->sensors_found++; - - } - } - } - return 0; -} - -/*Find all lm75 devices and return sum of temperatures.*/ -static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, - char *buf) -{ - ssize_t ret = 0; - struct as7312_54x_fan_data *data = as7312_54x_fan_update_device(dev); - - data->system_temp=0; - data->sensors_found=0; - i2c_for_each_dev(data, _find_lm75_device); - if (NUM_THERMAL_SENSORS != data->sensors_found) - { - dev_dbg(dev,"only %d of %d temps are found\n", - data->sensors_found, NUM_THERMAL_SENSORS); - data->system_temp = INT_MAX; - } - ret = sprintf(buf, "%d\n",data->system_temp); - return ret; -} - static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf) { diff --git a/platform/broadcom/sonic-platform-modules-accton/as7312-54x/utils/accton_as7312_util.py b/platform/broadcom/sonic-platform-modules-accton/as7312-54x/utils/accton_as7312_util.py index b79a1c1088dc..4897945368ab 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7312-54x/utils/accton_as7312_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7312-54x/utils/accton_as7312_util.py @@ -164,7 +164,7 @@ def driver_check(): kos = [ 'modprobe i2c_dev', - 'modprobe i2c_mux_pca954x force_deselect_on_exit=1', + 'modprobe i2c_mux_pca954x', 'modprobe accton_i2c_cpld', 'modprobe ym2651y', 'modprobe accton_as7312_54x_fan', @@ -308,6 +308,15 @@ def device_install(): print(output) if FORCE == 0: return status + + # set all pca954x idle_disconnect + cmd = 'echo -2 | tee /sys/bus/i2c/drivers/pca954x/*-00*/idle_state' + status, output = log_os_system(cmd, 1) + if status: + print(output) + if FORCE == 0: + return status + for i in range(0, len(sfp_map)): if i < qsfp_start: (status, output) = \ diff --git a/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_as7312_54x_fan.c b/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_as7312_54x_fan.c index 8764ec8a3176..1a32c57f28e9 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_as7312_54x_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/modules/accton_as7312_54x_fan.c @@ -35,7 +35,6 @@ #define DRVNAME "as7312_54x_fan" #define NUM_THERMAL_SENSORS (3) /* Get sum of this number of sensors.*/ -#define THERMAL_SENSORS_DRIVER "lm75" #define THERMAL_SENSORS_ADDRS {0x48, 0x49, 0x4a} #define IN @@ -48,7 +47,6 @@ static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, static ssize_t get_enable(struct device *dev, struct device_attribute *da, char *buf); static ssize_t set_enable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, char *buf); extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); @@ -150,11 +148,6 @@ enum sysfs_fan_attributes { &sensor_dev_attr_pwm##index.dev_attr.attr, \ &sensor_dev_attr_pwm##index##_enable.dev_attr.attr -#define DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR() \ - static SENSOR_DEVICE_ATTR(sys_temp, S_IRUGO, get_sys_temp, NULL, FAN_DUTY_CYCLE_PERCENTAGE) - -#define DECLARE_FAN_SYSTEM_TEMP_ATTR() &sensor_dev_attr_sys_temp.dev_attr.attr - #define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(index) \ static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT) @@ -200,8 +193,6 @@ DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(5); DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(6); /* 1 fan duty cycle attribute in this platform */ DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(1); -/* System temperature for fancontrol */ -DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR(); static struct attribute *as7312_54x_fan_attributes[] = { /* fan related attributes */ @@ -230,7 +221,6 @@ static struct attribute *as7312_54x_fan_attributes[] = { DECLARE_FAN_DIRECTION_ATTR(5), DECLARE_FAN_DIRECTION_ATTR(6), DECLARE_FAN_DUTY_CYCLE_ATTR(1), - DECLARE_FAN_SYSTEM_TEMP_ATTR(), NULL }; @@ -348,267 +338,6 @@ static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, return count; } -/* Due to this struct is declared at lm75.c, it cannot be include - * under Sonic environment. I duplicate it from lm75.c. - */ -struct lm75_data { - struct i2c_client *client; - struct device *hwmon_dev; - struct thermal_zone_device *tz; - struct mutex update_lock; - u8 orig_conf; - u8 resolution; /* In bits, between 9 and 12 */ - u8 resolution_limits; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - unsigned long sample_time; /* In jiffies */ - s16 temp[3]; /* Register values, - 0 = input - 1 = max - 2 = hyst */ -}; - -/*Copied from lm75.c*/ -static inline long lm75_reg_to_mc(s16 temp, u8 resolution) -{ - return ((temp >> (16 - resolution)) * 1000) >> (resolution - 8); -} - -/*Get hwmon_dev from i2c_client, set hwmon_dev = NULL is failed.*/ -static struct device * get_hwmon_dev( - struct i2c_client *client) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - if(data) - { - if( data->valid == 1 && data->hwmon_dev) - { - return data->hwmon_dev; - } - - } - return NULL; -} - -/* To find hwmon index by opening hwmon under that i2c address. - */ -static int find_hwmon_index_by_FileOpen( - int bus_nr, - unsigned short addr, - OUT int *index) -{ -#define MAX_HWMON_DEVICE (10) /* Find hwmon device in 0~10*/ - struct file *sfd; - char client_name[96]; - int i=0; - - do { - snprintf(client_name, sizeof(client_name), - "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", - bus_nr, addr, i); - - sfd = filp_open(client_name, O_RDONLY, 0); - i++; - } while( IS_ERR(sfd) && i < MAX_HWMON_DEVICE); - - if (IS_ERR(sfd)) { - pr_err("Failed to open file(%s)#%d\r\n", client_name, __LINE__); - return -ENOENT; - } - filp_close(sfd, 0); - *index = i - 1; - return 0; - -#undef MAX_HWMON_DEVICE -} - -static int get_temp_file_path( - int bus_nr, unsigned short addr, - struct device *hwmon_dev - ,char *path, int max_len) -{ - - if(hwmon_dev && strlen(dev_name(hwmon_dev))) - { - snprintf(path, max_len, - "/sys/bus/i2c/devices/%d-%04x/hwmon/%s/temp1_input", - bus_nr, addr, dev_name(hwmon_dev)); - } - else - { - int i=0; - if(find_hwmon_index_by_FileOpen( bus_nr, addr, &i)) - { - return -EIO; - } - snprintf(path, max_len, - "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", - bus_nr, addr, i); - } - return 0; -} - -/*File read the dev file at user space.*/ -static int read_devfile_temp1_input( - struct device *dev, - int bus_nr, - unsigned short addr, - struct device *hwmon_dev, - int *miniCelsius) -{ - struct file *sfd; - char buffer[96]; - char devfile[96]; - int rc, status; - int rdlen, value; - mm_segment_t old_fs; - - rc = 0; - get_temp_file_path(bus_nr, addr, hwmon_dev, devfile, sizeof(devfile)); - sfd = filp_open(devfile, O_RDONLY, 0); - if (IS_ERR(sfd)) { - pr_err("Failed to open file(%s)#%d\r\n", devfile, __LINE__); - return -ENOENT; - } - dev_dbg(dev, "Found device:%s\n",devfile); - - if(!(sfd->f_op) || !(sfd->f_op->read) ) { - pr_err("file %s cann't readable ?\n",devfile); - return -ENOENT; - } - - old_fs = get_fs(); - set_fs(KERNEL_DS); - rdlen = sfd->f_op->read(sfd, buffer, sizeof(buffer), &sfd->f_pos); - if (rdlen == 0) { - pr_err( "File(%s) empty!\n", devfile); - rc = -EIO; - goto exit; - } - status = sscanf(buffer, "%d", &value); - if (status != 1) { - rc = -EIO; - goto exit; - } - *miniCelsius = value; - dev_dbg(dev,"found sensors: %d @i2c %d-%04x\n", value, bus_nr, addr); - -exit: - set_fs(old_fs); - filp_close(sfd, 0); - return rc; -} - -static u8 is_lm75_data_due(struct i2c_client *client) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - if (time_after(jiffies, data->last_updated + data->sample_time)) - { - return 1; - } - return 0; -} -static int get_lm75_temp(struct i2c_client *client, int *miniCelsius) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - *miniCelsius = lm75_reg_to_mc(data->temp[0], data->resolution); - - return 0; -} - -static bool lm75_addr_mached(unsigned short addr) -{ - int i; - unsigned short addrs[] = THERMAL_SENSORS_ADDRS; - - for (i = 0; i < ARRAY_SIZE(addrs); i++) - { - if( addr == addrs[i]) - return 1; - } - return 0; -} - -static int _find_lm75_device(struct device *dev, void *data) -{ - struct device_driver *driver; - struct as7312_54x_fan_data *prv = data; - char *driver_name = THERMAL_SENSORS_DRIVER; - - driver = dev->driver; - if (driver && driver->name && - strcmp(driver->name, driver_name) == 0) - { - struct i2c_client *client; - client = to_i2c_client(dev); - if (client) - { - /*cannot use "struct i2c_adapter *adap = to_i2c_adapter(dev);"*/ - struct i2c_adapter *adap = client->adapter; - int miniCelsius = 0; - - if (! lm75_addr_mached(client->addr)) - { - return 0; - } - - if (!adap) { - return -ENXIO; - } - - /* If the data is not updated, read them from devfile - to drive them updateing data from chip.*/ - if (is_lm75_data_due(client)) - { - struct device *hwmon_dev; - - hwmon_dev = get_hwmon_dev(client); - if(0 == read_devfile_temp1_input(dev, adap->nr, - client->addr, hwmon_dev, &miniCelsius)) - { - prv->system_temp += miniCelsius; - prv->sensors_found++; - } - - } - else - { - get_lm75_temp(client, &miniCelsius); - prv->system_temp += miniCelsius; - prv->sensors_found++; - - } - } - } - return 0; -} - -/*Find all lm75 devices and return sum of temperatures.*/ -static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, - char *buf) -{ - ssize_t ret = 0; - struct as7312_54x_fan_data *data = as7312_54x_fan_update_device(dev); - - data->system_temp=0; - data->sensors_found=0; - i2c_for_each_dev(data, _find_lm75_device); - if (NUM_THERMAL_SENSORS != data->sensors_found) - { - dev_dbg(dev,"only %d of %d temps are found\n", - data->sensors_found, NUM_THERMAL_SENSORS); - data->system_temp = INT_MAX; - } - ret = sprintf(buf, "%d\n",data->system_temp); - return ret; -} - static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf) { diff --git a/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/classes/fanutil.py b/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/classes/fanutil.py index 6254e1a0b2aa..31697f7c644e 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/classes/fanutil.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/classes/fanutil.py @@ -27,6 +27,7 @@ import time import logging from collections import namedtuple + import subprocess except ImportError as e: raise ImportError('%s - required module not found' % str(e)) @@ -44,8 +45,11 @@ class FanUtil(object): #FAN_NODE_DUTY_IDX_OF_MAP = 4 #FANR_NODE_FAULT_IDX_OF_MAP = 5 - BASE_VAL_PATH = '/sys/bus/i2c/devices/50-0066/{0}' - FAN_DUTY_PATH = '/sys/bus/i2c/devices/50-0066/fan{0}_pwm' + I2CADDR_CANDIDATES = ((9, 66), # for R0C HW and later + (50, 66)) # for R0A, R0B HW + PATH_PREFIX = '/sys/bus/i2c/devices/{}-00{}/' + BASE_VAL_PATH = '{0}' + FAN_DUTY_PATH = 'fan{0}_pwm' #logfile = '' #loglevel = self.logger.INFO @@ -59,6 +63,21 @@ class FanUtil(object): node_postfix = ["fault", "direction"] def _get_fan_to_device_node(self, fan_num, node_num): return "fan{0}_{1}".format(fan_num, self.node_postfix[node_num-1]) + + def _get_fan_i2c_bus_addr(self): + cmd_template = 'i2cget -f -y {} 0x{} 0' + for bus_no, dev_addr in self.I2CADDR_CANDIDATES: + cmd = cmd_template.format(bus_no, dev_addr) + if subprocess.getstatusoutput(cmd)[0] == 0: + return bus_no, dev_addr + raise IOError('Unable to reach fan CPLD via I2C') + + def _init_fnode_basepath(self): + '''format BASE_VAL_PATH and FAN_DUTY_PATH ''' + bus, addr = self._get_fan_i2c_bus_addr() + self.PATH_PREFIX = self.PATH_PREFIX.format(bus, addr) + self.BASE_VAL_PATH = self.PATH_PREFIX + self.BASE_VAL_PATH + self.FAN_DUTY_PATH = self.PATH_PREFIX + self.FAN_DUTY_PATH def _get_fan_node_val(self, fan_num, node_num): if fan_num < self.FAN_NUM_1_IDX or fan_num > self.FAN_TOTAL_NUM: @@ -84,7 +103,7 @@ def _get_fan_node_val(self, fan_num, node_num): return None try: - val_file.close() + val_file.close() except: self.logger.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -115,7 +134,7 @@ def _set_fan_node_val(self, fan_num, node_num, val): val_file.write(content) try: - val_file.close() + val_file.close() except: self.logger.debug('GET. unable to close file. device_path:%s', device_path) return None @@ -128,6 +147,7 @@ def __init__(self, log_level=logging.DEBUG): ch.setLevel(log_level) self.logger.addHandler(ch) + self._init_fnode_basepath() fan_path = self.BASE_VAL_PATH for fan_num in range(self.FAN_NUM_1_IDX, self.FAN_TOTAL_NUM+1): for node_num in range(1, self.FAN_NODE_NUM+1): diff --git a/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/Makefile b/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/Makefile index a1bf8335378c..9ef6485f5677 100644 --- a/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/Makefile +++ b/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/Makefile @@ -1,2 +1,2 @@ obj-m:= accton_as7315_27xb_fan.o x86-64-accton-as7315-27xb-cpld.o x86-64-accton-as7315-27xb-psu.o \ - at24_as7315_27xb.o x86-64-accton-as7315-27xb-led.o ym2651y.o + x86-64-accton-as7315-27xb-led.o ym2651y.o diff --git a/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/at24_as7315_27xb.c b/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/at24_as7315_27xb.c deleted file mode 100755 index 8d8c7601a71d..000000000000 --- a/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/modules/at24_as7315_27xb.c +++ /dev/null @@ -1,695 +0,0 @@ -/* - * at24_as7315_27xb.c - handle most I2C EEPROMs for ethernet switch, as7315_27xb. - * - * Copyright (C) 2005-2007 David Brownell - * Copyright (C) 2008 Wolfram Sang, Pengutronix - * Copyright (C) 2019 Roy Lee, EdgeCore network. - * Revised to support specially I2C transactions, pure READ and WRITE. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -/* - * I2C EEPROMs from most vendors are inexpensive and mostly interchangeable. - * Differences between different vendor product lines (like Atmel AT24C or - * MicroChip 24LC, etc) won't much matter for typical read/write access. - * There are also I2C RAM chips, likewise interchangeable. One example - * would be the PCF8570, which acts like a 24c02 EEPROM (256 bytes). - * - * However, misconfiguration can lose data. "Set 16-bit memory address" - * to a part with 8-bit addressing will overwrite data. Writing with too - * big a page size also loses data. And it's not safe to assume that the - * conventional addresses 0x50..0x57 only hold eeproms; a PCF8563 RTC - * uses 0x51, for just one example. - * - * Accordingly, explicit board-specific configuration data should be used - * in almost all cases. (One partial exception is an SMBus used to access - * "SPD" data for DRAM sticks. Those only use 24c02 EEPROMs.) - * - * So this driver uses "new style" I2C driver binding, expecting to be - * told what devices exist. That may be in arch/X/mach-Y/board-Z.c or - * similar kernel-resident tables; or, configuration data coming from - * a bootloader. - * - * Other than binding model, current differences from "eeprom" driver are - * that this one handles write access and isn't restricted to 24c02 devices. - * It also handles larger devices (32 kbit and up) with two-byte addresses, - * which won't work on pure SMBus systems. - */ - -struct at24_data { - struct at24_platform_data chip; - int use_smbus; - int use_smbus_write; - - ssize_t (*read_func)(struct at24_data *, char *, unsigned int, size_t); - ssize_t (*write_func)(struct at24_data *, - const char *, unsigned int, size_t); - - /* - * Lock protects against activities from other Linux tasks, - * but not from changes by other I2C masters. - */ - struct mutex lock; - - u8 *writebuf; - unsigned write_max; - unsigned num_addresses; - - struct nvmem_config nvmem_config; - struct nvmem_device *nvmem; - - /* - * Some chips tie up multiple I2C addresses; dummy devices reserve - * them for us, and we'll use them with SMBus calls. - */ - struct i2c_client *client[]; -}; - -/* - * This parameter is to help this driver avoid blocking other drivers out - * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C - * clock, one 256 byte read takes about 1/43 second which is excessive; - * but the 1/170 second it takes at 400 kHz may be quite reasonable; and - * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible. - * - * This value is forced to be a power of two so that writes align on pages. - */ -static unsigned io_limit = 128; -module_param(io_limit, uint, 0); -MODULE_PARM_DESC(io_limit, "Maximum bytes per I/O (default 128)"); - -/* - * Specs often allow 5 msec for a page write, sometimes 20 msec; - * it's important to recover from write timeouts. - */ -static unsigned write_timeout = 25; -module_param(write_timeout, uint, 0); -MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)"); - -#define AT24_SIZE_BYTELEN 5 -#define AT24_SIZE_FLAGS 8 - -#define AT24_BITMASK(x) (BIT(x) - 1) - -/* create non-zero magic value for given eeprom parameters */ -#define AT24_DEVICE_MAGIC(_len, _flags) \ - ((1 << AT24_SIZE_FLAGS | (_flags)) \ - << AT24_SIZE_BYTELEN | ilog2(_len)) - -/* - * Both reads and writes fail if the previous write didn't complete yet. This - * macro loops a few times waiting at least long enough for one entire page - * write to work while making sure that at least one iteration is run before - * checking the break condition. - * - * It takes two parameters: a variable in which the future timeout in jiffies - * will be stored and a temporary variable holding the time of the last - * iteration of processing the request. Both should be unsigned integers - * holding at least 32 bits. - */ -#define loop_until_timeout(tout, op_time) \ - for (tout = jiffies + msecs_to_jiffies(write_timeout), op_time = 0; \ - op_time ? time_before(op_time, tout) : true; \ - usleep_range(1000, 1500), op_time = jiffies) - -static const struct i2c_device_id at24_ids[] = { - { "24cxb04", AT24_DEVICE_MAGIC(4096 / 8, AT24_FLAG_ADDR16) }, - { "24cxb08", AT24_DEVICE_MAGIC(8192 / 8, AT24_FLAG_ADDR16) }, - { "24cxb16", AT24_DEVICE_MAGIC(16384 / 8, AT24_FLAG_ADDR16) }, - { "24cxb32", AT24_DEVICE_MAGIC(32768 / 8, AT24_FLAG_ADDR16) }, - { "24cxb64", AT24_DEVICE_MAGIC(65536 / 8, AT24_FLAG_ADDR16) }, - { "at24", 0 }, - { /* END OF LIST */ } -}; -MODULE_DEVICE_TABLE(i2c, at24_ids); - -static const struct acpi_device_id at24_acpi_ids[] = { - { "INT3499", AT24_DEVICE_MAGIC(8192 / 8, 0) }, - { } -}; -MODULE_DEVICE_TABLE(acpi, at24_acpi_ids); - -/*-------------------------------------------------------------------------*/ - -/* - * This routine supports chips which consume multiple I2C addresses. It - * computes the addressing information to be used for a given r/w request. - * Assumes that sanity checks for offset happened at sysfs-layer. - * - * Slave address and byte offset derive from the offset. Always - * set the byte address; on a multi-master board, another master - * may have changed the chip's "current" address pointer. - * - * REVISIT some multi-address chips don't rollover page reads to - * the next slave address, so we may need to truncate the count. - * Those chips might need another quirk flag. - * - * If the real hardware used four adjacent 24c02 chips and that - * were misconfigured as one 24c08, that would be a similar effect: - * one "eeprom" file not four, but larger reads would fail when - * they crossed certain pages. - */ -static struct i2c_client *at24_translate_offset(struct at24_data *at24, - unsigned int *offset) -{ - unsigned i; - - /*Always AT24_FLAG_ADDR16*/ - i = *offset >> 16; - *offset &= 0xffff; - - return at24->client[i]; -} - -static ssize_t at24_eeprom_read_smbus(struct at24_data *at24, char *buf, - unsigned int offset, size_t count) -{ - unsigned long timeout, read_time; - struct i2c_client *client; - int status; - client = at24_translate_offset(at24, &offset); - - if (count > io_limit) - count = io_limit; - - loop_until_timeout(timeout, read_time) { -/* - status = i2c_smbus_read_i2c_block_data_or_emulated(client, - offset, - count, buf); - - dev_dbg(&client->dev, "read %zu@%d --> %d (%ld)\n", - count, offset, status, jiffies); -*/ - int i=0; - - /*Write 2-byte offset*/ - unsigned char bb = offset&0xff; - status = i2c_smbus_write_i2c_block_data(client, offset>>8, 1, &bb); - if (status < 0) { - return status; - } - - while (i < count) { - status = i2c_smbus_read_byte(client); - if (status < 0) { - return status; - } - buf[i] = status; - i++; - } - - - if (i == count) - return count; - } - - return -ETIMEDOUT; -} - -/* - * Note that if the hardware write-protect pin is pulled high, the whole - * chip is normally write protected. But there are plenty of product - * variants here, including OTP fuses and partial chip protect. - * - * We only use page mode writes; the alternative is sloooow. These routines - * write at most one page. - */ - -static size_t at24_adjust_write_count(struct at24_data *at24, - unsigned int offset, size_t count) -{ - unsigned next_page; - - /* write_max is at most a page */ - if (count > at24->write_max) - count = at24->write_max; - - /* Never roll over backwards, to the start of this page */ - next_page = roundup(offset + 1, at24->chip.page_size); - if (offset + count > next_page) - count = next_page - offset; - - return count; -} - -static ssize_t at24_eeprom_write_smbus_block(struct at24_data *at24, - const char *buf, - unsigned int offset, size_t count) -{ - unsigned long timeout, write_time; - struct i2c_client *client; - ssize_t status = 0; - - client = at24_translate_offset(at24, &offset); - count = at24_adjust_write_count(at24, offset, count); - - loop_until_timeout(timeout, write_time) { - status = i2c_smbus_write_i2c_block_data(client, - offset, count, buf); - if (status == 0) - status = count; - - dev_dbg(&client->dev, "write %zu@%d --> %zd (%ld)\n", - count, offset, status, jiffies); - - if (status == count) - return count; - } - - return -ETIMEDOUT; -} - -static ssize_t at24_eeprom_write_smbus_byte(struct at24_data *at24, - const char *buf, - unsigned int offset, size_t count) -{ - unsigned long timeout, write_time; - struct i2c_client *client; - ssize_t status = 0; - - client = at24_translate_offset(at24, &offset); - - loop_until_timeout(timeout, write_time) { - status = i2c_smbus_write_byte_data(client, offset, buf[0]); - if (status == 0) - status = count; - - dev_dbg(&client->dev, "write %zu@%d --> %zd (%ld)\n", - count, offset, status, jiffies); - - if (status == count) - return count; - } - - return -ETIMEDOUT; -} - -static ssize_t at24_eeprom_write_i2c(struct at24_data *at24, const char *buf, - unsigned int offset, size_t count) -{ - unsigned long timeout, write_time; - struct i2c_client *client; - struct i2c_msg msg; - ssize_t status = 0; - int i = 0; - - client = at24_translate_offset(at24, &offset); - count = at24_adjust_write_count(at24, offset, count); - - msg.addr = client->addr; - msg.flags = 0; - - /* msg.buf is u8 and casts will mask the values */ - msg.buf = at24->writebuf; - if (at24->chip.flags & AT24_FLAG_ADDR16) - msg.buf[i++] = offset >> 8; - - msg.buf[i++] = offset; - memcpy(&msg.buf[i], buf, count); - msg.len = i + count; - - loop_until_timeout(timeout, write_time) { - status = i2c_transfer(client->adapter, &msg, 1); - if (status == 1) - status = count; - - dev_dbg(&client->dev, "write %zu@%d --> %zd (%ld)\n", - count, offset, status, jiffies); - - if (status == count) - return count; - } - - return -ETIMEDOUT; -} - -static int at24_read(void *priv, unsigned int off, void *val, size_t count) -{ - struct at24_data *at24 = priv; - char *buf = val; - - - - if (unlikely(!count)) - return count; - - if (off + count > at24->chip.byte_len) - return -EINVAL; - - /* - * Read data from chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&at24->lock); - - while (count) { - int status; - - status = at24->read_func(at24, buf, off, count); - if (status < 0) { - mutex_unlock(&at24->lock); - return status; - } - buf += status; - off += status; - count -= status; - } - - mutex_unlock(&at24->lock); - - return 0; -} - -static int at24_write(void *priv, unsigned int off, void *val, size_t count) -{ - struct at24_data *at24 = priv; - char *buf = val; - - if (unlikely(!count)) - return -EINVAL; - - if (off + count > at24->chip.byte_len) - return -EINVAL; - - /* - * Write data to chip, protecting against concurrent updates - * from this host, but not from other I2C masters. - */ - mutex_lock(&at24->lock); - - while (count) { - int status; - - status = at24->write_func(at24, buf, off, count); - if (status < 0) { - mutex_unlock(&at24->lock); - return status; - } - buf += status; - off += status; - count -= status; - } - - mutex_unlock(&at24->lock); - - return 0; -} - -#ifdef CONFIG_OF -static void at24_get_ofdata(struct i2c_client *client, - struct at24_platform_data *chip) -{ - const __be32 *val; - struct device_node *node = client->dev.of_node; - - if (node) { - if (of_get_property(node, "read-only", NULL)) - chip->flags |= AT24_FLAG_READONLY; - val = of_get_property(node, "pagesize", NULL); - if (val) - chip->page_size = be32_to_cpup(val); - } -} -#else -static void at24_get_ofdata(struct i2c_client *client, - struct at24_platform_data *chip) -{ } -#endif /* CONFIG_OF */ - -static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) -{ - struct at24_platform_data chip; - kernel_ulong_t magic = 0; - bool writable; - int use_smbus = 0; - int use_smbus_write = 0; - struct at24_data *at24; - int err; - unsigned i, num_addresses; - - if (client->dev.platform_data) { - chip = *(struct at24_platform_data *)client->dev.platform_data; - } else { - if (id) { - magic = id->driver_data; - } else { - const struct acpi_device_id *aid; - - aid = acpi_match_device(at24_acpi_ids, &client->dev); - if (aid) - magic = aid->driver_data; - } - if (!magic) - return -ENODEV; - - chip.byte_len = BIT(magic & AT24_BITMASK(AT24_SIZE_BYTELEN)); - magic >>= AT24_SIZE_BYTELEN; - chip.flags = magic & AT24_BITMASK(AT24_SIZE_FLAGS); - /* - * This is slow, but we can't know all eeproms, so we better - * play safe. Specifying custom eeprom-types via platform_data - * is recommended anyhow. - */ - chip.page_size = 1; - - /* update chipdata if OF is present */ - at24_get_ofdata(client, &chip); - - chip.setup = NULL; - chip.context = NULL; - } - - if (!is_power_of_2(chip.byte_len)) - dev_warn(&client->dev, - "byte_len looks suspicious (no power of 2)!\n"); - if (!chip.page_size) { - dev_err(&client->dev, "page_size must not be 0!\n"); - return -EINVAL; - } - if (!is_power_of_2(chip.page_size)) - dev_warn(&client->dev, - "page_size looks suspicious (no power of 2)!\n"); - - /* - * REVISIT: the size of the EUI-48 byte array is 6 in at24mac402, while - * the call to ilog2() in AT24_DEVICE_MAGIC() rounds it down to 4. - * - * Eventually we'll get rid of the magic values altoghether in favor of - * real structs, but for now just manually set the right size. - */ - if (chip.flags & AT24_FLAG_MAC && chip.byte_len == 4) - chip.byte_len = 6; - - /* Use I2C operations unless we're stuck with SMBus extensions. */ - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - /*if (chip.flags & AT24_FLAG_ADDR16){ - return -EPFNOSUPPORT; - }*/ - if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_I2C_BLOCK)) { - use_smbus = I2C_SMBUS_I2C_BLOCK_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_WORD_DATA)) { - use_smbus = I2C_SMBUS_WORD_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_BYTE_DATA)) { - use_smbus = I2C_SMBUS_BYTE_DATA; - } else { - return -EPFNOSUPPORT; - } - - if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) { - use_smbus_write = I2C_SMBUS_I2C_BLOCK_DATA; - } else if (i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { - use_smbus_write = I2C_SMBUS_BYTE_DATA; - chip.page_size = 1; - } - } - - if (chip.flags & AT24_FLAG_TAKE8ADDR) - num_addresses = 8; - else - num_addresses = DIV_ROUND_UP(chip.byte_len, - (chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256); - - at24 = devm_kzalloc(&client->dev, sizeof(struct at24_data) + - num_addresses * sizeof(struct i2c_client *), GFP_KERNEL); - if (!at24) - return -ENOMEM; - - mutex_init(&at24->lock); - at24->use_smbus = use_smbus; - at24->use_smbus_write = use_smbus_write; - at24->chip = chip; - at24->num_addresses = num_addresses; - - if ((chip.flags & AT24_FLAG_SERIAL) && (chip.flags & AT24_FLAG_MAC)) { - dev_err(&client->dev, - "invalid device data - cannot have both AT24_FLAG_SERIAL & AT24_FLAG_MAC."); - return -EINVAL; - } - at24->read_func = at24_eeprom_read_smbus; - - if (at24->use_smbus) { - if (at24->use_smbus_write == I2C_SMBUS_I2C_BLOCK_DATA) - at24->write_func = at24_eeprom_write_smbus_block; - else - at24->write_func = at24_eeprom_write_smbus_byte; - } else { - at24->write_func = at24_eeprom_write_i2c; - } - - writable = !(chip.flags & AT24_FLAG_READONLY); - if (writable) { - if (!use_smbus || use_smbus_write) { - - unsigned write_max = chip.page_size; - - if (write_max > io_limit) - write_max = io_limit; - if (use_smbus && write_max > I2C_SMBUS_BLOCK_MAX) - write_max = I2C_SMBUS_BLOCK_MAX; - at24->write_max = write_max; - - /* buffer (data + address at the beginning) */ - at24->writebuf = devm_kzalloc(&client->dev, - write_max + 2, GFP_KERNEL); - if (!at24->writebuf) - return -ENOMEM; - } else { - dev_warn(&client->dev, - "cannot write due to controller restrictions."); - } - } - - at24->client[0] = client; - - /* use dummy devices for multiple-address chips */ - for (i = 1; i < num_addresses; i++) { - at24->client[i] = i2c_new_dummy(client->adapter, - client->addr + i); - if (!at24->client[i]) { - dev_err(&client->dev, "address 0x%02x unavailable\n", - client->addr + i); - err = -EADDRINUSE; - goto err_clients; - } - } - - i2c_set_clientdata(client, at24); - at24->nvmem_config.name = dev_name(&client->dev); - at24->nvmem_config.dev = &client->dev; - at24->nvmem_config.read_only = !writable; - at24->nvmem_config.root_only = true; - at24->nvmem_config.owner = THIS_MODULE; - at24->nvmem_config.compat = true; - at24->nvmem_config.base_dev = &client->dev; - at24->nvmem_config.reg_read = at24_read; - at24->nvmem_config.reg_write = at24_write; - at24->nvmem_config.priv = at24; - at24->nvmem_config.stride = 1; - at24->nvmem_config.word_size = 1; - at24->nvmem_config.size = chip.byte_len; - - at24->nvmem = nvmem_register(&at24->nvmem_config); - - if (IS_ERR(at24->nvmem)) { - err = PTR_ERR(at24->nvmem); - goto err_clients; - } - - dev_info(&client->dev, "%u byte %s EEPROM, %s, %u bytes/write\n", - chip.byte_len, client->name, - writable ? "writable" : "read-only", at24->write_max); - if (use_smbus == I2C_SMBUS_WORD_DATA || - use_smbus == I2C_SMBUS_BYTE_DATA) { - dev_notice(&client->dev, "Falling back to %s reads, " - "performance will suffer\n", use_smbus == - I2C_SMBUS_WORD_DATA ? "word" : "byte"); - } - - /* export data to kernel code */ - if (chip.setup) - chip.setup(at24->nvmem, chip.context); - - return 0; - -err_clients: - for (i = 1; i < num_addresses; i++) - if (at24->client[i]) - i2c_unregister_device(at24->client[i]); - - return err; -} - -static int at24_remove(struct i2c_client *client) -{ - struct at24_data *at24; - int i; - - at24 = i2c_get_clientdata(client); - - nvmem_unregister(at24->nvmem); - - for (i = 1; i < at24->num_addresses; i++) - i2c_unregister_device(at24->client[i]); - - return 0; -} - -/*-------------------------------------------------------------------------*/ - -static struct i2c_driver at24_as7315_27xb_driver = { - .driver = { - .name = "at24_as7315_27xb", - .acpi_match_table = ACPI_PTR(at24_acpi_ids), - }, - .probe = at24_probe, - .remove = at24_remove, - .id_table = at24_ids, -}; - -static int __init at24_as7315_27xb_init(void) -{ - if (!io_limit) { - pr_err("at24_as7315_27xb: io_limit must not be 0!\n"); - return -EINVAL; - } - - io_limit = rounddown_pow_of_two(io_limit); - return i2c_add_driver(&at24_as7315_27xb_driver); -} -module_init(at24_as7315_27xb_init); - -static void __exit at24_as7315_27xb_exit(void) -{ - i2c_del_driver(&at24_as7315_27xb_driver); -} -module_exit(at24_as7315_27xb_exit); - -MODULE_DESCRIPTION("Driver for I2C EEPROMs on accton switch, as7315_27xb"); -MODULE_AUTHOR("Roy Lee"); -MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/utils/accton_as7315_util.py b/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/utils/accton_as7315_util.py index 867f5ce1aee6..d013b993da27 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/utils/accton_as7315_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7315-27xb/utils/accton_as7315_util.py @@ -158,11 +158,12 @@ def driver_check(): kos = [ 'modprobe i2c_dev', -'modprobe i2c_mux_pca954x force_deselect_on_exit=1', +'modprobe i2c_mux_pca954x', +'modprobe i2c_ismt', +'modprobe i2c_i801', 'modprobe optoe', 'modprobe ym2651y', 'modprobe accton_as7315_27xb_fan', -'modprobe at24_as7315_27xb', 'modprobe x86-64-accton-as7315_27xb-cpld', 'modprobe x86-64-accton-as7315_27xb-led', 'modprobe x86-64-accton-as7315_27xb-psu' ] @@ -227,12 +228,13 @@ def driver_uninstall(): 'echo as7315_cpld1 0x63 > /sys/bus/i2c/devices/i2c-8/new_device', 'echo as7315_cpld2 0x64 > /sys/bus/i2c/devices/i2c-7/new_device', -'echo 24cxb04 0x57 > /sys/bus/i2c/devices/i2c-4/new_device', +'echo 24c32 0x57 > /sys/bus/i2c/devices/i2c-4/new_device', 'echo as7315_27xb_psu2 0x50 > /sys/bus/i2c/devices/i2c-12/new_device', 'echo ym2401 0x58 > /sys/bus/i2c/devices/i2c-12/new_device', 'echo as7315_27xb_psu1 0x53 > /sys/bus/i2c/devices/i2c-13/new_device', 'echo ym2401 0x5b > /sys/bus/i2c/devices/i2c-13/new_device', -'echo as7315_fan 0x66 > /sys/bus/i2c/devices/i2c-50/new_device', +'echo as7315_fan 0x66 > /sys/bus/i2c/devices/i2c-50/new_device', # for R0A, R0B HW +'echo as7315_fan 0x66 > /sys/bus/i2c/devices/i2c-9/new_device', # for R0C HW and later 'echo lm75 0x49 > /sys/bus/i2c/devices/i2c-51/new_device', 'echo lm75 0x4a > /sys/bus/i2c/devices/i2c-52/new_device', 'echo lm75 0x4c > /sys/bus/i2c/devices/i2c-53/new_device', @@ -240,7 +242,7 @@ def driver_uninstall(): def i2c_order_check(): return 0 - + def device_install(): global FORCE @@ -255,6 +257,14 @@ def device_install(): if FORCE == 0: return status + # set all pca954x idle_disconnect + cmd = 'echo -2 | tee /sys/bus/i2c/drivers/pca954x/*-00*/idle_state' + status, output = log_os_system(cmd, 1) + if status: + print(output) + if FORCE == 0: + return status + for i in range(0,len(sfp_map)): path = "/sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device" if 1 >= qsfp_start_index: diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_fan.c b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_fan.c index 606019f3ea44..6120760fa941 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/modules/accton_as7326_56x_fan.c @@ -48,7 +48,7 @@ static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, static ssize_t get_enable(struct device *dev, struct device_attribute *da, char *buf); static ssize_t set_enable(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, char *buf); + extern int accton_i2c_cpld_read(unsigned short cpld_addr, u8 reg); extern int accton_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); @@ -150,12 +150,6 @@ enum sysfs_fan_attributes { &sensor_dev_attr_pwm##index.dev_attr.attr, \ &sensor_dev_attr_pwm##index##_enable.dev_attr.attr -#define DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR() \ - static SENSOR_DEVICE_ATTR(sys_temp, S_IRUGO, get_sys_temp, NULL, FAN_DUTY_CYCLE_PERCENTAGE) - -#define DECLARE_FAN_SYSTEM_TEMP_ATTR() &sensor_dev_attr_sys_temp.dev_attr.attr - - #define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(index) \ static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT) #define DECLARE_FAN_PRESENT_ATTR(index) &sensor_dev_attr_fan##index##_present.dev_attr.attr @@ -200,8 +194,6 @@ DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(5); DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(6); /* 1 fan duty cycle attribute in this platform */ DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(1); -/* System temperature for fancontrol */ -DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR(); static struct attribute *as7326_56x_fan_attributes[] = { /* fan related attributes */ @@ -230,7 +222,6 @@ static struct attribute *as7326_56x_fan_attributes[] = { DECLARE_FAN_DIRECTION_ATTR(5), DECLARE_FAN_DIRECTION_ATTR(6), DECLARE_FAN_DUTY_CYCLE_ATTR(1), - DECLARE_FAN_SYSTEM_TEMP_ATTR(), NULL }; @@ -348,267 +339,6 @@ static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, return count; } -/* Due to this struct is declared at lm75.c, it cannot be include - * under Sonic environment. I duplicate it from lm75.c. - */ -struct lm75_data { - struct i2c_client *client; - struct device *hwmon_dev; - struct thermal_zone_device *tz; - struct mutex update_lock; - u8 orig_conf; - u8 resolution; /* In bits, between 9 and 12 */ - u8 resolution_limits; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - unsigned long sample_time; /* In jiffies */ - s16 temp[3]; /* Register values, - 0 = input - 1 = max - 2 = hyst */ -}; - -/*Copied from lm75.c*/ -static inline long lm75_reg_to_mc(s16 temp, u8 resolution) -{ - return ((temp >> (16 - resolution)) * 1000) >> (resolution - 8); -} - -/*Get hwmon_dev from i2c_client, set hwmon_dev = NULL is failed.*/ -static struct device * get_hwmon_dev( - struct i2c_client *client) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - if(data) - { - if( data->valid == 1 && data->hwmon_dev) - { - return data->hwmon_dev; - } - - } - return NULL; -} - -/* To find hwmon index by opening hwmon under that i2c address. - */ -static int find_hwmon_index_by_FileOpen( - int bus_nr, - unsigned short addr, - OUT int *index) -{ -#define MAX_HWMON_DEVICE (10) /* Find hwmon device in 0~10*/ - struct file *sfd; - char client_name[96]; - int i=0; - - do { - snprintf(client_name, sizeof(client_name), - "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", - bus_nr, addr, i); - - sfd = filp_open(client_name, O_RDONLY, 0); - i++; - } while( IS_ERR(sfd) && i < MAX_HWMON_DEVICE); - - if (IS_ERR(sfd)) { - pr_err("Failed to open file(%s)#%d\r\n", client_name, __LINE__); - return -ENOENT; - } - filp_close(sfd, 0); - *index = i - 1; - return 0; - -#undef MAX_HWMON_DEVICE -} - -static int get_temp_file_path( - int bus_nr, unsigned short addr, - struct device *hwmon_dev - ,char *path, int max_len) -{ - - if(hwmon_dev && strlen(dev_name(hwmon_dev))) - { - snprintf(path, max_len, - "/sys/bus/i2c/devices/%d-%04x/hwmon/%s/temp1_input", - bus_nr, addr, dev_name(hwmon_dev)); - } - else - { - int i=0; - if(find_hwmon_index_by_FileOpen( bus_nr, addr, &i)) - { - return -EIO; - } - snprintf(path, max_len, - "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", - bus_nr, addr, i); - } - return 0; -} - -/*File read the dev file at user space.*/ -static int read_devfile_temp1_input( - struct device *dev, - int bus_nr, - unsigned short addr, - struct device *hwmon_dev, - int *miniCelsius) -{ - struct file *sfd; - char buffer[96]; - char devfile[96]; - int rc, status; - int rdlen, value; - mm_segment_t old_fs; - - rc = 0; - get_temp_file_path(bus_nr, addr, hwmon_dev, devfile, sizeof(devfile)); - sfd = filp_open(devfile, O_RDONLY, 0); - if (IS_ERR(sfd)) { - pr_err("Failed to open file(%s)#%d\r\n", devfile, __LINE__); - return -ENOENT; - } - dev_dbg(dev, "Found device:%s\n",devfile); - - if(!(sfd->f_op) || !(sfd->f_op->read) ) { - pr_err("file %s cann't readable ?\n",devfile); - return -ENOENT; - } - - old_fs = get_fs(); - set_fs(KERNEL_DS); - rdlen = sfd->f_op->read(sfd, buffer, sizeof(buffer), &sfd->f_pos); - if (rdlen == 0) { - pr_err( "File(%s) empty!\n", devfile); - rc = -EIO; - goto exit; - } - status = sscanf(buffer, "%d", &value); - if (status != 1) { - rc = -EIO; - goto exit; - } - *miniCelsius = value; - dev_dbg(dev,"found sensors: %d @i2c %d-%04x\n", value, bus_nr, addr); - -exit: - set_fs(old_fs); - filp_close(sfd, 0); - return rc; -} - -static u8 is_lm75_data_due(struct i2c_client *client) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - if (time_after(jiffies, data->last_updated + data->sample_time)) - { - return 1; - } - return 0; -} -static int get_lm75_temp(struct i2c_client *client, int *miniCelsius) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - *miniCelsius = lm75_reg_to_mc(data->temp[0], data->resolution); - - return 0; -} - -static bool lm75_addr_mached(unsigned short addr) -{ - int i; - unsigned short addrs[] = THERMAL_SENSORS_ADDRS; - - for (i = 0; i < ARRAY_SIZE(addrs); i++) - { - if( addr == addrs[i]) - return 1; - } - return 0; -} - -static int _find_lm75_device(struct device *dev, void *data) -{ - struct device_driver *driver; - struct as7326_56x_fan_data *prv = data; - char *driver_name = THERMAL_SENSORS_DRIVER; - - driver = dev->driver; - if (driver && driver->name && - strcmp(driver->name, driver_name) == 0) - { - struct i2c_client *client; - client = to_i2c_client(dev); - if (client) - { - /*cannot use "struct i2c_adapter *adap = to_i2c_adapter(dev);"*/ - struct i2c_adapter *adap = client->adapter; - int miniCelsius = 0; - - if (! lm75_addr_mached(client->addr)) - { - return 0; - } - - if (!adap) { - return -ENXIO; - } - - /* If the data is not updated, read them from devfile - to drive them updateing data from chip.*/ - if (is_lm75_data_due(client)) - { - struct device *hwmon_dev; - - hwmon_dev = get_hwmon_dev(client); - if(0 == read_devfile_temp1_input(dev, adap->nr, - client->addr, hwmon_dev, &miniCelsius)) - { - prv->system_temp += miniCelsius; - prv->sensors_found++; - } - - } - else - { - get_lm75_temp(client, &miniCelsius); - prv->system_temp += miniCelsius; - prv->sensors_found++; - - } - } - } - return 0; -} - -/*Find all lm75 devices and return sum of temperatures.*/ -static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, - char *buf) -{ - ssize_t ret = 0; - struct as7326_56x_fan_data *data = as7326_56x_fan_update_device(dev); - - data->system_temp=0; - data->sensors_found=0; - i2c_for_each_dev(data, _find_lm75_device); - if (NUM_THERMAL_SENSORS != data->sensors_found) - { - dev_dbg(dev,"only %d of %d temps are found\n", - data->sensors_found, NUM_THERMAL_SENSORS); - data->system_temp = INT_MAX; - } - ret = sprintf(buf, "%d\n",data->system_temp); - return ret; -} - static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf) { 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 new file mode 100755 index 000000000000..bfa545595338 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/pddf_post_device_create.sh @@ -0,0 +1,12 @@ +#!/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 diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_fan.c b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_fan.c index beb58804ac94..0341b3802b0f 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/modules/accton_as7726_32x_fan.c @@ -74,7 +74,6 @@ struct as7726_32x_fan_data { char valid; /* != 0 if registers are valid */ unsigned long last_updated; /* In jiffies */ u8 reg_val[ARRAY_SIZE(fan_reg)]; /* Register value */ - int system_temp; /*In unit of mini-Celsius*/ int sensors_found; }; @@ -141,11 +140,6 @@ enum sysfs_fan_attributes { static SENSOR_DEVICE_ATTR(fan##index##_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN##index##_DUTY_CYCLE_PERCENTAGE) #define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan##index##_duty_cycle_percentage.dev_attr.attr -#define DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR() \ - static SENSOR_DEVICE_ATTR(sys_temp, S_IRUGO, get_sys_temp, NULL, FAN_DUTY_CYCLE_PERCENTAGE) - -#define DECLARE_FAN_SYSTEM_TEMP_ATTR() &sensor_dev_attr_sys_temp.dev_attr.attr - #define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(index) \ static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT) #define DECLARE_FAN_PRESENT_ATTR(index) &sensor_dev_attr_fan##index##_present.dev_attr.attr @@ -191,8 +185,6 @@ DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(5); DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(6); /* 1 fan duty cycle attribute in this platform */ DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(); -/* System temperature for fancontrol */ -DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR(); static struct attribute *as7726_32x_fan_attributes[] = { /* fan related attributes */ @@ -221,7 +213,6 @@ static struct attribute *as7726_32x_fan_attributes[] = { DECLARE_FAN_DIRECTION_ATTR(5), DECLARE_FAN_DIRECTION_ATTR(6), DECLARE_FAN_DUTY_CYCLE_ATTR(), - DECLARE_FAN_SYSTEM_TEMP_ATTR(), NULL }; @@ -308,267 +299,6 @@ static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, return count; } -/* Due to this struct is declared at lm75.c, it cannot be include - * under Sonic environment. I duplicate it from lm75.c. - */ -struct lm75_data { - struct i2c_client *client; - struct device *hwmon_dev; - struct thermal_zone_device *tz; - struct mutex update_lock; - u8 orig_conf; - u8 resolution; /* In bits, between 9 and 12 */ - u8 resolution_limits; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - unsigned long sample_time; /* In jiffies */ - s16 temp[3]; /* Register values, - 0 = input - 1 = max - 2 = hyst */ -}; - -/*Copied from lm75.c*/ -static inline long lm75_reg_to_mc(s16 temp, u8 resolution) -{ - return ((temp >> (16 - resolution)) * 1000) >> (resolution - 8); -} - -/*Get hwmon_dev from i2c_client, set hwmon_dev = NULL is failed.*/ -static struct device * get_hwmon_dev( - struct i2c_client *client) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - if(data) - { - if( data->valid == 1 && data->hwmon_dev) - { - return data->hwmon_dev; - } - - } - return NULL; -} - -/* To find hwmon index by opening hwmon under that i2c address. - */ -static int find_hwmon_index_by_FileOpen( - int bus_nr, - unsigned short addr, - OUT int *index) -{ -#define MAX_HWMON_DEVICE (10) /* Find hwmon device in 0~10*/ - struct file *sfd; - char client_name[96]; - int i=0; - - do { - snprintf(client_name, sizeof(client_name), - "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", - bus_nr, addr, i); - - sfd = filp_open(client_name, O_RDONLY, 0); - i++; - } while( IS_ERR(sfd) && i < MAX_HWMON_DEVICE); - - if (IS_ERR(sfd)) { - pr_err("Failed to open file(%s)#%d\r\n", client_name, __LINE__); - return -ENOENT; - } - filp_close(sfd, 0); - *index = i - 1; - return 0; - -#undef MAX_HWMON_DEVICE -} - -static int get_temp_file_path( - int bus_nr, unsigned short addr, - struct device *hwmon_dev - ,char *path, int max_len) -{ - - if(hwmon_dev && strlen(dev_name(hwmon_dev))) - { - snprintf(path, max_len, - "/sys/bus/i2c/devices/%d-%04x/hwmon/%s/temp1_input", - bus_nr, addr, dev_name(hwmon_dev)); - } - else - { - int i=0; - if(find_hwmon_index_by_FileOpen( bus_nr, addr, &i)) - { - return -EIO; - } - snprintf(path, max_len, - "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", - bus_nr, addr, i); - } - - return 0; -} - -/*File read the dev file at user space.*/ -static int read_devfile_temp1_input( - struct device *dev, - int bus_nr, - unsigned short addr, - struct device *hwmon_dev, - int *miniCelsius) -{ - struct file *sfd; - char buffer[96]; - char devfile[96]; - int rc, status; - int rdlen, value; - mm_segment_t old_fs; - - rc = 0; - get_temp_file_path(bus_nr, addr, hwmon_dev, devfile, sizeof(devfile)); - sfd = filp_open(devfile, O_RDONLY, 0); - if (IS_ERR(sfd)) { - pr_err("Failed to open file(%s)#%d\r\n", devfile, __LINE__); - return -ENOENT; - } - dev_dbg(dev, "Found device:%s\n",devfile); - - if(!(sfd->f_op) || !(sfd->f_op->read) ) { - pr_err("file %s cann't readable ?\n",devfile); - return -ENOENT; - } - - old_fs = get_fs(); - set_fs(KERNEL_DS); - rdlen = sfd->f_op->read(sfd, buffer, sizeof(buffer), &sfd->f_pos); - if (rdlen == 0) { - pr_err( "File(%s) empty!\n", devfile); - rc = -EIO; - goto exit; - } - status = sscanf(buffer, "%d", &value); - if (status != 1) { - rc = -EIO; - goto exit; - } - *miniCelsius = value; - dev_dbg(dev,"found sensors: %d @i2c %d-%04x\n", value, bus_nr, addr); - -exit: - set_fs(old_fs); - filp_close(sfd, 0); - return rc; -} - -static u8 is_lm75_data_due(struct i2c_client *client) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - if (time_after(jiffies, data->last_updated + data->sample_time)) - { - return 1; - } - return 0; -} -static int get_lm75_temp(struct i2c_client *client, int *miniCelsius) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - *miniCelsius = lm75_reg_to_mc(data->temp[0], data->resolution); - - return 0; -} - -static bool lm75_addr_mached(unsigned short addr) -{ - int i; - unsigned short addrs[] = THERMAL_SENSORS_ADDRS; - - for (i = 0; i < ARRAY_SIZE(addrs); i++) - { - if( addr == addrs[i]) - return 1; - } - return 0; -} - -static int _find_lm75_device(struct device *dev, void *data) -{ - struct device_driver *driver; - struct as7726_32x_fan_data *prv = data; - char *driver_name = THERMAL_SENSORS_DRIVER; - - driver = dev->driver; - if (driver && driver->name && - strcmp(driver->name, driver_name) == 0) - { - struct i2c_client *client; - client = to_i2c_client(dev); - if (client) - { - /*cannot use "struct i2c_adapter *adap = to_i2c_adapter(dev);"*/ - struct i2c_adapter *adap = client->adapter; - int miniCelsius = 0; - - if (! lm75_addr_mached(client->addr)) - { - return 0; - } - - if (!adap) { - return -ENXIO; - } - - /* If the data is not updated, read them from devfile - to drive them updateing data from chip.*/ - if (is_lm75_data_due(client)) - { - struct device *hwmon_dev; - - hwmon_dev = get_hwmon_dev(client); - if(0 == read_devfile_temp1_input(dev, adap->nr, - client->addr, hwmon_dev, &miniCelsius)) - { - prv->system_temp += miniCelsius; - prv->sensors_found++; - } - - } - else - { - get_lm75_temp(client, &miniCelsius); - prv->system_temp += miniCelsius; - prv->sensors_found++; - - } - } - } - return 0; -} - -/*Find all lm75 devices and return sum of temperatures.*/ -static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, - char *buf) -{ - ssize_t ret = 0; - struct as7726_32x_fan_data *data = as7726_32x_fan_update_device(dev); - - data->system_temp=0; - data->sensors_found=0; - i2c_for_each_dev(data, _find_lm75_device); - if (NUM_THERMAL_SENSORS != data->sensors_found) - { - dev_dbg(dev,"only %d of %d temps are found\n", - data->sensors_found, NUM_THERMAL_SENSORS); - data->system_temp = INT_MAX; - } - ret = sprintf(buf, "%d\n",data->system_temp); - return ret; -} static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/pddf_post_device_create.sh b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/pddf_post_device_create.sh new file mode 100755 index 000000000000..bfa545595338 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/pddf_post_device_create.sh @@ -0,0 +1,12 @@ +#!/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 diff --git a/platform/broadcom/sonic-platform-modules-accton/as7816-64x/utils/pddf_post_device_create.sh b/platform/broadcom/sonic-platform-modules-accton/as7816-64x/utils/pddf_post_device_create.sh new file mode 100755 index 000000000000..bfa545595338 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7816-64x/utils/pddf_post_device_create.sh @@ -0,0 +1,12 @@ +#!/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 diff --git a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_as9716_32d_fan.c b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_as9716_32d_fan.c index 4d2433e7981e..b586a47ed007 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_as9716_32d_fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/modules/accton_as9716_32d_fan.c @@ -42,7 +42,6 @@ static struct as9716_32d_fan_data *as9716_32d_fan_update_device(struct device *d static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf); static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, char *buf); /* fan related data, the index should match sysfs_fan_attributes */ @@ -138,10 +137,6 @@ enum sysfs_fan_attributes { static SENSOR_DEVICE_ATTR(fan##index##_duty_cycle_percentage, S_IWUSR | S_IRUGO, fan_show_value, set_duty_cycle, FAN##index##_DUTY_CYCLE_PERCENTAGE) #define DECLARE_FAN_DUTY_CYCLE_ATTR(index) &sensor_dev_attr_fan##index##_duty_cycle_percentage.dev_attr.attr -#define DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR() \ - static SENSOR_DEVICE_ATTR(sys_temp, S_IRUGO, get_sys_temp, NULL, FAN_DUTY_CYCLE_PERCENTAGE) - -#define DECLARE_FAN_SYSTEM_TEMP_ATTR() &sensor_dev_attr_sys_temp.dev_attr.attr #define DECLARE_FAN_PRESENT_SENSOR_DEV_ATTR(index) \ static SENSOR_DEVICE_ATTR(fan##index##_present, S_IRUGO, fan_show_value, NULL, FAN##index##_PRESENT) @@ -189,7 +184,6 @@ DECLARE_FAN_DIRECTION_SENSOR_DEV_ATTR(6); /* 1 fan duty cycle attribute in this platform */ DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(); /* System temperature for fancontrol */ -DECLARE_FAN_SYSTEM_TEMP_SENSOR_DEV_ATTR(); static struct attribute *as9716_32d_fan_attributes[] = { /* fan related attributes */ @@ -217,8 +211,7 @@ static struct attribute *as9716_32d_fan_attributes[] = { DECLARE_FAN_DIRECTION_ATTR(4), DECLARE_FAN_DIRECTION_ATTR(5), DECLARE_FAN_DIRECTION_ATTR(6), - DECLARE_FAN_DUTY_CYCLE_ATTR(), - DECLARE_FAN_SYSTEM_TEMP_ATTR(), + DECLARE_FAN_DUTY_CYCLE_ATTR(), NULL }; @@ -305,267 +298,6 @@ static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, return count; } -/* Due to this struct is declared at lm75.c, it cannot be include - * under Sonic environment. I duplicate it from lm75.c. - */ -struct lm75_data { - struct i2c_client *client; - struct device *hwmon_dev; - struct thermal_zone_device *tz; - struct mutex update_lock; - u8 orig_conf; - u8 resolution; /* In bits, between 9 and 12 */ - u8 resolution_limits; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - unsigned long sample_time; /* In jiffies */ - s16 temp[3]; /* Register values, - 0 = input - 1 = max - 2 = hyst */ -}; - -/*Copied from lm75.c*/ -static inline long lm75_reg_to_mc(s16 temp, u8 resolution) -{ - return ((temp >> (16 - resolution)) * 1000) >> (resolution - 8); -} - -/*Get hwmon_dev from i2c_client, set hwmon_dev = NULL is failed.*/ -static struct device * get_hwmon_dev( - struct i2c_client *client) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - if(data) - { - if( data->valid == 1 && data->hwmon_dev) - { - return data->hwmon_dev; - } - - } - return NULL; -} - -/* To find hwmon index by opening hwmon under that i2c address. - */ -static int find_hwmon_index_by_FileOpen( - int bus_nr, - unsigned short addr, - int *index) -{ -#define MAX_HWMON_DEVICE (10) /* Find hwmon device in 0~10*/ - struct file *sfd; - char client_name[96]; - int i=0; - - do { - snprintf(client_name, sizeof(client_name), - "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", - bus_nr, addr, i); - - sfd = filp_open(client_name, O_RDONLY, 0); - i++; - } while( IS_ERR(sfd) && i < MAX_HWMON_DEVICE); - - if (IS_ERR(sfd)) { - pr_err("Failed to open file(%s)#%d\r\n", client_name, __LINE__); - return -ENOENT; - } - filp_close(sfd, 0); - *index = i - 1; - return 0; - -#undef MAX_HWMON_DEVICE -} - -static int get_temp_file_path( - int bus_nr, unsigned short addr, - struct device *hwmon_dev - ,char *path, int max_len) -{ - - if(hwmon_dev && strlen(dev_name(hwmon_dev))) - { - snprintf(path, max_len, - "/sys/bus/i2c/devices/%d-%04x/hwmon/%s/temp1_input", - bus_nr, addr, dev_name(hwmon_dev)); - } - else - { - int i=0; - if(find_hwmon_index_by_FileOpen( bus_nr, addr, &i)) - { - return -EIO; - } - snprintf(path, max_len, - "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", - bus_nr, addr, i); - } - - return 0; -} - -/*File read the dev file at user space.*/ -static int read_devfile_temp1_input( - struct device *dev, - int bus_nr, - unsigned short addr, - struct device *hwmon_dev, - int *miniCelsius) -{ - struct file *sfd; - char buffer[96]; - char devfile[96]; - int rc, status; - int rdlen, value; - mm_segment_t old_fs; - - rc = 0; - get_temp_file_path(bus_nr, addr, hwmon_dev, devfile, sizeof(devfile)); - sfd = filp_open(devfile, O_RDONLY, 0); - if (IS_ERR(sfd)) { - pr_err("Failed to open file(%s)#%d\r\n", devfile, __LINE__); - return -ENOENT; - } - dev_dbg(dev, "Found device:%s\n",devfile); - - if(!(sfd->f_op) || !(sfd->f_op->read) ) { - pr_err("file %s cann't readable ?\n",devfile); - return -ENOENT; - } - - old_fs = get_fs(); - set_fs(KERNEL_DS); - rdlen = sfd->f_op->read(sfd, buffer, sizeof(buffer), &sfd->f_pos); - if (rdlen == 0) { - pr_err( "File(%s) empty!\n", devfile); - rc = -EIO; - goto exit; - } - status = sscanf(buffer, "%d", &value); - if (status != 1) { - rc = -EIO; - goto exit; - } - *miniCelsius = value; - dev_dbg(dev,"found sensors: %d @i2c %d-%04x\n", value, bus_nr, addr); - -exit: - set_fs(old_fs); - filp_close(sfd, 0); - return rc; -} - -static u8 is_lm75_data_due(struct i2c_client *client) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - if (time_after(jiffies, data->last_updated + data->sample_time)) - { - return 1; - } - return 0; -} -static int get_lm75_temp(struct i2c_client *client, int *miniCelsius) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - *miniCelsius = lm75_reg_to_mc(data->temp[0], data->resolution); - - return 0; -} - -static bool lm75_addr_mached(unsigned short addr) -{ - int i; - unsigned short addrs[] = THERMAL_SENSORS_ADDRS; - - for (i = 0; i < ARRAY_SIZE(addrs); i++) - { - if( addr == addrs[i]) - return 1; - } - return 0; -} - -static int _find_lm75_device(struct device *dev, void *data) -{ - struct device_driver *driver; - struct as9716_32d_fan_data *prv = data; - char *driver_name = THERMAL_SENSORS_DRIVER; - - driver = dev->driver; - if (driver && driver->name && - strcmp(driver->name, driver_name) == 0) - { - struct i2c_client *client; - client = to_i2c_client(dev); - if (client) - { - /*cannot use "struct i2c_adapter *adap = to_i2c_adapter(dev);"*/ - struct i2c_adapter *adap = client->adapter; - int miniCelsius = 0; - - if (! lm75_addr_mached(client->addr)) - { - return 0; - } - - if (!adap) { - return -ENXIO; - } - - /* If the data is not updated, read them from devfile - to drive them updateing data from chip.*/ - if (is_lm75_data_due(client)) - { - struct device *hwmon_dev; - - hwmon_dev = get_hwmon_dev(client); - if(0 == read_devfile_temp1_input(dev, adap->nr, - client->addr, hwmon_dev, &miniCelsius)) - { - prv->system_temp += miniCelsius; - prv->sensors_found++; - } - - } - else - { - get_lm75_temp(client, &miniCelsius); - prv->system_temp += miniCelsius; - prv->sensors_found++; - - } - } - } - return 0; -} - -/*Find all lm75 devices and return sum of temperatures.*/ -static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, - char *buf) -{ - ssize_t ret = 0; - struct as9716_32d_fan_data *data = as9716_32d_fan_update_device(dev); - - data->system_temp=0; - data->sensors_found=0; - i2c_for_each_dev(data, _find_lm75_device); - if (NUM_THERMAL_SENSORS != data->sensors_found) - { - dev_dbg(dev,"only %d of %d temps are found\n", - data->sensors_found, NUM_THERMAL_SENSORS); - data->system_temp = INT_MAX; - } - ret = sprintf(buf, "%d\n",data->system_temp); - return ret; -} static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf) diff --git a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/utils/pddf_post_device_create.sh b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/utils/pddf_post_device_create.sh new file mode 100755 index 000000000000..bfa545595338 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/utils/pddf_post_device_create.sh @@ -0,0 +1,12 @@ +#!/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 diff --git a/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/x86-64-accton-as9726-32d-fan.c b/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/x86-64-accton-as9726-32d-fan.c index faf1e84acc37..67a015f01c62 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/x86-64-accton-as9726-32d-fan.c +++ b/platform/broadcom/sonic-platform-modules-accton/as9726-32d/modules/x86-64-accton-as9726-32d-fan.c @@ -358,172 +358,6 @@ static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, return count; } -/* Due to this struct is declared at lm75.c, it cannot be include - * under Sonic environment. I duplicate it from lm75.c. - */ -struct lm75_data { - struct i2c_client *client; - struct device *hwmon_dev; - struct thermal_zone_device *tz; - struct mutex update_lock; - u8 orig_conf; - u8 resolution; /* In bits, between 9 and 12 */ - u8 resolution_limits; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - unsigned long sample_time; /* In jiffies */ - s16 temp[3]; /* Register values, - 0 = input - 1 = max - 2 = hyst */ -}; - -/*Copied from lm75.c*/ -static inline long lm75_reg_to_mc(s16 temp, u8 resolution) -{ - return ((temp >> (16 - resolution)) * 1000) >> (resolution - 8); -} - -/*Get hwmon_dev from i2c_client, set hwmon_dev = NULL is failed.*/ -static struct device * get_hwmon_dev( - struct i2c_client *client) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - if(data) - { - if( data->valid == 1 && data->hwmon_dev) - { - return data->hwmon_dev; - } - - } - return NULL; -} - -/* To find hwmon index by opening hwmon under that i2c address. - */ -static int find_hwmon_index_by_FileOpen( - int bus_nr, - unsigned short addr, - int *index) -{ -#define MAX_HWMON_DEVICE (10) /* Find hwmon device in 0~10*/ - struct file *sfd; - char client_name[96]; - int i=0; - - do { - snprintf(client_name, sizeof(client_name), - "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", - bus_nr, addr, i); - - sfd = filp_open(client_name, O_RDONLY, 0); - i++; - } while( IS_ERR(sfd) && i < MAX_HWMON_DEVICE); - - if (IS_ERR(sfd)) { - pr_err("Failed to open file(%s)#%d\r\n", client_name, __LINE__); - return -ENOENT; - } - filp_close(sfd, 0); - *index = i - 1; - return 0; - -#undef MAX_HWMON_DEVICE -} - -static int get_temp_file_path( - int bus_nr, unsigned short addr, - struct device *hwmon_dev - ,char *path, int max_len) -{ - - if(hwmon_dev && strlen(dev_name(hwmon_dev))) - { - snprintf(path, max_len, - "/sys/bus/i2c/devices/%d-%04x/hwmon/%s/temp1_input", - bus_nr, addr, dev_name(hwmon_dev)); - } - else - { - int i=0; - if(find_hwmon_index_by_FileOpen( bus_nr, addr, &i)) - { - return -EIO; - } - snprintf(path, max_len, - "/sys/bus/i2c/devices/%d-%04x/hwmon/hwmon%d/temp1_input", - bus_nr, addr, i); - } - - return 0; -} - -/*File read the dev file at user space.*/ -static int read_devfile_temp1_input( - struct device *dev, - int bus_nr, - unsigned short addr, - struct device *hwmon_dev, - int *miniCelsius) -{ - struct file *sfd; - char buffer[96]; - char devfile[96]; - int rc, status; - int rdlen, value; - mm_segment_t old_fs; - - rc = 0; - get_temp_file_path(bus_nr, addr, hwmon_dev, devfile, sizeof(devfile)); - sfd = filp_open(devfile, O_RDONLY, 0); - if (IS_ERR(sfd)) { - pr_err("Failed to open file(%s)#%d\r\n", devfile, __LINE__); - return -ENOENT; - } - dev_dbg(dev, "Found device:%s\n",devfile); - - if(!(sfd->f_op) || !(sfd->f_op->read) ) { - pr_err("file %s cann't readable ?\n",devfile); - return -ENOENT; - } - - old_fs = get_fs(); - set_fs(KERNEL_DS); - rdlen = sfd->f_op->read(sfd, buffer, sizeof(buffer), &sfd->f_pos); - if (rdlen == 0) { - pr_err( "File(%s) empty!\n", devfile); - rc = -EIO; - goto exit; - } - status = sscanf(buffer, "%d", &value); - if (status != 1) { - rc = -EIO; - goto exit; - } - *miniCelsius = value; - dev_dbg(dev,"found sensors: %d @i2c %d-%04x\n", value, bus_nr, addr); - -exit: - set_fs(old_fs); - filp_close(sfd, 0); - return rc; -} - -static u8 is_lm75_data_due(struct i2c_client *client) -{ - struct lm75_data *data = NULL; - - data = i2c_get_clientdata(client); - if (time_after(jiffies, data->last_updated + data->sample_time)) - { - return 1; - } - return 0; -} - static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf) { diff --git a/platform/broadcom/sonic-platform-modules-accton/as9726-32d/utils/accton_as9726_32d_util.py b/platform/broadcom/sonic-platform-modules-accton/as9726-32d/utils/accton_as9726_32d_util.py index 5ba732cb73b2..1dd3c0b467d0 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as9726-32d/utils/accton_as9726_32d_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as9726-32d/utils/accton_as9726_32d_util.py @@ -277,7 +277,7 @@ def driver_inserted(): kos = [ 'depmod -ae', 'modprobe i2c_dev', - 'modprobe i2c_mux_pca954x force_deselect_on_exit=1', + 'modprobe i2c_mux_pca954x', 'modprobe ym2651y', 'modprobe x86-64-accton-as9726-32d_cpld', 'modprobe x86-64-accton-as9726-32d_fan', @@ -326,6 +326,15 @@ def device_install(): print(output) if FORCE == 0: return status + + # set all pca954x idle_disconnect + cmd = 'echo -2 | tee /sys/bus/i2c/drivers/pca954x/*-00*/idle_state' + status, output = log_os_system(cmd, 1) + if status: + print(output) + if FORCE == 0: + return status + print("Check SFP") for i in range(0, len(sfp_map)): if(i >= (len(sfp_map)-2)): diff --git a/platform/broadcom/sonic-platform-modules-arista b/platform/broadcom/sonic-platform-modules-arista index 65399c088de6..376e6a22debb 160000 --- a/platform/broadcom/sonic-platform-modules-arista +++ b/platform/broadcom/sonic-platform-modules-arista @@ -1 +1 @@ -Subproject commit 65399c088de6f79161752659e2a0dd1cec1fecd0 +Subproject commit 376e6a22debbc5880ee91fd02c0c2023d347884e diff --git a/platform/broadcom/sonic-platform-modules-cel/debian/rules b/platform/broadcom/sonic-platform-modules-cel/debian/rules index b6a8fa7187f1..0948949cccd1 100755 --- a/platform/broadcom/sonic-platform-modules-cel/debian/rules +++ b/platform/broadcom/sonic-platform-modules-cel/debian/rules @@ -14,7 +14,7 @@ override_dh_auto_build: (for mod in $(MODULE_DIRS); do \ make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \ if [ $$mod = "seastone2" ]; then \ - cd services/platform_api; \ + cd $(MOD_SRC_DIR)/services/platform_api; \ python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ continue; \ fi; \ diff --git a/platform/broadcom/sonic-platform-modules-dell/s5212f/scripts/pcisysfs.py b/platform/broadcom/sonic-platform-modules-dell/s5212f/scripts/pcisysfs.py index 047618e057c8..1ca22db926f5 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s5212f/scripts/pcisysfs.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5212f/scripts/pcisysfs.py @@ -20,23 +20,23 @@ from mmap import * def usage(): - ''' This is the Usage Method ''' + ''' This is the Usage Method ''' - print '\t\t pcisysfs.py --get --offset --res ' - print '\t\t pcisysfs.py --set --val --offset --res ' - sys.exit(1) + print('\t\t pcisysfs.py --get --offset --res ') + print('\t\t pcisysfs.py --set --val --offset --res ') + sys.exit(1) def pci_mem_read(mm,offset): mm.seek(offset) read_data_stream=mm.read(4) - print "" + print("") reg_val=struct.unpack('I',read_data_stream) - print "reg_val read:%x"%reg_val + print("reg_val read:%x"%reg_val) return reg_val def pci_mem_write(mm,offset,data): mm.seek(offset) - print "data to write:%x"%data + print("data to write:%x"%data) mm.write(struct.pack('I',data)) def pci_set_value(resource,val,offset): @@ -63,7 +63,7 @@ def main(argv): try: opts, args = getopt.getopt(argv, "hgsv:" , \ ["val=","res=","offset=","help", "get", "set"]) - + except getopt.GetoptError: usage() diff --git a/platform/broadcom/sonic-platform-modules-dell/s5212f/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s5212f/sonic_platform/chassis.py index 76e9a4b3648d..629f4e73f7b7 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5212f/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5212f/sonic_platform/chassis.py @@ -303,15 +303,15 @@ def get_reboot_cause(self): return (self.REBOOT_CAUSE_NON_HARDWARE, None) if reboot_cause & 0x1: - return (self.REBOOT_CAUSE_POWER_LOSS, None) + return (self.REBOOT_CAUSE_POWER_LOSS, "Power on reset") elif reboot_cause & 0x2: return (self.REBOOT_CAUSE_NON_HARDWARE, None) elif reboot_cause & 0x4: return (self.REBOOT_CAUSE_HARDWARE_OTHER, "PSU Shutdown") elif reboot_cause & 0x8: - return (self.REBOOT_CAUSE_THERMAL_OVERLOAD_CPU, None) + return (self.REBOOT_CAUSE_THERMAL_OVERLOAD_CPU, "Thermal overload") elif reboot_cause & 0x10: - return (self.REBOOT_CAUSE_WATCHDOG, None) + return (self.REBOOT_CAUSE_WATCHDOG, "Watchdog reset") elif reboot_cause & 0x20: return (self.REBOOT_CAUSE_HARDWARE_OTHER, "BMC Shutdown") elif reboot_cause & 0x40: diff --git a/platform/broadcom/sonic-platform-modules-dell/s5224f/scripts/pcisysfs.py b/platform/broadcom/sonic-platform-modules-dell/s5224f/scripts/pcisysfs.py index 347d1bd7fb33..45669199a383 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5224f/scripts/pcisysfs.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5224f/scripts/pcisysfs.py @@ -22,21 +22,21 @@ def usage(): ''' This is the Usage Method ''' - print '\t\t pcisysfs.py --get --offset --res ' - print '\t\t pcisysfs.py --set --val --offset --res ' + print('\t\t pcisysfs.py --get --offset --res ') + print('\t\t pcisysfs.py --set --val --offset --res ') sys.exit(1) def pci_mem_read(mm,offset): mm.seek(offset) read_data_stream=mm.read(4) - print "" + print("") reg_val=struct.unpack('I',read_data_stream) - print "reg_val read:%x"%reg_val + print("reg_val read:%x"%reg_val) return reg_val def pci_mem_write(mm,offset,data): mm.seek(offset) - print "data to write:%x"%data + print("data to write:%x"%data) mm.write(struct.pack('I',data)) def pci_set_value(resource,val,offset): diff --git a/platform/broadcom/sonic-platform-modules-dell/s5224f/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s5224f/sonic_platform/chassis.py index 250983d805bf..1f85dd80b259 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5224f/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5224f/sonic_platform/chassis.py @@ -262,6 +262,7 @@ def get_num_sfps(self): An integer represences the number of SFPs on the chassis. """ return self._num_sfps + def get_reboot_cause(self): """ Retrieves the cause of the previous reboot @@ -279,15 +280,15 @@ def get_reboot_cause(self): return (self.REBOOT_CAUSE_NON_HARDWARE, None) if reboot_cause & 0x1: - return (self.REBOOT_CAUSE_POWER_LOSS, None) + return (self.REBOOT_CAUSE_POWER_LOSS, "Power on reset") elif reboot_cause & 0x2: return (self.REBOOT_CAUSE_NON_HARDWARE, None) elif reboot_cause & 0x4: return (self.REBOOT_CAUSE_HARDWARE_OTHER, "PSU Shutdown") elif reboot_cause & 0x8: - return (self.REBOOT_CAUSE_THERMAL_OVERLOAD_CPU, None) + return (self.REBOOT_CAUSE_THERMAL_OVERLOAD_CPU, "Thermal overload") elif reboot_cause & 0x10: - return (self.REBOOT_CAUSE_WATCHDOG, None) + return (self.REBOOT_CAUSE_WATCHDOG, "Watchdog reset") elif reboot_cause & 0x20: return (self.REBOOT_CAUSE_HARDWARE_OTHER, "BMC Shutdown") elif reboot_cause & 0x40: diff --git a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/chassis.py index 30a79744cabd..41f985a173f9 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/chassis.py @@ -39,6 +39,7 @@ class Chassis(ChassisBase): oir_fd = -1 epoll = -1 + REBOOT_CAUSE_PATH = "/host/reboot-cause/platform/reboot_reason" pci_res = "/sys/bus/pci/devices/0000:04:00.0/resource0" sysled_offset = 0x0024 SYSLED_COLOR_TO_REG = { @@ -290,15 +291,15 @@ def get_reboot_cause(self): return (self.REBOOT_CAUSE_NON_HARDWARE, None) if reboot_cause & 0x1: - return (self.REBOOT_CAUSE_POWER_LOSS, None) + return (self.REBOOT_CAUSE_POWER_LOSS, "Power on reset") elif reboot_cause & 0x2: return (self.REBOOT_CAUSE_NON_HARDWARE, None) elif reboot_cause & 0x4: return (self.REBOOT_CAUSE_HARDWARE_OTHER, "PSU Shutdown") elif reboot_cause & 0x8: - return (self.REBOOT_CAUSE_THERMAL_OVERLOAD_CPU, None) + return (self.REBOOT_CAUSE_THERMAL_OVERLOAD_CPU, "Thermal overload") elif reboot_cause & 0x10: - return (self.REBOOT_CAUSE_WATCHDOG, None) + return (self.REBOOT_CAUSE_WATCHDOG, "Watchdog reset") elif reboot_cause & 0x20: return (self.REBOOT_CAUSE_HARDWARE_OTHER, "BMC Shutdown") elif reboot_cause & 0x40: diff --git a/platform/broadcom/sonic-platform-modules-dell/s5296f/scripts/pcisysfs.py b/platform/broadcom/sonic-platform-modules-dell/s5296f/scripts/pcisysfs.py index 047618e057c8..45669199a383 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s5296f/scripts/pcisysfs.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5296f/scripts/pcisysfs.py @@ -20,23 +20,23 @@ from mmap import * def usage(): - ''' This is the Usage Method ''' + ''' This is the Usage Method ''' - print '\t\t pcisysfs.py --get --offset --res ' - print '\t\t pcisysfs.py --set --val --offset --res ' - sys.exit(1) + print('\t\t pcisysfs.py --get --offset --res ') + print('\t\t pcisysfs.py --set --val --offset --res ') + sys.exit(1) def pci_mem_read(mm,offset): mm.seek(offset) read_data_stream=mm.read(4) - print "" + print("") reg_val=struct.unpack('I',read_data_stream) - print "reg_val read:%x"%reg_val + print("reg_val read:%x"%reg_val) return reg_val def pci_mem_write(mm,offset,data): mm.seek(offset) - print "data to write:%x"%data + print("data to write:%x"%data) mm.write(struct.pack('I',data)) def pci_set_value(resource,val,offset): @@ -63,7 +63,7 @@ def main(argv): try: opts, args = getopt.getopt(argv, "hgsv:" , \ ["val=","res=","offset=","help", "get", "set"]) - + except getopt.GetoptError: usage() diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.py index c0750e4ada1d..6ae79ffadb00 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/chassis.py @@ -231,6 +231,15 @@ def get_base_mac(self): """ return self._eeprom.get_base_mac() + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + return self._eeprom.get_revision() + def get_system_eeprom_info(self): """ Retrieves the full content of system EEPROM information for the diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/eeprom.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/eeprom.py index 5afe0112441b..12b3cfae5606 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/eeprom.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/eeprom.py @@ -105,6 +105,7 @@ def _load_system_eeprom(self): self.part_number = 'NA' self.model_str = 'NA' self.serial = 'NA' + self.revision = 'NA' return total_length = (eeprom[9] << 8) | (eeprom[10]) @@ -142,6 +143,8 @@ def _load_system_eeprom(self): "0x%X" % (self._TLV_CODE_PRODUCT_NAME), 'NA') self.serial = self.eeprom_tlv_dict.get( "0x%X" % (self._TLV_CODE_SERVICE_TAG), 'NA') + self.revision = self.eeprom_tlv_dict.get( + "0x%X" % (self._TLV_CODE_LABEL_REVISION), 'NA') def _load_device_eeprom(self): """ @@ -154,6 +157,7 @@ def _load_device_eeprom(self): except: self.serial_number = 'NA' self.part_number = 'NA' + self.revision = 'NA' if self.is_psu_eeprom: self.psu_type = 'NA' else: @@ -167,9 +171,13 @@ def _load_device_eeprom(self): + "-" + ppid[16:]) (valid, data) = self._get_eeprom_field("DPN Rev") if valid: + self.revision = data self.serial_number += "-" + data + else: + self.revision = 'NA' else: self.serial_number = 'NA' + self.revision = 'NA' (valid, data) = self._get_eeprom_field("Part Number") if valid: @@ -219,6 +227,12 @@ def get_part_number(self): """ return self.part_number + def get_revision(self): + """ + Returns the hardware revision. + """ + return self.revision + def airflow_fan_type(self): """ Returns the airflow fan type. @@ -449,7 +463,7 @@ def get_part_number(self): (valid, data) = self._get_eeprom_field(self.eeprom_data, self._BLK_CODE_MFG, "Part Number") if valid: - return data + return data.rstrip('\x00') else: return 'NA' @@ -475,6 +489,17 @@ def get_serial_number(self): else: return 'NA' + def get_revision(self): + """ + Returns the hardware revision. + """ + (valid, data) = self._get_eeprom_field(self.eeprom_data, + self._BLK_CODE_MFG, "DPN Rev") + if valid: + return data + else: + return 'NA' + # EEPROM Plugin specific methods def is_checksum_valid(self, e): # Checksum is already calculated before diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/fan_drawer.py index 2e5e3446cd80..90298fdad015 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/fan_drawer.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/fan_drawer.py @@ -182,3 +182,13 @@ def get_status_led(self): return fantray_led else: return self.STATUS_LED_COLOR_OFF + + def get_maximum_consumed_power(self): + """ + Retrives the maximum power drawn by Fan Drawer + + Returns: + A float, with value of the maximum consumable power of the + component. + """ + return 18.0 diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/psu.py index e217c0a08c40..c7dea7dade94 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/psu.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/psu.py @@ -161,6 +161,15 @@ def get_serial(self): # Sample Serial number format "US-01234D-54321-25A-0123-A00" return self.eeprom.get_serial_number() + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + return self.eeprom.get_revision() + def get_status(self): """ Retrieves the operational status of the PSU @@ -248,6 +257,21 @@ def get_power(self): return psu_power + def get_maximum_supplied_power(self): + """ + Retrieves the maximum supplied power by PSU + + Returns: + A float number, the maximum power output in Watts. + e.g. 1200.1 + """ + if self.get_presence(): + psu_maxpower = 460.0 + else: + psu_maxpower = 0.0 + + return psu_maxpower + def get_powergood_status(self): """ Retrieves the powergood status of PSU diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/sfp.py index f9be744a1ae7..5a5439910dc3 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/sfp.py @@ -9,14 +9,17 @@ ############################################################################# try: + import fcntl + import os import time from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase - import fcntl except ImportError as e: raise ImportError(str(e) + "- required module not found") +QSFP_INFO_OFFSET = 128 SFP_LOCK_FILE="/etc/sonic/sfp_lock" + class Sfp(SfpOptoeBase): """ DELLEMC Platform-specific Sfp class @@ -331,3 +334,27 @@ def is_replaceable(self): bool: True if it is replaceable. """ return True + + 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" + """ + if not self.get_presence(): + return self.SFP_STATUS_UNPLUGGED + else: + if not os.path.isfile(self.eeprom_path): + return "EEPROM driver is not attached" + + try: + with open(self.eeprom_path, mode="rb", buffering=0) as eeprom: + eeprom.seek(QSFP_INFO_OFFSET) + eeprom.read(1) + except OSError as e: + return "EEPROM read failed ({})".format(e.strerror) + + return self.SFP_STATUS_OK diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py index e96edbe21cbe..c93420886639 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/chassis.py @@ -10,16 +10,16 @@ try: import os + import re + import time from sonic_platform_base.chassis_base import ChassisBase - from sonic_platform.sfp import Sfp - from sonic_platform.psu import Psu + from sonic_platform.component import Component + from sonic_platform.eeprom import Eeprom from sonic_platform.fan_drawer import FanDrawer from sonic_platform.module import Module + from sonic_platform.psu import Psu from sonic_platform.thermal import Thermal - from sonic_platform.component import Component from sonic_platform.watchdog import Watchdog, WatchdogTCO - from sonic_platform.eeprom import Eeprom - import time except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -235,6 +235,15 @@ def get_base_mac(self): """ return self._eeprom.base_mac_addr() + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + return self._eeprom.revision_str() + def get_system_eeprom_info(self): """ Retrieves the full content of system EEPROM information for the chassis @@ -245,6 +254,19 @@ def get_system_eeprom_info(self): """ return self._eeprom.system_eeprom_info() + def get_module_index(self, module_name): + """ + Retrieves module index from the module name + + Args: + module_name: A string, prefixed by SUPERVISOR, LINE-CARD or FABRIC-CARD + Ex. SUPERVISOR0, LINE-CARD1, FABRIC-CARD5 + Returns: + An integer, the index of the ModuleBase object in the module_list + """ + module_index = re.match(r'IOM([1-4])', module_name).group(1) + return int(module_index) - 1 + def get_reboot_cause(self): """ Retrieves the cause of the previous reboot diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/eeprom.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/eeprom.py index 288c1a2ccfcf..ab3bb174e62b 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/eeprom.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/eeprom.py @@ -123,7 +123,7 @@ def serial_str(self): def revision_str(self): (is_valid, results) = self.get_tlv_field( - self.eeprom_data, self._TLV_CODE_DEVICE_VERSION) + self.eeprom_data, self._TLV_CODE_LABEL_REVISION) if not is_valid: return "N/A" diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/fan_drawer.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/fan_drawer.py index 41e870a63971..2f38be9cd574 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/fan_drawer.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/fan_drawer.py @@ -159,3 +159,13 @@ def get_status_led(self): return self.STATUS_LED_COLOR_AMBER else: return self.STATUS_LED_COLOR_OFF + + def get_maximum_consumed_power(self): + """ + Retrives the maximum power drawn by Fan Drawer + + Returns: + A float, with value of the maximum consumable power of the + component. + """ + return 54.0 diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/module.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/module.py index 923bb5c0550a..163a0ab3981c 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/module.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/module.py @@ -198,3 +198,48 @@ def get_system_eeprom_info(self): ‘0x26’:’01’, ‘0x27’:’REV01’, ‘0x28’:’AG9064-C2358-16G’} """ return self._eeprom.system_eeprom_info() + + def get_description(self): + """ + Retrieves the platform vendor's product description of the module + + Returns: + A string, providing the vendor's product description of the module. + """ + return self._eeprom.modelstr() + + def get_slot(self): + """ + Retrieves the platform vendor's slot number of the module + + Returns: + An integer, indicating the slot number in the chassis + """ + return self.index + + def get_oper_status(self): + """ + Retrieves the operational status of the module + + Returns: + A string, the operational status of the module from one of the + predefined status values: MODULE_STATUS_EMPTY, MODULE_STATUS_OFFLINE, + MODULE_STATUS_FAULT, MODULE_STATUS_PRESENT or MODULE_STATUS_ONLINE + """ + if self.get_presence(): + if self.get_status(): + return self.MODULE_STATUS_ONLINE + else: + return self.MODULE_STATUS_PRESENT + else: + return self.MODULE_STATUS_EMPTY + + def get_maximum_consumed_power(self): + """ + Retrives the maximum power drawn by this module + + Returns: + A float, with value of the maximum consumable power of the + module. + """ + return 97.23 diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/psu.py index 4e528b679e4a..8bfc0ddf2b77 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/psu.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/psu.py @@ -34,11 +34,13 @@ def __init__(self, psu_index): self.psu_voltage_reg = "in30_input" self.psu_current_reg = "curr602_input" self.psu_power_reg = "power2_input" + self.psu_maxpower_reg = "power2_max" self.psu_temperature_reg = "temp14_input" elif self.index == 2: self.psu_voltage_reg = "in32_input" self.psu_current_reg = "curr702_input" self.psu_power_reg = "power4_input" + self.psu_maxpower_reg = "power4_max" self.psu_temperature_reg = "temp15_input" # Passing True to specify it is a PSU fan @@ -124,6 +126,19 @@ def get_serial(self): return psu_serialno + def get_revision(self): + """ + Retrieves the hardware revision of the device + + Returns: + string: Revision value of device + """ + serial = self.get_serial() + if serial != "NA" and len(serial) == 28: + return serial[-3:] + else: + return "NA" + def get_status(self): """ Retrieves the operational status of the PSU @@ -195,6 +210,24 @@ def get_power(self): return psu_power + def get_maximum_supplied_power(self): + """ + Retrieves the maximum supplied power by PSU + + Returns: + A float number, the maximum power output in Watts. + e.g. 1200.1 + """ + psu_maxpower = self._get_pmc_register(self.psu_maxpower_reg) + if (psu_maxpower != 'ERR') and self.get_presence(): + # Converting the value returned by driver which is in + # microwatts to watts + psu_maxpower = float(psu_maxpower) / 1000000 + else: + psu_maxpower = 0.0 + + return psu_maxpower + def get_powergood_status(self): """ Retrieves the powergood status of PSU diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/sfp.py index fae9624e86a5..1a0c9cc8417e 100755 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/sfp.py @@ -9,11 +9,15 @@ ############################################################################# try: + import os import time from sonic_platform_base.sonic_xcvr.sfp_optoe_base import SfpOptoeBase except ImportError as e: raise ImportError(str(e) + "- required module not found") +QSFP_INFO_OFFSET = 128 + + class Sfp(SfpOptoeBase): """ DELLEMC Platform-specific Sfp class @@ -238,3 +242,27 @@ def is_replaceable(self): bool: True if it is replaceable. """ return True + + 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" + """ + if not self.get_presence(): + return self.SFP_STATUS_UNPLUGGED + else: + if not os.path.isfile(self.eeprom_path): + return "EEPROM driver is not attached" + + try: + with open(self.eeprom_path, mode="rb", buffering=0) as eeprom: + eeprom.seek(QSFP_INFO_OFFSET) + eeprom.read(1) + except OSError as e: + return "EEPROM read failed ({})".format(e.strerror) + + return self.SFP_STATUS_OK diff --git a/platform/broadcom/sonic-platform-modules-nokia b/platform/broadcom/sonic-platform-modules-nokia index 4ecf1ec8ca8d..edbfbf92902f 160000 --- a/platform/broadcom/sonic-platform-modules-nokia +++ b/platform/broadcom/sonic-platform-modules-nokia @@ -1 +1 @@ -Subproject commit 4ecf1ec8ca8d616221fdfdb350d1613590b37d90 +Subproject commit edbfbf92902f9e48c5f759cb11f09da3ea50ddd5 diff --git a/platform/centec-arm64/docker-saiserver-centec.mk b/platform/centec-arm64/docker-saiserver-centec.mk index 1751877bde93..78b7f44d7fbd 100755 --- a/platform/centec-arm64/docker-saiserver-centec.mk +++ b/platform/centec-arm64/docker-saiserver-centec.mk @@ -12,3 +12,5 @@ $(DOCKER_SAISERVER_CENTEC)_RUN_OPT += -v /host/machine.conf:/etc/machine.conf $(DOCKER_SAISERVER_CENTEC)_RUN_OPT += -v /var/run/docker-saiserver:/var/run/sswsyncd $(DOCKER_SAISERVER_CENTEC)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro $(DOCKER_SAISERVER_CENTEC)_RUN_OPT += -v /host/warmboot:/var/warmboot + +SONIC_BUSTER_DOCKERS += $(DOCKER_SAISERVER_CENTEC) diff --git a/platform/centec-arm64/docker-syncd-centec-rpc.mk b/platform/centec-arm64/docker-syncd-centec-rpc.mk index f8b7fe030099..a2d4f9287735 100755 --- a/platform/centec-arm64/docker-syncd-centec-rpc.mk +++ b/platform/centec-arm64/docker-syncd-centec-rpc.mk @@ -23,3 +23,5 @@ $(DOCKER_SYNCD_CENTEC_RPC)_RUN_OPT += --privileged -t $(DOCKER_SYNCD_CENTEC_RPC)_RUN_OPT += -v /host/machine.conf:/etc/machine.conf $(DOCKER_SYNCD_CENTEC_RPC)_RUN_OPT += -v /var/run/docker-syncd:/var/run/sswsyncd $(DOCKER_SYNCD_CENTEC_RPC)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro + +SONIC_BUSTER_DOCKERS += $(DOCKER_SYNCD_CENTEC_RPC) diff --git a/platform/centec/docker-saiserver-centec.mk b/platform/centec/docker-saiserver-centec.mk index 1751877bde93..78b7f44d7fbd 100755 --- a/platform/centec/docker-saiserver-centec.mk +++ b/platform/centec/docker-saiserver-centec.mk @@ -12,3 +12,5 @@ $(DOCKER_SAISERVER_CENTEC)_RUN_OPT += -v /host/machine.conf:/etc/machine.conf $(DOCKER_SAISERVER_CENTEC)_RUN_OPT += -v /var/run/docker-saiserver:/var/run/sswsyncd $(DOCKER_SAISERVER_CENTEC)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro $(DOCKER_SAISERVER_CENTEC)_RUN_OPT += -v /host/warmboot:/var/warmboot + +SONIC_BUSTER_DOCKERS += $(DOCKER_SAISERVER_CENTEC) diff --git a/platform/centec/docker-syncd-centec-rpc.mk b/platform/centec/docker-syncd-centec-rpc.mk index f8b7fe030099..a2d4f9287735 100644 --- a/platform/centec/docker-syncd-centec-rpc.mk +++ b/platform/centec/docker-syncd-centec-rpc.mk @@ -23,3 +23,5 @@ $(DOCKER_SYNCD_CENTEC_RPC)_RUN_OPT += --privileged -t $(DOCKER_SYNCD_CENTEC_RPC)_RUN_OPT += -v /host/machine.conf:/etc/machine.conf $(DOCKER_SYNCD_CENTEC_RPC)_RUN_OPT += -v /var/run/docker-syncd:/var/run/sswsyncd $(DOCKER_SYNCD_CENTEC_RPC)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro + +SONIC_BUSTER_DOCKERS += $(DOCKER_SYNCD_CENTEC_RPC) diff --git a/platform/centec/one-image.mk b/platform/centec/one-image.mk index da129addb247..84b993bb5986 100644 --- a/platform/centec/one-image.mk +++ b/platform/centec/one-image.mk @@ -9,6 +9,8 @@ $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(CENTEC_E582_48X6Q_PLATFORM_MODULE) \ $(EMBEDWAY_ES6220_PLATFORM_MODULE) $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(CENTEC_V682_48Y8C_D_PLATFORM_MODULE) +$(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(CENTEC_V682_48Y8C_PLATFORM_MODULE) +$(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(CENTEC_V682_48X8C_PLATFORM_MODULE) ifeq ($(INSTALL_DEBUG_TOOLS),y) $(SONIC_ONE_IMAGE)_DOCKERS += $(SONIC_INSTALL_DOCKER_DBG_IMAGES) diff --git a/platform/centec/platform-modules-centec-v682.mk b/platform/centec/platform-modules-centec-v682.mk index 1736279fdcef..46b64c3e6d72 100644 --- a/platform/centec/platform-modules-centec-v682.mk +++ b/platform/centec/platform-modules-centec-v682.mk @@ -2,8 +2,12 @@ CENTEC_V682_48Y8C_D_PLATFORM_MODULE_VERSION =1.0 +CENTEC_V682_48Y8C_PLATFORM_MODULE_VERSION =1.0 +CENTEC_V682_48X8C_PLATFORM_MODULE_VERSION =1.0 export CENTEC_V682_48Y8C_D_PLATFORM_MODULE_VERSION +export CENTEC_V682_48Y8C_PLATFORM_MODULE_VERSION +export CENTEC_V682_48X8C_PLATFORM_MODULE_VERSION CENTEC_V682_48Y8C_D_PLATFORM_MODULE = platform-modules-v682-48y8c-d_$(CENTEC_V682_48Y8C_D_PLATFORM_MODULE_VERSION)_amd64.deb @@ -12,3 +16,11 @@ $(CENTEC_V682_48Y8C_D_PLATFORM_MODULE)_PLATFORM = x86_64-centec_v682_48y8c_d-r0 $(CENTEC_V682_48Y8C_D_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) SONIC_STRETCH_DEBS += $(CENTEC_V682_48Y8C_D_PLATFORM_MODULE) SONIC_DPKG_DEBS += $(CENTEC_V682_48Y8C_D_PLATFORM_MODULE) + +CENTEC_V682_48Y8C_PLATFORM_MODULE = platform-modules-v682-48y8c_$(CENTEC_V682_48Y8C_PLATFORM_MODULE_VERSION)_amd64.deb +$(CENTEC_V682_48Y8C_PLATFORM_MODULE)_PLATFORM = x86_64-centec_v682_48y8c-r0 +$(eval $(call add_extra_package,$(CENTEC_V682_48Y8C_D_PLATFORM_MODULE),$(CENTEC_V682_48Y8C_PLATFORM_MODULE))) + +CENTEC_V682_48X8C_PLATFORM_MODULE = platform-modules-v682-48x8c_$(CENTEC_V682_48X8C_PLATFORM_MODULE_VERSION)_amd64.deb +$(CENTEC_V682_48X8C_PLATFORM_MODULE)_PLATFORM = x86_64-centec_v682_48x8c-r0 +$(eval $(call add_extra_package,$(CENTEC_V682_48Y8C_D_PLATFORM_MODULE),$(CENTEC_V682_48X8C_PLATFORM_MODULE))) diff --git a/platform/centec/sdk.mk b/platform/centec/sdk.mk index ead6de87dd65..2f56265b4890 100644 --- a/platform/centec/sdk.mk +++ b/platform/centec/sdk.mk @@ -1,5 +1,5 @@ # Centec SAI -CENTEC_SAI = libsai_1.8.1-0_amd64.deb +CENTEC_SAI = libsai_1.9.1-0_amd64.deb $(CENTEC_SAI)_URL = https://github.com/CentecNetworks/sonic-binaries/raw/master/amd64/sai/$(CENTEC_SAI) $(eval $(call add_conflict_package,$(CENTEC_SAI),$(LIBSAIVS_DEV))) diff --git a/platform/centec/sonic-platform-modules-v682/48x8c/modules/Makefile b/platform/centec/sonic-platform-modules-v682/48x8c/modules/Makefile new file mode 100644 index 000000000000..eabfe2733c41 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48x8c/modules/Makefile @@ -0,0 +1 @@ +obj-m := centec_v682_48x8c_platform.o rtc-sd2405.o diff --git a/platform/centec/sonic-platform-modules-v682/48x8c/modules/centec_v682_48x8c_platform.c b/platform/centec/sonic-platform-modules-v682/48x8c/modules/centec_v682_48x8c_platform.c new file mode 100644 index 000000000000..049ca4a710c3 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48x8c/modules/centec_v682_48x8c_platform.c @@ -0,0 +1,167 @@ +#include +#include +#include +#include +#include +#include + +#define SEP(XXX) 1 +#define IS_INVALID_PTR(_PTR_) ((_PTR_ == NULL) || IS_ERR(_PTR_)) +#define IS_VALID_PTR(_PTR_) (!IS_INVALID_PTR(_PTR_)) + +#if SEP("defines") +#define SFP_NUM 48 +#define QSFP_NUM 8 +#define PORT_NUM (SFP_NUM + QSFP_NUM) +#endif + +#if SEP("drivers:leds") +extern void v682_48x8c_led_port_set(struct led_classdev *led_cdev, enum led_brightness set_value); +extern enum led_brightness v682_48x8c_led_port_get(struct led_classdev *led_cdev); + +static struct led_classdev led_dev_port[PORT_NUM] = { +{ .name = "port0", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port1", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port2", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port3", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port4", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port5", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port6", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port7", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port8", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port9", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port10", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port11", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port12", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port13", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port14", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port15", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port16", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port17", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port18", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port19", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port20", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port21", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port22", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port23", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port24", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port25", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port26", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port27", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port28", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port29", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port30", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port31", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port32", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port33", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port34", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port35", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port36", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port37", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port38", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port39", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port40", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port41", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port42", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port43", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port44", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port45", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port46", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port47", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port48", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port49", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port50", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port51", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port52", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port53", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port54", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +{ .name = "port55", .brightness_set = v682_48x8c_led_port_set, .brightness_get = v682_48x8c_led_port_get,}, +}; +static unsigned char port_led_mode[PORT_NUM] = {0}; + +void v682_48x8c_led_port_set(struct led_classdev *led_cdev, enum led_brightness set_value) +{ + int portNum = 0; + + sscanf(led_cdev->name, "port%d", &portNum); + + port_led_mode[portNum] = set_value; + + return; +} + +enum led_brightness v682_48x8c_led_port_get(struct led_classdev *led_cdev) +{ + int portNum = 0; + + sscanf(led_cdev->name, "port%d", &portNum); + + return port_led_mode[portNum]; +} + +static int v682_48x8c_init_led(void) +{ + int ret = 0; + int i = 0; + + for (i = 0; i < PORT_NUM; i++) + { + ret = led_classdev_register(NULL, &(led_dev_port[i])); + if (ret != 0) + { + printk(KERN_CRIT "create v682_48x8c led_dev_port%d device failed\n", i); + continue; + } + } + + return ret; +} + +static int v682_48x8c_exit_led(void) +{ + int i = 0; + + for (i = 0; i < PORT_NUM; i++) + { + led_classdev_unregister(&(led_dev_port[i])); + } + + return 0; +} +#endif + +static int v682_48x8c_init(void) +{ + int ret = 0; + int failed = 0; + + printk(KERN_ALERT "init v682_48x8c board dirver...\n"); + + ret = v682_48x8c_init_led(); + if (ret != 0) + { + failed = 1; + } + + if (failed) + printk(KERN_INFO "init v682_48x8c board driver failed\n"); + else + printk(KERN_ALERT "init v682_48x8c board dirver...ok\n"); + + return 0; +} + +static void v682_48x8c_exit(void) +{ + printk(KERN_INFO "deinit v682_48x8c board dirver...\n"); + + v682_48x8c_exit_led(); + + printk(KERN_INFO "deinit v682_48x8c board dirver...ok\n"); +} + +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_AUTHOR("shil centecNetworks, Inc"); +MODULE_DESCRIPTION("v682-48x8c board driver"); +module_init(v682_48x8c_init); +module_exit(v682_48x8c_exit); diff --git a/platform/centec/sonic-platform-modules-v682/48x8c/modules/rtc-sd2405.c b/platform/centec/sonic-platform-modules-v682/48x8c/modules/rtc-sd2405.c new file mode 100644 index 000000000000..c22ab3349144 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48x8c/modules/rtc-sd2405.c @@ -0,0 +1,264 @@ +/* + * rtc class driver for the SD2405 chip + * + * Author: Dale Farnsworth + * + * based on previously existing rtc class drivers + * + * 2007 (c) MontaVista, Software, Inc. This file is licensed under + * the terms of the GNU General Public License version 2. This program + * is licensed "as is" without any warranty of any kind, whether express + * or implied. + */ + +#include +#include +#include +#include +#include + +#define DRV_VERSION "0.1" + +/* + * register indices + */ +#define SD2405_REG_SC 0x0 /* seconds 00-59 */ +#define SD2405_REG_MN 0x1 /* minutes 00-59 */ +#define SD2405_REG_HR 0x2 /* hours 00-23 */ +#define SD2405_REG_DW 0x3 /* day of week 1-7 */ +#define SD2405_REG_DT 0x4 /* day of month 00-31 */ +#define SD2405_REG_MO 0x5 /* month 01-12 */ +#define SD2405_REG_YR 0x6 /* year 00-99 */ + +#define SD2405_REG_CTRL1 0xf /* control 1 */ +#define SD2405_REG_CTRL2 0x10 /* control 2 */ +#define SD2405_REG_CTRL3 0x11 /* control 3 ARST*/ + +#define SD2405_REG_LEN 7 + +/* + * register write protect + */ +#define SD2405_REG_CONTROL1_WRITE 0x80 +#define SD2405_REG_CONTROL2_WRITE 0x84 + + +#define SD2405_IDLE_TIME_AFTER_WRITE 3 /* specification says 2.5 mS */ + +static struct i2c_driver sd2405_driver; + +#if 1 +/* modified by shil, for bug 46153 */ +static int sd2405_i2c_read_regs(struct i2c_client *client, u8 *buf) +{ + int i; + + for (i = 0; i < SD2405_REG_LEN; i++) { + buf[i] = i2c_smbus_read_byte_data(client, SD2405_REG_SC+i); + } + return 0; +} + +/* modified by shil, for bug 46153 */ +static int sd2405_i2c_write_regs(struct i2c_client *client, u8 const *buf) +{ + int i; + + for (i = 0; i < SD2405_REG_LEN; i++) { + i2c_smbus_write_byte_data(client, SD2405_REG_SC+i, buf[i]); + msleep(SD2405_IDLE_TIME_AFTER_WRITE); + } + return 0; +} + +#else +static int sd2405_i2c_read_regs(struct i2c_client *client, u8 *buf) +{ + struct i2c_msg msgs[1] = { + { + .addr = client->addr, + .flags = I2C_M_RD, /* read */ + .len = SD2405_REG_LEN, + .buf = buf} + }; + int rc; + + rc = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); + if (rc != ARRAY_SIZE(msgs)) { + dev_err(&client->dev, "%s: register read failed\n", __func__); + return -EIO; + } + return 0; +} + +static int sd2405_i2c_write_regs(struct i2c_client *client, u8 const *buf) +{ + int rc; + + u8 temp_reg[SD2405_REG_LEN+1] = {0}; + memcpy(&temp_reg[1], buf, SD2405_REG_LEN); + + struct i2c_msg msgs[1] = { + { + .addr = client->addr, + .flags = 0, /* write */ + .len = SD2405_REG_LEN+1, + .buf = temp_reg} + }; + + rc = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); + if (rc != ARRAY_SIZE(msgs)) + goto write_failed; + msleep(SD2405_IDLE_TIME_AFTER_WRITE); + + return 0; + + write_failed: + dev_err(&client->dev, "%s: register write failed\n", __func__); + return -EIO; +} +#endif + +static int sd2405_i2c_read_time(struct i2c_client *client, struct rtc_time *tm) +{ + int rc; + u8 regs[SD2405_REG_LEN]; + + rc = sd2405_i2c_read_regs(client, regs); + if (rc < 0) + return rc; + + tm->tm_sec = bcd2bin(regs[SD2405_REG_SC]); + tm->tm_min = bcd2bin(regs[SD2405_REG_MN]); + tm->tm_hour = bcd2bin(regs[SD2405_REG_HR] & 0x3f); + tm->tm_wday = bcd2bin(regs[SD2405_REG_DW]); + tm->tm_mday = bcd2bin(regs[SD2405_REG_DT]); + tm->tm_mon = bcd2bin(regs[SD2405_REG_MO]) - 1; + tm->tm_year = bcd2bin(regs[SD2405_REG_YR]) + 100; + + return 0; +} + +static int sd2405_i2c_set_write_protect(struct i2c_client *client) +{ + int rc; + rc = i2c_smbus_write_byte_data(client, SD2405_REG_CTRL1, 0); + rc += i2c_smbus_write_byte_data(client, SD2405_REG_CTRL2, 0); + if (rc < 0) { + dev_err(&client->dev, "%s: control register write failed\n", + __func__); + return -EIO; + } + return 0; +} + +static int sd2405_i2c_clear_write_protect(struct i2c_client *client) +{ + int rc; + rc = i2c_smbus_write_byte_data(client, SD2405_REG_CTRL2, SD2405_REG_CONTROL1_WRITE); + rc += i2c_smbus_write_byte_data(client, SD2405_REG_CTRL1, SD2405_REG_CONTROL2_WRITE); + if (rc < 0) { + dev_err(&client->dev, "%s: control register write failed\n", + __func__); + return -EIO; + } + return 0; +} + +static int +sd2405_i2c_set_time(struct i2c_client *client, struct rtc_time const *tm) +{ + u8 regs[SD2405_REG_LEN]; + int rc; + + rc = sd2405_i2c_clear_write_protect(client); + if (rc < 0) + return rc; + + regs[SD2405_REG_SC] = bin2bcd(tm->tm_sec); + regs[SD2405_REG_MN] = bin2bcd(tm->tm_min); + regs[SD2405_REG_HR] = bin2bcd(tm->tm_hour)|0x80; + regs[SD2405_REG_DW] = bin2bcd(tm->tm_wday); + regs[SD2405_REG_DT] = bin2bcd(tm->tm_mday); + regs[SD2405_REG_MO] = bin2bcd(tm->tm_mon + 1); + regs[SD2405_REG_YR] = bin2bcd(tm->tm_year - 100); + + rc = sd2405_i2c_write_regs(client, regs); + if (rc < 0) + return rc; + + rc = sd2405_i2c_set_write_protect(client); + if (rc < 0) + return rc; + + return 0; +} + +static int sd2405_rtc_read_time(struct device *dev, struct rtc_time *tm) +{ + return sd2405_i2c_read_time(to_i2c_client(dev), tm); +} + +static int sd2405_rtc_set_time(struct device *dev, struct rtc_time *tm) +{ + return sd2405_i2c_set_time(to_i2c_client(dev), tm); +} + +static const struct rtc_class_ops sd2405_rtc_ops = { + .read_time = sd2405_rtc_read_time, + .set_time = sd2405_rtc_set_time, +}; + +static int +sd2405_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct rtc_device *rtc; + +/* modified by shil, for bug 46153 */ +#if 0 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) + return -ENODEV; +#endif + + dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); + + rtc = devm_rtc_allocate_device(&client->dev); + if (IS_ERR(rtc)) + return PTR_ERR(rtc); + + i2c_set_clientdata(client, rtc); + rtc->ops = &sd2405_rtc_ops; + + return rtc_register_device(rtc); +} + +static struct i2c_device_id sd2405_id[] = { + { "sd2405", 0 }, + { } +}; + +static struct i2c_driver sd2405_driver = { + .driver = { + .name = "rtc-sd2405", + }, + .probe = sd2405_probe, + .id_table = sd2405_id, +}; + +static int __init sd2405_init(void) +{ + return i2c_add_driver(&sd2405_driver); +} + +static void __exit sd2405_exit(void) +{ + i2c_del_driver(&sd2405_driver); +} + +MODULE_DESCRIPTION("Maxim SD2405 RTC driver"); +MODULE_AUTHOR("Dale Farnsworth "); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); + +module_init(sd2405_init); +module_exit(sd2405_exit); diff --git a/platform/centec/sonic-platform-modules-v682/48x8c/service/48x8c_platform.service b/platform/centec/sonic-platform-modules-v682/48x8c/service/48x8c_platform.service new file mode 100644 index 000000000000..af5f5b779e66 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48x8c/service/48x8c_platform.service @@ -0,0 +1,13 @@ +[Unit] +Description=Centec modules init +After=local-fs.target +Before=syncd.service + +[Service] +Type=oneshot +ExecStart=-/etc/init.d/platform-modules-v682-48x8c start +ExecStop=-/etc/init.d/platform-modules-v682-48x8c stop +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/platform/centec/sonic-platform-modules-v682/48x8c/service/release.py b/platform/centec/sonic-platform-modules-v682/48x8c/service/release.py new file mode 100644 index 000000000000..8ae790a24fdc --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48x8c/service/release.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +import os +import time + +def release_board(): + if open('/proc/cmdline', 'r').readlines()[0].find('SONIC_BOOT_TYPE=warm') != -1: + return + + os.system('i2cset -y 0 0x37 0x4 0x0') + time.sleep(1) + os.system('i2cset -y 0 0x37 0x4 0x1') + time.sleep(1) + os.system('echo 1 > /sys/bus/pci/devices/0000\:00\:1c.0/remove') + time.sleep(1) + os.system('echo 1 > /sys/bus/pci/rescan') + time.sleep(1) + # EPLD_QSFP_RST + os.system('i2cset -y 0 0x36 0x5 0xff') + os.system('i2cset -y 0 0x37 0x5 0xff') + # EPLD_QSFP_INT_MASK + os.system('i2cset -y 0 0x36 0xd 0xff') + os.system('i2cset -y 0 0x37 0xd 0xff') + # EPLD_PPU_INT_MASK + os.system('i2cset -y 0 0x36 0xb 0x00') + # EPLD_SFP_DISABLE1 + os.system('i2cset -y 0 0x36 0xe 0x00') + os.system('i2cset -y 0 0x37 0xe 0x00') + # EPLD_SFP_DISABLE2 + os.system('i2cset -y 0 0x36 0xf 0x00') + os.system('i2cset -y 0 0x37 0xf 0x00') + # EPLD_SFP_DISABLE3 + os.system('i2cset -y 0 0x36 0x10 0x00') + os.system('i2cset -y 0 0x37 0x10 0x00') + +if __name__ == '__main__': + release_board() diff --git a/platform/centec/sonic-platform-modules-v682/48x8c/setup.py b/platform/centec/sonic-platform-modules-v682/48x8c/setup.py new file mode 100644 index 000000000000..57724ad4b4f8 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48x8c/setup.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +import os +from setuptools import setup +os.listdir + +setup( + name='sonic_platform', + version='1.0', + description='Module to initialize centec v682-48x8c platforms', + + packages=['sonic_platform'], + package_dir={'sonic_platform': 'sonic_platform'}, +) + diff --git a/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/__init__.py b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/__init__.py new file mode 100644 index 000000000000..6e50c02e9d1f --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/__init__.py @@ -0,0 +1,2 @@ +__all__ = ["platform", "chassis", "sfp", "eeprom", "psu", "thermal", "fan", "fan_drawer", "led"] +from . import platform diff --git a/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/chassis.py b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/chassis.py new file mode 100644 index 000000000000..7a137fc534f8 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/chassis.py @@ -0,0 +1,282 @@ +#!/usr/bin/env python +# +# Name: chassis.py, version: 1.0 +# +# Description: Module contains the definitions of SONiC platform APIs +# + +try: + import os + import re + import time + import collections + from sonic_py_common import device_info + from sonic_platform_base.chassis_base import ChassisBase + from sonic_platform.sfp import Sfp + from sonic_platform.fan_drawer import FanDrawer + from sonic_platform.psu import Psu + from sonic_platform.thermal import Thermal + from sonic_platform.eeprom import Eeprom +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +NUM_FAN_TRAY = 2 +NUM_THERMAL = 1 +NUM_PSU = 2 + +USR_SHARE_SONIC_PATH = "/usr/share/sonic" +HOST_DEVICE_PATH = USR_SHARE_SONIC_PATH + "/device" +CONTAINER_PLATFORM_PATH = USR_SHARE_SONIC_PATH + "/platform" + +REBOOT_CAUSE_DIR = "/host/reboot-cause/" +REBOOT_CAUSE_FILE = os.path.join(REBOOT_CAUSE_DIR, "reboot-cause.txt") + +class Chassis(ChassisBase): + # System status LED + _led = None + + def __init__(self): + ChassisBase.__init__(self) + + self.data = {'valid':0, 'last':0} + self.sfp_presence = {} + + if os.path.isdir(CONTAINER_PLATFORM_PATH): + platform_path = CONTAINER_PLATFORM_PATH + else: + platform = device_info.get_platform() + if platform is None: + raise + platform_path = os.path.join(HOST_DEVICE_PATH, platform) + + port_config_file = "/".join([platform_path, "V682-48x8c", "port_config.ini"]) + try: + f = open(port_config_file) + except: + raise + for line in f: + line.strip() + if re.search('^#', line) is not None: + Port_cfg = collections.namedtuple('Port_cfg', line.split()[1:]) + break + f.close() + f = open(port_config_file) + _port_cfgs = [Port_cfg(*tuple((line.strip().split()))) + for line in f if re.search('^#', line) is None] + f.close() + + # Initialize EEPROM + self._eeprom = Eeprom() + + # Initialize FAN + for i in range(NUM_FAN_TRAY): + fandrawer = FanDrawer(i + 1) + self._fan_drawer_list.append(fandrawer) + self._fan_list.extend(fandrawer._fan_list) + + # Initialize PSU + for index in range(0, NUM_PSU): + psu = Psu(index + 1) + self._psu_list.append(psu) + + # Initialize THERMAL + for index in range(0, NUM_THERMAL): + thermal = Thermal(index) + self._thermal_list.append(thermal) + + # Initialize SFP + for port_cfg in _port_cfgs: + sfp = Sfp(int(port_cfg.index), 'SFP' if int(port_cfg.index) < 48 else 'QSFP') + self._sfp_list.append(sfp) + self.sfp_presence[int(port_cfg.index)] = False + +############################################## +# Device methods +############################################## + + def get_name(self): + """ + Retrieves the name of the chassis + Returns: + string: The name of the chassis + """ + return self._eeprom.modelstr() + + def get_presence(self): + """ + Retrieves the presence of the chassis + Returns: + bool: True if chassis is present, False if not + """ + return True + + def get_model(self): + """ + Retrieves the model number (or part number) of the chassis + Returns: + string: Model/part number of chassis + """ + return self._eeprom.part_number_str() + + def get_serial(self): + """ + Retrieves the serial number of the chassis + Returns: + string: Serial number of chassis + """ + return self._eeprom.serial_number_str() + + def get_status(self): + """ + Retrieves the operational status of the chassis + Returns: + bool: A boolean value, True if chassis is operating properly + False if not + """ + return True + +############################################## +# Chassis methods +############################################## + + 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.base_mac_addr() + + def get_serial_number(self): + """ + Retrieves the hardware serial number for the chassis + + Returns: + A string containing the hardware serial number for this chassis. + """ + return self._eeprom.serial_number_str() + + 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. + Ex. { '0x21':'AG9064', '0x22':'V1.0', '0x23':'AG9064-0109867821', + '0x24':'001c0f000fcd0a', '0x25':'02/03/2018 16:22:00', + '0x26':'01', '0x27':'REV01', '0x28':'AG9064-C2358-16G'} + """ + return self._eeprom.system_eeprom_info() + + 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. + """ + if os.path.exists(REBOOT_CAUSE_FILE): + with open(REBOOT_CAUSE_FILE) as reboot_cause_file: + reboot_cause = reboot_cause_file.readline() + if re.search(r'User issued', reboot_cause) is None: + return (self.REBOOT_CAUSE_POWER_LOSS, None) + else: + return (self.REBOOT_CAUSE_NON_HARDWARE, None) + else: + return (self.REBOOT_CAUSE_POWER_LOSS, None) + + def get_change_event(self, timeout=2000): + """ + Returns a nested dictionary containing all devices which have + experienced a change at chassis level + + Args: + timeout: Timeout in milliseconds (optional). If timeout == 0, + this method will block until a change is detected. + + Returns: + (bool, dict): + - True if call successful, False if not; + - A nested dictionary where key is a device type, + value is a dictionary with key:value pairs in the + format of {'device_id':'device_event'}, + where device_id is the device ID for this device and + device_event, + status='1' represents device inserted, + status='0' represents device removed. + Ex. {'fan':{'0':'0', '2':'1'}, 'sfp':{'11':'0'}} + indicates that fan 0 has been removed, fan 2 + has been inserted and sfp 11 has been removed. + """ + SFP_STATUS_INSERTED = '1' + SFP_STATUS_REMOVED = '0' + + now = time.time() + port_dict = {} + + if timeout < 1000: + timeout = 1000 + timeout = (timeout) / float(1000) # Convert to secs + + if now < (self.data['last'] + timeout) and self.data['valid']: + return False, {'sfp': {}} + + for sfp in self._sfp_list: + sfp_presence = sfp.get_presence() + if sfp_presence != self.sfp_presence[sfp.index]: + self.sfp_presence[sfp.index] = sfp_presence + if sfp_presence: + port_dict[sfp.index] = SFP_STATUS_INSERTED + else: + port_dict[sfp.index] = SFP_STATUS_REMOVED + + if bool(port_dict): + self.data['last'] = now + self.data['valid'] = 1 + ret = True + else: + time.sleep(0.5) + ret = False + + ret_dict = {'sfp': port_dict} + return ret, ret_dict + + def get_num_psus(self): + return len(self._psu_list) + + def get_psu(self, psu_index): + return self._psu_list[psu_index] + + def initizalize_system_led(self): + from .led import SystemLed + Chassis._led = SystemLed() + + def set_status_led(self, color): + """ + Sets the state of the system LED + + Args: + color: A string representing the color with which to set the + system LED + + Returns: + bool: True if system LED state is set successfully, False if not + """ + return False if not Chassis._led else Chassis._led.set_status(color) + + def get_status_led(self): + """ + Gets the state of the system LED + + Returns: + A string, one of the valid LED color strings which could be vendor + specified. + """ + return None if not Chassis._led else Chassis._led.get_status() diff --git a/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/eeprom.py b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/eeprom.py new file mode 100644 index 000000000000..7d2750475717 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/eeprom.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python +# +# Name: eeprom.py, version: 1.0 +# +# Description: Module contains the definitions of SONiC platform APIs +# + +try: + import os + from sonic_eeprom import eeprom_tlvinfo + from sonic_py_common import device_info + import binascii +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +USR_SHARE_SONIC_PATH = "/usr/share/sonic" +HOST_DEVICE_PATH = USR_SHARE_SONIC_PATH + "/device" +CONTAINER_PLATFORM_PATH = USR_SHARE_SONIC_PATH + "/platform" + +class Eeprom(eeprom_tlvinfo.TlvInfoDecoder): + + def __init__(self): + if os.path.isdir(CONTAINER_PLATFORM_PATH): + platform_path = CONTAINER_PLATFORM_PATH + else: + platform = device_info.get_platform() + if platform is None: + raise + platform_path = os.path.join(HOST_DEVICE_PATH, platform) + + self.__eeprom_path = platform_path + '/eeprom_file' + + super(Eeprom, self).__init__(self.__eeprom_path, 0, '', True) + + self.__eeprom_tlv_dict = dict() + try: + self.open_eeprom() + self.__eeprom_data = self.read_eeprom() + except: + self.__eeprom_data = "N/A" + raise RuntimeError("Eeprom is not Programmed") + else: + eeprom = self.__eeprom_data + + 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 + + def serial_number_str(self): + (is_valid, results) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_SERIAL_NUMBER) + if not is_valid: + return "N/A" + return results[2].decode('ascii') + + def base_mac_addr(self): + (is_valid, t) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_MAC_BASE) + if not is_valid or t[1] != 6: + return super(TlvInfoDecoder, self).switchaddrstr(e) + + return ":".join([binascii.b2a_hex(T) for T in t[2]]) + + def modelstr(self): + (is_valid, results) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_PRODUCT_NAME) + if not is_valid: + return "N/A" + + return results[2].decode('ascii') + + def part_number_str(self): + (is_valid, results) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_PART_NUMBER) + if not is_valid: + return "N/A" + + return results[2].decode('ascii') + + def serial_tag_str(self): + (is_valid, results) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_SERVICE_TAG) + if not is_valid: + return "N/A" + + return results[2].decode('ascii') + + def revision_str(self): + (is_valid, results) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_DEVICE_VERSION) + if not is_valid: + return "N/A" + + return results[2].decode('ascii') + + def system_eeprom_info(self): + """ + Returns a dictionary, where keys are the type code defined in + ONIE EEPROM format and values are their corresponding values + found in the system EEPROM. + """ + return self.__eeprom_tlv_dict + diff --git a/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/fan.py b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/fan.py new file mode 100644 index 000000000000..5f7b256eafb8 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/fan.py @@ -0,0 +1,186 @@ +#!/usr/bin/env python + +############################################################################# +# Celestica +# +# Module contains an implementation of SONiC Platform Base API and +# provides the fan status which are available in the platform +# +############################################################################# + +import math +import os.path + +try: + from sonic_platform_base.fan_base import FanBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +FAN_PATH = "/sys/class/hwmon/hwmon{}/" +FAN_MAX_PWM = 255 +FAN_FAN_PWM = "pwm{}" +FAN_FAN_INPUT = "fan{}_input" +FAN_MAX_RPM = 15000 +FAN_NAME_LIST = ["FAN-{}-1", "FAN-{}-2", "FAN-{}-3", "FAN-{}-4"] + +class Fan(FanBase): + """Platform-specific Fan class""" + + def __init__(self, fan_tray_index, fan_index=0): + self.fan_index = fan_index + self.fan_tray_index = fan_tray_index + + FanBase.__init__(self) + + def __read_txt_file(self, file_path): + try: + with open(file_path, 'r') as fd: + data = fd.read() + return data.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 IOError: + return False + return True + + def __search_file_by_name(self, directory, file_name): + for dirpath, dirnames, files in os.walk(directory): + for name in files: + file_path = os.path.join(dirpath, name) + if name in file_name: + return file_path + return None + + def get_direction(self): + """ + Retrieves the direction of fan + Returns: + A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST + depending on fan direction + """ + direction = self.FAN_DIRECTION_EXHAUST + 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) + + Note: + speed = pwm_in/255*100 + """ + speed = 0 + fan_speed_sysfs_name = "fan{}_input".format(self.fan_index+1) + fan_speed_sysfs_path = self.__search_file_by_name( + FAN_PATH.format(self.fan_tray_index + 1), fan_speed_sysfs_name) + fan_speed_rpm = self.__read_txt_file(fan_speed_sysfs_path) or 0 + speed = math.ceil(float(fan_speed_rpm) * 100 / FAN_MAX_RPM) + + 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 + """ + # target = 0 + # fan_target_sysfs_name = "pwm{}".format(self.fan_index+1) + # fan_target_sysfs_path = self.__search_file_by_name( + # FAN_PATH.format(self.fan_tray_index + 1), fan_target_sysfs_name) + # fan_target_pwm = self.__read_txt_file(fan_target_sysfs_path) or 0 + # target = math.ceil(float(fan_target_pwm) * 100 / FAN_MAX_PWM) + + # return target + speed = 0 + fan_speed_sysfs_name = "fan{}_input".format(self.fan_index+1) + fan_speed_sysfs_path = self.__search_file_by_name( + FAN_PATH.format(self.fan_tray_index + 1), fan_speed_sysfs_name) + fan_speed_rpm = self.__read_txt_file(fan_speed_sysfs_path) or 0 + speed = math.ceil(float(fan_speed_rpm) * 100 / FAN_MAX_RPM) + + return 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 10 + + 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 + + Note: + Depends on pwm or target mode is selected: + 1) pwm = speed_pc * 255 <-- Currently use this mode. + 2) target_pwm = speed_pc * 100 / 255 + 2.1) set pwm{}_enable to 3 + + """ + pwm = speed * 255 / 100 + fan_target_sysfs_name = "pwm{}".format(self.fan_index+1) + fan_target_sysfs_path = self.__search_file_by_name( + FAN_PATH.format(self.fan_tray_index + 1), fan_target_sysfs_name) + return self.__write_txt_file(fan_target_sysfs_path, int(pwm)) + + 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: always True + """ + return True + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + fan_name = FAN_NAME_LIST[self.fan_index].format(self.fan_tray_index) + + return fan_name + + def get_presence(self): + """ + Retrieves the presence of the FAN + Returns: + bool: always True + """ + + return True + + def get_status(self): + """ + Retrieves the status of the FAN + Returns: + bool: always True + """ + return True diff --git a/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/fan_drawer.py b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/fan_drawer.py new file mode 100644 index 000000000000..9940645ff92d --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/fan_drawer.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +######################################################################## +# Centec V682 48X8C +# +# 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 + from sonic_platform.fan import Fan +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +CENTEC_FANS_PER_FANTRAY = 4 + + +class FanDrawer(FanDrawerBase): + """Centec V682 48X8C Platform-specific Fan class""" + + def __init__(self, fantray_index): + + FanDrawerBase.__init__(self) + self.fantrayindex = fantray_index + for i in range(CENTEC_FANS_PER_FANTRAY): + self._fan_list.append(Fan(fantray_index, i)) + + def get_name(self): + """ + Retrieves the fan drawer name + Returns: + string: The name of the device + """ + return "FanTray{}".format(self.fantrayindex) + + def set_status_led(self, color): + """ + Sets the state of the fan drawer status LED + + Args: + color: A string representing the color with which to set the + fan drawer status LED + + Returns: + bool: True if status LED state is set successfully, False if not + """ + return True diff --git a/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/led.py b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/led.py new file mode 100644 index 000000000000..492d6983ea76 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/led.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +############################################################################# +# +# Module contains an implementation of SONiC Platform Base API and +# provides the led status which are available in the platform +# +############################################################################# + +from subprocess import Popen, PIPE, STDOUT + +class SystemLed(object): + STATUS_LED_COLOR_GREEN = 'green' + STATUS_LED_COLOR_ORANGE = 'orange' + STATUS_LED_COLOR_OFF = 'off' + + SYSTEM_LED_PATH = '/sys/class/leds/system/brightness' + + def set_status(self, color): + status = False + + if color == SystemLed.STATUS_LED_COLOR_ORANGE: + cmd = 'i2cset -y 0 0x36 0x2 0xb' + Popen(cmd, shell=True) + status = True + elif color == SystemLed.STATUS_LED_COLOR_OFF: + cmd = 'i2cset -y 0 0x36 0x2 0x0' + Popen(cmd, shell=True) + status = True + elif color == SystemLed.STATUS_LED_COLOR_GREEN: + cmd = 'i2cset -y 0 0x36 0x2 0x5' + Popen(cmd, shell=True) + status = True + + return status + + def get_status(self): + cmd = 'i2cget -y 0 0x36 0x2' + status = int(Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True).stdout.readline(), 16) + if status == 11: + return SystemLed.STATUS_LED_COLOR_ORANGE + elif status == 0: + return SystemLed.STATUS_LED_COLOR_OFF + else: + return SystemLed.STATUS_LED_COLOR_GREEN diff --git a/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/platform.py b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/platform.py new file mode 100644 index 000000000000..59d37da538a1 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/platform.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +# +# Name: platform.py, version: 1.0 +# +# Description: Module contains the definitions of SONiC platform APIs for Centec V682-48X8C +# + + +try: + from sonic_platform_base.platform_base import PlatformBase + from sonic_platform.chassis import Chassis +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Platform(PlatformBase): + + def __init__(self): + PlatformBase.__init__(self) + self._chassis = Chassis() + diff --git a/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/psu.py b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/psu.py new file mode 100644 index 000000000000..779209c71c2e --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/psu.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +from __future__ import print_function + +from subprocess import Popen, PIPE, STDOUT + +try: + from sonic_platform_base.psu_base import PsuBase +except ImportError as e: + raise ImportError("%s - required module not found" % e) + +class Psu(PsuBase): + """Centec Platform-specific PSU class""" + + def __init__(self, index): + self._index = index + self._fan_list = [] + + def get_presence(self): + cmd = 'i2cget -y 0 0x36 0x1e' + status = int(Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True).stdout.readline(), 16) + presence = ((status & (1 << (3 * (self._index - 1) + 1))) == 0) + return presence + + def get_powergood_status(self): + cmd = 'i2cget -y 0 0x36 0x1e' + status = int(Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True).stdout.readline(), 16) + powergood = ((status & (1 << (3 * (self._index - 1) + 2))) != 0) + return powergood diff --git a/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/sfp.py b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/sfp.py new file mode 100644 index 000000000000..1d4154ff8384 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/sfp.py @@ -0,0 +1,1618 @@ +#!/usr/bin/env python + +############################################################################# +# Centec +# +# Sfp contains an implementation of SONiC Platform Base API and +# provides the sfp device status which are available in the platform +# +############################################################################# + +import os +import time +import re +import collections +#import subprocess +#import sonic_device_util +from ctypes import create_string_buffer +from subprocess import Popen, PIPE, STDOUT +from sonic_py_common import device_info + +try: + from sonic_platform_base.sfp_base import SfpBase +# from sonic_platform_base.sonic_eeprom import eeprom_dts + from sonic_platform_base.sonic_sfp.sff8472 import sff8472InterfaceId + from sonic_platform_base.sonic_sfp.sff8472 import sff8472Dom + from sonic_platform_base.sonic_sfp.sff8436 import sff8436InterfaceId + from sonic_platform_base.sonic_sfp.sff8436 import sff8436Dom +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +USR_SHARE_SONIC_PATH = "/usr/share/sonic" +HOST_DEVICE_PATH = USR_SHARE_SONIC_PATH + "/device" +CONTAINER_PLATFORM_PATH = USR_SHARE_SONIC_PATH + "/platform" + +QSFP_INFO_OFFSET = 128 +QSFP_DOM_OFFSET = 0 +SFP_INFO_OFFSET = 0 +SFP_DOM_OFFSET = 256 + +# definitions of the offset and width for values in XCVR info eeprom +XCVR_INTFACE_BULK_OFFSET = 0 +XCVR_INTFACE_BULK_WIDTH_QSFP = 20 +XCVR_INTFACE_BULK_WIDTH_SFP = 21 +XCVR_TYPE_OFFSET = 0 +XCVR_TYPE_WIDTH = 1 +XCVR_EXT_TYPE_OFFSET = 1 +XCVR_EXT_TYPE_WIDTH = 1 +XCVR_CONNECTOR_OFFSET = 2 +XCVR_CONNECTOR_WIDTH = 1 +XCVR_COMPLIANCE_CODE_OFFSET = 3 +XCVR_COMPLIANCE_CODE_WIDTH = 8 +XCVR_ENCODING_OFFSET = 11 +XCVR_ENCODING_WIDTH = 1 +XCVR_NBR_OFFSET = 12 +XCVR_NBR_WIDTH = 1 +XCVR_EXT_RATE_SEL_OFFSET = 13 +XCVR_EXT_RATE_SEL_WIDTH = 1 +XCVR_CABLE_LENGTH_OFFSET = 14 +XCVR_CABLE_LENGTH_WIDTH_QSFP = 5 +XCVR_CABLE_LENGTH_WIDTH_SFP = 6 +XCVR_VENDOR_NAME_OFFSET = 20 +XCVR_VENDOR_NAME_WIDTH = 16 +XCVR_VENDOR_OUI_OFFSET = 37 +XCVR_VENDOR_OUI_WIDTH = 3 +XCVR_VENDOR_PN_OFFSET = 40 +XCVR_VENDOR_PN_WIDTH = 16 +XCVR_HW_REV_OFFSET = 56 +XCVR_HW_REV_WIDTH_QSFP = 2 +XCVR_HW_REV_WIDTH_SFP = 4 +XCVR_VENDOR_SN_OFFSET = 68 +XCVR_VENDOR_SN_WIDTH = 16 +XCVR_VENDOR_DATE_OFFSET = 84 +XCVR_VENDOR_DATE_WIDTH = 8 +XCVR_DOM_CAPABILITY_OFFSET = 92 +XCVR_DOM_CAPABILITY_WIDTH = 2 + +XCVR_INTERFACE_DATA_START = 0 +XCVR_INTERFACE_DATA_SIZE = 92 + +QSFP_DOM_BULK_DATA_START = 22 +QSFP_DOM_BULK_DATA_SIZE = 36 +SFP_DOM_BULK_DATA_START = 96 +SFP_DOM_BULK_DATA_SIZE = 10 + +# Offset for values in QSFP eeprom +QSFP_DOM_REV_OFFSET = 1 +QSFP_DOM_REV_WIDTH = 1 +QSFP_TEMPE_OFFSET = 22 +QSFP_TEMPE_WIDTH = 2 +QSFP_VOLT_OFFSET = 26 +QSFP_VOLT_WIDTH = 2 +QSFP_VERSION_COMPLIANCE_OFFSET = 1 +QSFP_VERSION_COMPLIANCE_WIDTH = 1 +QSFP_CHANNL_MON_OFFSET = 34 +QSFP_CHANNL_MON_WIDTH = 16 +QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH = 24 +QSFP_CHANNL_DISABLE_STATUS_OFFSET = 86 +QSFP_CHANNL_DISABLE_STATUS_WIDTH = 1 +QSFP_CHANNL_RX_LOS_STATUS_OFFSET = 3 +QSFP_CHANNL_RX_LOS_STATUS_WIDTH = 1 +QSFP_CHANNL_TX_FAULT_STATUS_OFFSET = 4 +QSFP_CHANNL_TX_FAULT_STATUS_WIDTH = 1 +QSFP_CONTROL_OFFSET = 86 +QSFP_CONTROL_WIDTH = 8 +QSFP_MODULE_MONITOR_OFFSET = 0 +QSFP_MODULE_MONITOR_WIDTH = 9 +QSFP_MODULE_THRESHOLD_OFFSET = 512 +QSFP_MODULE_THRESHOLD_WIDTH = 24 +QSFP_CHANNEL_THRESHOLD_OFFSET = 560 +QSFP_CHANNEL_THRESHOLD_WIDTH = 16 +QSFP_POWEROVERRIDE_OFFSET = 93 +QSFP_POWEROVERRIDE_WIDTH = 1 +QSFP_POWEROVERRIDE_BIT = 0 +QSFP_POWERSET_BIT = 1 +QSFP_OPTION_VALUE_OFFSET = 192 +QSFP_OPTION_VALUE_WIDTH = 4 + +SFP_TEMPE_OFFSET = 96 +SFP_TEMPE_WIDTH = 2 +SFP_VOLT_OFFSET = 98 +SFP_VOLT_WIDTH = 2 +SFP_CHANNL_MON_OFFSET = 100 +SFP_CHANNL_MON_WIDTH = 6 +SFP_MODULE_THRESHOLD_OFFSET = 0 +SFP_MODULE_THRESHOLD_WIDTH = 40 +SFP_CHANNL_THRESHOLD_OFFSET = 112 +SFP_CHANNL_THRESHOLD_WIDTH = 2 +SFP_STATUS_CONTROL_OFFSET = 110 +SFP_STATUS_CONTROL_WIDTH = 1 +SFP_TX_DISABLE_HARD_BIT = 7 +SFP_TX_DISABLE_SOFT_BIT = 6 + +qsfp_cable_length_tup = ('Length(km)', 'Length OM3(2m)', + 'Length OM2(m)', 'Length OM1(m)', + 'Length Cable Assembly(m)') + +sfp_cable_length_tup = ('LengthSMFkm-UnitsOfKm', 'LengthSMF(UnitsOf100m)', + 'Length50um(UnitsOf10m)', 'Length62.5um(UnitsOfm)', + 'LengthCable(UnitsOfm)', 'LengthOM3(UnitsOf10m)') + +sfp_compliance_code_tup = ('10GEthernetComplianceCode', 'InfinibandComplianceCode', + 'ESCONComplianceCodes', 'SONETComplianceCodes', + 'EthernetComplianceCodes','FibreChannelLinkLength', + 'FibreChannelTechnology', 'SFP+CableTechnology', + 'FibreChannelTransmissionMedia','FibreChannelSpeed') + +qsfp_compliance_code_tup = ('10/40G Ethernet Compliance Code', 'SONET Compliance codes', + 'SAS/SATA compliance codes', 'Gigabit Ethernet Compliant codes', + 'Fibre Channel link length/Transmitter Technology', + 'Fibre Channel transmission media', 'Fibre Channel Speed') + +SFP_TYPE = "SFP" +QSFP_TYPE = "QSFP" + + +class Sfp(SfpBase): + """Platform-specific Sfp class""" + + dom_supported = True + dom_temp_supported = True + dom_volt_supported = True + dom_rx_power_supported = True + dom_tx_power_supported = True + dom_tx_disable_supported = True + calibration = 1 + + # Path to QSFP sysfs + PLATFORM_ROOT_PATH = "/usr/share/sonic/device" + PMON_HWSKU_PATH = "/usr/share/sonic/hwsku" + HOST_CHK_CMD = "docker > /dev/null 2>&1" + + PLATFORM = "x86_64-centec_v682_48x8c-r0" + HWSKU = "V682-48x8c" + + def __init__(self, sfp_index, sfp_type): + if os.path.isdir(CONTAINER_PLATFORM_PATH): + platform_path = CONTAINER_PLATFORM_PATH + else: + platform = device_info.get_platform() + if platform is None: + raise + platform_path = os.path.join(HOST_DEVICE_PATH, platform) + + port_config_file = "/".join([platform_path, self.HWSKU, "port_config.ini"]) + try: + f = open(port_config_file) + except: + raise + for line in f: + line.strip() + if re.search('^#', line) is not None: + Port_cfg = collections.namedtuple('Port_cfg', line.split()[1:]) + break + f.close() + f = open(port_config_file) + self._port_cfgs = [Port_cfg(*tuple((line.strip().split()))) + for line in f if re.search('^#', line) is None] + f.close() + + # Port number + self.PORT_START = 256 + self.PORT_END = 0 + self.QSFP_START = 48 + self.QSFP_END = 0 + + for port_cfg in self._port_cfgs: + if int(port_cfg.index) <= self.PORT_START: + self.PORT_START = int(port_cfg.index) + elif int(port_cfg.index) >= self.PORT_END: + self.PORT_END = int(port_cfg.index) + self.QSFP_END = self.PORT_END + + # Init index + self.index = sfp_index + self.port_num = self.index + #self.dom_supported = False + self.sfp_type = sfp_type + # Init eeprom path + eeprom_path = '/sys/bus/i2c/devices/i2c-{0}/{0}-0050/eeprom' + self.port_to_eeprom_mapping = {} + self.port_to_i2c_mapping = { + # mac i2c presence enable(or reset for qsfp) + 32 : (13, 0x36, 0x11, 0, 0x36, 0x0e, 0), + 33 : (12, 0x36, 0x11, 1, 0x36, 0x0e, 1), + 34 : (11, 0x36, 0x11, 2, 0x36, 0x0e, 2), + 35 : (10, 0x36, 0x11, 3, 0x36, 0x0e, 3), + 0 : (17, 0x36, 0x11, 4, 0x36, 0x0e, 4), + 4 : (16, 0x36, 0x11, 5, 0x36, 0x0e, 5), + 8 : (15, 0x36, 0x11, 6, 0x36, 0x0e, 6), + 12 : (14, 0x36, 0x11, 7, 0x36, 0x0e, 7), + 16 : (21, 0x36, 0x12, 0, 0x36, 0x0f, 0), + 20 : (20, 0x36, 0x12, 1, 0x36, 0x0f, 1), + 24 : (19, 0x36, 0x12, 2, 0x36, 0x0f, 2), + 28 : (18, 0x36, 0x12, 3, 0x36, 0x0f, 3), + 40 : (25, 0x36, 0x12, 4, 0x36, 0x0f, 4), + 44 : (24, 0x36, 0x12, 5, 0x36, 0x0f, 5), + 48 : (23, 0x36, 0x12, 6, 0x36, 0x0f, 6), + 52 : (22, 0x36, 0x12, 7, 0x36, 0x0f, 7), + 56 : (29, 0x36, 0x13, 0, 0x36, 0x10, 0), + 60 : (28, 0x36, 0x13, 1, 0x36, 0x10, 1), + 64 : (27, 0x36, 0x13, 2, 0x36, 0x10, 2), + 68 : (26, 0x36, 0x13, 3, 0x36, 0x10, 3), + 72 : (33, 0x36, 0x13, 4, 0x36, 0x10, 4), + 73 : (32, 0x36, 0x13, 5, 0x36, 0x10, 5), + 74 : (31, 0x36, 0x13, 6, 0x36, 0x10, 6), + 75 : (30, 0x36, 0x13, 7, 0x36, 0x10, 7), + 232 : (37, 0x37, 0x11, 0, 0x37, 0x0e, 0), + 233 : (36, 0x37, 0x11, 1, 0x37, 0x0e, 1), + 234 : (35, 0x37, 0x11, 2, 0x37, 0x0e, 2), + 235 : (34, 0x37, 0x11, 3, 0x37, 0x0e, 3), + 200 : (41, 0x37, 0x11, 4, 0x37, 0x0e, 4), + 204 : (40, 0x37, 0x11, 5, 0x37, 0x0e, 5), + 208 : (39, 0x37, 0x11, 6, 0x37, 0x0e, 6), + 212 : (38, 0x37, 0x11, 7, 0x37, 0x0e, 7), + 216 : (45, 0x37, 0x12, 0, 0x37, 0x0f, 0), + 220 : (44, 0x37, 0x12, 1, 0x37, 0x0f, 1), + 224 : (43, 0x37, 0x12, 2, 0x37, 0x0f, 2), + 228 : (42, 0x37, 0x12, 3, 0x37, 0x0f, 3), + 160 : (49, 0x37, 0x12, 4, 0x37, 0x0f, 4), + 164 : (48, 0x37, 0x12, 5, 0x37, 0x0f, 5), + 168 : (47, 0x37, 0x12, 6, 0x37, 0x0f, 6), + 172 : (46, 0x37, 0x12, 7, 0x37, 0x0f, 7), + 176 : (53, 0x37, 0x13, 0, 0x37, 0x10, 0), + 180 : (52, 0x37, 0x13, 1, 0x37, 0x10, 1), + 184 : (51, 0x37, 0x13, 2, 0x37, 0x10, 2), + 188 : (50, 0x37, 0x13, 3, 0x37, 0x10, 3), + 192 : (57, 0x37, 0x13, 4, 0x37, 0x10, 4), + 193 : (56, 0x37, 0x13, 5, 0x37, 0x10, 5), + 194 : (55, 0x37, 0x13, 6, 0x37, 0x10, 6), + 195 : (54, 0x37, 0x13, 7, 0x37, 0x10, 7), + 120 : (61, 0x36, 0x14, 0, 0x36, 0x05, 0), + 121 : (61, 0x36, 0x14, 0, 0x36, 0x05, 0), + 122 : (61, 0x36, 0x14, 0, 0x36, 0x05, 0), + 123 : (61, 0x36, 0x14, 0, 0x36, 0x05, 0), + 124 : (60, 0x36, 0x14, 1, 0x36, 0x05, 1), + 125 : (60, 0x36, 0x14, 1, 0x36, 0x05, 1), + 126 : (60, 0x36, 0x14, 1, 0x36, 0x05, 1), + 127 : (60, 0x36, 0x14, 1, 0x36, 0x05, 1), + 80 : (59, 0x36, 0x14, 2, 0x36, 0x05, 2), + 81 : (59, 0x36, 0x14, 2, 0x36, 0x05, 2), + 82 : (59, 0x36, 0x14, 2, 0x36, 0x05, 2), + 83 : (59, 0x36, 0x14, 2, 0x36, 0x05, 2), + 84 : (58, 0x36, 0x14, 3, 0x36, 0x05, 3), + 85 : (58, 0x36, 0x14, 3, 0x36, 0x05, 3), + 86 : (58, 0x36, 0x14, 3, 0x36, 0x05, 3), + 87 : (58, 0x36, 0x14, 3, 0x36, 0x05, 3), + 240 : (65, 0x37, 0x14, 0, 0x37, 0x05, 0), + 241 : (65, 0x37, 0x14, 0, 0x37, 0x05, 0), + 242 : (65, 0x37, 0x14, 0, 0x37, 0x05, 0), + 243 : (65, 0x37, 0x14, 0, 0x37, 0x05, 0), + 244 : (64, 0x37, 0x14, 1, 0x37, 0x05, 1), + 245 : (64, 0x37, 0x14, 1, 0x37, 0x05, 1), + 246 : (64, 0x37, 0x14, 1, 0x37, 0x05, 1), + 247 : (64, 0x37, 0x14, 1, 0x37, 0x05, 1), + 280 : (63, 0x37, 0x14, 2, 0x37, 0x05, 2), + 281 : (63, 0x37, 0x14, 2, 0x37, 0x05, 2), + 282 : (63, 0x37, 0x14, 2, 0x37, 0x05, 2), + 283 : (63, 0x37, 0x14, 2, 0x37, 0x05, 2), + 284 : (62, 0x37, 0x14, 3, 0x37, 0x05, 3), + 285 : (62, 0x37, 0x14, 3, 0x37, 0x05, 3), + 286 : (62, 0x37, 0x14, 3, 0x37, 0x05, 3), + 287 : (62, 0x37, 0x14, 3, 0x37, 0x05, 3) + } + + for port_cfg in self._port_cfgs: + i2c_idx = self.port_to_i2c_mapping[int(port_cfg.lanes.split(',')[0])][0] + port_eeprom_path = eeprom_path.format(i2c_idx) + self.port_to_eeprom_mapping[int(port_cfg.index)] = port_eeprom_path + + self.info_dict_keys = ['type', 'hardware_rev', 'serial', 'manufacturer', + 'model', 'connector', 'encoding', 'ext_identifier', + 'ext_rateselect_compliance', 'cable_type', 'cable_length', + 'nominal_bit_rate', 'specification_compliance', 'vendor_date', + 'vendor_oui', 'application_advertisement'] + + self.dom_dict_keys = ['rx_los', 'tx_fault', 'reset_status', 'power_lpmode', + 'tx_disable', 'tx_disable_channel', 'temperature', 'voltage', + 'rx1power', 'rx2power', 'rx3power', 'rx4power', 'tx1bias', 'tx2bias', + 'tx3bias', 'tx4bias', 'tx1power', 'tx2power', 'tx3power', 'tx4power'] + + self.threshold_dict_keys = ['temphighalarm', 'temphighwarning', + 'templowalarm', 'templowwarning', 'vcchighalarm', 'vcchighwarning', + 'vcclowalarm', 'vcclowwarning', 'rxpowerhighalarm', 'rxpowerhighwarning', + 'rxpowerlowalarm', 'rxpowerlowwarning', 'txpowerhighalarm', + 'txpowerhighwarning', 'txpowerlowalarm', 'txpowerlowwarning', + 'txbiashighalarm', 'txbiashighwarning', 'txbiaslowalarm', 'txbiaslowwarning'] + + SfpBase.__init__(self) + + + def _convert_string_to_num(self, value_str): + if "-inf" in value_str: + return 'N/A' + elif "Unknown" in value_str: + return 'N/A' + elif 'dBm' in value_str: + t_str = value_str.rstrip('dBm') + return float(t_str) + elif 'mA' in value_str: + t_str = value_str.rstrip('mA') + return float(t_str) + elif 'C' in value_str: + t_str = value_str.rstrip('C') + return float(t_str) + elif 'Volts' in value_str: + t_str = value_str.rstrip('Volts') + return float(t_str) + else: + return 'N/A' + + def __read_txt_file(self, file_path): + try: + with open(file_path, 'r') as fd: + data = fd.read() + return data.strip() + except IOError: + pass + return "" + + def __is_host(self): + return os.system(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 get_presence(self): + """ + Retrieves the presence of the SFP module + Returns: + bool: True if SFP module is present, False if not + """ + # Check for invalid port_num + if self.port_num < self.PORT_START or self.port_num > self.PORT_END: + return False + + sfp_info = self.port_to_i2c_mapping[int(self._port_cfgs[self.port_num].lanes.split(',')[0])] + cmd = 'i2cget -y 0 {0} {1}'.format(sfp_info[1], sfp_info[2]) + presence = int(Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True).stdout.readline(), 16) + presence &= (1 << sfp_info[3]) + + try: + with open(self.port_to_eeprom_mapping[self.port_num], mode='rb', buffering=0) as fd: + fd.read() + except IOError: + return False + + return (presence == 0) + + 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): + eeprom_raw[n] = hex(raw[n])[2:].zfill(2) + except Exception: + eeprom_raw = None + finally: + if sysfsfile_eeprom: + sysfsfile_eeprom.close() + + return eeprom_raw + + def __convert_string_to_num(self, value_str): + if "-inf" in value_str: + return 'N/A' + elif "Unknown" in value_str: + return 'N/A' + elif 'dBm' in value_str: + t_str = value_str.rstrip('dBm') + return float(t_str) + elif 'mA' in value_str: + t_str = value_str.rstrip('mA') + return float(t_str) + elif 'C' in value_str: + t_str = value_str.rstrip('C') + return float(t_str) + elif 'Volts' in value_str: + t_str = value_str.rstrip('Volts') + return float(t_str) + else: + return 'N/A' + + def _dom_capability_detect(self): + if not self.get_presence(): + self.dom_supported = False + self.dom_temp_supported = False + self.dom_volt_supported = False + self.dom_rx_power_supported = False + self.dom_tx_power_supported = False + self.calibration = 0 + return + + if self.sfp_type == "QSFP": + self.calibration = 1 + sfpi_obj = sff8436InterfaceId() + if sfpi_obj is None: + self.dom_supported = False + offset = 128 + + # QSFP capability byte parse, through this byte can know whether it support tx_power or not. + # TODO: in the future when decided to migrate to support SFF-8636 instead of SFF-8436, + # need to add more code for determining the capability and version compliance + # in SFF-8636 dom capability definitions evolving with the versions. + qsfp_dom_capability_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) + if qsfp_dom_capability_raw is not None: + qsfp_dom_capability = int(qsfp_dom_capability_raw[0], 16) + + qsfp_version_compliance_raw = self.__read_eeprom_specific_bytes( + QSFP_VERSION_COMPLIANCE_OFFSET, QSFP_VERSION_COMPLIANCE_OFFSET) + if qsfp_version_compliance_raw is not None: + qsfp_version_compliance = int(qsfp_version_compliance_raw[0], 16) + else: + self.dom_supported = False + self.dom_temp_supported = False + self.dom_volt_supported = False + self.dom_rx_power_supported = False + self.dom_tx_power_supported = False + self.calibration = 0 + return + + if qsfp_version_compliance >= 0x08: + self.dom_temp_supported = (qsfp_dom_capability & 0x20 != 0) + self.dom_volt_supported = (qsfp_dom_capability & 0x10 != 0) + self.dom_rx_power_supported = (qsfp_dom_capability & 0x08 != 0) + self.dom_tx_power_supported = (qsfp_dom_capability & 0x04 != 0) + else: + self.dom_temp_supported = True + self.dom_volt_supported = True + self.dom_rx_power_supported = (qsfp_dom_capability & 0x08 != 0) + self.dom_tx_power_supported = True + self.dom_supported = True + self.calibration = 1 + self.dom_tx_disable_supported = True + else: + self.dom_supported = False + self.dom_temp_supported = False + self.dom_volt_supported = False + self.dom_rx_power_supported = False + self.dom_tx_power_supported = False + self.calibration = 0 + elif self.sfp_type == "SFP": + sfpi_obj = sff8472InterfaceId() + if sfpi_obj is None: + return None + sfp_dom_capability_raw = self.__read_eeprom_specific_bytes( + XCVR_DOM_CAPABILITY_OFFSET, XCVR_DOM_CAPABILITY_WIDTH) + if sfp_dom_capability_raw is not None: + sfp_dom_capability = int(sfp_dom_capability_raw[0], 16) + self.dom_supported = (sfp_dom_capability & 0x40 != 0) + if self.dom_supported: + self.dom_temp_supported = True + self.dom_volt_supported = True + self.dom_rx_power_supported = True + self.dom_tx_power_supported = True + if sfp_dom_capability & 0x20 != 0: + self.calibration = 1 + elif sfp_dom_capability & 0x10 != 0: + self.calibration = 2 + else: + self.calibration = 0 + else: + self.dom_temp_supported = False + self.dom_volt_supported = False + self.dom_rx_power_supported = False + self.dom_tx_power_supported = False + self.calibration = 0 + self.dom_tx_disable_supported = (int(sfp_dom_capability_raw[1], 16) & 0x40 != 0) + else: + self.dom_supported = False + self.dom_temp_supported = False + self.dom_volt_supported = False + self.dom_rx_power_supported = False + self.dom_tx_power_supported = False + + def get_transceiver_info(self): + """ + Retrieves transceiver info of this SFP + Returns: + A dict which contains following keys/values : + ======================================================================== + keys |Value Format |Information + ---------------------------|---------------|---------------------------- + type |1*255VCHAR |type of SFP + hardware_rev |1*255VCHAR |hardware version of SFP + serial |1*255VCHAR |serial number of the SFP + manufacturer |1*255VCHAR |SFP vendor name + model |1*255VCHAR |SFP model name + connector |1*255VCHAR |connector information + encoding |1*255VCHAR |encoding information + ext_identifier |1*255VCHAR |extend identifier + ext_rateselect_compliance |1*255VCHAR |extended rateSelect compliance + cable_length |INT |cable length in m + nominal_bit_rate |INT |nominal bit rate by 100Mbs + specification_compliance |1*255VCHAR |specification compliance + vendor_date |1*255VCHAR |vendor date + vendor_oui |1*255VCHAR |vendor OUI + application_advertisement |1*255VCHAR |supported applications advertisement + ======================================================================== + """ + + transceiver_info_dict = {} + compliance_code_dict = {} + transceiver_info_dict = dict.fromkeys(self.info_dict_keys, 'N/A') + transceiver_info_dict['specification_compliance'] = '{}' + if not self.get_presence(): + return transceiver_info_dict + + if self.sfp_type == QSFP_TYPE: + offset = QSFP_INFO_OFFSET + vendor_rev_width = XCVR_HW_REV_WIDTH_QSFP + interface_info_bulk_width = XCVR_INTFACE_BULK_WIDTH_QSFP + + sfpi_obj = sff8436InterfaceId() + if sfpi_obj is None: + print("Error: sfp_object open failed") + return transceiver_info_dict + + elif self.sfp_type == SFP_TYPE: + offset = SFP_INFO_OFFSET + vendor_rev_width = XCVR_HW_REV_WIDTH_SFP + interface_info_bulk_width = XCVR_INTFACE_BULK_WIDTH_SFP + + sfpi_obj = sff8472InterfaceId() + if sfpi_obj is None: + print("Error: sfp_object open failed") + return transceiver_info_dict + else: + return transceiver_info_dict + + # Add retry for xcvr eeprom to get ready + max_retry = 10 + for i in range(0,max_retry): + sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes( + offset + XCVR_INTERFACE_DATA_START, XCVR_INTERFACE_DATA_SIZE) + if sfp_interface_bulk_raw is not None: + break + else: + if not self.get_presence(): + return transceiver_info_dict + elif i == max_retry-1: + pass + else: + time.sleep(0.5) + + if sfp_interface_bulk_raw is None: + return transceiver_info_dict + + start = XCVR_INTFACE_BULK_OFFSET - XCVR_INTERFACE_DATA_START + end = start + interface_info_bulk_width + sfp_interface_bulk_data = sfpi_obj.parse_sfp_info_bulk(sfp_interface_bulk_raw[start : end], 0) + + start = XCVR_VENDOR_NAME_OFFSET - XCVR_INTERFACE_DATA_START + end = start + XCVR_VENDOR_NAME_WIDTH + sfp_vendor_name_data = sfpi_obj.parse_vendor_name(sfp_interface_bulk_raw[start : end], 0) + + start = XCVR_VENDOR_PN_OFFSET - XCVR_INTERFACE_DATA_START + end = start + XCVR_VENDOR_PN_WIDTH + sfp_vendor_pn_data = sfpi_obj.parse_vendor_pn(sfp_interface_bulk_raw[start : end], 0) + + start = XCVR_HW_REV_OFFSET - XCVR_INTERFACE_DATA_START + end = start + vendor_rev_width + sfp_vendor_rev_data = sfpi_obj.parse_vendor_rev(sfp_interface_bulk_raw[start : end], 0) + + start = XCVR_VENDOR_SN_OFFSET - XCVR_INTERFACE_DATA_START + end = start + XCVR_VENDOR_SN_WIDTH + sfp_vendor_sn_data = sfpi_obj.parse_vendor_sn(sfp_interface_bulk_raw[start : end], 0) + + start = XCVR_VENDOR_OUI_OFFSET - XCVR_INTERFACE_DATA_START + end = start + XCVR_VENDOR_OUI_WIDTH + sfp_vendor_oui_data = sfpi_obj.parse_vendor_oui(sfp_interface_bulk_raw[start : end], 0) + + start = XCVR_VENDOR_DATE_OFFSET - XCVR_INTERFACE_DATA_START + end = start + XCVR_VENDOR_DATE_WIDTH + sfp_vendor_date_data = sfpi_obj.parse_vendor_date(sfp_interface_bulk_raw[start : end], 0) + transceiver_info_dict['type'] = sfp_interface_bulk_data \ + ['data']['type']['value'] + transceiver_info_dict['manufacturer'] = sfp_vendor_name_data \ + ['data']['Vendor Name']['value'] + transceiver_info_dict['model'] = sfp_vendor_pn_data \ + ['data']['Vendor PN']['value'] + transceiver_info_dict['hardware_rev'] = sfp_vendor_rev_data \ + ['data']['Vendor Rev']['value'] + transceiver_info_dict['serial'] = sfp_vendor_sn_data \ + ['data']['Vendor SN']['value'] + transceiver_info_dict['vendor_oui'] = sfp_vendor_oui_data \ + ['data']['Vendor OUI']['value'] + transceiver_info_dict['vendor_date'] = sfp_vendor_date_data \ + ['data']['VendorDataCode(YYYY-MM-DD Lot)']['value'] + transceiver_info_dict['connector'] = sfp_interface_bulk_data \ + ['data']['Connector']['value'] + transceiver_info_dict['encoding'] = sfp_interface_bulk_data \ + ['data']['EncodingCodes']['value'] + transceiver_info_dict['ext_identifier'] = sfp_interface_bulk_data \ + ['data']['Extended Identifier']['value'] + transceiver_info_dict['ext_rateselect_compliance'] = sfp_interface_bulk_data \ + ['data']['RateIdentifier']['value'] + transceiver_info_dict['type_abbrv_name'] = 'N/A' + if self.sfp_type == QSFP_TYPE: + for key in qsfp_cable_length_tup: + if key in sfp_interface_bulk_data['data']: + transceiver_info_dict['cable_type'] = key + transceiver_info_dict['cable_length'] = str( + sfp_interface_bulk_data['data'][key]['value']) + + for key in qsfp_compliance_code_tup: + if key in sfp_interface_bulk_data['data']['Specification compliance']['value']: + compliance_code_dict[key] = sfp_interface_bulk_data \ + ['data']['Specification compliance']['value'][key]['value'] + transceiver_info_dict['specification_compliance'] = str(compliance_code_dict) + + transceiver_info_dict['nominal_bit_rate'] = str(sfp_interface_bulk_data \ + ['data']['Nominal Bit Rate(100Mbs)']['value']) + else: + for key in sfp_cable_length_tup: + if key in sfp_interface_bulk_data['data']: + transceiver_info_dict['cable_type'] = key + transceiver_info_dict['cable_length'] = str( + sfp_interface_bulk_data['data'][key]['value']) + + for key in sfp_compliance_code_tup: + if key in sfp_interface_bulk_data['data']['Specification compliance']['value']: + compliance_code_dict[key] = sfp_interface_bulk_data \ + ['data']['Specification compliance']['value'][key]['value'] + transceiver_info_dict['specification_compliance'] = str(compliance_code_dict) + + transceiver_info_dict['nominal_bit_rate'] = str(sfp_interface_bulk_data \ + ['data']['NominalSignallingRate(UnitsOf100Mbd)']['value']) + + return transceiver_info_dict + + def get_transceiver_bulk_status(self): + """ + Retrieves transceiver bulk status of this SFP + Returns: + A dict which contains following keys/values : + ======================================================================== + keys |Value Format |Information + ---------------------------|---------------|---------------------------- + rx_los |BOOLEAN |RX loss-of-signal status, True if has RX los, False if not. + tx_fault |BOOLEAN |TX fault status, True if has TX fault, False if not. + reset_status |BOOLEAN |reset status, True if SFP in reset, False if not. + lp_mode |BOOLEAN |low power mode status, True in lp mode, False if not. + tx_disable |BOOLEAN |TX disable status, True TX disabled, False if not. + tx_disabled_channel |HEX |disabled TX channels in hex, bits 0 to 3 represent channel 0 + | |to channel 3. + temperature |INT |module temperature in Celsius + voltage |INT |supply voltage in mV + txbias |INT |TX Bias Current in mA, n is the channel number, + | |for example, tx2bias stands for tx bias of channel 2. + rxpower |INT |received optical power in mW, n is the channel number, + | |for example, rx2power stands for rx power of channel 2. + txpower |INT |TX output power in mW, n is the channel number, + | |for example, tx2power stands for tx power of channel 2. + ======================================================================== + """ + + if not self.get_presence(): + return None + + self._dom_capability_detect() + + if self.sfp_type == QSFP_TYPE: + sfpd_obj = sff8436Dom() + sfpi_obj = sff8436InterfaceId() + + if not sfpi_obj or not sfpd_obj: + return None + + transceiver_dom_info_dict = dict.fromkeys(self.dom_dict_keys, 'N/A') + offset = QSFP_DOM_OFFSET + offset_xcvr = QSFP_INFO_OFFSET + + # QSFP capability byte parse, through this byte can know whether it support tx_power or not. + # TODO: in the future when decided to migrate to support SFF-8636 instead of SFF-8436, + # need to add more code for determining the capability and version compliance + # in SFF-8636 dom capability definitions evolving with the versions. + qsfp_dom_capability_raw = self.__read_eeprom_specific_bytes( + (offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) + if qsfp_dom_capability_raw is not None: + qsfp_dom_capability_data = sfpi_obj.parse_dom_capability( + qsfp_dom_capability_raw, 0) + else: + return None + + dom_temperature_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_TEMPE_OFFSET), QSFP_TEMPE_WIDTH) + if dom_temperature_raw is not None: + dom_temperature_data = sfpd_obj.parse_temperature( + dom_temperature_raw, 0) + transceiver_dom_info_dict['temperature'] = dom_temperature_data['data']['Temperature']['value'] + + dom_voltage_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_VOLT_OFFSET), QSFP_VOLT_WIDTH) + if dom_voltage_raw is not None: + dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) + transceiver_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc']['value'] + + qsfp_dom_rev_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_DOM_REV_OFFSET), QSFP_DOM_REV_WIDTH) + if qsfp_dom_rev_raw is not None: + qsfp_dom_rev_data = sfpd_obj.parse_sfp_dom_rev(qsfp_dom_rev_raw, 0) + qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value'] + + # The tx_power monitoring is only available on QSFP which compliant with SFF-8636 + # and claimed that it support tx_power with one indicator bit. + dom_channel_monitor_data = {} + dom_channel_monitor_raw = None + qsfp_tx_power_support = qsfp_dom_capability_data['data']['Tx_power_support']['value'] + if (qsfp_dom_rev[0:8] != 'SFF-8636' or (qsfp_dom_rev[0:8] == 'SFF-8636' and qsfp_tx_power_support != 'on')): + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WIDTH) + if dom_channel_monitor_raw is not None: + dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params( + dom_channel_monitor_raw, 0) + + else: + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) + if dom_channel_monitor_raw is not None: + dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power( + dom_channel_monitor_raw, 0) + transceiver_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TX1Power']['value'] + transceiver_dom_info_dict['tx2power'] = dom_channel_monitor_data['data']['TX2Power']['value'] + transceiver_dom_info_dict['tx3power'] = dom_channel_monitor_data['data']['TX3Power']['value'] + transceiver_dom_info_dict['tx4power'] = dom_channel_monitor_data['data']['TX4Power']['value'] + + if dom_channel_monitor_raw: + transceiver_dom_info_dict['rx1power'] = dom_channel_monitor_data['data']['RX1Power']['value'] + transceiver_dom_info_dict['rx2power'] = dom_channel_monitor_data['data']['RX2Power']['value'] + transceiver_dom_info_dict['rx3power'] = dom_channel_monitor_data['data']['RX3Power']['value'] + transceiver_dom_info_dict['rx4power'] = dom_channel_monitor_data['data']['RX4Power']['value'] + transceiver_dom_info_dict['tx1bias'] = dom_channel_monitor_data['data']['TX1Bias']['value'] + transceiver_dom_info_dict['tx2bias'] = dom_channel_monitor_data['data']['TX2Bias']['value'] + transceiver_dom_info_dict['tx3bias'] = dom_channel_monitor_data['data']['TX3Bias']['value'] + transceiver_dom_info_dict['tx4bias'] = dom_channel_monitor_data['data']['TX4Bias']['value'] + elif self.sfp_type == SFP_TYPE: + sfpd_obj = sff8472Dom() + if not sfpd_obj: + return None + + eeprom_ifraw = self.__read_eeprom_specific_bytes(0, SFP_DOM_OFFSET) + if eeprom_ifraw is not None: + sfpi_obj = sff8472InterfaceId(eeprom_ifraw) + cal_type = sfpi_obj.get_calibration_type() + sfpd_obj._calibration_type = cal_type + + offset = SFP_DOM_OFFSET + transceiver_dom_info_dict = dict.fromkeys(self.dom_dict_keys, 'N/A') + dom_temperature_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH) + + if dom_temperature_raw is not None: + dom_temperature_data = sfpd_obj.parse_temperature( + dom_temperature_raw, 0) + transceiver_dom_info_dict['temperature'] = dom_temperature_data['data']['Temperature']['value'] + + dom_voltage_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH) + if dom_voltage_raw is not None: + dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) + transceiver_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc']['value'] + + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH) + if dom_channel_monitor_raw is not None: + dom_voltage_data = sfpd_obj.parse_channel_monitor_params( + dom_channel_monitor_raw, 0) + transceiver_dom_info_dict['tx1power'] = dom_voltage_data['data']['TXPower']['value'] + transceiver_dom_info_dict['rx1power'] = dom_voltage_data['data']['RXPower']['value'] + transceiver_dom_info_dict['tx1bias'] = dom_voltage_data['data']['TXBias']['value'] + else: + return None + + for key in transceiver_dom_info_dict: + transceiver_dom_info_dict[key] = self._convert_string_to_num( + transceiver_dom_info_dict[key]) + + transceiver_dom_info_dict['rx_los'] = self.get_rx_los() + transceiver_dom_info_dict['tx_fault'] = self.get_tx_fault() + transceiver_dom_info_dict['reset_status'] = self.get_reset_status() + transceiver_dom_info_dict['lp_mode'] = self.get_lpmode() + transceiver_dom_info_dict['tx_disable'] = self.get_tx_disable() + transceiver_dom_info_dict['tx_disable_channel'] = self.get_tx_disable_channel() + + return transceiver_dom_info_dict + + def get_transceiver_threshold_info(self): + """ + Retrieves transceiver threshold info of this SFP + + Returns: + A dict which contains following keys/values : + ======================================================================== + keys |Value Format |Information + ---------------------------|---------------|---------------------------- + temphighalarm |FLOAT |High Alarm Threshold value of temperature in Celsius. + templowalarm |FLOAT |Low Alarm Threshold value of temperature in Celsius. + temphighwarning |FLOAT |High Warning Threshold value of temperature in Celsius. + templowwarning |FLOAT |Low Warning Threshold value of temperature in Celsius. + vcchighalarm |FLOAT |High Alarm Threshold value of supply voltage in mV. + vcclowalarm |FLOAT |Low Alarm Threshold value of supply voltage in mV. + vcchighwarning |FLOAT |High Warning Threshold value of supply voltage in mV. + vcclowwarning |FLOAT |Low Warning Threshold value of supply voltage in mV. + rxpowerhighalarm |FLOAT |High Alarm Threshold value of received power in dBm. + rxpowerlowalarm |FLOAT |Low Alarm Threshold value of received power in dBm. + rxpowerhighwarning |FLOAT |High Warning Threshold value of received power in dBm. + rxpowerlowwarning |FLOAT |Low Warning Threshold value of received power in dBm. + txpowerhighalarm |FLOAT |High Alarm Threshold value of transmit power in dBm. + txpowerlowalarm |FLOAT |Low Alarm Threshold value of transmit power in dBm. + txpowerhighwarning |FLOAT |High Warning Threshold value of transmit power in dBm. + txpowerlowwarning |FLOAT |Low Warning Threshold value of transmit power in dBm. + txbiashighalarm |FLOAT |High Alarm Threshold value of tx Bias Current in mA. + txbiaslowalarm |FLOAT |Low Alarm Threshold value of tx Bias Current in mA. + txbiashighwarning |FLOAT |High Warning Threshold value of tx Bias Current in mA. + txbiaslowwarning |FLOAT |Low Warning Threshold value of tx Bias Current in mA. + ======================================================================== + """ + transceiver_dom_threshold_info_dict_keys = ['temphighalarm', 'temphighwarning', 'templowalarm', 'templowwarning', + 'vcchighalarm', 'vcchighwarning', 'vcclowalarm', 'vcclowwarning', + 'rxpowerhighalarm', 'rxpowerhighwarning', 'rxpowerlowalarm', 'rxpowerlowwarning', + 'txpowerhighalarm', 'txpowerhighwarning', 'txpowerlowalarm', 'txpowerlowwarning', + 'txbiashighalarm', 'txbiashighwarning', 'txbiaslowalarm', 'txbiaslowwarning'] + + if self.sfp_type == QSFP_TYPE: + sfpd_obj = sff8436Dom() + if not self.get_presence() or not sfpd_obj: + return None + DOM_OFFSET = 0 + transceiver_dom_threshold_dict = dict.fromkeys(transceiver_dom_threshold_info_dict_keys, 'N/A') + offset = DOM_OFFSET + + dom_module_threshold_raw = self.__read_eeprom_specific_bytes((offset + QSFP_MODULE_THRESHOLD_OFFSET), QSFP_MODULE_THRESHOLD_WIDTH) + if dom_module_threshold_raw is not None: + module_threshold_values = sfpd_obj.parse_module_threshold_values(dom_module_threshold_raw, 0) + module_threshold_data = module_threshold_values.get('data') + if module_threshold_data: + transceiver_dom_threshold_dict['temphighalarm'] = module_threshold_data['TempHighAlarm']['value'] + transceiver_dom_threshold_dict['templowalarm'] = module_threshold_data['TempLowAlarm']['value'] + transceiver_dom_threshold_dict['temphighwarning'] = module_threshold_data['TempHighWarning']['value'] + transceiver_dom_threshold_dict['templowwarning'] = module_threshold_data['TempLowWarning']['value'] + transceiver_dom_threshold_dict['vcchighalarm'] = module_threshold_data['VccHighAlarm']['value'] + transceiver_dom_threshold_dict['vcclowalarm'] = module_threshold_data['VccLowAlarm']['value'] + transceiver_dom_threshold_dict['vcchighwarning'] = module_threshold_data['VccHighWarning']['value'] + transceiver_dom_threshold_dict['vcclowwarning'] = module_threshold_data['VccLowWarning']['value'] + + dom_channel_thres_raw = self.__read_eeprom_specific_bytes((offset + QSFP_CHANNEL_THRESHOLD_OFFSET), QSFP_CHANNEL_THRESHOLD_WIDTH) + if dom_channel_thres_raw is not None: + channel_threshold_values = sfpd_obj.parse_channel_threshold_values(dom_channel_thres_raw, 0) + channel_threshold_data = channel_threshold_values.get('data') + else: + channel_threshold_data = None + if channel_threshold_data: + transceiver_dom_threshold_dict['rxpowerhighalarm'] = channel_threshold_data['RxPowerHighAlarm']['value'] + transceiver_dom_threshold_dict['rxpowerlowalarm'] = channel_threshold_data['RxPowerLowAlarm']['value'] + transceiver_dom_threshold_dict['rxpowerhighwarning'] = channel_threshold_data['RxPowerHighWarning']['value'] + transceiver_dom_threshold_dict['rxpowerlowwarning'] = channel_threshold_data['RxPowerLowWarning']['value'] + transceiver_dom_threshold_dict['txpowerhighalarm'] = "0.0dBm" + transceiver_dom_threshold_dict['txpowerlowalarm'] = "0.0dBm" + transceiver_dom_threshold_dict['txpowerhighwarning'] = "0.0dBm" + transceiver_dom_threshold_dict['txpowerlowwarning'] = "0.0dBm" + transceiver_dom_threshold_dict['txbiashighalarm'] = channel_threshold_data['TxBiasHighAlarm']['value'] + transceiver_dom_threshold_dict['txbiaslowalarm'] = channel_threshold_data['TxBiasLowAlarm']['value'] + transceiver_dom_threshold_dict['txbiashighwarning'] = channel_threshold_data['TxBiasHighWarning']['value'] + transceiver_dom_threshold_dict['txbiaslowwarning'] = channel_threshold_data['TxBiasLowWarning']['value'] + + for key in transceiver_dom_threshold_dict: + transceiver_dom_threshold_dict[key] = self.__convert_string_to_num(transceiver_dom_threshold_dict[key]) + + return transceiver_dom_threshold_dict + + elif self.sfp_type == SFP_TYPE: + sfpd_obj = sff8472Dom() + + if not self.get_presence() and not sfpd_obj: + return None + DOM_OFFSET = 256 + eeprom_ifraw = self.__read_eeprom_specific_bytes(0, DOM_OFFSET) + if eeprom_ifraw is not None: + sfpi_obj = sff8472InterfaceId(eeprom_ifraw) + cal_type = sfpi_obj.get_calibration_type() + sfpd_obj._calibration_type = cal_type + + offset = DOM_OFFSET + transceiver_dom_threshold_info_dict = dict.fromkeys(transceiver_dom_threshold_info_dict_keys, 'N/A') + dom_module_threshold_raw = self.__read_eeprom_specific_bytes((offset + SFP_MODULE_THRESHOLD_OFFSET), SFP_MODULE_THRESHOLD_WIDTH) + if dom_module_threshold_raw is not None: + dom_module_threshold_data = sfpd_obj.parse_alarm_warning_threshold(dom_module_threshold_raw, 0) + + transceiver_dom_threshold_info_dict['temphighalarm'] = dom_module_threshold_data['data']['TempHighAlarm']['value'] + transceiver_dom_threshold_info_dict['templowalarm'] = dom_module_threshold_data['data']['TempLowAlarm']['value'] + transceiver_dom_threshold_info_dict['temphighwarning'] = dom_module_threshold_data['data']['TempHighWarning']['value'] + transceiver_dom_threshold_info_dict['templowwarning'] = dom_module_threshold_data['data']['TempLowWarning']['value'] + + transceiver_dom_threshold_info_dict['vcchighalarm'] = dom_module_threshold_data['data']['VoltageHighAlarm']['value'] + transceiver_dom_threshold_info_dict['vcclowalarm'] = dom_module_threshold_data['data']['VoltageLowAlarm']['value'] + transceiver_dom_threshold_info_dict['vcchighwarning'] = dom_module_threshold_data['data']['VoltageHighWarning']['value'] + transceiver_dom_threshold_info_dict['vcclowwarning'] = dom_module_threshold_data['data']['VoltageLowWarning']['value'] + + transceiver_dom_threshold_info_dict['txbiashighalarm'] = dom_module_threshold_data['data']['BiasHighAlarm']['value'] + transceiver_dom_threshold_info_dict['txbiaslowalarm'] = dom_module_threshold_data['data']['BiasLowAlarm']['value'] + transceiver_dom_threshold_info_dict['txbiashighwarning'] = dom_module_threshold_data['data']['BiasHighWarning']['value'] + transceiver_dom_threshold_info_dict['txbiaslowwarning'] = dom_module_threshold_data['data']['BiasLowWarning']['value'] + + transceiver_dom_threshold_info_dict['txpowerhighalarm'] = dom_module_threshold_data['data']['TXPowerHighAlarm']['value'] + transceiver_dom_threshold_info_dict['txpowerlowalarm'] = dom_module_threshold_data['data']['TXPowerLowAlarm']['value'] + transceiver_dom_threshold_info_dict['txpowerhighwarning'] = dom_module_threshold_data['data']['TXPowerHighWarning']['value'] + transceiver_dom_threshold_info_dict['txpowerlowwarning'] = dom_module_threshold_data['data']['TXPowerLowWarning']['value'] + + transceiver_dom_threshold_info_dict['rxpowerhighalarm'] = dom_module_threshold_data['data']['RXPowerHighAlarm']['value'] + transceiver_dom_threshold_info_dict['rxpowerlowalarm'] = dom_module_threshold_data['data']['RXPowerLowAlarm']['value'] + transceiver_dom_threshold_info_dict['rxpowerhighwarning'] = dom_module_threshold_data['data']['RXPowerHighWarning']['value'] + transceiver_dom_threshold_info_dict['rxpowerlowwarning'] = dom_module_threshold_data['data']['RXPowerLowWarning']['value'] + + for key in transceiver_dom_threshold_info_dict: + transceiver_dom_threshold_info_dict[key] = self.__convert_string_to_num(transceiver_dom_threshold_info_dict[key]) + + return transceiver_dom_threshold_info_dict + + else: + return None + + def get_reset_status(self): + """ + Retrieves the reset status of SFP + Returns: + A Boolean, True if reset enabled, False if disabled + """ + # Check for invalid port_num + if self.port_num < self.PORT_START or self.port_num > self.PORT_END or self.sfp_type == SFP_TYPE: + return False + + sfp_info = self.port_to_i2c_mapping[int(self._port_cfgs[self.port_num].lanes.split(',')[0])] + cmd = 'i2cget -y 0 {0} {1}'.format(sfp_info[4], sfp_info[5]) + reset_status = int(Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True).stdout.readline(), 16) + reset_status &= (1 << sfp_info[6]) + + return (reset_status == 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 not self.dom_supported: + return None + + rx_los_list = [] + + if self.sfp_type == QSFP_TYPE: + offset = 0 + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_CHANNL_RX_LOS_STATUS_OFFSET), QSFP_CHANNL_RX_LOS_STATUS_WIDTH) + 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) + elif self.sfp_type == SFP_TYPE: + offset = 256 + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_STATUS_CONTROL_OFFSET), SFP_STATUS_CONTROL_WIDTH) + 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 & 0x02 != 0) + else: + return None + else: + return None + + return rx_los_list + + def get_tx_fault(self): + """ + Retrieves the TX fault status of SFP + Returns: + A Boolean, True if SFP has TX fault, False if not + Note : TX fault status is lached until a call to get_tx_fault or a reset. + """ + if not self.dom_supported: + return None + + tx_fault_list = [] + + if self.sfp_type == QSFP_TYPE: + offset = 0 + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_CHANNL_TX_FAULT_STATUS_OFFSET), QSFP_CHANNL_TX_FAULT_STATUS_WIDTH) + 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) + elif self.sfp_type == SFP_TYPE: + offset = 256 + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_STATUS_CONTROL_OFFSET), SFP_STATUS_CONTROL_WIDTH) + 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 & 0x04 != 0) + else: + return None + else: + return None + + return tx_fault_list + + def get_tx_disable(self): + """ + Retrieves the tx_disable status of this SFP + Returns: + A Boolean, True if tx_disable is enabled, False if disabled + """ + if not self.dom_supported: + return None + + tx_disable_list = [] + + if self.sfp_type == QSFP_TYPE: + offset = 0 + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_CHANNL_DISABLE_STATUS_OFFSET), QSFP_CHANNL_DISABLE_STATUS_WIDTH) + if dom_channel_monitor_raw is not None: + tx_disable_data = int(dom_channel_monitor_raw[0], 16) + tx_disable_list.append(tx_disable_data & 0x01 != 0) + tx_disable_list.append(tx_disable_data & 0x02 != 0) + tx_disable_list.append(tx_disable_data & 0x04 != 0) + tx_disable_list.append(tx_disable_data & 0x08 != 0) + elif self.sfp_type == SFP_TYPE: + offset = 256 + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_STATUS_CONTROL_OFFSET), SFP_STATUS_CONTROL_WIDTH) + if dom_channel_monitor_raw is not None: + tx_disable_data = int(dom_channel_monitor_raw[0], 16) + tx_disable_list.append(tx_disable_data & 0xC0 != 0) + else: + return None + else: + return None + + return tx_disable_list + + 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. + """ + # SFP doesn't support this feature + if self.sfp_type == SFP_TYPE: + return 0 + elif self.sfp_type == QSFP_TYPE: + 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 + else: + return None + + return tx_disabled + + def get_lpmode(self): + """ + Retrieves the lpmode (low power mode) status of this QSFP module + Returns: + A Boolean, True if lpmode is enabled, False if disabled + """ + return False + + 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 + """ + # SFP doesn't support this feature + if self.sfp_type == SFP_TYPE: + return False + elif self.sfp_type == QSFP_TYPE: + offset = 0 + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return False + + dom_control_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_POWEROVERRIDE_OFFSET), QSFP_POWEROVERRIDE_WIDTH) + if dom_control_raw is not None: + if int(dom_control_raw[0],16) & (0x01 << QSFP_POWEROVERRIDE_BIT): + return True + else: + return False + else: + return None + + def get_temperature(self): + """ + Retrieves the temperature of this SFP + Returns: + An integer number of current temperature in Celsius + """ + if not self.dom_supported: + return None + if self.sfp_type == QSFP_TYPE: + offset = 0 + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return None + + if self.dom_temp_supported: + dom_temperature_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_TEMPE_OFFSET), QSFP_TEMPE_WIDTH) + if dom_temperature_raw is not None: + dom_temperature_data = sfpd_obj.parse_temperature(dom_temperature_raw, 0) + temp = self._convert_string_to_num( + dom_temperature_data['data']['Temperature']['value']) + return temp + else: + return None + elif self.sfp_type == SFP_TYPE: + offset = 256 + sfpd_obj = sff8472Dom() + if sfpd_obj is None: + return None + sfpd_obj._calibration_type = 1 + + dom_temperature_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH) + if dom_temperature_raw is not None: + dom_temperature_data = sfpd_obj.parse_temperature(dom_temperature_raw, 0) + temp = self._convert_string_to_num( + dom_temperature_data['data']['Temperature']['value']) + return temp + else: + return None + else: + return None + + def get_voltage(self): + """ + Retrieves the supply voltage of this SFP + Returns: + An integer number of supply voltage in mV + """ + if not self.dom_supported: + return None + if self.sfp_type == QSFP_TYPE: + offset = 0 + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return None + + if self.dom_volt_supported: + dom_voltage_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_VOLT_OFFSET), QSFP_VOLT_WIDTH) + if dom_voltage_raw is not None: + dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) + voltage = self._convert_string_to_num( + dom_voltage_data['data']['Vcc']['value']) + return voltage + else: + return None + elif self.sfp_type == SFP_TYPE: + offset = 256 + + sfpd_obj = sff8472Dom() + if sfpd_obj is None: + return None + + sfpd_obj._calibration_type = self.calibration + + dom_voltage_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH) + if dom_voltage_raw is not None: + dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) + voltage = self._convert_string_to_num( + dom_voltage_data['data']['Vcc']['value']) + return voltage + else: + return None + else: + return None + + def get_tx_bias(self): + """ + Retrieves the TX bias current of this SFP + Returns: + A list of four integer numbers, representing TX bias in mA + for channel 0 to channel 4. + Ex. ['110.09', '111.12', '108.21', '112.09'] + """ + tx_bias_list = [] + if self.sfp_type == QSFP_TYPE: + offset = 0 + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return None + + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) + if dom_channel_monitor_raw is not None: + dom_channel_monitor_data = \ + sfpd_obj.parse_channel_monitor_params_with_tx_power(dom_channel_monitor_raw, 0) + tx_bias_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX1Bias']['value'])) + tx_bias_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX2Bias']['value'])) + tx_bias_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX3Bias']['value'])) + tx_bias_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX4Bias']['value'])) + elif self.sfp_type == SFP_TYPE: + offset = 256 + + sfpd_obj = sff8472Dom() + if sfpd_obj is None: + return None + sfpd_obj._calibration_type = self.calibration + + if self.dom_supported: + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH) + if dom_channel_monitor_raw is not None: + dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params( \ + dom_channel_monitor_raw, 0) + tx_bias_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TXBias']['value'])) + else: + return None + else: + return None + else: + return None + + return tx_bias_list + + def get_rx_power(self): + """ + Retrieves the received optical power for this SFP + Returns: + A list of four integer numbers, representing received optical + power in mW for channel 0 to channel 4. + Ex. ['1.77', '1.71', '1.68', '1.70'] + """ + rx_power_list = [] + + if self.sfp_type == QSFP_TYPE: + offset = 0 + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return None + + if self.dom_rx_power_supported: + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) + if dom_channel_monitor_raw is not None: + dom_channel_monitor_data = \ + sfpd_obj.parse_channel_monitor_params_with_tx_power(dom_channel_monitor_raw, 0) + rx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['RX1Power']['value'])) + rx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['RX2Power']['value'])) + rx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['RX3Power']['value'])) + rx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['RX4Power']['value'])) + else: + return None + else: + return None + elif self.sfp_type == SFP_TYPE: + offset = 256 + + sfpd_obj = sff8472Dom() + if sfpd_obj is None: + return None + + if self.dom_supported: + sfpd_obj._calibration_type = self.calibration + + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH) + if dom_channel_monitor_raw is not None: + dom_channel_monitor_data = \ + sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0) + rx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['RXPower']['value'])) + else: + return None + else: + return None + else: + return None + + return rx_power_list + + def get_tx_power(self): + """ + Retrieves the TX power of this SFP + Returns: + A list of four integer numbers, representing TX power in mW + for channel 0 to channel 4. + Ex. ['1.86', '1.86', '1.86', '1.86'] + """ + tx_power_list = [] + + if self.sfp_type == QSFP_TYPE: + offset = 0 + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return None + + if self.dom_tx_power_supported: + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) + if dom_channel_monitor_raw is not None: + dom_channel_monitor_data = \ + sfpd_obj.parse_channel_monitor_params_with_tx_power(dom_channel_monitor_raw, 0) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX1Power']['value'])) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX2Power']['value'])) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX3Power']['value'])) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX4Power']['value'])) + else: + return None + else: + return None + elif self.sfp_type == SFP_TYPE: + offset = 256 + sfpd_obj = sff8472Dom() + if sfpd_obj is None: + return None + + if self.dom_supported: + sfpd_obj._calibration_type = self.calibration + + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH) + if dom_channel_monitor_raw is not None: + dom_channel_monitor_data = \ + sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TXPower']['value'])) + else: + return None + else: + return None + else: + return None + + return tx_power_list + + def reset(self): + """ + Reset SFP and return all user module settings to their default state. + Returns: + A boolean, True if successful, False if not + """ + if not self.get_presence(): + return False + + # SFP doesn't support this feature + if self.sfp_type == SFP_TYPE: + return False + elif self.sfp_type == QSFP_TYPE: + sfp_info = self.port_to_i2c_mapping[int(self._port_cfgs[self.port_num].lanes.split(',')[0])] + cmd = 'i2cget -y 0 {0} {1}'.format(sfp_info[4], sfp_info[5]) + reset = int(Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True).stdout.readline(), 16) + + reset &= ~(1 << sfp_info[6]) + cmd = 'i2cset -y 0 {0} {1} {2}'.format(sfp_info[4], sfp_info[5], reset) + Popen(cmd, shell=True) + + reset |= (1 << sfp_info[6]) + cmd = 'i2cset -y 0 {0} {1} {2}'.format(sfp_info[4], sfp_info[5], reset) + Popen(cmd, shell=True) + + return True + + 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 not self.get_presence(): + return False + + if self.sfp_type == SFP_TYPE: + if self.dom_tx_disable_supported: + offset = 256 + sysfs_sfp_i2c_client_eeprom_path = self.port_to_eeprom_mapping[self.port_num] + status_control_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_STATUS_CONTROL_OFFSET), SFP_STATUS_CONTROL_WIDTH) + if status_control_raw is not None: + # Set bit 6 for Soft TX Disable Select + # 01000000 = 64 and 10111111 = 191 + tx_disable_bit = 64 if tx_disable else 191 + status_control = int(status_control_raw[0], 16) + tx_disable_ctl = (status_control | tx_disable_bit) if tx_disable else ( + status_control & tx_disable_bit) + try: + sysfsfile_eeprom = open( + sysfs_sfp_i2c_client_eeprom_path, mode="r+b", buffering=0) + buffer = create_string_buffer(1) + buffer[0] = chr(tx_disable_ctl) + # Write to eeprom + sysfsfile_eeprom.seek(offset + SFP_STATUS_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: + sysfsfile_eeprom.close() + time.sleep(0.01) + return True + return False + else: + return False + elif self.sfp_type == QSFP_TYPE: + if self.dom_tx_disable_supported: + channel_mask = 0x0f + if tx_disable: + return self.tx_disable_channel(channel_mask, True) + else: + return self.tx_disable_channel(channel_mask, False) + else: + return False + else: + return None + + 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 not self.get_presence(): + return False + # SFP doesn't support this feature + if self.sfp_type == SFP_TYPE: + return False + elif self.sfp_type == QSFP_TYPE: + if self.dom_tx_disable_supported: + sysfsfile_eeprom = None + try: + channel_state = self.get_tx_disable_channel() + if disable: + tx_disable_ctl = channel_state | channel + else: + tx_disable_ctl = channel_state & (~channel) + buffer = create_string_buffer(1) + 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 + else: + return False + else: + return None + + 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 + """ + return 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 + """ + # SFP doesn't support this feature + if not self.get_presence(): + return False + + if self.sfp_type == SFP_TYPE: + return False + elif self.sfp_type == QSFP_TYPE: + try: + power_override_bit = 0 + if power_override: + power_override_bit |= 1 << 0 + + power_set_bit = 0 + if power_set: + power_set_bit |= 1 << 1 + + buffer = create_string_buffer(1) + buffer[0] = chr(power_override_bit | power_set_bit) + # Write to eeprom + sysfsfile_eeprom = open(self.port_to_eeprom_mapping[self.port_num], "r+b") + sysfsfile_eeprom.seek(QSFP_POWEROVERRIDE_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) + else: + return None + + return True + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + return "Ethernet{}".format(self.port_num) + diff --git a/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/thermal.py b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/thermal.py new file mode 100644 index 000000000000..ca4e35969269 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48x8c/sonic_platform/thermal.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python + +############################################################################# +# Celestica +# +# 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 + +try: + from sonic_platform_base.thermal_base import ThermalBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Thermal(ThermalBase): + """Platform-specific Thermal class""" + + THERMAL_NAME_LIST = [] + CPUBOARD_SS_PATH = "/sys/class/hwmon/hwmon1" + + def __init__(self, thermal_index): + self.index = thermal_index + self.high_threshold = float(112) + + # Add thermal name + self.THERMAL_NAME_LIST.append("ASIC") + + # Set hwmon path + self.ss_index, self.hwmon_path = 1, self.CPUBOARD_SS_PATH + self.ss_key = self.THERMAL_NAME_LIST[self.index - 1] + + def __read_txt_file(self, file_path): + try: + with open(file_path, 'r') as fd: + data = fd.read() + return data.strip() + except IOError: + raise IOError("Unable to open %s file !" % file_path) + + def __get_temp(self, temp_file): + temp_file_path = os.path.join(self.hwmon_path, temp_file) + raw_temp = self.__read_txt_file(temp_file_path) + temp = float(raw_temp)/1000 + return float("{:.3f}".format(temp)) + + def __set_threshold(self, file_name, temperature): + 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 + """ + temp_file = "temp{}_input".format(self.ss_index) + 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 + """ + return self.high_threshold + + 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 + """ + self.high_threshold = float(temperature) + return True + + def get_name(self): + """ + Retrieves the name of the thermal device + Returns: + string: The name of the thermal device + """ + 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 + """ + temp_file = "temp{}_input".format(self.ss_index) + temp_file_path = os.path.join(self.hwmon_path, temp_file) + return os.path.isfile(temp_file_path) + + 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 not self.get_presence(): + return False + + return True diff --git a/platform/centec/sonic-platform-modules-v682/48y8c-d/service/release.py b/platform/centec/sonic-platform-modules-v682/48y8c-d/service/release.py index 2c799e6ef3d6..a5174b02daa4 100644 --- a/platform/centec/sonic-platform-modules-v682/48y8c-d/service/release.py +++ b/platform/centec/sonic-platform-modules-v682/48y8c-d/service/release.py @@ -1,10 +1,10 @@ -#!/usr/bin/python2 +#!/usr/bin/env python import os import sys import time -susi4_lib = '/usr/local/lib/python2.7/dist-packages/' +susi4_lib = '/usr/local/lib/python3.9/dist-packages/' if not susi4_lib in os.environ.setdefault('LD_LIBRARY_PATH', ''): os.environ['LD_LIBRARY_PATH'] += (':' + susi4_lib) try: diff --git a/platform/centec/sonic-platform-modules-v682/48y8c/modules/Makefile b/platform/centec/sonic-platform-modules-v682/48y8c/modules/Makefile new file mode 100644 index 000000000000..53c96acb0cb7 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48y8c/modules/Makefile @@ -0,0 +1 @@ +obj-m := centec_v682_48y8c_platform.o rtc-sd2405.o diff --git a/platform/centec/sonic-platform-modules-v682/48y8c/modules/centec_v682_48y8c_platform.c b/platform/centec/sonic-platform-modules-v682/48y8c/modules/centec_v682_48y8c_platform.c new file mode 100644 index 000000000000..28e0e9f2610d --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48y8c/modules/centec_v682_48y8c_platform.c @@ -0,0 +1,167 @@ +#include +#include +#include +#include +#include +#include + +#define SEP(XXX) 1 +#define IS_INVALID_PTR(_PTR_) ((_PTR_ == NULL) || IS_ERR(_PTR_)) +#define IS_VALID_PTR(_PTR_) (!IS_INVALID_PTR(_PTR_)) + +#if SEP("defines") +#define SFP_NUM 48 +#define QSFP_NUM 8 +#define PORT_NUM (SFP_NUM + QSFP_NUM) +#endif + +#if SEP("drivers:leds") +extern void v682_48y8c_led_port_set(struct led_classdev *led_cdev, enum led_brightness set_value); +extern enum led_brightness v682_48y8c_led_port_get(struct led_classdev *led_cdev); + +static struct led_classdev led_dev_port[PORT_NUM] = { +{ .name = "port0", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port1", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port2", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port3", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port4", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port5", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port6", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port7", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port8", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port9", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port10", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port11", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port12", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port13", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port14", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port15", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port16", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port17", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port18", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port19", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port20", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port21", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port22", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port23", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port24", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port25", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port26", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port27", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port28", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port29", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port30", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port31", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port32", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port33", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port34", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port35", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port36", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port37", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port38", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port39", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port40", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port41", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port42", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port43", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port44", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port45", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port46", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port47", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port48", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port49", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port50", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port51", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port52", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port53", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port54", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +{ .name = "port55", .brightness_set = v682_48y8c_led_port_set, .brightness_get = v682_48y8c_led_port_get,}, +}; +static unsigned char port_led_mode[PORT_NUM] = {0}; + +void v682_48y8c_led_port_set(struct led_classdev *led_cdev, enum led_brightness set_value) +{ + int portNum = 0; + + sscanf(led_cdev->name, "port%d", &portNum); + + port_led_mode[portNum] = set_value; + + return; +} + +enum led_brightness v682_48y8c_led_port_get(struct led_classdev *led_cdev) +{ + int portNum = 0; + + sscanf(led_cdev->name, "port%d", &portNum); + + return port_led_mode[portNum]; +} + +static int v682_48y8c_init_led(void) +{ + int ret = 0; + int i = 0; + + for (i = 0; i < PORT_NUM; i++) + { + ret = led_classdev_register(NULL, &(led_dev_port[i])); + if (ret != 0) + { + printk(KERN_CRIT "create v682_48y8c led_dev_port%d device failed\n", i); + continue; + } + } + + return ret; +} + +static int v682_48y8c_exit_led(void) +{ + int i = 0; + + for (i = 0; i < PORT_NUM; i++) + { + led_classdev_unregister(&(led_dev_port[i])); + } + + return 0; +} +#endif + +static int v682_48y8c_init(void) +{ + int ret = 0; + int failed = 0; + + printk(KERN_ALERT "init v682_48y8c board dirver...\n"); + + ret = v682_48y8c_init_led(); + if (ret != 0) + { + failed = 1; + } + + if (failed) + printk(KERN_INFO "init v682_48y8c board driver failed\n"); + else + printk(KERN_ALERT "init v682_48y8c board dirver...ok\n"); + + return 0; +} + +static void v682_48y8c_exit(void) +{ + printk(KERN_INFO "deinit v682_48y8c board dirver...\n"); + + v682_48y8c_exit_led(); + + printk(KERN_INFO "deinit v682_48y8c board dirver...ok\n"); +} + +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_AUTHOR("shil centecNetworks, Inc"); +MODULE_DESCRIPTION("v682-48y8c board driver"); +module_init(v682_48y8c_init); +module_exit(v682_48y8c_exit); diff --git a/platform/centec/sonic-platform-modules-v682/48y8c/modules/rtc-sd2405.c b/platform/centec/sonic-platform-modules-v682/48y8c/modules/rtc-sd2405.c new file mode 100644 index 000000000000..c22ab3349144 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48y8c/modules/rtc-sd2405.c @@ -0,0 +1,264 @@ +/* + * rtc class driver for the SD2405 chip + * + * Author: Dale Farnsworth + * + * based on previously existing rtc class drivers + * + * 2007 (c) MontaVista, Software, Inc. This file is licensed under + * the terms of the GNU General Public License version 2. This program + * is licensed "as is" without any warranty of any kind, whether express + * or implied. + */ + +#include +#include +#include +#include +#include + +#define DRV_VERSION "0.1" + +/* + * register indices + */ +#define SD2405_REG_SC 0x0 /* seconds 00-59 */ +#define SD2405_REG_MN 0x1 /* minutes 00-59 */ +#define SD2405_REG_HR 0x2 /* hours 00-23 */ +#define SD2405_REG_DW 0x3 /* day of week 1-7 */ +#define SD2405_REG_DT 0x4 /* day of month 00-31 */ +#define SD2405_REG_MO 0x5 /* month 01-12 */ +#define SD2405_REG_YR 0x6 /* year 00-99 */ + +#define SD2405_REG_CTRL1 0xf /* control 1 */ +#define SD2405_REG_CTRL2 0x10 /* control 2 */ +#define SD2405_REG_CTRL3 0x11 /* control 3 ARST*/ + +#define SD2405_REG_LEN 7 + +/* + * register write protect + */ +#define SD2405_REG_CONTROL1_WRITE 0x80 +#define SD2405_REG_CONTROL2_WRITE 0x84 + + +#define SD2405_IDLE_TIME_AFTER_WRITE 3 /* specification says 2.5 mS */ + +static struct i2c_driver sd2405_driver; + +#if 1 +/* modified by shil, for bug 46153 */ +static int sd2405_i2c_read_regs(struct i2c_client *client, u8 *buf) +{ + int i; + + for (i = 0; i < SD2405_REG_LEN; i++) { + buf[i] = i2c_smbus_read_byte_data(client, SD2405_REG_SC+i); + } + return 0; +} + +/* modified by shil, for bug 46153 */ +static int sd2405_i2c_write_regs(struct i2c_client *client, u8 const *buf) +{ + int i; + + for (i = 0; i < SD2405_REG_LEN; i++) { + i2c_smbus_write_byte_data(client, SD2405_REG_SC+i, buf[i]); + msleep(SD2405_IDLE_TIME_AFTER_WRITE); + } + return 0; +} + +#else +static int sd2405_i2c_read_regs(struct i2c_client *client, u8 *buf) +{ + struct i2c_msg msgs[1] = { + { + .addr = client->addr, + .flags = I2C_M_RD, /* read */ + .len = SD2405_REG_LEN, + .buf = buf} + }; + int rc; + + rc = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); + if (rc != ARRAY_SIZE(msgs)) { + dev_err(&client->dev, "%s: register read failed\n", __func__); + return -EIO; + } + return 0; +} + +static int sd2405_i2c_write_regs(struct i2c_client *client, u8 const *buf) +{ + int rc; + + u8 temp_reg[SD2405_REG_LEN+1] = {0}; + memcpy(&temp_reg[1], buf, SD2405_REG_LEN); + + struct i2c_msg msgs[1] = { + { + .addr = client->addr, + .flags = 0, /* write */ + .len = SD2405_REG_LEN+1, + .buf = temp_reg} + }; + + rc = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); + if (rc != ARRAY_SIZE(msgs)) + goto write_failed; + msleep(SD2405_IDLE_TIME_AFTER_WRITE); + + return 0; + + write_failed: + dev_err(&client->dev, "%s: register write failed\n", __func__); + return -EIO; +} +#endif + +static int sd2405_i2c_read_time(struct i2c_client *client, struct rtc_time *tm) +{ + int rc; + u8 regs[SD2405_REG_LEN]; + + rc = sd2405_i2c_read_regs(client, regs); + if (rc < 0) + return rc; + + tm->tm_sec = bcd2bin(regs[SD2405_REG_SC]); + tm->tm_min = bcd2bin(regs[SD2405_REG_MN]); + tm->tm_hour = bcd2bin(regs[SD2405_REG_HR] & 0x3f); + tm->tm_wday = bcd2bin(regs[SD2405_REG_DW]); + tm->tm_mday = bcd2bin(regs[SD2405_REG_DT]); + tm->tm_mon = bcd2bin(regs[SD2405_REG_MO]) - 1; + tm->tm_year = bcd2bin(regs[SD2405_REG_YR]) + 100; + + return 0; +} + +static int sd2405_i2c_set_write_protect(struct i2c_client *client) +{ + int rc; + rc = i2c_smbus_write_byte_data(client, SD2405_REG_CTRL1, 0); + rc += i2c_smbus_write_byte_data(client, SD2405_REG_CTRL2, 0); + if (rc < 0) { + dev_err(&client->dev, "%s: control register write failed\n", + __func__); + return -EIO; + } + return 0; +} + +static int sd2405_i2c_clear_write_protect(struct i2c_client *client) +{ + int rc; + rc = i2c_smbus_write_byte_data(client, SD2405_REG_CTRL2, SD2405_REG_CONTROL1_WRITE); + rc += i2c_smbus_write_byte_data(client, SD2405_REG_CTRL1, SD2405_REG_CONTROL2_WRITE); + if (rc < 0) { + dev_err(&client->dev, "%s: control register write failed\n", + __func__); + return -EIO; + } + return 0; +} + +static int +sd2405_i2c_set_time(struct i2c_client *client, struct rtc_time const *tm) +{ + u8 regs[SD2405_REG_LEN]; + int rc; + + rc = sd2405_i2c_clear_write_protect(client); + if (rc < 0) + return rc; + + regs[SD2405_REG_SC] = bin2bcd(tm->tm_sec); + regs[SD2405_REG_MN] = bin2bcd(tm->tm_min); + regs[SD2405_REG_HR] = bin2bcd(tm->tm_hour)|0x80; + regs[SD2405_REG_DW] = bin2bcd(tm->tm_wday); + regs[SD2405_REG_DT] = bin2bcd(tm->tm_mday); + regs[SD2405_REG_MO] = bin2bcd(tm->tm_mon + 1); + regs[SD2405_REG_YR] = bin2bcd(tm->tm_year - 100); + + rc = sd2405_i2c_write_regs(client, regs); + if (rc < 0) + return rc; + + rc = sd2405_i2c_set_write_protect(client); + if (rc < 0) + return rc; + + return 0; +} + +static int sd2405_rtc_read_time(struct device *dev, struct rtc_time *tm) +{ + return sd2405_i2c_read_time(to_i2c_client(dev), tm); +} + +static int sd2405_rtc_set_time(struct device *dev, struct rtc_time *tm) +{ + return sd2405_i2c_set_time(to_i2c_client(dev), tm); +} + +static const struct rtc_class_ops sd2405_rtc_ops = { + .read_time = sd2405_rtc_read_time, + .set_time = sd2405_rtc_set_time, +}; + +static int +sd2405_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + struct rtc_device *rtc; + +/* modified by shil, for bug 46153 */ +#if 0 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) + return -ENODEV; +#endif + + dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); + + rtc = devm_rtc_allocate_device(&client->dev); + if (IS_ERR(rtc)) + return PTR_ERR(rtc); + + i2c_set_clientdata(client, rtc); + rtc->ops = &sd2405_rtc_ops; + + return rtc_register_device(rtc); +} + +static struct i2c_device_id sd2405_id[] = { + { "sd2405", 0 }, + { } +}; + +static struct i2c_driver sd2405_driver = { + .driver = { + .name = "rtc-sd2405", + }, + .probe = sd2405_probe, + .id_table = sd2405_id, +}; + +static int __init sd2405_init(void) +{ + return i2c_add_driver(&sd2405_driver); +} + +static void __exit sd2405_exit(void) +{ + i2c_del_driver(&sd2405_driver); +} + +MODULE_DESCRIPTION("Maxim SD2405 RTC driver"); +MODULE_AUTHOR("Dale Farnsworth "); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); + +module_init(sd2405_init); +module_exit(sd2405_exit); diff --git a/platform/centec/sonic-platform-modules-v682/48y8c/service/48y8c_platform.service b/platform/centec/sonic-platform-modules-v682/48y8c/service/48y8c_platform.service new file mode 100644 index 000000000000..48327ec456b2 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48y8c/service/48y8c_platform.service @@ -0,0 +1,13 @@ +[Unit] +Description=Centec modules init +After=local-fs.target +Before=syncd.service + +[Service] +Type=oneshot +ExecStart=-/etc/init.d/platform-modules-v682-48y8c start +ExecStop=-/etc/init.d/platform-modules-v682-48y8c stop +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/platform/centec/sonic-platform-modules-v682/48y8c/service/release.py b/platform/centec/sonic-platform-modules-v682/48y8c/service/release.py new file mode 100644 index 000000000000..8ae790a24fdc --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48y8c/service/release.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +import os +import time + +def release_board(): + if open('/proc/cmdline', 'r').readlines()[0].find('SONIC_BOOT_TYPE=warm') != -1: + return + + os.system('i2cset -y 0 0x37 0x4 0x0') + time.sleep(1) + os.system('i2cset -y 0 0x37 0x4 0x1') + time.sleep(1) + os.system('echo 1 > /sys/bus/pci/devices/0000\:00\:1c.0/remove') + time.sleep(1) + os.system('echo 1 > /sys/bus/pci/rescan') + time.sleep(1) + # EPLD_QSFP_RST + os.system('i2cset -y 0 0x36 0x5 0xff') + os.system('i2cset -y 0 0x37 0x5 0xff') + # EPLD_QSFP_INT_MASK + os.system('i2cset -y 0 0x36 0xd 0xff') + os.system('i2cset -y 0 0x37 0xd 0xff') + # EPLD_PPU_INT_MASK + os.system('i2cset -y 0 0x36 0xb 0x00') + # EPLD_SFP_DISABLE1 + os.system('i2cset -y 0 0x36 0xe 0x00') + os.system('i2cset -y 0 0x37 0xe 0x00') + # EPLD_SFP_DISABLE2 + os.system('i2cset -y 0 0x36 0xf 0x00') + os.system('i2cset -y 0 0x37 0xf 0x00') + # EPLD_SFP_DISABLE3 + os.system('i2cset -y 0 0x36 0x10 0x00') + os.system('i2cset -y 0 0x37 0x10 0x00') + +if __name__ == '__main__': + release_board() diff --git a/platform/centec/sonic-platform-modules-v682/48y8c/setup.py b/platform/centec/sonic-platform-modules-v682/48y8c/setup.py new file mode 100644 index 000000000000..e0713e550f11 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48y8c/setup.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +import os +from setuptools import setup +os.listdir + +setup( + name='sonic_platform', + version='1.0', + description='Module to initialize centec v682-48y8c platforms', + + packages=['sonic_platform'], + package_dir={'sonic_platform': 'sonic_platform'}, +) + diff --git a/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/__init__.py b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/__init__.py new file mode 100644 index 000000000000..6e50c02e9d1f --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/__init__.py @@ -0,0 +1,2 @@ +__all__ = ["platform", "chassis", "sfp", "eeprom", "psu", "thermal", "fan", "fan_drawer", "led"] +from . import platform diff --git a/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/chassis.py b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/chassis.py new file mode 100644 index 000000000000..566612e40654 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/chassis.py @@ -0,0 +1,282 @@ +#!/usr/bin/env python +# +# Name: chassis.py, version: 1.0 +# +# Description: Module contains the definitions of SONiC platform APIs +# + +try: + import os + import re + import time + import collections + from sonic_py_common import device_info + from sonic_platform_base.chassis_base import ChassisBase + from sonic_platform.sfp import Sfp + from sonic_platform.fan_drawer import FanDrawer + from sonic_platform.psu import Psu + from sonic_platform.thermal import Thermal + from sonic_platform.eeprom import Eeprom +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +NUM_FAN_TRAY = 2 +NUM_THERMAL = 1 +NUM_PSU = 2 + +USR_SHARE_SONIC_PATH = "/usr/share/sonic" +HOST_DEVICE_PATH = USR_SHARE_SONIC_PATH + "/device" +CONTAINER_PLATFORM_PATH = USR_SHARE_SONIC_PATH + "/platform" + +REBOOT_CAUSE_DIR = "/host/reboot-cause/" +REBOOT_CAUSE_FILE = os.path.join(REBOOT_CAUSE_DIR, "reboot-cause.txt") + +class Chassis(ChassisBase): + # System status LED + _led = None + + def __init__(self): + ChassisBase.__init__(self) + + self.data = {'valid':0, 'last':0} + self.sfp_presence = {} + + if os.path.isdir(CONTAINER_PLATFORM_PATH): + platform_path = CONTAINER_PLATFORM_PATH + else: + platform = device_info.get_platform() + if platform is None: + raise + platform_path = os.path.join(HOST_DEVICE_PATH, platform) + + port_config_file = "/".join([platform_path, "V682-48y8c", "port_config.ini"]) + try: + f = open(port_config_file) + except: + raise + for line in f: + line.strip() + if re.search('^#', line) is not None: + Port_cfg = collections.namedtuple('Port_cfg', line.split()[1:]) + break + f.close() + f = open(port_config_file) + _port_cfgs = [Port_cfg(*tuple((line.strip().split()))) + for line in f if re.search('^#', line) is None] + f.close() + + # Initialize EEPROM + self._eeprom = Eeprom() + + # Initialize FAN + for i in range(NUM_FAN_TRAY): + fandrawer = FanDrawer(i + 1) + self._fan_drawer_list.append(fandrawer) + self._fan_list.extend(fandrawer._fan_list) + + # Initialize PSU + for index in range(0, NUM_PSU): + psu = Psu(index + 1) + self._psu_list.append(psu) + + # Initialize THERMAL + for index in range(0, NUM_THERMAL): + thermal = Thermal(index) + self._thermal_list.append(thermal) + + # Initialize SFP + for port_cfg in _port_cfgs: + sfp = Sfp(int(port_cfg.index), 'SFP' if int(port_cfg.index) < 48 else 'QSFP') + self._sfp_list.append(sfp) + self.sfp_presence[int(port_cfg.index)] = False + +############################################## +# Device methods +############################################## + + def get_name(self): + """ + Retrieves the name of the chassis + Returns: + string: The name of the chassis + """ + return self._eeprom.modelstr() + + def get_presence(self): + """ + Retrieves the presence of the chassis + Returns: + bool: True if chassis is present, False if not + """ + return True + + def get_model(self): + """ + Retrieves the model number (or part number) of the chassis + Returns: + string: Model/part number of chassis + """ + return self._eeprom.part_number_str() + + def get_serial(self): + """ + Retrieves the serial number of the chassis + Returns: + string: Serial number of chassis + """ + return self._eeprom.serial_number_str() + + def get_status(self): + """ + Retrieves the operational status of the chassis + Returns: + bool: A boolean value, True if chassis is operating properly + False if not + """ + return True + +############################################## +# Chassis methods +############################################## + + 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.base_mac_addr() + + def get_serial_number(self): + """ + Retrieves the hardware serial number for the chassis + + Returns: + A string containing the hardware serial number for this chassis. + """ + return self._eeprom.serial_number_str() + + 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. + Ex. { '0x21':'AG9064', '0x22':'V1.0', '0x23':'AG9064-0109867821', + '0x24':'001c0f000fcd0a', '0x25':'02/03/2018 16:22:00', + '0x26':'01', '0x27':'REV01', '0x28':'AG9064-C2358-16G'} + """ + return self._eeprom.system_eeprom_info() + + 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. + """ + if os.path.exists(REBOOT_CAUSE_FILE): + with open(REBOOT_CAUSE_FILE) as reboot_cause_file: + reboot_cause = reboot_cause_file.readline() + if re.search(r'User issued', reboot_cause) is None: + return (self.REBOOT_CAUSE_POWER_LOSS, None) + else: + return (self.REBOOT_CAUSE_NON_HARDWARE, None) + else: + return (self.REBOOT_CAUSE_POWER_LOSS, None) + + def get_change_event(self, timeout=2000): + """ + Returns a nested dictionary containing all devices which have + experienced a change at chassis level + + Args: + timeout: Timeout in milliseconds (optional). If timeout == 0, + this method will block until a change is detected. + + Returns: + (bool, dict): + - True if call successful, False if not; + - A nested dictionary where key is a device type, + value is a dictionary with key:value pairs in the + format of {'device_id':'device_event'}, + where device_id is the device ID for this device and + device_event, + status='1' represents device inserted, + status='0' represents device removed. + Ex. {'fan':{'0':'0', '2':'1'}, 'sfp':{'11':'0'}} + indicates that fan 0 has been removed, fan 2 + has been inserted and sfp 11 has been removed. + """ + SFP_STATUS_INSERTED = '1' + SFP_STATUS_REMOVED = '0' + + now = time.time() + port_dict = {} + + if timeout < 1000: + timeout = 1000 + timeout = (timeout) / float(1000) # Convert to secs + + if now < (self.data['last'] + timeout) and self.data['valid']: + return False, {'sfp': {}} + + for sfp in self._sfp_list: + sfp_presence = sfp.get_presence() + if sfp_presence != self.sfp_presence[sfp.index]: + self.sfp_presence[sfp.index] = sfp_presence + if sfp_presence: + port_dict[sfp.index] = SFP_STATUS_INSERTED + else: + port_dict[sfp.index] = SFP_STATUS_REMOVED + + if bool(port_dict): + self.data['last'] = now + self.data['valid'] = 1 + ret = True + else: + time.sleep(0.5) + ret = False + + ret_dict = {'sfp': port_dict} + return ret, ret_dict + + def get_num_psus(self): + return len(self._psu_list) + + def get_psu(self, psu_index): + return self._psu_list[psu_index] + + def initizalize_system_led(self): + from .led import SystemLed + Chassis._led = SystemLed() + + def set_status_led(self, color): + """ + Sets the state of the system LED + + Args: + color: A string representing the color with which to set the + system LED + + Returns: + bool: True if system LED state is set successfully, False if not + """ + return False if not Chassis._led else Chassis._led.set_status(color) + + def get_status_led(self): + """ + Gets the state of the system LED + + Returns: + A string, one of the valid LED color strings which could be vendor + specified. + """ + return None if not Chassis._led else Chassis._led.get_status() diff --git a/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/eeprom.py b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/eeprom.py new file mode 100644 index 000000000000..7d2750475717 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/eeprom.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python +# +# Name: eeprom.py, version: 1.0 +# +# Description: Module contains the definitions of SONiC platform APIs +# + +try: + import os + from sonic_eeprom import eeprom_tlvinfo + from sonic_py_common import device_info + import binascii +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +USR_SHARE_SONIC_PATH = "/usr/share/sonic" +HOST_DEVICE_PATH = USR_SHARE_SONIC_PATH + "/device" +CONTAINER_PLATFORM_PATH = USR_SHARE_SONIC_PATH + "/platform" + +class Eeprom(eeprom_tlvinfo.TlvInfoDecoder): + + def __init__(self): + if os.path.isdir(CONTAINER_PLATFORM_PATH): + platform_path = CONTAINER_PLATFORM_PATH + else: + platform = device_info.get_platform() + if platform is None: + raise + platform_path = os.path.join(HOST_DEVICE_PATH, platform) + + self.__eeprom_path = platform_path + '/eeprom_file' + + super(Eeprom, self).__init__(self.__eeprom_path, 0, '', True) + + self.__eeprom_tlv_dict = dict() + try: + self.open_eeprom() + self.__eeprom_data = self.read_eeprom() + except: + self.__eeprom_data = "N/A" + raise RuntimeError("Eeprom is not Programmed") + else: + eeprom = self.__eeprom_data + + 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 + + def serial_number_str(self): + (is_valid, results) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_SERIAL_NUMBER) + if not is_valid: + return "N/A" + return results[2].decode('ascii') + + def base_mac_addr(self): + (is_valid, t) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_MAC_BASE) + if not is_valid or t[1] != 6: + return super(TlvInfoDecoder, self).switchaddrstr(e) + + return ":".join([binascii.b2a_hex(T) for T in t[2]]) + + def modelstr(self): + (is_valid, results) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_PRODUCT_NAME) + if not is_valid: + return "N/A" + + return results[2].decode('ascii') + + def part_number_str(self): + (is_valid, results) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_PART_NUMBER) + if not is_valid: + return "N/A" + + return results[2].decode('ascii') + + def serial_tag_str(self): + (is_valid, results) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_SERVICE_TAG) + if not is_valid: + return "N/A" + + return results[2].decode('ascii') + + def revision_str(self): + (is_valid, results) = self.get_tlv_field( + self.__eeprom_data, self._TLV_CODE_DEVICE_VERSION) + if not is_valid: + return "N/A" + + return results[2].decode('ascii') + + def system_eeprom_info(self): + """ + Returns a dictionary, where keys are the type code defined in + ONIE EEPROM format and values are their corresponding values + found in the system EEPROM. + """ + return self.__eeprom_tlv_dict + diff --git a/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/fan.py b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/fan.py new file mode 100644 index 000000000000..5f7b256eafb8 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/fan.py @@ -0,0 +1,186 @@ +#!/usr/bin/env python + +############################################################################# +# Celestica +# +# Module contains an implementation of SONiC Platform Base API and +# provides the fan status which are available in the platform +# +############################################################################# + +import math +import os.path + +try: + from sonic_platform_base.fan_base import FanBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +FAN_PATH = "/sys/class/hwmon/hwmon{}/" +FAN_MAX_PWM = 255 +FAN_FAN_PWM = "pwm{}" +FAN_FAN_INPUT = "fan{}_input" +FAN_MAX_RPM = 15000 +FAN_NAME_LIST = ["FAN-{}-1", "FAN-{}-2", "FAN-{}-3", "FAN-{}-4"] + +class Fan(FanBase): + """Platform-specific Fan class""" + + def __init__(self, fan_tray_index, fan_index=0): + self.fan_index = fan_index + self.fan_tray_index = fan_tray_index + + FanBase.__init__(self) + + def __read_txt_file(self, file_path): + try: + with open(file_path, 'r') as fd: + data = fd.read() + return data.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 IOError: + return False + return True + + def __search_file_by_name(self, directory, file_name): + for dirpath, dirnames, files in os.walk(directory): + for name in files: + file_path = os.path.join(dirpath, name) + if name in file_name: + return file_path + return None + + def get_direction(self): + """ + Retrieves the direction of fan + Returns: + A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST + depending on fan direction + """ + direction = self.FAN_DIRECTION_EXHAUST + 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) + + Note: + speed = pwm_in/255*100 + """ + speed = 0 + fan_speed_sysfs_name = "fan{}_input".format(self.fan_index+1) + fan_speed_sysfs_path = self.__search_file_by_name( + FAN_PATH.format(self.fan_tray_index + 1), fan_speed_sysfs_name) + fan_speed_rpm = self.__read_txt_file(fan_speed_sysfs_path) or 0 + speed = math.ceil(float(fan_speed_rpm) * 100 / FAN_MAX_RPM) + + 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 + """ + # target = 0 + # fan_target_sysfs_name = "pwm{}".format(self.fan_index+1) + # fan_target_sysfs_path = self.__search_file_by_name( + # FAN_PATH.format(self.fan_tray_index + 1), fan_target_sysfs_name) + # fan_target_pwm = self.__read_txt_file(fan_target_sysfs_path) or 0 + # target = math.ceil(float(fan_target_pwm) * 100 / FAN_MAX_PWM) + + # return target + speed = 0 + fan_speed_sysfs_name = "fan{}_input".format(self.fan_index+1) + fan_speed_sysfs_path = self.__search_file_by_name( + FAN_PATH.format(self.fan_tray_index + 1), fan_speed_sysfs_name) + fan_speed_rpm = self.__read_txt_file(fan_speed_sysfs_path) or 0 + speed = math.ceil(float(fan_speed_rpm) * 100 / FAN_MAX_RPM) + + return 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 10 + + 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 + + Note: + Depends on pwm or target mode is selected: + 1) pwm = speed_pc * 255 <-- Currently use this mode. + 2) target_pwm = speed_pc * 100 / 255 + 2.1) set pwm{}_enable to 3 + + """ + pwm = speed * 255 / 100 + fan_target_sysfs_name = "pwm{}".format(self.fan_index+1) + fan_target_sysfs_path = self.__search_file_by_name( + FAN_PATH.format(self.fan_tray_index + 1), fan_target_sysfs_name) + return self.__write_txt_file(fan_target_sysfs_path, int(pwm)) + + 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: always True + """ + return True + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + fan_name = FAN_NAME_LIST[self.fan_index].format(self.fan_tray_index) + + return fan_name + + def get_presence(self): + """ + Retrieves the presence of the FAN + Returns: + bool: always True + """ + + return True + + def get_status(self): + """ + Retrieves the status of the FAN + Returns: + bool: always True + """ + return True diff --git a/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/fan_drawer.py b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/fan_drawer.py new file mode 100644 index 000000000000..781ba7957a4e --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/fan_drawer.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +######################################################################## +# Centec V682 48Y8C +# +# 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 + from sonic_platform.fan import Fan +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +CENTEC_FANS_PER_FANTRAY = 4 + + +class FanDrawer(FanDrawerBase): + """Centec V682 48Y8C Platform-specific Fan class""" + + def __init__(self, fantray_index): + + FanDrawerBase.__init__(self) + self.fantrayindex = fantray_index + for i in range(CENTEC_FANS_PER_FANTRAY): + self._fan_list.append(Fan(fantray_index, i)) + + def get_name(self): + """ + Retrieves the fan drawer name + Returns: + string: The name of the device + """ + return "FanTray{}".format(self.fantrayindex) + + def set_status_led(self, color): + """ + Sets the state of the fan drawer status LED + + Args: + color: A string representing the color with which to set the + fan drawer status LED + + Returns: + bool: True if status LED state is set successfully, False if not + """ + return True diff --git a/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/led.py b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/led.py new file mode 100644 index 000000000000..492d6983ea76 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/led.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +############################################################################# +# +# Module contains an implementation of SONiC Platform Base API and +# provides the led status which are available in the platform +# +############################################################################# + +from subprocess import Popen, PIPE, STDOUT + +class SystemLed(object): + STATUS_LED_COLOR_GREEN = 'green' + STATUS_LED_COLOR_ORANGE = 'orange' + STATUS_LED_COLOR_OFF = 'off' + + SYSTEM_LED_PATH = '/sys/class/leds/system/brightness' + + def set_status(self, color): + status = False + + if color == SystemLed.STATUS_LED_COLOR_ORANGE: + cmd = 'i2cset -y 0 0x36 0x2 0xb' + Popen(cmd, shell=True) + status = True + elif color == SystemLed.STATUS_LED_COLOR_OFF: + cmd = 'i2cset -y 0 0x36 0x2 0x0' + Popen(cmd, shell=True) + status = True + elif color == SystemLed.STATUS_LED_COLOR_GREEN: + cmd = 'i2cset -y 0 0x36 0x2 0x5' + Popen(cmd, shell=True) + status = True + + return status + + def get_status(self): + cmd = 'i2cget -y 0 0x36 0x2' + status = int(Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True).stdout.readline(), 16) + if status == 11: + return SystemLed.STATUS_LED_COLOR_ORANGE + elif status == 0: + return SystemLed.STATUS_LED_COLOR_OFF + else: + return SystemLed.STATUS_LED_COLOR_GREEN diff --git a/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/platform.py b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/platform.py new file mode 100644 index 000000000000..358edc6f19f2 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/platform.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +# +# Name: platform.py, version: 1.0 +# +# Description: Module contains the definitions of SONiC platform APIs for Centec V682-48Y8C-D +# + + +try: + from sonic_platform_base.platform_base import PlatformBase + from sonic_platform.chassis import Chassis +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Platform(PlatformBase): + + def __init__(self): + PlatformBase.__init__(self) + self._chassis = Chassis() + diff --git a/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/psu.py b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/psu.py new file mode 100644 index 000000000000..779209c71c2e --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/psu.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +from __future__ import print_function + +from subprocess import Popen, PIPE, STDOUT + +try: + from sonic_platform_base.psu_base import PsuBase +except ImportError as e: + raise ImportError("%s - required module not found" % e) + +class Psu(PsuBase): + """Centec Platform-specific PSU class""" + + def __init__(self, index): + self._index = index + self._fan_list = [] + + def get_presence(self): + cmd = 'i2cget -y 0 0x36 0x1e' + status = int(Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True).stdout.readline(), 16) + presence = ((status & (1 << (3 * (self._index - 1) + 1))) == 0) + return presence + + def get_powergood_status(self): + cmd = 'i2cget -y 0 0x36 0x1e' + status = int(Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True).stdout.readline(), 16) + powergood = ((status & (1 << (3 * (self._index - 1) + 2))) != 0) + return powergood diff --git a/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/sfp.py b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/sfp.py new file mode 100644 index 000000000000..3475753cd49d --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/sfp.py @@ -0,0 +1,1618 @@ +#!/usr/bin/env python + +############################################################################# +# Centec +# +# Sfp contains an implementation of SONiC Platform Base API and +# provides the sfp device status which are available in the platform +# +############################################################################# + +import os +import time +import re +import collections +#import subprocess +#import sonic_device_util +from ctypes import create_string_buffer +from subprocess import Popen, PIPE, STDOUT +from sonic_py_common import device_info + +try: + from sonic_platform_base.sfp_base import SfpBase +# from sonic_platform_base.sonic_eeprom import eeprom_dts + from sonic_platform_base.sonic_sfp.sff8472 import sff8472InterfaceId + from sonic_platform_base.sonic_sfp.sff8472 import sff8472Dom + from sonic_platform_base.sonic_sfp.sff8436 import sff8436InterfaceId + from sonic_platform_base.sonic_sfp.sff8436 import sff8436Dom +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +USR_SHARE_SONIC_PATH = "/usr/share/sonic" +HOST_DEVICE_PATH = USR_SHARE_SONIC_PATH + "/device" +CONTAINER_PLATFORM_PATH = USR_SHARE_SONIC_PATH + "/platform" + +QSFP_INFO_OFFSET = 128 +QSFP_DOM_OFFSET = 0 +SFP_INFO_OFFSET = 0 +SFP_DOM_OFFSET = 256 + +# definitions of the offset and width for values in XCVR info eeprom +XCVR_INTFACE_BULK_OFFSET = 0 +XCVR_INTFACE_BULK_WIDTH_QSFP = 20 +XCVR_INTFACE_BULK_WIDTH_SFP = 21 +XCVR_TYPE_OFFSET = 0 +XCVR_TYPE_WIDTH = 1 +XCVR_EXT_TYPE_OFFSET = 1 +XCVR_EXT_TYPE_WIDTH = 1 +XCVR_CONNECTOR_OFFSET = 2 +XCVR_CONNECTOR_WIDTH = 1 +XCVR_COMPLIANCE_CODE_OFFSET = 3 +XCVR_COMPLIANCE_CODE_WIDTH = 8 +XCVR_ENCODING_OFFSET = 11 +XCVR_ENCODING_WIDTH = 1 +XCVR_NBR_OFFSET = 12 +XCVR_NBR_WIDTH = 1 +XCVR_EXT_RATE_SEL_OFFSET = 13 +XCVR_EXT_RATE_SEL_WIDTH = 1 +XCVR_CABLE_LENGTH_OFFSET = 14 +XCVR_CABLE_LENGTH_WIDTH_QSFP = 5 +XCVR_CABLE_LENGTH_WIDTH_SFP = 6 +XCVR_VENDOR_NAME_OFFSET = 20 +XCVR_VENDOR_NAME_WIDTH = 16 +XCVR_VENDOR_OUI_OFFSET = 37 +XCVR_VENDOR_OUI_WIDTH = 3 +XCVR_VENDOR_PN_OFFSET = 40 +XCVR_VENDOR_PN_WIDTH = 16 +XCVR_HW_REV_OFFSET = 56 +XCVR_HW_REV_WIDTH_QSFP = 2 +XCVR_HW_REV_WIDTH_SFP = 4 +XCVR_VENDOR_SN_OFFSET = 68 +XCVR_VENDOR_SN_WIDTH = 16 +XCVR_VENDOR_DATE_OFFSET = 84 +XCVR_VENDOR_DATE_WIDTH = 8 +XCVR_DOM_CAPABILITY_OFFSET = 92 +XCVR_DOM_CAPABILITY_WIDTH = 2 + +XCVR_INTERFACE_DATA_START = 0 +XCVR_INTERFACE_DATA_SIZE = 92 + +QSFP_DOM_BULK_DATA_START = 22 +QSFP_DOM_BULK_DATA_SIZE = 36 +SFP_DOM_BULK_DATA_START = 96 +SFP_DOM_BULK_DATA_SIZE = 10 + +# Offset for values in QSFP eeprom +QSFP_DOM_REV_OFFSET = 1 +QSFP_DOM_REV_WIDTH = 1 +QSFP_TEMPE_OFFSET = 22 +QSFP_TEMPE_WIDTH = 2 +QSFP_VOLT_OFFSET = 26 +QSFP_VOLT_WIDTH = 2 +QSFP_VERSION_COMPLIANCE_OFFSET = 1 +QSFP_VERSION_COMPLIANCE_WIDTH = 1 +QSFP_CHANNL_MON_OFFSET = 34 +QSFP_CHANNL_MON_WIDTH = 16 +QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH = 24 +QSFP_CHANNL_DISABLE_STATUS_OFFSET = 86 +QSFP_CHANNL_DISABLE_STATUS_WIDTH = 1 +QSFP_CHANNL_RX_LOS_STATUS_OFFSET = 3 +QSFP_CHANNL_RX_LOS_STATUS_WIDTH = 1 +QSFP_CHANNL_TX_FAULT_STATUS_OFFSET = 4 +QSFP_CHANNL_TX_FAULT_STATUS_WIDTH = 1 +QSFP_CONTROL_OFFSET = 86 +QSFP_CONTROL_WIDTH = 8 +QSFP_MODULE_MONITOR_OFFSET = 0 +QSFP_MODULE_MONITOR_WIDTH = 9 +QSFP_MODULE_THRESHOLD_OFFSET = 512 +QSFP_MODULE_THRESHOLD_WIDTH = 24 +QSFP_CHANNEL_THRESHOLD_OFFSET = 560 +QSFP_CHANNEL_THRESHOLD_WIDTH = 16 +QSFP_POWEROVERRIDE_OFFSET = 93 +QSFP_POWEROVERRIDE_WIDTH = 1 +QSFP_POWEROVERRIDE_BIT = 0 +QSFP_POWERSET_BIT = 1 +QSFP_OPTION_VALUE_OFFSET = 192 +QSFP_OPTION_VALUE_WIDTH = 4 + +SFP_TEMPE_OFFSET = 96 +SFP_TEMPE_WIDTH = 2 +SFP_VOLT_OFFSET = 98 +SFP_VOLT_WIDTH = 2 +SFP_CHANNL_MON_OFFSET = 100 +SFP_CHANNL_MON_WIDTH = 6 +SFP_MODULE_THRESHOLD_OFFSET = 0 +SFP_MODULE_THRESHOLD_WIDTH = 40 +SFP_CHANNL_THRESHOLD_OFFSET = 112 +SFP_CHANNL_THRESHOLD_WIDTH = 2 +SFP_STATUS_CONTROL_OFFSET = 110 +SFP_STATUS_CONTROL_WIDTH = 1 +SFP_TX_DISABLE_HARD_BIT = 7 +SFP_TX_DISABLE_SOFT_BIT = 6 + +qsfp_cable_length_tup = ('Length(km)', 'Length OM3(2m)', + 'Length OM2(m)', 'Length OM1(m)', + 'Length Cable Assembly(m)') + +sfp_cable_length_tup = ('LengthSMFkm-UnitsOfKm', 'LengthSMF(UnitsOf100m)', + 'Length50um(UnitsOf10m)', 'Length62.5um(UnitsOfm)', + 'LengthCable(UnitsOfm)', 'LengthOM3(UnitsOf10m)') + +sfp_compliance_code_tup = ('10GEthernetComplianceCode', 'InfinibandComplianceCode', + 'ESCONComplianceCodes', 'SONETComplianceCodes', + 'EthernetComplianceCodes','FibreChannelLinkLength', + 'FibreChannelTechnology', 'SFP+CableTechnology', + 'FibreChannelTransmissionMedia','FibreChannelSpeed') + +qsfp_compliance_code_tup = ('10/40G Ethernet Compliance Code', 'SONET Compliance codes', + 'SAS/SATA compliance codes', 'Gigabit Ethernet Compliant codes', + 'Fibre Channel link length/Transmitter Technology', + 'Fibre Channel transmission media', 'Fibre Channel Speed') + +SFP_TYPE = "SFP" +QSFP_TYPE = "QSFP" + + +class Sfp(SfpBase): + """Platform-specific Sfp class""" + + dom_supported = True + dom_temp_supported = True + dom_volt_supported = True + dom_rx_power_supported = True + dom_tx_power_supported = True + dom_tx_disable_supported = True + calibration = 1 + + # Path to QSFP sysfs + PLATFORM_ROOT_PATH = "/usr/share/sonic/device" + PMON_HWSKU_PATH = "/usr/share/sonic/hwsku" + HOST_CHK_CMD = "docker > /dev/null 2>&1" + + PLATFORM = "x86_64-centec_v682_48y8c-r0" + HWSKU = "V682-48y8c" + + def __init__(self, sfp_index, sfp_type): + if os.path.isdir(CONTAINER_PLATFORM_PATH): + platform_path = CONTAINER_PLATFORM_PATH + else: + platform = device_info.get_platform() + if platform is None: + raise + platform_path = os.path.join(HOST_DEVICE_PATH, platform) + + port_config_file = "/".join([platform_path, self.HWSKU, "port_config.ini"]) + try: + f = open(port_config_file) + except: + raise + for line in f: + line.strip() + if re.search('^#', line) is not None: + Port_cfg = collections.namedtuple('Port_cfg', line.split()[1:]) + break + f.close() + f = open(port_config_file) + self._port_cfgs = [Port_cfg(*tuple((line.strip().split()))) + for line in f if re.search('^#', line) is None] + f.close() + + # Port number + self.PORT_START = 256 + self.PORT_END = 0 + self.QSFP_START = 48 + self.QSFP_END = 0 + + for port_cfg in self._port_cfgs: + if int(port_cfg.index) <= self.PORT_START: + self.PORT_START = int(port_cfg.index) + elif int(port_cfg.index) >= self.PORT_END: + self.PORT_END = int(port_cfg.index) + self.QSFP_END = self.PORT_END + + # Init index + self.index = sfp_index + self.port_num = self.index + #self.dom_supported = False + self.sfp_type = sfp_type + # Init eeprom path + eeprom_path = '/sys/bus/i2c/devices/i2c-{0}/{0}-0050/eeprom' + self.port_to_eeprom_mapping = {} + self.port_to_i2c_mapping = { + # mac i2c presence enable(or reset for qsfp) + 32 : (13, 0x36, 0x11, 0, 0x36, 0x0e, 0), + 33 : (12, 0x36, 0x11, 1, 0x36, 0x0e, 1), + 34 : (11, 0x36, 0x11, 2, 0x36, 0x0e, 2), + 35 : (10, 0x36, 0x11, 3, 0x36, 0x0e, 3), + 0 : (17, 0x36, 0x11, 4, 0x36, 0x0e, 4), + 4 : (16, 0x36, 0x11, 5, 0x36, 0x0e, 5), + 8 : (15, 0x36, 0x11, 6, 0x36, 0x0e, 6), + 12 : (14, 0x36, 0x11, 7, 0x36, 0x0e, 7), + 16 : (21, 0x36, 0x12, 0, 0x36, 0x0f, 0), + 20 : (20, 0x36, 0x12, 1, 0x36, 0x0f, 1), + 24 : (19, 0x36, 0x12, 2, 0x36, 0x0f, 2), + 28 : (18, 0x36, 0x12, 3, 0x36, 0x0f, 3), + 40 : (25, 0x36, 0x12, 4, 0x36, 0x0f, 4), + 44 : (24, 0x36, 0x12, 5, 0x36, 0x0f, 5), + 48 : (23, 0x36, 0x12, 6, 0x36, 0x0f, 6), + 52 : (22, 0x36, 0x12, 7, 0x36, 0x0f, 7), + 56 : (29, 0x36, 0x13, 0, 0x36, 0x10, 0), + 60 : (28, 0x36, 0x13, 1, 0x36, 0x10, 1), + 64 : (27, 0x36, 0x13, 2, 0x36, 0x10, 2), + 68 : (26, 0x36, 0x13, 3, 0x36, 0x10, 3), + 72 : (33, 0x36, 0x13, 4, 0x36, 0x10, 4), + 73 : (32, 0x36, 0x13, 5, 0x36, 0x10, 5), + 74 : (31, 0x36, 0x13, 6, 0x36, 0x10, 6), + 75 : (30, 0x36, 0x13, 7, 0x36, 0x10, 7), + 232 : (37, 0x37, 0x11, 0, 0x37, 0x0e, 0), + 233 : (36, 0x37, 0x11, 1, 0x37, 0x0e, 1), + 234 : (35, 0x37, 0x11, 2, 0x37, 0x0e, 2), + 235 : (34, 0x37, 0x11, 3, 0x37, 0x0e, 3), + 200 : (41, 0x37, 0x11, 4, 0x37, 0x0e, 4), + 204 : (40, 0x37, 0x11, 5, 0x37, 0x0e, 5), + 208 : (39, 0x37, 0x11, 6, 0x37, 0x0e, 6), + 212 : (38, 0x37, 0x11, 7, 0x37, 0x0e, 7), + 216 : (45, 0x37, 0x12, 0, 0x37, 0x0f, 0), + 220 : (44, 0x37, 0x12, 1, 0x37, 0x0f, 1), + 224 : (43, 0x37, 0x12, 2, 0x37, 0x0f, 2), + 228 : (42, 0x37, 0x12, 3, 0x37, 0x0f, 3), + 160 : (49, 0x37, 0x12, 4, 0x37, 0x0f, 4), + 164 : (48, 0x37, 0x12, 5, 0x37, 0x0f, 5), + 168 : (47, 0x37, 0x12, 6, 0x37, 0x0f, 6), + 172 : (46, 0x37, 0x12, 7, 0x37, 0x0f, 7), + 176 : (53, 0x37, 0x13, 0, 0x37, 0x10, 0), + 180 : (52, 0x37, 0x13, 1, 0x37, 0x10, 1), + 184 : (51, 0x37, 0x13, 2, 0x37, 0x10, 2), + 188 : (50, 0x37, 0x13, 3, 0x37, 0x10, 3), + 192 : (57, 0x37, 0x13, 4, 0x37, 0x10, 4), + 193 : (56, 0x37, 0x13, 5, 0x37, 0x10, 5), + 194 : (55, 0x37, 0x13, 6, 0x37, 0x10, 6), + 195 : (54, 0x37, 0x13, 7, 0x37, 0x10, 7), + 120 : (61, 0x36, 0x14, 0, 0x36, 0x05, 0), + 121 : (61, 0x36, 0x14, 0, 0x36, 0x05, 0), + 122 : (61, 0x36, 0x14, 0, 0x36, 0x05, 0), + 123 : (61, 0x36, 0x14, 0, 0x36, 0x05, 0), + 124 : (60, 0x36, 0x14, 1, 0x36, 0x05, 1), + 125 : (60, 0x36, 0x14, 1, 0x36, 0x05, 1), + 126 : (60, 0x36, 0x14, 1, 0x36, 0x05, 1), + 127 : (60, 0x36, 0x14, 1, 0x36, 0x05, 1), + 80 : (59, 0x36, 0x14, 2, 0x36, 0x05, 2), + 81 : (59, 0x36, 0x14, 2, 0x36, 0x05, 2), + 82 : (59, 0x36, 0x14, 2, 0x36, 0x05, 2), + 83 : (59, 0x36, 0x14, 2, 0x36, 0x05, 2), + 84 : (58, 0x36, 0x14, 3, 0x36, 0x05, 3), + 85 : (58, 0x36, 0x14, 3, 0x36, 0x05, 3), + 86 : (58, 0x36, 0x14, 3, 0x36, 0x05, 3), + 87 : (58, 0x36, 0x14, 3, 0x36, 0x05, 3), + 240 : (65, 0x37, 0x14, 0, 0x37, 0x05, 0), + 241 : (65, 0x37, 0x14, 0, 0x37, 0x05, 0), + 242 : (65, 0x37, 0x14, 0, 0x37, 0x05, 0), + 243 : (65, 0x37, 0x14, 0, 0x37, 0x05, 0), + 244 : (64, 0x37, 0x14, 1, 0x37, 0x05, 1), + 245 : (64, 0x37, 0x14, 1, 0x37, 0x05, 1), + 246 : (64, 0x37, 0x14, 1, 0x37, 0x05, 1), + 247 : (64, 0x37, 0x14, 1, 0x37, 0x05, 1), + 280 : (63, 0x37, 0x14, 2, 0x37, 0x05, 2), + 281 : (63, 0x37, 0x14, 2, 0x37, 0x05, 2), + 282 : (63, 0x37, 0x14, 2, 0x37, 0x05, 2), + 283 : (63, 0x37, 0x14, 2, 0x37, 0x05, 2), + 284 : (62, 0x37, 0x14, 3, 0x37, 0x05, 3), + 285 : (62, 0x37, 0x14, 3, 0x37, 0x05, 3), + 286 : (62, 0x37, 0x14, 3, 0x37, 0x05, 3), + 287 : (62, 0x37, 0x14, 3, 0x37, 0x05, 3) + } + + for port_cfg in self._port_cfgs: + i2c_idx = self.port_to_i2c_mapping[int(port_cfg.lanes.split(',')[0])][0] + port_eeprom_path = eeprom_path.format(i2c_idx) + self.port_to_eeprom_mapping[int(port_cfg.index)] = port_eeprom_path + + self.info_dict_keys = ['type', 'hardware_rev', 'serial', 'manufacturer', + 'model', 'connector', 'encoding', 'ext_identifier', + 'ext_rateselect_compliance', 'cable_type', 'cable_length', + 'nominal_bit_rate', 'specification_compliance', 'vendor_date', + 'vendor_oui', 'application_advertisement'] + + self.dom_dict_keys = ['rx_los', 'tx_fault', 'reset_status', 'power_lpmode', + 'tx_disable', 'tx_disable_channel', 'temperature', 'voltage', + 'rx1power', 'rx2power', 'rx3power', 'rx4power', 'tx1bias', 'tx2bias', + 'tx3bias', 'tx4bias', 'tx1power', 'tx2power', 'tx3power', 'tx4power'] + + self.threshold_dict_keys = ['temphighalarm', 'temphighwarning', + 'templowalarm', 'templowwarning', 'vcchighalarm', 'vcchighwarning', + 'vcclowalarm', 'vcclowwarning', 'rxpowerhighalarm', 'rxpowerhighwarning', + 'rxpowerlowalarm', 'rxpowerlowwarning', 'txpowerhighalarm', + 'txpowerhighwarning', 'txpowerlowalarm', 'txpowerlowwarning', + 'txbiashighalarm', 'txbiashighwarning', 'txbiaslowalarm', 'txbiaslowwarning'] + + SfpBase.__init__(self) + + + def _convert_string_to_num(self, value_str): + if "-inf" in value_str: + return 'N/A' + elif "Unknown" in value_str: + return 'N/A' + elif 'dBm' in value_str: + t_str = value_str.rstrip('dBm') + return float(t_str) + elif 'mA' in value_str: + t_str = value_str.rstrip('mA') + return float(t_str) + elif 'C' in value_str: + t_str = value_str.rstrip('C') + return float(t_str) + elif 'Volts' in value_str: + t_str = value_str.rstrip('Volts') + return float(t_str) + else: + return 'N/A' + + def __read_txt_file(self, file_path): + try: + with open(file_path, 'r') as fd: + data = fd.read() + return data.strip() + except IOError: + pass + return "" + + def __is_host(self): + return os.system(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 get_presence(self): + """ + Retrieves the presence of the SFP module + Returns: + bool: True if SFP module is present, False if not + """ + # Check for invalid port_num + if self.port_num < self.PORT_START or self.port_num > self.PORT_END: + return False + + sfp_info = self.port_to_i2c_mapping[int(self._port_cfgs[self.port_num].lanes.split(',')[0])] + cmd = 'i2cget -y 0 {0} {1}'.format(sfp_info[1], sfp_info[2]) + presence = int(Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True).stdout.readline(), 16) + presence &= (1 << sfp_info[3]) + + try: + with open(self.port_to_eeprom_mapping[self.port_num], mode='rb', buffering=0) as fd: + fd.read() + except IOError: + return False + + return (presence == 0) + + 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): + eeprom_raw[n] = hex(raw[n])[2:].zfill(2) + except Exception: + eeprom_raw = None + finally: + if sysfsfile_eeprom: + sysfsfile_eeprom.close() + + return eeprom_raw + + def __convert_string_to_num(self, value_str): + if "-inf" in value_str: + return 'N/A' + elif "Unknown" in value_str: + return 'N/A' + elif 'dBm' in value_str: + t_str = value_str.rstrip('dBm') + return float(t_str) + elif 'mA' in value_str: + t_str = value_str.rstrip('mA') + return float(t_str) + elif 'C' in value_str: + t_str = value_str.rstrip('C') + return float(t_str) + elif 'Volts' in value_str: + t_str = value_str.rstrip('Volts') + return float(t_str) + else: + return 'N/A' + + def _dom_capability_detect(self): + if not self.get_presence(): + self.dom_supported = False + self.dom_temp_supported = False + self.dom_volt_supported = False + self.dom_rx_power_supported = False + self.dom_tx_power_supported = False + self.calibration = 0 + return + + if self.sfp_type == "QSFP": + self.calibration = 1 + sfpi_obj = sff8436InterfaceId() + if sfpi_obj is None: + self.dom_supported = False + offset = 128 + + # QSFP capability byte parse, through this byte can know whether it support tx_power or not. + # TODO: in the future when decided to migrate to support SFF-8636 instead of SFF-8436, + # need to add more code for determining the capability and version compliance + # in SFF-8636 dom capability definitions evolving with the versions. + qsfp_dom_capability_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) + if qsfp_dom_capability_raw is not None: + qsfp_dom_capability = int(qsfp_dom_capability_raw[0], 16) + + qsfp_version_compliance_raw = self.__read_eeprom_specific_bytes( + QSFP_VERSION_COMPLIANCE_OFFSET, QSFP_VERSION_COMPLIANCE_OFFSET) + if qsfp_version_compliance_raw is not None: + qsfp_version_compliance = int(qsfp_version_compliance_raw[0], 16) + else: + self.dom_supported = False + self.dom_temp_supported = False + self.dom_volt_supported = False + self.dom_rx_power_supported = False + self.dom_tx_power_supported = False + self.calibration = 0 + return + + if qsfp_version_compliance >= 0x08: + self.dom_temp_supported = (qsfp_dom_capability & 0x20 != 0) + self.dom_volt_supported = (qsfp_dom_capability & 0x10 != 0) + self.dom_rx_power_supported = (qsfp_dom_capability & 0x08 != 0) + self.dom_tx_power_supported = (qsfp_dom_capability & 0x04 != 0) + else: + self.dom_temp_supported = True + self.dom_volt_supported = True + self.dom_rx_power_supported = (qsfp_dom_capability & 0x08 != 0) + self.dom_tx_power_supported = True + self.dom_supported = True + self.calibration = 1 + self.dom_tx_disable_supported = True + else: + self.dom_supported = False + self.dom_temp_supported = False + self.dom_volt_supported = False + self.dom_rx_power_supported = False + self.dom_tx_power_supported = False + self.calibration = 0 + elif self.sfp_type == "SFP": + sfpi_obj = sff8472InterfaceId() + if sfpi_obj is None: + return None + sfp_dom_capability_raw = self.__read_eeprom_specific_bytes( + XCVR_DOM_CAPABILITY_OFFSET, XCVR_DOM_CAPABILITY_WIDTH) + if sfp_dom_capability_raw is not None: + sfp_dom_capability = int(sfp_dom_capability_raw[0], 16) + self.dom_supported = (sfp_dom_capability & 0x40 != 0) + if self.dom_supported: + self.dom_temp_supported = True + self.dom_volt_supported = True + self.dom_rx_power_supported = True + self.dom_tx_power_supported = True + if sfp_dom_capability & 0x20 != 0: + self.calibration = 1 + elif sfp_dom_capability & 0x10 != 0: + self.calibration = 2 + else: + self.calibration = 0 + else: + self.dom_temp_supported = False + self.dom_volt_supported = False + self.dom_rx_power_supported = False + self.dom_tx_power_supported = False + self.calibration = 0 + self.dom_tx_disable_supported = (int(sfp_dom_capability_raw[1], 16) & 0x40 != 0) + else: + self.dom_supported = False + self.dom_temp_supported = False + self.dom_volt_supported = False + self.dom_rx_power_supported = False + self.dom_tx_power_supported = False + + def get_transceiver_info(self): + """ + Retrieves transceiver info of this SFP + Returns: + A dict which contains following keys/values : + ======================================================================== + keys |Value Format |Information + ---------------------------|---------------|---------------------------- + type |1*255VCHAR |type of SFP + hardware_rev |1*255VCHAR |hardware version of SFP + serial |1*255VCHAR |serial number of the SFP + manufacturer |1*255VCHAR |SFP vendor name + model |1*255VCHAR |SFP model name + connector |1*255VCHAR |connector information + encoding |1*255VCHAR |encoding information + ext_identifier |1*255VCHAR |extend identifier + ext_rateselect_compliance |1*255VCHAR |extended rateSelect compliance + cable_length |INT |cable length in m + nominal_bit_rate |INT |nominal bit rate by 100Mbs + specification_compliance |1*255VCHAR |specification compliance + vendor_date |1*255VCHAR |vendor date + vendor_oui |1*255VCHAR |vendor OUI + application_advertisement |1*255VCHAR |supported applications advertisement + ======================================================================== + """ + + transceiver_info_dict = {} + compliance_code_dict = {} + transceiver_info_dict = dict.fromkeys(self.info_dict_keys, 'N/A') + transceiver_info_dict['specification_compliance'] = '{}' + if not self.get_presence(): + return transceiver_info_dict + + if self.sfp_type == QSFP_TYPE: + offset = QSFP_INFO_OFFSET + vendor_rev_width = XCVR_HW_REV_WIDTH_QSFP + interface_info_bulk_width = XCVR_INTFACE_BULK_WIDTH_QSFP + + sfpi_obj = sff8436InterfaceId() + if sfpi_obj is None: + print("Error: sfp_object open failed") + return transceiver_info_dict + + elif self.sfp_type == SFP_TYPE: + offset = SFP_INFO_OFFSET + vendor_rev_width = XCVR_HW_REV_WIDTH_SFP + interface_info_bulk_width = XCVR_INTFACE_BULK_WIDTH_SFP + + sfpi_obj = sff8472InterfaceId() + if sfpi_obj is None: + print("Error: sfp_object open failed") + return transceiver_info_dict + else: + return transceiver_info_dict + + # Add retry for xcvr eeprom to get ready + max_retry = 10 + for i in range(0,max_retry): + sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes( + offset + XCVR_INTERFACE_DATA_START, XCVR_INTERFACE_DATA_SIZE) + if sfp_interface_bulk_raw is not None: + break + else: + if not self.get_presence(): + return transceiver_info_dict + elif i == max_retry-1: + pass + else: + time.sleep(0.5) + + if sfp_interface_bulk_raw is None: + return transceiver_info_dict + + start = XCVR_INTFACE_BULK_OFFSET - XCVR_INTERFACE_DATA_START + end = start + interface_info_bulk_width + sfp_interface_bulk_data = sfpi_obj.parse_sfp_info_bulk(sfp_interface_bulk_raw[start : end], 0) + + start = XCVR_VENDOR_NAME_OFFSET - XCVR_INTERFACE_DATA_START + end = start + XCVR_VENDOR_NAME_WIDTH + sfp_vendor_name_data = sfpi_obj.parse_vendor_name(sfp_interface_bulk_raw[start : end], 0) + + start = XCVR_VENDOR_PN_OFFSET - XCVR_INTERFACE_DATA_START + end = start + XCVR_VENDOR_PN_WIDTH + sfp_vendor_pn_data = sfpi_obj.parse_vendor_pn(sfp_interface_bulk_raw[start : end], 0) + + start = XCVR_HW_REV_OFFSET - XCVR_INTERFACE_DATA_START + end = start + vendor_rev_width + sfp_vendor_rev_data = sfpi_obj.parse_vendor_rev(sfp_interface_bulk_raw[start : end], 0) + + start = XCVR_VENDOR_SN_OFFSET - XCVR_INTERFACE_DATA_START + end = start + XCVR_VENDOR_SN_WIDTH + sfp_vendor_sn_data = sfpi_obj.parse_vendor_sn(sfp_interface_bulk_raw[start : end], 0) + + start = XCVR_VENDOR_OUI_OFFSET - XCVR_INTERFACE_DATA_START + end = start + XCVR_VENDOR_OUI_WIDTH + sfp_vendor_oui_data = sfpi_obj.parse_vendor_oui(sfp_interface_bulk_raw[start : end], 0) + + start = XCVR_VENDOR_DATE_OFFSET - XCVR_INTERFACE_DATA_START + end = start + XCVR_VENDOR_DATE_WIDTH + sfp_vendor_date_data = sfpi_obj.parse_vendor_date(sfp_interface_bulk_raw[start : end], 0) + transceiver_info_dict['type'] = sfp_interface_bulk_data \ + ['data']['type']['value'] + transceiver_info_dict['manufacturer'] = sfp_vendor_name_data \ + ['data']['Vendor Name']['value'] + transceiver_info_dict['model'] = sfp_vendor_pn_data \ + ['data']['Vendor PN']['value'] + transceiver_info_dict['hardware_rev'] = sfp_vendor_rev_data \ + ['data']['Vendor Rev']['value'] + transceiver_info_dict['serial'] = sfp_vendor_sn_data \ + ['data']['Vendor SN']['value'] + transceiver_info_dict['vendor_oui'] = sfp_vendor_oui_data \ + ['data']['Vendor OUI']['value'] + transceiver_info_dict['vendor_date'] = sfp_vendor_date_data \ + ['data']['VendorDataCode(YYYY-MM-DD Lot)']['value'] + transceiver_info_dict['connector'] = sfp_interface_bulk_data \ + ['data']['Connector']['value'] + transceiver_info_dict['encoding'] = sfp_interface_bulk_data \ + ['data']['EncodingCodes']['value'] + transceiver_info_dict['ext_identifier'] = sfp_interface_bulk_data \ + ['data']['Extended Identifier']['value'] + transceiver_info_dict['ext_rateselect_compliance'] = sfp_interface_bulk_data \ + ['data']['RateIdentifier']['value'] + transceiver_info_dict['type_abbrv_name'] = 'N/A' + if self.sfp_type == QSFP_TYPE: + for key in qsfp_cable_length_tup: + if key in sfp_interface_bulk_data['data']: + transceiver_info_dict['cable_type'] = key + transceiver_info_dict['cable_length'] = str( + sfp_interface_bulk_data['data'][key]['value']) + + for key in qsfp_compliance_code_tup: + if key in sfp_interface_bulk_data['data']['Specification compliance']['value']: + compliance_code_dict[key] = sfp_interface_bulk_data \ + ['data']['Specification compliance']['value'][key]['value'] + transceiver_info_dict['specification_compliance'] = str(compliance_code_dict) + + transceiver_info_dict['nominal_bit_rate'] = str(sfp_interface_bulk_data \ + ['data']['Nominal Bit Rate(100Mbs)']['value']) + else: + for key in sfp_cable_length_tup: + if key in sfp_interface_bulk_data['data']: + transceiver_info_dict['cable_type'] = key + transceiver_info_dict['cable_length'] = str( + sfp_interface_bulk_data['data'][key]['value']) + + for key in sfp_compliance_code_tup: + if key in sfp_interface_bulk_data['data']['Specification compliance']['value']: + compliance_code_dict[key] = sfp_interface_bulk_data \ + ['data']['Specification compliance']['value'][key]['value'] + transceiver_info_dict['specification_compliance'] = str(compliance_code_dict) + + transceiver_info_dict['nominal_bit_rate'] = str(sfp_interface_bulk_data \ + ['data']['NominalSignallingRate(UnitsOf100Mbd)']['value']) + + return transceiver_info_dict + + def get_transceiver_bulk_status(self): + """ + Retrieves transceiver bulk status of this SFP + Returns: + A dict which contains following keys/values : + ======================================================================== + keys |Value Format |Information + ---------------------------|---------------|---------------------------- + rx_los |BOOLEAN |RX loss-of-signal status, True if has RX los, False if not. + tx_fault |BOOLEAN |TX fault status, True if has TX fault, False if not. + reset_status |BOOLEAN |reset status, True if SFP in reset, False if not. + lp_mode |BOOLEAN |low power mode status, True in lp mode, False if not. + tx_disable |BOOLEAN |TX disable status, True TX disabled, False if not. + tx_disabled_channel |HEX |disabled TX channels in hex, bits 0 to 3 represent channel 0 + | |to channel 3. + temperature |INT |module temperature in Celsius + voltage |INT |supply voltage in mV + txbias |INT |TX Bias Current in mA, n is the channel number, + | |for example, tx2bias stands for tx bias of channel 2. + rxpower |INT |received optical power in mW, n is the channel number, + | |for example, rx2power stands for rx power of channel 2. + txpower |INT |TX output power in mW, n is the channel number, + | |for example, tx2power stands for tx power of channel 2. + ======================================================================== + """ + + if not self.get_presence(): + return None + + self._dom_capability_detect() + + if self.sfp_type == QSFP_TYPE: + sfpd_obj = sff8436Dom() + sfpi_obj = sff8436InterfaceId() + + if not sfpi_obj or not sfpd_obj: + return None + + transceiver_dom_info_dict = dict.fromkeys(self.dom_dict_keys, 'N/A') + offset = QSFP_DOM_OFFSET + offset_xcvr = QSFP_INFO_OFFSET + + # QSFP capability byte parse, through this byte can know whether it support tx_power or not. + # TODO: in the future when decided to migrate to support SFF-8636 instead of SFF-8436, + # need to add more code for determining the capability and version compliance + # in SFF-8636 dom capability definitions evolving with the versions. + qsfp_dom_capability_raw = self.__read_eeprom_specific_bytes( + (offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) + if qsfp_dom_capability_raw is not None: + qsfp_dom_capability_data = sfpi_obj.parse_dom_capability( + qsfp_dom_capability_raw, 0) + else: + return None + + dom_temperature_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_TEMPE_OFFSET), QSFP_TEMPE_WIDTH) + if dom_temperature_raw is not None: + dom_temperature_data = sfpd_obj.parse_temperature( + dom_temperature_raw, 0) + transceiver_dom_info_dict['temperature'] = dom_temperature_data['data']['Temperature']['value'] + + dom_voltage_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_VOLT_OFFSET), QSFP_VOLT_WIDTH) + if dom_voltage_raw is not None: + dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) + transceiver_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc']['value'] + + qsfp_dom_rev_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_DOM_REV_OFFSET), QSFP_DOM_REV_WIDTH) + if qsfp_dom_rev_raw is not None: + qsfp_dom_rev_data = sfpd_obj.parse_sfp_dom_rev(qsfp_dom_rev_raw, 0) + qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value'] + + # The tx_power monitoring is only available on QSFP which compliant with SFF-8636 + # and claimed that it support tx_power with one indicator bit. + dom_channel_monitor_data = {} + dom_channel_monitor_raw = None + qsfp_tx_power_support = qsfp_dom_capability_data['data']['Tx_power_support']['value'] + if (qsfp_dom_rev[0:8] != 'SFF-8636' or (qsfp_dom_rev[0:8] == 'SFF-8636' and qsfp_tx_power_support != 'on')): + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WIDTH) + if dom_channel_monitor_raw is not None: + dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params( + dom_channel_monitor_raw, 0) + + else: + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) + if dom_channel_monitor_raw is not None: + dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power( + dom_channel_monitor_raw, 0) + transceiver_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TX1Power']['value'] + transceiver_dom_info_dict['tx2power'] = dom_channel_monitor_data['data']['TX2Power']['value'] + transceiver_dom_info_dict['tx3power'] = dom_channel_monitor_data['data']['TX3Power']['value'] + transceiver_dom_info_dict['tx4power'] = dom_channel_monitor_data['data']['TX4Power']['value'] + + if dom_channel_monitor_raw: + transceiver_dom_info_dict['rx1power'] = dom_channel_monitor_data['data']['RX1Power']['value'] + transceiver_dom_info_dict['rx2power'] = dom_channel_monitor_data['data']['RX2Power']['value'] + transceiver_dom_info_dict['rx3power'] = dom_channel_monitor_data['data']['RX3Power']['value'] + transceiver_dom_info_dict['rx4power'] = dom_channel_monitor_data['data']['RX4Power']['value'] + transceiver_dom_info_dict['tx1bias'] = dom_channel_monitor_data['data']['TX1Bias']['value'] + transceiver_dom_info_dict['tx2bias'] = dom_channel_monitor_data['data']['TX2Bias']['value'] + transceiver_dom_info_dict['tx3bias'] = dom_channel_monitor_data['data']['TX3Bias']['value'] + transceiver_dom_info_dict['tx4bias'] = dom_channel_monitor_data['data']['TX4Bias']['value'] + elif self.sfp_type == SFP_TYPE: + sfpd_obj = sff8472Dom() + if not sfpd_obj: + return None + + eeprom_ifraw = self.__read_eeprom_specific_bytes(0, SFP_DOM_OFFSET) + if eeprom_ifraw is not None: + sfpi_obj = sff8472InterfaceId(eeprom_ifraw) + cal_type = sfpi_obj.get_calibration_type() + sfpd_obj._calibration_type = cal_type + + offset = SFP_DOM_OFFSET + transceiver_dom_info_dict = dict.fromkeys(self.dom_dict_keys, 'N/A') + dom_temperature_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH) + + if dom_temperature_raw is not None: + dom_temperature_data = sfpd_obj.parse_temperature( + dom_temperature_raw, 0) + transceiver_dom_info_dict['temperature'] = dom_temperature_data['data']['Temperature']['value'] + + dom_voltage_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH) + if dom_voltage_raw is not None: + dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) + transceiver_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc']['value'] + + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH) + if dom_channel_monitor_raw is not None: + dom_voltage_data = sfpd_obj.parse_channel_monitor_params( + dom_channel_monitor_raw, 0) + transceiver_dom_info_dict['tx1power'] = dom_voltage_data['data']['TXPower']['value'] + transceiver_dom_info_dict['rx1power'] = dom_voltage_data['data']['RXPower']['value'] + transceiver_dom_info_dict['tx1bias'] = dom_voltage_data['data']['TXBias']['value'] + else: + return None + + for key in transceiver_dom_info_dict: + transceiver_dom_info_dict[key] = self._convert_string_to_num( + transceiver_dom_info_dict[key]) + + transceiver_dom_info_dict['rx_los'] = self.get_rx_los() + transceiver_dom_info_dict['tx_fault'] = self.get_tx_fault() + transceiver_dom_info_dict['reset_status'] = self.get_reset_status() + transceiver_dom_info_dict['lp_mode'] = self.get_lpmode() + transceiver_dom_info_dict['tx_disable'] = self.get_tx_disable() + transceiver_dom_info_dict['tx_disable_channel'] = self.get_tx_disable_channel() + + return transceiver_dom_info_dict + + def get_transceiver_threshold_info(self): + """ + Retrieves transceiver threshold info of this SFP + + Returns: + A dict which contains following keys/values : + ======================================================================== + keys |Value Format |Information + ---------------------------|---------------|---------------------------- + temphighalarm |FLOAT |High Alarm Threshold value of temperature in Celsius. + templowalarm |FLOAT |Low Alarm Threshold value of temperature in Celsius. + temphighwarning |FLOAT |High Warning Threshold value of temperature in Celsius. + templowwarning |FLOAT |Low Warning Threshold value of temperature in Celsius. + vcchighalarm |FLOAT |High Alarm Threshold value of supply voltage in mV. + vcclowalarm |FLOAT |Low Alarm Threshold value of supply voltage in mV. + vcchighwarning |FLOAT |High Warning Threshold value of supply voltage in mV. + vcclowwarning |FLOAT |Low Warning Threshold value of supply voltage in mV. + rxpowerhighalarm |FLOAT |High Alarm Threshold value of received power in dBm. + rxpowerlowalarm |FLOAT |Low Alarm Threshold value of received power in dBm. + rxpowerhighwarning |FLOAT |High Warning Threshold value of received power in dBm. + rxpowerlowwarning |FLOAT |Low Warning Threshold value of received power in dBm. + txpowerhighalarm |FLOAT |High Alarm Threshold value of transmit power in dBm. + txpowerlowalarm |FLOAT |Low Alarm Threshold value of transmit power in dBm. + txpowerhighwarning |FLOAT |High Warning Threshold value of transmit power in dBm. + txpowerlowwarning |FLOAT |Low Warning Threshold value of transmit power in dBm. + txbiashighalarm |FLOAT |High Alarm Threshold value of tx Bias Current in mA. + txbiaslowalarm |FLOAT |Low Alarm Threshold value of tx Bias Current in mA. + txbiashighwarning |FLOAT |High Warning Threshold value of tx Bias Current in mA. + txbiaslowwarning |FLOAT |Low Warning Threshold value of tx Bias Current in mA. + ======================================================================== + """ + transceiver_dom_threshold_info_dict_keys = ['temphighalarm', 'temphighwarning', 'templowalarm', 'templowwarning', + 'vcchighalarm', 'vcchighwarning', 'vcclowalarm', 'vcclowwarning', + 'rxpowerhighalarm', 'rxpowerhighwarning', 'rxpowerlowalarm', 'rxpowerlowwarning', + 'txpowerhighalarm', 'txpowerhighwarning', 'txpowerlowalarm', 'txpowerlowwarning', + 'txbiashighalarm', 'txbiashighwarning', 'txbiaslowalarm', 'txbiaslowwarning'] + + if self.sfp_type == QSFP_TYPE: + sfpd_obj = sff8436Dom() + if not self.get_presence() or not sfpd_obj: + return None + DOM_OFFSET = 0 + transceiver_dom_threshold_dict = dict.fromkeys(transceiver_dom_threshold_info_dict_keys, 'N/A') + offset = DOM_OFFSET + + dom_module_threshold_raw = self.__read_eeprom_specific_bytes((offset + QSFP_MODULE_THRESHOLD_OFFSET), QSFP_MODULE_THRESHOLD_WIDTH) + if dom_module_threshold_raw is not None: + module_threshold_values = sfpd_obj.parse_module_threshold_values(dom_module_threshold_raw, 0) + module_threshold_data = module_threshold_values.get('data') + if module_threshold_data: + transceiver_dom_threshold_dict['temphighalarm'] = module_threshold_data['TempHighAlarm']['value'] + transceiver_dom_threshold_dict['templowalarm'] = module_threshold_data['TempLowAlarm']['value'] + transceiver_dom_threshold_dict['temphighwarning'] = module_threshold_data['TempHighWarning']['value'] + transceiver_dom_threshold_dict['templowwarning'] = module_threshold_data['TempLowWarning']['value'] + transceiver_dom_threshold_dict['vcchighalarm'] = module_threshold_data['VccHighAlarm']['value'] + transceiver_dom_threshold_dict['vcclowalarm'] = module_threshold_data['VccLowAlarm']['value'] + transceiver_dom_threshold_dict['vcchighwarning'] = module_threshold_data['VccHighWarning']['value'] + transceiver_dom_threshold_dict['vcclowwarning'] = module_threshold_data['VccLowWarning']['value'] + + dom_channel_thres_raw = self.__read_eeprom_specific_bytes((offset + QSFP_CHANNEL_THRESHOLD_OFFSET), QSFP_CHANNEL_THRESHOLD_WIDTH) + if dom_channel_thres_raw is not None: + channel_threshold_values = sfpd_obj.parse_channel_threshold_values(dom_channel_thres_raw, 0) + channel_threshold_data = channel_threshold_values.get('data') + else: + channel_threshold_data = None + if channel_threshold_data: + transceiver_dom_threshold_dict['rxpowerhighalarm'] = channel_threshold_data['RxPowerHighAlarm']['value'] + transceiver_dom_threshold_dict['rxpowerlowalarm'] = channel_threshold_data['RxPowerLowAlarm']['value'] + transceiver_dom_threshold_dict['rxpowerhighwarning'] = channel_threshold_data['RxPowerHighWarning']['value'] + transceiver_dom_threshold_dict['rxpowerlowwarning'] = channel_threshold_data['RxPowerLowWarning']['value'] + transceiver_dom_threshold_dict['txpowerhighalarm'] = "0.0dBm" + transceiver_dom_threshold_dict['txpowerlowalarm'] = "0.0dBm" + transceiver_dom_threshold_dict['txpowerhighwarning'] = "0.0dBm" + transceiver_dom_threshold_dict['txpowerlowwarning'] = "0.0dBm" + transceiver_dom_threshold_dict['txbiashighalarm'] = channel_threshold_data['TxBiasHighAlarm']['value'] + transceiver_dom_threshold_dict['txbiaslowalarm'] = channel_threshold_data['TxBiasLowAlarm']['value'] + transceiver_dom_threshold_dict['txbiashighwarning'] = channel_threshold_data['TxBiasHighWarning']['value'] + transceiver_dom_threshold_dict['txbiaslowwarning'] = channel_threshold_data['TxBiasLowWarning']['value'] + + for key in transceiver_dom_threshold_dict: + transceiver_dom_threshold_dict[key] = self.__convert_string_to_num(transceiver_dom_threshold_dict[key]) + + return transceiver_dom_threshold_dict + + elif self.sfp_type == SFP_TYPE: + sfpd_obj = sff8472Dom() + + if not self.get_presence() and not sfpd_obj: + return None + DOM_OFFSET = 256 + eeprom_ifraw = self.__read_eeprom_specific_bytes(0, DOM_OFFSET) + if eeprom_ifraw is not None: + sfpi_obj = sff8472InterfaceId(eeprom_ifraw) + cal_type = sfpi_obj.get_calibration_type() + sfpd_obj._calibration_type = cal_type + + offset = DOM_OFFSET + transceiver_dom_threshold_info_dict = dict.fromkeys(transceiver_dom_threshold_info_dict_keys, 'N/A') + dom_module_threshold_raw = self.__read_eeprom_specific_bytes((offset + SFP_MODULE_THRESHOLD_OFFSET), SFP_MODULE_THRESHOLD_WIDTH) + if dom_module_threshold_raw is not None: + dom_module_threshold_data = sfpd_obj.parse_alarm_warning_threshold(dom_module_threshold_raw, 0) + + transceiver_dom_threshold_info_dict['temphighalarm'] = dom_module_threshold_data['data']['TempHighAlarm']['value'] + transceiver_dom_threshold_info_dict['templowalarm'] = dom_module_threshold_data['data']['TempLowAlarm']['value'] + transceiver_dom_threshold_info_dict['temphighwarning'] = dom_module_threshold_data['data']['TempHighWarning']['value'] + transceiver_dom_threshold_info_dict['templowwarning'] = dom_module_threshold_data['data']['TempLowWarning']['value'] + + transceiver_dom_threshold_info_dict['vcchighalarm'] = dom_module_threshold_data['data']['VoltageHighAlarm']['value'] + transceiver_dom_threshold_info_dict['vcclowalarm'] = dom_module_threshold_data['data']['VoltageLowAlarm']['value'] + transceiver_dom_threshold_info_dict['vcchighwarning'] = dom_module_threshold_data['data']['VoltageHighWarning']['value'] + transceiver_dom_threshold_info_dict['vcclowwarning'] = dom_module_threshold_data['data']['VoltageLowWarning']['value'] + + transceiver_dom_threshold_info_dict['txbiashighalarm'] = dom_module_threshold_data['data']['BiasHighAlarm']['value'] + transceiver_dom_threshold_info_dict['txbiaslowalarm'] = dom_module_threshold_data['data']['BiasLowAlarm']['value'] + transceiver_dom_threshold_info_dict['txbiashighwarning'] = dom_module_threshold_data['data']['BiasHighWarning']['value'] + transceiver_dom_threshold_info_dict['txbiaslowwarning'] = dom_module_threshold_data['data']['BiasLowWarning']['value'] + + transceiver_dom_threshold_info_dict['txpowerhighalarm'] = dom_module_threshold_data['data']['TXPowerHighAlarm']['value'] + transceiver_dom_threshold_info_dict['txpowerlowalarm'] = dom_module_threshold_data['data']['TXPowerLowAlarm']['value'] + transceiver_dom_threshold_info_dict['txpowerhighwarning'] = dom_module_threshold_data['data']['TXPowerHighWarning']['value'] + transceiver_dom_threshold_info_dict['txpowerlowwarning'] = dom_module_threshold_data['data']['TXPowerLowWarning']['value'] + + transceiver_dom_threshold_info_dict['rxpowerhighalarm'] = dom_module_threshold_data['data']['RXPowerHighAlarm']['value'] + transceiver_dom_threshold_info_dict['rxpowerlowalarm'] = dom_module_threshold_data['data']['RXPowerLowAlarm']['value'] + transceiver_dom_threshold_info_dict['rxpowerhighwarning'] = dom_module_threshold_data['data']['RXPowerHighWarning']['value'] + transceiver_dom_threshold_info_dict['rxpowerlowwarning'] = dom_module_threshold_data['data']['RXPowerLowWarning']['value'] + + for key in transceiver_dom_threshold_info_dict: + transceiver_dom_threshold_info_dict[key] = self.__convert_string_to_num(transceiver_dom_threshold_info_dict[key]) + + return transceiver_dom_threshold_info_dict + + else: + return None + + def get_reset_status(self): + """ + Retrieves the reset status of SFP + Returns: + A Boolean, True if reset enabled, False if disabled + """ + # Check for invalid port_num + if self.port_num < self.PORT_START or self.port_num > self.PORT_END or self.sfp_type == SFP_TYPE: + return False + + sfp_info = self.port_to_i2c_mapping[int(self._port_cfgs[self.port_num].lanes.split(',')[0])] + cmd = 'i2cget -y 0 {0} {1}'.format(sfp_info[4], sfp_info[5]) + reset_status = int(Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True).stdout.readline(), 16) + reset_status &= (1 << sfp_info[6]) + + return (reset_status == 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 not self.dom_supported: + return None + + rx_los_list = [] + + if self.sfp_type == QSFP_TYPE: + offset = 0 + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_CHANNL_RX_LOS_STATUS_OFFSET), QSFP_CHANNL_RX_LOS_STATUS_WIDTH) + 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) + elif self.sfp_type == SFP_TYPE: + offset = 256 + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_STATUS_CONTROL_OFFSET), SFP_STATUS_CONTROL_WIDTH) + 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 & 0x02 != 0) + else: + return None + else: + return None + + return rx_los_list + + def get_tx_fault(self): + """ + Retrieves the TX fault status of SFP + Returns: + A Boolean, True if SFP has TX fault, False if not + Note : TX fault status is lached until a call to get_tx_fault or a reset. + """ + if not self.dom_supported: + return None + + tx_fault_list = [] + + if self.sfp_type == QSFP_TYPE: + offset = 0 + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_CHANNL_TX_FAULT_STATUS_OFFSET), QSFP_CHANNL_TX_FAULT_STATUS_WIDTH) + 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) + elif self.sfp_type == SFP_TYPE: + offset = 256 + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_STATUS_CONTROL_OFFSET), SFP_STATUS_CONTROL_WIDTH) + 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 & 0x04 != 0) + else: + return None + else: + return None + + return tx_fault_list + + def get_tx_disable(self): + """ + Retrieves the tx_disable status of this SFP + Returns: + A Boolean, True if tx_disable is enabled, False if disabled + """ + if not self.dom_supported: + return None + + tx_disable_list = [] + + if self.sfp_type == QSFP_TYPE: + offset = 0 + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_CHANNL_DISABLE_STATUS_OFFSET), QSFP_CHANNL_DISABLE_STATUS_WIDTH) + if dom_channel_monitor_raw is not None: + tx_disable_data = int(dom_channel_monitor_raw[0], 16) + tx_disable_list.append(tx_disable_data & 0x01 != 0) + tx_disable_list.append(tx_disable_data & 0x02 != 0) + tx_disable_list.append(tx_disable_data & 0x04 != 0) + tx_disable_list.append(tx_disable_data & 0x08 != 0) + elif self.sfp_type == SFP_TYPE: + offset = 256 + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_STATUS_CONTROL_OFFSET), SFP_STATUS_CONTROL_WIDTH) + if dom_channel_monitor_raw is not None: + tx_disable_data = int(dom_channel_monitor_raw[0], 16) + tx_disable_list.append(tx_disable_data & 0xC0 != 0) + else: + return None + else: + return None + + return tx_disable_list + + 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. + """ + # SFP doesn't support this feature + if self.sfp_type == SFP_TYPE: + return 0 + elif self.sfp_type == QSFP_TYPE: + 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 + else: + return None + + return tx_disabled + + def get_lpmode(self): + """ + Retrieves the lpmode (low power mode) status of this QSFP module + Returns: + A Boolean, True if lpmode is enabled, False if disabled + """ + return False + + 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 + """ + # SFP doesn't support this feature + if self.sfp_type == SFP_TYPE: + return False + elif self.sfp_type == QSFP_TYPE: + offset = 0 + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return False + + dom_control_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_POWEROVERRIDE_OFFSET), QSFP_POWEROVERRIDE_WIDTH) + if dom_control_raw is not None: + if int(dom_control_raw[0],16) & (0x01 << QSFP_POWEROVERRIDE_BIT): + return True + else: + return False + else: + return None + + def get_temperature(self): + """ + Retrieves the temperature of this SFP + Returns: + An integer number of current temperature in Celsius + """ + if not self.dom_supported: + return None + if self.sfp_type == QSFP_TYPE: + offset = 0 + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return None + + if self.dom_temp_supported: + dom_temperature_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_TEMPE_OFFSET), QSFP_TEMPE_WIDTH) + if dom_temperature_raw is not None: + dom_temperature_data = sfpd_obj.parse_temperature(dom_temperature_raw, 0) + temp = self._convert_string_to_num( + dom_temperature_data['data']['Temperature']['value']) + return temp + else: + return None + elif self.sfp_type == SFP_TYPE: + offset = 256 + sfpd_obj = sff8472Dom() + if sfpd_obj is None: + return None + sfpd_obj._calibration_type = 1 + + dom_temperature_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH) + if dom_temperature_raw is not None: + dom_temperature_data = sfpd_obj.parse_temperature(dom_temperature_raw, 0) + temp = self._convert_string_to_num( + dom_temperature_data['data']['Temperature']['value']) + return temp + else: + return None + else: + return None + + def get_voltage(self): + """ + Retrieves the supply voltage of this SFP + Returns: + An integer number of supply voltage in mV + """ + if not self.dom_supported: + return None + if self.sfp_type == QSFP_TYPE: + offset = 0 + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return None + + if self.dom_volt_supported: + dom_voltage_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_VOLT_OFFSET), QSFP_VOLT_WIDTH) + if dom_voltage_raw is not None: + dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) + voltage = self._convert_string_to_num( + dom_voltage_data['data']['Vcc']['value']) + return voltage + else: + return None + elif self.sfp_type == SFP_TYPE: + offset = 256 + + sfpd_obj = sff8472Dom() + if sfpd_obj is None: + return None + + sfpd_obj._calibration_type = self.calibration + + dom_voltage_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH) + if dom_voltage_raw is not None: + dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0) + voltage = self._convert_string_to_num( + dom_voltage_data['data']['Vcc']['value']) + return voltage + else: + return None + else: + return None + + def get_tx_bias(self): + """ + Retrieves the TX bias current of this SFP + Returns: + A list of four integer numbers, representing TX bias in mA + for channel 0 to channel 4. + Ex. ['110.09', '111.12', '108.21', '112.09'] + """ + tx_bias_list = [] + if self.sfp_type == QSFP_TYPE: + offset = 0 + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return None + + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) + if dom_channel_monitor_raw is not None: + dom_channel_monitor_data = \ + sfpd_obj.parse_channel_monitor_params_with_tx_power(dom_channel_monitor_raw, 0) + tx_bias_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX1Bias']['value'])) + tx_bias_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX2Bias']['value'])) + tx_bias_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX3Bias']['value'])) + tx_bias_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX4Bias']['value'])) + elif self.sfp_type == SFP_TYPE: + offset = 256 + + sfpd_obj = sff8472Dom() + if sfpd_obj is None: + return None + sfpd_obj._calibration_type = self.calibration + + if self.dom_supported: + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH) + if dom_channel_monitor_raw is not None: + dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params( \ + dom_channel_monitor_raw, 0) + tx_bias_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TXBias']['value'])) + else: + return None + else: + return None + else: + return None + + return tx_bias_list + + def get_rx_power(self): + """ + Retrieves the received optical power for this SFP + Returns: + A list of four integer numbers, representing received optical + power in mW for channel 0 to channel 4. + Ex. ['1.77', '1.71', '1.68', '1.70'] + """ + rx_power_list = [] + + if self.sfp_type == QSFP_TYPE: + offset = 0 + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return None + + if self.dom_rx_power_supported: + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) + if dom_channel_monitor_raw is not None: + dom_channel_monitor_data = \ + sfpd_obj.parse_channel_monitor_params_with_tx_power(dom_channel_monitor_raw, 0) + rx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['RX1Power']['value'])) + rx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['RX2Power']['value'])) + rx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['RX3Power']['value'])) + rx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['RX4Power']['value'])) + else: + return None + else: + return None + elif self.sfp_type == SFP_TYPE: + offset = 256 + + sfpd_obj = sff8472Dom() + if sfpd_obj is None: + return None + + if self.dom_supported: + sfpd_obj._calibration_type = self.calibration + + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH) + if dom_channel_monitor_raw is not None: + dom_channel_monitor_data = \ + sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0) + rx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['RXPower']['value'])) + else: + return None + else: + return None + else: + return None + + return rx_power_list + + def get_tx_power(self): + """ + Retrieves the TX power of this SFP + Returns: + A list of four integer numbers, representing TX power in mW + for channel 0 to channel 4. + Ex. ['1.86', '1.86', '1.86', '1.86'] + """ + tx_power_list = [] + + if self.sfp_type == QSFP_TYPE: + offset = 0 + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return None + + if self.dom_tx_power_supported: + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) + if dom_channel_monitor_raw is not None: + dom_channel_monitor_data = \ + sfpd_obj.parse_channel_monitor_params_with_tx_power(dom_channel_monitor_raw, 0) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX1Power']['value'])) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX2Power']['value'])) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX3Power']['value'])) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TX4Power']['value'])) + else: + return None + else: + return None + elif self.sfp_type == SFP_TYPE: + offset = 256 + sfpd_obj = sff8472Dom() + if sfpd_obj is None: + return None + + if self.dom_supported: + sfpd_obj._calibration_type = self.calibration + + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH) + if dom_channel_monitor_raw is not None: + dom_channel_monitor_data = \ + sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0) + tx_power_list.append(self._convert_string_to_num( + dom_channel_monitor_data['data']['TXPower']['value'])) + else: + return None + else: + return None + else: + return None + + return tx_power_list + + def reset(self): + """ + Reset SFP and return all user module settings to their default state. + Returns: + A boolean, True if successful, False if not + """ + if not self.get_presence(): + return False + + # SFP doesn't support this feature + if self.sfp_type == SFP_TYPE: + return False + elif self.sfp_type == QSFP_TYPE: + sfp_info = self.port_to_i2c_mapping[int(self._port_cfgs[self.port_num].lanes.split(',')[0])] + cmd = 'i2cget -y 0 {0} {1}'.format(sfp_info[4], sfp_info[5]) + reset = int(Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True).stdout.readline(), 16) + + reset &= ~(1 << sfp_info[6]) + cmd = 'i2cset -y 0 {0} {1} {2}'.format(sfp_info[4], sfp_info[5], reset) + Popen(cmd, shell=True) + + reset |= (1 << sfp_info[6]) + cmd = 'i2cset -y 0 {0} {1} {2}'.format(sfp_info[4], sfp_info[5], reset) + Popen(cmd, shell=True) + + return True + + 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 not self.get_presence(): + return False + + if self.sfp_type == SFP_TYPE: + if self.dom_tx_disable_supported: + offset = 256 + sysfs_sfp_i2c_client_eeprom_path = self.port_to_eeprom_mapping[self.port_num] + status_control_raw = self.__read_eeprom_specific_bytes( + (offset + SFP_STATUS_CONTROL_OFFSET), SFP_STATUS_CONTROL_WIDTH) + if status_control_raw is not None: + # Set bit 6 for Soft TX Disable Select + # 01000000 = 64 and 10111111 = 191 + tx_disable_bit = 64 if tx_disable else 191 + status_control = int(status_control_raw[0], 16) + tx_disable_ctl = (status_control | tx_disable_bit) if tx_disable else ( + status_control & tx_disable_bit) + try: + sysfsfile_eeprom = open( + sysfs_sfp_i2c_client_eeprom_path, mode="r+b", buffering=0) + buffer = create_string_buffer(1) + buffer[0] = chr(tx_disable_ctl) + # Write to eeprom + sysfsfile_eeprom.seek(offset + SFP_STATUS_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: + sysfsfile_eeprom.close() + time.sleep(0.01) + return True + return False + else: + return False + elif self.sfp_type == QSFP_TYPE: + if self.dom_tx_disable_supported: + channel_mask = 0x0f + if tx_disable: + return self.tx_disable_channel(channel_mask, True) + else: + return self.tx_disable_channel(channel_mask, False) + else: + return False + else: + return None + + 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 not self.get_presence(): + return False + # SFP doesn't support this feature + if self.sfp_type == SFP_TYPE: + return False + elif self.sfp_type == QSFP_TYPE: + if self.dom_tx_disable_supported: + sysfsfile_eeprom = None + try: + channel_state = self.get_tx_disable_channel() + if disable: + tx_disable_ctl = channel_state | channel + else: + tx_disable_ctl = channel_state & (~channel) + buffer = create_string_buffer(1) + 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 + else: + return False + else: + return None + + 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 + """ + return 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 + """ + # SFP doesn't support this feature + if not self.get_presence(): + return False + + if self.sfp_type == SFP_TYPE: + return False + elif self.sfp_type == QSFP_TYPE: + try: + power_override_bit = 0 + if power_override: + power_override_bit |= 1 << 0 + + power_set_bit = 0 + if power_set: + power_set_bit |= 1 << 1 + + buffer = create_string_buffer(1) + buffer[0] = chr(power_override_bit | power_set_bit) + # Write to eeprom + sysfsfile_eeprom = open(self.port_to_eeprom_mapping[self.port_num], "r+b") + sysfsfile_eeprom.seek(QSFP_POWEROVERRIDE_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) + else: + return None + + return True + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + return "Ethernet{}".format(self.port_num) + diff --git a/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/thermal.py b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/thermal.py new file mode 100644 index 000000000000..ca4e35969269 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/48y8c/sonic_platform/thermal.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python + +############################################################################# +# Celestica +# +# 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 + +try: + from sonic_platform_base.thermal_base import ThermalBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Thermal(ThermalBase): + """Platform-specific Thermal class""" + + THERMAL_NAME_LIST = [] + CPUBOARD_SS_PATH = "/sys/class/hwmon/hwmon1" + + def __init__(self, thermal_index): + self.index = thermal_index + self.high_threshold = float(112) + + # Add thermal name + self.THERMAL_NAME_LIST.append("ASIC") + + # Set hwmon path + self.ss_index, self.hwmon_path = 1, self.CPUBOARD_SS_PATH + self.ss_key = self.THERMAL_NAME_LIST[self.index - 1] + + def __read_txt_file(self, file_path): + try: + with open(file_path, 'r') as fd: + data = fd.read() + return data.strip() + except IOError: + raise IOError("Unable to open %s file !" % file_path) + + def __get_temp(self, temp_file): + temp_file_path = os.path.join(self.hwmon_path, temp_file) + raw_temp = self.__read_txt_file(temp_file_path) + temp = float(raw_temp)/1000 + return float("{:.3f}".format(temp)) + + def __set_threshold(self, file_name, temperature): + 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 + """ + temp_file = "temp{}_input".format(self.ss_index) + 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 + """ + return self.high_threshold + + 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 + """ + self.high_threshold = float(temperature) + return True + + def get_name(self): + """ + Retrieves the name of the thermal device + Returns: + string: The name of the thermal device + """ + 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 + """ + temp_file = "temp{}_input".format(self.ss_index) + temp_file_path = os.path.join(self.hwmon_path, temp_file) + return os.path.isfile(temp_file_path) + + 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 not self.get_presence(): + return False + + return True diff --git a/platform/centec/sonic-platform-modules-v682/debian/control b/platform/centec/sonic-platform-modules-v682/debian/control index 2c79ea7193ee..3460d4b00ba5 100644 --- a/platform/centec/sonic-platform-modules-v682/debian/control +++ b/platform/centec/sonic-platform-modules-v682/debian/control @@ -7,5 +7,15 @@ Standards-Version: 3.9.3 Package: platform-modules-v682-48y8c-d Architecture: amd64 -Depends: linux-image-4.19.0-12-2-amd64-unsigned +Depends: linux-image-5.10.0-8-2-amd64-unsigned +Description: kernel modules for platform devices such as fan, led, sfp + +Package: platform-modules-v682-48y8c +Architecture: amd64 +Depends: linux-image-5.10.0-8-2-amd64-unsigned +Description: kernel modules for platform devices such as fan, led, sfp + +Package: platform-modules-v682-48x8c +Architecture: amd64 +Depends: linux-image-5.10.0-8-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48x8c.init b/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48x8c.init new file mode 100644 index 000000000000..16b23082d6f9 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48x8c.init @@ -0,0 +1,200 @@ +#!/bin/bash +# This script load/unload centec kernel modules + +### BEGIN INIT INFO +# Provides: platform-modules-v682-48x8c +# Required-Start: +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: S +# Default-Stop: 0 6 +# Short-Description: Load Centec kernel modules +### END INIT INFO + +function install_python_api_package() +{ + device="/usr/share/sonic/device" + platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) + + rv=$(pip3 show sonic-platform > /dev/null 2>/dev/null) + if [ $? -ne 0 ]; then + rv=$(pip3 install $device/$platform/sonic_platform-1.0-py3-none-any.whl) + fi +} + +function load_system_eeprom_file() +{ + device="/usr/share/sonic/device" + platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) + mkdir -p /mnt/onie-boot + mount -t ext4 -L ONIE-BOOT /mnt/onie-boot + dd if=/mnt/onie-boot/eeprom_file of=$device/$platform/eeprom_file bs=1 skip=1046528 + dd if=/mnt/onie-boot/eeprom_file of=$device/$platform/eeprom_cipher bs=1 count=32 + MACADDR=`decode-syseeprom | grep "Base MAC Address" | awk '{print $6}'` + ifconfig eth0 hw ether $MACADDR + umount /mnt/onie-boot + rmdir /mnt/onie-boot +} + +function load_kernel_modules() +{ + modprobe centec_v682_48x8c_platform + modprobe dal + modprobe knet + modprobe tun + modprobe tap +} + +function remove_kernel_modules() +{ + modprobe -r tap + modprobe -r tun + modprobe -r knet + modprobe -r dal + modprobe -r centec_v682_48x8c_platform +} + +function release_board() +{ + systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target + chmod a+x /usr/local/lib/python3.9/dist-packages/release.py + /usr/local/lib/python3.9/dist-packages/release.py +} + +function create_i2c_device_nodes() +{ + # load pca954x driver for pca9548 + modprobe i2c-mux-pca954x + modprobe optoe + + # i2c-0 for SMBus + # i2c-1 for CP2112 + # create i2c 2,3,4,5,6,7,8,9 for pca9548 0x70 channel 0,1,2,3,4,5,6,7 + echo pca9548 0x70 > /sys/bus/i2c/devices/i2c-0/new_device + # create i2c 13,12,11,10,17,16,15,14 for fiber 0,1,2,3,4,5,6,7 + echo pca9548 0x71 > /sys/bus/i2c/devices/i2c-2/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-13/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-12/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-11/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-10/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-17/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-16/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-15/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-14/new_device + # create i2c 21,20,19,18,25,24,23,22 for fiber 8,9,10,11,12,13,14,15 + echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-3/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-21/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-20/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-19/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-18/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-25/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-24/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-23/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-22/new_device + # create i2c 29,28,27,26,33,32,31,30 for fiber 16,17,18,19,20,21,22,23 + echo pca9548 0x73 > /sys/bus/i2c/devices/i2c-4/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-29/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-28/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-27/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-26/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-33/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-32/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-31/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-30/new_device + # create i2c 37,36,35,34,41,40,39,38 for fiber 24,25,26,27,28,29,30,31 + echo pca9548 0x74 > /sys/bus/i2c/devices/i2c-6/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-37/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-36/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-35/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-34/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-41/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-40/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-39/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-38/new_device + # create i2c 45,44,43,42,49,48,47,46 for fiber 32,33,34,35,36,37,38,39 + echo pca9548 0x75 > /sys/bus/i2c/devices/i2c-7/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-45/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-44/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-43/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-42/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-49/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-48/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-47/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-46/new_device + # create i2c 53,52,51,50,57,56,55,54 for fiber 40,41,42,43,44,45,46,47 + echo pca9548 0x76 > /sys/bus/i2c/devices/i2c-8/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-53/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-52/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-51/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-50/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-57/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-56/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-55/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-54/new_device + # create i2c 61,60,59,58,65,64,63,62 for fiber 48,49,50,51,52,53,54,55 + echo pca9548 0x77 > /sys/bus/i2c/devices/i2c-5/new_device + echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-61/new_device + echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-60/new_device + echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-59/new_device + echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-58/new_device + echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-65/new_device + echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-64/new_device + echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-63/new_device + echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-62/new_device + + # for rtc sd2405 + echo sd2405 0x32 > /sys/bus/i2c/devices/i2c-0/new_device + # load rtc-sd2405 driver for rtc sd2405 + modprobe rtc-sd2405 + sleep 1 + hwclock -s -f /dev/rtc1 > /dev/null 2>&1 + + # for sensor lm77 + echo lm77 0x49 > /sys/bus/i2c/devices/i2c-0/new_device + # load lm77 driver for sensor lm77 + modprobe lm77 + + # for fan adt7470 + echo adt7470 0x2c > /sys/bus/i2c/devices/i2c-9/new_device + echo adt7470 0x2e > /sys/bus/i2c/devices/i2c-9/new_device + # load adt7470 driver for fan adt7470 + modprobe adt7470 +} + +case "$1" in +start) + echo -n "Init Centec V682-48X8C ... " + + depmod -a + modprobe i2c-dev + + release_board + load_kernel_modules + create_i2c_device_nodes + install_python_api_package + load_system_eeprom_file + + echo "done." + ;; + +stop) + echo -n "Deinit Centec V682-48X8C ... " + + remove_kernel_modules + + echo "done." + ;; + +force-reload|restart) + echo "Not supported" + ;; + +*) + echo "Usage: /etc/init.d/platform-modules-v682-48x8c {start|stop}" + exit 1 + ;; +esac + +exit 0 + diff --git a/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48x8c.install b/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48x8c.install new file mode 100644 index 000000000000..c798deffaede --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48x8c.install @@ -0,0 +1,2 @@ +48x8c/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-centec_v682_48x8c-r0 +48x8c/service/release.py usr/local/lib/python3.9/dist-packages diff --git a/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48x8c.postinst b/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48x8c.postinst new file mode 100644 index 000000000000..a4f0261a1d3e --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48x8c.postinst @@ -0,0 +1,2 @@ +systemctl enable 48x8c_platform.service +systemctl start 48x8c_platform.service diff --git a/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48y8c-d.init b/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48y8c-d.init index 92ce88465d11..b74489e9a30d 100644 --- a/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48y8c-d.init +++ b/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48y8c-d.init @@ -17,16 +17,26 @@ function install_python_api_package() device="/usr/share/sonic/device" platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) - rv=$(pip2 show sonic-platform > /dev/null 2>/dev/null) - if [ $? -ne 0 ]; then - rv=$(pip2 install $device/$platform/sonic_platform-1.0-py2-none-any.whl) - fi rv=$(pip3 show sonic-platform > /dev/null 2>/dev/null) if [ $? -ne 0 ]; then rv=$(pip3 install $device/$platform/sonic_platform-1.0-py3-none-any.whl) fi } +function load_system_eeprom_file() +{ + device="/usr/share/sonic/device" + platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) + mkdir -p /mnt/onie-boot + mount -t ext4 -L ONIE-BOOT /mnt/onie-boot + dd if=/mnt/onie-boot/eeprom_file of=$device/$platform/eeprom_file bs=1 skip=1046528 + dd if=/mnt/onie-boot/eeprom_file of=$device/$platform/eeprom_cipher bs=1 count=32 + MACADDR=`decode-syseeprom | grep "Base MAC Address" | awk '{print $6}'` + ifconfig eth0 hw ether $MACADDR + umount /mnt/onie-boot + rmdir /mnt/onie-boot +} + function load_kernel_modules() { depmod -a @@ -50,10 +60,10 @@ function release_board() { systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target - chmod a+x /usr/local/lib/python2.7/dist-packages/libSUSI-4.00.so.1 - chmod a+x /usr/local/lib/python2.7/dist-packages/_Susi4.so - chmod a+x /usr/local/lib/python2.7/dist-packages/release.py - /usr/local/lib/python2.7/dist-packages/release.py + chmod a+x /usr/local/lib/python3.9/dist-packages/libSUSI-4.00.so.1 + chmod a+x /usr/local/lib/python3.9/dist-packages/_Susi4.so + chmod a+x /usr/local/lib/python3.9/dist-packages/release.py + /usr/local/lib/python3.9/dist-packages/release.py } @@ -64,6 +74,7 @@ start) release_board load_kernel_modules install_python_api_package + load_system_eeprom_file echo "done." ;; diff --git a/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48y8c-d.install b/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48y8c-d.install index e3f3758b333e..8a5a1440cfe3 100644 --- a/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48y8c-d.install +++ b/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48y8c-d.install @@ -1,5 +1,4 @@ -48y8c-d/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-centec_v682_48y8c_d-r0 48y8c-d/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-centec_v682_48y8c_d-r0 -48y8c-d/service/release.py usr/local/lib/python2.7/dist-packages -48y8c-d/service/_Susi4.so usr/local/lib/python2.7/dist-packages -48y8c-d/service/libSUSI-4.00.so.1 usr/local/lib/python2.7/dist-packages +48y8c-d/service/release.py usr/local/lib/python3.9/dist-packages +48y8c-d/service/_Susi4.so usr/local/lib/python3.9/dist-packages +48y8c-d/service/libSUSI-4.00.so.1 usr/local/lib/python3.9/dist-packages diff --git a/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48y8c.init b/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48y8c.init new file mode 100644 index 000000000000..16a85d40e72b --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48y8c.init @@ -0,0 +1,200 @@ +#!/bin/bash +# This script load/unload centec kernel modules + +### BEGIN INIT INFO +# Provides: platform-modules-v682-48y8c +# Required-Start: +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: S +# Default-Stop: 0 6 +# Short-Description: Load Centec kernel modules +### END INIT INFO + +function install_python_api_package() +{ + device="/usr/share/sonic/device" + platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) + + rv=$(pip3 show sonic-platform > /dev/null 2>/dev/null) + if [ $? -ne 0 ]; then + rv=$(pip3 install $device/$platform/sonic_platform-1.0-py3-none-any.whl) + fi +} + +function load_system_eeprom_file() +{ + device="/usr/share/sonic/device" + platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) + mkdir -p /mnt/onie-boot + mount -t ext4 -L ONIE-BOOT /mnt/onie-boot + dd if=/mnt/onie-boot/eeprom_file of=$device/$platform/eeprom_file bs=1 skip=1046528 + dd if=/mnt/onie-boot/eeprom_file of=$device/$platform/eeprom_cipher bs=1 count=32 + MACADDR=`decode-syseeprom | grep "Base MAC Address" | awk '{print $6}'` + ifconfig eth0 hw ether $MACADDR + umount /mnt/onie-boot + rmdir /mnt/onie-boot +} + +function load_kernel_modules() +{ + modprobe centec_v682_48y8c_platform + modprobe dal + modprobe knet + modprobe tun + modprobe tap +} + +function remove_kernel_modules() +{ + modprobe -r tap + modprobe -r tun + modprobe -r knet + modprobe -r dal + modprobe -r centec_v682_48y8c_platform +} + +function release_board() +{ + systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target + chmod a+x /usr/local/lib/python3.9/dist-packages/release.py + /usr/local/lib/python3.9/dist-packages/release.py +} + +function create_i2c_device_nodes() +{ + # load pca954x driver for pca9548 + modprobe i2c-mux-pca954x + modprobe optoe + + # i2c-0 for SMBus + # i2c-1 for CP2112 + # create i2c 2,3,4,5,6,7,8,9 for pca9548 0x70 channel 0,1,2,3,4,5,6,7 + echo pca9548 0x70 > /sys/bus/i2c/devices/i2c-0/new_device + # create i2c 13,12,11,10,17,16,15,14 for fiber 0,1,2,3,4,5,6,7 + echo pca9548 0x71 > /sys/bus/i2c/devices/i2c-2/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-13/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-12/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-11/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-10/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-17/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-16/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-15/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-14/new_device + # create i2c 21,20,19,18,25,24,23,22 for fiber 8,9,10,11,12,13,14,15 + echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-3/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-21/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-20/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-19/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-18/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-25/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-24/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-23/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-22/new_device + # create i2c 29,28,27,26,33,32,31,30 for fiber 16,17,18,19,20,21,22,23 + echo pca9548 0x73 > /sys/bus/i2c/devices/i2c-4/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-29/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-28/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-27/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-26/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-33/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-32/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-31/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-30/new_device + # create i2c 37,36,35,34,41,40,39,38 for fiber 24,25,26,27,28,29,30,31 + echo pca9548 0x74 > /sys/bus/i2c/devices/i2c-6/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-37/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-36/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-35/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-34/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-41/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-40/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-39/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-38/new_device + # create i2c 45,44,43,42,49,48,47,46 for fiber 32,33,34,35,36,37,38,39 + echo pca9548 0x75 > /sys/bus/i2c/devices/i2c-7/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-45/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-44/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-43/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-42/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-49/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-48/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-47/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-46/new_device + # create i2c 53,52,51,50,57,56,55,54 for fiber 40,41,42,43,44,45,46,47 + echo pca9548 0x76 > /sys/bus/i2c/devices/i2c-8/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-53/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-52/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-51/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-50/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-57/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-56/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-55/new_device + echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-54/new_device + # create i2c 61,60,59,58,65,64,63,62 for fiber 48,49,50,51,52,53,54,55 + echo pca9548 0x77 > /sys/bus/i2c/devices/i2c-5/new_device + echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-61/new_device + echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-60/new_device + echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-59/new_device + echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-58/new_device + echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-65/new_device + echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-64/new_device + echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-63/new_device + echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-62/new_device + + # for rtc sd2405 + echo sd2405 0x32 > /sys/bus/i2c/devices/i2c-0/new_device + # load rtc-sd2405 driver for rtc sd2405 + modprobe rtc-sd2405 + sleep 1 + hwclock -s -f /dev/rtc1 > /dev/null 2>&1 + + # for sensor lm77 + echo lm77 0x49 > /sys/bus/i2c/devices/i2c-0/new_device + # load lm77 driver for sensor lm77 + modprobe lm77 + + # for fan adt7470 + echo adt7470 0x2c > /sys/bus/i2c/devices/i2c-9/new_device + echo adt7470 0x2e > /sys/bus/i2c/devices/i2c-9/new_device + # load adt7470 driver for fan adt7470 + modprobe adt7470 +} + +case "$1" in +start) + echo -n "Init Centec V682-48Y8C ... " + + depmod -a + modprobe i2c-dev + + release_board + load_kernel_modules + create_i2c_device_nodes + install_python_api_package + load_system_eeprom_file + + echo "done." + ;; + +stop) + echo -n "Deinit Centec V682-48Y8C ... " + + remove_kernel_modules + + echo "done." + ;; + +force-reload|restart) + echo "Not supported" + ;; + +*) + echo "Usage: /etc/init.d/platform-modules-v682-48y8c {start|stop}" + exit 1 + ;; +esac + +exit 0 + diff --git a/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48y8c.install b/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48y8c.install new file mode 100644 index 000000000000..999baedb4b20 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48y8c.install @@ -0,0 +1,2 @@ +48y8c/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-centec_v682_48y8c-r0 +48y8c/service/release.py usr/local/lib/python3.9/dist-packages diff --git a/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48y8c.postinst b/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48y8c.postinst new file mode 100644 index 000000000000..30915b9e6fe0 --- /dev/null +++ b/platform/centec/sonic-platform-modules-v682/debian/platform-modules-v682-48y8c.postinst @@ -0,0 +1,2 @@ +systemctl enable 48y8c_platform.service +systemctl start 48y8c_platform.service diff --git a/platform/centec/sonic-platform-modules-v682/debian/rules b/platform/centec/sonic-platform-modules-v682/debian/rules index c50356d4517d..2e0e0dc0ffee 100755 --- a/platform/centec/sonic-platform-modules-v682/debian/rules +++ b/platform/centec/sonic-platform-modules-v682/debian/rules @@ -17,7 +17,7 @@ PACKAGE_PRE_NAME := platform-modules-v682 KVERSION ?= $(shell uname -r) KERNEL_SRC := /lib/modules/$(KVERSION) MOD_SRC_DIR:= $(shell pwd) -MODULE_DIRS:= 48y8c-d +MODULE_DIRS:= 48y8c-d 48y8c 48x8c MODULE_DIR := modules SERVICE_DIR := service CLASSES_DIR := classes @@ -41,7 +41,6 @@ build: (for mod in $(MODULE_DIRS); do \ make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \ cd $${mod}; \ - python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ cd -; \ done) diff --git a/platform/components/docker-gbsyncd-credo/Dockerfile.j2 b/platform/components/docker-gbsyncd-credo/Dockerfile.j2 index f12e6350f4de..1b9631707cb6 100644 --- a/platform/components/docker-gbsyncd-credo/Dockerfile.j2 +++ b/platform/components/docker-gbsyncd-credo/Dockerfile.j2 @@ -8,7 +8,7 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update -RUN apt-get install -f -y iproute2 libcap2-bin libprotobuf-dev +RUN apt-get install -f -y iproute2 libcap2-bin COPY \ {% for deb in docker_gbsyncd_credo_debs.split(' ') -%} diff --git a/platform/mellanox/asic_table.j2 b/platform/mellanox/asic_table.j2 index 53be34854364..a12f8d38d254 100644 --- a/platform/mellanox/asic_table.j2 +++ b/platform/mellanox/asic_table.j2 @@ -40,8 +40,11 @@ 'x86_64-mlnx_msn4700-r0':'MELLANOX-SPECTRUM-3', 'x86_64-mlnx_msn4600c-r0':'MELLANOX-SPECTRUM-3', 'x86_64-mlnx_msn4600-r0':'MELLANOX-SPECTRUM-3', + 'x86_64-nvidia_sn4800-r0':'MELLANOX-SPECTRUM-3', + 'x86_64-nvidia_sn4800_simx-r0':'MELLANOX-SPECTRUM-3', 'x86_64-nvidia_sn2201-r0':'MELLANOX-SPECTRUM', 'x86_64-nvidia_sn5600-r0':'MELLANOX-SPECTRUM-4', + 'x86_64-nvidia_sn5600_simx-r0':'MELLANOX-SPECTRUM-4', 'vs-platform':'vs' } %} @@ -76,5 +79,15 @@ }, "OP": "SET" } +{% elif asic_type == 'MELLANOX-SPECTRUM-4' %} + { + "ASIC_TABLE:MELLANOX-SPECTRUM-4": { + "cell_size": "192", + "pipeline_latency": "19", + "mac_phy_delay": "0.8", + "peer_response_time": "3.8" + }, + "OP": "SET" + } {% endif %} ] diff --git a/platform/mellanox/docker-syncd-mlnx.mk b/platform/mellanox/docker-syncd-mlnx.mk index 0377b910be6f..a2e733782b9e 100644 --- a/platform/mellanox/docker-syncd-mlnx.mk +++ b/platform/mellanox/docker-syncd-mlnx.mk @@ -36,4 +36,3 @@ $(DOCKER_SYNCD_BASE)_VERSION = 1.0.0 $(DOCKER_SYNCD_BASE)_PACKAGE_NAME = syncd $(DOCKER_SYNCD_BASE)_RUN_OPT += -v /host/warmboot:/var/warmboot -SONIC_BUSTER_DOCKERS += $(DOCKER_SYNCD_BASE) diff --git a/platform/mellanox/hw-management/0002-hw-mgmt-system-MSN4600-A1-BU-config1-fix.patch b/platform/mellanox/hw-management/0002-hw-mgmt-system-MSN4600-A1-BU-config1-fix.patch deleted file mode 100644 index 391121cff4b8..000000000000 --- a/platform/mellanox/hw-management/0002-hw-mgmt-system-MSN4600-A1-BU-config1-fix.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 1b2c2343d62b2fadb5c8fc9e61f2f654f4085193 Mon Sep 17 00:00:00 2001 -From: Mykola Kostenok -Date: Wed, 12 May 2021 10:59:57 +0300 -Subject: [PATCH] hw-mgmt: system: MSN4600 A1 BU config1 fix - -Fix config1 matching for MSN4600. - -Signed-off-by: Mykola Kostenok ---- - usr/usr/bin/hw-management.sh | 2 +- - 1 files changed, 1 insertions(+), 1 deletions(-) - -diff --git a/usr/usr/bin/hw-management.sh b/usr/usr/bin/hw-management.sh -index d5b2728..150e583 100755 ---- a/usr/usr/bin/hw-management.sh -+++ b/usr/usr/bin/hw-management.sh -@@ -728,7 +728,7 @@ msn46xx_specific() - if [ $res -eq 0 ]; then - sys_ver=$(cut "$regio_path"/config1 -d' ' -f 1) - case $sys_ver in -- 3) -+ 1) - connect_msn4700_msn4600_A1 - ;; - *) --- -1.7.1 - diff --git a/platform/mellanox/hw-management/Makefile b/platform/mellanox/hw-management/Makefile index eb087b47bfff..9c62312d18c5 100644 --- a/platform/mellanox/hw-management/Makefile +++ b/platform/mellanox/hw-management/Makefile @@ -6,7 +6,8 @@ MAIN_TARGET = hw-management_1.mlnx.$(MLNX_HW_MANAGEMENT_VERSION)_amd64.deb $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : pushd hw-mgmt - git am ../*.patch + git stash + git apply -3 ../*.patch || exit 1 chmod +x ./debian/rules KVERSION=$(KVERSION) dpkg-buildpackage -us -uc -b -rfakeroot -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd diff --git a/platform/mellanox/install-pending-fw.dep b/platform/mellanox/install-pending-fw.dep new file mode 100644 index 000000000000..ddd6f325684b --- /dev/null +++ b/platform/mellanox/install-pending-fw.dep @@ -0,0 +1,10 @@ +# DPKG FRK + +DPATH := $($(MLNX_INSTALL_PENDING_FW)_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) $(PLATFORM_PATH)/install-pending-fw.mk $(PLATFORM_PATH)/install-pending-fw.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES += $(addprefix $(DPATH),$(MLNX_INSTALL_PENDING_FW)) + +$(MLNX_INSTALL_PENDING_FW)_CACHE_MODE := GIT_CONTENT_SHA +$(MLNX_INSTALL_PENDING_FW)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(MLNX_INSTALL_PENDING_FW)_DEP_FILES := $(DEP_FILES) diff --git a/platform/mellanox/install-pending-fw.mk b/platform/mellanox/install-pending-fw.mk new file mode 100644 index 000000000000..0160bb81ed53 --- /dev/null +++ b/platform/mellanox/install-pending-fw.mk @@ -0,0 +1,25 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Firmware pending update checker and installer + +MLNX_INSTALL_PENDING_FW = install-pending-fw.py +$(MLNX_INSTALL_PENDING_FW)_PATH = $(PLATFORM_PATH)/ +SONIC_COPY_FILES += $(MLNX_INSTALL_PENDING_FW) + +MLNX_FILES += $(MLNX_INSTALL_PENDING_FW) + +export MLNX_INSTALL_PENDING_FW diff --git a/platform/mellanox/install-pending-fw.py b/platform/mellanox/install-pending-fw.py new file mode 100755 index 000000000000..55287854bfe2 --- /dev/null +++ b/platform/mellanox/install-pending-fw.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import os + +from fwutil.lib import ComponentStatusProvider, PlatformComponentsParser +from sonic_platform.component import ComponentCPLD, MPFAManager + +# Globals +FW_STATUS_SCHEDULED = "scheduled" +CPLD_FLAG = False + +# Init platform chassis helper classes +csp = ComponentStatusProvider() +pcp = PlatformComponentsParser(csp.is_modular_chassis()) + +# Parse update status file +update_status = csp.read_au_status_file_if_exists() + +if update_status is None: + exit(0) + +# Parse platform components file +try: + pcp.parse_platform_components() +except Exception as e: + print("Error parsing platform components. Firmware update failed: {}".format(str(e))) + print("System will reboot in 10 seconds please fix issue and run update command again.") + time.sleep(10) + exit(-1) + +# Iterate each component in the status file +comp_install = [] +files = [] + +for boot_type, components in update_status.items(): + for comp in components: + + # Skip if fw isn't scheduled for install at reboot + if comp["info"] != FW_STATUS_SCHEDULED: continue + + # Get component object and target firmware file + key = comp["comp"] + comp_path = key.split("/") + + if len(comp_path) == 3: + # Module component + _, parent_name, comp_name = comp_path + fw_file = pcp.module_component_map[parent_name][comp_name]["firmware"] + component = csp.module_component_map[parent_name][comp_name] + else: + # Chassis component + parent_name, comp_name = comp_path + fw_file = pcp.chassis_component_map[parent_name][comp_name]["firmware"] + component = csp.chassis_component_map[parent_name][comp_name] + + # Install firmware. If CPLD flag to be installed last due to force reboot during refresh + if type(component) == ComponentCPLD: + if CPLD_FLAG: + # Only need one refresh + continue + mpfa = MPFAManager(fw_file) + mpfa.extract() + if not mpfa.get_metadata().has_option('firmware', 'refresh'): + print("Failed to get CPLD refresh firmware. Skipping.") + continue + CPLD_FLAG = True + refresh_firmware = mpfa.get_metadata().get('firmware', 'refresh') + comp_install = comp_install + [component] + files = files + [os.path.join(mpfa.get_path(), refresh_firmware)] + else: + comp_install = [component] + comp_install + files = [fw_file] + files + +# Do install +for i, c in enumerate(comp_install): + try: + if type(c) == ComponentCPLD: + c.install_firmware(files[i]) + else: + c.install_firmware(files[i], allow_reboot=False) + except Exception as e: + print("Firmware install for {} FAILED with: {}".format(c.get_name(),e)) + diff --git a/platform/mellanox/mlnx-onie-fw-update.sh b/platform/mellanox/mlnx-onie-fw-update.sh index b1b85f5fb42d..d60c6694c0cd 100755 --- a/platform/mellanox/mlnx-onie-fw-update.sh +++ b/platform/mellanox/mlnx-onie-fw-update.sh @@ -186,7 +186,12 @@ case "${cmd}" in rc=$? disable_onie_access if [[ ${rc} -eq 0 ]]; then - system_reboot + if [[ "${arg}" == "--no-reboot" ]]; then + echo "INFO: ONIE firmware update successfully STAGED for install at NEXT reboot. Please reboot manually to complete installation." + exit 0 + else + system_reboot + fi else echo "ERROR: failed to enable ONIE firmware update mode" exit ${rc} diff --git a/platform/mellanox/mlnx-platform-api.dep b/platform/mellanox/mlnx-platform-api.dep index b66c0b9c3bdf..c237ab9f02c8 100644 --- a/platform/mellanox/mlnx-platform-api.dep +++ b/platform/mellanox/mlnx-platform-api.dep @@ -1,14 +1,16 @@ # DPKG FRK -SPATH := $($(SONIC_PLATFORM_API_PY2)_SRC_PATH) +SPATH := $($(SONIC_PLATFORM_API_PY3)_SRC_PATH) SLINKS := $(shell find $(SPATH) -type l -exec echo {} \; | grep -Ev ' ') DEP_FILES := $(SONIC_COMMON_FILES_LIST) $(PLATFORM_PATH)/mlnx-platform-api.mk $(PLATFORM_PATH)/mlnx-platform-api.dep DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) DEP_FILES += $(shell git ls-files -- $(SPATH) | grep -Ev ' ') -$(SONIC_PLATFORM_API_PY2)_CACHE_MODE := GIT_CONTENT_SHA -$(SONIC_PLATFORM_API_PY2)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) -$(SONIC_PLATFORM_API_PY2)_DEP_FILES := $(filter-out $(SLINKS),$(DEP_FILES)) +ifeq ($(ENABLE_PY2_MODULES), y) + $(SONIC_PLATFORM_API_PY2)_CACHE_MODE := GIT_CONTENT_SHA + $(SONIC_PLATFORM_API_PY2)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) + $(SONIC_PLATFORM_API_PY2)_DEP_FILES := $(filter-out $(SLINKS),$(DEP_FILES)) +endif $(SONIC_PLATFORM_API_PY3)_CACHE_MODE := GIT_CONTENT_SHA $(SONIC_PLATFORM_API_PY3)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/component.py b/platform/mellanox/mlnx-platform-api/sonic_platform/component.py index 4a252db72d72..37f04f9a1dee 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/component.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/component.py @@ -34,11 +34,16 @@ else: import ConfigParser as configparser + from shutil import copyfile + from sonic_platform_base.component_base import ComponentBase, \ FW_AUTO_INSTALLED, \ + FW_AUTO_UPDATED, \ + FW_AUTO_SCHEDULED, \ FW_AUTO_ERR_BOOT_TYPE, \ FW_AUTO_ERR_IMAGE, \ - FW_AUTO_ERR_UKNOWN + FW_AUTO_ERR_UNKNOWN + except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -119,6 +124,7 @@ class ONIEUpdater(object): ONIE_FW_UPDATE_CMD_ADD = '/usr/bin/mlnx-onie-fw-update.sh add {}' ONIE_FW_UPDATE_CMD_REMOVE = '/usr/bin/mlnx-onie-fw-update.sh remove {}' ONIE_FW_UPDATE_CMD_UPDATE = '/usr/bin/mlnx-onie-fw-update.sh update' + ONIE_FW_UPDATE_CMD_INSTALL = '/usr/bin/mlnx-onie-fw-update.sh update --no-reboot' ONIE_FW_UPDATE_CMD_SHOW_PENDING = '/usr/bin/mlnx-onie-fw-update.sh show-pending' ONIE_VERSION_PARSE_PATTERN = '([0-9]{4})\.([0-9]{2})-([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)' @@ -130,6 +136,18 @@ class ONIEUpdater(object): ONIE_IMAGE_INFO_COMMAND = '/bin/bash {} -q -i' + BIOS_UPDATE_FILE_EXT = '.rom' + + def __add_prefix(self, image_path): + if self.BIOS_UPDATE_FILE_EXT not in image_path: + rename_path = "/tmp/00-{}".format(os.path.basename(image_path)) + else: + rename_path = "/tmp/99-{}".format(os.path.basename(image_path)) + + copyfile(image_path, rename_path) + + return rename_path + def __mount_onie_fs(self): fs_mountpoint = '/mnt/onie-fs' onie_path = '/lib/onie' @@ -138,9 +156,9 @@ def __mount_onie_fs(self): self.__umount_onie_fs() cmd = "fdisk -l | grep 'ONIE boot' | awk '{print $1}'" - fs_path = subprocess.check_output(cmd, - stderr=subprocess.STDOUT, - shell=True, + fs_path = subprocess.check_output(cmd, + stderr=subprocess.STDOUT, + shell=True, universal_newlines=True).rstrip('\n') os.mkdir(fs_mountpoint) @@ -167,7 +185,9 @@ def __umount_onie_fs(self): os.rmdir(fs_mountpoint) def __stage_update(self, image_path): - cmd = self.ONIE_FW_UPDATE_CMD_ADD.format(image_path) + rename_path = self.__add_prefix(image_path) + + cmd = self.ONIE_FW_UPDATE_CMD_ADD.format(rename_path) try: subprocess.check_call(cmd.split(), universal_newlines=True) @@ -175,15 +195,20 @@ def __stage_update(self, image_path): raise RuntimeError("Failed to stage firmware update: {}".format(str(e))) def __unstage_update(self, image_path): - cmd = self.ONIE_FW_UPDATE_CMD_REMOVE.format(os.path.basename(image_path)) + rename_path = self.__add_prefix(image_path) + + cmd = self.ONIE_FW_UPDATE_CMD_REMOVE.format(os.path.basename(rename_path)) try: subprocess.check_call(cmd.split(), universal_newlines=True) except subprocess.CalledProcessError as e: raise RuntimeError("Failed to unstage firmware update: {}".format(str(e))) - def __trigger_update(self): - cmd = self.ONIE_FW_UPDATE_CMD_UPDATE + def __trigger_update(self, allow_reboot): + if allow_reboot: + cmd = self.ONIE_FW_UPDATE_CMD_UPDATE + else: + cmd = self.ONIE_FW_UPDATE_CMD_INSTALL try: subprocess.check_call(cmd.split(), universal_newlines=True) @@ -194,13 +219,14 @@ def __is_update_staged(self, image_path): cmd = self.ONIE_FW_UPDATE_CMD_SHOW_PENDING try: - output = subprocess.check_output(cmd.split(), - stderr=subprocess.STDOUT, + output = subprocess.check_output(cmd.split(), + stderr=subprocess.STDOUT, universal_newlines=True).rstrip('\n') except subprocess.CalledProcessError as e: raise RuntimeError("Failed to get pending firmware updates: {}".format(str(e))) - basename = os.path.basename(image_path) + rename_path = self.__add_prefix(image_path) + basename = os.path.basename(rename_path) for line in output.splitlines(): if line.startswith(basename): @@ -281,8 +307,8 @@ def get_onie_firmware_info(self, image_path): cmd = self.ONIE_IMAGE_INFO_COMMAND.format(image_path) try: - output = subprocess.check_output(cmd.split(), - stderr=subprocess.STDOUT, + output = subprocess.check_output(cmd.split(), + stderr=subprocess.STDOUT, universal_newlines=True).rstrip('\n') except subprocess.CalledProcessError as e: raise RuntimeError("Failed to get ONIE firmware info: {}".format(str(e))) @@ -299,29 +325,11 @@ def get_onie_firmware_info(self, image_path): return firmware_info - def update_firmware(self, image_path): - cmd = self.ONIE_FW_UPDATE_CMD_SHOW_PENDING - - try: - output = subprocess.check_output(cmd.split(), - stderr=subprocess.STDOUT, - universal_newlines=True).rstrip('\n') - except subprocess.CalledProcessError as e: - raise RuntimeError("Failed to get pending firmware updates: {}".format(str(e))) - - no_pending_updates = False - - for line in output.splitlines(): - if line.startswith(self.ONIE_NO_PENDING_UPDATES_ATTR): - no_pending_updates = True - break - - if not no_pending_updates: - raise RuntimeError("Failed to complete firmware update: pending updates are present") + def update_firmware(self, image_path, allow_reboot=True): try: self.__stage_update(image_path) - self.__trigger_update() + self.__trigger_update(allow_reboot) except: if self.__is_update_staged(image_path): self.__unstage_update(image_path) @@ -359,22 +367,21 @@ def auto_update_firmware(self, image_path, boot_action): if boot_action is fast. """ - default_supported_boot = ['cold'] - # Verify image path exists if not os.path.exists(image_path): # Invalid image path return FW_AUTO_ERR_IMAGE - if boot_action in default_supported_boot: - if self.update_firmware(image_path): - # Successful update - return FW_AUTO_INSTALLED - # Failed update (unknown reason) - return FW_AUTO_ERR_UKNOWN - # boot_type did not match (skip) - return FW_AUTO_ERR_BOOT_TYPE + if boot_action != "cold": + return FW_AUTO_ERR_BOOT_TYPE + + # Install firmware + if not self.install_firmware(image_path, allow_reboot=False): + return FW_AUTO_ERR_UNKNOWN + + # Installed pending next reboot + return FW_AUTO_INSTALLED @staticmethod def _read_generic_file(filename, len, ignore_errors=False): @@ -395,10 +402,10 @@ def _read_generic_file(filename, len, ignore_errors=False): @staticmethod def _get_command_result(cmdline): try: - proc = subprocess.Popen(cmdline, - stdout=subprocess.PIPE, - shell=True, - stderr=subprocess.STDOUT, + proc = subprocess.Popen(cmdline, + stdout=subprocess.PIPE, + shell=True, + stderr=subprocess.STDOUT, universal_newlines=True) stdout = proc.communicate()[0] rc = proc.wait() @@ -438,13 +445,13 @@ def __init__(self): self.description = self.COMPONENT_DESCRIPTION self.onie_updater = ONIEUpdater() - def __install_firmware(self, image_path): + def __install_firmware(self, image_path, allow_reboot=True): if not self._check_file_validity(image_path): return False try: print("INFO: Staging {} firmware update with ONIE updater".format(self.name)) - self.onie_updater.update_firmware(image_path) + self.onie_updater.update_firmware(image_path, allow_reboot) except Exception as e: print("ERROR: Failed to update {} firmware: {}".format(self.name, str(e))) return False @@ -464,8 +471,8 @@ def get_available_firmware_version(self, image_path): def get_firmware_update_notification(self, image_path): return "Immediate cold reboot is required to complete {} firmware update".format(self.name) - def install_firmware(self, image_path): - return self.__install_firmware(image_path) + def install_firmware(self, image_path, allow_reboot=True): + return self.__install_firmware(image_path, allow_reboot) def update_firmware(self, image_path): self.__install_firmware(image_path) @@ -483,6 +490,7 @@ class ComponentSSD(Component): SSD_INFO_COMMAND = "/usr/bin/mlnx-ssd-fw-update.sh -q" SSD_FIRMWARE_INFO_COMMAND = "/usr/bin/mlnx-ssd-fw-update.sh -q -i {}" + SSD_FIRMWARE_INSTALL_COMMAND = "/usr/bin/mlnx-ssd-fw-update.sh --no-power-cycle -y -u -i {}" SSD_FIRMWARE_UPDATE_COMMAND = "/usr/bin/mlnx-ssd-fw-update.sh -y -u -i {}" def __init__(self): @@ -492,11 +500,14 @@ def __init__(self): self.description = self.COMPONENT_DESCRIPTION self.image_ext_name = self.COMPONENT_FIRMWARE_EXTENSION - def __install_firmware(self, image_path): + def __install_firmware(self, image_path, allow_reboot=True): if not self._check_file_validity(image_path): return False - cmd = self.SSD_FIRMWARE_UPDATE_COMMAND.format(image_path) + if allow_reboot: + cmd = self.SSD_FIRMWARE_UPDATE_COMMAND.format(image_path) + else: + cmd = self.SSD_FIRMWARE_INSTALL_COMMAND.format(image_path) try: print("INFO: Installing {} firmware update".format(self.name)) @@ -510,13 +521,10 @@ def __install_firmware(self, image_path): def auto_update_firmware(self, image_path, boot_action): """ Handling of attempted automatic update for a SSD of a Mellanox switch. - Will first check the image_path to determine if a post-install reboot is required, + Will first check the image_path to determine if a post-install reboot is required, then compares it against boot_action to determine whether to proceed with install. """ - # All devices support cold boot - supported_boot = ['cold'] - # Verify image path exists if not os.path.exists(image_path): # Invalid image path @@ -524,29 +532,28 @@ def auto_update_firmware(self, image_path, boot_action): # Check if post_install reboot is required try: - if self.get_firmware_update_notification(image_path) is None: - # No power cycle required - supported_boot += ['warm', 'fast', 'none', 'any'] - except RuntimeError: - # Unknown error from firmware probe - return FW_AUTO_ERR_UKNOWN - - if boot_action in supported_boot: - if self.update_firmware(image_path): - # Successful update - return FW_AUTO_INSTALLED - # Failed update (unknown reason) - return FW_AUTO_ERR_UKNOWN + reboot_required = self.get_firmware_update_notification(image_path) is not None + except RuntimeError as e: + return FW_AUTO_ERR_UNKNOWN + + # Update if no reboot needed + if not reboot_required: + self.update_firmware(image_path) + return FW_AUTO_UPDATED # boot_type did not match (skip) - return FW_AUTO_ERR_BOOT_TYPE + if boot_action != "cold": + return FW_AUTO_ERR_BOOT_TYPE + + # Schedule if we need a cold boot + return FW_AUTO_SCHEDULED def get_firmware_version(self): cmd = self.SSD_INFO_COMMAND try: - output = subprocess.check_output(cmd.split(), - stderr=subprocess.STDOUT, + output = subprocess.check_output(cmd.split(), + stderr=subprocess.STDOUT, universal_newlines=True).rstrip('\n') except subprocess.CalledProcessError as e: raise RuntimeError("Failed to get {} info: {}".format(self.name, str(e))) @@ -561,8 +568,8 @@ def get_available_firmware_version(self, image_path): cmd = self.SSD_FIRMWARE_INFO_COMMAND.format(image_path) try: - output = subprocess.check_output(cmd.split(), - stderr=subprocess.STDOUT, + output = subprocess.check_output(cmd.split(), + stderr=subprocess.STDOUT, universal_newlines=True).rstrip('\n') except subprocess.CalledProcessError as e: raise RuntimeError("Failed to get {} firmware info: {}".format(self.name, str(e))) @@ -596,8 +603,8 @@ def get_firmware_update_notification(self, image_path): cmd = self.SSD_FIRMWARE_INFO_COMMAND.format(image_path) try: - output = subprocess.check_output(cmd.split(), - stderr=subprocess.STDOUT, + output = subprocess.check_output(cmd.split(), + stderr=subprocess.STDOUT, universal_newlines=True).rstrip('\n') except subprocess.CalledProcessError as e: raise RuntimeError("Failed to get {} firmware info: {}".format(self.name, str(e))) @@ -627,8 +634,8 @@ def get_firmware_update_notification(self, image_path): return notification - def install_firmware(self, image_path): - return self.__install_firmware(image_path) + def install_firmware(self, image_path, allow_reboot=True): + return self.__install_firmware(image_path, allow_reboot) def update_firmware(self, image_path): self.__install_firmware(image_path) @@ -649,7 +656,7 @@ def __init__(self): self.image_ext_name = self.COMPONENT_FIRMWARE_EXTENSION self.onie_updater = ONIEUpdater() - def __install_firmware(self, image_path): + def __install_firmware(self, image_path, allow_reboot=True): if not self.onie_updater.is_non_onie_firmware_update_supported(): print("ERROR: ONIE {} or later is required".format(self.onie_updater.get_onie_required_version())) return False @@ -659,7 +666,7 @@ def __install_firmware(self, image_path): try: print("INFO: Staging {} firmware update with ONIE updater".format(self.name)) - self.onie_updater.update_firmware(image_path) + self.onie_updater.update_firmware(image_path, allow_reboot) except Exception as e: print("ERROR: Failed to update {} firmware: {}".format(self.name, str(e))) return False @@ -670,8 +677,8 @@ def get_firmware_version(self): cmd = self.BIOS_VERSION_COMMAND try: - version = subprocess.check_output(cmd.split(), - stderr=subprocess.STDOUT, + version = subprocess.check_output(cmd.split(), + stderr=subprocess.STDOUT, universal_newlines=True).rstrip('\n') except subprocess.CalledProcessError as e: raise RuntimeError("Failed to get {} version: {}".format(self.name, str(e))) @@ -684,8 +691,8 @@ def get_available_firmware_version(self, image_path): def get_firmware_update_notification(self, image_path): return "Immediate cold reboot is required to complete {} firmware update".format(self.name) - def install_firmware(self, image_path): - return self.__install_firmware(image_path) + def install_firmware(self, image_path, allow_reboot=True): + return self.__install_firmware(image_path, allow_reboot) def update_firmware(self, image_path): self.__install_firmware(image_path) @@ -756,6 +763,29 @@ def __install_firmware(self, image_path): return True + def auto_update_firmware(self, image_path, boot_action): + """ + Default handling of attempted automatic update for a component of a Mellanox switch. + Will skip the installation if the boot_action is 'warm' or 'fast' and will call update_firmware() + if boot_action is fast. + """ + + # Verify image path exists + if not os.path.exists(image_path): + # Invalid image path + return FW_AUTO_ERR_IMAGE + + # boot_type did not match (skip) + if boot_action != "cold": + return FW_AUTO_ERR_BOOT_TYPE + + # Install burn. Error if fail. + if not self.install_firmware(image_path): + return FW_AUTO_ERR_UNKNOWN + + # Schedule refresh + return FW_AUTO_SCHEDULED + def get_firmware_version(self): part_number_file = self.CPLD_PART_NUMBER_FILE.format(self.idx) version_file = self.CPLD_VERSION_FILE.format(self.idx) @@ -792,7 +822,17 @@ def get_firmware_update_notification(self, image_path): return "Immediate power cycle is required to complete {} firmware update".format(self.name) def install_firmware(self, image_path): - return self.__install_firmware(image_path) + if MPFAManager.MPFA_EXTENSION in image_path: + with MPFAManager(image_path) as mpfa: + if not mpfa.get_metadata().has_option('firmware', 'burn'): + raise RuntimeError("Failed to get {} burn firmware".format(self.name)) + + burn_firmware = mpfa.get_metadata().get('firmware', 'burn') + + print("INFO: Processing {} burn file: firmware install".format(self.name)) + return self.__install_firmware(os.path.join(mpfa.get_path(), burn_firmware)) + else: + return self.__install_firmware(image_path) def update_firmware(self, image_path): with MPFAManager(image_path) as mpfa: diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py b/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py index 69849893f635..b4610fe045f0 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py @@ -144,7 +144,7 @@ } } }, - 'x86_64-mlnx_msn4800-r0': { + 'x86_64-nvidia_sn4800-r0': { 'thermal': { "capability": { "comex_amb": False @@ -157,7 +157,9 @@ 'x86_64-nvidia_sn2201-r0': { 'thermal': { "capability": { - "comex_amb": False + "comex_amb": False, + "cpu_amb": True, + "swb_amb": True } } }, @@ -225,7 +227,7 @@ def get_minimum_table(cls): platform_data = DEVICE_DATA.get(cls.get_platform_name(), None) if not platform_data: return None - + thermal_data = platform_data.get('thermal', None) if not thermal_data: return None @@ -238,7 +240,7 @@ def get_thermal_capability(cls): platform_data = DEVICE_DATA.get(cls.get_platform_name(), None) if not platform_data: return None - + thermal_data = platform_data.get('thermal', None) if not thermal_data: return None @@ -256,7 +258,7 @@ def get_linecard_max_port_count(cls): platform_data = DEVICE_DATA.get(cls.get_platform_name(), None) if not platform_data: return 0 - + sfp_data = platform_data.get('sfp', None) if not sfp_data: return 0 diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/fan.py b/platform/mellanox/mlnx-platform-api/sonic_platform/fan.py index 1da6fd8e5c69..b67bb065a70c 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/fan.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/fan.py @@ -30,6 +30,7 @@ from sonic_py_common.logger import Logger from .led import ComponentFaultyIndicator from . import utils + from .thermal import Thermal except ImportError as e: raise ImportError (str(e) + "- required module not found") @@ -44,13 +45,9 @@ FAN_DIR = "/var/run/hw-management/thermal/fan{}_dir" FAN_DIR_VALUE_EXHAUST = 0 FAN_DIR_VALUE_INTAKE = 1 -COOLING_STATE_PATH = "/var/run/hw-management/thermal/cooling_cur_state" class MlnxFan(FanBase): - MIN_VALID_COOLING_LEVEL = 1 - MAX_VALID_COOLING_LEVEL = 10 - def __init__(self, fan_index, position): super(MlnxFan, self).__init__() self.index = fan_index + 1 @@ -88,7 +85,7 @@ def set_status_led(self, color): fan module status LED Returns: - bool: True if set success, False if fail. + bool: True if set success, False if fail. """ return self.led.set_status(color) @@ -128,37 +125,6 @@ def is_replaceable(self): """ return False - @classmethod - def set_cooling_level(cls, level, cur_state): - """ - Change cooling level. The input level should be an integer value [1, 10]. - 1 means 10%, 2 means 20%, 10 means 100%. - """ - if level < cls.MIN_VALID_COOLING_LEVEL or level > cls.MAX_VALID_COOLING_LEVEL: - raise RuntimeError("Failed to set cooling level, level value must be in range [{}, {}], got {}".format( - cls.MIN_VALID_COOLING_LEVEL, - cls.MAX_VALID_COOLING_LEVEL, - level - )) - - try: - # Reset FAN cooling level vector. According to low level team, - # if we need set cooling level to X, we need first write a (10+X) - # to cooling_cur_state file to reset the cooling level vector. - utils.write_file(COOLING_STATE_PATH, level + 10, raise_exception=True) - - # We need set cooling level after resetting the cooling level vector - utils.write_file(COOLING_STATE_PATH, cur_state, raise_exception=True) - except (ValueError, IOError) as e: - raise RuntimeError("Failed to set cooling level - {}".format(e)) - - @classmethod - def get_cooling_level(cls): - try: - return utils.read_int_from_file(COOLING_STATE_PATH, raise_exception=True) - except (ValueError, IOError) as e: - raise RuntimeError("Failed to get cooling level - {}".format(e)) - class PsuFan(MlnxFan): # PSU fan speed vector @@ -189,7 +155,7 @@ def get_direction(self): depending on fan direction Notes: - What Mellanox calls forward: + What Mellanox calls forward: Air flows from fans side to QSFP side, for example: MSN2700-CS2F which means intake in community What Mellanox calls reverse: @@ -228,7 +194,7 @@ def get_target_speed(self): """ try: # Get PSU fan target speed according to current system cooling level - cooling_level = self.get_cooling_level() + cooling_level = Thermal.get_cooling_level() return int(self.PSU_FAN_SPEED[cooling_level], 16) except Exception: return self.get_speed() @@ -242,7 +208,7 @@ def set_speed(self, speed): in the range 0 (off) to 100 (full speed) Returns: - bool: True if set success, False if fail. + bool: True if set success, False if fail. """ if not self.get_presence(): return False @@ -264,12 +230,9 @@ def set_speed(self, speed): class Fan(MlnxFan): """Platform-specific Fan class""" - - min_cooling_level = 2 - def __init__(self, fan_index, fan_drawer, position): super(Fan, self).__init__(fan_index, position) - + self.fan_drawer = fan_drawer self.led = ComponentFaultyIndicator(self.fan_drawer.get_led()) @@ -278,7 +241,7 @@ def __init__(self, fan_index, fan_drawer, position): self.fan_speed_set_path = os.path.join(FAN_PATH, "fan{}_speed_set".format(self.index)) self.fan_max_speed_path = os.path.join(FAN_PATH, "fan{}_max".format(self.index)) self.fan_min_speed_path = os.path.join(FAN_PATH, "fan{}_min".format(self.index)) - + self.fan_status_path = os.path.join(FAN_PATH, "fan{}_fault".format(self.index)) def get_direction(self): @@ -290,7 +253,7 @@ def get_direction(self): depending on fan direction Notes: - What Mellanox calls forward: + What Mellanox calls forward: Air flows from fans side to QSFP side, for example: MSN2700-CS2F which means intake in community What Mellanox calls reverse: @@ -340,16 +303,11 @@ def set_speed(self, speed): in the range 0 (off) to 100 (full speed) Returns: - bool: True if set success, False if fail. + bool: True if set success, False if fail. """ status = True try: - cooling_level = int(speed // 10) - if cooling_level < self.min_cooling_level: - cooling_level = self.min_cooling_level - speed = self.min_cooling_level * 10 - self.set_cooling_level(cooling_level, cooling_level) pwm = int(PWM_MAX*speed/100.0) utils.write_file(self.fan_speed_set_path, pwm, raise_exception=True) except (ValueError, IOError): diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py index a0d392d4b680..e4d22575450c 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py @@ -38,8 +38,8 @@ logger = Logger() """ -The most important information for creating a Thermal object is 3 sysfs files: temperature file, high threshold file and -high critical threshold file. There is no common naming rule for thermal objects on Nvidia platform. There are two types +The most important information for creating a Thermal object is 3 sysfs files: temperature file, high threshold file and +high critical threshold file. There is no common naming rule for thermal objects on Nvidia platform. There are two types of thermal object: single and indexable: 1. Single. Such as asic, port_amb... 2. Indexablt. Such as cpu_core0, cpu_core1, psu1_temp, psu2_temp @@ -63,7 +63,7 @@ "high_critical_threshold": "module{}_temp_emergency", "type": "indexable" }, - "psu thermals": + "psu thermals": { "name": "PSU-{} Temp", "temperature": "psu{}_temp", @@ -112,11 +112,13 @@ }, { "name": "Ambient CPU Board Temp", - "temperature": "cpu_amb" + "temperature": "cpu_amb", + "default_present": False }, { "name": "Ambient Switch Board Temp", - "temperature": "swb_amb" + "temperature": "swb_amb", + "default_present": False } ], 'linecard thermals': { @@ -129,13 +131,23 @@ } CHASSIS_THERMAL_SYSFS_FOLDER = '/run/hw-management/thermal' +COOLING_STATE_PATH = "/var/run/hw-management/thermal/cooling_cur_state" +THERMAL_ZONE_ASIC_PATH = '/var/run/hw-management/thermal/mlxsw/' THERMAL_ZONE_FOLDER_WILDCARD = '/run/hw-management/thermal/mlxsw*' -THERMAL_ZONE_POLICY_FILE = 'thermal_zone_policy' +THERMAL_ZONE_HIGH_THRESHOLD = 'temp_trip_high' +THERMAL_ZONE_HOT_THRESHOLD = 'temp_trip_hot' +THERMAL_ZONE_NORMAL_THRESHOLD = 'temp_trip_norm' THERMAL_ZONE_MODE_FILE = 'thermal_zone_mode' +THERMAL_ZONE_POLICY_FILE = 'thermal_zone_policy' THERMAL_ZONE_TEMP_FILE = 'thermal_zone_temp' -THERMAL_ZONE_THRESHOLD_FILE = 'temp_trip_high' +THERMAL_ZONE_HYSTERESIS = 5000 MODULE_TEMP_FAULT_WILDCARRD = '/run/hw-management/thermal/module*_temp_fault' MAX_AMBIENT_TEMP = 120 +# Min allowed cooling level when all thermal zones are in normal state +MIN_COOLING_LEVEL_FOR_NORMAL = 2 +# Min allowed cooling level when any thermal zone is in high state but no thermal zone is in emergency state +MIN_COOLING_LEVEL_FOR_HIGH = 4 +MAX_COOLING_LEVEL = 10 def initialize_chassis_thermals(): @@ -170,7 +182,7 @@ def initialize_psu_thermal(psu_index, presence_cb): Args: psu_index (int): PSU index, 0-based presence_cb (function): A callback function to indicate if the thermal is present. When removing a PSU, the related - thermal sysfs files will be removed from system, presence_cb is used to check such situation and avoid printing + thermal sysfs files will be removed from system, presence_cb is used to check such situation and avoid printing error logs. Returns: @@ -226,10 +238,14 @@ def create_indexable_thermal(rule, index, sysfs_folder, position, presence_cb=No def create_single_thermal(rule, sysfs_folder, position, presence_cb=None): temp_file = rule['temperature'] + default_present = rule.get('default_present', True) thermal_capability = DeviceDataManager.get_thermal_capability() + if thermal_capability: - if not thermal_capability.get(temp_file, True): + if not thermal_capability.get(temp_file, default_present): return None + elif not default_present: + return None temp_file = os.path.join(sysfs_folder, temp_file) _check_thermal_sysfs_existence(temp_file) @@ -257,6 +273,14 @@ def _check_thermal_sysfs_existence(file_path): class Thermal(ThermalBase): thermal_algorithm_status = False + # Expect cooling level, used for caching the cooling level value before commiting to hardware + expect_cooling_level = None + # Expect cooling state + expect_cooling_state = None + # Last committed cooling level + last_set_cooling_level = None + last_set_cooling_state = None + last_set_psu_cooling_level = None def __init__(self, name, temp_file, high_th_file, high_crit_th_file, position): """ @@ -284,7 +308,7 @@ def get_temperature(self): Returns: A float number of current temperature in Celsius up to nearest thousandth - of one degree Celsius, e.g. 30.125 + of one degree Celsius, e.g. 30.125 """ value = utils.read_float_from_file(self.temperature, None, log_func=logger.log_info) return value / 1000.0 if (value is not None and value != 0) else None @@ -340,8 +364,8 @@ def set_thermal_algorithm_status(cls, status, force=True): only adjust fan speed when temperature across some "edge", e.g temperature changes to exceed high threshold. When disable kernel thermal algorithm, kernel no longer adjust fan speed. - We usually disable the algorithm when we want to set a fix speed. E.g, when - a fan unit is removed from system, we will set fan speed to 100% and disable + We usually disable the algorithm when we want to set a fix speed. E.g, when + a fan unit is removed from system, we will set fan speed to 100% and disable the algorithm to avoid it adjust the speed. Returns: @@ -358,35 +382,41 @@ def set_thermal_algorithm_status(cls, status, force=True): utils.write_file(policy_file, policy) mode_file = os.path.join(thermal_zone_folder, THERMAL_ZONE_MODE_FILE) utils.write_file(mode_file, mode) - + return True @classmethod - def check_thermal_zone_temperature(cls): - """ - Check thermal zone current temperature with normal temperature - + def get_min_allowed_cooling_level_by_thermal_zone(cls): + """Get min allowed cooling level according to thermal zone status: + 1. If temperature of all thermal zones is less than normal threshold, min allowed cooling level is + $MIN_COOLING_LEVEL_FOR_NORMAL = 2 + 2. If temperature of any thermal zone is greater than normal threshold, but no thermal zone temperature + is greater than high threshold, min allowed cooling level is $MIN_COOLING_LEVEL_FOR_HIGH = 4 + 3. Otherwise, there is no minimum allowed value and policy should not adjust cooling level Returns: - True if all thermal zones current temperature less or equal than normal temperature + int: minimum allowed cooling level """ - for thermal_zone_folder in glob.iglob(THERMAL_ZONE_FOLDER_WILDCARD): - if not cls._check_thermal_zone_temperature(thermal_zone_folder): - return False - - return True - - @classmethod - def _check_thermal_zone_temperature(cls, thermal_zone_path): - threshold_path = os.path.join(thermal_zone_path, THERMAL_ZONE_THRESHOLD_FILE) - current_temp_path = os.path.join(thermal_zone_path, THERMAL_ZONE_TEMP_FILE) - + min_allowed = MIN_COOLING_LEVEL_FOR_NORMAL + thermal_zone_present = False try: - threshold = utils.read_int_from_file(threshold_path, raise_exception=True) - current = utils.read_int_from_file(current_temp_path, raise_exception=True) - return current <= threshold + for thermal_zone_folder in glob.iglob(THERMAL_ZONE_FOLDER_WILDCARD): + thermal_zone_present = True + normal_thresh = utils.read_int_from_file(os.path.join(thermal_zone_folder, THERMAL_ZONE_NORMAL_THRESHOLD)) + current = utils.read_int_from_file(os.path.join(thermal_zone_folder, THERMAL_ZONE_TEMP_FILE)) + if current < normal_thresh - THERMAL_ZONE_HYSTERESIS: + continue + + hot_thresh = utils.read_int_from_file(os.path.join(thermal_zone_folder, THERMAL_ZONE_HIGH_THRESHOLD)) + if current < hot_thresh - THERMAL_ZONE_HYSTERESIS: + min_allowed = MIN_COOLING_LEVEL_FOR_HIGH + else: + min_allowed = None + break except Exception as e: - logger.log_info("Fail to check thermal zone temperature for file {} due to {}".format(thermal_zone_path, repr(e))) - return False + logger.log_error('Failed to get thermal zone status for {} - {}'.format(thermal_zone_folder, repr(e))) + return None + + return min_allowed if thermal_zone_present else None @classmethod def check_module_temperature_trustable(cls): @@ -410,6 +440,85 @@ def get_min_amb_temperature(cls): logger.log_error('Failed to get minimum ambient temperature, use pessimistic instead') return MAX_AMBIENT_TEMP + @classmethod + def set_cooling_level(cls, level): + """ + Change cooling level. The input level should be an integer value [1, 10]. + 1 means 10%, 2 means 20%, 10 means 100%. + """ + if cls.last_set_cooling_level != level: + utils.write_file(COOLING_STATE_PATH, level + 10, raise_exception=True) + cls.last_set_cooling_level = level + + @classmethod + def set_cooling_state(cls, state): + """Change cooling state. + Args: + state (int): cooling state + """ + if cls.last_set_cooling_state != state: + utils.write_file(COOLING_STATE_PATH, state, raise_exception=True) + cls.last_set_cooling_state = state + + @classmethod + def get_cooling_level(cls): + try: + return utils.read_int_from_file(COOLING_STATE_PATH, raise_exception=True) + except (ValueError, IOError) as e: + raise RuntimeError("Failed to get cooling level - {}".format(e)) + + @classmethod + def set_expect_cooling_level(cls, expect_value): + """During thermal policy running, cache the expect cooling level generated by policies. The max expect + cooling level will be committed to hardware. + Args: + expect_value (int): Expected cooling level value + """ + if cls.expect_cooling_level is None or cls.expect_cooling_level < expect_value: + cls.expect_cooling_level = int(expect_value) + + @classmethod + def commit_cooling_level(cls, thermal_info_dict): + """Commit cooling level to hardware. This will affect system fan and PSU fan speed. + Args: + thermal_info_dict (dict): Thermal information dictionary + """ + if cls.expect_cooling_level is not None: + cls.set_cooling_level(cls.expect_cooling_level) + + if cls.expect_cooling_state is not None: + cls.set_cooling_state(cls.expect_cooling_state) + elif cls.expect_cooling_level is not None: + cls.set_cooling_state(cls.expect_cooling_level) + + cls.expect_cooling_level = None + # We need to set system fan speed here because kernel will automaticlly adjust fan speed according to cooling level and cooling state + + # Commit PSU fan speed with current state + from .thermal_infos import ChassisInfo + if ChassisInfo.INFO_NAME in thermal_info_dict and isinstance(thermal_info_dict[ChassisInfo.INFO_NAME], ChassisInfo): + cooling_level = cls.get_cooling_level() + if cls.last_set_psu_cooling_level == cooling_level: + return + speed = cooling_level * 10 + chassis = thermal_info_dict[ChassisInfo.INFO_NAME].get_chassis() + for psu in chassis.get_all_psus(): + for psu_fan in psu.get_all_fans(): + psu_fan.set_speed(speed) + cls.last_set_psu_cooling_level = cooling_level + + @classmethod + def monitor_asic_themal_zone(cls): + """This is a protection for asic thermal zone, if asic temperature is greater than hot threshold + THERMAL_ZONE_HYSTERESIS, + and if cooling state is not MAX, we need enforce the cooling state to MAX + """ + asic_temp = utils.read_int_from_file(os.path.join(THERMAL_ZONE_ASIC_PATH, THERMAL_ZONE_TEMP_FILE), raise_exception=True) + hot_thresh = utils.read_int_from_file(os.path.join(THERMAL_ZONE_ASIC_PATH, THERMAL_ZONE_HOT_THRESHOLD), raise_exception=True) + if asic_temp >= hot_thresh + THERMAL_ZONE_HYSTERESIS: + cls.expect_cooling_state = MAX_COOLING_LEVEL + else: + cls.expect_cooling_state = None + class RemovableThermal(Thermal): def __init__(self, name, temp_file, high_th_file, high_crit_th_file, position, presence_cb): @@ -422,7 +531,7 @@ def get_temperature(self): Returns: A float number of current temperature in Celsius up to nearest thousandth - of one degree Celsius, e.g. 30.125 + of one degree Celsius, e.g. 30.125 """ status, hint = self.presence_cb() if not status: diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_actions.py b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_actions.py index e5bc9e8b25a4..3b93a7468b15 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_actions.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_actions.py @@ -16,7 +16,7 @@ # from sonic_platform_base.sonic_thermal_control.thermal_action_base import ThermalPolicyActionBase from sonic_platform_base.sonic_thermal_control.thermal_json_object import thermal_json_object -from .thermal import logger +from .thermal import Thermal class SetFanSpeedAction(ThermalPolicyActionBase): @@ -64,120 +64,28 @@ def execute(self, thermal_info_dict): :param thermal_info_dict: A dictionary stores all thermal information. :return: """ - from .thermal_infos import FanInfo - if FanInfo.INFO_NAME in thermal_info_dict and isinstance(thermal_info_dict[FanInfo.INFO_NAME], FanInfo): - fan_info_obj = thermal_info_dict[FanInfo.INFO_NAME] - for fan in fan_info_obj.get_presence_fans(): - fan.set_speed(self.speed) - logger.log_info('Set all system FAN speed to {}'.format(self.speed)) - - SetAllFanSpeedAction.set_psu_fan_speed(thermal_info_dict, self.speed) - - @classmethod - def set_psu_fan_speed(cls, thermal_info_dict, speed): - from .thermal_infos import ChassisInfo - if ChassisInfo.INFO_NAME in thermal_info_dict and isinstance(thermal_info_dict[ChassisInfo.INFO_NAME], ChassisInfo): - chassis = thermal_info_dict[ChassisInfo.INFO_NAME].get_chassis() - for psu in chassis.get_all_psus(): - for psu_fan in psu.get_all_fans(): - psu_fan.set_speed(speed) - - -@thermal_json_object('fan.all.check_and_set_speed') -class CheckAndSetAllFanSpeedAction(SetAllFanSpeedAction): - """ - Action to check thermal zone temperature and recover speed for all fans - """ - def execute(self, thermal_info_dict): - """ - Check thermal zone and set speed for all fans - :param thermal_info_dict: A dictionary stores all thermal information. - :return: - """ - from .thermal import Thermal - if Thermal.check_thermal_zone_temperature(): - SetAllFanSpeedAction.execute(self, thermal_info_dict) - - -@thermal_json_object('thermal_control.control') -class ControlThermalAlgoAction(ThermalPolicyActionBase): - """ - Action to control the thermal control algorithm - """ - # JSON field definition - JSON_FIELD_STATUS = 'status' - - def __init__(self): - self.status = True - - def load_from_json(self, json_obj): - """ - Construct ControlThermalAlgoAction via JSON. JSON example: - { - "type": "thermal_control.control" - "status": "true" - } - :param json_obj: A JSON object representing a ControlThermalAlgoAction action. - :return: - """ - if ControlThermalAlgoAction.JSON_FIELD_STATUS in json_obj: - status_str = json_obj[ControlThermalAlgoAction.JSON_FIELD_STATUS].lower() - if status_str == 'true': - self.status = True - elif status_str == 'false': - self.status = False - else: - raise ValueError('Invalid {} field value, please specify true of false'. - format(ControlThermalAlgoAction.JSON_FIELD_STATUS)) - else: - raise ValueError('ControlThermalAlgoAction ' - 'missing mandatory field {} in JSON policy file'. - format(ControlThermalAlgoAction.JSON_FIELD_STATUS)) - - def execute(self, thermal_info_dict): - """ - Disable thermal control algorithm - :param thermal_info_dict: A dictionary stores all thermal information. - :return: - """ - from .thermal_infos import FanInfo - from .thermal import Thermal - from .thermal_conditions import UpdateCoolingLevelToMinCondition - from .fan import Fan - status_changed = Thermal.set_thermal_algorithm_status(self.status, False) - - # Only update cooling level if thermal algorithm status changed - if status_changed: - if self.status: - # Check thermal zone temperature, if all thermal zone temperature - # back to normal, set it to minimum allowed speed to - # save power - UpdateCoolingLevelToMinAction.update_cooling_level_to_minimum(thermal_info_dict) - - logger.log_info('Changed thermal algorithm status to {}'.format(self.status)) + Thermal.set_expect_cooling_level(self.speed / 10) @thermal_json_object('thermal.recover') class ThermalRecoverAction(ThermalPolicyActionBase): - def execute(self, thermal_info_dict): - UpdateCoolingLevelToMinAction.update_cooling_level_to_minimum(thermal_info_dict) - - -class ChangeMinCoolingLevelAction(ThermalPolicyActionBase): UNKNOWN_SKU_COOLING_LEVEL = 6 + def execute(self, thermal_info_dict): from .device_data import DeviceDataManager - from .fan import Fan - from .thermal_infos import ChassisInfo - from .thermal_conditions import MinCoolingLevelChangeCondition - from .thermal_conditions import UpdateCoolingLevelToMinCondition + from .thermal import MAX_COOLING_LEVEL, MIN_COOLING_LEVEL_FOR_HIGH, logger + Thermal.monitor_asic_themal_zone() + # Calculate dynamic minimum cooling level + dynamic_min_cooling_level = None minimum_table = DeviceDataManager.get_minimum_table() if not minimum_table: - Fan.min_cooling_level = ChangeMinCoolingLevelAction.UNKNOWN_SKU_COOLING_LEVEL + # If there is no minimum_table defined, set dynamic_min_cooling_level to default value + dynamic_min_cooling_level = ThermalRecoverAction.UNKNOWN_SKU_COOLING_LEVEL else: - trust_state = MinCoolingLevelChangeCondition.trust_state - temperature = MinCoolingLevelChangeCondition.temperature + trust_state = Thermal.check_module_temperature_trustable() + temperature = Thermal.get_min_amb_temperature() + temperature = int(temperature / 1000) minimum_table = minimum_table['unk_{}'.format(trust_state)] for key, cooling_level in minimum_table.items(): @@ -185,41 +93,19 @@ def execute(self, thermal_info_dict): temp_min = int(temp_range[0].strip()) temp_max = int(temp_range[1].strip()) if temp_min <= temperature <= temp_max: - Fan.min_cooling_level = cooling_level - 10 + dynamic_min_cooling_level = cooling_level - 10 break - - current_cooling_level = Fan.get_cooling_level() - if current_cooling_level < Fan.min_cooling_level: - Fan.set_cooling_level(Fan.min_cooling_level, Fan.min_cooling_level) - SetAllFanSpeedAction.set_psu_fan_speed(thermal_info_dict, Fan.min_cooling_level * 10) - else: - Fan.set_cooling_level(Fan.min_cooling_level, current_cooling_level) - UpdateCoolingLevelToMinAction.update_cooling_level_to_minimum(thermal_info_dict) + if not dynamic_min_cooling_level: + # Should not go to this branch, just in case + logger.log_error('Failed to get dynamic minimum cooling level') + dynamic_min_cooling_level = MAX_COOLING_LEVEL -class UpdatePsuFanSpeedAction(ThermalPolicyActionBase): - def execute(self, thermal_info_dict): - from .thermal_conditions import CoolingLevelChangeCondition - SetAllFanSpeedAction.set_psu_fan_speed(thermal_info_dict, CoolingLevelChangeCondition.cooling_level * 10) - - -class UpdateCoolingLevelToMinAction(ThermalPolicyActionBase): - def execute(self, thermal_info_dict): - self.update_cooling_level_to_minimum(thermal_info_dict) - - @classmethod - def update_cooling_level_to_minimum(cls, thermal_info_dict): - from .fan import Fan - from .thermal import Thermal - from .thermal_conditions import UpdateCoolingLevelToMinCondition - from .thermal_infos import FanInfo - if Thermal.check_thermal_zone_temperature(): - fan_info_obj = thermal_info_dict[FanInfo.INFO_NAME] - speed = Fan.min_cooling_level * 10 - for fan in fan_info_obj.get_presence_fans(): - fan.set_speed(speed) - SetAllFanSpeedAction.set_psu_fan_speed(thermal_info_dict, speed) - UpdateCoolingLevelToMinCondition.enable = False + if Thermal.last_set_cooling_level is not None and dynamic_min_cooling_level > Thermal.last_set_cooling_level and dynamic_min_cooling_level >= MIN_COOLING_LEVEL_FOR_HIGH: + # No need to check thermal zone as dynamic_min_cooling_level is greater than previous value and MIN_COOLING_LEVEL_FOR_HIGH + Thermal.set_expect_cooling_level(dynamic_min_cooling_level) else: - UpdateCoolingLevelToMinCondition.enable = True - + min_cooling_level_by_tz = Thermal.get_min_allowed_cooling_level_by_thermal_zone() + if min_cooling_level_by_tz is not None: + cooling_level = max(dynamic_min_cooling_level, min_cooling_level_by_tz) + Thermal.set_expect_cooling_level(cooling_level) diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_conditions.py b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_conditions.py index 6c82fb752171..456923d230c2 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_conditions.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_conditions.py @@ -90,53 +90,3 @@ class AllPsuPresenceCondition(PsuCondition): def is_match(self, thermal_info_dict): psu_info_obj = self.get_psu_info(thermal_info_dict) return len(psu_info_obj.get_absence_psus()) == 0 if psu_info_obj else False - - -class MinCoolingLevelChangeCondition(ThermalPolicyConditionBase): - trust_state = None - temperature = None - - def is_match(self, thermal_info_dict): - from .thermal import Thermal - - trust_state = Thermal.check_module_temperature_trustable() - temperature = Thermal.get_min_amb_temperature() - temperature = int(temperature / 1000) - - change_cooling_level = False - if trust_state != MinCoolingLevelChangeCondition.trust_state: - MinCoolingLevelChangeCondition.trust_state = trust_state - change_cooling_level = True - - if temperature != MinCoolingLevelChangeCondition.temperature: - MinCoolingLevelChangeCondition.temperature = temperature - change_cooling_level = True - - return change_cooling_level - - -class CoolingLevelChangeCondition(ThermalPolicyConditionBase): - cooling_level = None - - def is_match(self, thermal_info_dict): - from .fan import Fan - current_cooling_level = Fan.get_cooling_level() - if current_cooling_level != CoolingLevelChangeCondition.cooling_level: - CoolingLevelChangeCondition.cooling_level = current_cooling_level - return True - else: - return False - - -class UpdateCoolingLevelToMinCondition(ThermalPolicyConditionBase): - enable = False - def is_match(self, thermal_info_dict): - if not UpdateCoolingLevelToMinCondition.enable: - return False - - from .fan import Fan - current_cooling_level = Fan.get_cooling_level() - if current_cooling_level == Fan.min_cooling_level: - UpdateCoolingLevelToMinCondition.enable = False - return False - return True diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_manager.py b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_manager.py index cfcd911b9c9a..895d3aaefedb 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_manager.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_manager.py @@ -14,33 +14,22 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import os from sonic_platform_base.sonic_thermal_control.thermal_manager_base import ThermalManagerBase -from sonic_platform_base.sonic_thermal_control.thermal_policy import ThermalPolicy from .thermal_actions import * from .thermal_conditions import * from .thermal_infos import * +from .thermal import logger, MAX_COOLING_LEVEL, Thermal class ThermalManager(ThermalManagerBase): - @classmethod - def initialize(cls): - """ - Initialize thermal manager, including register thermal condition types and thermal action types - and any other vendor specific initialization. - :return: - """ - cls._add_private_thermal_policy() - @classmethod def start_thermal_control_algorithm(cls): """ Start thermal control algorithm Returns: - bool: True if set success, False if fail. + bool: True if set success, False if fail. """ - from .thermal import Thermal Thermal.set_thermal_algorithm_status(True) @classmethod @@ -49,24 +38,33 @@ def stop_thermal_control_algorithm(cls): Stop thermal control algorithm Returns: - bool: True if set success, False if fail. + bool: True if set success, False if fail. """ - from .thermal import Thermal Thermal.set_thermal_algorithm_status(False) @classmethod - def _add_private_thermal_policy(cls): - dynamic_min_speed_policy = ThermalPolicy() - dynamic_min_speed_policy.conditions[MinCoolingLevelChangeCondition] = MinCoolingLevelChangeCondition() - dynamic_min_speed_policy.actions[ChangeMinCoolingLevelAction] = ChangeMinCoolingLevelAction() - cls._policy_dict['DynamicMinCoolingLevelPolicy'] = dynamic_min_speed_policy + def run_policy(cls, chassis): + if not cls._policy_dict: + return + + try: + cls._collect_thermal_information(chassis) + except Exception as e: + logger.log_error('Failed to collect thermal information {}'.format(repr(e))) + Thermal.set_expect_cooling_level(MAX_COOLING_LEVEL) + Thermal.commit_cooling_level(cls._thermal_info_dict) + return - update_psu_fan_speed_policy = ThermalPolicy() - update_psu_fan_speed_policy.conditions[CoolingLevelChangeCondition] = CoolingLevelChangeCondition() - update_psu_fan_speed_policy.actions[UpdatePsuFanSpeedAction] = UpdatePsuFanSpeedAction() - cls._policy_dict['UpdatePsuFanSpeedPolicy'] = update_psu_fan_speed_policy + for policy in cls._policy_dict.values(): + if not cls._running: + return + try: + print(policy.name) + if policy.is_match(cls._thermal_info_dict): + policy.do_action(cls._thermal_info_dict) + except Exception as e: + logger.log_error('Failed to run thermal policy {} - {}'.format(policy.name, repr(e))) + # In case there is an exception, we put cooling level to max value + Thermal.set_expect_cooling_level(MAX_COOLING_LEVEL) - update_cooling_level_policy = ThermalPolicy() - update_cooling_level_policy.conditions[UpdateCoolingLevelToMinCondition] = UpdateCoolingLevelToMinCondition() - update_cooling_level_policy.actions[UpdateCoolingLevelToMinAction] = UpdateCoolingLevelToMinAction() - cls._policy_dict['UpdateCoolingLevelPolicy'] = update_cooling_level_policy + Thermal.commit_cooling_level(cls._thermal_info_dict) diff --git a/platform/mellanox/mlnx-platform-api/tests/conftest.py b/platform/mellanox/mlnx-platform-api/tests/conftest.py index f232c55c47a2..c69ba8464e28 100644 --- a/platform/mellanox/mlnx-platform-api/tests/conftest.py +++ b/platform/mellanox/mlnx-platform-api/tests/conftest.py @@ -42,3 +42,14 @@ def auto_recover_mock(): utils.read_str_from_file = origin_read_str_from_file utils.write_file = origin_write_file utils.read_float_from_file = origin_read_float_from_file + + +@pytest.fixture(scope='function', autouse=True) +def auto_reset_cooling_level(): + from sonic_platform.thermal import Thermal + yield + Thermal.expect_cooling_level = None + Thermal.expect_cooling_state = None + Thermal.last_set_cooling_level = None + Thermal.last_set_cooling_state = None + Thermal.last_set_psu_cooling_level = None diff --git a/platform/mellanox/mlnx-platform-api/tests/policy_with_same_conditions.json b/platform/mellanox/mlnx-platform-api/tests/policy_with_same_conditions.json index ace291be1c55..9efe773a9b07 100644 --- a/platform/mellanox/mlnx-platform-api/tests/policy_with_same_conditions.json +++ b/platform/mellanox/mlnx-platform-api/tests/policy_with_same_conditions.json @@ -27,8 +27,7 @@ ], "actions": [ { - "type": "thermal_control.control", - "status": "false" + "type": "thermal.recover" }, { "type": "fan.all.set_speed", @@ -45,8 +44,7 @@ ], "actions": [ { - "type": "thermal_control.control", - "status": "false" + "type": "thermal.recover" }, { "type": "fan.all.set_speed", @@ -66,8 +64,7 @@ ], "actions": [ { - "type": "thermal_control.control", - "status": "true" + "type": "thermal.recover" } ] } diff --git a/platform/mellanox/mlnx-platform-api/tests/test_fan_api.py b/platform/mellanox/mlnx-platform-api/tests/test_fan_api.py index 80eb16d912be..2aa33c213882 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_fan_api.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_fan_api.py @@ -18,14 +18,14 @@ import pytest import subprocess import sys -from mock import call, MagicMock +from mock import MagicMock, patch test_path = os.path.dirname(os.path.abspath(__file__)) modules_path = os.path.dirname(test_path) sys.path.insert(0, modules_path) from sonic_platform import utils -from sonic_platform.fan import Fan, PsuFan, COOLING_STATE_PATH +from sonic_platform.fan import Fan, PsuFan from sonic_platform.fan_drawer import RealDrawer, VirtualDrawer from sonic_platform.psu import Psu @@ -100,64 +100,31 @@ def mock_read_int_from_file(file_path, default=0, raise_exception=False): fan.fan_drawer.get_presence = MagicMock(return_value=True) assert fan.get_presence() is True - def test_system_fan_set_speed(self): + @patch('sonic_platform.utils.write_file') + def test_system_fan_set_speed(self, mock_write_file): fan_drawer = RealDrawer(0) fan = Fan(2, fan_drawer, 1) - fan.min_cooling_level = 2 - fan.set_cooling_level = MagicMock() - utils.write_file = MagicMock() fan.set_speed(60) - fan.set_cooling_level.assert_called_with(6, 6) - utils.write_file.assert_called_with(fan.fan_speed_set_path, 153, raise_exception=True) - - fan.min_cooling_level = 7 - fan.set_speed(60) - fan.set_cooling_level.assert_called_with(7, 7) - utils.write_file.assert_called_with(fan.fan_speed_set_path, 178, raise_exception=True) - - def test_set_cooling_level(self): - with pytest.raises(RuntimeError): - Fan.set_cooling_level(11, 11) - - utils.write_file = MagicMock() - Fan.set_cooling_level(10, 10) - calls = [call(COOLING_STATE_PATH, 20, raise_exception=True), call(COOLING_STATE_PATH, 10, raise_exception=True)] - utils.write_file.assert_has_calls(calls) - - utils.write_file = MagicMock(side_effect=IOError('')) - with pytest.raises(RuntimeError): - Fan.set_cooling_level(10, 10) - - utils.write_file = MagicMock(side_effect=ValueError('')) - with pytest.raises(RuntimeError): - Fan.set_cooling_level(10, 10) - - def test_get_cooling_level(self): - utils.read_int_from_file = MagicMock() - Fan.get_cooling_level() - utils.read_int_from_file.assert_called_with(COOLING_STATE_PATH, raise_exception=True) - - utils.read_int_from_file = MagicMock(side_effect=IOError('')) - with pytest.raises(RuntimeError): - Fan.get_cooling_level() - - utils.read_int_from_file = MagicMock(side_effect=ValueError('')) - with pytest.raises(RuntimeError): - Fan.get_cooling_level() - - def test_psu_fan_basic(self): + mock_write_file.assert_called_with(fan.fan_speed_set_path, 153, raise_exception=True) + + @patch('sonic_platform.thermal.Thermal.get_cooling_level') + @patch('sonic_platform.psu.Psu.get_presence') + @patch('sonic_platform.psu.Psu.get_powergood_status') + @patch('os.path.exists') + def test_psu_fan_basic(self, mock_path_exists, mock_powergood, mock_presence, mock_cooling_level): + mock_path_exists.return_value = False psu = Psu(0) fan = PsuFan(0, 1, psu) assert fan.get_direction() == Fan.FAN_DIRECTION_NOT_APPLICABLE assert fan.get_status() is True assert fan.get_presence() is False - psu.get_presence = MagicMock(return_value=True) + mock_presence.return_value = True assert fan.get_presence() is False - psu.get_powergood_status = MagicMock(return_value=True) + mock_powergood.return_value = True assert fan.get_presence() is False - os.path.exists = MagicMock(return_value=True) + mock_path_exists.return_value = True assert fan.get_presence() is True - fan.get_cooling_level = MagicMock(return_value=7) + mock_cooling_level.return_value = 7 assert fan.get_target_speed() == 70 def test_psu_fan_set_speed(self): diff --git a/platform/mellanox/mlnx-platform-api/tests/test_firmware.py b/platform/mellanox/mlnx-platform-api/tests/test_firmware.py index 6e24bdf07d24..5d576cd2d0cd 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_firmware.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_firmware.py @@ -24,18 +24,21 @@ modules_path = os.path.dirname(test_path) sys.path.insert(0, modules_path) -from sonic_platform.component import Component, ComponentSSD +from sonic_platform.component import Component, ComponentSSD, ComponentCPLD from sonic_platform_base.component_base import ComponentBase, \ FW_AUTO_INSTALLED, \ + FW_AUTO_SCHEDULED, \ + FW_AUTO_UPDATED, \ FW_AUTO_ERR_BOOT_TYPE, \ FW_AUTO_ERR_IMAGE, \ - FW_AUTO_ERR_UKNOWN + FW_AUTO_ERR_UNKNOWN -def mock_update_firmware_success(image_path): + +def mock_update_firmware_success(image_path, allow_reboot=False): return True -def mock_update_firmware_fail(image_path): +def mock_update_firmware_fail(image_path, allow_reboot=False): return False def mock_update_notification_cold_boot(image_path): @@ -50,18 +53,24 @@ def mock_update_notification_error(image_path): test_data_default = [ (None, False, None, FW_AUTO_ERR_IMAGE), (None, True, 'warm', FW_AUTO_ERR_BOOT_TYPE), - (mock_update_firmware_fail, True, 'cold', FW_AUTO_ERR_UKNOWN), + (mock_update_firmware_fail, True, 'cold', FW_AUTO_ERR_UNKNOWN), (mock_update_firmware_success, True, 'cold', FW_AUTO_INSTALLED) ] +test_data_cpld = [ + (None, False, None, FW_AUTO_ERR_IMAGE), + (None, True, 'warm', FW_AUTO_ERR_BOOT_TYPE), + (mock_update_firmware_fail, True, 'cold', FW_AUTO_ERR_UNKNOWN), + (mock_update_firmware_success, True, 'cold', FW_AUTO_SCHEDULED) + ] + test_data_ssd = [ (None, None, False, None, FW_AUTO_ERR_IMAGE), - (None, mock_update_notification_error, True, None, FW_AUTO_ERR_UKNOWN), - (mock_update_firmware_fail, mock_update_notification_cold_boot, True, 'cold', FW_AUTO_ERR_UKNOWN), + (None, mock_update_notification_error, True, None, FW_AUTO_ERR_UNKNOWN), (mock_update_firmware_success, mock_update_notification_cold_boot, True, 'warm', FW_AUTO_ERR_BOOT_TYPE), - (mock_update_firmware_success, mock_update_notification_cold_boot, True, 'cold', FW_AUTO_INSTALLED), - (mock_update_firmware_success, mock_update_notification_warm_boot, True, 'warm', FW_AUTO_INSTALLED), - (mock_update_firmware_success, mock_update_notification_warm_boot, True, 'cold', FW_AUTO_INSTALLED) + (mock_update_firmware_success, mock_update_notification_cold_boot, True, 'cold', FW_AUTO_SCHEDULED), + (mock_update_firmware_success, mock_update_notification_warm_boot, True, 'warm', FW_AUTO_UPDATED), + (mock_update_firmware_success, mock_update_notification_warm_boot, True, 'cold', FW_AUTO_UPDATED) ] @pytest.mark.parametrize('update_func, image_found, boot_type, expect', test_data_default) @@ -72,7 +81,23 @@ def mock_path_exists(path): test_component = Component() - monkeypatch.setattr(test_component, 'update_firmware', update_func) + monkeypatch.setattr(test_component, 'install_firmware', update_func) + monkeypatch.setattr(os.path, 'exists', mock_path_exists) + + result = test_component.auto_update_firmware(None, boot_type) + + assert result == expect + + +@pytest.mark.parametrize('update_func, image_found, boot_type, expect', test_data_cpld) +def test_auto_update_firmware_cpld(monkeypatch, update_func, image_found, boot_type, expect): + + def mock_path_exists(path): + return image_found + + test_component = ComponentCPLD(0) + + monkeypatch.setattr(test_component, 'install_firmware', update_func) monkeypatch.setattr(os.path, 'exists', mock_path_exists) result = test_component.auto_update_firmware(None, boot_type) @@ -81,7 +106,7 @@ def mock_path_exists(path): @pytest.mark.parametrize('update_func, notify, image_found, boot_type, expect', test_data_ssd) -def test_auto_update_firmware_default(monkeypatch, update_func, notify, image_found, boot_type, expect): +def test_auto_update_firmware_ssd(monkeypatch, update_func, notify, image_found, boot_type, expect): def mock_path_exists(path): return image_found diff --git a/platform/mellanox/mlnx-platform-api/tests/test_thermal.py b/platform/mellanox/mlnx-platform-api/tests/test_thermal.py index a3e90d7c56cd..216b5cd316c7 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_thermal.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_thermal.py @@ -17,6 +17,7 @@ import glob import os +import pytest import sys if sys.version_info.major == 3: from unittest import mock @@ -32,12 +33,13 @@ class TestThermal: + @mock.patch('os.path.exists', mock.MagicMock(return_value=True)) + @mock.patch('sonic_platform.device_data.DeviceDataManager.get_gearbox_count', mock.MagicMock(return_value=2)) + @mock.patch('sonic_platform.device_data.DeviceDataManager.get_cpu_thermal_count', mock.MagicMock(return_value=2)) + @mock.patch('sonic_platform.device_data.DeviceDataManager.get_platform_name', mock.MagicMock(return_value='x86_64-mlnx_msn2700-r0')) def test_chassis_thermal(self): from sonic_platform.thermal import THERMAL_NAMING_RULE os.path.exists = mock.MagicMock(return_value=True) - DeviceDataManager.get_gearbox_count = mock.MagicMock(return_value=2) - DeviceDataManager.get_cpu_thermal_count = mock.MagicMock(return_value=2) - DeviceDataManager.get_platform_name = mock.MagicMock(return_value='x86_64-mlnx_msn2700-r0') chassis = Chassis() thermal_list = chassis.get_all_thermals() assert thermal_list @@ -51,6 +53,10 @@ def test_chassis_thermal(self): if rule['temperature'] == 'comex_amb': assert thermal_name not in thermal_dict continue + default_present = rule.get('default_present', True) + if not default_present: + assert thermal_name not in thermal_dict + continue assert thermal_name in thermal_dict thermal = thermal_dict[thermal_name] assert rule['temperature'] in thermal.temperature @@ -61,7 +67,7 @@ def test_chassis_thermal(self): gearbox_thermal_rule = rule elif 'CPU Core' in rule['name']: cpu_thermal_rule = rule - + gearbox_thermal_count = 0 cpu_thermal_count = 0 for thermal in thermal_list: @@ -81,10 +87,24 @@ def test_chassis_thermal(self): assert cpu_thermal_rule['high_threshold'].format(start_index) in thermal.high_threshold assert cpu_thermal_rule['high_critical_threshold'].format(start_index) in thermal.high_critical_threshold cpu_thermal_count += 1 - + assert gearbox_thermal_count == 2 assert cpu_thermal_count == 2 + def test_chassis_thermal_includes(self): + from sonic_platform.thermal import THERMAL_NAMING_RULE + DeviceDataManager.get_platform_name = mock.MagicMock(return_value='x86_64-nvidia_sn2201-r0') + DeviceDataManager.get_thermal_capability = mock.MagicMock(return_value={'comex_amb': False, 'cpu_amb': True, 'swb_amb': True}) + chassis = Chassis() + thermal_list = chassis.get_all_thermals() + assert thermal_list + thermal_dict = {thermal.get_name(): thermal for thermal in thermal_list} + for rule in THERMAL_NAMING_RULE['chassis thermals']: + default_present = rule.get('default_present', True) + if not default_present: + thermal_name = rule['name'] + assert thermal_name in thermal_dict + def test_psu_thermal(self): from sonic_platform.thermal import initialize_psu_thermal, THERMAL_NAMING_RULE os.path.exists = mock.MagicMock(return_value=True) @@ -133,7 +153,7 @@ def test_get_temperature(self): utils.read_float_from_file = mock.MagicMock(return_value=0.0) assert thermal.get_temperature() is None - + utils.read_float_from_file = mock.MagicMock(return_value=None) assert thermal.get_temperature() is None @@ -149,7 +169,7 @@ def test_get_high_threshold(self): utils.read_float_from_file = mock.MagicMock(return_value=0.0) assert thermal.get_temperature() is None - + utils.read_float_from_file = mock.MagicMock(return_value=None) assert thermal.get_temperature() is None @@ -165,7 +185,7 @@ def test_get_high_critical_threshold(self): utils.read_float_from_file = mock.MagicMock(return_value=0.0) assert thermal.get_high_critical_threshold() is None - + utils.read_float_from_file = mock.MagicMock(return_value=None) assert thermal.get_high_critical_threshold() is None @@ -179,7 +199,7 @@ def test_set_thermal_algorithm_status(self): for folder in glob.iglob(THERMAL_ZONE_FOLDER_WILDCARD): utils.write_file.assert_any_call(os.path.join(folder, THERMAL_ZONE_POLICY_FILE), 'step_wise') utils.write_file.assert_any_call(os.path.join(folder, THERMAL_ZONE_MODE_FILE), 'enabled') - + assert Thermal.set_thermal_algorithm_status(False, False) for folder in glob.iglob(THERMAL_ZONE_FOLDER_WILDCARD): utils.write_file.assert_any_call(os.path.join(folder, THERMAL_ZONE_POLICY_FILE), 'user_space') @@ -189,27 +209,35 @@ def test_set_thermal_algorithm_status(self): assert Thermal.set_thermal_algorithm_status(False) - def test_check_thermal_zone_temperature(self): - from sonic_platform.thermal import Thermal, THERMAL_ZONE_FOLDER_WILDCARD, THERMAL_ZONE_THRESHOLD_FILE, THERMAL_ZONE_TEMP_FILE - from sonic_platform import utils - glob.iglob = mock.MagicMock(return_value=['thermal_zone1', 'thermal_zone2']) - - utils.read_int_from_file = mock.MagicMock(side_effect=Exception('')) - assert not Thermal.check_thermal_zone_temperature() + @mock.patch('glob.iglob', mock.MagicMock(return_value=['thermal_zone1', 'thermal_zone2'])) + @mock.patch('sonic_platform.utils.read_int_from_file') + def test_get_min_allowed_cooling_level_by_thermal_zone(self, mock_read_file): + from sonic_platform.thermal import Thermal, THERMAL_ZONE_TEMP_FILE, THERMAL_ZONE_HIGH_THRESHOLD, THERMAL_ZONE_NORMAL_THRESHOLD, MIN_COOLING_LEVEL_FOR_HIGH, MIN_COOLING_LEVEL_FOR_NORMAL + mock_read_file.side_effect = Exception('') + assert Thermal.get_min_allowed_cooling_level_by_thermal_zone() is None mock_file_content = {} def mock_read_int_from_file(file_path, default=0, raise_exception=False): return mock_file_content[file_path] - utils.read_int_from_file = mock_read_int_from_file - mock_file_content[os.path.join('thermal_zone1', THERMAL_ZONE_THRESHOLD_FILE)] = 25 - mock_file_content[os.path.join('thermal_zone1', THERMAL_ZONE_TEMP_FILE)] = 30 - mock_file_content[os.path.join('thermal_zone2', THERMAL_ZONE_THRESHOLD_FILE)] = 25 - mock_file_content[os.path.join('thermal_zone2', THERMAL_ZONE_TEMP_FILE)] = 24 - assert not Thermal.check_thermal_zone_temperature() + mock_read_file.side_effect = mock_read_int_from_file + mock_file_content[os.path.join('thermal_zone1', THERMAL_ZONE_NORMAL_THRESHOLD)] = 75000 + mock_file_content[os.path.join('thermal_zone1', THERMAL_ZONE_HIGH_THRESHOLD)] = 85000 + mock_file_content[os.path.join('thermal_zone1', THERMAL_ZONE_TEMP_FILE)] = 69000 + mock_file_content[os.path.join('thermal_zone2', THERMAL_ZONE_NORMAL_THRESHOLD)] = 75000 + mock_file_content[os.path.join('thermal_zone1', THERMAL_ZONE_HIGH_THRESHOLD)] = 85000 + mock_file_content[os.path.join('thermal_zone2', THERMAL_ZONE_TEMP_FILE)] = 24000 + assert Thermal.get_min_allowed_cooling_level_by_thermal_zone() == MIN_COOLING_LEVEL_FOR_NORMAL + + mock_file_content[os.path.join('thermal_zone1', THERMAL_ZONE_TEMP_FILE)] = 71000 + assert Thermal.get_min_allowed_cooling_level_by_thermal_zone() == MIN_COOLING_LEVEL_FOR_HIGH + + mock_file_content[os.path.join('thermal_zone1', THERMAL_ZONE_TEMP_FILE)] = 79000 + assert Thermal.get_min_allowed_cooling_level_by_thermal_zone() == MIN_COOLING_LEVEL_FOR_HIGH + + mock_file_content[os.path.join('thermal_zone1', THERMAL_ZONE_TEMP_FILE)] = 81000 + assert Thermal.get_min_allowed_cooling_level_by_thermal_zone() is None - mock_file_content[os.path.join('thermal_zone1', THERMAL_ZONE_TEMP_FILE)] = 24 - assert Thermal.check_thermal_zone_temperature() def test_check_module_temperature_trustable(self): from sonic_platform.thermal import Thermal @@ -237,3 +265,47 @@ def mock_read_int_from_file(file_path, default=0, raise_exception=False): mock_file_content[os.path.join(CHASSIS_THERMAL_SYSFS_FOLDER, 'fan_amb')] = 50 mock_file_content[os.path.join(CHASSIS_THERMAL_SYSFS_FOLDER, 'port_amb')] = 40 assert Thermal.get_min_amb_temperature() == 40 + + @mock.patch('sonic_platform.utils.write_file') + def test_set_cooling_level(self, mock_write_file): + from sonic_platform.thermal import Thermal, COOLING_STATE_PATH + Thermal.set_cooling_level(10) + calls = [mock.call(COOLING_STATE_PATH, 20, raise_exception=True)] + mock_write_file.assert_has_calls(calls) + + pre_call_count = mock_write_file.call_count + Thermal.set_cooling_level(10) + assert pre_call_count == mock_write_file.call_count + + Thermal.set_cooling_level(9) + calls = [mock.call(COOLING_STATE_PATH, 19, raise_exception=True)] + mock_write_file.assert_has_calls(calls) + + @mock.patch('sonic_platform.utils.write_file') + def test_set_cooling_state(self, mock_write_file): + from sonic_platform.thermal import Thermal, COOLING_STATE_PATH + Thermal.set_cooling_state(10) + calls = [mock.call(COOLING_STATE_PATH, 10, raise_exception=True)] + mock_write_file.assert_has_calls(calls) + + pre_call_count = mock_write_file.call_count + Thermal.set_cooling_state(10) + assert pre_call_count == mock_write_file.call_count + + Thermal.set_cooling_state(9) + calls = [mock.call(COOLING_STATE_PATH, 9, raise_exception=True)] + mock_write_file.assert_has_calls(calls) + + @mock.patch('sonic_platform.utils.read_int_from_file') + def test_get_cooling_level(self, mock_read_file): + from sonic_platform.thermal import Thermal, COOLING_STATE_PATH + Thermal.get_cooling_level() + mock_read_file.assert_called_with(COOLING_STATE_PATH, raise_exception=True) + + mock_read_file.side_effect = IOError('') + with pytest.raises(RuntimeError): + Thermal.get_cooling_level() + + mock_read_file.side_effect = ValueError('') + with pytest.raises(RuntimeError): + Thermal.get_cooling_level() \ No newline at end of file diff --git a/platform/mellanox/mlnx-platform-api/tests/test_thermal_policy.py b/platform/mellanox/mlnx-platform-api/tests/test_thermal_policy.py index 39210a855295..b0ef02c347d7 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_thermal_policy.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_thermal_policy.py @@ -18,7 +18,7 @@ import sys import pytest import json -from mock import MagicMock +from mock import MagicMock, patch from .mock_platform import MockChassis, MockFan, MockFanDrawer, MockPsu test_path = os.path.dirname(os.path.abspath(__file__)) @@ -27,24 +27,10 @@ from sonic_platform.thermal_manager import ThermalManager from sonic_platform.thermal_infos import FanInfo, PsuInfo -from sonic_platform.fan import Fan -from sonic_platform.thermal import Thermal +from sonic_platform.thermal import Thermal, MAX_COOLING_LEVEL from sonic_platform.device_data import DeviceDataManager -@pytest.fixture(scope='module', autouse=True) -def configure_mocks(): - check_thermal_zone_temperature = Thermal.check_thermal_zone_temperature - set_thermal_algorithm_status = Thermal.set_thermal_algorithm_status - Thermal.check_thermal_zone_temperature = MagicMock() - Thermal.set_thermal_algorithm_status = MagicMock() - - yield - - Thermal.check_thermal_zone_temperature = check_thermal_zone_temperature - Thermal.set_thermal_algorithm_status = set_thermal_algorithm_status - - @pytest.fixture(scope='session', autouse=True) def thermal_manager(): policy_file = os.path.join(test_path, 'thermal_policy.json') @@ -113,51 +99,60 @@ def test_psu_info(): assert not psu_info.is_status_changed() -def test_fan_policy(thermal_manager): +@patch('sonic_platform.thermal.Thermal.monitor_asic_themal_zone', MagicMock()) +@patch('sonic_platform.thermal.Thermal.get_cooling_level', MagicMock(return_value=6)) +@patch('sonic_platform.thermal.Thermal.get_min_allowed_cooling_level_by_thermal_zone', MagicMock(return_value=2)) +@patch('sonic_platform.thermal.Thermal.set_cooling_state') +@patch('sonic_platform.thermal.Thermal.set_cooling_level') +def test_fan_policy(mock_set_cooling_level, mock_set_cooling_state, thermal_manager): + print('In test_fan_policy') + from sonic_platform.thermal import MIN_COOLING_LEVEL_FOR_NORMAL chassis = MockChassis() chassis.make_fan_absence() chassis.get_all_fan_drawers()[0].get_all_fans().append(MockFan()) + chassis.platform_name = 'some_platform' thermal_manager.run_policy(chassis) - fan_list = chassis.get_all_fan_drawers()[0].get_all_fans() - assert fan_list[1].speed == 100 - Thermal.set_thermal_algorithm_status.assert_called_with(False, False) + mock_set_cooling_level.assert_called_with(MAX_COOLING_LEVEL) + mock_set_cooling_state.assert_called_with(MAX_COOLING_LEVEL) + Thermal.expect_cooling_level = None + fan_list = chassis.get_all_fan_drawers()[0].get_all_fans() fan_list[0].presence = True - Thermal.check_thermal_zone_temperature = MagicMock(return_value=True) thermal_manager.run_policy(chassis) - Thermal.set_thermal_algorithm_status.assert_called_with(True, False) - assert Thermal.check_thermal_zone_temperature.call_count == 2 - assert fan_list[0].speed == 60 - assert fan_list[1].speed == 60 + mock_set_cooling_level.assert_called_with(6) + mock_set_cooling_state.assert_called_with(6) + Thermal.expect_cooling_level = None fan_list[0].status = False thermal_manager.run_policy(chassis) - Thermal.set_thermal_algorithm_status.assert_called_with(False, False) + mock_set_cooling_level.assert_called_with(MAX_COOLING_LEVEL) + Thermal.expect_cooling_level = None fan_list[0].status = True - Thermal.check_thermal_zone_temperature = MagicMock(return_value=False) thermal_manager.run_policy(chassis) - Thermal.set_thermal_algorithm_status.assert_called_with(True, False) - assert Thermal.check_thermal_zone_temperature.call_count == 2 - assert fan_list[0].speed == 100 - assert fan_list[1].speed == 100 + mock_set_cooling_level.assert_called_with(6) + mock_set_cooling_state.assert_called_with(6) -def test_psu_policy(thermal_manager): +@patch('sonic_platform.thermal.Thermal.monitor_asic_themal_zone', MagicMock()) +@patch('sonic_platform.thermal.Thermal.get_min_allowed_cooling_level_by_thermal_zone', MagicMock(return_value=2)) +@patch('sonic_platform.thermal.Thermal.get_cooling_level', MagicMock(return_value=6)) +@patch('sonic_platform.thermal.Thermal.set_cooling_state') +@patch('sonic_platform.thermal.Thermal.set_cooling_level') +def test_psu_policy(mock_set_cooling_level, mock_set_cooling_state, thermal_manager): chassis = MockChassis() chassis.make_psu_absence() - chassis.fan_list.append(MockFan()) + chassis.platform_name = 'some_platform' thermal_manager.run_policy(chassis) - - fan_list = chassis.get_all_fans() - assert fan_list[0].speed == 100 - Thermal.set_thermal_algorithm_status.assert_called_with(False, False) + mock_set_cooling_level.assert_called_with(MAX_COOLING_LEVEL) + mock_set_cooling_state.assert_called_with(MAX_COOLING_LEVEL) psu_list = chassis.get_all_psus() psu_list[0].presence = True thermal_manager.run_policy(chassis) - Thermal.set_thermal_algorithm_status.assert_called_with(True, False) + mock_set_cooling_level.assert_called_with(6) + mock_set_cooling_state.assert_called_with(6) def test_any_fan_absence_condition(): @@ -328,6 +323,7 @@ def test_load_set_fan_speed_action(): action.load_from_json(json_obj) +@patch('sonic_platform.thermal.Thermal.set_cooling_level', MagicMock()) def test_execute_set_fan_speed_action(): chassis = MockChassis() chassis.get_all_fan_drawers().append(MockFanDrawer()) @@ -337,84 +333,13 @@ def test_execute_set_fan_speed_action(): fan_info = FanInfo() fan_info.collect(chassis) + Thermal.expect_cooling_level = None from sonic_platform.thermal_actions import SetAllFanSpeedAction action = SetAllFanSpeedAction() - action.speed = 99 - action.execute({'fan_info': fan_info}) - assert fan_list[0].speed == 99 - assert fan_list[1].speed == 99 - - -def test_load_control_thermal_algo_action(): - from sonic_platform.thermal_actions import ControlThermalAlgoAction - action = ControlThermalAlgoAction() - json_str = '{\"status\": \"false\"}' - json_obj = json.loads(json_str) - action.load_from_json(json_obj) - assert not action.status - - json_str = '{\"status\": \"true\"}' - json_obj = json.loads(json_str) - action.load_from_json(json_obj) - assert action.status - - json_str = '{\"status\": \"invalid\"}' - json_obj = json.loads(json_str) - with pytest.raises(ValueError): - action.load_from_json(json_obj) - - json_str = '{\"invalid\": \"true\"}' - json_obj = json.loads(json_str) - with pytest.raises(ValueError): - action.load_from_json(json_obj) - -def test_load_check_and_set_speed_action(): - from sonic_platform.thermal_actions import CheckAndSetAllFanSpeedAction - action = CheckAndSetAllFanSpeedAction() - json_str = '{\"speed\": \"40\"}' - json_obj = json.loads(json_str) - action.load_from_json(json_obj) - assert action.speed == 40 - - json_str = '{\"speed\": \"-1\"}' - json_obj = json.loads(json_str) - with pytest.raises(ValueError): - action.load_from_json(json_obj) - - json_str = '{\"speed\": \"101\"}' - json_obj = json.loads(json_str) - with pytest.raises(ValueError): - action.load_from_json(json_obj) - - json_str = '{\"invalid\": \"60\"}' - json_obj = json.loads(json_str) - with pytest.raises(ValueError): - action.load_from_json(json_obj) - -def test_execute_check_and_set_fan_speed_action(): - chassis = MockChassis() - chassis.get_all_fan_drawers().append(MockFanDrawer()) - fan_list = chassis.get_all_fan_drawers()[0].get_all_fans() - fan_list.append(MockFan()) - fan_list.append(MockFan()) - fan_info = FanInfo() - fan_info.collect(chassis) - Thermal.check_thermal_zone_temperature = MagicMock(return_value=True) - - from sonic_platform.thermal_actions import CheckAndSetAllFanSpeedAction - action = CheckAndSetAllFanSpeedAction() - action.speed = 99 + action.speed = 20 action.execute({'fan_info': fan_info}) - assert fan_list[0].speed == 99 - assert fan_list[1].speed == 99 + assert Thermal.expect_cooling_level == 2 - Thermal.check_thermal_zone_temperature = MagicMock(return_value=False) - fan_list[0].speed = 100 - fan_list[1].speed = 100 - action.speed = 60 - action.execute({'fan_info': fan_info}) - assert fan_list[0].speed == 100 - assert fan_list[1].speed == 100 def test_load_duplicate_condition(): from sonic_platform_base.sonic_thermal_control.thermal_policy import ThermalPolicy @@ -497,54 +422,89 @@ def check_minimum_table_data(platform, minimum_table): assert cooling_level > previous_cooling_level previous_cooling_level = cooling_level -def test_dynamic_minimum_policy(thermal_manager): - from sonic_platform.thermal_conditions import MinCoolingLevelChangeCondition - from sonic_platform.thermal_actions import ChangeMinCoolingLevelAction - from sonic_platform.thermal_infos import ChassisInfo, FanInfo - from sonic_platform.thermal import Thermal - from sonic_platform.fan import Fan - ThermalManager.initialize() - assert 'DynamicMinCoolingLevelPolicy' in thermal_manager._policy_dict - policy = thermal_manager._policy_dict['DynamicMinCoolingLevelPolicy'] - assert MinCoolingLevelChangeCondition in policy.conditions - assert ChangeMinCoolingLevelAction in policy.actions - - condition = policy.conditions[MinCoolingLevelChangeCondition] - action = policy.actions[ChangeMinCoolingLevelAction] - Thermal.check_module_temperature_trustable = MagicMock(return_value='trust') - Thermal.get_min_amb_temperature = MagicMock(return_value=35001) - assert condition.is_match(None) - assert MinCoolingLevelChangeCondition.trust_state == 'trust' - assert MinCoolingLevelChangeCondition.temperature == 35 - assert not condition.is_match(None) - - Thermal.check_module_temperature_trustable = MagicMock(return_value='untrust') - assert condition.is_match(None) - assert MinCoolingLevelChangeCondition.trust_state == 'untrust' - - Thermal.get_min_amb_temperature = MagicMock(return_value=25999) - assert condition.is_match(None) - assert MinCoolingLevelChangeCondition.temperature == 25 - +@patch('sonic_platform.thermal.Thermal.monitor_asic_themal_zone', MagicMock()) +@patch('sonic_platform.device_data.DeviceDataManager.get_platform_name') +@patch('sonic_platform.thermal.Thermal.get_min_allowed_cooling_level_by_thermal_zone') +@patch('sonic_platform.thermal.Thermal.get_min_amb_temperature') +@patch('sonic_platform.thermal.Thermal.check_module_temperature_trustable') +def test_thermal_recover_policy(mock_check_trustable, mock_get_min_amb, moc_get_min_allowed, mock_platform_name): + from sonic_platform.thermal_infos import ChassisInfo + from sonic_platform.thermal_actions import ThermalRecoverAction chassis = MockChassis() + mock_platform_name.return_value = 'invalid' info = ChassisInfo() info._chassis = chassis - fan_info = FanInfo() + thermal_info_dict = {ChassisInfo.INFO_NAME: info} - thermal_info_dict = { - ChassisInfo.INFO_NAME: info, - FanInfo.INFO_NAME: fan_info - } - DeviceDataManager.get_platform_name = MagicMock(return_value=None) - Fan.get_cooling_level = MagicMock(return_value=5) - Fan.set_cooling_level = MagicMock() + Thermal.expect_cooling_level = None + action = ThermalRecoverAction() + moc_get_min_allowed.return_value = 2 + action.execute(thermal_info_dict) + assert Thermal.expect_cooling_level == 6 + Thermal.last_set_cooling_level = Thermal.expect_cooling_level + + Thermal.expect_cooling_level = None + mock_platform_name.return_value = 'x86_64-mlnx_msn2700-r0' + mock_check_trustable.return_value = 'trust' + mock_get_min_amb.return_value = 29999 + moc_get_min_allowed.return_value = None action.execute(thermal_info_dict) - assert Fan.min_cooling_level == 6 - Fan.set_cooling_level.assert_called_with(6, 6) - Fan.set_cooling_level.call_count = 0 + assert Thermal.expect_cooling_level is None - DeviceDataManager.get_platform_name = MagicMock(return_value='x86_64-mlnx_msn2700-r0') - print('Before execute') + moc_get_min_allowed.return_value = 4 action.execute(thermal_info_dict) - assert Fan.min_cooling_level == 3 - Fan.set_cooling_level.assert_called_with(3, 5) + assert Thermal.expect_cooling_level == 4 + Thermal.last_set_cooling_level = Thermal.expect_cooling_level + + mock_check_trustable.return_value = 'untrust' + mock_get_min_amb.return_value = 31001 + action.execute(thermal_info_dict) + assert Thermal.expect_cooling_level == 5 + + +@patch('sonic_platform.thermal.Thermal.set_cooling_state') +@patch('sonic_platform.utils.read_int_from_file') +def test_monitor_asic_themal_zone(mock_read_int, mock_set_cooling_state): + mock_read_int.side_effect = [111000, 105000] + Thermal.monitor_asic_themal_zone() + assert Thermal.expect_cooling_state == MAX_COOLING_LEVEL + Thermal.commit_cooling_level({}) + mock_set_cooling_state.assert_called_with(MAX_COOLING_LEVEL) + mock_read_int.reset() + mock_read_int.side_effect = [104000, 105000] + Thermal.monitor_asic_themal_zone() + assert Thermal.expect_cooling_state is None + + +def test_set_expect_cooling_level(): + Thermal.set_expect_cooling_level(5) + assert Thermal.expect_cooling_level == 5 + + Thermal.set_expect_cooling_level(3) + assert Thermal.expect_cooling_level == 5 + + Thermal.set_expect_cooling_level(10) + assert Thermal.expect_cooling_level == 10 + + +@patch('sonic_platform.thermal.Thermal.commit_cooling_level', MagicMock()) +@patch('sonic_platform.thermal_conditions.AnyFanFaultCondition.is_match') +@patch('sonic_platform.thermal_manager.ThermalManager._collect_thermal_information') +@patch('sonic_platform.thermal.Thermal.set_expect_cooling_level') +def test_run_policy(mock_expect, mock_collect_info, mock_match, thermal_manager): + chassis = MockChassis() + mock_collect_info.side_effect = Exception('') + thermal_manager.run_policy(chassis) + mock_expect.assert_called_with(MAX_COOLING_LEVEL) + + mock_collect_info.side_effect = None + mock_expect.reset_mock() + mock_match.side_effect = Exception('') + thermal_manager.run_policy(chassis) + mock_expect.assert_called_with(MAX_COOLING_LEVEL) + + thermal_manager.stop() + mock_expect.reset_mock() + thermal_manager.run_policy(chassis) + assert mock_expect.call_count == 0 + diff --git a/platform/mellanox/mlnx-platform-api/tests/thermal_policy.json b/platform/mellanox/mlnx-platform-api/tests/thermal_policy.json index 413211b21220..5155c0718522 100644 --- a/platform/mellanox/mlnx-platform-api/tests/thermal_policy.json +++ b/platform/mellanox/mlnx-platform-api/tests/thermal_policy.json @@ -23,10 +23,6 @@ } ], "actions": [ - { - "type": "thermal_control.control", - "status": "false" - }, { "type": "fan.all.set_speed", "speed": "100" @@ -41,10 +37,6 @@ } ], "actions": [ - { - "type": "thermal_control.control", - "status": "false" - }, { "type": "fan.all.set_speed", "speed": "100" @@ -59,10 +51,6 @@ } ], "actions": [ - { - "type": "thermal_control.control", - "status": "false" - }, { "type": "fan.all.set_speed", "speed": "100" @@ -84,12 +72,8 @@ ], "actions": [ { - "type": "thermal_control.control", + "type": "thermal.recover", "status": "true" - }, - { - "type": "fan.all.check_and_set_speed", - "speed": "60" } ] } diff --git a/platform/mellanox/mlnx-ssd-fw-update.sh b/platform/mellanox/mlnx-ssd-fw-update.sh index e453aa24ebb5..7a180bde7bc7 100755 --- a/platform/mellanox/mlnx-ssd-fw-update.sh +++ b/platform/mellanox/mlnx-ssd-fw-update.sh @@ -48,6 +48,7 @@ ARG_IMAGE_VAL="" ARG_QUERY_FLAG=$FALSE ARG_YES_FLAG=$FALSE ARG_POWER_CYCLE_FLAG=$FALSE +ARG_FORCE_POWER_CYCLE_FLAG=$FALSE ARG_HELP_FLAG=$FALSE ARG_VERSION_FLAG=$FALSE ARG_PACKAGE_INFO_FLAG=$FALSE @@ -178,6 +179,10 @@ function check_usage() { ARG_POWER_CYCLE_FLAG=$TRUE shift # past argument ;; + --no-power-cycle) + ARG_FORCE_NO_POWER_CYCLE_FLAG=$TRUE + shift # past argument + ;; *) LOG_MSG "Error: false usage given." usage @@ -197,6 +202,7 @@ function check_usage() { ("$ARG_UPDATE_FLAG" == "$TRUE" && "$ARG_IMAGE_FLAG" == "$FALSE") || ("$ARG_PACKAGE_INFO_FLAG" == "$TRUE" && "$ARG_IMAGE_FLAG" == "$FALSE") || ("$ARG_POWER_CYCLE_FLAG" == "$TRUE" && "$ARG_UPDATE_FLAG" == "$FALSE") || + ("$ARG_FORCE_NO_POWER_CYCLE_FLAG" == "$TRUE" && "$ARG_POWER_CYCLE_FLAG" == "$TRUE") || ("$ARG_UPDATE_FLAG" == "$TRUE" && "$ARG_PACKAGE_INFO_FLAG" == "$TRUE") ]]; then LOG_MSG "Error: false usage given." @@ -213,6 +219,7 @@ function check_usage() { LOG_MSG "ARG_VERSION_FLAG = ${ARG_VERSION_FLAG}" ${DEBUG_MSG} LOG_MSG "ARG_PACKAGE_INFO_FLAG = ${ARG_PACKAGE_INFO_FLAG}" ${DEBUG_MSG} LOG_MSG "ARG_POWER_CYCLE_FLAG = ${ARG_POWER_CYCLE_FLAG}" ${DEBUG_MSG} + LOG_MSG "ARG_FORCE_NO_POWER_CYCLE_FLAG = ${ARG_FORCE_NO_POWER_CYCLE_FLAG}" ${DEBUG_MSG} } @@ -280,12 +287,12 @@ function get_ssd_info() { #= function check_tool_dependencies() { LOG_MSG "func: ${FUNCNAME[0]}()" ${DEBUG_MSG} - for i in "${!DEPENDECIES[@]}" - do - if [ ! -x "$(command -v ${DEPENDECIES[$i]})" ]; then - LOG_MSG_AND_EXIT "Error: This tool require the following utils to be installed ${DEPENDECIES[$i]}" - fi - done + for i in "${!DEPENDECIES[@]}" + do + if [ ! -x "$(command -v ${DEPENDECIES[$i]})" ]; then + LOG_MSG_AND_EXIT "Error: This tool require the following utils to be installed ${DEPENDECIES[$i]}" + fi + done } #==============================================================================# @@ -673,7 +680,12 @@ elif [ $ARG_UPDATE_FLAG == $TRUE ]; then if [ ! -f $ssd_script_path ]; then LOG_MSG_AND_EXIT "Error: fail to call upgrade script ($ssd_script_path)!" fi - ( + ( + if [[ "yes" == "$power_policy" && $ARG_FORCE_NO_POWER_CYCLE_FLAG == $TRUE ]]; then + # If a power cycle is required and we are not power cycling automatically lock the file system for safety + LOG_MSG "Immediate power cycle is required but override flag has been given. Locking file system as read only to protect system integrity." + echo u > /proc/sysrq-trigger + fi cd "${extraction_path}/${section}" > /dev/null 2>&1 || exit /bin/bash "$ssd_script_path" "${extraction_path}/${section}" #cd - > /dev/null 2>&1 || exit @@ -684,6 +696,11 @@ elif [ $ARG_UPDATE_FLAG == $TRUE ]; then LOG_MSG "SSD FW update completed successfully." if [[ "yes" == "$power_policy" || $ARG_POWER_CYCLE_FLAG == $TRUE ]]; then + + if [[ $ARG_FORCE_NO_POWER_CYCLE_FLAG == $TRUE ]]; then + LOG_MSG_AND_EXIT "An IMMEDIATE power cycle is REQUIRED to upgrade the SSD. Please perform a cold reboot as soon as possible." + fi + LOG_MSG "Execute power cycle..." sleep 1 sync diff --git a/platform/mellanox/rules.dep b/platform/mellanox/rules.dep index 409857592159..5dce51d83bb5 100644 --- a/platform/mellanox/rules.dep +++ b/platform/mellanox/rules.dep @@ -15,3 +15,4 @@ include $(PLATFORM_PATH)/mlnx-ffb.dep include $(PLATFORM_PATH)/issu-version.dep include $(PLATFORM_PATH)/mlnx-onie-fw-update.dep include $(PLATFORM_PATH)/mlnx-ssd-fw-update.dep +include $(PLATFORM_PATH)/install-pending-fw.dep diff --git a/platform/mellanox/rules.mk b/platform/mellanox/rules.mk index be046bed91eb..7048920f6c5f 100644 --- a/platform/mellanox/rules.mk +++ b/platform/mellanox/rules.mk @@ -29,6 +29,7 @@ include $(PLATFORM_PATH)/mlnx-ffb.mk include $(PLATFORM_PATH)/issu-version.mk include $(PLATFORM_PATH)/mlnx-onie-fw-update.mk include $(PLATFORM_PATH)/mlnx-ssd-fw-update.mk +include $(PLATFORM_PATH)/install-pending-fw.mk SONIC_ALL += $(SONIC_ONE_IMAGE) \ $(DOCKER_FPM) diff --git a/platform/mellanox/sdk-src/sxd-libs/Makefile b/platform/mellanox/sdk-src/sxd-libs/Makefile index 0b142c920828..892974e75e5f 100644 --- a/platform/mellanox/sdk-src/sxd-libs/Makefile +++ b/platform/mellanox/sdk-src/sxd-libs/Makefile @@ -20,7 +20,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : ./autogen.sh fi - debuild -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + debuild -e 'configure_options=--enable-sniffer=yes' -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) popd diff --git a/platform/pddf/i2c/Makefile b/platform/pddf/i2c/Makefile index 1486370b5005..092c11539723 100644 --- a/platform/pddf/i2c/Makefile +++ b/platform/pddf/i2c/Makefile @@ -1 +1 @@ -subdir-m := modules +obj-m := modules/ diff --git a/platform/pddf/i2c/debian/rules b/platform/pddf/i2c/debian/rules index 45a58fb9b570..edca93ee06a8 100755 --- a/platform/pddf/i2c/debian/rules +++ b/platform/pddf/i2c/debian/rules @@ -18,7 +18,7 @@ PACKAGE_PRE_NAME := sonic-platform-pddf KVERSION ?= $(shell uname -r) KERNEL_SRC := /lib/modules/$(KVERSION) MOD_SRC_DIR:= $(shell pwd) -MODULE_DIRS:= client cpld cpld/driver cpldmux cpldmux/driver fan fan/driver fan/vendor_api mux gpio led psu psu/driver sysstatus xcvr xcvr/driver +MODULE_DIRS:= client cpld cpld/driver cpldmux cpldmux/driver fan fan/driver mux gpio led psu psu/driver sysstatus xcvr xcvr/driver MODULE_DIR:= modules UTILS_DIR := utils SERVICE_DIR := service @@ -35,8 +35,10 @@ clean: make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR) clean build: + set -e; \ make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR); \ $(PYTHON) $(MOD_SRC_DIR)/setup.py build; \ + set +e binary: binary-arch binary-indep # Nothing to do @@ -50,11 +52,15 @@ binary-indep: dh_installdirs -p$(PACKAGE_PRE_NAME) $(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ dh_installdirs -p$(PACKAGE_PRE_NAME) usr/local/bin; \ # Custom package commands + set -e; \ (for mod in $(MODULE_DIRS); do \ cp $(MOD_SRC_DIR)/$(MODULE_DIR)/$${mod}/*.ko debian/$(PACKAGE_PRE_NAME)/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ done) ; \ + # Need to take a backup of symvers file for compilation of custom modules in various platforms + cp $(MOD_SRC_DIR)/Module.symvers $(MOD_SRC_DIR)/Module.symvers.PDDF; \ cp -r $(MOD_SRC_DIR)/$(UTILS_DIR)/* debian/$(PACKAGE_PRE_NAME)/usr/local/bin/; \ - $(PYTHON) $(MOD_SRC_DIR)/setup.py install --root=$(MOD_SRC_DIR)/debian/$(PACKAGE_PRE_NAME) --install-layout=deb; + $(PYTHON) $(MOD_SRC_DIR)/setup.py install --root=$(MOD_SRC_DIR)/debian/$(PACKAGE_PRE_NAME) --install-layout=deb; \ + set +e # Resuming debhelper scripts dh_testroot diff --git a/platform/pddf/i2c/modules/Makefile b/platform/pddf/i2c/modules/Makefile index 67d3726c3202..ebfce193c273 100644 --- a/platform/pddf/i2c/modules/Makefile +++ b/platform/pddf/i2c/modules/Makefile @@ -1 +1 @@ -subdir-m := client cpld cpldmux xcvr mux gpio psu fan led sysstatus +obj-m := client/ cpld/ cpldmux/ xcvr/ mux/ gpio/ psu/ fan/ led/ sysstatus/ diff --git a/platform/pddf/i2c/modules/cpld/Makefile b/platform/pddf/i2c/modules/cpld/Makefile index c6182ef4f93d..2ed1697c8e24 100644 --- a/platform/pddf/i2c/modules/cpld/Makefile +++ b/platform/pddf/i2c/modules/cpld/Makefile @@ -1,4 +1,4 @@ -subdir-m := driver -obj-m := pddf_cpld_module.o +obj-m := driver/ +obj-m += pddf_cpld_module.o -CFLAGS_$(obj-m):= -I$(M)/modules/include +ccflags-y:= -I$(M)/modules/include diff --git a/platform/pddf/i2c/modules/cpld/driver/pddf_cpld_driver.c b/platform/pddf/i2c/modules/cpld/driver/pddf_cpld_driver.c index a34c370b9af1..dabc8f9d8f9c 100755 --- a/platform/pddf/i2c/modules/cpld/driver/pddf_cpld_driver.c +++ b/platform/pddf/i2c/modules/cpld/driver/pddf_cpld_driver.c @@ -30,9 +30,58 @@ static struct mutex list_lock; struct cpld_client_node { struct i2c_client *client; + char name[CPLD_CLIENT_NAME_LEN]; struct list_head list; }; +int board_i2c_cpld_read_new(unsigned short cpld_addr, char *name, u8 reg) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EPERM; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if ((cpld_node->client->addr == cpld_addr) && (strncmp(cpld_node->name, name, strlen(name)) == 0)) { + ret = i2c_smbus_read_byte_data(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(board_i2c_cpld_read_new); + +int board_i2c_cpld_write_new(unsigned short cpld_addr, char *name, u8 reg, u8 value) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int ret = -EIO; + + mutex_lock(&list_lock); + + list_for_each(list_node, &cpld_client_list) + { + cpld_node = list_entry(list_node, struct cpld_client_node, list); + + if ((cpld_node->client->addr == cpld_addr) && (strncmp(cpld_node->name, name, strlen(name)) == 0)){ + ret = i2c_smbus_write_byte_data(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(board_i2c_cpld_write_new); + int board_i2c_cpld_read(unsigned short cpld_addr, u8 reg) { struct list_head *list_node = NULL; @@ -128,7 +177,9 @@ static void board_i2c_cpld_add_client(struct i2c_client *client) } node->client = client; - + strcpy(node->name, (char *)client->dev.platform_data); + dev_dbg(&client->dev, "Adding %s to the cpld client list\n", node->name); + mutex_lock(&list_lock); list_add(&node->list, &cpld_client_list); mutex_unlock(&list_lock); @@ -188,8 +239,14 @@ static int board_i2c_cpld_probe(struct i2c_client *client, static int board_i2c_cpld_remove(struct i2c_client *client) { - sysfs_remove_group(&client->dev.kobj, &cpld_attribute_group); + /* Platform data is just a char string */ + char *platdata = (char *)client->dev.platform_data; + sysfs_remove_group(&client->dev.kobj, &cpld_attribute_group); board_i2c_cpld_remove_client(client); + if (platdata) + { + kfree(platdata); + } return 0; } diff --git a/platform/pddf/i2c/modules/cpld/pddf_cpld_module.c b/platform/pddf/i2c/modules/cpld/pddf_cpld_module.c index 156ab9644c6c..4a933069e6d8 100644 --- a/platform/pddf/i2c/modules/cpld/pddf_cpld_module.c +++ b/platform/pddf/i2c/modules/cpld/pddf_cpld_module.c @@ -37,7 +37,7 @@ EXPORT_SYMBOL(pddf_cpld_data); static ssize_t do_device_operation(struct device *dev, struct device_attribute *da, const char *buf, size_t count); static ssize_t store_pddf_cpld_data(struct device *dev, struct device_attribute *da, const char *buf, size_t count); -ssize_t show_pddf_cpld_data(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_pddf_cpld_data(struct device *dev, struct device_attribute *da, char *buf); extern void *get_device_table(char *name); extern void delete_device_table(char *name); @@ -77,9 +77,8 @@ static ssize_t store_pddf_cpld_data(struct device *dev, struct device_attribute return count; } -EXPORT_SYMBOL(store_pddf_cpld_data); -ssize_t show_pddf_cpld_data(struct device *dev, struct device_attribute *da, char *buf) +static ssize_t show_pddf_cpld_data(struct device *dev, struct device_attribute *da, char *buf) { int ret = 0; PDDF_ATTR *ptr = (PDDF_ATTR *)da; @@ -91,7 +90,6 @@ ssize_t show_pddf_cpld_data(struct device *dev, struct device_attribute *da, cha return ret; } -EXPORT_SYMBOL(show_pddf_cpld_data); static ssize_t do_device_operation(struct device *dev, struct device_attribute *da, const char *buf, size_t count) { @@ -100,6 +98,7 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute * struct i2c_adapter *adapter; static struct i2c_board_info board_info; struct i2c_client *client_ptr; + char *pddf_cpld_name = NULL; if (strncmp(buf, "add", strlen(buf)-1)==0) { @@ -107,17 +106,19 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute * if (strncmp(device_ptr->dev_type, "i2c_cpld", strlen("i2c_cpld"))==0) { + pddf_cpld_name = (char *)kzalloc(CPLD_CLIENT_NAME_LEN, GFP_KERNEL); + if (pddf_cpld_name != NULL) strcpy(pddf_cpld_name, device_ptr->i2c_name); + board_info = (struct i2c_board_info) { - .platform_data = (void *)NULL, + .platform_data = (void *)pddf_cpld_name, }; board_info.addr = device_ptr->dev_addr; strcpy(board_info.type, device_ptr->dev_type); - /*pddf_dbg(KERN_ERR "Creating a client %s on 0x%x, platform_data 0x%x\n", board_info.type, board_info.addr, board_info.platform_data);*/ client_ptr = i2c_new_client_device(adapter, &board_info); - if (client_ptr != NULL) { + if (!IS_ERR(client_ptr)) { i2c_put_adapter(adapter); pddf_dbg(CPLD, KERN_ERR "Created %s client: 0x%p\n", device_ptr->i2c_name, (void *)client_ptr); add_device_table(device_ptr->i2c_name, (void*)client_ptr); @@ -152,8 +153,12 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute * { printk(KERN_ERR "PDDF_ERROR: %s: Invalid value for dev_ops %s", __FUNCTION__, buf); } + goto clear_data; free_data: + if (board_info.platform_data) + kfree(board_info.platform_data); +clear_data: /*TODO: free the device_ptr->data is dynamically allocated*/ memset(device_ptr, 0 , sizeof(NEW_DEV_ATTR)); diff --git a/platform/pddf/i2c/modules/cpldmux/Makefile b/platform/pddf/i2c/modules/cpldmux/Makefile index 53816b98f750..518f225fdd3a 100644 --- a/platform/pddf/i2c/modules/cpldmux/Makefile +++ b/platform/pddf/i2c/modules/cpldmux/Makefile @@ -1,4 +1,4 @@ -subdir-m := driver -obj-m := pddf_cpldmux_module.o +obj-m := driver/ +obj-m += pddf_cpldmux_module.o -CFLAGS_$(obj-m):= -I$(M)/modules/include +ccflags-y:= -I$(M)/modules/include diff --git a/platform/pddf/i2c/modules/cpldmux/driver/pddf_cpldmux_driver.c b/platform/pddf/i2c/modules/cpldmux/driver/pddf_cpldmux_driver.c index c9df1a60c1af..2c914b92b1b0 100755 --- a/platform/pddf/i2c/modules/cpldmux/driver/pddf_cpldmux_driver.c +++ b/platform/pddf/i2c/modules/cpldmux/driver/pddf_cpldmux_driver.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include "pddf_client_defs.h" diff --git a/platform/pddf/i2c/modules/fan/Makefile b/platform/pddf/i2c/modules/fan/Makefile index 94b6b146c51d..acd0bf5f411b 100644 --- a/platform/pddf/i2c/modules/fan/Makefile +++ b/platform/pddf/i2c/modules/fan/Makefile @@ -1,4 +1,4 @@ -subdir-m := driver -obj-m := pddf_fan_module.o +obj-m := driver/ +obj-m += pddf_fan_module.o -CFLAGS_$(obj-m):= -I$(M)/modules/include +ccflags-y:= -I$(M)/modules/include diff --git a/platform/pddf/i2c/modules/fan/driver/pddf_fan_api.c b/platform/pddf/i2c/modules/fan/driver/pddf_fan_api.c index 167b0e183315..0fecee963ed2 100644 --- a/platform/pddf/i2c/modules/fan/driver/pddf_fan_api.c +++ b/platform/pddf/i2c/modules/fan/driver/pddf_fan_api.c @@ -64,20 +64,20 @@ int fan_update_hw(struct device *dev, struct fan_attr_info *info, FAN_DATA_ATTR { status = (sysfs_attr_data->pre_set)(client, udata, info); if (status!=0) - printk(KERN_ERR "%s: pre_set function fails for %s attribute\n", __FUNCTION__, udata->aname); + dev_warn(&client->dev, "%s: pre_set function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status); } if (sysfs_attr_data->do_set != NULL) { status = (sysfs_attr_data->do_set)(client, udata, info); if (status!=0) - printk(KERN_ERR "%s: do_set function fails for %s attribute\n", __FUNCTION__, udata->aname); + dev_warn(&client->dev, "%s: do_set function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status); } if (sysfs_attr_data->post_set != NULL) { status = (sysfs_attr_data->post_set)(client, udata, info); if (status!=0) - printk(KERN_ERR "%s: post_set function fails for %s attribute\n", __FUNCTION__, udata->aname); + dev_warn(&client->dev, "%s: post_set function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status); } mutex_unlock(&info->update_lock); @@ -104,20 +104,20 @@ int fan_update_attr(struct device *dev, struct fan_attr_info *info, FAN_DATA_ATT { status = (sysfs_attr_data->pre_get)(client, udata, info); if (status!=0) - printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, udata->aname); + dev_warn(&client->dev, "%s: pre_get function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status); } if (sysfs_attr_data->do_get != NULL) { status = (sysfs_attr_data->do_get)(client, udata, info); if (status!=0) - printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, udata->aname); + dev_warn(&client->dev, "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status); } if (sysfs_attr_data->post_get != NULL) { status = (sysfs_attr_data->post_get)(client, udata, info); if (status!=0) - printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, udata->aname); + dev_warn(&client->dev, "%s: post_get function fails for %s attribute.ret %d\n", __FUNCTION__, udata->aname, status); } @@ -346,7 +346,10 @@ int sonic_i2c_get_fan_present_default(void *client, FAN_DATA_ATTR *udata, void * val = i2c_smbus_read_byte_data((struct i2c_client *)client, udata->offset); } - painfo->val.intval = ((val & udata->mask) == udata->cmpval); + if (val < 0) + status = val; + else + painfo->val.intval = ((val & udata->mask) == udata->cmpval); return status; @@ -355,7 +358,7 @@ int sonic_i2c_get_fan_present_default(void *client, FAN_DATA_ATTR *udata, void * int sonic_i2c_get_fan_rpm_default(void *client, FAN_DATA_ATTR *udata, void *info) { int status = 0; - uint32_t val = 0; + int val = 0; struct fan_attr_info *painfo = (struct fan_attr_info *)info; if (strcmp(udata->devtype, "cpld") == 0) @@ -375,10 +378,15 @@ int sonic_i2c_get_fan_rpm_default(void *client, FAN_DATA_ATTR *udata, void *info } } - if (udata->is_divisor) - painfo->val.intval = udata->mult / (val >> 3); + if (val < 0) + status = val; else - painfo->val.intval = udata->mult * val; + { + if (udata->is_divisor) + painfo->val.intval = udata->mult / (val >> 3); + else + painfo->val.intval = udata->mult * val; + } return status; } @@ -471,7 +479,7 @@ int sonic_i2c_set_fan_pwm_default(struct i2c_client *client, FAN_DATA_ATTR *udat int sonic_i2c_get_fan_pwm_default(void *client, FAN_DATA_ATTR *udata, void *info) { int status = 0; - uint32_t val = 0; + int val = 0; struct fan_attr_info *painfo = (struct fan_attr_info *)info; if (strcmp(udata->devtype, "cpld") == 0) @@ -491,15 +499,20 @@ int sonic_i2c_get_fan_pwm_default(void *client, FAN_DATA_ATTR *udata, void *info } } - val = val & udata->mask; - painfo->val.intval = val; + if (val < 0) + status = val; + else + { + val = val & udata->mask; + painfo->val.intval = val; + } return status; } int sonic_i2c_get_fan_fault_default(void *client, FAN_DATA_ATTR *udata, void *info) { int status = 0; - uint32_t val = 0; + int val = 0; struct fan_attr_info *painfo = (struct fan_attr_info *)info; /*Assuming fan fault to be denoted by 1 byte only*/ @@ -512,8 +525,10 @@ int sonic_i2c_get_fan_fault_default(void *client, FAN_DATA_ATTR *udata, void *in val = i2c_smbus_read_byte_data((struct i2c_client *)client, udata->offset); } - val = val & udata->mask; - painfo->val.intval = val; + if (val < 0) + status = val; + else + painfo->val.intval = ((val & udata->mask) == udata->cmpval); return status; } diff --git a/platform/pddf/i2c/modules/fan/driver/pddf_fan_driver.c b/platform/pddf/i2c/modules/fan/driver/pddf_fan_driver.c index da8275fccd64..45105f8707a9 100644 --- a/platform/pddf/i2c/modules/fan/driver/pddf_fan_driver.c +++ b/platform/pddf/i2c/modules/fan/driver/pddf_fan_driver.c @@ -357,7 +357,7 @@ static int pddf_fan_probe(struct i2c_client *client, goto exit_free; } - data->hwmon_dev = hwmon_device_register(&client->dev); + data->hwmon_dev = hwmon_device_register_with_info(&client->dev, client->name, NULL, NULL, NULL); if (IS_ERR(data->hwmon_dev)) { status = PTR_ERR(data->hwmon_dev); goto exit_remove; diff --git a/platform/pddf/i2c/modules/fan/pddf_fan_module.c b/platform/pddf/i2c/modules/fan/pddf_fan_module.c index b910d6b4a351..1c31fb920c04 100644 --- a/platform/pddf/i2c/modules/fan/pddf_fan_module.c +++ b/platform/pddf/i2c/modules/fan/pddf_fan_module.c @@ -159,9 +159,9 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute * board_info = i2c_get_fan_board_info(fdata, cdata); /* Populate the platform data for fan */ - client_ptr = i2c_new_device(adapter, board_info); + client_ptr = i2c_new_client_device(adapter, board_info); - if(client_ptr != NULL) + if(!IS_ERR(client_ptr)) { i2c_put_adapter(adapter); pddf_dbg(FAN, KERN_ERR "Created a %s client: 0x%p\n", cdata->i2c_name, (void *)client_ptr); diff --git a/platform/pddf/i2c/modules/gpio/Makefile b/platform/pddf/i2c/modules/gpio/Makefile index 6d48c5884731..c5e69ac7c1ff 100644 --- a/platform/pddf/i2c/modules/gpio/Makefile +++ b/platform/pddf/i2c/modules/gpio/Makefile @@ -1,4 +1,4 @@ obj-m := pddf_gpio_module.o -CFLAGS_$(obj-m):= -I$(M)/modules/include +ccflags-y := -I$(M)/modules/include diff --git a/platform/pddf/i2c/modules/gpio/pddf_gpio_module.c b/platform/pddf/i2c/modules/gpio/pddf_gpio_module.c index afd37c3927df..30eec5f185f4 100644 --- a/platform/pddf/i2c/modules/gpio/pddf_gpio_module.c +++ b/platform/pddf/i2c/modules/gpio/pddf_gpio_module.c @@ -119,10 +119,10 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute * board_info = i2c_get_gpio_board_info(gpio_ptr, device_ptr); /*pddf_dbg(KERN_ERR "Creating a client %s on 0x%x, platform_data 0x%x\n", board_info->type, board_info->addr, board_info->platform_data);*/ - client_ptr = i2c_new_device(adapter, board_info); + client_ptr = i2c_new_client_device(adapter, board_info); i2c_put_adapter(adapter); - if (client_ptr != NULL) + if (!IS_ERR(client_ptr)) { pddf_dbg(GPIO, KERN_ERR "Created %s client: 0x%p\n", device_ptr->i2c_name, (void *)client_ptr); add_device_table(device_ptr->i2c_name, (void*)client_ptr); diff --git a/platform/pddf/i2c/modules/include/pddf_cpld_defs.h b/platform/pddf/i2c/modules/include/pddf_cpld_defs.h index c312f3277f75..23b8505e666a 100644 --- a/platform/pddf/i2c/modules/include/pddf_cpld_defs.h +++ b/platform/pddf/i2c/modules/include/pddf_cpld_defs.h @@ -20,6 +20,7 @@ #ifndef __PDDF_CPLD_DEFS_H__ #define __PDDF_CPLD_DEFS_H__ +#define CPLD_CLIENT_NAME_LEN 32 /* CPLD DATA - DATA FOR CPLD CLIENT READ/WRITE*/ typedef struct CPLD_DATA { diff --git a/platform/pddf/i2c/modules/include/pddf_mux_defs.h b/platform/pddf/i2c/modules/include/pddf_mux_defs.h index c58a00e972c6..f10cb25e50c4 100644 --- a/platform/pddf/i2c/modules/include/pddf_mux_defs.h +++ b/platform/pddf/i2c/modules/include/pddf_mux_defs.h @@ -20,8 +20,6 @@ #ifndef __PAL_MUX_DEFS_H__ #define __PAL_MUX_DEFS_H__ -#include - /* MUX CLIENT DATA - PLATFORM DATA FOR PSU CLIENT */ typedef struct MUX_DATA { diff --git a/platform/pddf/i2c/modules/include/pddf_xcvr_defs.h b/platform/pddf/i2c/modules/include/pddf_xcvr_defs.h index 63de2eeae0c2..585ce8cc7334 100644 --- a/platform/pddf/i2c/modules/include/pddf_xcvr_defs.h +++ b/platform/pddf/i2c/modules/include/pddf_xcvr_defs.h @@ -115,7 +115,7 @@ enum xcvr_sysfs_attributes { XCVR_ATTR_MAX }; -extern int board_i2c_cpld_read(unsigned short cpld_addr, u8 reg); -extern int board_i2c_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); +extern int board_i2c_cpld_read_new(unsigned short cpld_addr, char *name, u8 reg); +extern int board_i2c_cpld_write_new(unsigned short cpld_addr, char *name, u8 reg, u8 value); #endif diff --git a/platform/pddf/i2c/modules/led/Makefile b/platform/pddf/i2c/modules/led/Makefile index 0c450ec70b4c..4bb36f9b5311 100644 --- a/platform/pddf/i2c/modules/led/Makefile +++ b/platform/pddf/i2c/modules/led/Makefile @@ -1,4 +1,4 @@ TARGET := pddf_led_module obj-m := $(TARGET).o -CFLAGS_$(obj-m):= -I$(M)/modules/include +ccflags-y := -I$(M)/modules/include diff --git a/platform/pddf/i2c/modules/mux/Makefile b/platform/pddf/i2c/modules/mux/Makefile index 486e7033435f..85502608cbdd 100644 --- a/platform/pddf/i2c/modules/mux/Makefile +++ b/platform/pddf/i2c/modules/mux/Makefile @@ -1,4 +1,4 @@ obj-m := pddf_mux_module.o -CFLAGS_$(obj-m):= -I$(M)/modules/include +ccflags-y := -I$(M)/modules/include diff --git a/platform/pddf/i2c/modules/mux/pddf_mux_module.c b/platform/pddf/i2c/modules/mux/pddf_mux_module.c index b0cd9e761ca7..b1daff2b7224 100644 --- a/platform/pddf/i2c/modules/mux/pddf_mux_module.c +++ b/platform/pddf/i2c/modules/mux/pddf_mux_module.c @@ -56,72 +56,49 @@ static const struct attribute_group pddf_mux_client_data_group = { .attrs = mux_attributes, }; -struct i2c_board_info *i2c_get_mux_board_info(MUX_DATA* mdata, NEW_DEV_ATTR *device_data) -{ - static struct i2c_board_info board_info; - static struct pca954x_platform_mode platform_modes[8]; - static struct pca954x_platform_data mux_platform_data; - int num_modes, i; - - if (strncmp(device_data->dev_type, "pca9548", strlen("pca9548")) == 0) - num_modes = 8; - else if (strncmp(device_data->dev_type, "pca9546", strlen("pca9546")) == 0) - num_modes = 6; - else - { - printk(KERN_ERR "%s: Unknown type of mux device\n", __FUNCTION__); - return NULL; - } - - for(i = 0; i < num_modes; i++) { - platform_modes[i] = (struct pca954x_platform_mode) { - .adap_id = (mdata->virt_bus + i), - .deselect_on_exit = 1, - }; - } - - mux_platform_data = (struct pca954x_platform_data) { - .modes = platform_modes, - .num_modes = num_modes, - }; - - board_info = (struct i2c_board_info) { - .platform_data = &mux_platform_data, - }; - - board_info.addr = device_data->dev_addr; - strcpy(board_info.type, device_data->dev_type); - - return &board_info; -} - - static ssize_t do_device_operation(struct device *dev, struct device_attribute *da, const char *buf, size_t count) { PDDF_ATTR *ptr = (PDDF_ATTR *)da; MUX_DATA *mux_ptr = (MUX_DATA *)(ptr->addr); NEW_DEV_ATTR *device_ptr = (NEW_DEV_ATTR *)(ptr->data); struct i2c_adapter *adapter; - struct i2c_board_info *board_info; + static struct i2c_board_info board_info; struct i2c_client *client_ptr; if (strncmp(buf, "add", strlen(buf)-1)==0) { - adapter = i2c_get_adapter(device_ptr->parent_bus); - board_info = i2c_get_mux_board_info(mux_ptr, device_ptr); - - client_ptr = i2c_new_device(adapter, board_info); - - if (client_ptr != NULL) + /* Supported types are pca_9540, pca_9542, pca_9543, pca_9544, pca_9545, pca_9546, pca_9547, pca_9548, + * pca_9846, pca_9847, pca_9848, pca_9849 + */ + if ( (strncmp(device_ptr->dev_type, "pca954", 6) == 0) || + (strncmp(device_ptr->dev_type, "pca984", 6) == 0) ) { - i2c_put_adapter(adapter); - pddf_dbg(MUX, KERN_ERR "Created %s client: 0x%p\n", device_ptr->i2c_name, (void *)client_ptr); - add_device_table(device_ptr->i2c_name, (void*)client_ptr); + adapter = i2c_get_adapter(device_ptr->parent_bus); + board_info = (struct i2c_board_info) { + .platform_data = NULL, + }; + + board_info.addr = device_ptr->dev_addr; + strcpy(board_info.type, device_ptr->dev_type); + + + client_ptr = i2c_new_client_device(adapter, &board_info); + + if (!IS_ERR(client_ptr)) + { + i2c_put_adapter(adapter); + pddf_dbg(MUX, KERN_ERR "Created %s client: 0x%p\n", device_ptr->i2c_name, (void *)client_ptr); + add_device_table(device_ptr->i2c_name, (void*)client_ptr); + } + else + { + i2c_put_adapter(adapter); + goto free_data; + } } - else + else { - i2c_put_adapter(adapter); - goto free_data; + printk(KERN_ERR "%s: Unknown type of mux device %s\n", __FUNCTION__, device_ptr->dev_type); } } else if (strncmp(buf, "delete", strlen(buf)-1)==0) diff --git a/platform/pddf/i2c/modules/psu/Makefile b/platform/pddf/i2c/modules/psu/Makefile index 04db30dfb48b..354c5ae2ed06 100644 --- a/platform/pddf/i2c/modules/psu/Makefile +++ b/platform/pddf/i2c/modules/psu/Makefile @@ -1,4 +1,4 @@ -subdir-m := driver -obj-m := pddf_psu_module.o +obj-m := driver/ +obj-m += pddf_psu_module.o -CFLAGS_$(obj-m):= -I$(M)/modules/include +ccflags-y:= -I$(M)/modules/include diff --git a/platform/pddf/i2c/modules/psu/driver/pddf_psu_api.c b/platform/pddf/i2c/modules/psu/driver/pddf_psu_api.c index b6b5e306a000..b358370f800e 100644 --- a/platform/pddf/i2c/modules/psu/driver/pddf_psu_api.c +++ b/platform/pddf/i2c/modules/psu/driver/pddf_psu_api.c @@ -89,20 +89,20 @@ int psu_update_hw(struct device *dev, struct psu_attr_info *info, PSU_DATA_ATTR { status = (sysfs_attr_data->pre_set)(client, udata, info); if (status!=0) - printk(KERN_ERR "%s: pre_set function fails for %s attribute\n", __FUNCTION__, udata->aname); + dev_warn(&client->dev, "%s: pre_set function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status); } if (sysfs_attr_data->do_set != NULL) { status = (sysfs_attr_data->do_set)(client, udata, info); if (status!=0) - printk(KERN_ERR "%s: do_set function fails for %s attribute\n", __FUNCTION__, udata->aname); + dev_warn(&client->dev, "%s: do_set function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status); } if (sysfs_attr_data->post_set != NULL) { status = (sysfs_attr_data->post_set)(client, udata, info); if (status!=0) - printk(KERN_ERR "%s: post_set function fails for %s attribute\n", __FUNCTION__, udata->aname); + dev_warn(&client->dev, "%s: post_set function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status); } mutex_unlock(&info->update_lock); @@ -128,20 +128,20 @@ int psu_update_attr(struct device *dev, struct psu_attr_info *data, PSU_DATA_ATT { status = (sysfs_attr_data->pre_get)(client, udata, data); if (status!=0) - printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, udata->aname); + dev_warn(&client->dev, "%s: pre_get function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status); } if (sysfs_attr_data->do_get != NULL) { status = (sysfs_attr_data->do_get)(client, udata, data); if (status!=0) - printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, udata->aname); + dev_warn(&client->dev, "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status); } if (sysfs_attr_data->post_get != NULL) { status = (sysfs_attr_data->post_get)(client, udata, data); if (status!=0) - printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, udata->aname); + dev_warn(&client->dev, "%s: post_get function fails for %s attribute. ret %d\n", __FUNCTION__, udata->aname, status); } data->last_updated = jiffies; diff --git a/platform/pddf/i2c/modules/psu/driver/pddf_psu_driver.c b/platform/pddf/i2c/modules/psu/driver/pddf_psu_driver.c index ad71e45eca20..dc7edb92a3ad 100644 --- a/platform/pddf/i2c/modules/psu/driver/pddf_psu_driver.c +++ b/platform/pddf/i2c/modules/psu/driver/pddf_psu_driver.c @@ -224,7 +224,7 @@ static int psu_probe(struct i2c_client *client, goto exit_free; } - data->hwmon_dev = hwmon_device_register(&client->dev); + data->hwmon_dev = hwmon_device_register_with_info(&client->dev, client->name, NULL, NULL, NULL); if (IS_ERR(data->hwmon_dev)) { status = PTR_ERR(data->hwmon_dev); goto exit_remove; diff --git a/platform/pddf/i2c/modules/psu/pddf_psu_module.c b/platform/pddf/i2c/modules/psu/pddf_psu_module.c index cf9713b407cd..41ceea7cca3d 100644 --- a/platform/pddf/i2c/modules/psu/pddf_psu_module.c +++ b/platform/pddf/i2c/modules/psu/pddf_psu_module.c @@ -160,9 +160,9 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute * board_info = i2c_get_psu_board_info(pdata, cdata); /* Populate the platform data for psu */ - client_ptr = i2c_new_device(adapter, board_info); + client_ptr = i2c_new_client_device(adapter, board_info); - if(client_ptr != NULL) + if(!IS_ERR(client_ptr)) { i2c_put_adapter(adapter); pddf_dbg(PSU, KERN_ERR "Created a %s client: 0x%p\n", cdata->i2c_name , (void *)client_ptr); diff --git a/platform/pddf/i2c/modules/sysstatus/Makefile b/platform/pddf/i2c/modules/sysstatus/Makefile index 150d160eae15..fc2e6261975e 100644 --- a/platform/pddf/i2c/modules/sysstatus/Makefile +++ b/platform/pddf/i2c/modules/sysstatus/Makefile @@ -1,4 +1,4 @@ TARGET := pddf_sysstatus_module obj-m := $(TARGET).o -CFLAGS_$(obj-m):= -I$(M)/modules/include +ccflags-y := -I$(M)/modules/include diff --git a/platform/pddf/i2c/modules/xcvr/Makefile b/platform/pddf/i2c/modules/xcvr/Makefile index e72ad6b44233..433a8630a2e8 100644 --- a/platform/pddf/i2c/modules/xcvr/Makefile +++ b/platform/pddf/i2c/modules/xcvr/Makefile @@ -1,4 +1,4 @@ -subdir-m := driver -obj-m := pddf_xcvr_module.o +obj-m := driver/ +obj-m += pddf_xcvr_module.o -CFLAGS_$(obj-m):= -I$(M)/modules/include +ccflags-y:= -I$(M)/modules/include diff --git a/platform/pddf/i2c/modules/xcvr/driver/pddf_xcvr_api.c b/platform/pddf/i2c/modules/xcvr/driver/pddf_xcvr_api.c index ddb7a1b3a2b3..a7be64328cab 100644 --- a/platform/pddf/i2c/modules/xcvr/driver/pddf_xcvr_api.c +++ b/platform/pddf/i2c/modules/xcvr/driver/pddf_xcvr_api.c @@ -47,36 +47,106 @@ int get_xcvr_module_attr_data(struct i2c_client *client, struct device *dev, int xcvr_i2c_cpld_read(XCVR_ATTR *info) { int status = -1; + int retry = 10; + struct i2c_client *client_ptr=NULL; if (info!=NULL) { - if (info->len==1) - { - status = board_i2c_cpld_read(info->devaddr , info->offset); - } - else + /* Get the I2C client for the CPLD */ + client_ptr = (struct i2c_client *)get_device_table(info->devname); + if (client_ptr) { - /* Get the I2C client for the CPLD */ - struct i2c_client *client_ptr=NULL; - client_ptr = (struct i2c_client *)get_device_table(info->devname); - if (client_ptr) + if (info->len==1) { - if (info->len==2) - { + while (retry) + { + status = board_i2c_cpld_read_new(info->devaddr, info->devname, info->offset); + if (unlikely(status < 0)) + { + msleep(60); + retry--; + continue; + } + break; + } + } + else if (info->len==2) + { + while(retry) + { status = i2c_smbus_read_word_swapped(client_ptr, info->offset); + if (unlikely(status < 0)) + { + msleep(60); + retry--; + continue; + } + break; } - else - printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD read yet"); } else - printk(KERN_ERR "Unable to get the client handle for %s\n", info->devname); + printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD read yet"); } + else + printk(KERN_ERR "Unable to get the client handle for %s\n", info->devname); + } + + return status; +} +int xcvr_i2c_cpld_write(XCVR_ATTR *info, uint32_t val) +{ + int status = 0; + unsigned int val_mask = 0, dnd_value = 0; + uint32_t reg; + struct i2c_client *client_ptr=NULL; + + val_mask = BIT_INDEX(info->mask); + /* Get the I2C client for the CPLD */ + client_ptr = (struct i2c_client *)get_device_table(info->devname); + + if (client_ptr) + { + if (info->len == 1) + status = board_i2c_cpld_read_new(info->devaddr, info->devname, info->offset); + else if (info->len == 2) + status = i2c_smbus_read_word_swapped(client_ptr, info->offset); + else + { + printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD read yet"); + status = -1; + } + } + else + { + printk(KERN_ERR "Unable to get the client handle for %s\n", info->devname); + status = -1; } + if (status < 0) + return status; + else + { + msleep(60); + dnd_value = status & ~val_mask; + if (((val == 1) && (info->cmpval != 0)) || ((val == 0) && (info->cmpval == 0))) + reg = dnd_value | val_mask; + else + reg = dnd_value; + if (info->len == 1) + status = board_i2c_cpld_write_new(info->devaddr, info->devname, info->offset, (uint8_t)reg); + else if (info->len == 2) + status = i2c_smbus_write_word_swapped(client_ptr, info->offset, (uint16_t)reg); + else + { + printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD write yet"); + status = -1; + } + } return status; } + int sonic_i2c_get_mod_pres(struct i2c_client *client, XCVR_ATTR *info, struct xcvr_data *data) { int status = 0; @@ -143,7 +213,7 @@ int sonic_i2c_get_mod_intr_status(struct i2c_client *client, XCVR_ATTR *info, st mod_intr = ((status & BIT_INDEX(info->mask)) == info->cmpval) ? 1 : 0; sfp_dbg(KERN_INFO "\nModule Interrupt :0x%x, reg_value = 0x%x\n", mod_intr, status); } - } + } else if(strcmp(info->devtype, "eeprom") == 0) { /* get client client for eeprom - Not Applicable */ @@ -247,54 +317,15 @@ int sonic_i2c_get_mod_txfault(struct i2c_client *client, XCVR_ATTR *info, struct int sonic_i2c_set_mod_reset(struct i2c_client *client, XCVR_ATTR *info, struct xcvr_data *data) { int status = 0; - unsigned int val_mask = 0, dnd_value = 0; - uint32_t reg; - struct i2c_client *client_ptr=NULL; if (strcmp(info->devtype, "cpld") == 0) { - val_mask = BIT_INDEX(info->mask); - /* Get the I2C client for the CPLD */ - client_ptr = (struct i2c_client *)get_device_table(info->devname); - - if (client_ptr) - { - if (info->len == 1) - status = board_i2c_cpld_read(info->devaddr , info->offset); - else if (info->len == 2) - status = i2c_smbus_read_word_data(client_ptr, info->offset); - else - { - printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD read yet"); - status = -1; - } - } - else - { - printk(KERN_ERR "Unable to get the client handle for %s\n", info->devname); - status = -1; - } - /*printk(KERN_ERR "sonic_i2c_set_mod_reset:client_ptr=0x%x, status=0x%x, offset=0x%x, len=%d\n", client_ptr, status, info->offset, info->len);*/ - - if (status < 0) - return status; - else - { - dnd_value = status & ~val_mask; - if (((data->reset == 1) && (info->cmpval != 0)) || ((data->reset == 0) && (info->cmpval == 0))) - reg = dnd_value | val_mask; - else - reg = dnd_value; - if (info->len == 1) - status = board_i2c_cpld_write(info->devaddr, info->offset, (uint8_t)reg); - else if (info->len == 2) - status = i2c_smbus_write_word_swapped(client_ptr, info->offset, (uint16_t)reg); - else - { - printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD write yet"); - status = -1; - } - } + status = xcvr_i2c_cpld_write(info, data->reset); + } + else + { + printk(KERN_ERR "Error: Invalid device type (%s) to set xcvr reset\n", info->devtype); + status = -1; } return status; @@ -303,53 +334,15 @@ int sonic_i2c_set_mod_reset(struct i2c_client *client, XCVR_ATTR *info, struct x int sonic_i2c_set_mod_lpmode(struct i2c_client *client, XCVR_ATTR *info, struct xcvr_data *data) { int status = 0; - unsigned int val_mask = 0, dnd_value = 0; - uint32_t reg; - struct i2c_client *client_ptr=NULL; if (strcmp(info->devtype, "cpld") == 0) { - val_mask = BIT_INDEX(info->mask); - /* Get the I2C client for the CPLD */ - client_ptr = (struct i2c_client *)get_device_table(info->devname); - - if (client_ptr) - { - if (info->len == 1) - status = board_i2c_cpld_read(info->devaddr , info->offset); - else if (info->len == 2) - status = i2c_smbus_read_word_data(client_ptr, info->offset); - else - { - printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD read yet"); - status = -1; - } - } - else - { - printk(KERN_ERR "Unable to get the client handle for %s\n", info->devname); - status = -1; - } - - if (status < 0) - return status; - else - { - dnd_value = status & ~val_mask; - if (((data->lpmode == 1) && (info->cmpval != 0)) || ((data->lpmode == 0) && (info->cmpval == 0))) - reg = dnd_value | val_mask; - else - reg = dnd_value; - if (info->len == 1) - status = board_i2c_cpld_write(info->devaddr, info->offset, (uint8_t)reg); - else if (info->len == 2) - status = i2c_smbus_write_word_swapped(client_ptr, info->offset, (uint16_t)reg); - else - { - printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD write yet"); - status = -1; - } - } + status = xcvr_i2c_cpld_write(info, data->lpmode); + } + else + { + printk(KERN_ERR "Error: Invalid device type (%s) to set xcvr lpmode\n", info->devtype); + status = -1; } return status; @@ -358,53 +351,15 @@ int sonic_i2c_set_mod_lpmode(struct i2c_client *client, XCVR_ATTR *info, struct int sonic_i2c_set_mod_txdisable(struct i2c_client *client, XCVR_ATTR *info, struct xcvr_data *data) { int status = 0; - unsigned int val_mask = 0, dnd_value = 0; - uint32_t reg; - struct i2c_client *client_ptr=NULL; if (strcmp(info->devtype, "cpld") == 0) { - val_mask = BIT_INDEX(info->mask); - /* Get the I2C client for the CPLD */ - client_ptr = (struct i2c_client *)get_device_table(info->devname); - - if (client_ptr) - { - if (info->len == 1) - status = board_i2c_cpld_read(info->devaddr , info->offset); - else if (info->len == 2) - status = i2c_smbus_read_word_data(client_ptr, info->offset); - else - { - printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD read yet"); - status = -1; - } - } - else - { - printk(KERN_ERR "Unable to get the client handle for %s\n", info->devname); - status = -1; - } - - if (status < 0) - return status; - else - { - dnd_value = status & ~val_mask; - if (((data->txdisable == 1) && (info->cmpval != 0)) || ((data->txdisable == 0) && (info->cmpval == 0))) - reg = dnd_value | val_mask; - else - reg = dnd_value; - if (info->len == 1) - status = board_i2c_cpld_write(info->devaddr, info->offset, (uint8_t)reg); - else if (info->len == 2) - status = i2c_smbus_write_word_swapped(client_ptr, info->offset, (uint16_t)reg); - else - { - printk(KERN_ERR "PDDF_XCVR: Doesn't support block CPLD write yet"); - status = -1; - } - } + status = xcvr_i2c_cpld_write(info, data->txdisable); + } + else + { + printk(KERN_ERR "Error: Invalid device type (%s) to set xcvr txdisable\n", info->devtype); + status = -1; } return status; @@ -433,20 +388,20 @@ ssize_t get_module_presence(struct device *dev, struct device_attribute *da, { status = (attr_ops->pre_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: pre_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->do_get != NULL) { status = (attr_ops->do_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); + dev_warn(&client->dev, "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->post_get != NULL) { status = (attr_ops->post_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: post_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } mutex_unlock(&data->update_lock); return sprintf(buf, "%d\n", data->modpres); @@ -478,20 +433,20 @@ ssize_t get_module_reset(struct device *dev, struct device_attribute *da, { status = (attr_ops->pre_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); } if (attr_ops->do_get != NULL) { status = (attr_ops->do_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); } if (attr_ops->post_get != NULL) { status = (attr_ops->post_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); } mutex_unlock(&data->update_lock); @@ -533,20 +488,20 @@ ssize_t set_module_reset(struct device *dev, struct device_attribute *da, const { status = (attr_ops->pre_set)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: pre_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->do_set != NULL) { status = (attr_ops->do_set)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: do_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->post_set != NULL) { status = (attr_ops->post_set)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: post_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } mutex_unlock(&data->update_lock); @@ -579,20 +534,20 @@ ssize_t get_module_intr_status(struct device *dev, struct device_attribute *da, { status = (attr_ops->pre_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: pre_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->do_get != NULL) { status = (attr_ops->do_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->post_get != NULL) { status = (attr_ops->post_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: post_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } mutex_unlock(&data->update_lock); @@ -645,20 +600,20 @@ ssize_t get_module_lpmode(struct device *dev, struct device_attribute *da, char { status = (attr_ops->pre_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: pre_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->do_get != NULL) { status = (attr_ops->do_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->post_get != NULL) { status = (attr_ops->post_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: post_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } mutex_unlock(&data->update_lock); return sprintf(buf, "%d\n", data->lpmode); @@ -699,20 +654,20 @@ ssize_t set_module_lpmode(struct device *dev, struct device_attribute *da, const { status = (attr_ops->pre_set)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: pre_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->do_set != NULL) { status = (attr_ops->do_set)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: do_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->post_set != NULL) { status = (attr_ops->post_set)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: post_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } mutex_unlock(&data->update_lock); } @@ -743,20 +698,20 @@ ssize_t get_module_rxlos(struct device *dev, struct device_attribute *da, { status = (attr_ops->pre_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: pre_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->do_get != NULL) { status = (attr_ops->do_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->post_get != NULL) { status = (attr_ops->post_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: post_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } mutex_unlock(&data->update_lock); return sprintf(buf, "%d\n", data->rxlos); @@ -789,20 +744,20 @@ ssize_t get_module_txdisable(struct device *dev, struct device_attribute *da, { status = (attr_ops->pre_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: pre_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->do_get != NULL) { status = (attr_ops->do_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->post_get != NULL) { status = (attr_ops->post_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: post_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } mutex_unlock(&data->update_lock); return sprintf(buf, "%d\n", data->txdisable); @@ -843,20 +798,20 @@ ssize_t set_module_txdisable(struct device *dev, struct device_attribute *da, co { status = (attr_ops->pre_set)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: pre_set function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: pre_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->do_set != NULL) { status = (attr_ops->do_set)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: do_set function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: do_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->post_set != NULL) { status = (attr_ops->post_set)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: post_set function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: post_set function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } mutex_unlock(&data->update_lock); } @@ -887,20 +842,20 @@ ssize_t get_module_txfault(struct device *dev, struct device_attribute *da, { status = (attr_ops->pre_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: pre_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: pre_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->do_get != NULL) { status = (attr_ops->do_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: do_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: do_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } if (attr_ops->post_get != NULL) { status = (attr_ops->post_get)(client, attr_data, data); if (status!=0) - printk(KERN_ERR "%s: post_get function fails for %s attribute\n", __FUNCTION__, attr_data->aname); + dev_warn(&client->dev, "%s: post_get function fails for %s attribute. ret %d\n", __FUNCTION__, attr_data->aname, status); } mutex_unlock(&data->update_lock); return sprintf(buf, "%d\n", data->txfault); diff --git a/platform/pddf/i2c/modules/xcvr/driver/pddf_xcvr_driver.c b/platform/pddf/i2c/modules/xcvr/driver/pddf_xcvr_driver.c index 142d38a2ff2b..7ce1bca94b71 100644 --- a/platform/pddf/i2c/modules/xcvr/driver/pddf_xcvr_driver.c +++ b/platform/pddf/i2c/modules/xcvr/driver/pddf_xcvr_driver.c @@ -159,7 +159,7 @@ static int xcvr_probe(struct i2c_client *client, goto exit_free; } - data->xdev = hwmon_device_register(&client->dev); + data->xdev = hwmon_device_register_with_info(&client->dev, client->name, NULL, NULL, NULL); if (IS_ERR(data->xdev)) { status = PTR_ERR(data->xdev); goto exit_remove; diff --git a/platform/pddf/i2c/modules/xcvr/pddf_xcvr_module.c b/platform/pddf/i2c/modules/xcvr/pddf_xcvr_module.c index 65c555b742a2..43c41954c71f 100644 --- a/platform/pddf/i2c/modules/xcvr/pddf_xcvr_module.c +++ b/platform/pddf/i2c/modules/xcvr/pddf_xcvr_module.c @@ -129,8 +129,8 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute * board_info.addr = cdata->dev_addr; strcpy(board_info.type, cdata->dev_type); - client_ptr = i2c_new_device(adapter, &board_info); - if (client_ptr != NULL) { + client_ptr = i2c_new_client_device(adapter, &board_info); + if (!IS_ERR(client_ptr)) { i2c_put_adapter(adapter); pddf_dbg(XCVR, KERN_ERR "Created a %s client: 0x%p\n", cdata->i2c_name, (void *)client_ptr); add_device_table(cdata->i2c_name, (void*)client_ptr); @@ -152,8 +152,8 @@ static ssize_t do_device_operation(struct device *dev, struct device_attribute * board_info.addr = cdata->dev_addr; strcpy(board_info.type, cdata->dev_type); - client_ptr = i2c_new_device(adapter, &board_info); - if(client_ptr != NULL) { + client_ptr = i2c_new_client_device(adapter, &board_info); + if(!IS_ERR(client_ptr)) { i2c_put_adapter(adapter); pddf_dbg(XCVR, KERN_ERR "Created %s, type:%s client: 0x%p\n", cdata->i2c_name, cdata->dev_type, (void *)client_ptr); add_device_table(cdata->i2c_name, (void*)client_ptr); diff --git a/platform/pddf/i2c/service/pddf-platform-init.service b/platform/pddf/i2c/service/pddf-platform-init.service index ccb8d1110fb7..41fa67214fc8 100644 --- a/platform/pddf/i2c/service/pddf-platform-init.service +++ b/platform/pddf/i2c/service/pddf-platform-init.service @@ -5,6 +5,7 @@ DefaultDependencies=no [Service] Type=oneshot +ExecStartPre=-/usr/local/bin/pre_pddf_init.sh ExecStart=/usr/local/bin/pddf_util.py install ExecStop=/usr/local/bin/pddf_util.py clean RemainAfterExit=yes diff --git a/platform/pddf/i2c/utils/pddf_util.py b/platform/pddf/i2c/utils/pddf_util.py index 299ec18babd9..fdefc8933c15 100755 --- a/platform/pddf/i2c/utils/pddf_util.py +++ b/platform/pddf/i2c/utils/pddf_util.py @@ -15,7 +15,6 @@ switch-nonpddf : switch to per platform, non-pddf mode """ -import commands import logging import getopt import os @@ -120,7 +119,7 @@ def my_log(txt): def log_os_system(cmd, show): logging.info('Run :'+cmd) - status, output = commands.getstatusoutput(cmd) + status, output = subprocess.getstatusoutput(cmd) my_log (cmd +"with result:" + str(status)) my_log (" output:"+output) if status: @@ -138,33 +137,9 @@ def driver_check(): return False return True - -# Returns platform and HW SKU -def get_platform_and_hwsku(): - try: - proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY], - stdout=subprocess.PIPE, - shell=False, - stderr=subprocess.STDOUT) - stdout = proc.communicate()[0] - proc.wait() - platform = stdout.rstrip('\n') - - proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-d', '-v', HWSKU_KEY], - stdout=subprocess.PIPE, - shell=False, - stderr=subprocess.STDOUT) - stdout = proc.communicate()[0] - proc.wait() - hwsku = stdout.rstrip('\n') - except OSError, e: - raise OSError("Cannot detect platform") - - return (platform, hwsku) - def get_path_to_device(): # Get platform and hwsku - (platform, hwsku) = get_platform_and_hwsku() + (platform, hwsku) = pddf_obj.get_platform_and_hwsku() # Load platform module from source platform_path = "/".join([PLATFORM_ROOT_PATH, platform]) @@ -193,14 +168,20 @@ def config_pddf_utils(): log_os_system('mv '+SONIC_PLATFORM_BSP_WHL_PKG+' '+SONIC_PLATFORM_BSP_WHL_PKG_BK, 1) # PDDF whl package exist ... this must be the whl package created from # PDDF 2.0 ref API classes and some changes on top of it ... install it + log_os_system('sync', 1) shutil.copy(SONIC_PLATFORM_PDDF_WHL_PKG, SONIC_PLATFORM_BSP_WHL_PKG) + log_os_system('sync', 1) print("Attemting to install the PDDF sonic_platform wheel package ...") - status, output = log_os_system("pip3 install "+ SONIC_PLATFORM_BSP_WHL_PKG, 1) - if status: - print("Error: Failed to install {}".format(SONIC_PLATFORM_BSP_WHL_PKG)) - return status + if os.path.getsize(SONIC_PLATFORM_BSP_WHL_PKG) != 0: + status, output = log_os_system("pip3 install "+ SONIC_PLATFORM_BSP_WHL_PKG, 1) + if status: + print("Error: Failed to install {}".format(SONIC_PLATFORM_BSP_WHL_PKG)) + return status + else: + print("Successfully installed {} package".format(SONIC_PLATFORM_BSP_WHL_PKG)) else: - print("Successfully installed {} package".format(SONIC_PLATFORM_BSP_WHL_PKG)) + print("Error: Failed to copy {} properly. Exiting ...".format(SONIC_PLATFORM_PDDF_WHL_PKG)) + return -1 else: # PDDF with platform APIs 1.5 must be supported device_plugin_path = "/".join([device_path, "plugins"]) @@ -228,13 +209,17 @@ def config_pddf_utils(): if status: print("Error: Unable to uninstall BSP sonic-platform whl package") return status - print("Attemting to install the PDDF sonic_platform wheel package ...") - status, output = log_os_system("pip3 install "+ SONIC_PLATFORM_BSP_WHL_PKG, 1) - if status: - print("Error: Failed to install {}".format(SONIC_PLATFORM_BSP_WHL_PKG)) - return status + print("Attempting to install the PDDF sonic_platform wheel package ...") + if os.path.getsize(SONIC_PLATFORM_BSP_WHL_PKG) != 0: + status, output = log_os_system("pip3 install "+ SONIC_PLATFORM_BSP_WHL_PKG, 1) + if status: + print("Error: Failed to install {}".format(SONIC_PLATFORM_BSP_WHL_PKG)) + return status + else: + print("Successfully installed {} package".format(SONIC_PLATFORM_BSP_WHL_PKG)) else: - print("Successfully installed {} package".format(SONIC_PLATFORM_BSP_WHL_PKG)) + print("Error: Failed to copy {} properly. Exiting ...".format(SONIC_PLATFORM_PDDF_WHL_PKG)) + return -1 else: # system rebooted in pddf mode print("System rebooted in PDDF mode, hence keeping the PDDF 2.0 classes") @@ -353,6 +338,16 @@ def driver_install(): if status: print("Error: pddf_pre_driver_install script failed with error %d"%status) return status + # For debug + print(output) + + # Removes the perm_kos first, then reload them in a proper sequence + for mod in perm_kos: + cmd = "modprobe -rq " + mod + status, output = log_os_system(cmd, 1) + if status: + print("driver_install: Unable to unload {}".format(mod)) + # Don't exit but continue log_os_system("depmod", 1) for i in range(0,len(kos)): diff --git a/platform/pddf/i2c/utils/pddfparse.py b/platform/pddf/i2c/utils/pddfparse.py index f9ce8fca0b42..9d4b82d7594f 100755 --- a/platform/pddf/i2c/utils/pddfparse.py +++ b/platform/pddf/i2c/utils/pddfparse.py @@ -2,7 +2,6 @@ import argparse import glob import json -from jsonschema import validate import os import re import subprocess @@ -10,13 +9,13 @@ import time import unicodedata -bmc_cache={} -cache={} +bmc_cache = {} +cache = {} SONIC_CFGGEN_PATH = '/usr/local/bin/sonic-cfggen' HWSKU_KEY = 'DEVICE_METADATA.localhost.hwsku' PLATFORM_KEY = 'DEVICE_METADATA.localhost.platform' -dirname=os.path.dirname(os.path.realpath(__file__)) +dirname = os.path.dirname(os.path.realpath(__file__)) color_map = { "STATUS_LED_COLOR_GREEN" : "green", @@ -31,8 +30,6 @@ } - - class PddfParse(): def __init__(self): if not os.path.exists("/usr/share/sonic/platform"): @@ -41,16 +38,14 @@ def __init__(self): try: with open('/usr/share/sonic/platform/pddf/pddf-device.json') as f: - self.data = json.load(f) + self.data = json.load(f) except IOError: if os.path.exists('/usr/share/sonic/platform'): os.unlink("/usr/share/sonic/platform") raise Exception('PDDF JSON file not found. PDDF is not supported on this platform') - - self.data_sysfs_obj={} - self.sysfs_obj={} - + self.data_sysfs_obj = {} + self.sysfs_obj = {} # Returns platform and HW SKU def get_platform_and_hwsku(self): @@ -58,6 +53,7 @@ def get_platform_and_hwsku(self): proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY], stdout=subprocess.PIPE, shell=False, + universal_newlines=True, stderr=subprocess.STDOUT) stdout = proc.communicate()[0] proc.wait() @@ -66,11 +62,12 @@ def get_platform_and_hwsku(self): proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-d', '-v', HWSKU_KEY], stdout=subprocess.PIPE, shell=False, + universal_newlines=True, stderr=subprocess.STDOUT) stdout = proc.communicate()[0] proc.wait() hwsku = stdout.rstrip('\n') - except OSError, e: + except OSError as e: raise OSError("Cannot detect platform") return (platform, hwsku) @@ -80,76 +77,81 @@ def get_platform_and_hwsku(self): ################################################################################################################### def runcmd(self, cmd): rc = os.system(cmd) - if rc!=0: - print "%s -- command failed"%cmd + if rc != 0: + print("%s -- command failed" % cmd) return rc def get_dev_idx(self, dev, ops): - parent=dev['dev_info']['virt_parent'] - pdev=self.data[parent] - - return pdev['dev_attr']['dev_idx'] + parent = dev['dev_info']['virt_parent'] + pdev = self.data[parent] + return pdev['dev_attr']['dev_idx'] - def get_path(self, target, attr): + def get_paths(self, target, attr): aa = target + attr if aa in cache: return cache[aa] - string = None + strings = [] p = re.search(r'\d+$', target) if p is None: - for bb in filter(re.compile(target).search,self.data.keys()): - path = self.dev_parse(self.data[bb], { "cmd": "show_attr", "target":bb, "attr":attr }) - if path != "": - string = path + for bb in filter(re.compile(target).search, self.data.keys()): + paths = self.dev_parse(self.data[bb], {"cmd": "show_attr", "target": bb, "attr": attr}) + if paths: + strings.extend(paths) else: if target in self.data.keys(): - path = self.dev_parse(self.data[target], { "cmd": "show_attr", "target":target, "attr":attr }) - if path != "": - string = path + paths = self.dev_parse(self.data[target], {"cmd": "show_attr", "target": target, "attr": attr}) + if paths: + strings.extend(paths) + cache[aa] = strings + return strings - if string is not None: - string = string.rstrip() - - cache[aa]=string - return string - + def get_path(self, target, attr): + nodes = self.get_paths(target, attr) + if nodes: + if len(nodes)==1: + return nodes[0] + # CAREFULL!!! If more than one paths are expected, use get_paths + else: + return nodes[0] + else: + return None def get_device_type(self, key): - if not key in self.data.keys(): - return None + if key not in self.data.keys(): + return None return self.data[key]['dev_info']['device_type'] def get_platform(self): return self.data['PLATFORM'] def get_num_psu_fans(self, dev): - if not dev in self.data.keys(): + if dev not in self.data.keys(): return 0 - if not 'num_psu_fans' in self.data[dev]['dev_attr']: + if 'num_psu_fans' not in self.data[dev]['dev_attr']: return 0 - + return self.data[dev]['dev_attr']['num_psu_fans'] - def get_led_path(self): - return ("pddf/devices/led") + def get_led_path(self): + return ("pddf/devices/led") - def get_led_cur_state_path(self): - return ("pddf/devices/led/cur_state") + def get_led_cur_state_path(self): + return ("pddf/devices/led/cur_state") - def get_led_color(self): - color_f="/sys/kernel/pddf/devices/led/cur_state/color" + def get_led_color(self): + color_f = "/sys/kernel/pddf/devices/led/cur_state/color" try: - with open(color_f, 'r') as f: - color = f.read().strip("\r\n") + with open(color_f, 'r') as f: + color = f.read().strip("\r\n") except IOError: - return ("Error") + return ("Error") - return (color_map[color]) + return (color_map[color]) ################################################################################################################### # CREATE DEFS @@ -162,291 +164,291 @@ def create_device(self, attr, path, ops): else: val = attr[key] - cmd="echo '%s' > /sys/kernel/%s/%s"%(val, path, key) - ret=self.runcmd(cmd) - if ret!=0: + cmd = "echo '%s' > /sys/kernel/%s/%s" % (val, path, key) + ret = self.runcmd(cmd) + if ret != 0: return ret return ret def create_psu_i2c_device(self, dev, ops): - create_ret = 0 + create_ret = [] + ret = 0 if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PSU']: - create_ret = self.create_device(dev['i2c']['topo_info'], "pddf/devices/psu/i2c", ops) - if create_ret!=0: - return create_ret - cmd= "echo '%s' > /sys/kernel/pddf/devices/psu/i2c/i2c_name"%(dev['dev_info']['device_name']) - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret - cmd= "echo '%s' > /sys/kernel/pddf/devices/psu/i2c/psu_idx"%( self.get_dev_idx(dev, ops)) - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + ret = self.create_device(dev['i2c']['topo_info'], "pddf/devices/psu/i2c", ops) + if ret != 0: + return create_ret.append(ret) + cmd = "echo '%s' > /sys/kernel/pddf/devices/psu/i2c/i2c_name" % (dev['dev_info']['device_name']) + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) + cmd = "echo '%s' > /sys/kernel/pddf/devices/psu/i2c/psu_idx" % (self.get_dev_idx(dev, ops)) + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) for attr in dev['i2c']['attr_list']: - create_ret = self.create_device(attr, "pddf/devices/psu/i2c", ops) - if create_ret!=0: - return create_ret - cmd= "echo 'add' > /sys/kernel/pddf/devices/psu/i2c/attr_ops" - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + ret = self.create_device(attr, "pddf/devices/psu/i2c", ops) + if ret != 0: + return create_ret.append(ret) + cmd = "echo 'add' > /sys/kernel/pddf/devices/psu/i2c/attr_ops" + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) cmd = "echo 'add' > /sys/kernel/pddf/devices/psu/i2c/dev_ops" - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) else: - cmd = "echo %s 0x%x > /sys/bus/i2c/devices/i2c-%d/new_device" % (dev['i2c']['topo_info']['dev_type'], + cmd = "echo %s 0x%x > /sys/bus/i2c/devices/i2c-%d/new_device" % (dev['i2c']['topo_info']['dev_type'], int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0)) - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret - - - return create_ret - + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) + return create_ret.append(ret) def create_psu_bmc_device(self, dev, ops): - print "" - + return [0] def create_psu_device(self, dev, ops): - return self.create_psu_i2c_device(dev, ops ) - + return self.create_psu_i2c_device(dev, ops) + def create_fan_device(self, dev, ops): - create_ret = 0 + create_ret = [] + ret = 0 if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['FAN']: - create_ret = self.create_device(dev['i2c']['topo_info'], "pddf/devices/fan/i2c", ops) - if create_ret!=0: - return create_ret - cmd= "echo '%s' > /sys/kernel/pddf/devices/fan/i2c/i2c_name"%(dev['dev_info']['device_name']) - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret - create_ret = self.create_device(dev['i2c']['dev_attr'], "pddf/devices/fan/i2c", ops) - if create_ret!=0: - return create_ret + ret = self.create_device(dev['i2c']['topo_info'], "pddf/devices/fan/i2c", ops) + if ret != 0: + return create_ret.append(ret) + cmd = "echo '%s' > /sys/kernel/pddf/devices/fan/i2c/i2c_name" % (dev['dev_info']['device_name']) + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) + ret = self.create_device(dev['i2c']['dev_attr'], "pddf/devices/fan/i2c", ops) + if ret != 0: + return create_ret.append(ret) for attr in dev['i2c']['attr_list']: - create_ret = self.create_device(attr, "pddf/devices/fan/i2c", ops) - if create_ret!=0: - return create_ret - cmd= "echo 'add' > /sys/kernel/pddf/devices/fan/i2c/attr_ops" - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret - - cmd= "echo 'add' > /sys/kernel/pddf/devices/fan/i2c/dev_ops" - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + ret = self.create_device(attr, "pddf/devices/fan/i2c", ops) + if ret != 0: + return create_ret.append(ret) + cmd = "echo 'add' > /sys/kernel/pddf/devices/fan/i2c/attr_ops" + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) + + cmd = "echo 'add' > /sys/kernel/pddf/devices/fan/i2c/dev_ops" + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) else: - cmd= "echo %s 0x%x > /sys/bus/i2c/devices/i2c-%d/new_device" % (dev['i2c']['topo_info']['dev_type'], + cmd = "echo %s 0x%x > /sys/bus/i2c/devices/i2c-%d/new_device" % (dev['i2c']['topo_info']['dev_type'], int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0)) - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) - return create_ret + return create_ret.append(ret) def create_temp_sensor_device(self, dev, ops): - create_ret = 0 - # NO PDDF driver for temp_sensors device - cmd= "echo %s 0x%x > /sys/bus/i2c/devices/i2c-%d/new_device" % (dev['i2c']['topo_info']['dev_type'], - int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0)) - create_ret = self.runcmd(cmd) - return create_ret - - - + create_ret = [] + ret = 0 + # NO PDDF driver for temp_sensors device + cmd = "echo %s 0x%x > /sys/bus/i2c/devices/i2c-%d/new_device" % (dev['i2c']['topo_info']['dev_type'], + int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0)) + ret = self.runcmd(cmd) + return create_ret.append(ret) def create_cpld_device(self, dev, ops): - create_ret = 0 + create_ret = [] + ret = 0 if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['CPLD']: - create_ret = self.create_device(dev['i2c']['topo_info'], "pddf/devices/cpld", ops) - if create_ret!=0: - return create_ret - - cmd= "echo '%s' > /sys/kernel/pddf/devices/cpld/i2c_name"%(dev['dev_info']['device_name']) - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + ret = self.create_device(dev['i2c']['topo_info'], "pddf/devices/cpld", ops) + if ret != 0: + return create_ret.append(ret) + + cmd = "echo '%s' > /sys/kernel/pddf/devices/cpld/i2c_name" % (dev['dev_info']['device_name']) + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) # TODO: If attributes are provided then, use 'self.create_device' for them too - cmd= "echo 'add' > /sys/kernel/pddf/devices/cpld/dev_ops" - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + cmd = "echo 'add' > /sys/kernel/pddf/devices/cpld/dev_ops" + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) else: - cmd= "echo %s 0x%x > /sys/bus/i2c/devices/i2c-%d/new_device" % (dev['i2c']['topo_info']['dev_type'], + cmd = "echo %s 0x%x > /sys/bus/i2c/devices/i2c-%d/new_device" % (dev['i2c']['topo_info']['dev_type'], int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0)) - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) - return create_ret + return create_ret.append(ret) def create_cpldmux_device(self, dev, ops): - create_ret = 0 - create_ret = self.create_device(dev['i2c']['topo_info'], "pddf/devices/cpldmux", ops) - if create_ret!=0: - return create_ret - cmd= "echo '%s' > /sys/kernel/pddf/devices/mux/i2c_name"%(dev['dev_info']['device_name']) - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + create_ret = [] + ret = 0 + ret = self.create_device(dev['i2c']['topo_info'], "pddf/devices/cpldmux", ops) + if ret != 0: + return create_ret.append(ret) + cmd = "echo '%s' > /sys/kernel/pddf/devices/mux/i2c_name" % (dev['dev_info']['device_name']) + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) self.create_device(dev['i2c']['dev_attr'], "pddf/devices/cpldmux", ops) - # Parse channel info + # Parse channel info for chan in dev['i2c']['channel']: self.create_device(chan, "pddf/devices/cpldmux", ops) - cmd="echo 'add' > /sys/kernel/pddf/devices/cpldmux/chan_ops" - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + cmd = "echo 'add' > /sys/kernel/pddf/devices/cpldmux/chan_ops" + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) - cmd= "echo 'add' > /sys/kernel/pddf/devices/cpldmux/dev_ops" - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + cmd = "echo 'add' > /sys/kernel/pddf/devices/cpldmux/dev_ops" + ret = self.runcmd(cmd) + return create_ret.append(ret) def create_gpio_device(self, dev, ops): - create_ret = 0 - create_ret = self.create_device(dev['i2c']['topo_info'], "pddf/devices/gpio", ops) - if create_ret!=0: - return create_ret - cmd= "echo '%s' > /sys/kernel/pddf/devices/gpio/i2c_name"%(dev['dev_info']['device_name']) - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret - create_ret = self.create_device(dev['i2c']['dev_attr'], "pddf/devices/gpio", ops) - if create_ret!=0: - return create_ret - cmd= "echo 'add' > /sys/kernel/pddf/devices/gpio/dev_ops" - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret - + create_ret = [] + ret = 0 + ret = self.create_device(dev['i2c']['topo_info'], "pddf/devices/gpio", ops) + if ret != 0: + return create_ret.append(ret) + cmd = "echo '%s' > /sys/kernel/pddf/devices/gpio/i2c_name" % (dev['dev_info']['device_name']) + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) + ret = self.create_device(dev['i2c']['dev_attr'], "pddf/devices/gpio", ops) + if ret != 0: + return create_ret.append(ret) + cmd = "echo 'add' > /sys/kernel/pddf/devices/gpio/dev_ops" + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) + time.sleep(2) base = dev['i2c']['dev_attr']['gpio_base'] for inst in dev['i2c']['ports']: - if inst['port_num']!="": + if inst['port_num'] != "": port_no = int(base, 16) + int(inst['port_num']) - cmd= "echo %d > /sys/class/gpio/export"%port_no - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret - if inst['direction']!="": - cmd= "echo %s >/sys/class/gpio/gpio%d/direction"%(inst['direction'], port_no) - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret - if inst['value']!="": + cmd = "echo %d > /sys/class/gpio/export" % port_no + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) + if inst['direction'] != "": + cmd = "echo %s >/sys/class/gpio/gpio%d/direction" % (inst['direction'], port_no) + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) + if inst['value'] != "": for i in inst['value'].split(','): - cmd= "echo %s >/sys/class/gpio/gpio%d/value"%(i.rstrip(), port_no) - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + cmd = "echo %s >/sys/class/gpio/gpio%d/value" % (i.rstrip(), port_no) + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) - return create_ret + return create_ret.append(ret) def create_mux_device(self, dev, ops): - create_ret = 0 - create_ret = self.create_device(dev['i2c']['topo_info'], "pddf/devices/mux", ops) - if create_ret!=0: - return create_ret - cmd= "echo '%s' > /sys/kernel/pddf/devices/mux/i2c_name"%(dev['dev_info']['device_name']) - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + create_ret = [] + ret = 0 + ret = self.create_device(dev['i2c']['topo_info'], "pddf/devices/mux", ops) + if ret != 0: + return create_ret.append(ret) + cmd = "echo '%s' > /sys/kernel/pddf/devices/mux/i2c_name" % (dev['dev_info']['device_name']) + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) self.create_device(dev['i2c']['dev_attr'], "pddf/devices/mux", ops) - cmd= "echo 'add' > /sys/kernel/pddf/devices/mux/dev_ops" - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret - + cmd = "echo 'add' > /sys/kernel/pddf/devices/mux/dev_ops" + ret = self.runcmd(cmd) + return create_ret.append(ret) def create_xcvr_i2c_device(self, dev, ops): - create_ret = 0 + create_ret = [] + ret = 0 if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PORT_MODULE']: self.create_device(dev['i2c']['topo_info'], "pddf/devices/xcvr/i2c", ops) - cmd= "echo '%s' > /sys/kernel/pddf/devices/xcvr/i2c/i2c_name"%(dev['dev_info']['device_name']) - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret - cmd="echo '%s' > /sys/kernel/pddf/devices/xcvr/i2c/dev_idx"%( self.get_dev_idx(dev, ops)) - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + cmd = "echo '%s' > /sys/kernel/pddf/devices/xcvr/i2c/i2c_name" % (dev['dev_info']['device_name']) + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) + cmd = "echo '%s' > /sys/kernel/pddf/devices/xcvr/i2c/dev_idx" % (self.get_dev_idx(dev, ops)) + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) for attr in dev['i2c']['attr_list']: self.create_device(attr, "pddf/devices/xcvr/i2c", ops) - cmd="echo 'add' > /sys/kernel/pddf/devices/xcvr/i2c/attr_ops" - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret - - cmd="echo 'add' > /sys/kernel/pddf/devices/xcvr/i2c/dev_ops" - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + cmd = "echo 'add' > /sys/kernel/pddf/devices/xcvr/i2c/attr_ops" + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) + + cmd = "echo 'add' > /sys/kernel/pddf/devices/xcvr/i2c/dev_ops" + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) else: - cmd="echo %s 0x%x > /sys/bus/i2c/devices/i2c-%d/new_device" % (dev['i2c']['topo_info']['dev_type'], + cmd = "echo %s 0x%x > /sys/bus/i2c/devices/i2c-%d/new_device" % (dev['i2c']['topo_info']['dev_type'], int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0)) - create_ret = self.runcmd(cmd) - #print "\n" - if create_ret!=0: - return create_ret + ret = self.runcmd(cmd) + # print("\n") + if ret != 0: + return create_ret.append(ret) # Add port name port_name_sysfs = '/sys/bus/i2c/devices/{}-00{:02x}/port_name'.format( - int(dev['i2c']['topo_info']['parent_bus'], 0),int(dev['i2c']['topo_info']['dev_addr'], 0)) + int(dev['i2c']['topo_info']['parent_bus'], 0), int(dev['i2c']['topo_info']['dev_addr'], 0)) if os.path.exists(port_name_sysfs): - cmd="echo {} > /sys/bus/i2c/devices/{}-00{:02x}/port_name".format( - dev['dev_info']['virt_parent'].lower(), int(dev['i2c']['topo_info']['parent_bus'], 0), - int(dev['i2c']['topo_info']['dev_addr'], 0)) - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + cmd = "echo {} > /sys/bus/i2c/devices/{}-00{:02x}/port_name".format( + dev['dev_info']['virt_parent'].lower(), int(dev['i2c']['topo_info']['parent_bus'], 0), + int(dev['i2c']['topo_info']['dev_addr'], 0)) + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) - return create_ret + return create_ret.append(ret) def create_xcvr_bmc_device(self, dev, ops): - print "" + return [0] def create_xcvr_device(self, dev, ops): - return self.create_xcvr_i2c_device(dev, ops ) + return self.create_xcvr_i2c_device(dev, ops) def create_sysstatus_device(self, dev, ops): - create_ret = 0 + create_ret = [] + ret = 0 for attr in dev['attr_list']: self.create_device(attr, "pddf/devices/sysstatus", ops) - cmd= "echo 'add' > /sys/kernel/pddf/devices/sysstatus/attr_ops" - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + cmd = "echo 'add' > /sys/kernel/pddf/devices/sysstatus/attr_ops" + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) def create_eeprom_device(self, dev, ops): - create_ret = 0 + create_ret = [] + ret = 0 if "EEPROM" in self.data['PLATFORM']['pddf_dev_types'] and \ dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['EEPROM']: self.create_device(dev['i2c']['topo_info'], "pddf/devices/eeprom/i2c", ops) - cmd= "echo '%s' > /sys/kernel/pddf/devices/eeprom/i2c/i2c_name"%(dev['dev_info']['device_name']) - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + cmd = "echo '%s' > /sys/kernel/pddf/devices/eeprom/i2c/i2c_name" % (dev['dev_info']['device_name']) + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) self.create_device(dev['i2c']['dev_attr'], "pddf/devices/eeprom/i2c", ops) cmd = "echo 'add' > /sys/kernel/pddf/devices/eeprom/i2c/dev_ops" - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) else: - cmd= "echo %s 0x%x > /sys/bus/i2c/devices/i2c-%d/new_device" % (dev['i2c']['topo_info']['dev_type'], + cmd = "echo %s 0x%x > /sys/bus/i2c/devices/i2c-%d/new_device" % (dev['i2c']['topo_info']['dev_type'], int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0)) - create_ret = self.runcmd(cmd) - if create_ret!=0: - return create_ret + ret = self.runcmd(cmd) + if ret != 0: + return create_ret.append(ret) - return create_ret + return create_ret.append(ret) ################################################################################################################### # DELETE DEFS @@ -454,13 +456,13 @@ def create_eeprom_device(self, dev, ops): def delete_eeprom_device(self, dev, ops): if "EEPROM" in self.data['PLATFORM']['pddf_dev_types'] and \ dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['EEPROM']: - cmd= "echo '%s' > /sys/kernel/pddf/devices/eeprom/i2c/i2c_name"%(dev['dev_info']['device_name']) + cmd = "echo '%s' > /sys/kernel/pddf/devices/eeprom/i2c/i2c_name" % (dev['dev_info']['device_name']) self.runcmd(cmd) cmd = "echo 'delete' > /sys/kernel/pddf/devices/eeprom/i2c/dev_ops" self.runcmd(cmd) else: - cmd= "echo 0x%x > /sys/bus/i2c/devices/i2c-%d/delete_device" % (int(dev['i2c']['topo_info']['dev_addr'], 0), - int(dev['i2c']['topo_info']['parent_bus'], 0)) + cmd = "echo 0x%x > /sys/bus/i2c/devices/i2c-%d/delete_device" % ( + int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0)) self.runcmd(cmd) def delete_sysstatus_device(self, dev, ops): @@ -470,13 +472,13 @@ def delete_sysstatus_device(self, dev, ops): def delete_xcvr_i2c_device(self, dev, ops): if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PORT_MODULE']: - cmd= "echo '%s' > /sys/kernel/pddf/devices/xcvr/i2c/i2c_name"%(dev['dev_info']['device_name']) + cmd = "echo '%s' > /sys/kernel/pddf/devices/xcvr/i2c/i2c_name" % (dev['dev_info']['device_name']) self.runcmd(cmd) - cmd="echo 'delete' > /sys/kernel/pddf/devices/xcvr/i2c/dev_ops" + cmd = "echo 'delete' > /sys/kernel/pddf/devices/xcvr/i2c/dev_ops" self.runcmd(cmd) else: - cmd="echo 0x%x > /sys/bus/i2c/devices/i2c-%d/delete_device" % (int(dev['i2c']['topo_info']['dev_addr'], 0), - int(dev['i2c']['topo_info']['parent_bus'], 0)) + cmd = "echo 0x%x > /sys/bus/i2c/devices/i2c-%d/delete_device" % ( + int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0)) self.runcmd(cmd) def delete_xcvr_device(self, dev, ops): @@ -484,75 +486,74 @@ def delete_xcvr_device(self, dev, ops): return def delete_gpio_device(self, dev, ops): - cmd= "echo '%s' > /sys/kernel/pddf/devices/gpio/i2c_name"%(dev['dev_info']['device_name']) - self.runcmd(cmd) - cmd= "echo 'delete' > /sys/kernel/pddf/devices/gpio/dev_ops" - self.runcmd(cmd) + cmd = "echo '%s' > /sys/kernel/pddf/devices/gpio/i2c_name" % (dev['dev_info']['device_name']) + self.runcmd(cmd) + cmd = "echo 'delete' > /sys/kernel/pddf/devices/gpio/dev_ops" + self.runcmd(cmd) def delete_mux_device(self, dev, ops): - cmd= "echo '%s' > /sys/kernel/pddf/devices/mux/i2c_name"%(dev['dev_info']['device_name']) - self.runcmd(cmd) - cmd= "echo 'delete' > /sys/kernel/pddf/devices/mux/dev_ops" - self.runcmd(cmd) + cmd = "echo '%s' > /sys/kernel/pddf/devices/mux/i2c_name" % (dev['dev_info']['device_name']) + self.runcmd(cmd) + cmd = "echo 'delete' > /sys/kernel/pddf/devices/mux/dev_ops" + self.runcmd(cmd) def delete_cpld_device(self, dev, ops): if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['CPLD']: - cmd= "echo '%s' > /sys/kernel/pddf/devices/cpld/i2c_name"%(dev['dev_info']['device_name']) + cmd = "echo '%s' > /sys/kernel/pddf/devices/cpld/i2c_name" % (dev['dev_info']['device_name']) self.runcmd(cmd) - cmd= "echo 'delete' > /sys/kernel/pddf/devices/cpld/dev_ops" + cmd = "echo 'delete' > /sys/kernel/pddf/devices/cpld/dev_ops" self.runcmd(cmd) else: - cmd= "echo 0x%x > /sys/bus/i2c/devices/i2c-%d/delete_device" % (int(dev['i2c']['topo_info']['dev_addr'], 0), - int(dev['i2c']['topo_info']['parent_bus'], 0)) + cmd = "echo 0x%x > /sys/bus/i2c/devices/i2c-%d/delete_device" % ( + int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0)) self.runcmd(cmd) def delete_cpldmux_device(self, dev, ops): if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['CPLDMUX']: - cmd= "echo '%s' > /sys/kernel/pddf/devices/cpldmux/i2c_name"%(dev['dev_info']['device_name']) + cmd = "echo '%s' > /sys/kernel/pddf/devices/cpldmux/i2c_name" % (dev['dev_info']['device_name']) self.runcmd(cmd) - cmd= "echo 'delete' > /sys/kernel/pddf/devices/cpldmux/dev_ops" + cmd = "echo 'delete' > /sys/kernel/pddf/devices/cpldmux/dev_ops" self.runcmd(cmd) def delete_temp_sensor_device(self, dev, ops): # NO PDDF driver for temp_sensors device - cmd= "echo 0x%x > /sys/bus/i2c/devices/i2c-%d/delete_device" % (int(dev['i2c']['topo_info']['dev_addr'], 0), - int(dev['i2c']['topo_info']['parent_bus'], 0)) + cmd = "echo 0x%x > /sys/bus/i2c/devices/i2c-%d/delete_device" % ( + int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0)) self.runcmd(cmd) def delete_fan_device(self, dev, ops): if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['FAN']: - cmd= "echo '%s' > /sys/kernel/pddf/devices/fan/i2c/i2c_name"%(dev['dev_info']['device_name']) + cmd = "echo '%s' > /sys/kernel/pddf/devices/fan/i2c/i2c_name" % (dev['dev_info']['device_name']) self.runcmd(cmd) - cmd= "echo 'delete' > /sys/kernel/pddf/devices/fan/i2c/dev_ops" + cmd = "echo 'delete' > /sys/kernel/pddf/devices/fan/i2c/dev_ops" self.runcmd(cmd) else: - cmd= "echo 0x%x > /sys/bus/i2c/devices/i2c-%d/delete_device" % (int(dev['i2c']['topo_info']['dev_addr'], 0), - int(dev['i2c']['topo_info']['parent_bus'], 0)) + cmd = "echo 0x%x > /sys/bus/i2c/devices/i2c-%d/delete_device" % ( + int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0)) self.runcmd(cmd) def delete_psu_i2c_device(self, dev, ops): if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PSU']: - cmd= "echo '%s' > /sys/kernel/pddf/devices/psu/i2c/i2c_name"%(dev['dev_info']['device_name']) + cmd = "echo '%s' > /sys/kernel/pddf/devices/psu/i2c/i2c_name" % (dev['dev_info']['device_name']) self.runcmd(cmd) cmd = "echo 'delete' > /sys/kernel/pddf/devices/psu/i2c/dev_ops" self.runcmd(cmd) else: - cmd = "echo 0x%x > /sys/bus/i2c/devices/i2c-%d/delete_device" %(int(dev['i2c']['topo_info']['dev_addr'], 0), - int(dev['i2c']['topo_info']['parent_bus'], 0)) + cmd = "echo 0x%x > /sys/bus/i2c/devices/i2c-%d/delete_device" % ( + int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0)) self.runcmd(cmd) def delete_psu_device(self, dev, ops): - self.delete_psu_i2c_device(dev, ops ) - return - + self.delete_psu_i2c_device(dev, ops) + return ################################################################################################################### # SHOW ATTRIBIUTES DEFS ################################################################################################################### def is_led_device_configured(self, device_name, attr_name): if device_name in self.data.keys(): - attr_list=self.data[device_name]['i2c']['attr_list'] + attr_list = self.data[device_name]['i2c']['attr_list'] for attr in attr_list: if attr['attr_name'].strip() == attr_name.strip(): return (True) @@ -560,23 +561,32 @@ def is_led_device_configured(self, device_name, attr_name): def show_device_sysfs(self, dev, ops): - parent=dev['dev_info']['device_parent'] - pdev=self.data[parent] + parent = dev['dev_info']['device_parent'] + pdev = self.data[parent] if pdev['dev_info']['device_parent'] == 'SYSTEM': - return "/sys/bus/i2c/devices/"+"i2c-%d"%int(pdev['i2c']['topo_info']['dev_addr'], 0) + if 'topo_info' in pdev['i2c']: + return "/sys/bus/i2c/devices/"+"i2c-%d"%int(pdev['i2c']['topo_info']['dev_addr'], 0) + else: + return "/sys/bus/i2c/devices" return self.show_device_sysfs(pdev, ops) + "/" + "i2c-%d" % int(dev['i2c']['topo_info']['parent_bus'], 0) + def get_gpio_attr_path(self, dev, offset): + base = int(dev['i2c']['dev_attr']['gpio_base'], 16) + port_num = base + int(offset, 16) + gpio_name = 'gpio'+str(port_num) + path = '/sys/class/gpio/'+gpio_name+'/value' + return path - # This is alid for 'at24' type of EEPROM devices. Only one attribtue 'eeprom' + # 'at24' type of EEPROM devices have only one attribtue 'eeprom' def show_attr_eeprom_device(self, dev, ops): - str = "" - attr_name=ops['attr'] - attr_list=dev['i2c']['attr_list'] - KEY="eeprom" - dsysfs_path="" + ret = [] + attr_name = ops['attr'] + attr_list = dev['i2c']['attr_list'] + KEY = "eeprom" + dsysfs_path = "" - if not KEY in self.data_sysfs_obj: - self.data_sysfs_obj[KEY]=[] + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] for attr in attr_list: if attr_name == attr['attr_name'] or attr_name == 'all': @@ -585,119 +595,134 @@ def show_attr_eeprom_device(self, dev, ops): else: real_name = attr['attr_name'] - dsysfs_path = self.show_device_sysfs(dev, ops)+"/%d-00%x"%(int(dev['i2c']['topo_info']['parent_bus'],0), - int(dev['i2c']['topo_info']['dev_addr'], 0))+"/%s"%real_name - if not dsysfs_path in self.data_sysfs_obj[KEY]: + dsysfs_path = self.show_device_sysfs(dev, ops) + \ + "/%d-00%x" % (int(dev['i2c']['topo_info']['parent_bus'], 0), + int(dev['i2c']['topo_info']['dev_addr'], 0)) + \ + "/%s" % real_name + if dsysfs_path not in self.data_sysfs_obj[KEY]: self.data_sysfs_obj[KEY].append(dsysfs_path) - str += dsysfs_path+"\n" - return str + ret.append(dsysfs_path) + return ret def show_attr_gpio_device(self, dev, ops): - ret = "" - KEY="gpio" - if not KEY in self.data_sysfs_obj: - self.data_sysfs_obj[KEY]=[] + ret = [] + KEY = "gpio" + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] return ret def show_attr_mux_device(self, dev, ops): - ret = "" - KEY="mux" - if not KEY in self.data_sysfs_obj: - self.data_sysfs_obj[KEY]=[] + ret = [] + KEY = "mux" + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] return ret def show_attr_psu_i2c_device(self, dev, ops): - target=ops['target'] - attr_name=ops['attr'] - ret = "" - KEY="psu" - dsysfs_path="" + target = ops['target'] + attr_name = ops['attr'] + ret = [] + KEY = "psu" + dsysfs_path = "" - if not KEY in self.data_sysfs_obj: - self.data_sysfs_obj[KEY]=[] + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] - if target == 'all' or target == dev['dev_info']['virt_parent'] : - attr_list=dev['i2c']['attr_list'] + if target == 'all' or target == dev['dev_info']['virt_parent']: + attr_list = dev['i2c']['attr_list'] if 'i2c' in dev else [] for attr in attr_list: - if attr_name == attr['attr_name'] or attr_name == 'all' : + if attr_name == attr['attr_name'] or attr_name == 'all': if 'attr_devtype' in attr.keys() and attr['attr_devtype'] == "gpio": # Check and enable the gpio from class - gpio_dev = self.data[attr['attr_devname']] - base = int(gpio_dev['i2c']['dev_attr']['gpio_base'], 16) - port_num = base + int(attr['attr_offset'], 16) - gpio_name = 'gpio'+str(port_num) - attr_path = '/sys/class/gpio/'+gpio_name+'/value' + attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], attr['attr_offset']) if (os.path.exists(attr_path)): - if not attr_path in self.data_sysfs_obj[KEY]: + if attr_path not in self.data_sysfs_obj[KEY]: self.data_sysfs_obj[KEY].append(attr_path) - ret += attr_path + '\n' + ret.append(attr_path) else: if 'drv_attr_name' in attr.keys(): real_name = attr['drv_attr_name'] + real_dev = dev + elif 'attr_devattr' in attr.keys(): + real_name = attr['attr_devattr'] + real_devname = attr['attr_devname'] if 'attr_devname' in attr.keys() else '' + real_dev = self.data[real_devname] else: real_name = attr['attr_name'] + real_dev = dev - dsysfs_path = self.show_device_sysfs(dev, ops) + \ - "/%d-00%x"%(int(dev['i2c']['topo_info']['parent_bus'], 0), - int(dev['i2c']['topo_info']['dev_addr'], 0)) + \ - "/%s"%real_name - if not dsysfs_path in self.data_sysfs_obj[KEY]: + dsysfs_path = self.show_device_sysfs(real_dev, ops) + \ + "/%d-00%x" % (int(real_dev['i2c']['topo_info']['parent_bus'], 0), + int(real_dev['i2c']['topo_info']['dev_addr'], 0)) + \ + "/%s" % real_name + if dsysfs_path not in self.data_sysfs_obj[KEY]: self.data_sysfs_obj[KEY].append(dsysfs_path) - ret += dsysfs_path+"\n" + ret.append(dsysfs_path) return ret def show_attr_psu_device(self, dev, ops): - return self.show_attr_psu_i2c_device(dev, ops ) - + return self.show_attr_psu_i2c_device(dev, ops) def show_attr_fan_device(self, dev, ops): - ret_str = "" - attr_name=ops['attr'] - attr_list=dev['i2c']['attr_list'] - KEY="fan" - dsysfs_path="" - - if not KEY in self.data_sysfs_obj: - self.data_sysfs_obj[KEY]=[] + ret = [] + attr_name = ops['attr'] + attr_list = dev['i2c']['attr_list'] if 'i2c' in dev else [] + KEY = "fan" + dsysfs_path = "" + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] for attr in attr_list: if attr_name == attr['attr_name'] or attr_name == 'all': - if 'drv_attr_name' in attr.keys(): - real_name = attr['drv_attr_name'] + if 'attr_devtype' in attr.keys() and attr['attr_devtype'] == "gpio": + # Check and enable the gpio from class + attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], attr['attr_offset']) + if (os.path.exists(attr_path)): + if attr_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(attr_path) + ret.append(attr_path) else: - real_name = attr['attr_name'] - - dsysfs_path= self.show_device_sysfs(dev, ops) + \ - "/%d-00%x" %(int(dev['i2c']['topo_info']['parent_bus'], 0), - int(dev['i2c']['topo_info']['dev_addr'], 0)) + \ - "/%s"%real_name - if not dsysfs_path in self.data_sysfs_obj[KEY]: - self.data_sysfs_obj[KEY].append(dsysfs_path) - ret_str += dsysfs_path+"\n" - return ret_str + if 'drv_attr_name' in attr.keys(): + real_name = attr['drv_attr_name'] + real_dev = dev + elif 'attr_devattr' in attr.keys(): + real_name = attr['attr_devattr'] + real_devname = attr['attr_devname'] if 'attr_devname' in attr.keys() else '' + real_dev = self.data[real_devname] + else: + real_name = attr['attr_name'] + real_dev = dev + + dsysfs_path = self.show_device_sysfs(real_dev, ops) + \ + "/%d-00%x" % (int(real_dev['i2c']['topo_info']['parent_bus'], 0), + int(real_dev['i2c']['topo_info']['dev_addr'], 0)) + \ + "/%s" % real_name + if dsysfs_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(dsysfs_path) + ret.append(dsysfs_path) + return ret # This is only valid for LM75 def show_attr_temp_sensor_device(self, dev, ops): - ret_str = "" - attr_name=ops['attr'] - attr_list=dev['i2c']['attr_list'] - KEY="temp-sensors" - dsysfs_path="" - - if not KEY in self.data_sysfs_obj: - self.data_sysfs_obj[KEY]=[] + ret = [] + attr_name = ops['attr'] + attr_list = dev['i2c']['attr_list'] if 'i2c' in dev else [] + KEY = "temp-sensors" + dsysfs_path = "" + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] for attr in attr_list: if attr_name == attr['attr_name'] or attr_name == 'all': path = self.show_device_sysfs(dev, ops) + \ - "/%d-00%x/" %(int(dev['i2c']['topo_info']['parent_bus'], 0), - int(dev['i2c']['topo_info']['dev_addr'], 0)) + "/%d-00%x/" % (int(dev['i2c']['topo_info']['parent_bus'], 0), + int(dev['i2c']['topo_info']['dev_addr'], 0)) if 'drv_attr_name' in attr.keys(): real_name = attr['drv_attr_name'] else: @@ -705,87 +730,105 @@ def show_attr_temp_sensor_device(self, dev, ops): if (os.path.exists(path)): full_path = glob.glob(path + 'hwmon/hwmon*/' + real_name)[0] - dsysfs_path=full_path - if not dsysfs_path in self.data_sysfs_obj[KEY]: + dsysfs_path = full_path + if dsysfs_path not in self.data_sysfs_obj[KEY]: self.data_sysfs_obj[KEY].append(dsysfs_path) - ret_str += full_path + "\n" - return ret_str + ret.append(full_path) + return ret def show_attr_sysstatus_device(self, dev, ops): - ret = "" - attr_name=ops['attr'] - attr_list=dev['attr_list'] - KEY="sys-status" - dsysfs_path="" - - if not KEY in self.data_sysfs_obj: - self.data_sysfs_obj[KEY]=[] + ret = [] + attr_name = ops['attr'] + attr_list = dev['attr_list'] + KEY = "sys-status" + dsysfs_path = "" + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] for attr in attr_list: - if attr_name == attr['attr_name'] or attr_name == 'all': - dsysfs_path = "/sys/kernel/pddf/devices/sysstatus/sysstatus_data/" + attr['attr_name'] - if not dsysfs_path in self.data_sysfs_obj[KEY]: - self.data_sysfs_obj[KEY].append(dsysfs_path) - ret += dsysfs_path+"\n" + if attr_name == attr['attr_name'] or attr_name == 'all': + dsysfs_path = "/sys/kernel/pddf/devices/sysstatus/sysstatus_data/" + attr['attr_name'] + if dsysfs_path not in self.data_sysfs_obj[KEY]: + self.data_sysfs_obj[KEY].append(dsysfs_path) + ret.append(dsysfs_path) return ret def show_attr_xcvr_i2c_device(self, dev, ops): - target=ops['target'] - attr_name=ops['attr'] - ret = "" + target = ops['target'] + attr_name = ops['attr'] + ret = [] dsysfs_path = "" - KEY="xcvr" - if not KEY in self.data_sysfs_obj: - self.data_sysfs_obj[KEY]=[] + KEY = "xcvr" + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] - if target == 'all' or target == dev['dev_info']['virt_parent'] : - attr_list=dev['i2c']['attr_list'] + if target == 'all' or target == dev['dev_info']['virt_parent']: + attr_list = dev['i2c']['attr_list'] for attr in attr_list: - if attr_name == attr['attr_name'] or attr_name == 'all' : + if attr_name == attr['attr_name'] or attr_name == 'all': if 'attr_devtype' in attr.keys() and attr['attr_devtype'] == "gpio": # Check and enable the gpio from class - gpio_dev = self.data[attr['attr_devname']] - base = int(gpio_dev['i2c']['dev_attr']['gpio_base'], 16) - port_num = base + int(attr['attr_offset'], 16) - gpio_name = 'gpio'+str(port_num) - attr_path = '/sys/class/gpio/'+gpio_name+'/value' + attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], attr['attr_offset']) if (os.path.exists(attr_path)): - if not attr_path in self.data_sysfs_obj[KEY]: + if attr_path not in self.data_sysfs_obj[KEY]: self.data_sysfs_obj[KEY].append(attr_path) - ret += attr_path + '\n' + ret.append(attr_path) else: if 'drv_attr_name' in attr.keys(): real_name = attr['drv_attr_name'] + real_dev = dev + elif 'attr_devattr' in attr.keys(): + real_name = attr['attr_devattr'] + real_devname = attr['attr_devname'] if 'attr_devname' in attr.keys() else '' + real_dev = self.data[real_devname] else: real_name = attr['attr_name'] + real_dev = dev - dsysfs_path = self.show_device_sysfs(dev, ops) + \ - "/%d-00%x" %(int(dev['i2c']['topo_info']['parent_bus'], 0), - int(dev['i2c']['topo_info']['dev_addr'], 0)) + \ - "/%s"%real_name - if not dsysfs_path in self.data_sysfs_obj[KEY]: + dsysfs_path = self.show_device_sysfs(real_dev, ops) + \ + "/%d-00%x" % (int(real_dev['i2c']['topo_info']['parent_bus'], 0), + int(real_dev['i2c']['topo_info']['dev_addr'], 0)) + \ + "/%s" % real_name + if dsysfs_path not in self.data_sysfs_obj[KEY]: self.data_sysfs_obj[KEY].append(dsysfs_path) - ret += dsysfs_path+"\n" + ret.append(dsysfs_path) return ret def show_attr_xcvr_device(self, dev, ops): - return self.show_attr_xcvr_i2c_device(dev, ops ) + return self.show_attr_xcvr_i2c_device(dev, ops) def show_attr_cpld_device(self, dev, ops): - ret = "" - KEY="cpld" - if not KEY in self.data_sysfs_obj: + ret = [] + KEY = "cpld" + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] + + return ret + + def show_attr_fpgai2c_device(self, dev, ops): + ret = [] + KEY="fpgai2c" + if KEY not in self.data_sysfs_obj: self.data_sysfs_obj[KEY]=[] return ret def show_attr_cpldmux_device(self, dev, ops): - ret = "" - KEY="cpldmux" - if not KEY in self.data_sysfs_obj: + ret = [] + KEY = "cpldmux" + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] + + return ret + + + def show_attr_fpgapci_device(self, dev, ops): + ret = [] + KEY="fpgapci" + if KEY not in self.data_sysfs_obj: self.data_sysfs_obj[KEY]=[] return ret @@ -795,25 +838,25 @@ def show_attr_cpldmux_device(self, dev, ops): # SHOW DEFS ################################################################################################################### def check_led_cmds(self, key, ops): - name = ops['target']+'_LED' - if (ops['target']=='config' or ops['attr']=='all') or \ - (name==self.data[key]['dev_info']['device_name'] and - ops['attr']==self.data[key]['dev_attr']['index']): - return (True) - else: - return (False) + name = ops['target']+'_LED' + if (ops['target'] == 'config' or ops['attr'] == 'all') or \ + (name == self.data[key]['dev_info']['device_name'] and + ops['attr'] == self.data[key]['dev_attr']['index']): + return (True) + else: + return (False) def dump_sysfs_obj(self, obj, key_type): - if (key_type == 'keys'): - for key in obj.keys(): - print key - return + if (key_type == 'keys'): + for key in obj.keys(): + print(key) + return - for key in obj: - if (key == key_type or key_type == 'all'): - print key+":" - for entry in obj[key]: - print "\t"+entry + for key in obj: + if (key == key_type or key_type == 'all'): + print(key+":") + for entry in obj[key]: + print("\t"+entry) def add_list_sysfs_obj(self, obj, KEY, list): for sysfs in list: @@ -821,160 +864,153 @@ def add_list_sysfs_obj(self, obj, KEY, list): obj[KEY].append(sysfs) def sysfs_attr(self, key, value, path, obj, obj_key): - sysfs_path="/sys/kernel/%s/%s"%(path, key) - if not sysfs_path in obj[obj_key]: - obj[obj_key].append(sysfs_path) - + sysfs_path = "/sys/kernel/%s/%s" % (path, key) + if not sysfs_path in obj[obj_key]: + obj[obj_key].append(sysfs_path) def sysfs_device(self, attr, path, obj, obj_key): - for key in attr.keys(): - sysfs_path="/sys/kernel/%s/%s"%(path, key) - if not sysfs_path in obj[obj_key]: - obj[obj_key].append(sysfs_path) + for key in attr.keys(): + sysfs_path = "/sys/kernel/%s/%s" % (path, key) + if not sysfs_path in obj[obj_key]: + obj[obj_key].append(sysfs_path) def show_eeprom_device(self, dev, ops): - return - + return def show_mux_device(self, dev, ops): - KEY ='mux' - if not KEY in self.sysfs_obj: - self.sysfs_obj[KEY] = [] - self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/mux", self.sysfs_obj, KEY) - self.sysfs_device(dev['i2c']['dev_attr'], "pddf/devices/mux", self.sysfs_obj, KEY) - sysfs_path= "/sys/kernel/pddf/devices/mux/dev_ops" - if not sysfs_path in self.sysfs_obj[KEY]: - self.sysfs_obj[KEY].append(sysfs_path) - list=['/sys/kernel/pddf/devices/mux/i2c_type', - '/sys/kernel/pddf/devices/mux/i2c_name', - '/sys/kernel/pddf/devices/mux/error'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) + KEY = 'mux' + if not KEY in self.sysfs_obj: + self.sysfs_obj[KEY] = [] + self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/mux", self.sysfs_obj, KEY) + self.sysfs_device(dev['i2c']['dev_attr'], "pddf/devices/mux", self.sysfs_obj, KEY) + sysfs_path = "/sys/kernel/pddf/devices/mux/dev_ops" + if not sysfs_path in self.sysfs_obj[KEY]: + self.sysfs_obj[KEY].append(sysfs_path) + list = ['/sys/kernel/pddf/devices/mux/i2c_type', + '/sys/kernel/pddf/devices/mux/i2c_name', + '/sys/kernel/pddf/devices/mux/error'] + self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) def show_gpio_device(self, dev, ops): - KEY ='gpio' - if not KEY in self.sysfs_obj: - self.sysfs_obj[KEY] = [] - self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/gpio", self.sysfs_obj, KEY) - self.sysfs_device(dev['i2c']['dev_attr'], "pddf/devices/gpio", self.sysfs_obj, KEY) - sysfs_path= "/sys/kernel/pddf/devices/gpio/dev_ops" - if not sysfs_path in self.sysfs_obj[KEY]: - self.sysfs_obj[KEY].append(sysfs_path) - list=['/sys/kernel/pddf/devices/gpio/i2c_type', - '/sys/kernel/pddf/devices/gpio/i2c_name', - '/sys/kernel/pddf/devices/gpio/error'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) - + KEY = 'gpio' + if not KEY in self.sysfs_obj: + self.sysfs_obj[KEY] = [] + self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/gpio", self.sysfs_obj, KEY) + self.sysfs_device(dev['i2c']['dev_attr'], "pddf/devices/gpio", self.sysfs_obj, KEY) + sysfs_path = "/sys/kernel/pddf/devices/gpio/dev_ops" + if not sysfs_path in self.sysfs_obj[KEY]: + self.sysfs_obj[KEY].append(sysfs_path) + list = ['/sys/kernel/pddf/devices/gpio/i2c_type', + '/sys/kernel/pddf/devices/gpio/i2c_name', + '/sys/kernel/pddf/devices/gpio/error'] + self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) def show_psu_i2c_device(self, dev, ops): - KEY ='psu' - path='pddf/devices/psu/i2c' + KEY = 'psu' + path = 'pddf/devices/psu/i2c' if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PSU']: if not KEY in self.sysfs_obj: - self.sysfs_obj[KEY] = [] - self.sysfs_device(dev['i2c']['topo_info'], path, self.sysfs_obj, KEY) - sysfs_path = "/sys/kernel/pddf/devices/psu/i2c/psu_idx" - self.sysfs_obj[KEY].append(sysfs_path) + self.sysfs_obj[KEY] = [] + self.sysfs_device(dev['i2c']['topo_info'], path, self.sysfs_obj, KEY) + sysfs_path = "/sys/kernel/pddf/devices/psu/i2c/psu_idx" + self.sysfs_obj[KEY].append(sysfs_path) - for attr in dev['i2c']['attr_list']: - self.sysfs_device(attr, "pddf/devices/psu/i2c", self.sysfs_obj, KEY) - sysfs_path = "/sys/kernel/pddf/devices/psu/i2c/dev_ops" - if not sysfs_path in self.sysfs_obj[KEY]: - self.sysfs_obj[KEY].append(sysfs_path) - list=['/sys/kernel/pddf/devices/psu/i2c/i2c_type', - '/sys/kernel/pddf/devices/fan/i2c/i2c_name', - '/sys/kernel/pddf/devices/psu/i2c/error', - '/sys/kernel/pddf/devices/psu/i2c/attr_ops'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) + for attr in dev['i2c']['attr_list']: + self.sysfs_device(attr, "pddf/devices/psu/i2c", self.sysfs_obj, KEY) + sysfs_path = "/sys/kernel/pddf/devices/psu/i2c/dev_ops" + if not sysfs_path in self.sysfs_obj[KEY]: + self.sysfs_obj[KEY].append(sysfs_path) + list = ['/sys/kernel/pddf/devices/psu/i2c/i2c_type', + '/sys/kernel/pddf/devices/fan/i2c/i2c_name', + '/sys/kernel/pddf/devices/psu/i2c/error', + '/sys/kernel/pddf/devices/psu/i2c/attr_ops'] + self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) def show_psu_device(self, dev, ops): - self.show_psu_i2c_device(dev, ops ) - return + self.show_psu_i2c_device(dev, ops) + return def show_client_device(self): - KEY ='client' + KEY = 'client' if not KEY in self.sysfs_obj: - self.sysfs_obj[KEY] = [] - list=['/sys/kernel/pddf/devices/showall'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) - + self.sysfs_obj[KEY] = [] + list = ['/sys/kernel/pddf/devices/showall'] + self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) def show_fan_device(self, dev, ops): - KEY ='fan' - path='pddf/devices/fan/i2c' + KEY = 'fan' + path = 'pddf/devices/fan/i2c' if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['FAN']: if not KEY in self.sysfs_obj: - self.sysfs_obj[KEY] = [] - - self.sysfs_device(dev['i2c']['topo_info'], path, self.sysfs_obj, KEY) - self.sysfs_device(dev['i2c']['dev_attr'], path, self.sysfs_obj, KEY) - for attr in dev['i2c']['attr_list']: - self.sysfs_device(attr, path, self.sysfs_obj, KEY) - list=['/sys/kernel/pddf/devices/fan/i2c/i2c_type', - '/sys/kernel/pddf/devices/fan/i2c/i2c_name', - '/sys/kernel/pddf/devices/fan/i2c/error', - '/sys/kernel/pddf/devices/fan/i2c/attr_ops', - '/sys/kernel/pddf/devices/fan/i2c/dev_ops'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) + self.sysfs_obj[KEY] = [] + self.sysfs_device(dev['i2c']['topo_info'], path, self.sysfs_obj, KEY) + self.sysfs_device(dev['i2c']['dev_attr'], path, self.sysfs_obj, KEY) + for attr in dev['i2c']['attr_list']: + self.sysfs_device(attr, path, self.sysfs_obj, KEY) + list = ['/sys/kernel/pddf/devices/fan/i2c/i2c_type', + '/sys/kernel/pddf/devices/fan/i2c/i2c_name', + '/sys/kernel/pddf/devices/fan/i2c/error', + '/sys/kernel/pddf/devices/fan/i2c/attr_ops', + '/sys/kernel/pddf/devices/fan/i2c/dev_ops'] + self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) def show_temp_sensor_device(self, dev, ops): - return + return def show_sysstatus_device(self, dev, ops): - KEY ='sysstatus' + KEY = 'sysstatus' if not KEY in self.sysfs_obj: self.sysfs_obj[KEY] = [] for attr in dev['attr_list']: - self.sysfs_device(attr, "pddf/devices/sysstatus", self.sysfs_obj, KEY) - sysfs_path= "/sys/kernel/pddf/devices/sysstatus/attr_ops" - if not sysfs_path in self.sysfs_obj[KEY]: - self.sysfs_obj[KEY].append(sysfs_path) - + self.sysfs_device(attr, "pddf/devices/sysstatus", self.sysfs_obj, KEY) + sysfs_path = "/sys/kernel/pddf/devices/sysstatus/attr_ops" + if not sysfs_path in self.sysfs_obj[KEY]: + self.sysfs_obj[KEY].append(sysfs_path) def show_xcvr_i2c_device(self, dev, ops): - KEY ='xcvr' + KEY = 'xcvr' if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PORT_MODULE']: if not KEY in self.sysfs_obj: - self.sysfs_obj[KEY] = [] - self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/xcvr/i2c", self.sysfs_obj, KEY) - - for attr in dev['i2c']['attr_list']: - self.sysfs_device(attr, "pddf/devices/xcvr/i2c", self.sysfs_obj, KEY) - sysfs_path = "/sys/kernel/pddf/devices/xcvr/i2c/dev_ops" - if not sysfs_path in self.sysfs_obj[KEY]: - self.sysfs_obj[KEY].append(sysfs_path) - list=['/sys/kernel/pddf/devices/xcvr/i2c/i2c_type', - '/sys/kernel/pddf/devices/xcvr/i2c/i2c_name', - '/sys/kernel/pddf/devices/xcvr/i2c/error', - '/sys/kernel/pddf/devices/xcvr/i2c/attr_ops'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) + self.sysfs_obj[KEY] = [] + self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/xcvr/i2c", self.sysfs_obj, KEY) + for attr in dev['i2c']['attr_list']: + self.sysfs_device(attr, "pddf/devices/xcvr/i2c", self.sysfs_obj, KEY) + sysfs_path = "/sys/kernel/pddf/devices/xcvr/i2c/dev_ops" + if not sysfs_path in self.sysfs_obj[KEY]: + self.sysfs_obj[KEY].append(sysfs_path) + list = ['/sys/kernel/pddf/devices/xcvr/i2c/i2c_type', + '/sys/kernel/pddf/devices/xcvr/i2c/i2c_name', + '/sys/kernel/pddf/devices/xcvr/i2c/error', + '/sys/kernel/pddf/devices/xcvr/i2c/attr_ops'] + self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) def show_xcvr_device(self, dev, ops): - self.show_xcvr_i2c_device(dev, ops ) - return + self.show_xcvr_i2c_device(dev, ops) + return def show_cpld_device(self, dev, ops): - KEY ='cpld' + KEY = 'cpld' if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['CPLD']: if not KEY in self.sysfs_obj: - self.sysfs_obj[KEY] = [] - self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/cpld", self.sysfs_obj, KEY) - sysfs_path= "/sys/kernel/pddf/devices/cpld/dev_ops" - if not sysfs_path in self.sysfs_obj[KEY]: - self.sysfs_obj[KEY].append(sysfs_path) - list=['/sys/kernel/pddf/devices/cpld/i2c_type', - '/sys/kernel/pddf/devices/cpld/i2c_name', - '/sys/kernel/pddf/devices/cpld/error'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) + self.sysfs_obj[KEY] = [] + self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/cpld", self.sysfs_obj, KEY) + sysfs_path = "/sys/kernel/pddf/devices/cpld/dev_ops" + if not sysfs_path in self.sysfs_obj[KEY]: + self.sysfs_obj[KEY].append(sysfs_path) + list = ['/sys/kernel/pddf/devices/cpld/i2c_type', + '/sys/kernel/pddf/devices/cpld/i2c_name', + '/sys/kernel/pddf/devices/cpld/error'] + self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) def show_led_platform_device(self, key, ops): - if ops['attr']=='all' or ops['attr']=='PLATFORM': - KEY='platform' + if ops['attr'] == 'all' or ops['attr'] == 'PLATFORM': + KEY = 'platform' if not KEY in self.sysfs_obj: self.sysfs_obj[KEY] = [] - path='pddf/devices/platform' + path = 'pddf/devices/platform' self.sysfs_attr('num_psus', self.data['PLATFORM']['num_psus'], path, self.sysfs_obj, KEY) self.sysfs_attr('num_fantrays', self.data['PLATFORM']['num_fantrays'], path, self.sysfs_obj, KEY) @@ -991,7 +1027,7 @@ def show_led_device(self, key, ops): path,self.sysfs_obj, KEY) self.sysfs_device(self.data[key]['dev_attr'], path, self.sysfs_obj, KEY) for attr_key in attr.keys(): - attr_path="pddf/devices/led/" + attr['attr_name'] + attr_path = "pddf/devices/led/" + attr['attr_name'] if (attr_key != 'attr_name' and attr_key != 'swpld_addr' and attr_key != 'swpld_addr_offset'): self.sysfs_attr(attr_key, attr[attr_key], attr_path, self.sysfs_obj, KEY) sysfs_path="/sys/kernel/pddf/devices/led/dev_ops" @@ -1011,7 +1047,7 @@ def validate_xcvr_device(self, dev, ops): if 'attr_name' in attr.keys() and 'eeprom' in attr.values(): ret_val = "xcvr validation success" else: - print "xcvr validation Failed" + print("xcvr validation Failed") return elif dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PORT_MODULE']: @@ -1019,9 +1055,9 @@ def validate_xcvr_device(self, dev, ops): if attr.get("attr_name") in dev_attribs: ret_val = "Success" else: - print "xcvr validation Failed" + print("xcvr validation Failed") return - print ret_val + print(ret_val) def validate_eeprom_device(self, dev, ops): devtype_list = ['24c02'] @@ -1034,7 +1070,7 @@ def validate_eeprom_device(self, dev, ops): for attr in dev['i2c']['attr_list']: if attr.get("attr_name") in dev_attribs: ret_val = "eeprom success" - print ret_val + print(ret_val) def validate_mux_device(self, dev, ops): devtype_list = ['pca9548', 'pca954x'] @@ -1045,7 +1081,7 @@ def validate_mux_device(self, dev, ops): for attr in dev['i2c']['channel']: if attr.get("chn") in dev_channels: ret_val = "Mux success" - print ret_val + print(ret_val) def validate_cpld_device(self, dev, ops): devtype_list = ['i2c_cpld'] @@ -1053,20 +1089,20 @@ def validate_cpld_device(self, dev, ops): if dev['i2c']['topo_info']['dev_type'] in devtype_list: ret_val = "cpld success" - print ret_val + print(ret_val) def validate_sysstatus_device(self, dev, ops): dev_attribs = ['board_info', 'cpld1_version', 'power_module_status', 'system_reset5', - 'system_reset6', 'system_reset7', 'misc1', 'cpld2_version', 'cpld3_version' - ] + 'system_reset6', 'system_reset7', 'misc1', 'cpld2_version', 'cpld3_version' + ] ret_val = "sysstatus failed" if dev['dev_info']['device_type'] == "SYSSTAT": - for attr in dev['attr_list']: - if attr.get("attr_name") in dev_attribs: - ret_val = "sysstatus success" - print ret_val + for attr in dev['attr_list']: + if attr.get("attr_name") in dev_attribs: + ret_val = "sysstatus success" + print(ret_val) def validate_temp_sensor_device(self, dev, ops): devtype_list = ['lm75'] @@ -1078,21 +1114,21 @@ def validate_temp_sensor_device(self, dev, ops): for attr in dev['i2c']['attr_list']: if attr.get("attr_name") in dev_attribs: ret_val = "tempsensor success" - print ret_val + print(ret_val) def validate_fan_device(self, dev, ops): ret_val = "fan failed" if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['FAN']: - if dev['i2c']['dev_attr']['num_fan'] is not None: + if dev['i2c']['dev_attr']['num_fantrays'] is not None: ret_val = "fan success" - print ret_val + print(ret_val) def validate_psu_device(self, dev, ops): dev_attribs = ['psu_present', 'psu_model_name', 'psu_power_good', 'psu_mfr_id', 'psu_serial_num', - 'psu_fan_dir', 'psu_v_out', 'psu_i_out', 'psu_p_out', 'psu_fan1_speed_rpm' - ] + 'psu_fan_dir', 'psu_v_out', 'psu_i_out', 'psu_p_out', 'psu_fan1_speed_rpm' + ] ret_val = "psu failed" if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PSU']: @@ -1102,167 +1138,167 @@ def validate_psu_device(self, dev, ops): if attr.get("attr_offset") is not None: if attr.get("attr_mask") is not None: if attr.get("attr_len") is not None: - ret_val = "psu success" + ret_val = "psu success" else: ret_val = "psu failed" - print ret_val + print(ret_val) ################################################################################################################### # SPYTEST ################################################################################################################### def verify_attr(self, key, attr, path): - node="/sys/kernel/%s/%s"%(path, key) - try: - with open(node, 'r') as f: - status = f.read() - except IOError: - print "PDDF_VERIFY_ERR: IOError: node:%s key:%s"%(node, key) - return + node = "/sys/kernel/%s/%s" % (path, key) + try: + with open(node, 'r') as f: + status = f.read() + except IOError: + print("PDDF_VERIFY_ERR: IOError: node:%s key:%s" % (node, key)) + return - status=status.rstrip("\n\r") - if attr[key]!=status: - print "PDDF_VERIFY_ERR: node: %s switch:%s"%(node, status) + status = status.rstrip("\n\r") + if attr[key] != status: + print("PDDF_VERIFY_ERR: node: %s switch:%s" % (node, status)) def verify_device(self, attr, path, ops): - for key in attr.keys(): - self.verify_attr(key, attr, path) - + for key in attr.keys(): + self.verify_attr(key, attr, path) def get_led_device(self, device_name): self.create_attr('device_name', self.data[device_name]['dev_info']['device_name'], "pddf/devices/led") self.create_attr('index', self.data[device_name]['dev_attr']['index'], "pddf/devices/led") - cmd="echo 'verify' > /sys/kernel/pddf/devices/led/dev_ops" + cmd = "echo 'verify' > /sys/kernel/pddf/devices/led/dev_ops" self.runcmd(cmd) def validate_sysfs_creation(self, obj, validate_type): - dir = '/sys/kernel/pddf/devices/'+validate_type - if (os.path.exists(dir) or validate_type=='client'): - for sysfs in obj[validate_type]: - if(not os.path.exists(sysfs)): - print "[SYSFS FILE] " + sysfs + ": does not exist" - else: - print "[SYSFS DIR] " + dir + ": does not exist" + dir = '/sys/kernel/pddf/devices/'+validate_type + if (os.path.exists(dir) or validate_type == 'client'): + for sysfs in obj[validate_type]: + if(not os.path.exists(sysfs)): + print("[SYSFS FILE] " + sysfs + ": does not exist") + else: + print("[SYSFS DIR] " + dir + ": does not exist") def validate_dsysfs_creation(self, obj, validate_type): if validate_type in obj.keys(): # There is a possibility that some components dont have any device-self.data attr if not obj[validate_type]: - print "[SYSFS ATTR] for " + validate_type + ": empty " + print("[SYSFS ATTR] for " + validate_type + ": empty ") else: - for sysfs in obj[validate_type]: - if(not os.path.exists(sysfs)): - print "[SYSFS FILE] " + sysfs + ": does not exist" + for sysfs in obj[validate_type]: + if(not os.path.exists(sysfs)): + print("[SYSFS FILE] " + sysfs + ": does not exist") else: - print "[SYSFS KEY] for " + validate_type + ": not configured" + print("[SYSFS KEY] for " + validate_type + ": not configured") def verify_sysfs_data(self, verify_type): - if (verify_type=='LED'): + if (verify_type == 'LED'): for key in self.data.keys(): if key != 'PLATFORM': - attr=self.data[key]['dev_info'] + attr = self.data[key]['dev_info'] if attr['device_type'] == 'LED': self.get_led_device(key) self.verify_attr('device_name', self.data[key]['dev_info'], "pddf/devices/led") self.verify_attr('index', self.data[key]['dev_attr'], "pddf/devices/led") for attr in self.data[key]['i2c']['attr_list']: - path="pddf/devices/led/" + attr['attr_name'] + path = "pddf/devices/led/" + attr['attr_name'] for entry in attr.keys(): if (entry != 'attr_name' and entry != 'swpld_addr' and entry != 'swpld_addr_offset'): - self.verify_attr(entry, attr, path) - if ( entry == 'swpld_addr' or entry == 'swpld_addr_offset'): - self.verify_attr(entry, attr, 'pddf/devices/led') + self.verify_attr(entry, attr, path) + if (entry == 'swpld_addr' or entry == 'swpld_addr_offset'): + self.verify_attr(entry, attr, 'pddf/devices/led') def schema_validation(self, validate_type): - process_validate_type = 0 - for key in self.data.keys(): - if (key != 'PLATFORM'): - temp_obj={} - schema_list=[] + process_validate_type = 0 + for key in self.data.keys(): + if (key != 'PLATFORM'): + temp_obj = {} + schema_list = [] + try: + device_type = self.data[key]["dev_info"]["device_type"] + except Exception as e: + print("dev_info or device_type ERROR: " + key) + print(e) + + if validate_type == 'mismatch': + process_validate_type = 1 + device_type = "PSU" + schema_file = "/usr/local/bin/schema/FAN.schema" + schema_list.append(schema_file) + elif validate_type == 'missing': + process_validate_type = 1 + schema_file = "/usr/local/bin/schema/PLATFORM.schema" + schema_list.append(schema_file) + + elif validate_type == 'empty': + process_validate_type = 1 + if not device_type: + print("Empty device_type for " + key) + continue + elif (validate_type == 'all' or validate_type == device_type): + process_validate_type = 1 + if "bmc" in self.data[key].keys(): + schema_file = "/usr/local/bin/schema/"+device_type + "_BMC.schema" + schema_list.append(schema_file) + + if "i2c" in self.data[key].keys(): + schema_file = "/usr/local/bin/schema/"+device_type + ".schema" + schema_list.append(schema_file) + if device_type: + temp_obj[device_type] = self.data[key] + for schema_file in schema_list: + if (os.path.exists(schema_file)): + print("Validate " + schema_file + ";" + key) + json_data = json.dumps(temp_obj) + with open(schema_file, 'r') as f: + schema = json.load(f) try: - device_type=self.data[key]["dev_info"]["device_type"] + from jsonschema import validate + validate(temp_obj, schema) except Exception as e: - print "dev_info or device_type ERROR: " + key - print e - - if validate_type == 'mismatch': - process_validate_type = 1 - device_type="PSU" - schema_file="/usr/local/bin/schema/FAN.schema" - schema_list.append(schema_file) - elif validate_type == 'missing': - process_validate_type = 1 - schema_file="/usr/local/bin/schema/PLATFORM.schema" - schema_list.append(schema_file) - - elif validate_type == 'empty': - process_validate_type = 1 - if not device_type: - print "Empty device_type for " + key - continue - elif (validate_type=='all' or validate_type==device_type): - process_validate_type = 1 - if "bmc" in self.data[key].keys(): - schema_file="/usr/local/bin/schema/"+device_type + "_BMC.schema" - schema_list.append(schema_file) - - if "i2c" in self.data[key].keys(): - schema_file="/usr/local/bin/schema/"+device_type + ".schema" - schema_list.append(schema_file) - if device_type: - temp_obj[device_type]=self.data[key] - for schema_file in schema_list: - if (os.path.exists(schema_file)): - print "Validate " + schema_file + ";" + key - json_data=json.dumps(temp_obj) - with open(schema_file, 'r') as f: - schema=json.load(f) - try: - validate(temp_obj, schema) - except Exception as e: - print "Validation ERROR: " + schema_file + ";" + key - if validate_type == 'mismatch': - return - else: - print e - else: - print "ERROR Missing File: " + schema_file - if not process_validate_type: - print "device_type: " + validate_type + " not configured" + print("Validation ERROR: " + schema_file + ";" + key) + if validate_type == 'mismatch': + return + else: + print(e) + else: + print("ERROR Missing File: " + schema_file) + if not process_validate_type: + print("device_type: " + validate_type + " not configured") def modules_validation(self, validate_type): kos = [] supported_type = False - module_validation_status=[] + module_validation_status = [] - if validate_type == "bmc": - kos=['ipmi_devintf', 'ipmi_si', 'ipmi_msghandler'] - validate_type = 'ipmi' + if validate_type == "bmc": + kos = ['ipmi_devintf', 'ipmi_si', 'ipmi_msghandler'] + validate_type = 'ipmi' else: - # generate the KOS list from pddf device JSON file - kos.extend(self.data['PLATFORM']['pddf_kos']) + # generate the KOS list from pddf device JSON file + kos.extend(self.data['PLATFORM']['pddf_kos']) - if 'custom_kos' in self.data['PLATFORM']: - kos.extend(self.data['PLATFORM']['custom_kos']) + if 'custom_kos' in self.data['PLATFORM']: + kos.extend(self.data['PLATFORM']['custom_kos']) for mod in kos: if validate_type in mod or validate_type == "pddf": - supported_type=True - cmd = "lsmod | grep " + mod - try: - subprocess.check_output(cmd, shell=True) - except Exception as e: - module_validation_status.append(mod) + supported_type = True + cmd = "lsmod | grep " + mod + try: + subprocess.check_output(cmd, shell=True) + except Exception as e: + module_validation_status.append(mod) if supported_type: if module_validation_status: - module_validation_status.append(":ERROR not loaded") - print str(module_validation_status)[1:-1] + module_validation_status.append(":ERROR not loaded") + print(str(module_validation_status)[1:-1]) else: - print "Loaded" + print("Loaded") else: - print validate_type + " not configured" + print(validate_type + " not configured" ) @@ -1272,428 +1308,386 @@ def modules_validation(self, validate_type): # PARSE DEFS ################################################################################################################### def psu_parse(self, dev, ops): - parse_str="" - ret="" - for ifce in dev['i2c']['interface']: - ret=getattr(self, ops['cmd']+"_psu_device")(self.data[ifce['dev']], ops ) - if not ret is None: - if str(ret).isdigit(): - if ret!=0: + ret = [] + for ifce in (dev['i2c']['interface'] if 'i2c' in dev else []): + val = getattr(self, ops['cmd']+"_psu_device")(self.data[ifce['dev']], ops) + if val: + if str(val[0]).isdigit(): + if val[0] != 0: # in case if 'create' functions - print "{}_psu_device failed".format(ops['cmd']) - return ret - else: - pass + print("{}_psu_device failed for {}".format(ops['cmd'], ifce['dev'])) + return val else: # in case of 'show_attr' functions - parse_str+=ret - return parse_str + ret.extend(val) + return ret def fan_parse(self, dev, ops): - parse_str="" - ret=getattr(self, ops['cmd']+"_fan_device")(dev, ops ) - if not ret is None: - if str(ret).isdigit(): - if ret!=0: + ret = [] + ret = getattr(self, ops['cmd']+"_fan_device")(dev, ops) + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print "{}_fan_device failed".format(ops['cmd']) - return ret - else: - pass - else: - # in case of 'show_attr' functions - parse_str+=ret + print("{}_fan_device failed for {}".format(ops['cmd'], dev['dev_info']['device_name'])) - return parse_str + return ret def temp_sensor_parse(self, dev, ops): - parse_str="" - ret=getattr(self, ops['cmd']+"_temp_sensor_device")(dev, ops ) - if not ret is None: - if str(ret).isdigit() : - if ret!=0: + ret = [] + ret = getattr(self, ops['cmd']+"_temp_sensor_device")(dev, ops) + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print "{}_temp_sensor_device failed".format(ops['cmd']) - return ret - else: - pass - else: - # in case of 'show_attr' functions - parse_str+=ret + print("{}_temp_sensor_device failed for {}".format(ops['cmd'], dev['dev_info']['device_name'])) - return parse_str + return ret def cpld_parse(self, dev, ops): - parse_str = "" + ret = [] ret = getattr(self, ops['cmd']+"_cpld_device")(dev, ops) - if not ret is None: - if str(ret).isdigit(): - if ret!=0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print "{}_cpld_device failed".format(ops['cmd']) + print("{}_cpld_device failed for {}".format(ops['cmd'], dev['dev_info']['device_name'])) + + return ret + + def fpgai2c_parse(self, dev, ops): + val = [] + ret = getattr(self, ops['cmd']+"_fpgai2c_device")(dev, ops) + if ret: + if str(ret[0]).isdigit(): + if ret[0]!=0: + # in case if 'create' functions + print("{}_fpgai2c_device failed".format(ops['cmd'])) return ret - else: - pass else: # in case of 'show_attr' functions - parse_str+=ret + val.extend(ret) - return parse_str + return val def cpldmux_parse(self, dev, ops): - parse_str = "" + val = [] ret = getattr(self, ops['cmd']+"_cpldmux_device")(dev, ops) - if not ret is None: - if str(ret).isdigit(): - if ret!=0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print "{}_cpldmux_device() cmd failed".format(ops['cmd']) + print("{}_cpldmux_device() cmd failed".format(ops['cmd'])) return ret - else: - pass else: - parse_str += ret + val.extend(ret) for chan in dev['i2c']['channel']: for device in chan['dev']: - ret = self.dev_parse(self.data[device], ops) - if not ret is None: - if str(ret).isdigit(): - if ret!=0: + ret = self.dev_parse(self.data[device], ops) + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions return ret - else: - pass else: - parse_str += ret + val.extend(ret) - return parse_str + return val def cpldmux_parse_reverse(self, dev, ops): - parse_str = "" + val = [] for chan in reversed(dev['i2c']['channel']): for device in reversed(chan['dev']): - ret = self.dev_parse(self.data[device], ops) - if not ret is None: - if str(ret).isdigit(): - if ret!=0: + ret = self.dev_parse(self.data[device], ops) + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions return ret - else: - pass else: - parse_str += ret + val.extend(ret) ret = getattr(self, ops['cmd']+"_cpldmux_device")(dev, ops) - if not ret is None: - if str(ret).isdigit(): - if ret!=0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print "{}_cpldmux_device() cmd failed".format(ops['cmd']) + print("{}_cpldmux_device() cmd failed".format(ops['cmd'])) return ret - else: - pass else: - parse_str += ret - - return parse_str + val.extend(ret) + return val - def sysstatus_parse(self, dev,ops): - parse_str = "" + def sysstatus_parse(self, dev, ops): + ret = [] ret = getattr(self, ops['cmd']+"_sysstatus_device")(dev, ops) - if not ret is None: - if str(ret).isdigit(): - if ret!=0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print "{}_sysstatus_device failed".format(ops['cmd']) - return ret - else: - pass - else: - # in case of 'show_attr' functions - parse_str+=ret + print("{}_sysstatus_device failed for {}".format(ops['cmd'], dev['dev_info']['device_name'])) - return parse_str + return ret def gpio_parse(self, dev, ops): - parse_str = "" + ret = [] ret = getattr(self, ops['cmd']+"_gpio_device")(dev, ops) - if not ret is None: - if str(ret).isdigit(): - if ret!=0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print "{}_temp_sensor_device failed".format(ops['cmd']) - return ret - else: - pass - else: - # in case of 'show_attr' functions - parse_str += ret - - return parse_str + print("{}_gpio_device failed for {}".format(ops['cmd'], dev['dev_info']['device_name'])) + return ret def mux_parse(self, dev, ops): - parse_str = "" + val = [] ret = getattr(self, ops['cmd']+"_mux_device")(dev, ops) - if not ret is None: - if str(ret).isdigit(): - if ret!=0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print "{}_mux_device() cmd failed".format(ops['cmd']) + print("{}_mux_device() cmd failed for {}".format(ops['cmd'], dev['dev_info']['device_name'])) return ret - else: - pass else: - parse_str += ret + val.extend(ret) for ch in dev['i2c']['channel']: - ret = self.dev_parse(self.data[ch['dev']], ops) - if not ret is None: - if str(ret).isdigit(): - if ret!=0: + ret = self.dev_parse(self.data[ch['dev']], ops) + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions return ret - else: - pass else: - parse_str += ret - return parse_str + val.extend(ret) + return val def mux_parse_reverse(self, dev, ops): - parse_str = "" + val = [] for ch in reversed(dev['i2c']['channel']): - ret = self.dev_parse(self.data[ch['dev']], ops) - if not ret is None: - if str(ret).isdigit(): - if ret!=0: + ret = self.dev_parse(self.data[ch['dev']], ops) + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions return ret - else: - pass else: - parse_str += ret + val.extend(ret) ret = getattr(self, ops['cmd']+"_mux_device")(dev, ops) - if not ret is None: - if str(ret).isdigit(): - if ret!=0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print "{}_mux_device() cmd failed".format(ops['cmd']) + print("{}_mux_device() cmd failed for {}".format(ops['cmd'], dev['dev_info']['device_name'])) return ret - else: - pass else: - parse_str += ret - - return parse_str + val.extend(ret) + return val def eeprom_parse(self, dev, ops): - parse_str = "" + ret = [] ret = getattr(self, ops['cmd']+"_eeprom_device")(dev, ops) - if not ret is None: - if str(ret).isdigit(): - if ret!=0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print "{}_eeprom_device() cmd failed".format(ops['cmd']) - return ret - else: - pass - else: - parse_str += ret + print("{}_eeprom_device() cmd failed for {}".format(ops['cmd'], dev['dev_info']['device_name'])) - return parse_str + return ret def optic_parse(self, dev, ops): - parse_str="" - ret="" + val = [] for ifce in dev['i2c']['interface']: - ret=getattr(self, ops['cmd']+"_xcvr_device")(self.data[ifce['dev']], ops ) - if not ret is None: - if str(ret).isdigit(): - if ret!=0: + ret = getattr(self, ops['cmd']+"_xcvr_device")(self.data[ifce['dev']], ops) + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print "{}_eeprom_device() cmd failed".format(ops['cmd']) + print("{}_xcvr_device() cmd failed for {}".format(ops['cmd'], ifce['dev'])) return ret - else: - pass else: - parse_str+=ret - return parse_str + val.extend(ret) + return val def cpu_parse(self, bus, ops): - parse_str = "" + val = [] for dev in bus['i2c']['CONTROLLERS']: dev1 = self.data[dev['dev']] for d in dev1['i2c']['DEVICES']: - ret=self.dev_parse(self.data[d['dev']], ops) - if not ret is None: - if str(ret).isdigit(): - if ret!=0: + ret = self.dev_parse(self.data[d['dev']], ops) + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions return ret - else: - pass else: - parse_str += ret - return parse_str + val.extend(ret) + return val def cpu_parse_reverse(self, bus, ops): - parse_str = "" + val = [] for dev in reversed(bus['i2c']['CONTROLLERS']): dev1 = self.data[dev['dev']] for d in reversed(dev1['i2c']['DEVICES']): - ret=self.dev_parse(self.data[d['dev']], ops) - if not ret is None: - if str(ret).isdigit(): - if ret!=0: + ret = self.dev_parse(self.data[d['dev']], ops) + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions return ret - else: - pass else: - parse_str += ret - return parse_str + val.extend(ret) + return val + + # 'create' and 'show_attr' ops returns an array + # 'delete', 'show' and 'validate' ops return None def dev_parse(self, dev, ops): - attr=dev['dev_info'] - if attr['device_type'] == 'CPU': - if ops['cmd']=='delete': - return self.cpu_parse_reverse(dev, ops) - else: - return self.cpu_parse(dev, ops) + attr=dev['dev_info'] + if attr['device_type'] == 'CPU': + if ops['cmd']=='delete': + return self.cpu_parse_reverse(dev, ops) + else: + return self.cpu_parse(dev, ops) - if attr['device_type'] == 'EEPROM': - return self.eeprom_parse(dev, ops) + if attr['device_type'] == 'EEPROM': + return self.eeprom_parse(dev, ops) - if attr['device_type'] == 'MUX': - if ops['cmd']=='delete': - return self.mux_parse_reverse(dev, ops) - else: - return self.mux_parse(dev, ops) + if attr['device_type'] == 'MUX': + if ops['cmd']=='delete': + return self.mux_parse_reverse(dev, ops) + else: + return self.mux_parse(dev, ops) - if attr['device_type'] == 'GPIO': - return self.gpio_parse(dev, ops) + if attr['device_type'] == 'GPIO': + return self.gpio_parse(dev, ops) - if attr['device_type'] == 'PSU': - return self.psu_parse(dev, ops) + if attr['device_type'] == 'PSU': + return self.psu_parse(dev, ops) - if attr['device_type'] == 'FAN': - return self.fan_parse(dev, ops) + if attr['device_type'] == 'FAN': + return self.fan_parse(dev, ops) - if attr['device_type'] == 'TEMP_SENSOR': - return self.temp_sensor_parse(dev, ops) + if attr['device_type'] == 'TEMP_SENSOR': + return self.temp_sensor_parse(dev, ops) - if attr['device_type'] == 'SFP' or attr['device_type'] == 'SFP28' or \ - attr['device_type'] == 'QSFP' or attr['device_type'] == 'QSFP28': - return self.optic_parse(dev, ops) + if attr['device_type'] == 'SFP' or attr['device_type'] == 'SFP+' or attr['device_type'] == 'SFP28' or \ + attr['device_type'] == 'QSFP' or attr['device_type'] == 'QSFP+' or attr['device_type'] == 'QSFP28' or \ + attr['device_type'] == 'QSFP-DD': + return self.optic_parse(dev, ops) - if attr['device_type'] == 'CPLD': - return self.cpld_parse(dev, ops) + if attr['device_type'] == 'CPLD': + return self.cpld_parse(dev, ops) - if attr['device_type'] == 'CPLDMUX': - if ops['cmd']=='delete': - return self.cpldmux_parse_reverse(dev, ops) - else: - return self.cpldmux_parse(dev, ops) + if attr['device_type'] == 'CPLDMUX': + if ops['cmd'] == 'delete': + return self.cpldmux_parse_reverse(dev, ops) + else: + return self.cpldmux_parse(dev, ops) - if attr['device_type'] == 'SYSSTAT': - return self.sysstatus_parse(dev,ops) + if attr['device_type'] == 'SYSSTAT': + return self.sysstatus_parse(dev, ops) def is_supported_sysled_state(self, sysled_name, sysled_state): - if not sysled_name in self.data.keys(): - return False, "[FAILED] " + sysled_name + " is not configured" - for attr in self.data[sysled_name]['i2c']['attr_list']: - if attr['attr_name'] == sysled_state: - return True, "[PASS] supported" - return False, "[FAILED]: Invalid color" + if not sysled_name in self.data.keys(): + return False, "[FAILED] " + sysled_name + " is not configured" + for attr in self.data[sysled_name]['i2c']['attr_list']: + if attr['attr_name'] == sysled_state: + return True, "[PASS] supported" + return False, "[FAILED]: Invalid color" def create_attr(self, key, value, path): - cmd = "echo '%s' > /sys/kernel/%s/%s"%(value, path, key) - self.runcmd(cmd) + cmd = "echo '%s' > /sys/kernel/%s/%s" % (value, path, key) + self.runcmd(cmd) def create_led_platform_device(self, key, ops): - if ops['attr']=='all' or ops['attr']=='PLATFORM': - path='pddf/devices/platform' - self.create_attr('num_psus', self.data['PLATFORM']['num_psus'], path) - self.create_attr('num_fantrays', self.data['PLATFORM']['num_fantrays'], path) + if ops['attr'] == 'all' or ops['attr'] == 'PLATFORM': + path = 'pddf/devices/platform' + self.create_attr('num_psus', self.data['PLATFORM']['num_psus'], path) + self.create_attr('num_fantrays', self.data['PLATFORM']['num_fantrays'], path) def create_led_device(self, key, ops): - if ops['attr']=='all' or ops['attr']==self.data[key]['dev_info']['device_name']: - path="pddf/devices/led" - for attr in self.data[key]['i2c']['attr_list']: - self.create_attr('device_name', self.data[key]['dev_info']['device_name'], path) - self.create_device(self.data[key]['dev_attr'], path, ops) - for attr_key in attr.keys(): - if (attr_key == 'swpld_addr_offset' or attr_key == 'swpld_addr'): - self.create_attr(attr_key, attr[attr_key], path) - elif (attr_key != 'attr_name' and attr_key != 'descr' and - attr_key != 'attr_devtype' and attr_key != 'attr_devname'): - state_path=path+'/state_attr' - self.create_attr(attr_key, attr[attr_key],state_path) - cmd="echo '" + attr['attr_name']+"' > /sys/kernel/pddf/devices/led/dev_ops" - self.runcmd(cmd) + if ops['attr']=='all' or ops['attr']==self.data[key]['dev_info']['device_name']: + path="pddf/devices/led" + for attr in self.data[key]['i2c']['attr_list']: + self.create_attr('device_name', self.data[key]['dev_info']['device_name'], path) + self.create_device(self.data[key]['dev_attr'], path, ops) + for attr_key in attr.keys(): + if (attr_key == 'swpld_addr_offset' or attr_key == 'swpld_addr'): + self.create_attr(attr_key, attr[attr_key], path) + elif (attr_key != 'attr_name' and attr_key != 'descr' and + attr_key != 'attr_devtype' and attr_key != 'attr_devname'): + state_path=path+'/state_attr' + self.create_attr(attr_key, attr[attr_key],state_path) + cmd="echo '" + attr['attr_name']+"' > /sys/kernel/pddf/devices/led/dev_ops" + self.runcmd(cmd) def led_parse(self, ops): - getattr(self, ops['cmd']+"_led_platform_device")("PLATFORM", ops) - for key in self.data.keys(): - if key != 'PLATFORM' and 'dev_info' in self.data[key]: - attr=self.data[key]['dev_info'] - if attr['device_type'] == 'LED': - getattr(self, ops['cmd']+"_led_device")(key, ops) + getattr(self, ops['cmd']+"_led_platform_device")("PLATFORM", ops) + for key in self.data.keys(): + if key != 'PLATFORM' and 'dev_info' in self.data[key]: + attr = self.data[key]['dev_info'] + if attr['device_type'] == 'LED': + getattr(self, ops['cmd']+"_led_device")(key, ops) def get_device_list(self, list, type): - for key in self.data.keys(): - if key != 'PLATFORM' and 'dev_info' in self.data[key]: - attr=self.data[key]['dev_info'] - if attr['device_type'] == type: - list.append(self.data[key]) + for key in self.data.keys(): + if key != 'PLATFORM' and 'dev_info' in self.data[key]: + attr = self.data[key]['dev_info'] + if attr['device_type'] == type: + list.append(self.data[key]) def create_pddf_devices(self): - self.led_parse({ "cmd": "create", "target":"all", "attr":"all" }) + self.led_parse({"cmd": "create", "target": "all", "attr": "all"}) create_ret = 0 - create_ret = self.dev_parse(self.data['SYSTEM'], { "cmd": "create", "target":"all", "attr":"all" } ) - if create_ret!=0: - return create_ret + ret = self.dev_parse(self.data['SYSTEM'], {"cmd": "create", "target": "all", "attr": "all"}) + if ret: + if ret[0] != 0: + return ret[0] if 'SYSSTATUS' in self.data: - create_ret = self.dev_parse(self.data['SYSSTATUS'], { "cmd": "create", "target":"all", "attr":"all" } ) - if create_ret!=0: - return create_ret - + ret = self.dev_parse(self.data['SYSSTATUS'], {"cmd": "create", "target": "all", "attr": "all"}) + if ret: + if ret[0] != 0: + return ret[0] + return create_ret + + def delete_pddf_devices(self): - self.dev_parse(self.data['SYSTEM'], { "cmd": "delete", "target":"all", "attr":"all" } ) + self.dev_parse(self.data['SYSTEM'], {"cmd": "delete", "target": "all", "attr": "all"}) if 'SYSSTATUS' in self.data: - self.dev_parse(self.data['SYSSTATUS'], { "cmd": "delete", "target":"all", "attr":"all" } ) + self.dev_parse(self.data['SYSSTATUS'], {"cmd": "delete", "target": "all", "attr": "all"}) def populate_pddf_sysfsobj(self): - self.dev_parse(self.data['SYSTEM'], { "cmd": "show", "target":"all", "attr":"all" } ) + self.dev_parse(self.data['SYSTEM'], {"cmd": "show", "target": "all", "attr": "all"}) if 'SYSSTATUS' in self.data: - self.dev_parse(self.data['SYSSTATUS'], { "cmd": "show", "target":"all", "attr":"all" } ) - self.led_parse({ "cmd": "show", "target":"all", "attr":"all" }) + self.dev_parse(self.data['SYSSTATUS'], {"cmd": "show", "target": "all", "attr": "all"}) + self.led_parse({"cmd": "show", "target": "all", "attr": "all"}) self.show_client_device() def cli_dump_dsysfs(self, component): - self.dev_parse(self.data['SYSTEM'], { "cmd": "show_attr", "target":"all", "attr":"all" } ) + self.dev_parse(self.data['SYSTEM'], {"cmd": "show_attr", "target": "all", "attr": "all"}) if 'SYSSTATUS' in self.data: - self.dev_parse(self.data['SYSSTATUS'], { "cmd": "show_attr", "target":"all", "attr":"all" } ) + self.dev_parse(self.data['SYSSTATUS'], {"cmd": "show_attr", "target": "all", "attr": "all"}) if component in self.data_sysfs_obj: return self.data_sysfs_obj[component] else: - return None - + return None def validate_pddf_devices(self, *args): - self.populate_pddf_sysfsobj() - v_ops = { 'cmd': 'validate', 'target':'all', 'attr':'all' } - self.dev_parse(self.data['SYSTEM'], v_ops ) + self.populate_pddf_sysfsobj() + v_ops = {'cmd': 'validate', 'target': 'all', 'attr': 'all'} + self.dev_parse(self.data['SYSTEM'], v_ops) ################################################################################################################## # BMC APIs @@ -1707,48 +1701,48 @@ def populate_bmc_cache_db(self, bmc_attr): delim = None o_list = subprocess.check_output(bmc_cmd, shell=True).strip().split('\n') - bmc_cache[bmc_cmd]={} - bmc_cache[bmc_cmd]['time']=time.time() + bmc_cache[bmc_cmd] = {} + bmc_cache[bmc_cmd]['time'] = time.time() for entry in o_list: name = entry.split(delim)[0].strip() - bmc_cache[bmc_cmd][name]=entry + bmc_cache[bmc_cmd][name] = entry def non_raw_ipmi_get_request(self, bmc_attr): - bmc_db_update_time=1 + bmc_db_update_time = 1 value = 'N/A' bmc_cmd = str(bmc_attr['bmc_cmd']).strip() field_name = str(bmc_attr['field_name']).strip() - field_pos= int(bmc_attr['field_pos'])-1 - + field_pos = int(bmc_attr['field_pos'])-1 + if 'delimiter' in bmc_attr.keys(): delim = str(bmc_attr['delimiter']).strip() else: delim = None if not bmc_cmd in bmc_cache: - self.populate_bmc_cache_db(bmc_attr) + self.populate_bmc_cache_db(bmc_attr) else: - now = time.time() - if (int(now - bmc_cache[bmc_cmd]['time']) > bmc_db_update_time): - self.populate_bmc_cache_db(bmc_attr) + now = time.time() + if (int(now - bmc_cache[bmc_cmd]['time']) > bmc_db_update_time): + self.populate_bmc_cache_db(bmc_attr) try: - data=bmc_cache[bmc_cmd][field_name] - value = data.split(delim)[field_pos].strip() + data = bmc_cache[bmc_cmd][field_name] + value = data.split(delim)[field_pos].strip() except Exception as e: - pass + pass if 'mult' in bmc_attr.keys() and not value.isalpha(): if value.isalpha(): value = 0.0 value = float(value) * float(bmc_attr['mult']) - + return str(value) def raw_ipmi_get_request(self, bmc_attr): value = 'N/A' - cmd = bmc_attr['bmc_cmd'] + " 2>/dev/null" - if bmc_attr['type'] == 'raw': + cmd = bmc_attr['bmc_cmd'] + " 2>/dev/null" + if bmc_attr['type'] == 'raw': try: value = subprocess.check_output(cmd, shell=True).strip() except Exception as e: @@ -1758,7 +1752,7 @@ def raw_ipmi_get_request(self, bmc_attr): value = str(int(value, 16)) return value - if bmc_attr['type'] == 'mask': + if bmc_attr['type'] == 'mask': mask = int(bmc_attr['mask'].encode('utf-8'), 16) try: value = subprocess.check_output(cmd, shell=True).strip() @@ -1768,10 +1762,10 @@ def raw_ipmi_get_request(self, bmc_attr): # value should either be '1' or '0' if value != 'N/A': value = '1' if bool(int(value, 16) & mask) else '0' - + return value - if bmc_attr['type'] == 'ascii': + if bmc_attr['type'] == 'ascii': try: value = subprocess.check_output(cmd, shell=True) except Exception as e: @@ -1779,19 +1773,19 @@ def raw_ipmi_get_request(self, bmc_attr): if value != 'N/A': tmp = ''.join(chr(int(i, 16)) for i in value.split()) - tmp = "".join(i for i in unicode(tmp) if unicodedata.category(i)[0]!="C") + tmp = "".join(i for i in unicode(tmp) if unicodedata.category(i)[0] != "C") value = str(tmp) return (value) - return value + return value - def bmc_get_cmd(self, bmc_attr): - if int(bmc_attr['raw']) == 1: + def bmc_get_cmd(self, bmc_attr): + if int(bmc_attr['raw']) == 1: value = self.raw_ipmi_get_request(bmc_attr) - else: + else: value = self.non_raw_ipmi_get_request(bmc_attr) - return (value) + return (value) def non_raw_ipmi_set_request(self, bmc_attr, val): value = 'N/A' @@ -1801,14 +1795,14 @@ def non_raw_ipmi_set_request(self, bmc_attr, val): def raw_ipmi_set_request(self, bmc_attr, val): value = 'N/A' # TODO: Implement this - return value + return value - def bmc_set_cmd(self, bmc_attr, val): - if int(bmc_attr['raw']) == 1: + def bmc_set_cmd(self, bmc_attr, val): + if int(bmc_attr['raw']) == 1: value = self.raw_ipmi_set_request(bmc_attr, val) - else: + else: value = self.non_raw_ipmi_set_request(bmc_attr, val) - return (value) + return (value) # bmc-based attr: return attr obj # non-bmc-based attr: return empty obj @@ -1821,43 +1815,43 @@ def check_bmc_based_attr(self, device_name, attr_name): return attr # Required attr_name is not supported in BMC object return {} - return None + return None def get_attr_name_output(self, device_name, attr_name): - bmc_attr = self.check_bmc_based_attr(device_name, attr_name) - output={"mode":"", "status":""} - + bmc_attr = self.check_bmc_based_attr(device_name, attr_name) + output = {"mode": "", "status": ""} + if bmc_attr is not None: - if bmc_attr=={}: - return {} - output['mode']="bmc" - output['status']=self.bmc_get_cmd(bmc_attr) + if bmc_attr == {}: + return {} + output['mode'] = "bmc" + output['status'] = self.bmc_get_cmd(bmc_attr) else: - output['mode']="i2c" - node = self.get_path(device_name, attr_name) - if node is None: - return {} - try: - with open(node, 'r') as f: - output['status'] = f.read() - except IOError: - return {} + output['mode'] = "i2c" + node = self.get_path(device_name, attr_name) + if node is None: + return {} + try: + with open(node, 'r') as f: + output['status'] = f.read() + except IOError: + return {} return output def set_attr_name_output(self, device_name, attr_name, val): - bmc_attr = self.check_bmc_based_attr(device_name, attr_name) - output={"mode":"", "status":""} - + bmc_attr = self.check_bmc_based_attr(device_name, attr_name) + output = {"mode": "", "status": ""} + if bmc_attr is not None: - if bmc_attr=={}: - return {} - output['mode']="bmc" - output['status']=False # No set operation allowed for BMC attributes as they are handled by BMC itself + if bmc_attr == {}: + return {} + output['mode'] = "bmc" + output['status'] = False # No set operation allowed for BMC attributes as they are handled by BMC itself else: - output['mode']="i2c" + output['mode'] = "i2c" node = self.get_path(device_name, attr_name) if node is None: - return {} + return {} try: with open(node, 'w') as f: f.write(str(val)) @@ -1886,7 +1880,7 @@ def main(): try: pddf_obj = PddfParse() except Exception as e: - print "%s" % str(e) + print("%s" % str(e)) sys.exit() if args.create: @@ -1894,39 +1888,40 @@ def main(): if args.sysfs: if args.sysfs[0] == 'all': - pddf_obj.populate_pddf_sysfsobj() + pddf_obj.populate_pddf_sysfsobj() if args.sysfs[0] == 'print': - pddf_obj.populate_pddf_sysfsobj() - pddf_obj.dump_sysfs_obj(pddf_obj.sysfs_obj, args.sysfs[1]) + pddf_obj.populate_pddf_sysfsobj() + pddf_obj.dump_sysfs_obj(pddf_obj.sysfs_obj, args.sysfs[1]) if args.sysfs[0] == 'validate': - pddf_obj.populate_pddf_sysfsobj() - pddf_obj.validate_sysfs_creation(pddf_obj.sysfs_obj, args.sysfs[1]) + pddf_obj.populate_pddf_sysfsobj() + pddf_obj.validate_sysfs_creation(pddf_obj.sysfs_obj, args.sysfs[1]) if args.sysfs[0] == 'verify': - pddf_obj.verify_sysfs_data(args.sysfs[1]) - + pddf_obj.verify_sysfs_data(args.sysfs[1]) if args.dsysfs: - if args.dsysfs[0] == 'validate': - pddf_obj.dev_parse(pddf_obj.data['SYSTEM'], { "cmd": "show_attr", "target":"all", "attr":"all" } ) + if args.dsysfs[0] == 'validate': + pddf_obj.dev_parse(pddf_obj.data['SYSTEM'], {"cmd": "show_attr", "target": "all", "attr": "all"}) if 'SYSSTATUS' in pddf_obj.data: - pddf_obj.dev_parse(pddf_obj.data['SYSSTATUS'], { "cmd": "show_attr", "target":"all", "attr":"all" } ) + pddf_obj.dev_parse(pddf_obj.data['SYSSTATUS'], {"cmd": "show_attr", "target": "all", "attr": "all"}) pddf_obj.validate_dsysfs_creation(pddf_obj.data_sysfs_obj, args.dsysfs[1]) elif args.dsysfs[0] == 'print': - pddf_obj.dev_parse(pddf_obj.data['SYSTEM'], { "cmd": "show_attr", "target":"all", "attr":"all" } ) + pddf_obj.dev_parse(pddf_obj.data['SYSTEM'], {"cmd": "show_attr", "target": "all", "attr": "all"}) if 'SYSSTATUS' in pddf_obj.data: - pddf_obj.dev_parse(pddf_obj.data['SYSSTATUS'], { "cmd": "show_attr", "target":"all", "attr":"all" } ) + pddf_obj.dev_parse(pddf_obj.data['SYSSTATUS'], {"cmd": "show_attr", "target": "all", "attr": "all"}) pddf_obj.dump_sysfs_obj(pddf_obj.data_sysfs_obj, args.dsysfs[1]) elif args.dsysfs[0] == 'all': - ret = pddf_obj.dev_parse(pddf_obj.data['SYSTEM'], { "cmd": "show_attr", "target":"all", "attr":"all" } ) + ret = pddf_obj.dev_parse(pddf_obj.data['SYSTEM'], {"cmd": "show_attr", "target": "all", "attr": "all"}) if 'SYSSTATUS' in pddf_obj.data: - ret += pddf_obj.dev_parse(pddf_obj.data['SYSSTATUS'], { "cmd": "show_attr", "target":"all", - "attr":"all" } ) + ret += pddf_obj.dev_parse(pddf_obj.data['SYSSTATUS'], {"cmd": "show_attr", "target": "all", + "attr": "all"}) pddf_obj.dump_sysfs_obj(pddf_obj.data_sysfs_obj, 'all') else: - pddf_obj.dev_parse(pddf_obj.data[args.dsysfs[0]], { "cmd": "show_attr", "target":args.dsysfs[0], - "attr":args.dsysfs[1] }) + val = pddf_obj.dev_parse(pddf_obj.data[args.dsysfs[0]], {"cmd": "show_attr", "target": args.dsysfs[0], + "attr": args.dsysfs[1]}) + for i in val: + print(i) if args.delete: pddf_obj.delete_pddf_devices() @@ -1944,6 +1939,5 @@ def main(): pddf_obj.modules_validation(args.modules[0]) - -if __name__ == "__main__" : - main() +if __name__ == "__main__": + main() diff --git a/platform/pddf/platform-api-pddf-base.dep b/platform/pddf/platform-api-pddf-base.dep index aaaedb068384..3c1f0d874814 100644 --- a/platform/pddf/platform-api-pddf-base.dep +++ b/platform/pddf/platform-api-pddf-base.dep @@ -1,5 +1,5 @@ -MPATH := $($(PDDF_PLATFORM_API_BASE_PY2)_SRC_PATH) +MPATH := $($(PDDF_PLATFORM_API_BASE_PY3)_SRC_PATH) DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/pddf/platform-api-pddf-base.mk platform/pddf/platform-api-pddf-base.dep DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) DEP_FILES += $(shell git ls-files $(MPATH)) diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_chassis.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_chassis.py old mode 100755 new mode 100644 index 9d0d963347ba..0ba2e8902c9c --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_chassis.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_chassis.py @@ -32,9 +32,9 @@ def __init__(self, pddf_data=None, pddf_plugin_data=None): self.plugin_data = pddf_plugin_data if pddf_plugin_data else None if not self.pddf_obj or not self.plugin_data: try: - from . import pddfparse + from . import pddfapi import json - self.pddf_obj = pddfparse.PddfParse() + self.pddf_obj = pddfapi.PddfApi() with open('/usr/share/sonic/platform/pddf/pd-plugin.json') as pd: self.plugin_data = json.load(pd) except Exception as e: @@ -43,7 +43,12 @@ def __init__(self, pddf_data=None, pddf_plugin_data=None): self.platform_inventory = self.pddf_obj.get_platform() # Initialize EEPROM - self.sys_eeprom = Eeprom(self.pddf_obj, self.plugin_data) + try: + self._eeprom = Eeprom(self.pddf_obj, self.plugin_data) + except Exception as err: + sys.stderr.write("Unable to initialize syseeprom - {}".format(repr(err))) + # Dont exit as we dont want failure in loading other components + # FANs for i in range(self.platform_inventory['num_fantrays']): @@ -66,28 +71,6 @@ def __init__(self, pddf_data=None, pddf_plugin_data=None): thermal = Thermal(i, self.pddf_obj, self.plugin_data) self._thermal_list.append(thermal) - # SYSTEM LED Test Cases - """ - #comment out test cases - sys_led_list= { "LOC":0, - "DIAG":0, - "FAN":0, - "SYS":0, - "PSU1":0, - "PSU2":1 - } - - for led in sys_led_list: - color=self.get_system_led(led, sys_led_list[led]) - print color - - self.set_system_led("LOC_LED","STATUS_LED_COLOR_GREEN") - color=self.get_system_led("LOC_LED") - print "Set Green: " + color - self.set_system_led("LOC_LED", "STATUS_LED_COLOR_OFF") - color=self.get_system_led("LOC_LED") - print "Set off: " + color - """ def get_name(self): """ @@ -95,7 +78,7 @@ def get_name(self): Returns: string: The name of the chassis """ - return self.sys_eeprom.modelstr() + return self._eeprom.modelstr() def get_presence(self): """ @@ -111,7 +94,7 @@ def get_model(self): Returns: string: Model/part number of chassis """ - return self.sys_eeprom.part_number_str() + return self._eeprom.part_number_str() def get_serial(self): """ @@ -119,7 +102,7 @@ def get_serial(self): Returns: string: Serial number of chassis """ - return self.sys_eeprom.serial_str() + return self._eeprom.serial_str() def get_status(self): """ @@ -138,7 +121,7 @@ def get_base_mac(self): A string containing the MAC address in the format 'XX:XX:XX:XX:XX:XX' """ - return self.sys_eeprom.base_mac_addr() + return self._eeprom.base_mac_addr() def get_serial_number(self): """ @@ -148,7 +131,7 @@ def get_serial_number(self): A string containing the hardware serial number for this chassis. """ - return self.sys_eeprom.serial_number_str() + return self._eeprom.serial_number_str() def get_system_eeprom_info(self): """ @@ -158,7 +141,7 @@ def get_system_eeprom_info(self): OCP ONIE TlvInfo EEPROM format and values are their corresponding values. """ - return self.sys_eeprom.system_eeprom_info() + return self._eeprom.system_eeprom_info() def get_reboot_cause(self): """ @@ -173,263 +156,39 @@ def get_reboot_cause(self): """ raise NotImplementedError - def get_component_name_list(self): - """ - Retrieves a list of the names of components available on the chassis (e.g., BIOS, CPLD, FPGA, etc.) - - Returns: - A list containing the names of components available on the chassis - """ - return self._component_name_list - - def get_firmware_version(self, component_name): - """ - Retrieves platform-specific hardware/firmware versions for chassis - componenets such as BIOS, CPLD, FPGA, etc. - Args: - component_name: A string, the component name. - - Returns: - A string containing platform-specific component versions - """ - raise NotImplementedError - - def install_component_firmware(self, component_name, image_path): - """ - Install firmware to component - Args: - component_name: A string, the component name. - image_path: A string, path to firmware image. - - Returns: - A boolean, True if install was successful, False if not - """ - raise NotImplementedError + ############################################## + # Component methods + ############################################## ############################################## # Module methods ############################################## + # All module methods are part of chassis_base.py + # if they need to be overwritten, define them here - def get_num_modules(self): - """ - Retrieves the number of modules available on this chassis - - Returns: - An integer, the number of modules available on this chassis - """ - return len(self._module_list) - - def get_all_modules(self): - """ - Retrieves all modules available on this chassis - - Returns: - A list of objects derived from ModuleBase representing all - modules available on this chassis - """ - return self._module_list - - def get_module(self, index): - """ - Retrieves module represented by (0-based) index - - Args: - index: An integer, the index (0-based) of the module to - retrieve - - Returns: - An object dervied from ModuleBase representing the specified - module - """ - module = None - - try: - module = self._module_list[index] - except IndexError: - sys.stderr.write("Module index {} out of range (0-{})\n".format( - index, len(self._module_list)-1)) - - return module ############################################## # Fan methods ############################################## - - def get_num_fans(self): - """ - Retrieves the number of fans available on this chassis - - Returns: - An integer, the number of fan modules available on this chassis - """ - return len(self._fan_list) - - def get_all_fans(self): - """ - Retrieves all fan modules available on this chassis - - Returns: - A list of objects derived from FanBase representing all fan - modules available on this chassis - """ - return self._fan_list - - def get_fan(self, index): - """ - Retrieves fan module represented by (0-based) index - - Args: - index: An integer, the index (0-based) of the fan module to - retrieve - - Returns: - An object dervied from FanBase representing the specified fan - module - """ - fan = None - - try: - fan = self._fan_list[index] - except IndexError: - sys.stderr.write("Fan index {} out of range (0-{})\n".format( - index, len(self._fan_list)-1)) - - return fan + # All fan methods are part of chassis_base.py + # if they need to be overwritten, define them here ############################################## # PSU methods ############################################## - - def get_num_psus(self): - """ - Retrieves the number of power supply units available on this chassis - - Returns: - An integer, the number of power supply units available on this - chassis - """ - return len(self._psu_list) - - def get_all_psus(self): - """ - Retrieves all power supply units available on this chassis - - Returns: - A list of objects derived from PsuBase representing all power - supply units available on this chassis - """ - return self._psu_list - - def get_psu(self, index): - """ - Retrieves power supply unit represented by (0-based) index - - Args: - index: An integer, the index (0-based) of the power supply unit to - retrieve - - Returns: - An object dervied from PsuBase representing the specified power - supply unit - """ - psu = None - - try: - psu = self._psu_list[index] - except IndexError: - sys.stderr.write("PSU index {} out of range (0-{})\n".format( - index, len(self._psu_list)-1)) - - return psu + # All psu methods are part of chassis_base.py + # if they need to be overwritten, define them here ############################################## # THERMAL methods ############################################## - - def get_num_thermals(self): - """ - Retrieves the number of thermals available on this chassis - - Returns: - An integer, the number of thermals available on this chassis - """ - return len(self._thermal_list) - - def get_all_thermals(self): - """ - Retrieves all thermals available on this chassis - - Returns: - A list of objects derived from ThermalBase representing all thermals - available on this chassis - """ - return self._thermal_list - - def get_thermal(self, index): - """ - Retrieves thermal unit represented by (0-based) index - - Args: - index: An integer, the index (0-based) of the thermal to - retrieve - - Returns: - An object dervied from ThermalBase representing the specified thermal - """ - thermal = None - - try: - thermal = self._thermal_list[index] - except IndexError: - sys.stderr.write("THERMAL index {} out of range (0-{})\n".format( - index, len(self._thermal_list)-1)) - - return thermal + # All thermal methods are part of chassis_base.py + # if they need to be overwritten, define them here ############################################## # SFP methods ############################################## - - def get_num_sfps(self): - """ - Retrieves the number of sfps available on this chassis - - Returns: - An integer, the number of sfps available on this chassis - """ - return len(self._sfp_list) - - def get_all_sfps(self): - """ - Retrieves all sfps available on this chassis - - Returns: - A list of objects derived from SfpBase representing all sfps - available on this chassis - """ - return self._sfp_list - - def get_sfp(self, index): - """ - Retrieves sfp represented by (0-based) index - - Args: - index: An integer, the index (0-based) of the sfp to retrieve. - The index should be the sequence of a physical port in a chassis, - starting from 0. - For example, 0 for Ethernet0, 1 for Ethernet4 and so on. - - Returns: - An object dervied from SfpBase representing the specified sfp - """ - sfp = None - - try: - sfp = self._sfp_list[index] - except IndexError: - sys.stderr.write("SFP index {} out of range (0-{})\n".format( - index, len(self._sfp_list)-1)) - - return sfp + # All sfp methods are part of chassis_base.py + # if they need to be overwritten, define them here ############################################## # System LED methods @@ -464,47 +223,3 @@ def get_system_led(self, led_device_name): ############################################## # Other methods ############################################## - - def get_watchdog(self): - """ - Retreives hardware watchdog device on this chassis - - Returns: - An object derived from WatchdogBase representing the hardware - watchdog device - """ - return self._watchdog - - def get_eeprom(self): - """ - Retreives eeprom device on this chassis - - Returns: - An object derived from WatchdogBase representing the hardware - eeprom device - """ - return self.sys_eeprom - - def get_change_event(self, timeout=0): - """ - Returns a nested dictionary containing all devices which have - experienced a change at chassis level - - Args: - timeout: Timeout in milliseconds (optional). If timeout == 0, - this method will block until a change is detected. - Returns: - (bool, dict): - - True if call successful, False if not; - - A nested dictionary where key is a device type, - value is a dictionary with key:value pairs in the format of - {'device_id':'device_event'}, - where device_id is the device ID for this device and - device_event, - status='1' represents device inserted, - status='0' represents device removed. - Ex. {'fan':{'0':'0', '2':'1'}, 'sfp':{'11':'0'}} - indicates that fan 0 has been removed, fan 2 - has been inserted and sfp 11 has been removed. - """ - raise NotImplementedError diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_fan.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_fan.py old mode 100755 new mode 100644 index 30be0dd74b35..d272d40e61a4 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_fan.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_fan.py @@ -224,7 +224,7 @@ def get_target_speed(self): target_speed = 0 if self.is_psu_fan: # Target speed not usually supported for PSU fans - target_speed = 0 + raise NotImplementedError else: idx = (self.fantray_index-1)*self.platform['num_fans_pertray'] + self.fan_index attr = "fan" + str(idx) + "_pwm" diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_platform.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_platform.py old mode 100755 new mode 100644 index c9c3a8d851ac..b7adecc312d5 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_platform.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_platform.py @@ -8,7 +8,7 @@ try: import json - from . import pddfparse + from . import pddfapi from sonic_platform_base.platform_base import PlatformBase from sonic_platform.chassis import Chassis except ImportError as e: @@ -24,7 +24,7 @@ class PddfPlatform(PlatformBase): def __init__(self): # Initialize the JSON data - self.pddf_data = pddfparse.PddfParse() + self.pddf_data = pddfapi.PddfApi() with open('/usr/share/sonic/platform/pddf/pd-plugin.json') as pd: self.pddf_plugin_data = json.load(pd) diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_psu.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_psu.py old mode 100755 new mode 100644 diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_sfp.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_sfp.py old mode 100755 new mode 100644 diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_thermal.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_thermal.py old mode 100755 new mode 100644 diff --git a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfparse.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py old mode 100755 new mode 100644 similarity index 53% rename from platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfparse.py rename to platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py index 6ca59206fd56..a4075af87a94 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfparse.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfapi.py @@ -1,7 +1,6 @@ #!/usr/bin/env python import glob import json -from jsonschema import validate import os import re import subprocess @@ -29,7 +28,7 @@ } -class PddfParse(): +class PddfApi(): def __init__(self): if not os.path.exists("/usr/share/sonic/platform"): self.platform, self.hwsku = self.get_platform_and_hwsku() @@ -46,7 +45,6 @@ def __init__(self): self.sysfs_obj = {} # Returns platform and HW SKU - def get_platform_and_hwsku(self): try: proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY], @@ -84,30 +82,38 @@ def get_dev_idx(self, dev, ops): return pdev['dev_attr']['dev_idx'] - def get_path(self, target, attr): + def get_paths(self, target, attr): aa = target + attr if aa in cache: return cache[aa] - string = None + strings = [] p = re.search(r'\d+$', target) if p is None: for bb in filter(re.compile(target).search, self.data.keys()): - path = self.dev_parse(self.data[bb], {"cmd": "show_attr", "target": bb, "attr": attr}) - if path != "": - string = path + paths = self.dev_parse(self.data[bb], {"cmd": "show_attr", "target": bb, "attr": attr}) + if paths: + strings.extend(paths) else: if target in self.data.keys(): - path = self.dev_parse(self.data[target], {"cmd": "show_attr", "target": target, "attr": attr}) - if path != "": - string = path + paths = self.dev_parse(self.data[target], {"cmd": "show_attr", "target": target, "attr": attr}) + if paths: + strings.extend(paths) - if string is not None: - string = string.rstrip() + cache[aa] = strings + return strings - cache[aa] = string - return string + def get_path(self, target, attr): + nodes = self.get_paths(target, attr) + if nodes: + if len(nodes)==1: + return nodes[0] + # CAREFULL!!! If more than one paths are expected, use get_paths + else: + return nodes[0] + else: + return None def get_device_type(self, key): if key not in self.data.keys(): @@ -173,7 +179,7 @@ def get_led_color_from_gpio(self, led_device_name): status = "[FAILED] {} does not exist".format(attr_path) return (status) cmd = 'cat ' + attr_path - gpio_value = subprocess.check_output(cmd, shell=True) + gpio_value = subprocess.check_output(cmd, shell=True, universal_newlines=True) value |= int(gpio_value) << bit bit += 1 @@ -205,8 +211,8 @@ def set_led_color_from_gpio(self, led_device_name, color): i = 0 while i <= max_bit: _value = (value >> i) & 1 - base_offset += i - attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], hex(base_offset)) + offset = base_offset + i + attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], hex(offset)) i += 1 try: cmd = "echo {} > {}".format(_value, attr_path) @@ -230,11 +236,11 @@ def get_system_led_color(self, led_device_name): status = "[FAILED] " + led_device_name + " is not configured" return (status) - type = self.get_led_color_devtype(led_device_name) + dtype = self.get_led_color_devtype(led_device_name) - if type == 'gpio': + if dtype == 'gpio': color = self.get_led_color_from_gpio(led_device_name) - elif type == 'cpld': + elif dtype == 'cpld': color = self.get_led_color_from_cpld(led_device_name) return color @@ -244,9 +250,9 @@ def set_system_led_color(self, led_device_name, color): print(msg) return (result) - type = self.get_led_color_devtype(led_device_name) + dtype = self.get_led_color_devtype(led_device_name) - if type == 'gpio': + if dtype == 'gpio': return (self.set_led_color_from_gpio(led_device_name, color)) else: return (self.set_led_color_from_cpld(led_device_name, color)) @@ -266,13 +272,22 @@ def show_device_sysfs(self, dev, ops): parent = dev['dev_info']['device_parent'] pdev = self.data[parent] if pdev['dev_info']['device_parent'] == 'SYSTEM': - return "/sys/bus/i2c/devices/"+"i2c-%d" % int(pdev['i2c']['topo_info']['dev_addr'], 0) + if 'topo_info' in pdev['i2c']: + return "/sys/bus/i2c/devices/"+"i2c-%d"%int(pdev['i2c']['topo_info']['dev_addr'], 0) + else: + return "/sys/bus/i2c/devices" return self.show_device_sysfs(pdev, ops) + "/" + "i2c-%d" % int(dev['i2c']['topo_info']['parent_bus'], 0) - # This is alid for 'at24' type of EEPROM devices. Only one attribtue 'eeprom' + def get_gpio_attr_path(self, dev, offset): + base = int(dev['i2c']['dev_attr']['gpio_base'], 16) + port_num = base + int(offset, 16) + gpio_name = 'gpio'+str(port_num) + path = '/sys/class/gpio/'+gpio_name+'/value' + return path + # This is alid for 'at24' type of EEPROM devices. Only one attribtue 'eeprom' def show_attr_eeprom_device(self, dev, ops): - str = "" + ret = [] attr_name = ops['attr'] attr_list = dev['i2c']['attr_list'] KEY = "eeprom" @@ -294,11 +309,11 @@ def show_attr_eeprom_device(self, dev, ops): "/%s" % real_name if dsysfs_path not in self.data_sysfs_obj[KEY]: self.data_sysfs_obj[KEY].append(dsysfs_path) - str += dsysfs_path+"\n" - return str + ret.append(dsysfs_path) + return ret def show_attr_gpio_device(self, dev, ops): - ret = "" + ret = [] KEY = "gpio" if KEY not in self.data_sysfs_obj: self.data_sysfs_obj[KEY] = [] @@ -306,24 +321,17 @@ def show_attr_gpio_device(self, dev, ops): return ret def show_attr_mux_device(self, dev, ops): - ret = "" + ret = [] KEY = "mux" if KEY not in self.data_sysfs_obj: self.data_sysfs_obj[KEY] = [] return ret - def get_gpio_attr_path(self, dev, offset): - base = int(dev['i2c']['dev_attr']['gpio_base'], 16) - port_num = base + int(offset, 16) - gpio_name = 'gpio'+str(port_num) - path = '/sys/class/gpio/'+gpio_name+'/value' - return path - def show_attr_psu_i2c_device(self, dev, ops): target = ops['target'] attr_name = ops['attr'] - ret = "" + ret = [] KEY = "psu" dsysfs_path = "" @@ -331,7 +339,7 @@ def show_attr_psu_i2c_device(self, dev, ops): self.data_sysfs_obj[KEY] = [] if target == 'all' or target == dev['dev_info']['virt_parent']: - attr_list = dev['i2c']['attr_list'] + attr_list = dev['i2c']['attr_list'] if 'i2c' in dev else [] for attr in attr_list: if attr_name == attr['attr_name'] or attr_name == 'all': if 'attr_devtype' in attr.keys() and attr['attr_devtype'] == "gpio": @@ -340,29 +348,35 @@ def show_attr_psu_i2c_device(self, dev, ops): if (os.path.exists(attr_path)): if attr_path not in self.data_sysfs_obj[KEY]: self.data_sysfs_obj[KEY].append(attr_path) - ret += attr_path + '\n' + ret.append(attr_path) else: if 'drv_attr_name' in attr.keys(): real_name = attr['drv_attr_name'] + real_dev = dev + elif 'attr_devattr' in attr.keys(): + real_name = attr['attr_devattr'] + real_devname = attr['attr_devname'] if 'attr_devname' in attr.keys() else '' + real_dev = self.data[real_devname] else: real_name = attr['attr_name'] + real_dev = dev - dsysfs_path = self.show_device_sysfs(dev, ops) + \ - "/%d-00%x" % (int(dev['i2c']['topo_info']['parent_bus'], 0), - int(dev['i2c']['topo_info']['dev_addr'], 0)) + \ + dsysfs_path = self.show_device_sysfs(real_dev, ops) + \ + "/%d-00%x" % (int(real_dev['i2c']['topo_info']['parent_bus'], 0), + int(real_dev['i2c']['topo_info']['dev_addr'], 0)) + \ "/%s" % real_name if dsysfs_path not in self.data_sysfs_obj[KEY]: self.data_sysfs_obj[KEY].append(dsysfs_path) - ret += dsysfs_path+"\n" + ret.append(dsysfs_path) return ret def show_attr_psu_device(self, dev, ops): return self.show_attr_psu_i2c_device(dev, ops) def show_attr_fan_device(self, dev, ops): - ret = "" + ret = [] attr_name = ops['attr'] - attr_list = dev['i2c']['attr_list'] + attr_list = dev['i2c']['attr_list'] if 'i2c' in dev else [] KEY = "fan" dsysfs_path = "" @@ -377,27 +391,35 @@ def show_attr_fan_device(self, dev, ops): if (os.path.exists(attr_path)): if attr_path not in self.data_sysfs_obj[KEY]: self.data_sysfs_obj[KEY].append(attr_path) - ret += attr_path + '\n' + ret.append(attr_path) else: if 'drv_attr_name' in attr.keys(): real_name = attr['drv_attr_name'] + real_dev = dev + elif 'attr_devattr' in attr.keys(): + real_name = attr['attr_devattr'] + real_devname = attr['attr_devname'] if 'attr_devname' in attr.keys() else '' + real_dev = self.data[real_devname] else: real_name = attr['attr_name'] + real_dev = dev - dsysfs_path = self.show_device_sysfs(dev, ops) + \ - "/%d-00%x" % (int(dev['i2c']['topo_info']['parent_bus'], 0), - int(dev['i2c']['topo_info']['dev_addr'], 0)) + \ + dsysfs_path = self.show_device_sysfs(real_dev, ops) + \ + "/%d-00%x" % (int(real_dev['i2c']['topo_info']['parent_bus'], 0), + int(real_dev['i2c']['topo_info']['dev_addr'], 0)) + \ "/%s" % real_name if dsysfs_path not in self.data_sysfs_obj[KEY]: self.data_sysfs_obj[KEY].append(dsysfs_path) - ret += dsysfs_path+"\n" + ret.append(dsysfs_path) return ret # This is only valid for LM75 def show_attr_temp_sensor_device(self, dev, ops): - str = "" + ret = [] + if 'i2c' not in dev.keys(): + return ret attr_name = ops['attr'] - attr_list = dev['i2c']['attr_list'] + attr_list = dev['i2c']['attr_list'] if 'i2c' in dev else [] KEY = "temp-sensors" dsysfs_path = "" @@ -418,11 +440,11 @@ def show_attr_temp_sensor_device(self, dev, ops): dsysfs_path = full_path if dsysfs_path not in self.data_sysfs_obj[KEY]: self.data_sysfs_obj[KEY].append(dsysfs_path) - str += full_path + "\n" - return str + ret.append(full_path) + return ret def show_attr_sysstatus_device(self, dev, ops): - ret = "" + ret = [] attr_name = ops['attr'] attr_list = dev['attr_list'] KEY = "sys-status" @@ -436,13 +458,13 @@ def show_attr_sysstatus_device(self, dev, ops): dsysfs_path = "/sys/kernel/pddf/devices/sysstatus/sysstatus_data/" + attr['attr_name'] if dsysfs_path not in self.data_sysfs_obj[KEY]: self.data_sysfs_obj[KEY].append(dsysfs_path) - ret += dsysfs_path+"\n" + ret.append(dsysfs_path) return ret def show_attr_xcvr_i2c_device(self, dev, ops): target = ops['target'] attr_name = ops['attr'] - ret = "" + ret = [] dsysfs_path = "" KEY = "xcvr" if KEY not in self.data_sysfs_obj: @@ -458,342 +480,39 @@ def show_attr_xcvr_i2c_device(self, dev, ops): if (os.path.exists(attr_path)): if attr_path not in self.data_sysfs_obj[KEY]: self.data_sysfs_obj[KEY].append(attr_path) - ret += attr_path + '\n' + ret.append(attr_path) else: if 'drv_attr_name' in attr.keys(): real_name = attr['drv_attr_name'] + real_dev = dev + elif 'attr_devattr' in attr.keys(): + real_name = attr['attr_devattr'] + real_devname = attr['attr_devname'] if 'attr_devname' in attr.keys() else '' + real_dev = self.data[real_devname] else: real_name = attr['attr_name'] + real_dev = dev - dsysfs_path = self.show_device_sysfs(dev, ops) + \ - "/%d-00%x" % (int(dev['i2c']['topo_info']['parent_bus'], 0), - int(dev['i2c']['topo_info']['dev_addr'], 0)) + \ + dsysfs_path = self.show_device_sysfs(real_dev, ops) + \ + "/%d-00%x" % (int(real_dev['i2c']['topo_info']['parent_bus'], 0), + int(real_dev['i2c']['topo_info']['dev_addr'], 0)) + \ "/%s" % real_name if dsysfs_path not in self.data_sysfs_obj[KEY]: self.data_sysfs_obj[KEY].append(dsysfs_path) - ret += dsysfs_path+"\n" + ret.append(dsysfs_path) return ret def show_attr_xcvr_device(self, dev, ops): return self.show_attr_xcvr_i2c_device(dev, ops) def show_attr_cpld_device(self, dev, ops): - ret = "" + ret = [] KEY = "cpld" if KEY not in self.data_sysfs_obj: self.data_sysfs_obj[KEY] = [] return ret - ################################################################################################################### - # SHOW DEFS - ################################################################################################################### - - def check_led_cmds(self, key, ops): - name = ops['target']+'_LED' - if (ops['target'] == 'config' or ops['attr'] == 'all') or \ - (name == self.data[key]['dev_info']['device_name'] and - ops['attr'] == self.data[key]['dev_attr']['index']): - return (True) - else: - return (False) - - def dump_sysfs_obj(self, obj, key_type): - if (key_type == 'keys'): - for key in obj.keys(): - print(key) - return - - for key in obj: - if (key == key_type or key_type == 'all'): - print(key+":") - for entry in obj[key]: - print("\t"+entry) - - def add_list_sysfs_obj(self, obj, KEY, list): - for sysfs in list: - if sysfs not in obj[KEY]: - obj[KEY].append(sysfs) - - def sysfs_attr(self, key, value, path, obj, obj_key): - sysfs_path = "/sys/kernel/%s/%s" % (path, key) - if sysfs_path not in obj[obj_key]: - obj[obj_key].append(sysfs_path) - - def sysfs_device(self, attr, path, obj, obj_key): - for key in attr.keys(): - sysfs_path = "/sys/kernel/%s/%s" % (path, key) - if sysfs_path not in obj[obj_key]: - obj[obj_key].append(sysfs_path) - - def show_eeprom_device(self, dev, ops): - return - - def show_mux_device(self, dev, ops): - KEY = 'mux' - if KEY not in self.sysfs_obj: - self.sysfs_obj[KEY] = [] - self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/mux", self.sysfs_obj, KEY) - self.sysfs_device(dev['i2c']['dev_attr'], "pddf/devices/mux", self.sysfs_obj, KEY) - sysfs_path = "/sys/kernel/pddf/devices/mux/dev_ops" - if sysfs_path not in self.sysfs_obj[KEY]: - self.sysfs_obj[KEY].append(sysfs_path) - list = ['/sys/kernel/pddf/devices/mux/i2c_type', - '/sys/kernel/pddf/devices/mux/i2c_name', - '/sys/kernel/pddf/devices/mux/error'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) - - def show_gpio_device(self, dev, ops): - KEY = 'gpio' - if KEY not in self.sysfs_obj: - self.sysfs_obj[KEY] = [] - self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/gpio", self.sysfs_obj, KEY) - self.sysfs_device(dev['i2c']['dev_attr'], "pddf/devices/gpio", self.sysfs_obj, KEY) - sysfs_path = "/sys/kernel/pddf/devices/gpio/dev_ops" - if sysfs_path not in self.sysfs_obj[KEY]: - self.sysfs_obj[KEY].append(sysfs_path) - list = ['/sys/kernel/pddf/devices/gpio/i2c_type', - '/sys/kernel/pddf/devices/gpio/i2c_name', - '/sys/kernel/pddf/devices/gpio/error'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) - - def show_psu_i2c_device(self, dev, ops): - KEY = 'psu' - path = 'pddf/devices/psu/i2c' - if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PSU']: - if KEY not in self.sysfs_obj: - self.sysfs_obj[KEY] = [] - self.sysfs_device(dev['i2c']['topo_info'], path, self.sysfs_obj, KEY) - sysfs_path = "/sys/kernel/pddf/devices/psu/i2c/psu_idx" - self.sysfs_obj[KEY].append(sysfs_path) - - for attr in dev['i2c']['attr_list']: - self.sysfs_device(attr, "pddf/devices/psu/i2c", self.sysfs_obj, KEY) - sysfs_path = "/sys/kernel/pddf/devices/psu/i2c/dev_ops" - if sysfs_path not in self.sysfs_obj[KEY]: - self.sysfs_obj[KEY].append(sysfs_path) - list = ['/sys/kernel/pddf/devices/psu/i2c/i2c_type', - '/sys/kernel/pddf/devices/fan/i2c/i2c_name', - '/sys/kernel/pddf/devices/psu/i2c/error', - '/sys/kernel/pddf/devices/psu/i2c/attr_ops'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) - - def show_psu_device(self, dev, ops): - self.show_psu_i2c_device(dev, ops) - return - - def show_client_device(self): - KEY = 'client' - if KEY not in self.sysfs_obj: - self.sysfs_obj[KEY] = [] - list = ['/sys/kernel/pddf/devices/showall'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) - - def show_fan_device(self, dev, ops): - KEY = 'fan' - path = 'pddf/devices/fan/i2c' - if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['FAN']: - if KEY not in self.sysfs_obj: - self.sysfs_obj[KEY] = [] - - self.sysfs_device(dev['i2c']['topo_info'], path, self.sysfs_obj, KEY) - self.sysfs_device(dev['i2c']['dev_attr'], path, self.sysfs_obj, KEY) - for attr in dev['i2c']['attr_list']: - self.sysfs_device(attr, path, self.sysfs_obj, KEY) - list = ['/sys/kernel/pddf/devices/fan/i2c/i2c_type', - '/sys/kernel/pddf/devices/fan/i2c/i2c_name', - '/sys/kernel/pddf/devices/fan/i2c/error', - '/sys/kernel/pddf/devices/fan/i2c/attr_ops', - '/sys/kernel/pddf/devices/fan/i2c/dev_ops'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) - - def show_temp_sensor_device(self, dev, ops): - return - - def show_sysstatus_device(self, dev, ops): - KEY = 'sysstatus' - if KEY not in self.sysfs_obj: - self.sysfs_obj[KEY] = [] - for attr in dev['attr_list']: - self.sysfs_device(attr, "pddf/devices/sysstatus", self.sysfs_obj, KEY) - sysfs_path = "/sys/kernel/pddf/devices/sysstatus/attr_ops" - if sysfs_path not in self.sysfs_obj[KEY]: - self.sysfs_obj[KEY].append(sysfs_path) - - def show_xcvr_i2c_device(self, dev, ops): - KEY = 'xcvr' - if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PORT_MODULE']: - if KEY not in self.sysfs_obj: - self.sysfs_obj[KEY] = [] - self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/xcvr/i2c", self.sysfs_obj, KEY) - - for attr in dev['i2c']['attr_list']: - self.sysfs_device(attr, "pddf/devices/xcvr/i2c", self.sysfs_obj, KEY) - sysfs_path = "/sys/kernel/pddf/devices/xcvr/i2c/dev_ops" - if sysfs_path not in self.sysfs_obj[KEY]: - self.sysfs_obj[KEY].append(sysfs_path) - list = ['/sys/kernel/pddf/devices/xcvr/i2c/i2c_type', - '/sys/kernel/pddf/devices/xcvr/i2c/i2c_name', - '/sys/kernel/pddf/devices/xcvr/i2c/error', - '/sys/kernel/pddf/devices/xcvr/i2c/attr_ops'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) - - def show_xcvr_device(self, dev, ops): - self.show_xcvr_i2c_device(dev, ops) - return - - def show_cpld_device(self, dev, ops): - KEY = 'cpld' - if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['CPLD']: - if KEY not in self.sysfs_obj: - self.sysfs_obj[KEY] = [] - self.sysfs_device(dev['i2c']['topo_info'], "pddf/devices/cpld", self.sysfs_obj, KEY) - sysfs_path = "/sys/kernel/pddf/devices/cpld/dev_ops" - if sysfs_path not in self.sysfs_obj[KEY]: - self.sysfs_obj[KEY].append(sysfs_path) - list = ['/sys/kernel/pddf/devices/cpld/i2c_type', - '/sys/kernel/pddf/devices/cpld/i2c_name', - '/sys/kernel/pddf/devices/cpld/error'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) - - def show_led_platform_device(self, key, ops): - if ops['attr'] == 'all' or ops['attr'] == 'PLATFORM': - KEY = 'platform' - if KEY not in self.sysfs_obj: - self.sysfs_obj[KEY] = [] - path = 'pddf/devices/platform' - self.sysfs_attr('num_psus', self.data['PLATFORM']['num_psus'], path, self.sysfs_obj, KEY) - self.sysfs_attr('num_fantrays', self.data['PLATFORM']['num_fantrays'], path, self.sysfs_obj, KEY) - - def show_led_device(self, key, ops): - if self.check_led_cmds(key, ops): - KEY = 'led' - if KEY not in self.sysfs_obj: - self.sysfs_obj[KEY] = [] - path = "pddf/devices/led" - for attr in self.data[key]['i2c']['attr_list']: - self.sysfs_attr('device_name', self.data[key]['dev_info']['device_name'], path, self.sysfs_obj, KEY) - self.sysfs_attr('swpld_addr', self.data[key]['dev_info']['device_name'], path, self.sysfs_obj, KEY) - self.sysfs_attr('swpld_addr_offset', self.data[key]['dev_info']['device_name'], path, - self.sysfs_obj, KEY) - self.sysfs_device(self.data[key]['dev_attr'], path, self.sysfs_obj, KEY) - for attr_key in attr.keys(): - attr_path = "pddf/devices/led/" + attr['attr_name'] - if (attr_key != 'attr_name' and attr_key != 'swpld_addr' and attr_key != 'swpld_addr_offset'): - self.sysfs_attr(attr_key, attr[attr_key], attr_path, self.sysfs_obj, KEY) - sysfs_path = "/sys/kernel/pddf/devices/led/dev_ops" - if sysfs_path not in self.sysfs_obj[KEY]: - self.sysfs_obj[KEY].append(sysfs_path) - list = ['/sys/kernel/pddf/devices/led/cur_state/color', - '/sys/kernel/pddf/devices/led/cur_state/color_state'] - self.add_list_sysfs_obj(self.sysfs_obj, KEY, list) - - def validate_xcvr_device(self, dev, ops): - devtype_list = ['optoe1', 'optoe2'] - dev_attribs = ['xcvr_present', 'xcvr_reset', 'xcvr_intr_status', 'xcvr_lpmode'] - ret_val = "xcvr validation failed" - - if dev['i2c']['topo_info']['dev_type'] in devtype_list: - for attr in dev['i2c']['attr_list']: - if 'attr_name' in attr.keys() and 'eeprom' in attr.values(): - ret_val = "xcvr validation success" - else: - print("xcvr validation Failed") - return - - elif dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PORT_MODULE']: - for attr in dev['i2c']['attr_list']: - if attr.get("attr_name") in dev_attribs: - ret_val = "Success" - else: - print("xcvr validation Failed") - return - print(ret_val) - - def validate_eeprom_device(self, dev, ops): - devtype_list = ['24c02'] - dev_access_mode = ['BLOCK', 'BYTE'] - dev_attribs = ['eeprom'] - ret_val = "eeprom failed" - - if dev['i2c']['topo_info']['dev_type'] in devtype_list: - if dev['i2c']['dev_attr']['access_mode'] in dev_access_mode: - for attr in dev['i2c']['attr_list']: - if attr.get("attr_name") in dev_attribs: - ret_val = "eeprom success" - print(ret_val) - - def validate_mux_device(self, dev, ops): - devtype_list = ['pca9548', 'pca954x'] - dev_channels = ["0", "1", "2", "3", "4", "5", "6", "7"] - ret_val = "mux failed" - - if dev['i2c']['topo_info']['dev_type'] in devtype_list: - for attr in dev['i2c']['channel']: - if attr.get("chn") in dev_channels: - ret_val = "Mux success" - print(ret_val) - - def validate_cpld_device(self, dev, ops): - devtype_list = ['i2c_cpld'] - ret_val = "cpld failed" - - if dev['i2c']['topo_info']['dev_type'] in devtype_list: - ret_val = "cpld success" - print(ret_val) - - def validate_sysstatus_device(self, dev, ops): - dev_attribs = ['board_info', 'cpld1_version', 'power_module_status', 'system_reset5', - 'system_reset6', 'system_reset7', 'misc1', 'cpld2_version', 'cpld3_version' - ] - ret_val = "sysstatus failed" - - if dev['dev_info']['device_type'] == "SYSSTAT": - for attr in dev['attr_list']: - if attr.get("attr_name") in dev_attribs: - ret_val = "sysstatus success" - print(ret_val) - - def validate_temp_sensor_device(self, dev, ops): - devtype_list = ['lm75'] - dev_attribs = ['temp1_max', 'temp1_max_hyst', 'temp1_input'] - ret_val = "temp sensor failed" - - if dev['dev_info']['device_type'] == "TEMP_SENSOR": - if dev['i2c']['topo_info']['dev_type'] in devtype_list: - for attr in dev['i2c']['attr_list']: - if attr.get("attr_name") in dev_attribs: - ret_val = "tempsensor success" - print(ret_val) - - def validate_fan_device(self, dev, ops): - ret_val = "fan failed" - - if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['FAN']: - if dev['i2c']['dev_attr']['num_fan'] is not None: - ret_val = "fan success" - - print(ret_val) - - def validate_psu_device(self, dev, ops): - dev_attribs = ['psu_present', 'psu_model_name', 'psu_power_good', 'psu_mfr_id', 'psu_serial_num', - 'psu_fan_dir', 'psu_v_out', 'psu_i_out', 'psu_p_out', 'psu_fan1_speed_rpm' - ] - ret_val = "psu failed" - - if dev['i2c']['topo_info']['dev_type'] in self.data['PLATFORM']['pddf_dev_types']['PSU']: - for attr in dev['i2c']['attr_list']: - if attr.get("attr_name") in dev_attribs: - if attr.get("attr_devaddr") is not None: - if attr.get("attr_offset") is not None: - if attr.get("attr_mask") is not None: - if attr.get("attr_len") is not None: - ret_val = "psu success" - else: - ret_val = "psu failed" - - print(ret_val) - ################################################################################################################### # SPYTEST ################################################################################################################### @@ -858,63 +577,6 @@ def verify_sysfs_data(self, verify_type): if (entry == 'swpld_addr' or entry == 'swpld_addr_offset'): self.verify_attr(entry, attr, 'pddf/devices/led') - def schema_validation(self, validate_type): - process_validate_type = 0 - for key in self.data.keys(): - if (key != 'PLATFORM'): - temp_obj = {} - schema_list = [] - try: - device_type = self.data[key]["dev_info"]["device_type"] - except Exception as e: - print("dev_info or device_type ERROR: " + key) - print(e) - - if validate_type == 'mismatch': - process_validate_type = 1 - device_type = "PSU" - schema_file = "/usr/local/bin/schema/FAN.schema" - schema_list.append(schema_file) - elif validate_type == 'missing': - process_validate_type = 1 - schema_file = "/usr/local/bin/schema/PLATFORM.schema" - schema_list.append(schema_file) - - elif validate_type == 'empty': - process_validate_type = 1 - if not device_type: - print("Empty device_type for " + key) - continue - elif (validate_type == 'all' or validate_type == device_type): - process_validate_type = 1 - if "bmc" in self.data[key].keys(): - schema_file = "/usr/local/bin/schema/"+device_type + "_BMC.schema" - schema_list.append(schema_file) - - if "i2c" in self.data[key].keys(): - schema_file = "/usr/local/bin/schema/"+device_type + ".schema" - schema_list.append(schema_file) - if device_type: - temp_obj[device_type] = self.data[key] - for schema_file in schema_list: - if (os.path.exists(schema_file)): - print("Validate " + schema_file + ";" + key) - json_data = json.dumps(temp_obj) - with open(schema_file, 'r') as f: - schema = json.load(f) - try: - validate(temp_obj, schema) - except Exception as e: - print("Validation ERROR: " + schema_file + ";" + key) - if validate_type == 'mismatch': - return - else: - print(e) - else: - print("ERROR Missing File: " + schema_file) - if not process_validate_type: - print("device_type: " + validate_type + " not configured") - def modules_validation(self, validate_type): kos = [] supported_type = False @@ -935,7 +597,7 @@ def modules_validation(self, validate_type): supported_type = True cmd = "lsmod | grep " + mod try: - subprocess.check_output(cmd, shell=True) + subprocess.check_output(cmd, shell=True, universal_newlines=True) except Exception as e: module_validation_status.append(mod) if supported_type: @@ -952,229 +614,176 @@ def modules_validation(self, validate_type): ################################################################################################################### def psu_parse(self, dev, ops): - parse_str = "" - ret = "" - for ifce in dev['i2c']['interface']: - ret = getattr(self, ops['cmd']+"_psu_device")(self.data[ifce['dev']], ops) - if ret is not None: - if str(ret).isdigit(): - if ret != 0: + ret = [] + for ifce in (dev['i2c']['interface'] if 'i2c' in dev else []): + val = getattr(self, ops['cmd']+"_psu_device")(self.data[ifce['dev']], ops) + if val: + if str(val[0]).isdigit(): + if val[0] != 0: # in case if 'create' functions - print("{}_psu_device failed".format(ops['cmd'])) - return ret - else: - pass + print("{}_psu_device failed for {}".format(ops['cmd'], ifce['dev'])) + return val else: # in case of 'show_attr' functions - parse_str += ret - return parse_str + ret.extend(val) + return ret def fan_parse(self, dev, ops): - parse_str = "" + ret = [] ret = getattr(self, ops['cmd']+"_fan_device")(dev, ops) - if ret is not None: - if str(ret).isdigit(): - if ret != 0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print("{}_fan_device failed".format(ops['cmd'])) - return ret - else: - pass - else: - # in case of 'show_attr' functions - parse_str += ret + print("{}_fan_device failed for {}".format(ops['cmd'], dev['dev_info']['device_name'])) - return parse_str + return ret def temp_sensor_parse(self, dev, ops): - parse_str = "" + ret = [] ret = getattr(self, ops['cmd']+"_temp_sensor_device")(dev, ops) - if ret is not None: - if str(ret).isdigit(): - if ret != 0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print("{}_temp_sensor_device failed".format(ops['cmd'])) - return ret - else: - pass - else: - # in case of 'show_attr' functions - parse_str += ret + print("{}_temp_sensor_device failed for {}".format(ops['cmd'], dev['dev_info']['device_name'])) - return parse_str + return ret def cpld_parse(self, dev, ops): - parse_str = "" + ret = [] ret = getattr(self, ops['cmd']+"_cpld_device")(dev, ops) - if ret is not None: - if str(ret).isdigit(): - if ret != 0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print("{}_cpld_device failed".format(ops['cmd'])) - return ret - else: - pass - else: - # in case of 'show_attr' functions - parse_str += ret + print("{}_cpld_device failed for {}".format(ops['cmd'], dev['dev_info']['device_name'])) - return parse_str + return ret def sysstatus_parse(self, dev, ops): - parse_str = "" + ret = [] ret = getattr(self, ops['cmd']+"_sysstatus_device")(dev, ops) - if ret is not None: - if str(ret).isdigit(): - if ret != 0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print("{}_sysstatus_device failed".format(ops['cmd'])) - return ret - else: - pass - else: - # in case of 'show_attr' functions - parse_str += ret + print("{}_sysstatus_device failed for {}".format(ops['cmd'], dev['dev_info']['device_name'])) - return parse_str + return ret def gpio_parse(self, dev, ops): - parse_str = "" + ret = [] ret = getattr(self, ops['cmd']+"_gpio_device")(dev, ops) - if ret is not None: - if str(ret).isdigit(): - if ret != 0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print("{}_temp_sensor_device failed".format(ops['cmd'])) - return ret - else: - pass - else: - # in case of 'show_attr' functions - parse_str += ret + print("{}_gpio_device failed for {}".format(ops['cmd'], dev['dev_info']['device_name'])) - return parse_str + return ret def mux_parse(self, dev, ops): - parse_str = "" + val = [] ret = getattr(self, ops['cmd']+"_mux_device")(dev, ops) - if ret is not None: - if str(ret).isdigit(): - if ret != 0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print("{}_mux_device() cmd failed".format(ops['cmd'])) + print("{}_mux_device() cmd failed for {}".format(ops['cmd'], dev['dev_info']['device_name'])) return ret - else: - pass else: - parse_str += ret + val.extend(ret) for ch in dev['i2c']['channel']: ret = self.dev_parse(self.data[ch['dev']], ops) - if ret is not None: - if str(ret).isdigit(): - if ret != 0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions return ret - else: - pass else: - parse_str += ret - return parse_str + val.extend(ret) + return val def mux_parse_reverse(self, dev, ops): - parse_str = "" + val = [] for ch in reversed(dev['i2c']['channel']): ret = self.dev_parse(self.data[ch['dev']], ops) - if ret is not None: - if str(ret).isdigit(): - if ret != 0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions return ret - else: - pass else: - parse_str += ret + val.extend(ret) ret = getattr(self, ops['cmd']+"_mux_device")(dev, ops) - if ret is not None: - if str(ret).isdigit(): - if ret != 0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print("{}_mux_device() cmd failed".format(ops['cmd'])) + print("{}_mux_device() cmd failed for {}".format(ops['cmd'], dev['dev_info']['device_name'])) return ret - else: - pass else: - parse_str += ret + val.extend(ret) - return parse_str + return val def eeprom_parse(self, dev, ops): - parse_str = "" + ret = [] ret = getattr(self, ops['cmd']+"_eeprom_device")(dev, ops) - if ret is not None: - if str(ret).isdigit(): - if ret != 0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print("{}_eeprom_device() cmd failed".format(ops['cmd'])) - return ret - else: - pass - else: - parse_str += ret + print("{}_eeprom_device() cmd failed for {}".format(ops['cmd'], dev['dev_info']['device_name'])) - return parse_str + return ret def optic_parse(self, dev, ops): - parse_str = "" - ret = "" + val = [] for ifce in dev['i2c']['interface']: ret = getattr(self, ops['cmd']+"_xcvr_device")(self.data[ifce['dev']], ops) - if ret is not None: - if str(ret).isdigit(): - if ret != 0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions - print("{}_eeprom_device() cmd failed".format(ops['cmd'])) + print("{}_xcvr_device() cmd failed for {}".format(ops['cmd'], ifce['dev'])) return ret - else: - pass else: - parse_str += ret - return parse_str + val.extend(ret) + return val def cpu_parse(self, bus, ops): - parse_str = "" + val = [] for dev in bus['i2c']['CONTROLLERS']: dev1 = self.data[dev['dev']] for d in dev1['i2c']['DEVICES']: ret = self.dev_parse(self.data[d['dev']], ops) - if ret is not None: - if str(ret).isdigit(): - if ret != 0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions return ret - else: - pass else: - parse_str += ret - return parse_str + val.extend(ret) + return val def cpu_parse_reverse(self, bus, ops): - parse_str = "" + val = [] for dev in reversed(bus['i2c']['CONTROLLERS']): dev1 = self.data[dev['dev']] for d in dev1['i2c']['DEVICES']: ret = self.dev_parse(self.data[d['dev']], ops) - if ret is not None: - if str(ret).isdigit(): - if ret != 0: + if ret: + if str(ret[0]).isdigit(): + if ret[0] != 0: # in case if 'create' functions return ret - else: - pass else: - parse_str += ret - return parse_str + val.extend(ret) + return val def dev_parse(self, dev, ops): attr = dev['dev_info'] @@ -1206,6 +815,7 @@ def dev_parse(self, dev, ops): return self.temp_sensor_parse(dev, ops) if attr['device_type'] == 'SFP' or attr['device_type'] == 'QSFP' or \ + attr['device_type'] == 'SFP+' or attr['device_type'] == 'QSFP+' or \ attr['device_type'] == 'SFP28' or attr['device_type'] == 'QSFP28' or \ attr['device_type'] == 'QSFP-DD': return self.optic_parse(dev, ops) @@ -1228,28 +838,6 @@ def create_attr(self, key, value, path): cmd = "echo '%s' > /sys/kernel/%s/%s" % (value, path, key) self.runcmd(cmd) - def create_led_platform_device(self, key, ops): - if ops['attr'] == 'all' or ops['attr'] == 'PLATFORM': - path = 'pddf/devices/platform' - self.create_attr('num_psus', self.data['PLATFORM']['num_psus'], path) - self.create_attr('num_fantrays', self.data['PLATFORM']['num_fantrays'], path) - - def create_led_device(self, key, ops): - if ops['attr'] == 'all' or ops['attr'] == self.data[key]['dev_info']['device_name']: - path = "pddf/devices/led" - for attr in self.data[key]['i2c']['attr_list']: - self.create_attr('device_name', self.data[key]['dev_info']['device_name'], path) - self.create_device(self.data[key]['dev_attr'], path, ops) - for attr_key in attr.keys(): - if (attr_key == 'swpld_addr_offset' or attr_key == 'swpld_addr'): - self.create_attr(attr_key, attr[attr_key], path) - elif (attr_key != 'attr_name' and attr_key != 'descr' and attr_key != 'attr_devtype' and - attr_key != 'attr_devname'): - state_path = path+'/state_attr' - self.create_attr(attr_key, attr[attr_key], state_path) - cmd = "echo '" + attr['attr_name']+"' > /sys/kernel/pddf/devices/led/dev_ops" - self.runcmd(cmd) - def led_parse(self, ops): getattr(self, ops['cmd']+"_led_platform_device")("PLATFORM", ops) for key in self.data.keys(): @@ -1265,29 +853,6 @@ def get_device_list(self, list, type): if attr['device_type'] == type: list.append(self.data[key]) - def create_pddf_devices(self): - self.led_parse({"cmd": "create", "target": "all", "attr": "all"}) - create_ret = 0 - create_ret = self.dev_parse(self.data['SYSTEM'], {"cmd": "create", "target": "all", "attr": "all"}) - if create_ret != 0: - return create_ret - if 'SYSSTATUS' in self.data: - create_ret = self.dev_parse(self.data['SYSSTATUS'], {"cmd": "create", "target": "all", "attr": "all"}) - if create_ret != 0: - return create_ret - - def delete_pddf_devices(self): - self.dev_parse(self.data['SYSTEM'], {"cmd": "delete", "target": "all", "attr": "all"}) - if 'SYSSTATUS' in self.data: - self.dev_parse(self.data['SYSSTATUS'], {"cmd": "delete", "target": "all", "attr": "all"}) - - def populate_pddf_sysfsobj(self): - self.dev_parse(self.data['SYSTEM'], {"cmd": "show", "target": "all", "attr": "all"}) - if 'SYSSTATUS' in self.data: - self.dev_parse(self.data['SYSSTATUS'], {"cmd": "show", "target": "all", "attr": "all"}) - self.led_parse({"cmd": "show", "target": "all", "attr": "all"}) - self.show_client_device() - def cli_dump_dsysfs(self, component): self.dev_parse(self.data['SYSTEM'], {"cmd": "show_attr", "target": "all", "attr": "all"}) if 'SYSSTATUS' in self.data: @@ -1297,23 +862,30 @@ def cli_dump_dsysfs(self, component): else: return None - def validate_pddf_devices(self, *args): - self.populate_pddf_sysfsobj() - v_ops = {'cmd': 'validate', 'target': 'all', 'attr': 'all'} - self.dev_parse(self.data['SYSTEM'], v_ops) - ################################################################################################################### # BMC APIs ################################################################################################################### def populate_bmc_cache_db(self, bmc_attr): bmc_cmd = str(bmc_attr['bmc_cmd']).strip() - o_list = subprocess.check_output(bmc_cmd, shell=True).strip().split('\n') - bmc_cache[bmc_cmd] = {} - bmc_cache[bmc_cmd]['time'] = time.time() + sdr_dump_file = "/usr/local/sdr_dump" + __bmc_cmd = bmc_cmd + if 'ipmitool' in bmc_cmd: + if not os.path.isfile(sdr_dump_file): + sdr_dump_cmd = "ipmitool sdr dump " + sdr_dump_file + subprocess.check_output(sdr_dump_cmd, shell=True, universal_newlines=True) + dump_cmd = "ipmitool -S " + sdr_dump_file + __bmc_cmd = __bmc_cmd.replace("ipmitool", dump_cmd, 1) + o_list = subprocess.check_output(__bmc_cmd, shell=True, universal_newlines=True).strip().split('\n') + bmc_cache[bmc_cmd]={} + bmc_cache[bmc_cmd]['time']=time.time() for entry in o_list: - name = entry.split()[0] - bmc_cache[bmc_cmd][name] = entry + if 'separator' in bmc_attr.keys(): + name = str(entry.split(bmc_attr['separator'])[0]).strip() + else: + name = str(entry.split()[0]).strip() + + bmc_cache[bmc_cmd][name]=entry def non_raw_ipmi_get_request(self, bmc_attr): bmc_db_update_time = 1 @@ -1330,16 +902,19 @@ def non_raw_ipmi_get_request(self, bmc_attr): self.populate_bmc_cache_db(bmc_attr) try: - data = bmc_cache[bmc_cmd][field_name] - value = data.split()[field_pos] + data=bmc_cache[bmc_cmd][field_name] + if 'separator' in bmc_attr: + value = data.split(bmc_attr['separator'])[field_pos].strip() + else: + value = data.split()[field_pos].strip() except Exception as e: - pass + pass - if 'mult' in bmc_attr.keys() and not value.isalpha(): - if value.isalpha(): + if 'mult' in bmc_attr.keys(): + if value.replace('.','',1).strip().isdigit(): + value = float(value) * float(bmc_attr['mult']) + else: value = 0.0 - value = float(value) * float(bmc_attr['mult']) - return str(value) def raw_ipmi_get_request(self, bmc_attr): @@ -1347,7 +922,7 @@ def raw_ipmi_get_request(self, bmc_attr): cmd = bmc_attr['bmc_cmd'] + " 2>/dev/null" if bmc_attr['type'] == 'raw': try: - value = subprocess.check_output(cmd, shell=True).strip() + value = subprocess.check_output(cmd, shell=True, universal_newlines=True).strip() except Exception as e: pass @@ -1358,7 +933,7 @@ def raw_ipmi_get_request(self, bmc_attr): if bmc_attr['type'] == 'mask': mask = int(bmc_attr['mask'].encode('utf-8'), 16) try: - value = subprocess.check_output(cmd, shell=True).strip() + value = subprocess.check_output(cmd, shell=True, universal_newlines=True).strip() except Exception as e: pass @@ -1369,7 +944,7 @@ def raw_ipmi_get_request(self, bmc_attr): if bmc_attr['type'] == 'ascii': try: - value = subprocess.check_output(cmd, shell=True) + value = subprocess.check_output(cmd, shell=True, universal_newlines=True).strip() except Exception as e: pass @@ -1423,18 +998,19 @@ def get_attr_name_output(self, device_name, attr_name): bmc_attr = self.check_bmc_based_attr(device_name, attr_name) output = {"mode": "", "status": ""} - if bmc_attr is not None: - if bmc_attr == {}: - return {} - output['mode'] = "bmc" - output['status'] = self.bmc_get_cmd(bmc_attr) + if bmc_attr is not None and bmc_attr!={}: + output['mode']="bmc" + output['status']=self.bmc_get_cmd(bmc_attr) else: - output['mode'] = "i2c" + # bmc_attr is either None or {}. In both the cases, its highly likely that the attribute + # is i2c based + output['mode']="i2c" node = self.get_path(device_name, attr_name) if node is None: return {} try: - with open(node, 'r') as f: + # Seen some errors in case of unencodable characters hence ignoring them in python3 + with open(node, 'r', errors='ignore') as f: output['status'] = f.read() except IOError: return {} diff --git a/platform/vs/docker-syncd-vs.mk b/platform/vs/docker-syncd-vs.mk index cbd1f9737764..7ec1ddd5d537 100644 --- a/platform/vs/docker-syncd-vs.mk +++ b/platform/vs/docker-syncd-vs.mk @@ -16,5 +16,3 @@ $(DOCKER_SYNCD_BASE)_VERSION = 1.0.0 $(DOCKER_SYNCD_BASE)_PACKAGE_NAME = syncd $(DOCKER_SYNCD_BASE)_RUN_OPT += -v /host/warmboot:/var/warmboot - -SONIC_BUSTER_DOCKERS += $(DOCKER_SYNCD_BASE) diff --git a/rules/docker-base-bullseye.dep b/rules/docker-base-bullseye.dep new file mode 100644 index 000000000000..a127e26f16fa --- /dev/null +++ b/rules/docker-base-bullseye.dep @@ -0,0 +1,9 @@ + +DPATH := $($(DOCKER_BASE_BULLSEYE)_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/docker-base-bullseye.mk rules/docker-base-bullseye.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES += $(shell git ls-files $(DPATH)) + +$(DOCKER_BASE_BULLSEYE)_CACHE_MODE := GIT_CONTENT_SHA +$(DOCKER_BASE_BULLSEYE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(DOCKER_BASE_BULLSEYE)_DEP_FILES := $(DEP_FILES) diff --git a/rules/docker-base-bullseye.mk b/rules/docker-base-bullseye.mk new file mode 100644 index 000000000000..fcebb554c777 --- /dev/null +++ b/rules/docker-base-bullseye.mk @@ -0,0 +1,16 @@ +# Docker base image (based on Debian Bullseye) + +DOCKER_BASE_BULLSEYE = docker-base-bullseye.gz +$(DOCKER_BASE_BULLSEYE)_PATH = $(DOCKERS_PATH)/docker-base-bullseye + +$(DOCKER_BASE_BULLSEYE)_DEPENDS += $(SOCAT) + +GDB = gdb +GDBSERVER = gdbserver +VIM = vim +OPENSSH = openssh-client +SSHPASS = sshpass +STRACE = strace +$(DOCKER_BASE_BULLSEYE)_DBG_IMAGE_PACKAGES += $(GDB) $(GDBSERVER) $(VIM) $(OPENSSH) $(SSHPASS) $(STRACE) + +SONIC_DOCKER_IMAGES += $(DOCKER_BASE_BULLSEYE) diff --git a/rules/docker-config-engine-bullseye.dep b/rules/docker-config-engine-bullseye.dep new file mode 100644 index 000000000000..b1435dba50a7 --- /dev/null +++ b/rules/docker-config-engine-bullseye.dep @@ -0,0 +1,9 @@ + +DPATH := $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/docker-config-engine-bullseye.mk rules/docker-config-engine-bullseye.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES += $(shell git ls-files $(DPATH)) + +$(DOCKER_CONFIG_ENGINE_BULLSEYE)_CACHE_MODE := GIT_CONTENT_SHA +$(DOCKER_CONFIG_ENGINE_BULLSEYE)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(DOCKER_CONFIG_ENGINE_BULLSEYE)_DEP_FILES := $(DEP_FILES) diff --git a/rules/docker-config-engine-bullseye.mk b/rules/docker-config-engine-bullseye.mk new file mode 100644 index 000000000000..eae426a111df --- /dev/null +++ b/rules/docker-config-engine-bullseye.mk @@ -0,0 +1,25 @@ +# docker image for sonic config engine + +DOCKER_CONFIG_ENGINE_BULLSEYE = docker-config-engine-bullseye.gz +$(DOCKER_CONFIG_ENGINE_BULLSEYE)_PATH = $(DOCKERS_PATH)/docker-config-engine-bullseye + +$(DOCKER_CONFIG_ENGINE_BULLSEYE)_DEPENDS += $(LIBSWSSCOMMON) \ + $(LIBYANG) \ + $(LIBYANG_CPP) \ + $(LIBYANG_PY3) \ + $(PYTHON3_SWSSCOMMON) +$(DOCKER_CONFIG_ENGINE_BULLSEYE)_PYTHON_WHEELS += $(SWSSSDK_PY3) +$(DOCKER_CONFIG_ENGINE_BULLSEYE)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY3) \ + $(SONIC_YANG_MGMT_PY3) \ + $(SONIC_YANG_MODELS_PY3) +$(DOCKER_CONFIG_ENGINE_BULLSEYE)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY3) +$(DOCKER_CONFIG_ENGINE_BULLSEYE)_LOAD_DOCKERS += $(DOCKER_BASE_BULLSEYE) +$(DOCKER_CONFIG_ENGINE_BULLSEYE)_FILES += $(SWSS_VARS_TEMPLATE) +$(DOCKER_CONFIG_ENGINE_BULLSEYE)_FILES += $($(SONIC_CTRMGRD)_CONTAINER_SCRIPT) + +$(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_DEPENDS = $($(DOCKER_BASE_BULLSEYE)_DBG_DEPENDS) \ + $(LIBSWSSCOMMON_DBG) \ + $(LIBHIREDIS_DBG) +$(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_IMAGE_PACKAGES = $($(DOCKER_BASE_BULLSEYE)_DBG_IMAGE_PACKAGES) + +SONIC_DOCKER_IMAGES += $(DOCKER_CONFIG_ENGINE_BULLSEYE) diff --git a/rules/docker-dhcp-relay.mk b/rules/docker-dhcp-relay.mk index d1460e5cbd33..5e3f84f05111 100644 --- a/rules/docker-dhcp-relay.mk +++ b/rules/docker-dhcp-relay.mk @@ -8,12 +8,12 @@ $(DOCKER_DHCP_RELAY)_PATH = $(DOCKERS_PATH)/$(DOCKER_DHCP_RELAY_STEM) $(DOCKER_DHCP_RELAY)_DEPENDS += $(ISC_DHCP_RELAY) $(SONIC_DHCPMON) $(SONIC_DHCP6RELAY) $(LIBSWSSCOMMON) -$(DOCKER_DHCP_RELAY)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS) +$(DOCKER_DHCP_RELAY)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_DEPENDS) $(DOCKER_DHCP_RELAY)_DBG_DEPENDS += $(ISC_DHCP_RELAY_DBG) $(SONIC_DHCP6RELAY_DBG) -$(DOCKER_DHCP_RELAY)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES) +$(DOCKER_DHCP_RELAY)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_IMAGE_PACKAGES) -$(DOCKER_DHCP_RELAY)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_BUSTER) +$(DOCKER_DHCP_RELAY)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_BULLSEYE) $(DOCKER_DHCP_RELAY)_INSTALL_PYTHON_WHEELS = $(SONIC_UTILITIES_PY3) $(DOCKER_DHCP_RELAY)_INSTALL_DEBS = $(PYTHON3_SWSSCOMMON) @@ -56,6 +56,3 @@ $(DOCKER_DHCP_RELAY)_CLI_SHOW_PLUGIN = /cli/show/plugins/show_dhcp_relay.py $(DOCKER_DHCP_RELAY)_CLI_CLEAR_PLUGIN = /cli/clear/plugins/clear_dhcp6relay_counter.py $(DOCKER_DHCP_RELAY)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) - -SONIC_BUSTER_DOCKERS += $(DOCKER_DHCP_RELAY) -SONIC_BUSTER_DBG_DOCKERS += $(DOCKER_DHCP_RELAY_DBG) diff --git a/rules/docker-fpm-frr.mk b/rules/docker-fpm-frr.mk index b6c4f2e0e02f..2249f828a48c 100644 --- a/rules/docker-fpm-frr.mk +++ b/rules/docker-fpm-frr.mk @@ -8,13 +8,13 @@ $(DOCKER_FPM_FRR)_PATH = $(DOCKERS_PATH)/$(DOCKER_FPM_FRR_STEM) $(DOCKER_FPM_FRR)_PYTHON_WHEELS += $(SONIC_BGPCFGD) $(SONIC_FRR_MGMT_FRAMEWORK) $(DOCKER_FPM_FRR)_DEPENDS += $(FRR) $(FRR_SNMP) $(SWSS) $(LIBYANG1) -$(DOCKER_FPM_FRR)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS) +$(DOCKER_FPM_FRR)_DBG_DEPENDS = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_DEPENDS) $(DOCKER_FPM_FRR)_DBG_DEPENDS += $(SWSS_DBG) $(LIBSWSSCOMMON_DBG) \ $(FRR_DBG) $(FRR_SNMP_DBG) $(LIBYANG1_DBG) -$(DOCKER_FPM_FRR)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES) +$(DOCKER_FPM_FRR)_DBG_IMAGE_PACKAGES = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_IMAGE_PACKAGES) -$(DOCKER_FPM_FRR)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER) +$(DOCKER_FPM_FRR)_LOAD_DOCKERS += $(DOCKER_SWSS_LAYER_BUSTER) $(DOCKER_FPM_FRR)_VERSION = 1.0.0 $(DOCKER_FPM_FRR)_PACKAGE_NAME = fpm-frr diff --git a/rules/docker-macsec.mk b/rules/docker-macsec.mk index 3ffdf1bd6f76..1cb14246e86a 100644 --- a/rules/docker-macsec.mk +++ b/rules/docker-macsec.mk @@ -7,13 +7,13 @@ DOCKER_MACSEC_DBG = $(DOCKER_MACSEC_STEM)-$(DBG_IMAGE_MARK).gz $(DOCKER_MACSEC)_PATH = $(DOCKERS_PATH)/$(DOCKER_MACSEC_STEM) $(DOCKER_MACSEC)_DEPENDS += $(SWSS) $(WPASUPPLICANT) $(REDIS_TOOLS) $(LIBNL3) $(LIBNL_GENL3) $(LIBNL_ROUTE3) -$(DOCKER_MACSEC)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS) +$(DOCKER_MACSEC)_DBG_DEPENDS = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_DEPENDS) $(DOCKER_MACSEC)_DBG_DEPENDS += $(SWSS_DBG) $(LIBSWSSCOMMON_DBG) $(DOCKER_MACSEC)_DBG_DEPENDS += $(WPASUPPLICANT_DBG) -$(DOCKER_MACSEC)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES) +$(DOCKER_MACSEC)_DBG_IMAGE_PACKAGES = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_IMAGE_PACKAGES) -$(DOCKER_MACSEC)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER) +$(DOCKER_MACSEC)_LOAD_DOCKERS += $(DOCKER_SWSS_LAYER_BUSTER) SONIC_DOCKER_IMAGES += $(DOCKER_MACSEC) ifeq ($(INCLUDE_MACSEC), y) diff --git a/rules/docker-nat.mk b/rules/docker-nat.mk index 07aa02b0149b..6e73ac9aec4b 100644 --- a/rules/docker-nat.mk +++ b/rules/docker-nat.mk @@ -7,11 +7,11 @@ DOCKER_NAT_DBG = $(DOCKER_NAT_STEM)-$(DBG_IMAGE_MARK).gz $(DOCKER_NAT)_PATH = $(DOCKERS_PATH)/$(DOCKER_NAT_STEM) $(DOCKER_NAT)_DEPENDS += $(SWSS) $(IPTABLESIP4TC) $(IPTABLESIP6TC) $(IPTABLESIPTC) $(IPXTABLES12) $(IPTABLES) -$(DOCKER_NAT)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS) +$(DOCKER_NAT)_DBG_DEPENDS = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_DEPENDS) $(DOCKER_NAT)_DBG_DEPENDS += $(SWSS_DBG) $(LIBSWSSCOMMON_DBG) -$(DOCKER_NAT)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES) +$(DOCKER_NAT)_DBG_IMAGE_PACKAGES = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_IMAGE_PACKAGES) -$(DOCKER_NAT)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER) +$(DOCKER_NAT)_LOAD_DOCKERS += $(DOCKER_SWSS_LAYER_BUSTER) $(DOCKER_NAT)_VERSION = 1.0.0 $(DOCKER_NAT)_PACKAGE_NAME = nat diff --git a/rules/docker-orchagent.mk b/rules/docker-orchagent.mk index 2b7a3f34eec5..d9453465c702 100644 --- a/rules/docker-orchagent.mk +++ b/rules/docker-orchagent.mk @@ -6,16 +6,16 @@ DOCKER_ORCHAGENT_DBG = $(DOCKER_ORCHAGENT_STEM)-$(DBG_IMAGE_MARK).gz $(DOCKER_ORCHAGENT)_DEPENDS += $(SWSS) -$(DOCKER_ORCHAGENT)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS) +$(DOCKER_ORCHAGENT)_DBG_DEPENDS = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_DEPENDS) $(DOCKER_ORCHAGENT)_DBG_DEPENDS += $(SWSS_DBG) \ $(LIBSWSSCOMMON_DBG) \ $(LIBSAIREDIS_DBG) -$(DOCKER_ORCHAGENT)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES) +$(DOCKER_ORCHAGENT)_DBG_IMAGE_PACKAGES = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_IMAGE_PACKAGES) $(DOCKER_ORCHAGENT)_PATH = $(DOCKERS_PATH)/$(DOCKER_ORCHAGENT_STEM) -$(DOCKER_ORCHAGENT)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER) +$(DOCKER_ORCHAGENT)_LOAD_DOCKERS += $(DOCKER_SWSS_LAYER_BUSTER) $(DOCKER_ORCHAGENT)_VERSION = 1.0.0 $(DOCKER_ORCHAGENT)_PACKAGE_NAME = swss diff --git a/rules/docker-platform-monitor.mk b/rules/docker-platform-monitor.mk index 84bffd3c61e7..d21598851914 100644 --- a/rules/docker-platform-monitor.mk +++ b/rules/docker-platform-monitor.mk @@ -6,23 +6,14 @@ DOCKER_PLATFORM_MONITOR_DBG = $(DOCKER_PLATFORM_MONITOR_STEM)-$(DBG_IMAGE_MARK). $(DOCKER_PLATFORM_MONITOR)_PATH = $(DOCKERS_PATH)/$(DOCKER_PLATFORM_MONITOR_STEM) -$(DOCKER_PLATFORM_MONITOR)_DEPENDS += $(LIBSENSORS) $(LM_SENSORS) $(FANCONTROL) $(SENSORD) $(LIBSWSSCOMMON) $(PYTHON_SWSSCOMMON) $(PYTHON3_SWSSCOMMON) $(SMARTMONTOOLS) $(ETHTOOL) +$(DOCKER_PLATFORM_MONITOR)_DEPENDS += $(LIBSENSORS) $(LM_SENSORS) $(FANCONTROL) $(SENSORD) $(LIBSWSSCOMMON) $(PYTHON3_SWSSCOMMON) $(ETHTOOL) + -$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY2) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY3) -$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SWSSSDK_PY2) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SWSSSDK_PY3) -$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY2) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY3) -$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY2) -$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_API_PY2) +$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY3) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_API_PY3) -$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_LEDD_PY2) -$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PCIED_PY2) -$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PSUD_PY2) -$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_SYSEEPROMD_PY2) -$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_THERMALCTLD_PY2) -$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_XCVRD_PY2) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_LEDD_PY3) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PCIED_PY3) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PSUD_PY3) @@ -32,7 +23,6 @@ $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_XCVRD_PY3) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_CHASSISD_PY3) ifeq ($(PDDF_SUPPORT),y) -$(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(PDDF_PLATFORM_API_BASE_PY2) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(PDDF_PLATFORM_API_BASE_PY3) endif @@ -66,7 +56,6 @@ $(DOCKER_PLATFORM_MONITOR)_aboot_RUN_OPT += -v /usr/lib/python3/dist-packages/ar $(DOCKER_PLATFORM_MONITOR)_aboot_RUN_OPT += -v /usr/lib/python3/dist-packages/sonic_platform:/usr/lib/python3/dist-packages/sonic_platform:ro $(DOCKER_PLATFORM_MONITOR)_BASE_IMAGE_FILES += cmd_wrapper:/usr/bin/sensors -$(DOCKER_PLATFORM_MONITOR)_BASE_IMAGE_FILES += cmd_wrapper:/usr/sbin/smartctl $(DOCKER_PLATFORM_MONITOR)_BASE_IMAGE_FILES += cmd_wrapper:/usr/sbin/iSmart $(DOCKER_PLATFORM_MONITOR)_BASE_IMAGE_FILES += cmd_wrapper:/usr/sbin/SmartCmd $(DOCKER_PLATFORM_MONITOR)_BASE_IMAGE_FILES += cmd_wrapper:/usr/bin/ethtool diff --git a/rules/docker-restapi.mk b/rules/docker-restapi.mk index 5d09dffe03e6..81ea57a89846 100644 --- a/rules/docker-restapi.mk +++ b/rules/docker-restapi.mk @@ -8,14 +8,13 @@ $(DOCKER_RESTAPI)_DEPENDS += $(LIBHIREDIS) $(LIBNL3) $(LIBNL_GENL3) \ $(DOCKER_RESTAPI)_PATH = $(DOCKERS_PATH)/$(DOCKER_RESTAPI_STEM) -$(DOCKER_RESTAPI)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_STRETCH) +$(DOCKER_RESTAPI)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BULLSEYE) $(DOCKER_RESTAPI)_VERSION = 1.0.0 $(DOCKER_RESTAPI)_PACKAGE_NAME = restapi ifeq ($(INCLUDE_RESTAPI), y) SONIC_DOCKER_IMAGES += $(DOCKER_RESTAPI) -SONIC_STRETCH_DOCKERS += $(DOCKER_RESTAPI) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_RESTAPI) endif @@ -26,5 +25,3 @@ $(DOCKER_RESTAPI)_RUN_OPT += -v /etc/sonic/credentials:/etc/sonic/credentials:ro $(DOCKER_RESTAPI)_RUN_OPT += -p=8081:8081/tcp $(DOCKER_RESTAPI)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) - -SONIC_BUSTER_DOCKERS += $(DOCKER_RESTAPI) diff --git a/rules/docker-sflow.mk b/rules/docker-sflow.mk index 099291005d90..22a9e538e1bd 100644 --- a/rules/docker-sflow.mk +++ b/rules/docker-sflow.mk @@ -7,11 +7,11 @@ DOCKER_SFLOW_DBG = $(DOCKER_SFLOW_STEM)-$(DBG_IMAGE_MARK).gz $(DOCKER_SFLOW)_PATH = $(DOCKERS_PATH)/$(DOCKER_SFLOW_STEM) $(DOCKER_SFLOW)_DEPENDS += $(SWSS) $(HSFLOWD) $(SFLOWTOOL) $(PSAMPLE) -$(DOCKER_SFLOW)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS) +$(DOCKER_SFLOW)_DBG_DEPENDS = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_DEPENDS) $(DOCKER_TEAMD)_DBG_DEPENDS += $(SWSS_DBG) $(LIBSWSSCOMMON_DBG) -$(DOCKER_SFLOW)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES) +$(DOCKER_SFLOW)_DBG_IMAGE_PACKAGES = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_IMAGE_PACKAGES) -$(DOCKER_SFLOW)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER) +$(DOCKER_SFLOW)_LOAD_DOCKERS += $(DOCKER_SWSS_LAYER_BUSTER) $(DOCKER_SFLOW)_VERSION = 1.0.0 $(DOCKER_SFLOW)_PACKAGE_NAME = sflow diff --git a/rules/docker-swss-layer-buster.dep b/rules/docker-swss-layer-buster.dep new file mode 100644 index 000000000000..d245a29269c3 --- /dev/null +++ b/rules/docker-swss-layer-buster.dep @@ -0,0 +1,10 @@ + +DPATH := $($(DOCKER_SWSS_LAYER_BUSTER)_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/docker-swss-layer-buster.mk rules/docker-swss-layer-buster.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES += $(shell git ls-files $(DPATH)) + +$(DOCKER_SWSS_LAYER_BUSTER)_CACHE_MODE := GIT_CONTENT_SHA +$(DOCKER_SWSS_LAYER_BUSTER)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(DOCKER_SWSS_LAYER_BUSTER)_DEP_FILES := $(DEP_FILES) + diff --git a/rules/docker-swss-layer-buster.mk b/rules/docker-swss-layer-buster.mk new file mode 100644 index 000000000000..f04a09fbca4c --- /dev/null +++ b/rules/docker-swss-layer-buster.mk @@ -0,0 +1,14 @@ +# docker image for sonic swss layer + +DOCKER_SWSS_LAYER_BUSTER = docker-swss-layer-buster.gz +$(DOCKER_SWSS_LAYER_BUSTER)_PATH = $(DOCKERS_PATH)/docker-swss-layer-buster + +$(DOCKER_SWSS_LAYER_BUSTER)_DEPENDS += $(SWSS) +$(DOCKER_SWSS_LAYER_BUSTER)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER) + +$(DOCKER_SWSS_LAYER_BUSTER)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS) \ + $(SWSS) +$(DOCKER_SWSS_LAYER_BUSTER)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES) + +SONIC_DOCKER_IMAGES += $(DOCKER_SWSS_LAYER_BUSTER) +SONIC_BUSTER_DOCKERS += $(DOCKER_SWSS_LAYER_BUSTER) diff --git a/rules/docker-teamd.mk b/rules/docker-teamd.mk index 4d1fe07a55ff..8d978ae66515 100644 --- a/rules/docker-teamd.mk +++ b/rules/docker-teamd.mk @@ -7,13 +7,13 @@ DOCKER_TEAMD_DBG = $(DOCKER_TEAMD_STEM)-$(DBG_IMAGE_MARK).gz $(DOCKER_TEAMD)_PATH = $(DOCKERS_PATH)/$(DOCKER_TEAMD_STEM) $(DOCKER_TEAMD)_DEPENDS += $(SWSS) $(LIBTEAMDCTL) $(LIBTEAM_UTILS) -$(DOCKER_TEAMD)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS) +$(DOCKER_TEAMD)_DBG_DEPENDS = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_DEPENDS) $(DOCKER_TEAMD)_DBG_DEPENDS += $(SWSS_DBG) $(LIBSWSSCOMMON_DBG) $(DOCKER_TEAMD)_DBG_DEPENDS += $(LIBTEAMDCTL_DBG) $(LIBTEAM_UTILS_DBG) -$(DOCKER_TEAMD)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES) +$(DOCKER_TEAMD)_DBG_IMAGE_PACKAGES = $($(DOCKER_SWSS_LAYER_BUSTER)_DBG_IMAGE_PACKAGES) -$(DOCKER_TEAMD)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER) +$(DOCKER_TEAMD)_LOAD_DOCKERS += $(DOCKER_SWSS_LAYER_BUSTER) $(DOCKER_TEAMD)_VERSION = 1.0.0 $(DOCKER_TEAMD)_PACKAGE_NAME = teamd diff --git a/rules/docker-telemetry.mk b/rules/docker-telemetry.mk index 6922856f82a0..4a2d3fd64e28 100644 --- a/rules/docker-telemetry.mk +++ b/rules/docker-telemetry.mk @@ -8,14 +8,14 @@ $(DOCKER_TELEMETRY)_PATH = $(DOCKERS_PATH)/$(DOCKER_TELEMETRY_STEM) $(DOCKER_TELEMETRY)_DEPENDS += $(SONIC_MGMT_COMMON) $(DOCKER_TELEMETRY)_DEPENDS += $(SONIC_TELEMETRY) -$(DOCKER_TELEMETRY)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS) +$(DOCKER_TELEMETRY)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_DEPENDS) -$(DOCKER_TELEMETRY)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER) +$(DOCKER_TELEMETRY)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BULLSEYE) $(DOCKER_TELEMETRY)_VERSION = 1.0.0 $(DOCKER_TELEMETRY)_PACKAGE_NAME = telemetry -$(DOCKER_TELEMETRY)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES) +$(DOCKER_TELEMETRY)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DBG_IMAGE_PACKAGES) SONIC_DOCKER_IMAGES += $(DOCKER_TELEMETRY) ifeq ($(INCLUDE_SYSTEM_TELEMETRY), y) @@ -35,6 +35,3 @@ $(DOCKER_TELEMETRY)_RUN_OPT += -v /var/run/dbus:/var/run/dbus:rw $(DOCKER_TELEMETRY)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) $(DOCKER_TELEMETRY)_BASE_IMAGE_FILES += monit_telemetry:/etc/monit/conf.d - -SONIC_BUSTER_DOCKERS += $(DOCKER_TELEMETRY) -SONIC_BUSTER_DBG_DOCKERS += $(DOCKER_TELEMETRY_DBG) diff --git a/rules/isc-dhcp.mk b/rules/isc-dhcp.mk index 3edebfd0dde0..1a1ad54678b8 100644 --- a/rules/isc-dhcp.mk +++ b/rules/isc-dhcp.mk @@ -1,7 +1,7 @@ # isc-dhcp packages ISC_DHCP_VERSION = 4.4.1 -ISC_DHCP_VERSION_FULL = ${ISC_DHCP_VERSION}-2 +ISC_DHCP_VERSION_FULL = ${ISC_DHCP_VERSION}-2.3 export ISC_DHCP_VERSION ISC_DHCP_VERSION_FULL diff --git a/rules/linux-kernel.dep b/rules/linux-kernel.dep index 6063ddded9d0..4706f56afbaf 100644 --- a/rules/linux-kernel.dep +++ b/rules/linux-kernel.dep @@ -1,7 +1,6 @@ SPATH := $($(LINUX_HEADERS_COMMON)_SRC_PATH) -DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/linux-kernel.mk rules/linux-kernel.dep -DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES := rules/linux-kernel.mk rules/linux-kernel.dep SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files)) DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) \ diff --git a/rules/phy-credo.mk b/rules/phy-credo.mk index 7e9441619139..0218fdf6f691 100644 --- a/rules/phy-credo.mk +++ b/rules/phy-credo.mk @@ -1,3 +1,3 @@ PHY_CREDO = phy-credo_1.0_amd64.deb -$(PHY_CREDO)_URL = "https://github.com/aristanetworks/sonic-firmware/raw/0468f6c23a7219dfee6dd2819013e9f1e940c95d/phy/phy-credo_1.0_amd64.deb" +$(PHY_CREDO)_URL = "https://github.com/aristanetworks/sonic-firmware/raw/d227160f981f27df020ab50b9e0f16b1bd9166ea/phy/phy-credo_1.0_amd64.deb" SONIC_ONLINE_DEBS += $(PHY_CREDO) diff --git a/rules/socat.mk b/rules/socat.mk index 3ee5d5d1c314..439e39af9426 100644 --- a/rules/socat.mk +++ b/rules/socat.mk @@ -1,6 +1,6 @@ # socat packages -SOCAT_VERSION = 1.7.3.1-2+deb9u1 +SOCAT_VERSION = 1.7.4.1-3 export SOCAT_VERSION diff --git a/rules/thrift_0_13_0.mk b/rules/thrift_0_13_0.mk index 9da97849809f..18d333910904 100644 --- a/rules/thrift_0_13_0.mk +++ b/rules/thrift_0_13_0.mk @@ -11,7 +11,7 @@ LIBTHRIFT_DEV_0_13_0 = libthrift-dev_$(THRIFT_VERSION_0_13_0_FULL)_$(CONFIGURED_ $(eval $(call add_derived_package,$(LIBTHRIFT_0_13_0),$(LIBTHRIFT_DEV_0_13_0))) PYTHON3_THRIFT_0_13_0 = python3-thrift_$(THRIFT_VERSION_0_13_0_FULL)_$(CONFIGURED_ARCH).deb -$(eval $(call add_derived_package,$(LIBTHRIFT_0_13_0),$(PYTHON_THRIFT_0_13_0))) +$(eval $(call add_derived_package,$(LIBTHRIFT_0_13_0),$(PYTHON3_THRIFT_0_13_0))) THRIFT_COMPILER_0_13_0 = thrift-compiler_$(THRIFT_VERSION_0_13_0_FULL)_$(CONFIGURED_ARCH).deb $(eval $(call add_derived_package,$(LIBTHRIFT_0_13_0),$(THRIFT_COMPILER_0_13_0))) diff --git a/scripts/build_debian_base_system.sh b/scripts/build_debian_base_system.sh index fc3e71290f02..72e3779ff3e2 100755 --- a/scripts/build_debian_base_system.sh +++ b/scripts/build_debian_base_system.sh @@ -13,6 +13,9 @@ TARGET=$TARGET_PATH TARGET_BASEIMAGE_PATH=$TARGET/versions/host-base-image mkdir -p $TARGET_BASEIMAGE_PATH +alias urlencode='python3 -c "import sys, urllib.parse as ul; print (ul.quote_plus(sys.argv[1]))"' +shopt -s expand_aliases + generate_version_file() { sudo LANG=C chroot $FILESYSTEM_ROOT /bin/bash -c "dpkg-query -W -f '\${Package}==\${Version}\n'" > $TARGET_BASEIMAGE_PATH/versions-deb-${IMAGE_DISTRO}-${CONFIGURED_ARCH} @@ -58,7 +61,7 @@ rm -rf $BASEIMAGE_TARBALLPATH $BASEIMAGE_TARBALL ARCHIEVES=$BASEIMAGE_TARBALLPATH/var/cache/apt/archives APTLIST=$BASEIMAGE_TARBALLPATH/var/lib/apt/lists TARGET_DEBOOTSTRAP=$BASEIMAGE_TARBALLPATH/debootstrap -APTDEBIAN="$APTLIST/deb.debian.org_debian_dists_buster_main_binary-${CONFIGURED_ARCH}_Packages" +APTDEBIAN="$APTLIST/deb.debian.org_debian_dists_${DISTRO}_main_binary-${CONFIGURED_ARCH}_Packages" DEBPATHS=$TARGET_DEBOOTSTRAP/debpaths DEBOOTSTRAP_BASE=$TARGET_DEBOOTSTRAP/base DEBOOTSTRAP_REQUIRED=$TARGET_DEBOOTSTRAP/required @@ -74,13 +77,14 @@ for ((i=0;i&1 exit 1 fi filename=$(basename "$url") - SKIP_BUILD_HOOK=y wget $url -P $ARCHIEVES + SKIP_BUILD_HOOK=y wget $url -O $ARCHIEVES/$filename echo $packagename >> $DEBOOTSTRAP_REQUIRED echo "$packagename /var/cache/apt/archives/$filename" >> $DEBPATHS done diff --git a/slave.mk b/slave.mk index 9926959e29b1..7fe8c9db0f41 100644 --- a/slave.mk +++ b/slave.mk @@ -27,12 +27,12 @@ SRC_PATH = src RULES_PATH = rules TARGET_PATH = target DOCKERS_PATH = dockers -BLDENV = $(shell lsb_release -cs) +BLDENV := $(shell lsb_release -cs) DEBS_PATH = $(TARGET_PATH)/debs/$(BLDENV) FILES_PATH = $(TARGET_PATH)/files/$(BLDENV) PYTHON_DEBS_PATH = $(TARGET_PATH)/python-debs/$(BLDENV) PYTHON_WHEELS_PATH = $(TARGET_PATH)/python-wheels/$(BLDENV) -PROJECT_ROOT = $(shell pwd) +PROJECT_ROOT := $(shell pwd) JESSIE_DEBS_PATH = $(TARGET_PATH)/debs/jessie JESSIE_FILES_PATH = $(TARGET_PATH)/files/jessie STRETCH_DEBS_PATH = $(TARGET_PATH)/debs/stretch @@ -958,6 +958,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ $(LIBNSS_TACPLUS) \ $(MONIT) \ $(OPENSSH_SERVER) \ + $(SMARTMONTOOLS) \ $(PYTHON_SWSSCOMMON) \ $(PYTHON3_SWSSCOMMON) \ $(SONIC_UTILITIES_DATA) \ diff --git a/sonic-slave-bullseye/Dockerfile.j2 b/sonic-slave-bullseye/Dockerfile.j2 index c13837fd3e48..c0a23c59624b 100644 --- a/sonic-slave-bullseye/Dockerfile.j2 +++ b/sonic-slave-bullseye/Dockerfile.j2 @@ -1,5 +1,5 @@ {%- if CONFIGURED_ARCH == "armhf" and MULTIARCH_QEMU_ENVIRON == "y" %} -FROM multiarch/qemu-user-static:x86_64-arm-5.2.0-2 as qemu +FROM multiarch/qemu-user-static:x86_64-arm-6.1.0-8 as qemu FROM multiarch/debian-debootstrap:armhf-bullseye COPY --from=qemu /usr/bin/qemu-arm-static /usr/bin {%- elif CONFIGURED_ARCH == "arm64" and MULTIARCH_QEMU_ENVIRON == "y" %} @@ -62,7 +62,6 @@ RUN apt-get update && apt-get install -y \ dh-exec \ kmod \ libtinyxml2-dev \ - python \ python3 \ python3-pip \ libncurses5-dev \ @@ -311,7 +310,6 @@ RUN apt-get update && apt-get install -y \ # For WPA supplication qtbase5-dev \ aspell-en \ - libpython2.7-dev \ libssl-dev \ dbus \ libdbus-1-dev \ @@ -325,22 +323,22 @@ RUN apt-get update && apt-get install -y \ # For kdump-tools libbz2-dev \ # For linkmgrd - libboost1.74-dev \ - libboost-program-options1.74-dev \ - libboost-system1.74-dev \ - libboost-thread1.74-dev \ - libboost-atomic1.74-dev \ - libboost-chrono1.74-dev \ - libboost-container1.74-dev \ - libboost-context1.74-dev \ - libboost-contract1.74-dev \ - libboost-coroutine1.74-dev \ - libboost-date-time1.74-dev \ - libboost-fiber1.74-dev \ - libboost-filesystem1.74-dev \ - libboost-graph-parallel1.74-dev \ - libboost-log1.74-dev \ - libboost-regex1.74-dev \ + libboost-dev \ + libboost-program-options-dev \ + libboost-system-dev \ + libboost-thread-dev \ + libboost-atomic-dev \ + libboost-chrono-dev \ + libboost-container-dev \ + libboost-context-dev \ + libboost-contract-dev \ + libboost-coroutine-dev \ + libboost-date-time-dev \ + libboost-fiber-dev \ + libboost-filesystem-dev \ + libboost-graph-parallel-dev \ + libboost-log-dev \ + libboost-regex-dev \ googletest \ libgtest-dev \ libgcc-10-dev \ @@ -447,7 +445,7 @@ RUN pip3 install "PyYAML==5.4.1" RUN pip3 install "lxml==4.6.2" # For sonic-platform-common testing -RUN pip3 install redis==3.5.3 +RUN pip3 install redis # For vs image build RUN pip3 install pexpect==4.8.0 @@ -483,6 +481,10 @@ EXPOSE 22 RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git /usr/share/depot_tools ENV PATH /usr/share/depot_tools:$PATH +# Install dependencies for dhcp relay test +RUN pip3 install parameterized==0.8.1 +RUN pip3 install pyfakefs + # Install docker engine 20.10 inside docker and enable experimental feature RUN apt-get update RUN apt-get install -y \ diff --git a/sonic-slave-buster/Dockerfile.j2 b/sonic-slave-buster/Dockerfile.j2 index a71e7c808ccf..44f7410df460 100644 --- a/sonic-slave-buster/Dockerfile.j2 +++ b/sonic-slave-buster/Dockerfile.j2 @@ -462,11 +462,11 @@ RUN pip2 install j2cli==0.3.10 # For sonic-mgmt-framework RUN pip2 install "PyYAML==5.4.1" RUN pip3 install "PyYAML==5.4.1" -RUN pip2 install "lxml==4.6.2" -RUN pip3 install "lxml==4.6.2" +RUN pip2 install "lxml==4.6.5" +RUN pip3 install "lxml==4.6.5" # For sonic-platform-common testing -RUN pip3 install redis==3.5.3 +RUN pip3 install redis # For vs image build RUN pip2 install pexpect==4.6.0 diff --git a/sonic-slave-stretch/Dockerfile.j2 b/sonic-slave-stretch/Dockerfile.j2 index a4cb4b57b14d..93c6d21d41e4 100644 --- a/sonic-slave-stretch/Dockerfile.j2 +++ b/sonic-slave-stretch/Dockerfile.j2 @@ -300,6 +300,9 @@ RUN apt-get update && apt-get install -y \ libauparse-dev \ auditd +# For gmock +RUN apt-get install -y libgmock-dev -t stretch-backports + # Install dependencies for dhcp relay test RUN pip3 install parameterized==0.8.1 RUN pip3 install pyfakefs @@ -363,12 +366,12 @@ RUN pip3 install mockredispy==2.9.3 # For sonic-mgmt-framework RUN pip2 install "PyYAML==5.3.1" RUN pip3 install "PyYAML==5.3.1" -RUN pip2 install "lxml==4.6.2" -RUN pip3 install "lxml==4.6.2" +RUN pip2 install "lxml==4.6.5" +RUN pip3 install "lxml==4.6.5" # For sonic-platform-common testing -RUN pip3 install redis==3.5.3 +RUN pip3 install redis # For vs image build RUN pip2 install pexpect==4.6.0 diff --git a/src/dhcp6relay/debian/compat b/src/dhcp6relay/debian/compat index ec635144f600..48082f72f087 100644 --- a/src/dhcp6relay/debian/compat +++ b/src/dhcp6relay/debian/compat @@ -1 +1 @@ -9 +12 diff --git a/src/dhcp6relay/debian/control b/src/dhcp6relay/debian/control index 31fdb6f41f3b..af7877fef9a8 100644 --- a/src/dhcp6relay/debian/control +++ b/src/dhcp6relay/debian/control @@ -2,8 +2,7 @@ Source: sonic-dhcp6relay Section: devel Priority: optional Maintainer: Kelly Yeh -Build-Depends: debhelper (>= 8.0.0), - dh-systemd +Build-Depends: debhelper (>= 12.0.0), libevent-dev, libboost-thread-dev, libboost-system-dev, libswsscommon-dev Standards-Version: 3.9.3 Homepage: https://github.com/Azure/sonic-buildimage XS-Go-Import-Path: github.com/Azure/sonic-buildimage @@ -11,7 +10,5 @@ XS-Go-Import-Path: github.com/Azure/sonic-buildimage Package: sonic-dhcp6relay Architecture: any Built-Using: ${misc:Built-Using} -Depends: libevent-2.1-6, - libboost-thread1.71.0, - libboost-system1.71.0 +Depends: ${shlibs:Depends} Description: SONiC DHCPv6 Relay diff --git a/src/dhcpmon/debian/compat b/src/dhcpmon/debian/compat index ec635144f600..48082f72f087 100644 --- a/src/dhcpmon/debian/compat +++ b/src/dhcpmon/debian/compat @@ -1 +1 @@ -9 +12 diff --git a/src/dhcpmon/debian/control b/src/dhcpmon/debian/control index 8623428462e3..c70c274f19fd 100644 --- a/src/dhcpmon/debian/control +++ b/src/dhcpmon/debian/control @@ -2,8 +2,7 @@ Source: sonic-dhcpmon Section: devel Priority: optional Maintainer: Tamer Ahmed -Build-Depends: debhelper (>= 8.0.0), - dh-systemd +Build-Depends: debhelper (>= 12.0.0), libevent-dev, libexplain-dev Standards-Version: 3.9.3 Homepage: https://github.com/Azure/sonic-buildimage XS-Go-Import-Path: github.com/Azure/sonic-buildimage @@ -11,6 +10,5 @@ XS-Go-Import-Path: github.com/Azure/sonic-buildimage Package: sonic-dhcpmon Architecture: any Built-Using: ${misc:Built-Using} -Depends: libexplain51, - libevent-2.1-6 +Depends: ${shlibs:Depends} Description: SONiC DHCP Monitor diff --git a/src/isc-dhcp/Makefile b/src/isc-dhcp/Makefile index 2adf6bba2aa3..63e82e5c49aa 100644 --- a/src/isc-dhcp/Makefile +++ b/src/isc-dhcp/Makefile @@ -7,16 +7,16 @@ DERIVED_TARGETS = $(ISC_DHCP_RELAY_DBG) $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Remove any stale files - rm -rf ./isc-dhcp + rm -rf ./isc-dhcp-$(ISC_DHCP_VERSION) - # Clone isc-dhcp repo - git clone https://salsa.debian.org/dhcp-team/isc-dhcp.git - pushd ./isc-dhcp + # Get isc-dhcp release, debian files + dget http://deb.debian.org/debian/pool/main/i/isc-dhcp/isc-dhcp_$(ISC_DHCP_VERSION_FULL).dsc + pushd ./isc-dhcp-$(ISC_DHCP_VERSION) - # Reset HEAD to the commit of the proper tag - # NOTE: Using "git checkout " here detaches our HEAD, - # which stg doesn't like, so we use this method instead - git reset --hard debian/$(ISC_DHCP_VERSION_FULL) + # Create a git repository here for stg to apply patches + git init + git add -f * + git commit -qm "initial commit" # Apply patches stg init diff --git a/src/isc-dhcp/patch/0012-add-option-si-to-support-using-src-intf-ip-in-relay.patch b/src/isc-dhcp/patch/0012-add-option-si-to-support-using-src-intf-ip-in-relay.patch index 7fd9fc313406..19a1192032db 100644 --- a/src/isc-dhcp/patch/0012-add-option-si-to-support-using-src-intf-ip-in-relay.patch +++ b/src/isc-dhcp/patch/0012-add-option-si-to-support-using-src-intf-ip-in-relay.patch @@ -165,20 +165,7 @@ diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c index 221106a..c44a79d 100644 --- a/relay/dhcrelay.c +++ b/relay/dhcrelay.c -@@ -97,6 +97,12 @@ struct downstream_intf_list { - isc_boolean_t use_if_id = ISC_FALSE; - #endif - -+/* -+ * If not set, kernel chooses what the src ip is. -+ * If set, uses "from" interface IP for packet Tx. -+ */ -+extern int use_src_intf_ip_for_tx = 0; -+ - /* Maximum size of a packet with agent options added. */ - int dhcp_max_agent_option_packet_length = DHCP_MTU_MIN; - -@@ -431,6 +437,8 @@ main(int argc, char **argv) { +@@ -431,6 +431,8 @@ main(int argc, char **argv) { #endif } else if (!strcmp(argv[i], "-d")) { /* no_daemon = 1; */ diff --git a/src/linkmgrd b/src/linkmgrd index 6c6151ba9512..0c23756cd618 160000 --- a/src/linkmgrd +++ b/src/linkmgrd @@ -1 +1 @@ -Subproject commit 6c6151ba9512166de0430e8e95076809dd706496 +Subproject commit 0c23756cd618473064381618ef82687f98b7e31f diff --git a/src/lldpd/patch/0012-fix-recreate-socket-on-ifindex-change.patch b/src/lldpd/patch/0012-fix-recreate-socket-on-ifindex-change.patch new file mode 100644 index 000000000000..685142dff904 --- /dev/null +++ b/src/lldpd/patch/0012-fix-recreate-socket-on-ifindex-change.patch @@ -0,0 +1,82 @@ +diff --git a/src/daemon/interfaces-linux.c b/src/daemon/interfaces-linux.c +index a8280c8..a51440a 100644 +--- a/src/daemon/interfaces-linux.c ++++ b/src/daemon/interfaces-linux.c +@@ -775,7 +775,7 @@ iflinux_handle_bond(struct lldpd *cfg, struct interfaces_device_list *interfaces + created = 1; + } + if (hardware->h_flags) continue; +- if (hardware->h_ops != &bond_ops) { ++ if (hardware->h_ops != &bond_ops || hardware->h_ifindex_changed) { + if (!created) { + log_debug("interfaces", + "bond %s is converted from another type of interface", +@@ -794,7 +794,7 @@ iflinux_handle_bond(struct lldpd *cfg, struct interfaces_device_list *interfaces + } else bmaster = hardware->h_data; + bmaster->index = master->index; + strlcpy(bmaster->name, master->name, IFNAMSIZ); +- if (hardware->h_ops != &bond_ops) { ++ if (hardware->h_ops != &bond_ops || hardware->h_ifindex_changed) { + if (iface_bond_init(cfg, hardware) != 0) { + log_warn("interfaces", "unable to initialize %s", + hardware->h_ifname); +diff --git a/src/daemon/interfaces.c b/src/daemon/interfaces.c +index 3c6c255..58db018 100644 +--- a/src/daemon/interfaces.c ++++ b/src/daemon/interfaces.c +@@ -623,7 +623,7 @@ interfaces_helper_physical(struct lldpd *cfg, + } + if (hardware->h_flags) + continue; +- if (hardware->h_ops != ops) { ++ if (hardware->h_ops != ops || hardware->h_ifindex_changed) { + if (!created) { + log_debug("interfaces", + "interface %s is converted from another type of interface", +diff --git a/src/daemon/lldpd.c b/src/daemon/lldpd.c +index 1d92dd3..f3e82e5 100644 +--- a/src/daemon/lldpd.c ++++ b/src/daemon/lldpd.c +@@ -147,6 +147,12 @@ lldpd_get_hardware(struct lldpd *cfg, char *name, int index) + TAILQ_FOREACH(hardware, &cfg->g_hardware, h_entries) { + if (strcmp(hardware->h_ifname, name) == 0) { + if (hardware->h_flags == 0) { ++ if (hardware->h_ifindex != 0 && ++ hardware->h_ifindex != index) { ++ log_debug("interfaces", "%s changed index: from %d to %d", ++ hardware->h_ifname, hardware->h_ifindex, index); ++ hardware->h_ifindex_changed = 1; ++ } + hardware->h_ifindex = index; + break; + } +@@ -392,7 +398,8 @@ lldpd_reset_timer(struct lldpd *cfg) + } + + /* Compare with the previous value */ +- if (hardware->h_lport_previous && ++ if (!hardware->h_ifindex_changed && ++ hardware->h_lport_previous && + output_len == hardware->h_lport_previous_len && + !memcmp(output, hardware->h_lport_previous, output_len)) { + log_debug("localchassis", +@@ -402,6 +409,7 @@ lldpd_reset_timer(struct lldpd *cfg) + log_debug("localchassis", + "change detected for port %s, resetting its timer", + hardware->h_ifname); ++ hardware->h_ifindex_changed = 0; + levent_schedule_pdu(hardware); + } + +diff --git a/src/lldpd-structs.h b/src/lldpd-structs.h +index f6b03d7..213f306 100644 +--- a/src/lldpd-structs.h ++++ b/src/lldpd-structs.h +@@ -454,6 +454,7 @@ struct lldpd_hardware { + removed if this is left + to 0. */ + int h_ifindex; /* Interface index, used by SNMP */ ++ int h_ifindex_changed; /* Interface index has changed */ + char h_ifname[IFNAMSIZ]; /* Should be unique */ + u_int8_t h_lladdr[ETHER_ADDR_LEN]; + diff --git a/src/lldpd/patch/series b/src/lldpd/patch/series index 32fd4c0ca9a7..d0b9904751cc 100644 --- a/src/lldpd/patch/series +++ b/src/lldpd/patch/series @@ -5,3 +5,4 @@ 0007-lib-fix-memory-leak-when-handling-I-O.patch 0010-Ported-fix-for-length-exceeded-from-lldp-community.patch 0011-fix-med-location-len.patch +0012-fix-recreate-socket-on-ifindex-change.patch diff --git a/src/socat/Makefile b/src/socat/Makefile index cc2cd7238684..1d1a0b36695c 100644 --- a/src/socat/Makefile +++ b/src/socat/Makefile @@ -6,19 +6,19 @@ MAIN_TARGET = socat_$(SOCAT_VERSION)_$(CONFIGURED_ARCH).deb $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Remove any stale files - rm -rf ./socat-1.7.3.1 + rm -rf ./socat-1.7.4.1 # Get source package - wget -NO socat_$(SOCAT_VERSION).dsc "https://sonicstorage.blob.core.windows.net/packages/debian/socat_1.7.3.1-2+deb9u1.dsc?sv=2015-04-05&sr=b&sig=Ph7aMqb%2F%2FE%2F8qwxMXoXb5oK1YPkfVt6PV8mBBv5Wi%2F4%3D&se=2155-07-05T11%3A42%3A29Z&sp=r" - wget -NO socat_$(SOCAT_VERSION).debian.tar.xz "https://sonicstorage.blob.core.windows.net/packages/debian/socat_1.7.3.1-2+deb9u1.debian.tar.xz?sv=2015-04-05&sr=b&sig=yv77Fr5RtZgRTPmJK3j0lZ0BzsCiGaSs2i7NqQKEy2Y%3D&se=2155-07-05T11%3A39%3A59Z&sp=r" - wget -NO socat_1.7.3.1.orig.tar.gz "https://sonicstorage.blob.core.windows.net/packages/debian/socat_1.7.3.1.orig.tar.gz?sv=2015-04-05&sr=b&sig=0Ai1FM604aGsF5uBu2yN8w9O1a6zNjIDCdaiTo24DyQ%3D&se=2155-07-05T11%3A40%3A14Z&sp=r" + wget -NO socat_$(SOCAT_VERSION).dsc "https://sonicstorage.blob.core.windows.net/packages/debian/socat_1.7.4.1-3.dsc?sv=2020-04-08&st=2021-12-14T00%3A00%3A00Z&se=2050-12-15T00%3A00%3A00Z&sr=b&sp=r&sig=fIy6dVz3s59K0TiMkTlwSWN8lCzRl3i76ruAtROhfWA%3D" + wget -NO socat_$(SOCAT_VERSION).debian.tar.xz "https://sonicstorage.blob.core.windows.net/packages/debian/socat_1.7.4.1-3.debian.tar.xz?sv=2020-04-08&st=2021-12-14T08%3A00%3A00Z&se=2030-12-14T18%3A18%3A00Z&sr=b&sp=r&sig=C8aYSvaQgMJ58Z13kFY0Wr0J0QF6i7WCeET9%2BpF%2BAxc%3D" + wget -NO socat_1.7.4.1.orig.tar.gz "https://sonicstorage.blob.core.windows.net/packages/debian/socat_1.7.4.1.orig.tar.gz?sv=2020-04-08&st=2021-12-14T00%3A00%3A00Z&se=2050-12-15T00%3A00%3A00Z&sr=b&sp=r&sig=gpihyZv%2Fr0bVrCUKCKwpS4bIoqiPpdd%2BgCfuUGNHOUc%3D" dpkg-source -x socat_$(SOCAT_VERSION).dsc # Build source and Debian packages - pushd socat-1.7.3.1 + pushd socat-1.7.4.1 patch -p0 < ../enable_readline.patch - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) + DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -rfakeroot -Pnocheck -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd # Move the newly-built .deb packages to the destination directory diff --git a/src/socat/enable_readline.patch b/src/socat/enable_readline.patch index f1914d3cb494..0bd34bf377f4 100644 --- a/src/socat/enable_readline.patch +++ b/src/socat/enable_readline.patch @@ -1,13 +1,29 @@ ---- debian/rules.old 2018-08-12 11:48:42.220230100 +0000 -+++ debian/rules 2018-08-12 11:48:52.072230100 +0000 -@@ -12,9 +12,6 @@ - %: - dh $@ --with=autoreconf +--- debian/rules.old 2021-12-14 10:51:09.641165521 -0800 ++++ debian/rules 2021-12-14 10:52:36.494048522 -0800 +@@ -11,9 +11,6 @@ + # upsteram maintains config.h.in manually + export AUTOHEADER = true -override_dh_auto_configure: - dh_auto_configure -- --disable-readline - override_dh_auto_test: + ifneq (, filter $(DEB_BUILD_ARCH_OS), kfreebsd hurd) + dh_auto_test +@@ -24,4 +21,4 @@ + %: + dh $@ --with=autoreconf -.PHONY: override_dh_auto_configure override_dh_auto_test +.PHONY: override_dh_auto_test +--- debian/control.old 2021-12-14 11:30:49.166051931 -0800 ++++ debian/control 2021-12-14 11:30:57.590153464 -0800 +@@ -3,7 +3,7 @@ + Priority: optional + Maintainer: Laszlo Boszormenyi (GCS) + Homepage: http://www.dest-unreach.org/socat/ +-Build-Depends: debhelper-compat (= 12), libssl-dev, libwrap0-dev, openssl , net-tools , iproute2 [linux-any] , netbase ++Build-Depends: debhelper-compat (= 12), libssl-dev, libwrap0-dev, libreadline-dev, openssl , net-tools , iproute2 [linux-any] , netbase + Standards-Version: 4.5.1 + Rules-Requires-Root: no + diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.conf.j2/all.json b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.conf.j2/all.json index 34fdbe72448b..fc5016d8536e 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.conf.j2/all.json +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.conf.j2/all.json @@ -3,7 +3,8 @@ "localhost": { "hostname": "new_hostname", "bgp_asn": "55555", - "sub_role": "FrontEnd" + "sub_role": "FrontEnd", + "type": "ToRRouter" } }, "LOOPBACK_INTERFACE": { diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/all.json b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/all.json index c8f0141ec4f5..47508bb3c001 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/all.json +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/all.json @@ -2,7 +2,8 @@ "DEVICE_METADATA": { "localhost": { "bgp_asn": "55555", - "sub_role": "FrontEnd" + "sub_role": "FrontEnd", + "type": "ToRRouter" } }, "LOOPBACK_INTERFACE": { diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/defaults.json b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/defaults.json index 5b30406668ab..c1b5ae8dc449 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/defaults.json +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/defaults.json @@ -2,7 +2,8 @@ "DEVICE_METADATA": { "localhost": { "bgp_asn": "55555", - "sub_role": "FrontEnd" + "sub_role": "FrontEnd", + "type": "ToRRouter" } }, "LOOPBACK_INTERFACE": { diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.conf b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.conf index 2852ce15023a..37ac8827dc46 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.conf +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.conf @@ -39,10 +39,6 @@ router bgp 55555 ! bgp bestpath as-path multipath-relax ! - bgp graceful-restart restart-time 240 - bgp graceful-restart - bgp graceful-restart preserve-fw-state - bgp graceful-restart select-defer-time 45 ! bgp router-id 55.55.55.56 ! diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.json b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.json index 418a62266d8d..41fc9351bebb 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.json +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.json @@ -3,7 +3,8 @@ "localhost": { "bgp_asn": "55555", "sub_role": "FrontEnd", - "switch_type": "chassis-packet" + "switch_type": "chassis-packet", + "type": "SpineRouter" } }, "LOOPBACK_INTERFACE": { diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.conf b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.conf index 26f06d843a7f..d8ee10ada1e0 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.conf +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.conf @@ -39,10 +39,6 @@ router bgp 55555 ! bgp bestpath as-path multipath-relax ! - bgp graceful-restart restart-time 240 - bgp graceful-restart - bgp graceful-restart preserve-fw-state - bgp graceful-restart select-defer-time 45 ! bgp router-id 55.55.55.56 ! diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.json b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.json index 4cbb4c0048c3..00c913981a1e 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.json +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/voq_chassis.json @@ -3,7 +3,8 @@ "localhost": { "bgp_asn": "55555", "sub_role": "", - "switch_type": "voq" + "switch_type": "voq", + "type": "SpineRouter" } }, "LOOPBACK_INTERFACE": { diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/frr.conf.j2/all.json b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/frr.conf.j2/all.json index 92143a2a9deb..9c8a34fb4120 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/frr.conf.j2/all.json +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/frr.conf.j2/all.json @@ -3,7 +3,8 @@ "localhost": { "bgp_asn": "55555", "hostname": "test_hostname", - "sub_role": "FrontEnd" + "sub_role": "FrontEnd", + "type": "ToRRouter" } }, "INTERFACE": { diff --git a/src/sonic-build-hooks/scripts/buildinfo_base.sh b/src/sonic-build-hooks/scripts/buildinfo_base.sh index f156930bf06d..d46ffec18330 100755 --- a/src/sonic-build-hooks/scripts/buildinfo_base.sh +++ b/src/sonic-build-hooks/scripts/buildinfo_base.sh @@ -17,6 +17,12 @@ REPR_MIRROR_URL_PATTERN='http:\/\/packages.trafficmanager.net\/debian' URL_PREFIX=$(echo "${PACKAGE_URL_PREFIX}" | sed -E "s#(//[^/]*/).*#\1#") +if [ "$(whoami)" != "root" ] && [ -n "$(which sudo)" ];then + SUDO=sudo +else + SUDO='' +fi + log_err() { echo "$1" >> $LOG_PATH/error.log @@ -72,7 +78,7 @@ set_reproducible_mirrors() local mirrors="/etc/apt/sources.list $(find /etc/apt/sources.list.d/ -type f)" for mirror in $mirrors; do - sed -i "$expression" "$mirror" + $SUDO sed -i "$expression" "$mirror" done } @@ -161,7 +167,7 @@ run_pip_command() install=y elif [[ "$para" == *.whl ]]; then package_name=$(echo $para | cut -d- -f1 | tr _ .) - sed "/^${package_name}==/d" -i $tmp_version_file + $SUDO sed "/^${package_name}==/d" -i $tmp_version_file fi done diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 8f8c90fab584..121e3ed9e55c 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -487,7 +487,7 @@ def parse_dpg(dpg, hname): for i, member in enumerate(pcmbr_list): pcmbr_list[i] = port_alias_map.get(member, member) intfs_inpc.append(pcmbr_list[i]) - pc_members[(pcintfname, pcmbr_list[i])] = {'NULL': 'NULL'} + pc_members[(pcintfname, pcmbr_list[i])] = {} if pcintf.find(str(QName(ns, "Fallback"))) != None: pcs[pcintfname] = {'members': pcmbr_list, 'fallback': pcintf.find(str(QName(ns, "Fallback"))).text, 'min_links': str(int(math.ceil(len() * 0.75)))} else: @@ -510,10 +510,11 @@ def parse_dpg(dpg, hname): elif ":" in ipnhaddr: port_nhipv6_map[ipnhfmbr] = ipnhaddr elif ipnh.find(str(QName(ns, "Type"))).text == 'StaticRoute': - prefix = ipnh.find(str(QName(ns, "AttachTo"))).text + prefix = ipnh.find(str(QName(ns, "AssociatedTo"))).text + ifname = ipnh.find(str(QName(ns, "AttachTo"))).text nexthop = ipnh.find(str(QName(ns, "Address"))).text advertise = ipnh.find(str(QName(ns, "Advertise"))).text - static_routes[prefix] = {'nexthop': nexthop, 'advertise': advertise} + static_routes[prefix] = {'nexthop': nexthop, 'ifname': ifname, 'advertise': advertise} if port_nhipv4_map and port_nhipv6_map: subnet_check_ip = list(port_nhipv4_map.values())[0] @@ -1623,7 +1624,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw results['ACL_TABLE'] = filter_acl_table_bindings(acls, neighbors, pcs, sub_role) results['FEATURE'] = { 'telemetry': { - 'status': 'enabled' + 'state': 'enabled' } } results['TELEMETRY'] = { diff --git a/src/sonic-config-engine/portconfig.py b/src/sonic-config-engine/portconfig.py index db486b1b7d8c..51a4c438faf2 100644 --- a/src/sonic-config-engine/portconfig.py +++ b/src/sonic-config-engine/portconfig.py @@ -39,7 +39,8 @@ INTF_KEY = "interfaces" OPTIONAL_HWSKU_ATTRIBUTES = ["fec", "autoneg"] -BRKOUT_PATTERN = r'(\d{1,3})x(\d{1,3}G)(\[(\d{1,3}G,?)*\])?(\((\d{1,3})\))?' +BRKOUT_PATTERN = r'(\d{1,6})x(\d{1,6}G?)(\[(\d{1,6}G?,?)*\])?(\((\d{1,6})\))?' +BRKOUT_PATTERN_GROUPS = 6 # # Helper Functions @@ -172,85 +173,156 @@ def parse_port_config_file(port_config_file): port_alias_asic_map[data['alias']] = data['asic_port_name'].strip() return (ports, port_alias_map, port_alias_asic_map) -# Generate configs (i.e. alias, lanes, speed, index) for port -def gen_port_config(ports, parent_intf_id, index, alias_list, lanes, k, offset): - if k is not None: - num_lane_used, speed, alt_speed, _, _ , assigned_lane = k[0], k[1], k[2], k[3], k[4], k[5] - - # In case of symmetric mode - if assigned_lane is None: - assigned_lane = len(lanes.split(",")) - - parent_intf_id = int(offset)+int(parent_intf_id) - alias_position = 0 + int(offset)//int(num_lane_used) - lanes_start = 0 + int(offset) - - step = int(assigned_lane)//int(num_lane_used) - for i in range(0,int(assigned_lane), step): - intf_name = PORT_STR + str(parent_intf_id) - ports[intf_name] = {} - ports[intf_name]['alias'] = alias_list[alias_position] - ports[intf_name]['lanes'] = ','.join(lanes.split(",")[lanes_start:lanes_start+step]) - if speed: - speed_pat = re.search("^((\d+)G|\d+)$", speed.upper()) - if speed_pat is None: - raise Exception('{} speed is not Supported...'.format(speed)) - speed_G, speed_orig = speed_pat.group(2), speed_pat.group(1) - if speed_G: - conv_speed = int(speed_G)*1000 - else: - conv_speed = int(speed_orig) - ports[intf_name]['speed'] = str(conv_speed) +class BreakoutCfg(object): + + class BreakoutModeEntry: + def __init__(self, num_ports, default_speed, supported_speed, num_assigned_lanes=None): + self.num_ports = int(num_ports) + self.default_speed = self._speed_to_int(default_speed) + self.supported_speed = set((self.default_speed, )) + self._parse_supported_speed(supported_speed) + self.num_assigned_lanes = self._parse_num_assigned_lanes(num_assigned_lanes) + + @classmethod + def _speed_to_int(cls, speed): + try: + if speed.endswith('G'): + return int(speed.replace('G', '')) * 1000 + + return int(speed) + except ValueError: + raise RuntimeError("Unsupported speed format '{}'".format(speed)) + + def _parse_supported_speed(self, speed): + if not speed: + return + + if not speed.startswith('[') and not speed.endswith(']'): + raise RuntimeError("Unsupported port breakout format!") + + for s in speed[1:-1].split(','): + self.supported_speed.add(self._speed_to_int(s.strip())) + + def _parse_num_assigned_lanes(self, num_assigned_lanes): + if not num_assigned_lanes: + return + + if isinstance(num_assigned_lanes, int): + return num_assigned_lanes + + if not num_assigned_lanes.startswith('(') and not num_assigned_lanes.endswith(')'): + raise RuntimeError("Unsupported port breakout format!") + + return int(num_assigned_lanes[1:-1]) + + def __eq__(self, other): + if isinstance(other, BreakoutCfg.BreakoutModeEntry): + if self.num_ports != other.num_ports: + return False + if self.supported_speed != other.supported_speed: + return False + if self.num_assigned_lanes != other.num_assigned_lanes: + return False + return True else: - raise Exception('Regex return for speed is None...') + return False - ports[intf_name]['index'] = index.split(",")[alias_position] + def __ne__(self, other): + return not self == other - parent_intf_id += step - alias_position += 1 - lanes_start += step + def __hash__(self): + return hash((self.num_ports, tuple(self.supported_speed), self.num_assigned_lanes)) + + def __init__(self, name, bmode, properties): + self._interface_base_id = int(name.replace(PORT_STR, '')) + self._properties = properties + self._lanes = properties ['lanes'].split(',') + self._indexes = properties ['index'].split(',') + self._breakout_mode_entry = self._str_to_entries(bmode) + self._breakout_capabilities = None + + # Find specified breakout mode in port breakout mode capabilities + for supported_mode in self._properties['breakout_modes']: + if self._breakout_mode_entry == self._str_to_entries(supported_mode): + self._breakout_capabilities = self._properties['breakout_modes'][supported_mode] + break + + if not self._breakout_capabilities: + raise RuntimeError("Unsupported breakout mode {}!".format(bmode)) + + def _re_group_to_entry(self, group): + if len(group) != BRKOUT_PATTERN_GROUPS: + raise RuntimeError("Unsupported breakout mode format!") + + num_ports, default_speed, supported_speed, _, num_assigned_lanes, _ = group + if not num_assigned_lanes: + num_assigned_lanes = len(self._lanes) + + return BreakoutCfg.BreakoutModeEntry(num_ports, default_speed, supported_speed, num_assigned_lanes) + + def _str_to_entries(self, bmode): + """ + Example of match_list for some breakout_mode using regex + Breakout Mode -------> Match_list + ----------------------------- + 2x25G(2)+1x50G(2) ---> [('2', '25G', None, '(2)', '2'), ('1', '50G', None, '(2)', '2')] + 1x50G(2)+2x25G(2) ---> [('1', '50G', None, '(2)', '2'), ('2', '25G', None, '(2)', '2')] + 1x100G[40G] ---------> [('1', '100G', '[40G]', None, None)] + 2x50G ---------------> [('2', '50G', None, None, None)] + """ + + try: + groups_list = [re.match(BRKOUT_PATTERN, i).groups() for i in bmode.split("+")] + except Exception: + raise RuntimeError('Breakout mode "{}" validation failed!'.format(bmode)) + + return [self._re_group_to_entry(group) for group in groups_list] + + def get_config(self): + # Ensure that we have corret number of configured lanes + lanes_used = 0 + for entry in self._breakout_mode_entry: + lanes_used += entry.num_assigned_lanes + + if lanes_used > len(self._lanes): + raise RuntimeError("Assigned lines count is more that available!") + + ports = {} + + lane_id = 0 + alias_id = 0 + + for entry in self._breakout_mode_entry: + lanes_per_port = entry.num_assigned_lanes // entry.num_ports + + for port in range(entry.num_ports): + interface_name = PORT_STR + str(self._interface_base_id + lane_id) + + lanes = self._lanes[lane_id:lane_id + lanes_per_port] + + ports[interface_name] = { + 'alias': self._breakout_capabilities[alias_id], + 'lanes': ','.join(lanes), + 'speed': str(entry.default_speed), + 'index': self._indexes[lane_id] + } + + lane_id += lanes_per_port + alias_id += 1 + + return ports - offset = int(assigned_lane) + int(offset) - return offset - else: - raise Exception('Regex return for k is None...') """ Given a port and breakout mode, this method returns the list of child ports using platform_json file """ def get_child_ports(interface, breakout_mode, platform_json_file): - child_ports = {} - port_dict = readJson(platform_json_file) - index = port_dict[INTF_KEY][interface]['index'] - alias_list = port_dict[INTF_KEY][interface]['breakout_modes'][breakout_mode] - lanes = port_dict[INTF_KEY][interface]['lanes'] - - """ - Example of match_list for some breakout_mode using regex - Breakout Mode -------> Match_list - ----------------------------- - 2x25G(2)+1x50G(2) ---> [('2', '25G', None, '(2)', '2'), ('1', '50G', None, '(2)', '2')] - 1x50G(2)+2x25G(2) ---> [('1', '50G', None, '(2)', '2'), ('2', '25G', None, '(2)', '2')] - 1x100G[40G] ---------> [('1', '100G', '[40G]', None, None)] - 2x50G ---------------> [('2', '50G', None, None, None)] - """ - # Asymmetric breakout mode - if re.search("\+",breakout_mode) is not None: - breakout_parts = breakout_mode.split("+") - match_list = [re.match(BRKOUT_PATTERN, i).groups() for i in breakout_parts] - - # Symmetric breakout mode - else: - match_list = [re.match(BRKOUT_PATTERN, breakout_mode).groups()] + mode_handler = BreakoutCfg(interface, breakout_mode, port_dict[INTF_KEY][interface]) - offset = 0 - parent_intf_id = int(re.search("Ethernet(\d+)", interface).group(1)) - for k in match_list: - offset = gen_port_config(child_ports, parent_intf_id, index, alias_list, lanes, k, offset) - return child_ports + return mode_handler.get_config() def parse_platform_json_file(hwsku_json_file, platform_json_file): ports = {} diff --git a/src/sonic-config-engine/setup.py b/src/sonic-config-engine/setup.py index d19fcb1e5b6f..50cd296dccd1 100644 --- a/src/sonic-config-engine/setup.py +++ b/src/sonic-config-engine/setup.py @@ -7,7 +7,7 @@ dependencies = [ 'bitarray==1.5.3', 'ipaddress==1.0.23', - 'lxml==4.6.3', + 'lxml==4.6.5', 'netaddr==0.8.0', 'pyyaml==5.4.1', 'sonic-py-common', diff --git a/src/sonic-config-engine/tests/fg-ecmp-sample-minigraph.xml b/src/sonic-config-engine/tests/fg-ecmp-sample-minigraph.xml index 9cca45e25241..236b63f77161 100644 --- a/src/sonic-config-engine/tests/fg-ecmp-sample-minigraph.xml +++ b/src/sonic-config-engine/tests/fg-ecmp-sample-minigraph.xml @@ -230,6 +230,17 @@ 1000 192.168.0.0/21 + + Vlan31 + etp26 + False + 0.0.0.0/0 + + 200.200.0.48 + 31 + 31 + 200.200.0.0/21 + diff --git a/src/sonic-config-engine/tests/pc-test-graph.xml b/src/sonic-config-engine/tests/pc-test-graph.xml index 6709d65c4969..814686d8ff06 100644 --- a/src/sonic-config-engine/tests/pc-test-graph.xml +++ b/src/sonic-config-engine/tests/pc-test-graph.xml @@ -202,6 +202,21 @@ + + + + switch-t0 + + + DeploymentId + + 1 + + + + + + switch-t0 Force10-S6000 diff --git a/src/sonic-config-engine/tests/sample-chassis-packet-lc-graph.xml b/src/sonic-config-engine/tests/sample-chassis-packet-lc-graph.xml index 65d435539d20..183c578385f0 100644 --- a/src/sonic-config-engine/tests/sample-chassis-packet-lc-graph.xml +++ b/src/sonic-config-engine/tests/sample-chassis-packet-lc-graph.xml @@ -121,8 +121,9 @@ IPNextHop - 8.0.0.1/32 + 8.0.0.1/32
192.168.1.2,192.168.2.2
+ PortChannel40,PortChannel50 StaticRoute false
@@ -212,8 +213,9 @@ IPNextHop - 8.0.0.1/32 -
192.168.1.2,192.168.2.2
+ 8.0.0.1/32 +
192.168.1.2,192.168.2.2
+ PortChannel40,PortChannel50 StaticRoute false
diff --git a/src/sonic-config-engine/tests/sample-graph-resource-type.xml b/src/sonic-config-engine/tests/sample-graph-resource-type.xml index ab486b51cb69..f09e4112d8ff 100644 --- a/src/sonic-config-engine/tests/sample-graph-resource-type.xml +++ b/src/sonic-config-engine/tests/sample-graph-resource-type.xml @@ -180,11 +180,6 @@ fortyGigE0/4 - - PortChannel1001 - fortyGigE0/1;fortyGigE0/2 - - @@ -287,26 +282,6 @@ fortyGigE0/8 true - - DeviceInterfaceLink - 10000 - switch-t0 - fortyGigE0/1 - true - ARISTA05T1 - Ethernet1/32 - true - - - DeviceInterfaceLink - 10000 - switch-t0 - fortyGigE0/2 - true - ARISTA06T1 - Ethernet1/33 - true - DeviceMgmtLink 1000 @@ -462,6 +437,11 @@ switch-t0 + + DeploymentId + + 1 + ResourceType diff --git a/src/sonic-config-engine/tests/sample-graph-subintf.xml b/src/sonic-config-engine/tests/sample-graph-subintf.xml index 06a6cf2fd665..29568be727a7 100644 --- a/src/sonic-config-engine/tests/sample-graph-subintf.xml +++ b/src/sonic-config-engine/tests/sample-graph-subintf.xml @@ -180,11 +180,6 @@ fortyGigE0/4 - - PortChannel1001 - fortyGigE0/1;fortyGigE0/2 - - @@ -295,26 +290,6 @@ fortyGigE0/8 true - - DeviceInterfaceLink - 10000 - switch-t0 - fortyGigE0/1 - true - ARISTA05T1 - Ethernet1/32 - true - - - DeviceInterfaceLink - 10000 - switch-t0 - fortyGigE0/2 - true - ARISTA06T1 - Ethernet1/33 - true - DeviceMgmtLink 1000 @@ -465,6 +440,21 @@ + + + + switch-t0 + + + DeploymentId + + 1 + + + + + + switch-t0 Force10-S6000 diff --git a/src/sonic-config-engine/tests/sample-voq-graph.xml b/src/sonic-config-engine/tests/sample-voq-graph.xml index c6fc1b2f5d17..5257efd4b0ae 100644 --- a/src/sonic-config-engine/tests/sample-voq-graph.xml +++ b/src/sonic-config-engine/tests/sample-voq-graph.xml @@ -1,7 +1,14 @@ - + + + 65100 + linecard-1 + + + + @@ -109,7 +116,7 @@ SyslogResources - 10.0.10.5;10.0.10.6; + 10.0.10.5;10.0.10.6 diff --git a/src/sonic-config-engine/tests/sample_graph.xml b/src/sonic-config-engine/tests/sample_graph.xml index 47efabf7d81c..7bd08ab8f7c8 100644 --- a/src/sonic-config-engine/tests/sample_graph.xml +++ b/src/sonic-config-engine/tests/sample_graph.xml @@ -111,7 +111,7 @@ 40000 DeviceInterfaceLink - OCPCH01040DDLF + OCPSCH01040DDLF Ethernet1 OCPSCH0104002MS Ethernet12 @@ -124,6 +124,21 @@ + + + + OCPSCH01040DDLF + + + DeploymentId + + 1 + + + + + + OCPSCH01040DDLF Force10-Z9100 diff --git a/src/sonic-config-engine/tests/sample_hwsku.json b/src/sonic-config-engine/tests/sample_hwsku.json index b4864d40eb11..697fb7b1ccb4 100644 --- a/src/sonic-config-engine/tests/sample_hwsku.json +++ b/src/sonic-config-engine/tests/sample_hwsku.json @@ -95,6 +95,21 @@ }, "Ethernet124": { "default_brkout_mode": "2x50G" + }, + "Ethernet128": { + "default_brkout_mode": "1x40G[100G]" + }, + "Ethernet132": { + "default_brkout_mode": "1x25G[100G,50G,40G,10G]" + }, + "Ethernet136": { + "default_brkout_mode": "4x10G[25G]" + }, + "Ethernet140": { + "default_brkout_mode": "2x25G(2)+1x50000(2)" + }, + "Ethernet144": { + "default_brkout_mode": "1x100000[50G,40000,25G,10000]" } } } diff --git a/src/sonic-config-engine/tests/sample_output/platform_output.json b/src/sonic-config-engine/tests/sample_output/platform_output.json index 8276b19e18a3..4c6cf197c389 100644 --- a/src/sonic-config-engine/tests/sample_output/platform_output.json +++ b/src/sonic-config-engine/tests/sample_output/platform_output.json @@ -819,5 +819,106 @@ "pfc_asym": "off", "speed": "50000", "tpid": "0x8100" + }, + "Ethernet128": { + "index": "33", + "lanes": "128,129,130,131", + "description": "Eth33", + "tpid": "0x8100", + "mtu": "9100", + "alias": "Eth33", + "pfc_asym": "off", + "speed": "40000" + }, + "Ethernet132": { + "index": "34", + "lanes": "132,133,134,135", + "description": "Eth34", + "tpid": "0x8100", + "mtu": "9100", + "alias": "Eth34", + "pfc_asym": "off", + "speed": "25000" + }, + "Ethernet136": { + "index": "35", + "lanes": "136", + "description": "Eth35/1", + "tpid": "0x8100", + "mtu": "9100", + "alias": "Eth35/1", + "pfc_asym": "off", + "speed": "10000" + }, + "Ethernet137": { + "index": "35", + "lanes": "137", + "description": "Eth35/2", + "tpid": "0x8100", + "mtu": "9100", + "alias": "Eth35/2", + "pfc_asym": "off", + "speed": "10000" + }, + "Ethernet138": { + "index": "35", + "lanes": "138", + "description": "Eth35/3", + "tpid": "0x8100", + "mtu": "9100", + "alias": "Eth35/3", + "pfc_asym": "off", + "speed": "10000" + }, + "Ethernet139": { + "index": "35", + "lanes": "139", + "description": "Eth35/4", + "tpid": "0x8100", + "mtu": "9100", + "alias": "Eth35/4", + "pfc_asym": "off", + "speed": "10000" + }, + "Ethernet140": { + "index": "36", + "lanes": "140", + "description": "Eth36/1", + "tpid": "0x8100", + "mtu": "9100", + "alias": "Eth36/1", + "pfc_asym": "off", + "speed": "25000" + }, + "Ethernet141": { + "index": "36", + "lanes": "141", + "description": "Eth36/2", + "tpid": "0x8100", + "mtu": "9100", + "alias": "Eth36/2", + "pfc_asym": "off", + "speed": "25000" + }, + "Ethernet142": { + "index": "36", + "lanes": "142,143", + "description": "Eth36/3", + "tpid": "0x8100", + "mtu": "9100", + "alias": "Eth36/3", + "pfc_asym": "off", + "speed": "50000" + }, + "Ethernet144": { + "index": "37", + "lanes": "144,145,146,147", + "description": "Eth37", + "tpid": "0x8100", + "mtu": "9100", + "alias": "Eth37", + "pfc_asym": "off", + "speed": "100000", + "fec": "rs" } } diff --git a/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_backend_asic.conf b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_backend_asic.conf index 0def8a6be321..d793dfa39a98 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_backend_asic.conf +++ b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_backend_asic.conf @@ -58,10 +58,6 @@ router bgp 65100 ! bgp bestpath as-path multipath-relax ! - bgp graceful-restart restart-time 240 - bgp graceful-restart - bgp graceful-restart preserve-fw-state - bgp graceful-restart select-defer-time 45 ! bgp router-id 8.0.0.5 ! diff --git a/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_frontend_asic.conf b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_frontend_asic.conf index ecdb3818ff62..94bd37e3b90f 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_frontend_asic.conf +++ b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr_frontend_asic.conf @@ -58,10 +58,6 @@ router bgp 65100 ! bgp bestpath as-path multipath-relax ! - bgp graceful-restart restart-time 240 - bgp graceful-restart - bgp graceful-restart preserve-fw-state - bgp graceful-restart select-defer-time 45 ! bgp router-id 10.1.0.32 ! diff --git a/src/sonic-config-engine/tests/sample_output/py2/t2-chassis-fe-bgpd.conf b/src/sonic-config-engine/tests/sample_output/py2/t2-chassis-fe-bgpd.conf index d3b9b472c5bd..20744efaa40f 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/t2-chassis-fe-bgpd.conf +++ b/src/sonic-config-engine/tests/sample_output/py2/t2-chassis-fe-bgpd.conf @@ -63,10 +63,6 @@ router bgp 4000 ! bgp bestpath as-path multipath-relax ! - bgp graceful-restart restart-time 240 - bgp graceful-restart - bgp graceful-restart preserve-fw-state - bgp graceful-restart select-defer-time 45 ! bgp router-id 4.0.0.0 ! diff --git a/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_backend_asic.conf b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_backend_asic.conf index 0def8a6be321..d793dfa39a98 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_backend_asic.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_backend_asic.conf @@ -58,10 +58,6 @@ router bgp 65100 ! bgp bestpath as-path multipath-relax ! - bgp graceful-restart restart-time 240 - bgp graceful-restart - bgp graceful-restart preserve-fw-state - bgp graceful-restart select-defer-time 45 ! bgp router-id 8.0.0.5 ! diff --git a/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_frontend_asic.conf b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_frontend_asic.conf index ecdb3818ff62..94bd37e3b90f 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_frontend_asic.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr_frontend_asic.conf @@ -58,10 +58,6 @@ router bgp 65100 ! bgp bestpath as-path multipath-relax ! - bgp graceful-restart restart-time 240 - bgp graceful-restart - bgp graceful-restart preserve-fw-state - bgp graceful-restart select-defer-time 45 ! bgp router-id 10.1.0.32 ! diff --git a/src/sonic-config-engine/tests/sample_output/py3/t2-chassis-fe-bgpd.conf b/src/sonic-config-engine/tests/sample_output/py3/t2-chassis-fe-bgpd.conf index d3b9b472c5bd..20744efaa40f 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/t2-chassis-fe-bgpd.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/t2-chassis-fe-bgpd.conf @@ -63,10 +63,6 @@ router bgp 4000 ! bgp bestpath as-path multipath-relax ! - bgp graceful-restart restart-time 240 - bgp graceful-restart - bgp graceful-restart preserve-fw-state - bgp graceful-restart select-defer-time 45 ! bgp router-id 4.0.0.0 ! diff --git a/src/sonic-config-engine/tests/sample_output/t0-switch-masic1.json b/src/sonic-config-engine/tests/sample_output/t0-switch-masic1.json index 34fd946da361..83ca9f50aed5 100644 --- a/src/sonic-config-engine/tests/sample_output/t0-switch-masic1.json +++ b/src/sonic-config-engine/tests/sample_output/t0-switch-masic1.json @@ -3,7 +3,8 @@ "SWITCH_TABLE:switch": { "ecmp_hash_seed": "11", "lag_hash_seed": "11", - "fdb_aging_time": "600" + "fdb_aging_time": "600", + "ordered_ecmp": "true" }, "OP": "SET" } diff --git a/src/sonic-config-engine/tests/sample_output/t0-switch-masic3.json b/src/sonic-config-engine/tests/sample_output/t0-switch-masic3.json index d9f929679cbc..db5d1b6e4aee 100644 --- a/src/sonic-config-engine/tests/sample_output/t0-switch-masic3.json +++ b/src/sonic-config-engine/tests/sample_output/t0-switch-masic3.json @@ -3,7 +3,8 @@ "SWITCH_TABLE:switch": { "ecmp_hash_seed": "13", "lag_hash_seed": "13", - "fdb_aging_time": "600" + "fdb_aging_time": "600", + "ordered_ecmp": "true" }, "OP": "SET" } diff --git a/src/sonic-config-engine/tests/sample_output/t0-switch.json b/src/sonic-config-engine/tests/sample_output/t0-switch.json index 414e53b8a356..d585ca2a52f6 100644 --- a/src/sonic-config-engine/tests/sample_output/t0-switch.json +++ b/src/sonic-config-engine/tests/sample_output/t0-switch.json @@ -3,7 +3,8 @@ "SWITCH_TABLE:switch": { "ecmp_hash_seed": "0", "lag_hash_seed": "0", - "fdb_aging_time": "600" + "fdb_aging_time": "600", + "ordered_ecmp": "false" }, "OP": "SET" } diff --git a/src/sonic-config-engine/tests/sample_output/t1-switch.json b/src/sonic-config-engine/tests/sample_output/t1-switch.json index fdae474251f0..3b3b7959191b 100644 --- a/src/sonic-config-engine/tests/sample_output/t1-switch.json +++ b/src/sonic-config-engine/tests/sample_output/t1-switch.json @@ -3,7 +3,8 @@ "SWITCH_TABLE:switch": { "ecmp_hash_seed": "10", "lag_hash_seed": "10", - "fdb_aging_time": "600" + "fdb_aging_time": "600", + "ordered_ecmp": "true" }, "OP": "SET" } diff --git a/src/sonic-config-engine/tests/sample_platform.json b/src/sonic-config-engine/tests/sample_platform.json index 1d8887920c9e..4a8804a552fe 100644 --- a/src/sonic-config-engine/tests/sample_platform.json +++ b/src/sonic-config-engine/tests/sample_platform.json @@ -350,6 +350,61 @@ "2x25G(2)+1x50G(2)": ["Eth32/1", "Eth32/2", "Eth32/3"], "1x50G(2)+2x25G(2)": ["Eth32/1", "Eth32/2", "Eth32/3"] } + }, + "Ethernet128": { + "index": "33,33,33,33", + "lanes": "128,129,130,131", + "breakout_modes": { + "1x100G[40G]": ["Eth33"], + "2x50G": ["Eth33/1", "Eth33/2"], + "4x25G[10G]": ["Eth33/1", "Eth33/2", "Eth33/3", "Eth33/4"], + "2x25G(2)+1x50G(2)": ["Eth33/1", "Eth33/2", "Eth33/3"], + "1x50G(2)+2x25G(2)": ["Eth33/1", "Eth33/2", "Eth33/3"] + } + }, + "Ethernet132": { + "index": "34,34,34,34", + "lanes": "132,133,134,135", + "breakout_modes": { + "1x100G[50G,40G,25G,10G]": ["Eth34"], + "2x50G": ["Eth34/1", "Eth34/2"], + "4x25G[10G]": ["Eth34/1", "Eth34/2", "Eth34/3", "Eth34/4"], + "2x25G(2)+1x50G(2)": ["Eth34/1", "Eth34/2", "Eth34/3"], + "1x50G(2)+2x25G(2)": ["Eth34/1", "Eth34/2", "Eth34/3"] + } + }, + "Ethernet136": { + "index": "35,35,35,35", + "lanes": "136,137,138,139", + "breakout_modes": { + "1x100G[50G,40G,25G,10G]": ["Eth35"], + "2x50G": ["Eth35/1", "Eth35/2"], + "4x25G[10G]": ["Eth35/1", "Eth35/2", "Eth35/3", "Eth35/4"], + "2x25G(2)+1x50G(2)": ["Eth35/1", "Eth35/2", "Eth35/3"], + "1x50G(2)+2x25G(2)": ["Eth35/1", "Eth35/2", "Eth35/3"] + } + }, + "Ethernet140": { + "index": "36,36,36,36", + "lanes": "140,141,142,143", + "breakout_modes": { + "1x100000[50G,40000,25000,10G]": ["Eth36"], + "2x50G": ["Eth36/1", "Eth36/2"], + "4x25G[10000]": ["Eth36/1", "Eth36/2", "Eth36/3", "Eth36/4"], + "2x25000(2)+1x50G(2)": ["Eth36/1", "Eth36/2", "Eth36/3"], + "1x50000(2)+2x25G(2)": ["Eth36/1", "Eth36/2", "Eth36/3"] + } + }, + "Ethernet144": { + "index": "37,37,37,37", + "lanes": "144,145,146,147", + "breakout_modes": { + "1x100G[50G,40G,25G,10G]": ["Eth37"], + "2x50G": ["Eth37/1", "Eth37/2"], + "4x25G[10000]": ["Eth37/1", "Eth37/2", "Eth37/3", "Eth37/4"], + "2x25000(2)+1x50G(2)": ["Eth37/1", "Eth37/2", "Eth37/3"], + "1x50000(2)+2x25G(2)": ["Eth37/1", "Eth37/2", "Eth37/3"] + } } } } diff --git a/src/sonic-config-engine/tests/simple-sample-graph-case.xml b/src/sonic-config-engine/tests/simple-sample-graph-case.xml index acaab2c4c7e3..08f750457499 100644 --- a/src/sonic-config-engine/tests/simple-sample-graph-case.xml +++ b/src/sonic-config-engine/tests/simple-sample-graph-case.xml @@ -446,7 +446,7 @@ SyslogResources - 10.0.10.5;10.0.10.6; + 10.0.10.5;10.0.10.6 diff --git a/src/sonic-config-engine/tests/simple-sample-graph-metadata.xml b/src/sonic-config-engine/tests/simple-sample-graph-metadata.xml index 80430633b1f8..5691ff81578a 100644 --- a/src/sonic-config-engine/tests/simple-sample-graph-metadata.xml +++ b/src/sonic-config-engine/tests/simple-sample-graph-metadata.xml @@ -245,7 +245,7 @@ SyslogResources - 10.0.10.5;10.0.10.6; + 10.0.10.5;10.0.10.6 diff --git a/src/sonic-config-engine/tests/simple-sample-graph.xml b/src/sonic-config-engine/tests/simple-sample-graph.xml index e1c4b87fc3ab..388627f8cdbf 100644 --- a/src/sonic-config-engine/tests/simple-sample-graph.xml +++ b/src/sonic-config-engine/tests/simple-sample-graph.xml @@ -180,11 +180,6 @@ fortyGigE0/4 - - PortChannel1001 - fortyGigE0/1;fortyGigE0/2 - - @@ -287,26 +282,6 @@ fortyGigE0/8 true - - DeviceInterfaceLink - 10000 - switch-t0 - fortyGigE0/1 - true - ARISTA05T1 - Ethernet1/32 - true - - - DeviceInterfaceLink - 10000 - switch-t0 - fortyGigE0/2 - true - ARISTA06T1 - Ethernet1/33 - true - DeviceMgmtLink 1000 @@ -457,6 +432,21 @@ + + + + switch-t0 + + + DeploymentId + + 1 + + + + + + switch-t0 Force10-S6000 diff --git a/src/sonic-config-engine/tests/t0-sample-graph.xml b/src/sonic-config-engine/tests/t0-sample-graph.xml index c06cc708c1ce..f0da95149653 100644 --- a/src/sonic-config-engine/tests/t0-sample-graph.xml +++ b/src/sonic-config-engine/tests/t0-sample-graph.xml @@ -549,6 +549,21 @@ + + + + switch-t0 + + + DeploymentId + + 1 + + + + + + switch-t0 Force10-S6000 diff --git a/src/sonic-config-engine/tests/test_cfggen.py b/src/sonic-config-engine/tests/test_cfggen.py index cbef4bbe8e5f..bf1221cab9ee 100644 --- a/src/sonic-config-engine/tests/test_cfggen.py +++ b/src/sonic-config-engine/tests/test_cfggen.py @@ -904,14 +904,14 @@ def test_minigraph_bgp_packet_chassis_static_route(self): output = self.run_script(argument) self.assertEqual( utils.to_dict(output.strip()), - utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'advertise':'false'}}") + utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'ifname': 'PortChannel40,PortChannel50', 'advertise':'false'}}") ) argument = '-m "' + self.packet_chassis_graph + '" -p "' + self.packet_chassis_port_ini + '" -n "' + "asic1" + '" -v "STATIC_ROUTE"' output = self.run_script(argument) self.assertEqual( utils.to_dict(output.strip()), - utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'advertise':'false'}}") + utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'ifname': 'PortChannel40,PortChannel50', 'advertise':'false'}}") ) def test_minigraph_bgp_packet_chassis_vlan_subintf(self): diff --git a/src/sonic-config-engine/tests/test_cfggen_platformJson.py b/src/sonic-config-engine/tests/test_cfggen_platformJson.py index 3307c3447c0c..fcfae855d0b5 100644 --- a/src/sonic-config-engine/tests/test_cfggen_platformJson.py +++ b/src/sonic-config-engine/tests/test_cfggen_platformJson.py @@ -58,9 +58,20 @@ def test_platform_json_interfaces_keys(self): argument = '-m "' + self.platform_sample_graph + '" -p "' + self.platform_json + '" -S "' + self.hwsku_json + '" -v "PORT.keys()|list"' output = self.run_script(argument) self.maxDiff = None - expected = "['Ethernet8', 'Ethernet9', 'Ethernet36', 'Ethernet98', 'Ethernet0', 'Ethernet6', 'Ethernet4', 'Ethernet109', 'Ethernet108', 'Ethernet18', 'Ethernet100', 'Ethernet34', 'Ethernet104', 'Ethernet106', 'Ethernet94', 'Ethernet126', 'Ethernet96', 'Ethernet124', 'Ethernet90', 'Ethernet91', 'Ethernet92', 'Ethernet93', 'Ethernet50', 'Ethernet51', 'Ethernet52', 'Ethernet53', 'Ethernet54', 'Ethernet99', 'Ethernet56', 'Ethernet113', 'Ethernet76', 'Ethernet74', 'Ethernet39', 'Ethernet72', 'Ethernet73', 'Ethernet70', 'Ethernet71', 'Ethernet32', 'Ethernet33', 'Ethernet16', 'Ethernet111', 'Ethernet10', 'Ethernet11', 'Ethernet12', 'Ethernet13', 'Ethernet58', 'Ethernet19', 'Ethernet59', 'Ethernet38', 'Ethernet78', 'Ethernet68', 'Ethernet14', 'Ethernet89', 'Ethernet88', 'Ethernet118', 'Ethernet119', 'Ethernet116', 'Ethernet114', 'Ethernet80', 'Ethernet112', 'Ethernet86', 'Ethernet110', 'Ethernet84', 'Ethernet31', 'Ethernet49', 'Ethernet48', 'Ethernet46', 'Ethernet30', 'Ethernet29', 'Ethernet40', 'Ethernet120', 'Ethernet28', 'Ethernet66', 'Ethernet60', 'Ethernet64', 'Ethernet44', 'Ethernet20', 'Ethernet79', 'Ethernet69', 'Ethernet24', 'Ethernet26']" - self.assertEqual(sorted(output.strip()), sorted(expected)) + expected = [ + 'Ethernet0', 'Ethernet4', 'Ethernet6', 'Ethernet8', 'Ethernet9', 'Ethernet10', 'Ethernet11', 'Ethernet12', 'Ethernet13', 'Ethernet14', 'Ethernet16', + 'Ethernet18', 'Ethernet19', 'Ethernet20', 'Ethernet24', 'Ethernet26', 'Ethernet28', 'Ethernet29', 'Ethernet30', 'Ethernet31', 'Ethernet32', 'Ethernet33', + 'Ethernet34', 'Ethernet36', 'Ethernet38', 'Ethernet39', 'Ethernet40', 'Ethernet44', 'Ethernet46', 'Ethernet48', 'Ethernet49', 'Ethernet50', 'Ethernet51', + 'Ethernet52', 'Ethernet53', 'Ethernet54', 'Ethernet56', 'Ethernet58', 'Ethernet59', 'Ethernet60', 'Ethernet64', 'Ethernet66', 'Ethernet68', 'Ethernet69', + 'Ethernet70', 'Ethernet71', 'Ethernet72', 'Ethernet73', 'Ethernet74', 'Ethernet76', 'Ethernet78', 'Ethernet79', 'Ethernet80', 'Ethernet84', 'Ethernet86', + 'Ethernet88', 'Ethernet89', 'Ethernet90', 'Ethernet91', 'Ethernet92', 'Ethernet93', 'Ethernet94', 'Ethernet96', 'Ethernet98', 'Ethernet99', 'Ethernet100', + 'Ethernet104', 'Ethernet106', 'Ethernet108', 'Ethernet109', 'Ethernet110', 'Ethernet111', 'Ethernet112', 'Ethernet113', 'Ethernet114', 'Ethernet116', + 'Ethernet118', 'Ethernet119', 'Ethernet120', 'Ethernet124', 'Ethernet126', 'Ethernet128', 'Ethernet132', 'Ethernet136', 'Ethernet137', 'Ethernet138', + 'Ethernet139', 'Ethernet140', 'Ethernet141', 'Ethernet142', 'Ethernet144' + ] + + self.assertEqual(sorted(eval(output.strip())), sorted(expected)) # Check specific Interface with it's proper configuration as per platform.json def test_platform_json_specific_ethernet_interfaces(self): @@ -83,6 +94,7 @@ def test_platform_json_specific_ethernet_interfaces(self): expected = "{'index': '2', 'lanes': '4,5', 'description': 'Eth2/1', 'admin_status': 'up', 'mtu': '9100', 'alias': 'Eth2/1', 'pfc_asym': 'off', 'speed': '50000', 'tpid': '0x8100'}" print(output.strip()) self.assertEqual(utils.to_dict(output.strip()), utils.to_dict(expected)) + # Check all Interface with it's proper configuration as per platform.json def test_platform_json_all_ethernet_interfaces(self): argument = '-m "' + self.platform_sample_graph + '" -p "' + self.platform_json + '" -S "' + self.hwsku_json + '" -v "PORT"' diff --git a/src/sonic-frr/patch/0011-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch b/src/sonic-frr/patch/0011-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch new file mode 100644 index 000000000000..7a041c02fe15 --- /dev/null +++ b/src/sonic-frr/patch/0011-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch @@ -0,0 +1,55 @@ +diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c +index 7b0611bf9..b5582ea35 100644 +--- a/zebra/zebra_fpm.c ++++ b/zebra/zebra_fpm.c +@@ -288,6 +288,9 @@ static void zfpm_start_connect_timer(const char *reason); + static void zfpm_start_stats_timer(void); + static void zfpm_mac_info_del(struct fpm_mac_info_t *fpm_mac); + ++static const char ipv4_ll_buf[16] = "169.254.0.1"; ++union g_addr ipv4ll_gateway; ++ + /* + * zfpm_thread_should_yield + */ +@@ -1988,6 +1991,9 @@ static int zfpm_init(struct thread_master *master) + zfpm_stats_init(&zfpm_g->last_ivl_stats); + zfpm_stats_init(&zfpm_g->cumulative_stats); + ++ memset(&ipv4ll_gateway, 0, sizeof(ipv4ll_gateway)); ++ inet_pton(AF_INET, ipv4_ll_buf, &ipv4ll_gateway.ipv4); ++ + install_node(&zebra_node); + install_element(ENABLE_NODE, &show_zebra_fpm_stats_cmd); + install_element(ENABLE_NODE, &clear_zebra_fpm_stats_cmd); +diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c +index 60ea7f97e..0f8ba5413 100644 +--- a/zebra/zebra_fpm_netlink.c ++++ b/zebra/zebra_fpm_netlink.c +@@ -221,7 +221,12 @@ static int netlink_route_info_add_nh(struct netlink_route_info *ri, + + if (nexthop->type == NEXTHOP_TYPE_IPV6 + || nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) { +- nhi.gateway = &nexthop->gate; ++ /* Special handling for IPv4 route with IPv6 Link Local next hop ++ */ ++ if (ri->af == AF_INET) ++ nhi.gateway = &ipv4ll_gateway; ++ else ++ nhi.gateway = &nexthop->gate; + } + + if (nexthop->type == NEXTHOP_TYPE_IFINDEX) { +diff --git a/zebra/zebra_fpm_private.h b/zebra/zebra_fpm_private.h +index c169ee8c2..13415c7e1 100644 +--- a/zebra/zebra_fpm_private.h ++++ b/zebra/zebra_fpm_private.h +@@ -97,6 +97,8 @@ extern int zfpm_netlink_encode_mac(struct fpm_mac_info_t *mac, char *in_buf, + + extern struct route_entry *zfpm_route_for_update(rib_dest_t *dest); + ++extern union g_addr ipv4ll_gateway; ++ + #ifdef __cplusplus + } + #endif diff --git a/src/sonic-frr/patch/series b/src/sonic-frr/patch/series index 376b6ce10c7b..b77931d57e9a 100644 --- a/src/sonic-frr/patch/series +++ b/src/sonic-frr/patch/series @@ -8,3 +8,4 @@ 0009-Add-bgp-bestpath-peer-type-multipath-relax.patch 0009-Link-local-scope-was-not-set-while-binding-socket-for-bgp-ipv6-link-local-neighbors.patch 0010-remove-doc-png-install.patch +0011-Ipv4-Link-local-address-for-Ipv6-linl-local-nexthop.patch diff --git a/src/sonic-host-services/host_modules/showtech.py b/src/sonic-host-services/host_modules/showtech.py new file mode 100644 index 000000000000..2b603d4f52d3 --- /dev/null +++ b/src/sonic-host-services/host_modules/showtech.py @@ -0,0 +1,50 @@ +"""Show techsupport command handler""" + +import host_service +import subprocess +import re + +MOD_NAME = 'showtech' + +class Showtech(host_service.HostModule): + """DBus endpoint that executes the "show techsupport" command + """ + @host_service.method(host_service.bus_name(MOD_NAME), in_signature='s', out_signature='is') + def info(self, date): + + ERROR_TAR_FAILED = 5 + ERROR_PROCFS_SAVE_FAILED = 6 + ERROR_INVALID_ARGUMENT = 10 + + err_dict = {ERROR_INVALID_ARGUMENT: 'Invalid input: Incorrect DateTime format', + ERROR_TAR_FAILED: 'Failure saving information into compressed output file', + ERROR_PROCFS_SAVE_FAILED: 'Saving of process information failed'} + + cmd = ['/usr/local/bin/generate_dump'] + if date: + cmd.append("-s") + cmd.append(date) + + try: + result = subprocess.run(cmd, capture_output=True, text=True, + check=True) + + except subprocess.CalledProcessError as err: + errmsg = err_dict.get(err.returncode) + + if errmsg is None: + output = 'Error: Failure code {:-5}'.format(err.returncode) + else: + output = errmsg + + print("%Error: Host side: Failed: " + str(err.returncode)) + return err.returncode, output + + output_file_match = re.search('\/var\/.*dump.*\.gz', result.stdout) + output_filename = output_file_match.group() + return result.returncode, output_filename + +def register(): + """Return the class name""" + return Showtech, MOD_NAME + diff --git a/src/sonic-mgmt-common b/src/sonic-mgmt-common index 86c110812583..d43a607d759d 160000 --- a/src/sonic-mgmt-common +++ b/src/sonic-mgmt-common @@ -1 +1 @@ -Subproject commit 86c110812583d0132d6504a1e74eb0337f521fde +Subproject commit d43a607d759d23f64d681e38d015ce0be886d440 diff --git a/src/sonic-platform-common b/src/sonic-platform-common index 77da9c8440dd..ee122155e0f6 160000 --- a/src/sonic-platform-common +++ b/src/sonic-platform-common @@ -1 +1 @@ -Subproject commit 77da9c8440dda385db745c070453ff343acc1eac +Subproject commit ee122155e0f6e40b483d24737c5f1b729bdbf111 diff --git a/src/sonic-platform-daemons b/src/sonic-platform-daemons index 59bc31557c99..c4127c28ada0 160000 --- a/src/sonic-platform-daemons +++ b/src/sonic-platform-daemons @@ -1 +1 @@ -Subproject commit 59bc31557c99ede23b3c9a937c7ebf77e7917e3c +Subproject commit c4127c28ada0cbc7fd8cb730320cbc65ef78ead8 diff --git a/src/sonic-py-common/sonic_py_common/interface.py b/src/sonic-py-common/sonic_py_common/interface.py index 59aeacf01316..286f28e531a2 100644 --- a/src/sonic-py-common/sonic_py_common/interface.py +++ b/src/sonic-py-common/sonic_py_common/interface.py @@ -15,6 +15,7 @@ "Loopback": "Loopback", "Ethernet-Backplane": "Ethernet-BP", "Ethernet-Inband": "Ethernet-IB", + "Ethernet-Recirc": "Ethernet-Rec", "Ethernet-SubPort": "Eth", "PortChannel-SubPort": "Po" } @@ -57,6 +58,12 @@ def inband_prefix(): """ return SONIC_INTERFACE_PREFIXES["Ethernet-Inband"] +def recirc_prefix(): + """ + Retrieves the SONIC recirculation port interface name prefix. + """ + return SONIC_INTERFACE_PREFIXES["Ethernet-Recirc"] + def physical_subinterface_prefix(): """ Retrieves the SONIC Subinterface name prefix. diff --git a/src/sonic-py-common/sonic_py_common/multi_asic.py b/src/sonic-py-common/sonic_py_common/multi_asic.py index a43275fd1ba9..662c01800e35 100644 --- a/src/sonic-py-common/sonic_py_common/multi_asic.py +++ b/src/sonic-py-common/sonic_py_common/multi_asic.py @@ -27,6 +27,10 @@ PORT_ROLE = 'role' +# Dictionary to cache config_db connection handle per namespace +# to prevent duplicate connections from being opened +config_db_handle = {} + def connect_config_db_for_ns(namespace=DEFAULT_NAMESPACE): """ The function connects to the config DB for a given namespace and @@ -237,7 +241,9 @@ def get_all_namespaces(): if is_multi_asic(): for asic in range(num_asics): namespace = "{}{}".format(ASIC_NAME_PREFIX, asic) - config_db = connect_config_db_for_ns(namespace) + if namespace not in config_db_handle: + config_db_handle[namespace] = connect_config_db_for_ns(namespace) + config_db = config_db_handle[namespace] metadata = config_db.get_table('DEVICE_METADATA') if metadata['localhost']['sub_role'] == FRONTEND_ASIC_SUB_ROLE: diff --git a/src/sonic-restapi b/src/sonic-restapi index e842c5ff317c..94805a39ac07 160000 --- a/src/sonic-restapi +++ b/src/sonic-restapi @@ -1 +1 @@ -Subproject commit e842c5ff317c67919dcbcab3358143cb9a16c9dd +Subproject commit 94805a39ac0712219f7dc08faa2cfdbf371dd177 diff --git a/src/sonic-sairedis b/src/sonic-sairedis index 69517ba08633..d5866a3dccfb 160000 --- a/src/sonic-sairedis +++ b/src/sonic-sairedis @@ -1 +1 @@ -Subproject commit 69517ba08633663438afd5bbab09b9a4dbe6ad5f +Subproject commit d5866a3dccfb3bc50853d740d54203b5cae61eed diff --git a/src/sonic-swss b/src/sonic-swss index bb0733aa67ff..6cb43ee25c8b 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit bb0733aa67ffc4e430e70bcf2db2dc6316172b32 +Subproject commit 6cb43ee25c8b810811bcf55f63e3e5ece7c82c7e diff --git a/src/sonic-utilities b/src/sonic-utilities index a0bff26a00d6..d9f3afe5b34e 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit a0bff26a00d63289c0cbd8ff17f5acf930588553 +Subproject commit d9f3afe5b34ef0f03f4137f607bc73bc625631ed diff --git a/src/sonic-yang-mgmt/sonic_yang.py b/src/sonic-yang-mgmt/sonic_yang.py index 0f62eccd93c1..16aeb8a9ff8a 100644 --- a/src/sonic-yang-mgmt/sonic_yang.py +++ b/src/sonic-yang-mgmt/sonic_yang.py @@ -12,7 +12,7 @@ """ class SonicYang(SonicYangExtMixin): - def __init__(self, yang_dir, debug=False): + def __init__(self, yang_dir, debug=False, print_log_enabled=True): self.yang_dir = yang_dir self.ctx = None self.module = None @@ -21,6 +21,11 @@ def __init__(self, yang_dir, debug=False): # logging vars self.SYSLOG_IDENTIFIER = "sonic_yang" self.DEBUG = debug + self.print_log_enabled = print_log_enabled + if not print_log_enabled: + # The default libyang log options are ly.LY_LOLOG|ly.LY_LOSTORE_LAST. + # Removing ly.LY_LOLOG will stop libyang from printing the logs. + ly.set_log_options(ly.LY_LOSTORE_LAST) # yang model files, need this map it to module self.yangFiles = list() @@ -51,11 +56,10 @@ def __del__(self): pass def sysLog(self, debug=syslog.LOG_INFO, msg=None, doPrint=False): - # log debug only if enabled if self.DEBUG == False and debug == syslog.LOG_DEBUG: return - if doPrint: + if doPrint and self.print_log_enabled: print("{}({}):{}".format(self.SYSLOG_IDENTIFIER, debug, msg)) syslog.openlog(self.SYSLOG_IDENTIFIER) syslog.syslog(debug, msg) @@ -64,7 +68,7 @@ def sysLog(self, debug=syslog.LOG_INFO, msg=None, doPrint=False): return def fail(self, e): - print(e) + self.sysLog(msg=e, debug=syslog.LOG_ERR, doPrint=True) raise e """ @@ -76,7 +80,7 @@ def _load_schema_module(self, yang_file): try: return self.ctx.parse_module_path(yang_file, ly.LYS_IN_YANG) except Exception as e: - print("Failed to load yang module file: " + yang_file) + self.sysLog(msg="Failed to load yang module file: " + yang_file, debug=syslog.LOG_ERR, doPrint=True) self.fail(e) """ @@ -120,7 +124,7 @@ def _load_schema_modules_ctx(self, yang_dir=None): try: ctx.parse_module_path(str(file), ly.LYS_IN_YANG) except Exception as e: - print("Failed to parse yang module file: " + file) + self.sysLog(msg="Failed to parse yang module file: " + file, debug=syslog.LOG_ERR, doPrint=True) self.fail(e) return ctx @@ -134,7 +138,7 @@ def _load_data_file(self, data_file): try: data_node = self.ctx.parse_data_path(data_file, ly.LYD_JSON, ly.LYD_OPT_CONFIG | ly.LYD_OPT_STRICT) except Exception as e: - print("Failed to load data file: " + str(data_file)) + self.sysLog(msg="Failed to load data file: " + str(data_file), debug=syslog.LOG_ERR, doPrint=True) self.fail(e) else: self.root = data_node @@ -176,7 +180,7 @@ def _load_data_model(self, yang_dir, yang_files, data_files, output=None): for i in range(1, len(data_files)): self._merge_data(data_files[i]) except Exception as e: - print("Failed to load data files") + self.sysLog(msg="Failed to load data files", debug=syslog.LOG_ERR, doPrint=True) self.fail(e) return @@ -217,7 +221,7 @@ def _get_module_tree(self, module_name, format): try: module = self.ctx.get_module(str(module_name)) except Exception as e: - print("Cound not get module: " + str(module_name)) + self.sysLog(msg="Cound not get module: " + str(module_name), debug=syslog.LOG_ERR, doPrint=True) self.fail(e) else: if (module is not None): @@ -256,7 +260,7 @@ def validate_data_tree(self): try: self._validate_data(self.root, self.ctx) except Exception as e: - print("Failed to validate data tree") + self.sysLog(msg="Failed to validate data tree\n{", debug=syslog.LOG_ERR, doPrint=True) raise SonicYangException("Failed to validate data tree\n{}".\ format(str(e))) @@ -267,12 +271,12 @@ def validate_data_tree(self): """ def _find_parent_data_node(self, data_xpath): if (self.root is None): - print("data not loaded") + self.sysLog(msg="data not loaded", debug=syslog.LOG_ERR, doPrint=True) return None try: data_node = self._find_data_node(data_xpath) except Exception as e: - print("Failed to find data node from xpath: " + str(data_xpath)) + self.sysLog(msg="Failed to find data node from xpath: " + str(data_xpath), debug=syslog.LOG_ERR, doPrint=True) self.fail(e) else: if data_node is not None: @@ -291,7 +295,7 @@ def _get_parent_data_xpath(self, data_xpath): try: data_node = self._find_parent_data_node(data_xpath) except Exception as e: - print("Failed to find parent node from xpath: " + str(data_xpath)) + self.sysLog(msg="Failed to find parent node from xpath: " + str(data_xpath), debug=syslog.LOG_ERR, doPrint=True) self.fail(e) else: if data_node is not None: @@ -310,7 +314,7 @@ def _new_data_node(self, xpath, value): try: data_node = self.root.new_path(self.ctx, xpath, val, 0, 0) except Exception as e: - print("Failed to add data node for path: " + str(xpath)) + self.sysLog(msg="Failed to add data node for path: " + str(xpath), debug=syslog.LOG_ERR, doPrint=True) self.fail(e) else: return data_node @@ -326,7 +330,7 @@ def _find_data_node(self, data_xpath): try: set = self.root.find_path(data_xpath) except Exception as e: - print("Failed to find data node from xpath: " + str(data_xpath)) + self.sysLog(msg="Failed to find data node from xpath: " + str(data_xpath), debug=syslog.LOG_ERR, doPrint=True) self.fail(e) else: if set is not None: @@ -386,7 +390,7 @@ def _add_data_node(self, data_xpath, value): #check if the node added to the data tree self._find_data_node(data_xpath) except Exception as e: - print("add_node(): Failed to add data node for xpath: " + str(data_xpath)) + self.sysLog(msg="add_node(): Failed to add data node for xpath: " + str(data_xpath), debug=syslog.LOG_ERR, doPrint=True) self.fail(e) """ @@ -426,10 +430,10 @@ def _deleteNode(self, xpath=None, node=None): #deleted node not found return True else: - print('Could not delete Node') + self.sysLog(msg='Could not delete Node', debug=syslog.LOG_ERR, doPrint=True) return False else: - print("failed to find node, xpath: " + xpath) + self.sysLog(msg="failed to find node, xpath: " + xpath, debug=syslog.LOG_ERR, doPrint=True) return False @@ -443,7 +447,7 @@ def _find_data_node_value(self, data_xpath): try: data_node = self._find_data_node(data_xpath) except Exception as e: - print("find_data_node_value(): Failed to find data node from xpath: {}".format(data_xpath)) + self.sysLog(msg="find_data_node_value(): Failed to find data node from xpath: {}".format(data_xpath), debug=syslog.LOG_ERR, doPrint=True) self.fail(e) else: if (data_node is not None): @@ -462,7 +466,7 @@ def _set_data_node_value(self, data_xpath, value): try: self.root.new_path(self.ctx, data_xpath, str(value), ly.LYD_ANYDATA_STRING, ly.LYD_PATH_OPT_UPDATE) except Exception as e: - print("set data node value failed for xpath: " + str(data_xpath)) + self.sysLog(msg="set data node value failed for xpath: " + str(data_xpath), debug=syslog.LOG_ERR, doPrint=True) self.fail(e) """ @@ -497,7 +501,7 @@ def _find_schema_dependencies(self, schema_xpath): try: schema_node = self._find_schema_node(schema_xpath) except Exception as e: - print("Cound not find the schema node from xpath: " + str(schema_xpath)) + self.sysLog(msg="Cound not find the schema node from xpath: " + str(schema_xpath), debug=syslog.LOG_ERR, doPrint=True) self.fail(e) return ref_list @@ -505,7 +509,7 @@ def _find_schema_dependencies(self, schema_xpath): backlinks = schema_node.backlinks() if backlinks.number() > 0: for link in backlinks.schema(): - print("backlink schema: {}".format(link.path())) + self.sysLog(msg="backlink schema: {}".format(link.path()), doPrint=True) ref_list.append(link.path()) return ref_list @@ -521,7 +525,7 @@ def find_data_dependencies(self, data_xpath): try: data_node = self._find_data_node(data_xpath) except Exception as e: - print("find_data_dependencies(): Failed to find data node from xpath: {}".format(data_xapth)) + self.sysLog(msg="find_data_dependencies(): Failed to find data node from xpath: {}".format(data_xapth), debug=syslog.LOG_ERR, doPrint=True) return ref_list try: @@ -538,7 +542,7 @@ def find_data_dependencies(self, data_xpath): if value == casted.value_str(): ref_list.append(data_set.path()) except Exception as e: - print('Failed to find node or dependencies for {}'.format(data_xpath)) + self.sysLog(msg='Failed to find node or dependencies for {}'.format(data_xpath), debug=syslog.LOG_ERR, doPrint=True) raise SonicYangException("Failed to find node or dependencies for \ {}\n{}".format(data_xpath, str(e))) @@ -598,7 +602,7 @@ def _get_data_type(self, schema_xpath): try: schema_node = self._find_schema_node(schema_xpath) except Exception as e: - print("get_data_type(): Failed to find schema node from xpath: {}".format(schema_xpath)) + self.sysLog(msg="get_data_type(): Failed to find schema node from xpath: {}".format(schema_xpath), debug=syslog.LOG_ERR, doPrint=True) self.fail(e) return None @@ -618,7 +622,7 @@ def _get_leafref_type(self, data_xpath): subtype = data_node.subtype() if (subtype is not None): if data_node.schema().subtype().type().base() != ly.LY_TYPE_LEAFREF: - print("get_leafref_type() node type for data xpath: {} is not LEAFREF".format(data_xpath)) + self.sysLog(msg="get_leafref_type() node type for data xpath: {} is not LEAFREF".format(data_xpath), debug=syslog.LOG_ERR, doPrint=True) return ly.LY_TYPE_UNKNOWN else: return subtype.value_type() diff --git a/src/sonic-yang-mgmt/sonic_yang_ext.py b/src/sonic-yang-mgmt/sonic_yang_ext.py index 423aece225b2..d99b805328eb 100644 --- a/src/sonic-yang-mgmt/sonic_yang_ext.py +++ b/src/sonic-yang-mgmt/sonic_yang_ext.py @@ -49,7 +49,7 @@ def loadYangModel(self): self.yangFiles = [f.split('/')[-1] for f in self.yangFiles] self.yangFiles = [f.split('.')[0] for f in self.yangFiles] self.sysLog(syslog.LOG_DEBUG,'Loaded below Yang Models') - self.sysLog(syslog.LOG_DEBUG,self.yangFiles) + self.sysLog(syslog.LOG_DEBUG,str(self.yangFiles)) # load json for each yang model self._loadJsonYangModel() @@ -219,10 +219,7 @@ def _cropConfigDB(self, croppedFile=None): del self.jIn[table] if len(self.tablesWithOutYang): - print("Note: Below table(s) have no YANG models:") - for table in self.tablesWithOutYang.keys(): - print(str(table), end=", ") - print() + self.sysLog(msg=f"Note: Below table(s) have no YANG models: {', '.join(self.tablesWithOutYang)}", doPrint=True) if croppedFile: with open(croppedFile, 'w') as f: diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 8c651a7a590c..70c14476e277 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -122,6 +122,7 @@ def run(self): './yang-models/sonic-versions.yang', './yang-models/sonic-vlan.yang', './yang-models/sonic-vrf.yang', + './yang-models/sonic-vlan-sub-interface.yang', './yang-models/sonic-warm-restart.yang', './yang-models/sonic-lldp.yang', './yang-models/sonic-scheduler.yang', @@ -131,6 +132,7 @@ def run(self): './yang-models/sonic-exp-fc-map.yang', './yang-models/sonic-dscp-tc-map.yang', './yang-models/sonic-dot1p-tc-map.yang', + './yang-models/sonic-storm-control.yang', './yang-models/sonic-tc-priority-group-map.yang', './yang-models/sonic-tc-queue-map.yang', './yang-models/sonic-pfc-priority-queue-map.yang', diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index 541cdb0f3ce3..fd3476d6dd21 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -688,6 +688,15 @@ "speed": "11100", "tpid": "0x8100", "admin_status": "up" + }, + "Ethernet120": { + "alias": "Eth31/1", + "lanes": "121,122", + "description": "", + "fec": "fc", + "speed": "11100", + "tpid": "0x8100", + "admin_status": "up" } }, "ACL_TABLE": { @@ -845,6 +854,13 @@ "family": "IPv4" } }, + "VLAN_SUB_INTERFACE": { + "Ethernet120.10": { + "admin_status": "up" + }, + "Ethernet120.10|10.0.1.56/31": {}, + "Ethernet120.10|fc00::1:71/126": {} + }, "VLAN_MEMBER": { "Vlan111|Ethernet0": { "tagging_mode": "untagged" @@ -973,13 +989,22 @@ "polling_interval": "0" } }, - "WARM_RESTART": { "bgp": { "bgp_timer": "500" } }, - + "PORT_STORM_CONTROL": { + "Ethernet0|broadcast": { + "kbps": "10000" + }, + "Ethernet0|unknown-multicast": { + "kbps": "30000" + }, + "Ethernet0|unknown-unicast": { + "kbps": "20000" + } + }, "PFC_WD": { "Ethernet9": { "action": "drop", @@ -1271,6 +1296,15 @@ "high_mem_alert": "disabled", "state": "enabled", "set_owner": "kube" + }, + "dhcp_relay": { + "auto_restart": "enabled", + "has_global_scope": "false", + "has_per_asic_scope": "true", + "has_timer": "false", + "high_mem_alert": "disabled", + "state": "{% if not (DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined and DEVICE_METADATA['localhost']['type'] != 'ToRRouter') %}enabled{% else %}disabled{% endif %}", + "set_owner": "kube" } }, "DHCP_RELAY": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/aaa.json b/src/sonic-yang-models/tests/yang_model_tests/tests/aaa.json index 5ecede4267f9..dc3a60a24df5 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/aaa.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/aaa.json @@ -8,7 +8,8 @@ }, "AAA_TEST_WRONG_FAILTHROUGH": { "desc": "Configure a wrong failthrough in AAA table.", - "eStrKey": "InvalidValue" + "eStrKey": "Pattern", + "eStr": ["false|true|False|True"] }, "AAA_AUTHORIZATION_TEST": { "desc": "Configure an authorization type in AAA table." diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/acl.json b/src/sonic-yang-models/tests/yang_model_tests/tests/acl.json index 849fbd78038f..8c307c30f294 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/acl.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/acl.json @@ -102,5 +102,8 @@ "ACL_RULE_L2_INVALID_ETHER": { "desc": "Configure invalid MAC address format.", "eStrKey" : "Pattern" + }, + "ACL_PACKET_ACTION_VALIDATE_VALUE_ACCEPT": { + "desc": "Configure CTRLPLANE with proper action ACCEPT." } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json index 16863ae253c2..a8b003c3b9ae 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/bgp.json @@ -138,6 +138,22 @@ "BGP_NEIGHBOR_NEG_INVALID_HOPS": { "desc": "Invalid TTL hops for unnumbered interface neigbhor.", "eStrKey" : "Pattern" + }, + "BGP_MONITORS_ALL_VALID": { + "desc": "Configure BGP monitor table." + }, + "BGP_MONITORS_NEG_INVALID_ADMIN_STATUS": { + "desc": "Incorrect admin status.", + "eStrKey": "InvalidValue", + "eStr": ["admin_status"] + }, + "BGP_MONITORS_NEG_INVALID_NAME": { + "desc": "Incorrect monitor name.", + "eStr": ["Invalid BGP monitor name"] + }, + "BGP_MONITORS_NEG_INVALID_ASN": { + "desc": "Invalid local AS number.", + "eStrKey" : "InvalidValue" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json b/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json index 62ebf55b6867..41a30e18965f 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json @@ -60,6 +60,33 @@ }, "DEVICE_METADATA_CORRECT_CLOUDTYPE_REGION_CONFIG": { "desc": "Verifying cloudtype and region configuration." - } + }, + "DEVICE_METADATA_DOWNSTREAM_SUBROLE_CONFIG": { + "desc": "Verifying downstream subrole configuration." + }, + "DEVICE_METADATA_RESOURCE_TYPE_CONFIG": { + "desc": "Verifying resource type configuration." + }, + "DEVICE_METADATA_VALID_SUBTYPE": { + "desc": "Verifying valid subtype value" + }, + "DEVICE_METADATA_INVALID_SUBTYPE": { + "desc": "Verifying invalid subtype value", + "eStrKey": "Pattern" + }, + "DEVICE_METADATA_VALID_PEER_SWITCH": { + "desc": "Verifying valid peer switch hostname" + }, + "DEVICE_METADATA_INVALID_PEER_SWITCH": { + "desc": "Verifying test fails with hostname that is too long", + "eStrKey": "Range" + }, + "DEVICE_METADATA_VALID_STORAGE_DEVICE": { + "desc": "Verifying valid storage device value" + }, + "DEVICE_METADATA_INVALID_STORAGE_DEVICE": { + "desc": "Verifying invalid storage device value", + "eStrKey": "InvalidValue" + } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/feature.json b/src/sonic-yang-models/tests/yang_model_tests/tests/feature.json index d18b693937c5..52dce58a2cf6 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/feature.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/feature.json @@ -2,11 +2,6 @@ "FEATURE_WITH_CORRECT_VALUES": { "desc": "CONFIG FEATURE TABLE WITH ALL THE CORRECT VALUES" }, - "FEATURE_WITH_INVALID_STATE" : { - "desc": "Referring invalid feature state.", - "eStrKey": "Pattern", - "eStr": ["enabled|disabled|always_enabled|always_disabled"] - }, "FEATURE_WITH_INVALID_BOOLEAN_TYPE" : { "desc": "Referring invalid feature boolean types.", "eStrKey": "Pattern", @@ -20,4 +15,4 @@ "FEATURE_WITH_NO_OWNER" : { "desc": "Config feature table without set_owner" } -} \ No newline at end of file +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/loopback.json b/src/sonic-yang-models/tests/yang_model_tests/tests/loopback.json index a4e4f9b6f2ca..9fdbb0a5e352 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/loopback.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/loopback.json @@ -1,7 +1,7 @@ { - "LOOPBACK_IPPREFIX_PORT_MUST_CONDITION_FALSE": { - "desc": "Loopback Ip-prefix port-name must condition failure.", - "eStrKey" : "Must" + "LOOPBACK_IPPREFIX_PORT_FOR_NON_EXIST_INTERFACE": { + "desc": "Configure Loopback Ip-prefix for non-existing Loopback interface.", + "eStrKey" : "LeafRef" }, "LOOPBACK_INTERFACE_WRONG_NAT_ZONE_RANGE": { "desc": "Configure wrong value for nat zone.", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/pfc.json b/src/sonic-yang-models/tests/yang_model_tests/tests/pfc.json index 4405075aeefc..0f8b4d0289c2 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/pfc.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/pfc.json @@ -31,6 +31,10 @@ "desc": "PFC_WDOG_WITH_WRONG_DETECTION_TIME_HIGH_VALUE", "eStr": "range" }, + "PFC_WDOG_WITH_INVALID_DETECTION_TIME": { + "desc": "PFC_WDOG_WITH_INVALID_DETECTION_TIME", + "eStr": ["detection_time must be greater than or equal to POLL_INTERVAL"] + }, "PFC_WDOG_WITH_WRONG_RESTORATION_TIME_LOW_VALUE": { "desc": "PFC_WDOG_WITH_WRONG_RESTORATION_TIME_LOW_VALUE", "eStr": "range" @@ -38,5 +42,9 @@ "PFC_WDOG_WITH_WRONG_RESTORATION_TIME_HIGH_VALUE": { "desc": "PFC_WDOG_WITH_WRONG_RESTORATION_TIME_HIGH_VALUE", "eStr": "range" + }, + "PFC_WDOG_WITH_INVALID_RESTORATION_TIME": { + "desc": "PFC_WDOG_WITH_INVALID_RESTORATION_TIME", + "eStr": ["restoration_time must be greater than or equal to POLL_INTERVAL"] } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/port.json b/src/sonic-yang-models/tests/yang_model_tests/tests/port.json index 174dcc4de716..f936d7a0b80d 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/port.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/port.json @@ -66,5 +66,12 @@ "desc": "PORT_INVALID_TPID_TEST invalid tpid value failure.", "eStrKey" : "Pattern", "eStr": ["0x8100|0x9100|0x9200|0x88a8|0x88A8"] + }, + "PORT_VALID_MUX_CABLE_TEST": { + "desc": "PORT_VALID_MUX_CABLE_TEST no failure." + }, + "PORT_INVALID_MUX_CABLE_TEST": { + "desc": "PORT_INVALID_MUX_CABLE_TEST non-boolean values, expect fail", + "eStrKey": "InvalidValue" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/storm_control.json b/src/sonic-yang-models/tests/yang_model_tests/tests/storm_control.json new file mode 100644 index 000000000000..16542eb1183b --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/storm_control.json @@ -0,0 +1,26 @@ +{ + "STORM_BROADCAST_TEST": { + "desc": "Broadcast storm-control" + }, + "STORM_UUCAST_TEST": { + "desc": "unknown-unicast storm-control" + }, + "STORM_UMCAST_TEST": { + "desc": "unknown-multicast storm-control" + }, + "STORM_INVALID_STORM_TYPE_TEST": { + "desc": "storm-control invalid storm-type", + "eStrKey" : "InvalidValue", + "eStr": ["storm_type"] + }, + "STORM_BROADCAST_INVALID_KBPS": { + "desc": "Broadcast storm-control invalid kbps", + "eStrKey" : "InvalidValue", + "eStr": ["kbps"] + }, + "STORM_BROADCAST_INVALID_INTERFACE": { + "desc": "Broadcast storm-control invalid interface", + "eStrKey" : "LeafRef", + "eStr": ["Eth"] + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json b/src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json index 74adac2f9c3d..a872784ff236 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json @@ -1,29 +1,32 @@ { + "VALID_VLAN": { + "desc": "Configure VLAN table." + }, "VLAN_INTERFACE_IPPREFIX_MUST_CONDITION_FALSE": { - "desc": "Vlan Interface Ip-prefix must condition failure.", - "eStrKey" : "Must" + "desc": "Vlan Interface Ip-prefix must condition failure.", + "eStrKey" : "Must" }, "INCORRECT_VLAN_NAME": { - "desc": "INCORRECT VLAN_NAME FIELD IN VLAN TABLE.", - "eStrKey" : "Pattern", - "eStr": ["Vlan"] + "desc": "INCORRECT VLAN_NAME FIELD IN VLAN TABLE.", + "eStrKey" : "Pattern", + "eStr": ["Vlan"] }, "WRONG_FAMILY_WITH_IP_PREFIX": { - "desc": "Configure Wrong family with ip-prefix for VLAN_Interface Table", - "eStrKey" : "Must" + "desc": "Configure Wrong family with ip-prefix for VLAN_Interface Table", + "eStrKey" : "Must" }, "DHCP_SERVER_INCORRECT_FORMAT": { - "desc": "Add dhcp_server which is not in correct ip-prefix format.", - "eStrKey" : "InvalidValue", - "eStr": ["dhcp_servers"] + "desc": "Add dhcp_server which is not in correct ip-prefix format.", + "eStrKey" : "InvalidValue", + "eStr": ["dhcp_servers"] }, "DHCPV6_SERVER_INCORRECT_FORMAT": { "desc": "Add dhcpv6_server which is not in correct ipv6-address format.", "eStrKey" : "Pattern" }, "VLAN_WITH_NON_EXIST_PORT": { - "desc": "Configure a member port in VLAN_MEMBER table which does not exist.", - "eStrKey" : "InvalidValue" + "desc": "Configure a member port in VLAN_MEMBER table which does not exist.", + "eStrKey" : "InvalidValue" }, "VLAN_WITH_PORTCHANNEL_MEMBER": { "desc": "Configure a PortChannel as a member of Vlan." @@ -33,13 +36,13 @@ "eStrKey" : "InvalidValue" }, "VLAN_MEMEBER_WITH_NON_EXIST_VLAN": { - "desc": "Configure vlan-id in VLAN_MEMBER table which does not exist in VLAN table.", - "eStrKey" : "LeafRef" + "desc": "Configure vlan-id in VLAN_MEMBER table which does not exist in VLAN table.", + "eStrKey" : "LeafRef" }, "TAGGING_MODE_WRONG_VALUE": { - "desc": "Configure wrong value for tagging_mode.", - "eStrKey" : "InvalidValue", - "eStr": ["tagging_mode"] + "desc": "Configure wrong value for tagging_mode.", + "eStrKey" : "InvalidValue", + "eStr": ["tagging_mode"] }, "VLAN_INTERFACE_WRONG_NAT_ZONE_RANGE": { "desc": "Configure wrong value for nat zone.", @@ -53,5 +56,23 @@ }, "DHCPV6_SERVER_VALID_FORMAT": { "desc": "Add dhcpv6_server in correct format." + }, + "INVALID_VLAN_MAC": { + "desc": "VLAN with invalid MAC address", + "eStrKey": "Pattern" + }, + "VLAN_INTERFACE_VALID_GRAT_ARP": { + "desc": "VLAN_INTERFACE with valid grat_arp value" + }, + "VLAN_INTERFACE_VALID_PROXY_ARP": { + "desc": "VLAN_INTERFACE with valid proxy_arp value" + }, + "VLAN_INTERFACE_INVALID_GRAT_ARP": { + "desc": "VLAN_INTERFACE with invalid grat_arp value", + "eStrKey": "Pattern" + }, + "VLAN_INTERFACE_INVALID_PROXY_ARP": { + "desc": "VLAN_INTERFACE with invalid proxy_arp value", + "eStrKey": "Pattern" } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/vlan_sub_interface.json b/src/sonic-yang-models/tests/yang_model_tests/tests/vlan_sub_interface.json new file mode 100644 index 000000000000..789b7ddd364a --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/vlan_sub_interface.json @@ -0,0 +1,29 @@ +{ + "VLAN_SUB_INTERFACE_MUST_CONDITION_TRUE_TEST": { + "desc": "Configure valid vlan sub interface must condition true." + }, + "VLAN_SUB_INTERFACE_MUST_CONDITION_FALSE_TEST": { + "desc": "Configure vlan sub interface must condition false.", + "eStrKey": "Must" + }, + "VLAN_SUB_INTERFACE_IP_PREFIX_PORT_NON_EXISTING_LEAF_TEST": { + "desc": "Configure ip prefix vlan sub interface with non-existing reference.", + "eStrKey": "LeafRef" + }, + "VLAN_SUB_INTERFACE_INVALID_VLAN_ID_TEST": { + "desc": "Configure vlan sub interface with invalid vlan id.", + "eStrKey": "Pattern" + }, + "VLAN_SUB_INTERFACE_INVALID_VLAN_ID_WITH_LEADING_ZERO_TEST": { + "desc": "Configure vlan sub interface with invalid vlan id with leading zeros.", + "eStrKey": "Pattern" + }, + "VLAN_SUB_INTERFACE_IP_PREFIX_EMPTY_STRING_TEST": { + "desc": "Configure ip prefix vlan sub interface with empty ip prefx.", + "eStrKey": "InvalidValue" + }, + "VLAN_SUB_INTERFACE_INVALID_NAME_TEST": { + "desc": "Configure invalid vlan sub interface name with no separator.", + "eStrKey": "Pattern" + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/aaa.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/aaa.json index 87b03ecd9d13..5b05fc333033 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/aaa.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/aaa.json @@ -5,8 +5,10 @@ "AAA_LIST": [{ "type": "authentication", "login": "tacacs+,local", - "failthrough": "true", - "debug": "true" + "failthrough": "True", + "fallback": "True", + "trace": "True", + "debug": "True" }] } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/acl.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/acl.json index 42ec34fed256..98acc17a63a4 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/acl.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/acl.json @@ -789,5 +789,36 @@ ] } } + }, + "ACL_PACKET_ACTION_VALIDATE_VALUE_ACCEPT": { + "sonic-acl:sonic-acl": { + "sonic-acl:ACL_RULE": { + "ACL_RULE_LIST": [ + { + "ACL_TABLE_NAME": "SNMP_ACL", + "DST_IP": "10.186.72.0/26", + "IP_TYPE": "IPv4ANY", + "PACKET_ACTION": "ACCEPT", + "PRIORITY": 999980, + "RULE_NAME": "Rule_20", + "SRC_IP": "10.176.0.0/15" + } + ] + }, + + "sonic-acl:ACL_TABLE": { + "ACL_TABLE_LIST": [ + { + "ACL_TABLE_NAME": "SNMP_ACL", + "policy_desc": "SNMP_ACL", + "services": [ + "SNMP" + ], + "stage": "ingress", + "type": "CTRLPLANE" + } + ] + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json index 3628ebf926f7..3fec22eb46fc 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/bgp.json @@ -1322,8 +1322,87 @@ ] } } - } + }, + "BGP_MONITORS_ALL_VALID": { + "sonic-bgp-monitor:sonic-bgp-monitor": { + "sonic-bgp-monitor:BGP_MONITORS": { + "BGP_MONITORS_LIST": [ + { + "addr": "10.0.0.1", + "asn": "65200", + "holdtime": "180", + "keepalive": "60", + "local_addr": "10.0.0.2", + "name":"BGPMonitor", + "nhopself":"0", + "rrclient":"0", + "admin_status":"up" + } + ] + } + } + }, + + "BGP_MONITORS_NEG_INVALID_ADMIN_STATUS": { + "sonic-bgp-monitor:sonic-bgp-monitor": { + "sonic-bgp-monitor:BGP_MONITORS": { + "BGP_MONITORS_LIST": [ + { + "addr": "10.0.0.1", + "asn": "65200", + "holdtime": "180", + "keepalive": "60", + "local_addr": "10.0.0.2", + "name":"BGPMonitor", + "nhopself":"0", + "rrclient":"0", + "admin_status":"left" + } + ] + } + } + }, + + "BGP_MONITORS_NEG_INVALID_NAME": { + "sonic-bgp-monitor:sonic-bgp-monitor": { + "sonic-bgp-monitor:BGP_MONITORS": { + "BGP_MONITORS_LIST": [ + { + "addr": "10.0.0.1", + "asn": "65200", + "holdtime": "180", + "keepalive": "60", + "local_addr": "10.0.0.2", + "name":"BGPMonitor123", + "nhopself":"0", + "rrclient":"0", + "admin_status":"up" + } + ] + } + } + }, + + "BGP_MONITORS_NEG_INVALID_ASN": { + "sonic-bgp-monitor:sonic-bgp-monitor": { + "sonic-bgp-monitor:BGP_MONITORS": { + "BGP_MONITORS_LIST": [ + { + "addr": "10.0.0.1", + "asn": "asda", + "holdtime": "180", + "keepalive": "60", + "local_addr": "10.0.0.2", + "name":"BGPMonitor", + "nhopself":"0", + "rrclient":"0", + "admin_status":"up" + } + ] + } + } + } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json index 545b34337646..50016176b7da 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json @@ -159,5 +159,77 @@ } } } + }, + "DEVICE_METADATA_DOWNSTREAM_SUBROLE_CONFIG": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "downstream_subrole": "downstream_subrole_y" + } + } + } + }, + "DEVICE_METADATA_RESOURCE_TYPE_CONFIG": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "resource_type": "resource_type_x" + } + } + } + }, + "DEVICE_METADATA_VALID_SUBTYPE": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "subtype": "DualToR" + } + } + } + }, + "DEVICE_METADATA_INVALID_SUBTYPE": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "subtype": "FakeSubtype" + } + } + } + }, + "DEVICE_METADATA_VALID_PEER_SWITCH": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "peer_switch": "peer_01_hostname" + } + } + } + }, + "DEVICE_METADATA_INVALID_PEER_SWITCH": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "peer_switch": "this_super_duper_long_hostname_is_too_long_according_to_RFC_1035" + } + } + } + }, + "DEVICE_METADATA_VALID_STORAGE_DEVICE": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "storage_device": "true" + } + } + } + }, + "DEVICE_METADATA_INVALID_STORAGE_DEVICE": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "storage_device": "yes" + } + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json index 5f43cfc3a6ab..82e403cb147c 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json @@ -47,23 +47,15 @@ "has_global_scope": "false", "has_per_asic_scope": "true", "set_owner": "kube" - } - ] - } - } - }, - "FEATURE_WITH_INVALID_STATE": { - "sonic-feature:sonic-feature": { - "sonic-feature:FEATURE": { - "FEATURE_LIST": [ + }, { - "name": "database", - "state": "dontcare", - "auto_restart": "always_enabled", + "name": "dhcp_relay", + "state": "{% if not (DEVICE_METADATA is defined and DEVICE_METADATA['localhost'] is defined and DEVICE_METADATA['localhost']['type'] is defined and DEVICE_METADATA['localhost']['type'] != 'ToRRouter') %}enabled{% else %}disabled{% endif %}", + "auto_restart": "disabled", "has_timer": "false", - "has_global_scope": "true", + "has_global_scope": "false", "has_per_asic_scope": "true", - "set_owner": "local" + "set_owner": "kube" } ] } @@ -118,4 +110,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/loopback.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/loopback.json index 89c40918739e..9ebb48556256 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/loopback.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/loopback.json @@ -1,5 +1,5 @@ { - "LOOPBACK_IPPREFIX_PORT_MUST_CONDITION_FALSE": { + "LOOPBACK_IPPREFIX_PORT_FOR_NON_EXIST_INTERFACE": { "sonic-loopback-interface:sonic-loopback-interface": { "sonic-loopback-interface:LOOPBACK_INTERFACE": { "LOOPBACK_INTERFACE_IPPREFIX_LIST": [ diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/pfc.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/pfc.json index 8c31d6dd98ed..f493701384e9 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/pfc.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/pfc.json @@ -105,36 +105,102 @@ } }, "PFC_WDOG_WITH_CORRECT_POLL_INTERVAL_VALUE": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet4", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet4", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, "sonic-pfcwd:sonic-pfcwd": { "sonic-pfcwd:PFC_WD": { "PFC_WD_LIST": [ { "ifname": "GLOBAL", "POLL_INTERVAL": 101 + }, + { + "ifname": "Ethernet4", + "action": "drop", + "detection_time": 101, + "restoration_time": 3000 } ] } } }, "PFC_WDOG_WITH_WRONG_POLL_INTERVAL_LOW_VALUE": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet4", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet4", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, "sonic-pfcwd:sonic-pfcwd": { "sonic-pfcwd:PFC_WD": { "PFC_WD_LIST": [ { "ifname": "GLOBAL", "POLL_INTERVAL":99 + }, + { + "ifname": "Ethernet4", + "action": "drop", + "detection_time": 100, + "restoration_time": 3000 } ] } } }, "PFC_WDOG_WITH_WRONG_POLL_INTERVAL_HIGH_VALUE": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet4", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet4", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, "sonic-pfcwd:sonic-pfcwd": { "sonic-pfcwd:PFC_WD": { "PFC_WD_LIST": [ { "ifname": "GLOBAL", "POLL_INTERVAL": 3001 + }, + { + "ifname": "Ethernet4", + "action": "drop", + "detection_time": 3001, + "restoration_time": 3001 } ] } @@ -160,7 +226,7 @@ "PFC_WD_LIST": [ { "ifname": "Ethernet4", - "action": "wrong", + "action": "drop", "detection_time": 5001, "restoration_time": 3000 } @@ -168,6 +234,40 @@ } } }, + "PFC_WDOG_WITH_INVALID_DETECTION_TIME": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet4", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet4", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, + "sonic-pfcwd:sonic-pfcwd": { + "sonic-pfcwd:PFC_WD": { + "PFC_WD_LIST": [ + { + "ifname": "GLOBAL", + "POLL_INTERVAL": 1000 + }, + { + "ifname": "Ethernet4", + "action": "drop", + "detection_time": 999, + "restoration_time": 1000 + } + ] + } + } + }, "PFC_WDOG_WITH_WRONG_RESTORATION_TIME_LOW_VALUE": { "sonic-pfcwd:sonic-pfcwd": { "sonic-pfcwd:PFC_WD": { @@ -188,12 +288,46 @@ "PFC_WD_LIST": [ { "ifname": "Ethernet4", - "action": "wrong", + "action": "drop", "detection_time": 60001, "restoration_time": 3000 } ] } } + }, + "PFC_WDOG_WITH_INVALID_RESTORATION_TIME": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet4", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet4", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, + "sonic-pfcwd:sonic-pfcwd": { + "sonic-pfcwd:PFC_WD": { + "PFC_WD_LIST": [ + { + "ifname": "GLOBAL", + "POLL_INTERVAL": 1000 + }, + { + "ifname": "Ethernet4", + "action": "drop", + "detection_time": 1000, + "restoration_time": 999 + } + ] + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json index 7423ecd6d419..5d7fff2cd878 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json @@ -275,5 +275,44 @@ ] } } + }, + + "PORT_VALID_MUX_CABLE_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "alias": "eth8", + "lanes": "65", + "speed": 50000, + "mux_cable": "true" + }, + { + "name": "Ethernet12", + "alias": "eth12", + "lanes": "6", + "speed": 50000, + "mux_cable": "false" + } + ] + } + } + }, + + "PORT_INVALID_MUX_CABLE_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "alias": "eth8", + "lanes": "65", + "speed": 50000, + "mux_cable": "enabled" + } + ] + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/storm_control.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/storm_control.json new file mode 100644 index 000000000000..d5c56249e484 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/storm_control.json @@ -0,0 +1,170 @@ +{ + "STORM_BROADCAST_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-storm-control:sonic-storm-control": { + "sonic-storm-control:PORT_STORM_CONTROL": { + "sonic-storm-control:PORT_STORM_CONTROL_LIST": [ + { + "ifname": "Ethernet0", + "storm_type": "broadcast", + "kbps": "100000" + } + ] + } + } + }, + "STORM_UUCAST_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-storm-control:sonic-storm-control": { + "sonic-storm-control:PORT_STORM_CONTROL": { + "sonic-storm-control:PORT_STORM_CONTROL_LIST": [ + { + "ifname": "Ethernet0", + "storm_type": "unknown-unicast", + "kbps": "200000" + } + ] + } + } + }, + "STORM_UMCAST_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-storm-control:sonic-storm-control": { + "sonic-storm-control:PORT_STORM_CONTROL": { + "sonic-storm-control:PORT_STORM_CONTROL_LIST": [ + { + "ifname": "Ethernet0", + "storm_type": "unknown-multicast", + "kbps": "300000" + } + ] + } + } + }, + "STORM_INVALID_STORM_TYPE_TEST": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-storm-control:sonic-storm-control": { + "sonic-storm-control:PORT_STORM_CONTROL": { + "sonic-storm-control:PORT_STORM_CONTROL_LIST": [ + { + "ifname": "Ethernet0", + "storm_type": "xyz", + "kbps": "400000" + } + ] + } + } + }, + "STORM_BROADCAST_INVALID_KBPS": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-storm-control:sonic-storm-control": { + "sonic-storm-control:PORT_STORM_CONTROL": { + "sonic-storm-control:PORT_STORM_CONTROL_LIST": [ + { + "ifname": "Ethernet0", + "storm_type": "broadcast", + "kbps": "xyz-kbps-value" + } + ] + } + } + }, + "STORM_BROADCAST_INVALID_INTERFACE": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + "sonic-storm-control:sonic-storm-control": { + "sonic-storm-control:PORT_STORM_CONTROL": { + "sonic-storm-control:PORT_STORM_CONTROL_LIST": [ + { + "ifname": "Eth", + "storm_type": "broadcast", + "kbps": "500000" + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json index c0ff21e6ae55..2ae87a7b822e 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json @@ -1,4 +1,33 @@ { + "VALID_VLAN": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "admin_status": "up", + "alias": "first_vlan", + "description": "server_vlan", + "dhcp_servers": [ + "10.186.72.56" + ], + "mtu": "9100", + "name": "Vlan100" + }, + { + "admin_status": "up", + "alias": "second_vlan", + "description": "server_vlan", + "dhcp_servers": [ + "10.186.72.66" + ], + "mtu": "9100", + "name": "Vlan200", + "mac": "00:aa:bb:cc:dd:ee" + } + ] + } + } + }, "INCORRECT_VLAN_NAME": { "sonic-vlan:sonic-vlan": { "sonic-vlan:VLAN": { @@ -496,5 +525,94 @@ ] } } + }, + "INVALID_VLAN_MAC": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "admin_status": "up", + "name": "Vlan1000", + "mac": "12345678" + } + ] + } + } + }, + "VLAN_INTERFACE_VALID_GRAT_ARP": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + }, + { + "name": "Vlan2000" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan1000", + "grat_arp": "enabled" + }, + { + "name": "Vlan2000", + "grat_arp": "disabled" + } + ] + } + } + }, + "VLAN_INTERFACE_VALID_PROXY_ARP": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN": { + "VLAN_LIST": [ + { + "name": "Vlan1000" + }, + { + "name": "Vlan2000" + } + ] + }, + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan1000", + "proxy_arp": "enabled" + }, + { + "name": "Vlan2000", + "proxy_arp": "disabled" + } + ] + } + } + }, + "VLAN_INTERFACE_INVALID_GRAT_ARP": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan1000", + "grat_arp": "true" + } + ] + } + } + }, + "VLAN_INTERFACE_INVALID_PROXY_ARP": { + "sonic-vlan:sonic-vlan": { + "sonic-vlan:VLAN_INTERFACE": { + "VLAN_INTERFACE_LIST": [ + { + "name": "Vlan1000", + "proxy_arp": "true" + } + ] + } + } } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan_sub_interface.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan_sub_interface.json new file mode 100644 index 000000000000..f95b1af8f049 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan_sub_interface.json @@ -0,0 +1,226 @@ +{ + "VLAN_SUB_INTERFACE_MUST_CONDITION_TRUE_TEST": { + "sonic-vlan-sub-interface:sonic-vlan-sub-interface": { + "sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": { + "VLAN_SUB_INTERFACE_LIST": [ + { + "name": "Ethernet8.10" + } + ], + "VLAN_SUB_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Ethernet8.10", + "ip-prefix": "10.0.0.1/30" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "admin_status": "up", + "alias": "Ethernet8/1", + "description": "Ethernet8", + "lanes": "45,46,47,48", + "mtu": 9000, + "speed": 100000 + } + ] + } + } + }, + "VLAN_SUB_INTERFACE_MUST_CONDITION_FALSE_TEST": { + "sonic-vlan-sub-interface:sonic-vlan-sub-interface": { + "sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": { + "VLAN_SUB_INTERFACE_LIST": [ + { + "name": "Ethernet8.10" + } + ], + "VLAN_SUB_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Ethernet8.10", + "ip-prefix": "10.0.0.1/30" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet12", + "admin_status": "up", + "alias": "Ethernet12/1", + "description": "Ethernet12", + "lanes": "49,50,51,52", + "mtu": 9000, + "speed": 100000 + } + ] + } + } + }, + "VLAN_SUB_INTERFACE_IP_PREFIX_PORT_NON_EXISTING_LEAF_TEST": { + "sonic-vlan-sub-interface:sonic-vlan-sub-interface": { + "sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": { + "VLAN_SUB_INTERFACE_LIST": [ + { + "name": "Ethernet8.10" + } + ], + "VLAN_SUB_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Ethernet8.20", + "ip-prefix": "10.0.0.1/30" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "admin_status": "up", + "alias": "Ethernet8/1", + "description": "Ethernet8", + "lanes": "45,46,47,48", + "mtu": 9000, + "speed": 100000 + } + ] + } + } + }, + "VLAN_SUB_INTERFACE_INVALID_VLAN_ID_TEST": { + "sonic-vlan-sub-interface:sonic-vlan-sub-interface": { + "sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": { + "VLAN_SUB_INTERFACE_LIST": [ + { + "name": "Ethernet8.4095" + } + ], + "VLAN_SUB_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Ethernet8.4095", + "ip-prefix": "10.0.0.1/30" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "admin_status": "up", + "alias": "Ethernet8/1", + "description": "Ethernet8", + "lanes": "45,46,47,48", + "mtu": 9000, + "speed": 100000 + } + ] + } + } + }, + "VLAN_SUB_INTERFACE_INVALID_VLAN_ID_WITH_LEADING_ZERO_TEST": { + "sonic-vlan-sub-interface:sonic-vlan-sub-interface": { + "sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": { + "VLAN_SUB_INTERFACE_LIST": [ + { + "name": "Ethernet8.095" + } + ], + "VLAN_SUB_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Ethernet8.095", + "ip-prefix": "10.0.0.1/30" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "admin_status": "up", + "alias": "Ethernet8/1", + "description": "Ethernet8", + "lanes": "45,46,47,48", + "mtu": 9000, + "speed": 100000 + } + ] + } + } + }, + "VLAN_SUB_INTERFACE_IP_PREFIX_EMPTY_STRING_TEST": { + "sonic-vlan-sub-interface:sonic-vlan-sub-interface": { + "sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": { + "VLAN_SUB_INTERFACE_LIST": [ + { + "name": "Ethernet8.10" + } + ], + "VLAN_SUB_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Ethernet8.10", + "ip-prefix": "" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "admin_status": "up", + "alias": "Ethernet8/1", + "description": "Ethernet8", + "lanes": "45,46,47,48", + "mtu": 9000, + "speed": 100000 + } + ] + } + } + }, + "VLAN_SUB_INTERFACE_INVALID_NAME_TEST": { + "sonic-vlan-sub-interface:sonic-vlan-sub-interface": { + "sonic-vlan-sub-interface:VLAN_SUB_INTERFACE": { + "VLAN_SUB_INTERFACE_LIST": [ + { + "name": "Ethernet810" + } + ], + "VLAN_SUB_INTERFACE_IPPREFIX_LIST": [ + { + "name": "Ethernet810", + "ip-prefix": "10.0.0.1/30" + } + ] + } + }, + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "name": "Ethernet8", + "admin_status": "up", + "alias": "Ethernet8/1", + "description": "Ethernet8", + "lanes": "45,46,47,48", + "mtu": 9000, + "speed": 100000 + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang index 1348ea16d947..1c360faa9cd4 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-common.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-common.yang @@ -531,4 +531,51 @@ module sonic-bgp-common { } } + grouping sonic-bgp-cmn-neigh { + leaf asn { + type uint32 { + range "1..4294967295"; + } + description "Peer AS number"; + } + + leaf holdtime { + type uint16; + description "Hold time"; + } + + leaf keepalive { + type uint16; + description "Keepalive interval"; + } + + leaf local_addr { + type inet:ip-address; + description "Local source address or interface name to use for connection."; + } + + leaf name { + type string; + description "Peer description"; + } + + leaf nhopself { + type uint8 { + range "0..1"; + } + description "Nexthop is self, no nexthop calculation"; + } + + leaf rrclient { + type uint8 { + range "0..1"; + } + description "Route reflector client"; + } + + leaf admin_status { + type stypes:admin_status; + description "Admin status of BGP peer"; + } + } } diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-monitor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-monitor.yang new file mode 100644 index 000000000000..d152ea94166b --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-bgp-monitor.yang @@ -0,0 +1,53 @@ +module sonic-bgp-monitor { + namespace "http://github.com/Azure/sonic-bgp-monitor"; + prefix bgpmon; + yang-version 1.1; + + import ietf-inet-types { + prefix inet; + } + + import sonic-types { + prefix stypes; + } + + import sonic-bgp-common { + prefix bgpcmn; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description + "SONIC BGP Monitor"; + + revision 2022-01-11 { + description + "Initial revision."; + } + + container sonic-bgp-monitor { + container BGP_MONITORS { + list BGP_MONITORS_LIST { + description "This list is to support BGP monitor configuration handled by bgpcfgd"; + key "addr"; + + leaf addr { + type inet:ip-address; + description "BGP monitor address"; + } + + uses bgpcmn:sonic-bgp-cmn-neigh { + refine name { + must "current() = 'BGPMonitor'" { + error-message "Invalid BGP monitor name"; + } + } + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang index d103cb92e58a..12432ffc35bb 100644 --- a/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang +++ b/src/sonic-yang-models/yang-models/sonic-bgp-neighbor.yang @@ -61,51 +61,7 @@ module sonic-bgp-neighbor { description "BGP Neighbor address"; } - leaf asn { - type uint32 { - range "1..4294967295"; - } - description "Peer AS number"; - } - - leaf holdtime { - type uint16; - description "Hold time"; - } - - leaf keepalive { - type uint16; - description "Keepalive interval"; - } - - leaf local_addr { - type inet:ip-address; - description "Local source address or interface name to use for connection."; - } - - leaf name { - type string; - description "Peer description"; - } - - leaf nhopself { - type uint8 { - range "0..1"; - } - description "Nexthop is self, no nexthop calculation"; - } - - leaf rrclient { - type uint8 { - range "0..1"; - } - description "Route reflector client"; - } - - leaf admin_status { - type stypes:admin_status; - description "Admin status of BGP peer"; - } + uses bgpcmn:sonic-bgp-cmn-neigh; } list BGP_NEIGHBOR_LIST { diff --git a/src/sonic-yang-models/yang-models/sonic-device_metadata.yang b/src/sonic-yang-models/yang-models/sonic-device_metadata.yang index 7ca7f44915ff..32e6b063e5b1 100644 --- a/src/sonic-yang-models/yang-models/sonic-device_metadata.yang +++ b/src/sonic-yang-models/yang-models/sonic-device_metadata.yang @@ -56,9 +56,7 @@ module sonic-device_metadata { } leaf hostname { - type string { - length 1..255; - } + type stypes:hostname; } leaf platform { @@ -128,6 +126,28 @@ module sonic-device_metadata { leaf region { type string; } + + leaf downstream_subrole { + type string; + } + + leaf resource_type { + type string; + } + + leaf subtype { + type string { + pattern "DualToR"; + } + } + + leaf peer_switch { + type stypes:hostname; + } + + leaf storage_device { + type boolean; + } } /* end of container localhost */ } diff --git a/src/sonic-yang-models/yang-models/sonic-feature.yang b/src/sonic-yang-models/yang-models/sonic-feature.yang index 6240836e74ee..be46bef19853 100644 --- a/src/sonic-yang-models/yang-models/sonic-feature.yang +++ b/src/sonic-yang-models/yang-models/sonic-feature.yang @@ -13,9 +13,7 @@ module sonic-feature{ typedef feature-state { description "configuration to set the feature running state"; - type string { - pattern "enabled|disabled|always_enabled|always_disabled"; - } + type string; } typedef feature-owner { @@ -91,4 +89,4 @@ module sonic-feature{ } } } -} \ No newline at end of file +} diff --git a/src/sonic-yang-models/yang-models/sonic-loopback-interface.yang b/src/sonic-yang-models/yang-models/sonic-loopback-interface.yang index df59d3961fb4..c3ada71aaeae 100644 --- a/src/sonic-yang-models/yang-models/sonic-loopback-interface.yang +++ b/src/sonic-yang-models/yang-models/sonic-loopback-interface.yang @@ -63,12 +63,11 @@ module sonic-loopback-interface { key "name ip-prefix"; leaf name{ - /* This node must be present in LOOPBACK_INTERFACE_LIST */ - must "(current() = ../../LOOPBACK_INTERFACE_LIST[name=current()]/name)" - { - error-message "Must condition not satisfied, Try adding lo<>: {}, Example: 'lo1': {}"; + description "Loopback interface name"; + + type leafref { + path "../../LOOPBACK_INTERFACE_LIST/name"; } - type string; } leaf ip-prefix { diff --git a/src/sonic-yang-models/yang-models/sonic-pfcwd.yang b/src/sonic-yang-models/yang-models/sonic-pfcwd.yang index beebf51965df..4ea0ffb8537f 100644 --- a/src/sonic-yang-models/yang-models/sonic-pfcwd.yang +++ b/src/sonic-yang-models/yang-models/sonic-pfcwd.yang @@ -51,6 +51,9 @@ module sonic-pfcwd { } leaf detection_time { must "../ifname != 'GLOBAL'"; + must "(not(boolean(current()/../../PFC_WD_LIST[ifname='GLOBAL'])) or (current() >= current()/../../PFC_WD_LIST[ifname='GLOBAL']/POLL_INTERVAL))" { + error-message "detection_time must be greater than or equal to POLL_INTERVAL"; + } type uint32 { range 100..5000; } @@ -59,6 +62,9 @@ module sonic-pfcwd { } leaf restoration_time { must "../ifname != 'GLOBAL'"; + must "(not(boolean(current()/../../PFC_WD_LIST[ifname='GLOBAL'])) or (current() >= current()/../../PFC_WD_LIST[ifname='GLOBAL']/POLL_INTERVAL))" { + error-message "restoration_time must be greater than or equal to POLL_INTERVAL"; + } type uint32 { range 100..60000; } diff --git a/src/sonic-yang-models/yang-models/sonic-port.yang b/src/sonic-yang-models/yang-models/sonic-port.yang index 0e1c5db0b8f0..b2031688af75 100644 --- a/src/sonic-yang-models/yang-models/sonic-port.yang +++ b/src/sonic-yang-models/yang-models/sonic-port.yang @@ -138,6 +138,10 @@ module sonic-port{ type stypes:tpid_type; } + leaf mux_cable { + type boolean; + } + } /* end of list PORT_LIST */ } /* end of container PORT */ diff --git a/src/sonic-yang-models/yang-models/sonic-storm-control.yang b/src/sonic-yang-models/yang-models/sonic-storm-control.yang new file mode 100644 index 000000000000..6d4e2b66a0f5 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-storm-control.yang @@ -0,0 +1,56 @@ +module sonic-storm-control { + namespace "http://github.com/Azure/sonic-storm-control"; + yang-version "1"; + + prefix ssc; + + import sonic-port { + prefix prt; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description + "This module defines configuration and operational state + data for broadcast, unknown-unicast and unknown-multicast (BUM) storm-control. + storm-control can be enabled on ethernet interfaces. + Rate is defined in bits-per-second. All three types of storm-control can be + enabled on an interface."; + + revision 2021-12-13 { + description + "Initial revision"; + } + + container sonic-storm-control { + container PORT_STORM_CONTROL { + list PORT_STORM_CONTROL_LIST { + key "ifname storm_type"; + /*scommon:key-pattern "PORT_STORM_CONTROL|{ifname}|{storm_type}";*/ + leaf ifname { + type leafref { + path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; + } + } + leaf storm_type { + type enumeration{ + enum broadcast; + enum unknown-unicast; + enum unknown-multicast; + } + } + leaf kbps { + type uint64 { + range "0..100000000" { + error-message "kbps value out of range"; + } + } + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-system-aaa.yang b/src/sonic-yang-models/yang-models/sonic-system-aaa.yang index 01e342b26915..5df05d475de3 100644 --- a/src/sonic-yang-models/yang-models/sonic-system-aaa.yang +++ b/src/sonic-yang-models/yang-models/sonic-system-aaa.yang @@ -3,6 +3,10 @@ module sonic-system-aaa { prefix ssys; yang-version 1.1; + import sonic-types { + prefix stypes; + } + revision 2021-10-12 { description "Add AAA authorization/accounting support."; } @@ -32,17 +36,28 @@ module sonic-system-aaa { } leaf failthrough { - type boolean; + type stypes:boolean_type; description "When set to true, authentication is attempted on next configured server/local in the list upon failure."; - default false; + default False; + } + + leaf fallback { + type stypes:boolean_type; + description "Allow AAA fallback"; + default False; } leaf debug { - type boolean; + type stypes:boolean_type; description "Enable/disable AAA debugging"; - default false; + default False; } + leaf trace { + type stypes:boolean_type; + description "AAA packet trace"; + default False; + } } } } diff --git a/src/sonic-yang-models/yang-models/sonic-vlan-sub-interface.yang b/src/sonic-yang-models/yang-models/sonic-vlan-sub-interface.yang new file mode 100644 index 000000000000..6ce391033ab0 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-vlan-sub-interface.yang @@ -0,0 +1,80 @@ +module sonic-vlan-sub-interface { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-vlan-sub-interface"; + + prefix vlan-sub-interface; + + import sonic-types { + prefix stypes; + } + + import sonic-port { + prefix port; + } + + import sonic-vrf { + prefix vrf; + } + + description "VLAN sub interface for SONiC OS"; + + revision 2021-11-11 { + description "Initial version"; + } + + container sonic-vlan-sub-interface { + container VLAN_SUB_INTERFACE { + + description "VLAN SUB INTERFACE part of config_db.json"; + + list VLAN_SUB_INTERFACE_LIST { + + description "VLAN_SUB_INTERFACE part of config_db.json with vrf"; + + key "name"; + + leaf name { + must "substring-before(current(), '.') = /port:sonic-port/port:PORT/port:PORT_LIST/port:name" + { + error-message "Must condition not satisfied, Try adding PORT: {}, Example: 'Ethernet0': {}"; + } + + // check if the vlan sub interface have the form as . + // the vlan_id should be chosen from range [1, 4094] + type string { + pattern '(\w+)\.([1-9][0-9]{0,2}|[1-3][0-9]{3}|[4][0][0-8][0-9]|[4][0][9][0-4])'; + } + } + + leaf admin_status { + type stypes:admin_status; + } + + leaf vrf_name { + type leafref { + path "/vrf:sonic-vrf/vrf:VRF/vrf:VRF_LIST/vrf:name"; + } + } + } + + list VLAN_SUB_INTERFACE_IPPREFIX_LIST { + + description "VLAN_SUB_INTERFACE part of config_db.json with ip-prefix"; + + key "name ip-prefix"; + + leaf name { + type leafref { + path "../../VLAN_SUB_INTERFACE_LIST/name"; + } + } + + leaf ip-prefix { + type stypes:sonic-ip-prefix; + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-vlan.yang b/src/sonic-yang-models/yang-models/sonic-vlan.yang index 3e4074428654..960f4b44c0d0 100644 --- a/src/sonic-yang-models/yang-models/sonic-vlan.yang +++ b/src/sonic-yang-models/yang-models/sonic-vlan.yang @@ -9,6 +9,10 @@ module sonic-vlan { prefix inet; } + import ietf-yang-types { + prefix yang; + } + import sonic-types { prefix stypes; } @@ -85,6 +89,18 @@ module sonic-vlan { enum disable; } } + + leaf grat_arp { + type string { + pattern "enabled|disabled"; + } + } + + leaf proxy_arp { + type string { + pattern "enabled|disabled"; + } + } } /* end of VLAN_INTERFACE_LIST */ @@ -155,6 +171,10 @@ module sonic-vlan { } } + leaf alias { + type string; + } + leaf description { type string { length 1..255; @@ -180,6 +200,10 @@ module sonic-vlan { leaf admin_status { type stypes:admin_status; } + + leaf mac { + type yang:mac-address; + } } /* end of VLAN_LIST */ } diff --git a/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 b/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 index 04aff692d6ee..2388b487e0eb 100644 --- a/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 +++ b/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 @@ -61,6 +61,7 @@ module sonic-types { typedef packet_action{ type enumeration { enum DROP; + enum ACCEPT; enum FORWARD; enum REDIRECT; enum DO_NOT_NAT; @@ -229,9 +230,14 @@ module sonic-types { } } + typedef hostname { + type string { + length 1..63; + } + } - /* Required for CVL */ {% if yang_model_type == "cvl" %} + /* Required for CVL */ container operation { description "This definition is used internally by CVL and diff --git a/src/sonic-ztp b/src/sonic-ztp index 4475750df0f4..f7dd3c54ec57 160000 --- a/src/sonic-ztp +++ b/src/sonic-ztp @@ -1 +1 @@ -Subproject commit 4475750df0f4db12c6e23cb59a50b47315d142db +Subproject commit f7dd3c54ec57848f7cb6d3eec748a4d8e54d0e6c diff --git a/src/tacacs/audisp/patches/0001-Porting-to-sonic.patch b/src/tacacs/audisp/patches/0001-Porting-to-sonic.patch index 343b14b3e6e2..e9277dc7c5cd 100644 --- a/src/tacacs/audisp/patches/0001-Porting-to-sonic.patch +++ b/src/tacacs/audisp/patches/0001-Porting-to-sonic.patch @@ -34,10 +34,12 @@ index ad70ca0..caead49 100644 @@ -27,7 +27,6 @@ install-data-hook: ${INSTALL} -m 755 audisp-tacplus $(DESTDIR)$(sbindir) - ${INSTALL} -d $(DESTDIR)$(sysconfdir)/audisp/plugins.d +- ${INSTALL} -d $(DESTDIR)$(sysconfdir)/audisp/plugins.d ++ ${INSTALL} -d $(DESTDIR)$(sysconfdir)/audit/plugins.d ${INSTALL} -d $(DESTDIR)$(sysconfdir)/audit/rules.d - ${INSTALL} -m 600 audisp-tac_plus.conf $(DESTDIR)$(sysconfdir)/audisp/ - ${INSTALL} -m 644 audisp-tacplus.conf $(DESTDIR)$(sysconfdir)/audisp/plugins.d +- ${INSTALL} -m 644 audisp-tacplus.conf $(DESTDIR)$(sysconfdir)/audisp/plugins.d ++ ${INSTALL} -m 644 audisp-tacplus.conf $(DESTDIR)$(sysconfdir)/audit/plugins.d ${INSTALL} -m 644 -o 0 audisp-tacplus.rules $(DESTDIR)$(sysconfdir)/audit/rules.d diff --git a/Makefile.in b/Makefile.in diff --git a/src/tacacs/bash_tacplus/debian/rules b/src/tacacs/bash_tacplus/debian/rules old mode 100644 new mode 100755 diff --git a/src/wpasupplicant/sonic-wpa-supplicant b/src/wpasupplicant/sonic-wpa-supplicant index 986a835153b3..43611ef88ea5 160000 --- a/src/wpasupplicant/sonic-wpa-supplicant +++ b/src/wpasupplicant/sonic-wpa-supplicant @@ -1 +1 @@ -Subproject commit 986a835153b3df3a37492fbd3a83fc8e38a40c10 +Subproject commit 43611ef88ea5c87f675cab55e3208c9f16bdd583