From 83781b94590dc41c1a151b9b19be28d7f4e5e518 Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Fri, 1 Jan 2021 01:00:47 -0800 Subject: [PATCH 0001/1674] [build]: fix dpkg uninstall bug fix a bug when there are multiple debian packages to be uninstalled Signed-off-by: Guohan Lu --- rules/functions | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rules/functions b/rules/functions index d5aba46fd5d2..104efa3055b7 100644 --- a/rules/functions +++ b/rules/functions @@ -145,11 +145,11 @@ expand = $(foreach d,$(1),$(call expand,$($(d)_$(2)),$(2))) $(1) ## Uninstall debs ############################################################################### define UNINSTALL_DEBS -$(info $(1)) -$(foreach deb,$(1), \ - { while true; do \ - if mkdir $(DEBS_PATH)/dpkg_lock &> /dev/null; then \ - { sudo DEBIAN_FRONTEND=noninteractive dpkg -P $(firstword $(subst _, ,$(basename $(deb)))) $(LOG) && rm -d $(DEBS_PATH)/dpkg_lock && break; } || { rm -d $(DEBS_PATH)/dpkg_lock && exit 1 ; } \ - fi; \ - done; } ) +if [ -n "$(1)" ]; then \ + while true; do \ + if mkdir $(DEBS_PATH)/dpkg_lock &> /dev/null; then \ + { sudo DEBIAN_FRONTEND=noninteractive dpkg -P $(foreach deb,$(1),$(firstword $(subst _, ,$(basename $(deb))))) $(LOG) && rm -d $(DEBS_PATH)/dpkg_lock && break; } || { rm -d $(DEBS_PATH)/dpkg_lock && exit 1 ; } \ + fi; \ + done; \ +fi endef From 68086fc2972e46f4144cc252a4e187947634539f Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Fri, 1 Jan 2021 01:14:15 -0800 Subject: [PATCH 0002/1674] [build]: check if package with given version is installed or not in case conflicting packages have same name but different version, the install step needs to wait till package with the conflicting version is uninstalled Signed-off-by: Guohan Lu --- slave.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slave.mk b/slave.mk index c75bf15e75c4..6393008b37e5 100644 --- a/slave.mk +++ b/slave.mk @@ -530,7 +530,7 @@ $(SONIC_INSTALL_TARGETS) : $(DEBS_PATH)/%-install : .platform $$(addsuffix -inst while true; do # wait for conflicted packages to be uninstalled $(foreach deb, $($*_CONFLICT_DEBS), \ - { while dpkg -s $(firstword $(subst _, ,$(basename $(deb)))) &> /dev/null; do echo "waiting for $(deb) to be uninstalled" $(LOG); sleep 1; done } ) + { while dpkg -s $(firstword $(subst _, ,$(basename $(deb)))) | grep "^Version: $(word 2, $(subst _, ,$(basename $(deb))))" &> /dev/null; do echo "waiting for $(deb) to be uninstalled" $(LOG); sleep 1; done } ) # put a lock here because dpkg does not allow installing packages in parallel if mkdir $(DEBS_PATH)/dpkg_lock &> /dev/null; then { sudo DEBIAN_FRONTEND=noninteractive dpkg -i $(DEBS_PATH)/$* $(LOG) && rm -d $(DEBS_PATH)/dpkg_lock && break; } || { rm -d $(DEBS_PATH)/dpkg_lock && exit 1 ; } From 91bf30422ceb49b80d2b82a855726381c558cc82 Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Fri, 1 Jan 2021 11:17:15 -0800 Subject: [PATCH 0003/1674] [frr]: remove dependency betwee frr and frr-snmp no instalation of frr during the build process Signed-off-by: Guohan Lu --- rules/frr.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules/frr.mk b/rules/frr.mk index 91e0c9795dae..63d25c147af2 100644 --- a/rules/frr.mk +++ b/rules/frr.mk @@ -14,13 +14,13 @@ $(FRR)_SRC_PATH = $(SRC_PATH)/sonic-frr SONIC_MAKE_DEBS += $(FRR) FRR_PYTHONTOOLS = frr-pythontools_$(FRR_VERSION)-sonic-$(FRR_SUBVERSION)_all.deb -$(eval $(call add_derived_package,$(FRR),$(FRR_PYTHONTOOLS))) +$(eval $(call add_extra_package,$(FRR),$(FRR_PYTHONTOOLS))) FRR_DBG = frr-dbgsym_$(FRR_VERSION)-sonic-$(FRR_SUBVERSION)_$(CONFIGURED_ARCH).deb $(eval $(call add_derived_package,$(FRR),$(FRR_DBG))) FRR_SNMP = frr-snmp_$(FRR_VERSION)-sonic-$(FRR_SUBVERSION)_$(CONFIGURED_ARCH).deb -$(eval $(call add_derived_package,$(FRR),$(FRR_SNMP))) +$(eval $(call add_extra_package,$(FRR),$(FRR_SNMP))) FRR_SNMP_DBG = frr-snmp-dbgsym_$(FRR_VERSION)-sonic-$(FRR_SUBVERSION)_$(CONFIGURED_ARCH).deb $(eval $(call add_derived_package,$(FRR),$(FRR_SNMP_DBG))) From 9b2274a4f1ad17124db267df906c3dce1021103a Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Wed, 30 Dec 2020 15:08:12 -0800 Subject: [PATCH 0004/1674] [build]: add artifical dependency between libyang and frr frr build requires libyang 1.0.184 which conflicts with libyang 1.0.73. Solution here is to compile frr and libyang 1.0.184 first, and then uninstall libyang 1.0.184 after frr build. Then, compile libyang 1.0.73 and all packages depend on it later. Signed-off-by: Guohan Lu --- rules/frr.mk | 1 + rules/libyang.mk | 6 ++++++ slave.mk | 13 ++++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/rules/frr.mk b/rules/frr.mk index 63d25c147af2..42b600004e8c 100644 --- a/rules/frr.mk +++ b/rules/frr.mk @@ -10,6 +10,7 @@ export FRR_VERSION FRR_SUBVERSION FRR_BRANCH FRR_TAG FRR = frr_$(FRR_VERSION)-sonic-$(FRR_SUBVERSION)_$(CONFIGURED_ARCH).deb $(FRR)_DEPENDS += $(LIBSNMP_DEV) $(LIBYANG1) $(LIBYANG1_DEV) $(FRR)_RDEPENDS += $(LIBYANG1) +$(FRR)_UNINSTALLS = $(LIBYANG1_DEV) $(LIBYANG1) $(FRR)_SRC_PATH = $(SRC_PATH)/sonic-frr SONIC_MAKE_DEBS += $(FRR) diff --git a/rules/libyang.mk b/rules/libyang.mk index 5a5000d7c425..181db2368c6d 100644 --- a/rules/libyang.mk +++ b/rules/libyang.mk @@ -10,6 +10,9 @@ export LIBYANG_SUBVERSION LIBYANG = libyang_$(LIBYANG_VERSION)_$(CONFIGURED_ARCH).deb $(LIBYANG)_SRC_PATH = $(SRC_PATH)/libyang +# introduce artifical dependency between LIBYANG and FRR +# make sure LIBYANG is compile after FRR +$(LIBYANG)_AFTER = $(FRR) SONIC_MAKE_DEBS += $(LIBYANG) LIBYANG_DEV = libyang-dev_$(LIBYANG_VERSION)_$(CONFIGURED_ARCH).deb @@ -30,4 +33,7 @@ LIBYANG_PY2 = python2-yang_$(LIBYANG_VERSION)_$(CONFIGURED_ARCH).deb $(LIBYANG_PY2)_DEPENDS += $(LIBYANG) $(LIBYANG_CPP) $(eval $(call add_derived_package,$(LIBYANG),$(LIBYANG_PY2))) +$(eval $(call add_conflict_package,$(LIBYANG),$(LIBYANG1))) +$(eval $(call add_conflict_package,$(LIBYANG_DEV),$(LIBYANG1_DEV))) + export LIBYANG LIBYANG_DBG LIBYANG_DEV LIBYANG_CPP LIBYANG_PY3 LIBYANG_PY2 diff --git a/slave.mk b/slave.mk index 6393008b37e5..18e70542f83e 100644 --- a/slave.mk +++ b/slave.mk @@ -369,6 +369,7 @@ SONIC_TARGET_LIST += $(addprefix $(FILES_PATH)/, $(SONIC_ONLINE_FILES)) # $(SOME_NEW_FILE)_DEPENDS = $(SOME_OTHER_DEB1) $(SOME_OTHER_DEB2) ... # SONIC_MAKE_FILES += $(SOME_NEW_FILE) $(addprefix $(FILES_PATH)/, $(SONIC_MAKE_FILES)) : $(FILES_PATH)/% : .platform $$(addsuffix -install,$$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS))) \ + $$(addprefix $(DEBS_PATH)/,$$($$*_AFTER)) \ $(call dpkg_depend,$(FILES_PATH)/%.dep) $(HEADER) @@ -411,6 +412,7 @@ SONIC_TARGET_LIST += $(addprefix $(FILES_PATH)/, $(SONIC_MAKE_FILES)) # $(SOME_NEW_DEB)_DEPENDS = $(SOME_OTHER_DEB1) $(SOME_OTHER_DEB2) ... # SONIC_MAKE_DEBS += $(SOME_NEW_DEB) $(addprefix $(DEBS_PATH)/, $(SONIC_MAKE_DEBS)) : $(DEBS_PATH)/% : .platform $$(addsuffix -install,$$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS))) \ + $$(addprefix $(DEBS_PATH)/,$$($$*_AFTER)) \ $(call dpkg_depend,$(DEBS_PATH)/%.dep) $(HEADER) @@ -448,6 +450,7 @@ SONIC_TARGET_LIST += $(addprefix $(DEBS_PATH)/, $(SONIC_MAKE_DEBS)) # $(SOME_NEW_DEB)_DEPENDS = $(SOME_OTHER_DEB1) $(SOME_OTHER_DEB2) ... # SONIC_DPKG_DEBS += $(SOME_NEW_DEB) $(addprefix $(DEBS_PATH)/, $(SONIC_DPKG_DEBS)) : $(DEBS_PATH)/% : .platform $$(addsuffix -install,$$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS))) \ + $$(addprefix $(DEBS_PATH)/,$$($$*_AFTER)) \ $(call dpkg_depend,$(DEBS_PATH)/%.dep ) $(HEADER) @@ -516,7 +519,7 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_EXTRA_DEBS)) : $(DEBS_PATH)/% : .platform $$( SONIC_TARGET_LIST += $(addprefix $(DEBS_PATH)/, $(SONIC_EXTRA_DEBS)) # Targets for installing debian packages prior to build one that depends on them -SONIC_INSTALL_TARGETS = $(addsuffix -install,$(addprefix $(DEBS_PATH)/, \ +SONIC_INSTALL_DEBS = $(addsuffix -install,$(addprefix $(DEBS_PATH)/, \ $(SONIC_ONLINE_DEBS) \ $(SONIC_COPY_DEBS) \ $(SONIC_MAKE_DEBS) \ @@ -524,7 +527,7 @@ SONIC_INSTALL_TARGETS = $(addsuffix -install,$(addprefix $(DEBS_PATH)/, \ $(SONIC_PYTHON_STDEB_DEBS) \ $(SONIC_DERIVED_DEBS) \ $(SONIC_EXTRA_DEBS))) -$(SONIC_INSTALL_TARGETS) : $(DEBS_PATH)/%-install : .platform $$(addsuffix -install,$$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS))) $(DEBS_PATH)/$$* +$(SONIC_INSTALL_DEBS) : $(DEBS_PATH)/%-install : .platform $$(addsuffix -install,$$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS))) $(DEBS_PATH)/$$* $(HEADER) [ -f $(DEBS_PATH)/$* ] || { echo $(DEBS_PATH)/$* does not exist $(LOG) && false $(LOG) } while true; do @@ -538,6 +541,7 @@ $(SONIC_INSTALL_TARGETS) : $(DEBS_PATH)/%-install : .platform $$(addsuffix -inst done $(FOOTER) + ############################################################################### ## Python packages ############################################################################### @@ -615,6 +619,9 @@ $(addprefix $(PYTHON_WHEELS_PATH)/, $(SONIC_PYTHON_WHEELS)) : $(PYTHON_WHEELS_PA $(call SAVE_CACHE,$*,$@) fi + # Uninstall unneeded build dependency + $(call UNINSTALL_DEBS,$($*_UNINSTALLS)) + $(FOOTER) SONIC_TARGET_LIST += $(addprefix $(PYTHON_WHEELS_PATH)/, $(SONIC_PYTHON_WHEELS)) @@ -1098,4 +1105,4 @@ jessie : $$(addprefix $(TARGET_PATH)/,$$(JESSIE_DOCKER_IMAGES)) \ .PHONY : $(SONIC_CLEAN_DEBS) $(SONIC_CLEAN_FILES) $(SONIC_CLEAN_TARGETS) $(SONIC_CLEAN_STDEB_DEBS) $(SONIC_CLEAN_WHEELS) $(SONIC_PHONY_TARGETS) clean distclean configure -.INTERMEDIATE : $(SONIC_INSTALL_TARGETS) $(SONIC_INSTALL_WHEELS) $(DOCKER_LOAD_TARGETS) docker-start .platform +.INTERMEDIATE : $(SONIC_INSTALL_DEBS) $(SONIC_INSTALL_WHEELS) $(DOCKER_LOAD_TARGETS) docker-start .platform From 0ac81e3c96e5aba8b230cf3ef090a226e8c81a02 Mon Sep 17 00:00:00 2001 From: xumia <59720581+xumia@users.noreply.github.com> Date: Sun, 3 Jan 2021 17:32:20 +0800 Subject: [PATCH 0005/1674] Fix the hostimage version path permission issue (#6337) --- build_debian.sh | 2 +- scripts/collect_host_image_version_files.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/build_debian.sh b/build_debian.sh index c642e5d8cfb2..53ac934bd357 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -578,7 +578,7 @@ sudo du -hsx $FILESYSTEM_ROOT sudo mkdir -p $FILESYSTEM_ROOT/var/lib/docker sudo mksquashfs $FILESYSTEM_ROOT $FILESYSTEM_SQUASHFS -e boot -e var/lib/docker -e $PLATFORM_DIR -sudo scripts/collect_host_image_version_files.sh $TARGET_PATH $FILESYSTEM_ROOT +scripts/collect_host_image_version_files.sh $TARGET_PATH $FILESYSTEM_ROOT if [[ $CONFIGURED_ARCH == armhf || $CONFIGURED_ARCH == arm64 ]]; then # Remove qemu arm bin executable used for cross-building diff --git a/scripts/collect_host_image_version_files.sh b/scripts/collect_host_image_version_files.sh index 3e06bcfb2345..2cabc049d9c7 100755 --- a/scripts/collect_host_image_version_files.sh +++ b/scripts/collect_host_image_version_files.sh @@ -4,6 +4,7 @@ TARGET=$1 FILESYSTEM_ROOT=$2 VERSIONS_PATH=$TARGET/versions/host-image +[ -d $VERSIONS_PATH ] && sudo rm -rf $VERSIONS_PATH mkdir -p $VERSIONS_PATH sudo LANG=C chroot $FILESYSTEM_ROOT post_run_buildinfo From 25b0f43d9f4b28267c31183e1fd11a1c734325cd Mon Sep 17 00:00:00 2001 From: Mahesh Maddikayala <10645050+smaheshm@users.noreply.github.com> Date: Sun, 3 Jan 2021 08:10:28 -0800 Subject: [PATCH 0006/1674] [sonic-py-common] Added an API to get file path containing SONiC version (#6309) * [sonic-py-common] add an API to get file path containing SONiC version so that the API can be mocked for unit tests. --- src/sonic-py-common/sonic_py_common/device_info.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sonic-py-common/sonic_py_common/device_info.py b/src/sonic-py-common/sonic_py_common/device_info.py index 5f1cb6a66d43..f486113196fb 100644 --- a/src/sonic-py-common/sonic_py_common/device_info.py +++ b/src/sonic-py-common/sonic_py_common/device_info.py @@ -297,6 +297,11 @@ def get_sonic_version_info(): return data +def get_sonic_version_file(): + if not os.path.isfile(SONIC_VERSION_YAML_PATH): + return None + + return SONIC_VERSION_YAML_PATH # # Multi-NPU functionality From 07b9282456b7c136f2e0804e3c48ad582678e29c Mon Sep 17 00:00:00 2001 From: lguohan Date: Sun, 3 Jan 2021 08:28:05 -0800 Subject: [PATCH 0007/1674] [broadcom]: match the brcm sai filename version to control file version (#6339) the control file version is 4.2.1.5-7 sonic$ sudo dpkg -i target/debs/buster/libsaibcm-dev_4.2.1.5-8_amd64.deb (Reading database ... 175880 files and directories currently installed.) Preparing to unpack .../libsaibcm-dev_4.2.1.5-8_amd64.deb ... Unpacking libsaibcm-dev (4.2.1.5-7) over (4.2.1.5-7) ... Setting up libsaibcm-dev (4.2.1.5-7) ... lgh@491d842369cf:/sonic$ sudo dpkg -i target/debs/buster/libsaibcm_4.2.1.5-8_amd64.deb (Reading database ... 175880 files and directories currently installed.) Preparing to unpack .../libsaibcm_4.2.1.5-8_amd64.deb ... Unpacking libsaibcm (4.2.1.5-7) over (4.2.1.5-7) ... Setting up libsaibcm (4.2.1.5-7) ... Processing triggers for libc-bin (2.28-10) ... Signed-off-by: Guohan Lu --- platform/broadcom/sai.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index 8690bdddcef5..cdd42ff4ed5a 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,6 +1,6 @@ -BRCM_SAI = libsaibcm_4.2.1.5-8_amd64.deb +BRCM_SAI = libsaibcm_4.2.1.5-7_amd64.deb $(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.2/master/buster/libsaibcm_4.2.1.5-8_amd64.deb?sv=2019-12-12&st=2020-12-18T18%3A41%3A23Z&se=2030-12-19T18%3A41%3A00Z&sr=b&sp=r&sig=GFNMn0borytUTFQJf%2F5A0J452XsQ%2FqnzBw5GyjFuYHw%3D" -BRCM_SAI_DEV = libsaibcm-dev_4.2.1.5-8_amd64.deb +BRCM_SAI_DEV = libsaibcm-dev_4.2.1.5-7_amd64.deb $(eval $(call add_derived_package,$(BRCM_SAI),$(BRCM_SAI_DEV))) $(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.2/master/buster/libsaibcm-dev_4.2.1.5-8_amd64.deb?sv=2019-12-12&st=2020-12-18T18%3A42%3A03Z&se=2030-12-19T18%3A42%3A00Z&sr=b&sp=r&sig=J%2BbRtZVVcZTLs3uqzZs9zObLKFxRgzvJkFL5iyJ48mA%3D" From 711b7f80790644c6e93de81955f1b74267292d8d Mon Sep 17 00:00:00 2001 From: lguohan Date: Sun, 3 Jan 2021 17:06:05 -0800 Subject: [PATCH 0008/1674] [frr]: change frr debug package to extra to avoid build break for dbg image (#6340) build frr dbg image force to install frr in the build process which breaks the current build and is uneccessary. Signed-off-by: Guohan Lu --- rules/frr.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules/frr.mk b/rules/frr.mk index 42b600004e8c..7572beb3b06c 100644 --- a/rules/frr.mk +++ b/rules/frr.mk @@ -18,13 +18,13 @@ FRR_PYTHONTOOLS = frr-pythontools_$(FRR_VERSION)-sonic-$(FRR_SUBVERSION)_all.deb $(eval $(call add_extra_package,$(FRR),$(FRR_PYTHONTOOLS))) FRR_DBG = frr-dbgsym_$(FRR_VERSION)-sonic-$(FRR_SUBVERSION)_$(CONFIGURED_ARCH).deb -$(eval $(call add_derived_package,$(FRR),$(FRR_DBG))) +$(eval $(call add_extra_package,$(FRR),$(FRR_DBG))) FRR_SNMP = frr-snmp_$(FRR_VERSION)-sonic-$(FRR_SUBVERSION)_$(CONFIGURED_ARCH).deb $(eval $(call add_extra_package,$(FRR),$(FRR_SNMP))) FRR_SNMP_DBG = frr-snmp-dbgsym_$(FRR_VERSION)-sonic-$(FRR_SUBVERSION)_$(CONFIGURED_ARCH).deb -$(eval $(call add_derived_package,$(FRR),$(FRR_SNMP_DBG))) +$(eval $(call add_extra_package,$(FRR),$(FRR_SNMP_DBG))) export FRR FRR_PYTHONTOOLS FRR_DBG FRR_SNMP FRR_SNMP_DBG From 42fa0968834f69a169f21a72cca92b97eaec79c1 Mon Sep 17 00:00:00 2001 From: Denys Petryshyn <74670099+dpetryshintl@users.noreply.github.com> Date: Mon, 4 Jan 2021 20:38:53 +0200 Subject: [PATCH 0009/1674] [BFN] Upgrade docker-syncd-bfn to buster (#6345) * Add changes to allow migration of bfn syncd to buster * Update BFN packages for Debian 10 Signed-off-by: Denys Petryshyn --- platform/barefoot/bfn-platform.mk | 2 +- platform/barefoot/bfn-sai.mk | 2 +- platform/barefoot/docker-ptf-bfn.mk | 1 - platform/barefoot/docker-syncd-bfn-rpc.mk | 1 - platform/barefoot/docker-syncd-bfn.mk | 3 --- platform/barefoot/docker-syncd-bfn/Dockerfile.j2 | 4 ++-- platform/barefoot/docker-syncd-bfn/supervisord.conf | 4 ++-- 7 files changed, 6 insertions(+), 11 deletions(-) diff --git a/platform/barefoot/bfn-platform.mk b/platform/barefoot/bfn-platform.mk index 1524a5be9b07..1db534775acd 100644 --- a/platform/barefoot/bfn-platform.mk +++ b/platform/barefoot/bfn-platform.mk @@ -1,4 +1,4 @@ -BFN_PLATFORM = bfnplatform_20201224_deb9.deb +BFN_PLATFORM = bfnplatform_20201228_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 0ef4f40258af..4f6322239d05 100644 --- a/platform/barefoot/bfn-sai.mk +++ b/platform/barefoot/bfn-sai.mk @@ -1,4 +1,4 @@ -BFN_SAI = bfnsdk_20201224_deb9.deb +BFN_SAI = bfnsdk_20201228_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/docker-ptf-bfn.mk b/platform/barefoot/docker-ptf-bfn.mk index 752e7345752a..573e9cd9cffa 100644 --- a/platform/barefoot/docker-ptf-bfn.mk +++ b/platform/barefoot/docker-ptf-bfn.mk @@ -3,4 +3,3 @@ DOCKER_PTF_BFN = docker-ptf-bfn.gz $(DOCKER_PTF_BFN)_PATH = $(DOCKERS_PATH)/docker-ptf-saithrift $(DOCKER_PTF_BFN)_LOAD_DOCKERS += $(DOCKER_PTF) -SONIC_STRETCH_DOCKERS += $(DOCKER_PTF_BFN) diff --git a/platform/barefoot/docker-syncd-bfn-rpc.mk b/platform/barefoot/docker-syncd-bfn-rpc.mk index 11b70a3a774f..aee465151d84 100644 --- a/platform/barefoot/docker-syncd-bfn-rpc.mk +++ b/platform/barefoot/docker-syncd-bfn-rpc.mk @@ -12,7 +12,6 @@ $(DOCKER_SYNCD_BFN_RPC)_DEPENDS += $(SYNCD_RPC_DBG) \ endif $(DOCKER_SYNCD_BFN_RPC)_LOAD_DOCKERS += $(DOCKER_SYNCD_BASE) SONIC_DOCKER_IMAGES += $(DOCKER_SYNCD_BFN_RPC) -SONIC_STRETCH_DOCKERS += $(DOCKER_SYNCD_BFN_RPC) ifeq ($(ENABLE_SYNCD_RPC),y) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_SYNCD_BFN_RPC) endif diff --git a/platform/barefoot/docker-syncd-bfn.mk b/platform/barefoot/docker-syncd-bfn.mk index ae4ca9d9f272..3a5c693e2fa8 100644 --- a/platform/barefoot/docker-syncd-bfn.mk +++ b/platform/barefoot/docker-syncd-bfn.mk @@ -10,8 +10,5 @@ $(DOCKER_SYNCD_BASE)_DBG_DEPENDS += $(SYNCD_DBG) \ $(LIBSAIMETADATA_DBG) \ $(LIBSAIREDIS_DBG) -SONIC_STRETCH_DOCKERS += $(DOCKER_SYNCD_BASE) -SONIC_STRETCH_DBG_DOCKERS += $(DOCKER_SYNCD_BASE_DBG) - $(DOCKER_SYNCD_BASE)_RUN_OPT += -v /host/warmboot:/var/warmboot $(DOCKER_SYNCD_BASE)_BASE_IMAGE_FILES += monit_syncd:/etc/monit/conf.d diff --git a/platform/barefoot/docker-syncd-bfn/Dockerfile.j2 b/platform/barefoot/docker-syncd-bfn/Dockerfile.j2 index b4bcafe5926a..b9dbad963665 100755 --- a/platform/barefoot/docker-syncd-bfn/Dockerfile.j2 +++ b/platform/barefoot/docker-syncd-bfn/Dockerfile.j2 @@ -1,4 +1,4 @@ -FROM docker-config-engine-stretch +FROM docker-config-engine-buster ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive @@ -15,7 +15,7 @@ RUN apt-get install -y \ libxml2 \ libpcap-dev \ libusb-1.0-0-dev \ - libcurl3 \ + libcurl4 \ libcurl4-gnutls-dev \ libunwind8-dev \ libpython3.4 \ diff --git a/platform/barefoot/docker-syncd-bfn/supervisord.conf b/platform/barefoot/docker-syncd-bfn/supervisord.conf index cb54aa419484..39ea308277d7 100644 --- a/platform/barefoot/docker-syncd-bfn/supervisord.conf +++ b/platform/barefoot/docker-syncd-bfn/supervisord.conf @@ -4,7 +4,7 @@ logfile_backups=2 nodaemon=true [eventlistener:dependent-startup] -command=python2 -m supervisord_dependent_startup +command=python3 -m supervisord_dependent_startup autostart=true autorestart=unexpected startretries=0 @@ -13,7 +13,7 @@ events=PROCESS_STATE buffer_size=25 [eventlistener:supervisor-proc-exit-listener] -command=python2 /usr/bin/supervisor-proc-exit-listener --container-name syncd +command=/usr/bin/supervisor-proc-exit-listener --container-name syncd events=PROCESS_STATE_EXITED autostart=true autorestart=unexpected From 08ab27506b1acf9a64e0c56f3ce267cf4c7af893 Mon Sep 17 00:00:00 2001 From: Sabareesh-Kumar-Anandan <59681634+Sabareesh-Kumar-Anandan@users.noreply.github.com> Date: Tue, 5 Jan 2021 01:58:32 +0530 Subject: [PATCH 0010/1674] [libyang1] Adding LFS support for arm32 (#6346) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the emulated armhf environment, the function readdir()returns NULL on a ext4 file system directory. When running the libyang1 test cases, it will require to load the plugins from the files (such as metadata.so), because the readdir() is failing, the plugins can’t be loaded in the emulated armhf environment, so it causes libyang1 test error. This error is a combination of the following reasons. • Emulation of a 32-bit target from a 64-bit host –> qemu from x86_64 to armhf • Glibc version > 2.27 – Debian buster is using glibc 2.28 - How I did it Enabled large file support by setting _FILE_OFFSET_BITS=64 for libyang1. Signed-off-by: Sabareesh Kumar Anandan --- src/libyang1/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libyang1/Makefile b/src/libyang1/Makefile index acdd686b7965..da6359aa9e12 100644 --- a/src/libyang1/Makefile +++ b/src/libyang1/Makefile @@ -28,6 +28,9 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : pushd libyang-$(LIBYANG1_VERSION) sed -i 's/set(LIBYANG_MAJOR_SOVERSION 1)/set(LIBYANG_MAJOR_SOVERSION 2)/' CMakeLists.txt sed -i 's/libyang1/libyang2/' debian/libyang1.install + # Enable large file support for 32-bit arch + echo 'add_definitions(-D_FILE_OFFSET_BITS=64)' >> CMakeLists.txt + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) popd From f7bb635be87d3d7903e26a85ce7385ff7a5798d5 Mon Sep 17 00:00:00 2001 From: Myron Sosyak <49795530+msosyak@users.noreply.github.com> Date: Tue, 5 Jan 2021 01:00:48 +0200 Subject: [PATCH 0011/1674] [BFN] Convert platform modules to python 3 (#6347) Fix syntax errors during xcvrd start with Python 3 daemons --- .../sonic_platform/sfp.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 dc57dbcd9040..cb8931998e39 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 @@ -46,7 +46,7 @@ def qsfp_ports(self): @property def port_to_eeprom_mapping(self): - print "dependency on sysfs has been removed" + print("dependency on sysfs has been removed") raise Exception() def __init__(self): @@ -88,8 +88,8 @@ def qsfp_presence_get(client): try: presence = thrift_try(qsfp_presence_get) except Exception as e: - print e.__doc__ - print e.message + print( e.__doc__) + print(e.message) return presence @@ -167,7 +167,7 @@ def get_transceiver_change_event(self, timeout=0): elif timeout > 0: timeout = timeout / float(1000) # Convert to secs else: - print "get_transceiver_change_event:Invalid timeout value", timeout + print("get_transceiver_change_event:Invalid timeout value", timeout) return False, {} while forever or timeout > 0: From 1b049421aa3d84637c97b90d4fc537a7071ea8a9 Mon Sep 17 00:00:00 2001 From: Arun Saravanan Balachandran <52521751+ArunSaravananBalachandran@users.noreply.github.com> Date: Tue, 5 Jan 2021 04:33:44 +0000 Subject: [PATCH 0012/1674] [DellEMC] Add platform-modules as prerequisite for determine-reboot-cause (#6322) Add a systemd dependency to make platform-modules service as a prerequisite for determine-reboot-cause service to ensure platform initialization is complete before determine-reboot-cause.service executes. --- .../s5232f/systemd/platform-modules-s5232f.service | 2 +- .../s6000/systemd/platform-modules-s6000.service | 2 +- .../s6100/systemd/platform-modules-s6100.service | 2 +- .../z9100/systemd/platform-modules-z9100.service | 2 +- .../z9264f/systemd/platform-modules-z9264f.service | 2 +- .../z9332f/systemd/platform-modules-z9332f.service | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-dell/s5232f/systemd/platform-modules-s5232f.service b/platform/broadcom/sonic-platform-modules-dell/s5232f/systemd/platform-modules-s5232f.service index 7fb3801e339e..0ca31b522bd4 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5232f/systemd/platform-modules-s5232f.service +++ b/platform/broadcom/sonic-platform-modules-dell/s5232f/systemd/platform-modules-s5232f.service @@ -1,6 +1,6 @@ [Unit] Description=Dell S5232f Platform modules -Before=pmon.service +Before=pmon.service determine-reboot-cause.service DefaultDependencies=no [Service] diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/systemd/platform-modules-s6000.service b/platform/broadcom/sonic-platform-modules-dell/s6000/systemd/platform-modules-s6000.service index b55a466890bd..22de50ca929e 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/systemd/platform-modules-s6000.service +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/systemd/platform-modules-s6000.service @@ -1,7 +1,7 @@ [Unit] Description=Dell S6000 Platform modules After=local-fs.target -Before=pmon.service +Before=pmon.service determine-reboot-cause.service [Service] Type=oneshot diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/systemd/platform-modules-s6100.service b/platform/broadcom/sonic-platform-modules-dell/s6100/systemd/platform-modules-s6100.service index 9b5805d5cbbb..4883ecf268fd 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/systemd/platform-modules-s6100.service +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/systemd/platform-modules-s6100.service @@ -1,6 +1,6 @@ [Unit] Description=Dell S6100 Platform modules -Before=pmon.service +Before=pmon.service determine-reboot-cause.service DefaultDependencies=no [Service] diff --git a/platform/broadcom/sonic-platform-modules-dell/z9100/systemd/platform-modules-z9100.service b/platform/broadcom/sonic-platform-modules-dell/z9100/systemd/platform-modules-z9100.service index 00fbfa6803ef..390cb6e0f567 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9100/systemd/platform-modules-z9100.service +++ b/platform/broadcom/sonic-platform-modules-dell/z9100/systemd/platform-modules-z9100.service @@ -1,6 +1,6 @@ [Unit] Description=Dell Z9100 Platform modules -Before=pmon.service +Before=pmon.service determine-reboot-cause.service DefaultDependencies=no [Service] diff --git a/platform/broadcom/sonic-platform-modules-dell/z9264f/systemd/platform-modules-z9264f.service b/platform/broadcom/sonic-platform-modules-dell/z9264f/systemd/platform-modules-z9264f.service index b89f61ea6226..05d920a8502b 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9264f/systemd/platform-modules-z9264f.service +++ b/platform/broadcom/sonic-platform-modules-dell/z9264f/systemd/platform-modules-z9264f.service @@ -1,6 +1,6 @@ [Unit] Description=Dell Z9264f Platform modules -Before=pmon.service +Before=pmon.service determine-reboot-cause.service DefaultDependencies=no [Service] diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/systemd/platform-modules-z9332f.service b/platform/broadcom/sonic-platform-modules-dell/z9332f/systemd/platform-modules-z9332f.service index 49064b00d682..348313718a70 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/systemd/platform-modules-z9332f.service +++ b/platform/broadcom/sonic-platform-modules-dell/z9332f/systemd/platform-modules-z9332f.service @@ -1,6 +1,6 @@ [Unit] Description=Dell Z9332f Platform modules -Before=pmon.service +Before=pmon.service determine-reboot-cause.service DefaultDependencies=no [Service] From dc94373a86a1dcc8755c31d93c6e03e2f356f37d Mon Sep 17 00:00:00 2001 From: lguohan Date: Mon, 4 Jan 2021 21:57:58 -0800 Subject: [PATCH 0013/1674] [docker-sonic-vs]: reduce the build steps for docker-sonic-vs (#6350) combine multiple same operation into one operation to reduce the build steps. this is to avoid max depth exceeded issue in the build. Signed-off-by: Guohan Lu --- platform/vs/docker-sonic-vs/Dockerfile.j2 | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/platform/vs/docker-sonic-vs/Dockerfile.j2 b/platform/vs/docker-sonic-vs/Dockerfile.j2 index a9f05f9b7421..837e8fc3cb66 100644 --- a/platform/vs/docker-sonic-vs/Dockerfile.j2 +++ b/platform/vs/docker-sonic-vs/Dockerfile.j2 @@ -101,33 +101,23 @@ RUN pip3 install \ {% if docker_sonic_vs_debs.strip() -%} # Copy locally-built Debian package dependencies -{%- for deb in docker_sonic_vs_debs.split(' ') %} -COPY debs/{{ deb }} /debs/ -{%- endfor %} +COPY {%- for deb in docker_sonic_vs_debs.split(' ') %} debs/{{ deb }}{%- endfor %} /debs/ # Install locally-built Debian packages and implicitly install their dependencies -{%- for deb in docker_sonic_vs_debs.split(' ') %} -RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; dpkg_apt /debs/{{ deb }} -{%- endfor %} +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; {%- for deb in docker_sonic_vs_debs.split(' ') %} dpkg_apt /debs/{{ deb }};{%- endfor %} {%- endif %} {% if docker_sonic_vs_pydebs.strip() -%} # Copy locally-built Debian package dependencies -{%- for deb in docker_sonic_vs_pydebs.split(' ') %} -COPY python-debs/{{ deb }} /debs/ -{%- endfor %} +COPY {%- for deb in docker_sonic_vs_pydebs.split(' ') %} python-debs/{{ deb }}{%- endfor %} /debs/ # Install locally-built Debian packages and implicitly install their dependencies -{%- for deb in docker_sonic_vs_pydebs.split(' ') %} -RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; dpkg_apt /debs/{{ deb }} -{%- endfor %} +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; }; {%- for deb in docker_sonic_vs_pydebs.split(' ') %} dpkg_apt /debs/{{ deb }};{%- endfor %} {%- endif %} {% if docker_sonic_vs_whls.strip() %} # copy all whl PKGs first, -{% for whl in docker_sonic_vs_whls.split(' ') -%} -COPY python-wheels/{{ whl }} python-wheels/ -{% endfor %} +copy {%- for whl in docker_sonic_vs_whls.split(' ') %} python-wheels/{{ whl }}{%- endfor %} python-wheels/ # install PKGs after copying all PKGs to avoid dependency failure # use py3 to find python3 package, which is forced by wheel as of now From d4f33183374a236623a1a3713c7ba026c5bf147d Mon Sep 17 00:00:00 2001 From: sudhanshukumar22 <51457531+sudhanshukumar22@users.noreply.github.com> Date: Tue, 5 Jan 2021 12:49:50 +0530 Subject: [PATCH 0014/1674] [lldp] lldp upstream patches (#6118) The details are as follows: 1. 0010-Ported-fix-for-length-exceeded-from-lldp-community.patch Patch taken from https://github.com/lldpd/lldpd/commit/78243478dcec865486b387cf361783dc137015b5 lib: remove limit on system description length The limit was introduced in 9c49ced while fixing a memory leak. The state data is used to ensure we don't interleave operations. We need to handle the case where the value is truncated because it is larger than the allocated size. Fix issue https://github.com/lldpd/lldpd/issues/408 2. 0011-fix-med-location-len.patch Patch taken from https://github.com/lldpd/lldpd/pull/422/commits/5c3479463a919193213213e2d8634c754c09aa51 lib: fix LLDP-MED location parsing in liblldpctl Some bounds were not checked correctly when parsing LLDP-MED civic location fields. This triggers out-of-bound reads (no write) in lldpcli, ultimately leading to a crash. Fix https://github.com/lldpd/lldpd/pull/420 Signed-off-by: sudhanshukumar22 --- ...-length-exceeded-from-lldp-community.patch | 35 ++++++++++++++ .../patch/0011-fix-med-location-len.patch | 47 +++++++++++++++++++ src/lldpd/patch/series | 2 + 3 files changed, 84 insertions(+) create mode 100644 src/lldpd/patch/0010-Ported-fix-for-length-exceeded-from-lldp-community.patch create mode 100644 src/lldpd/patch/0011-fix-med-location-len.patch diff --git a/src/lldpd/patch/0010-Ported-fix-for-length-exceeded-from-lldp-community.patch b/src/lldpd/patch/0010-Ported-fix-for-length-exceeded-from-lldp-community.patch new file mode 100644 index 000000000000..072790641206 --- /dev/null +++ b/src/lldpd/patch/0010-Ported-fix-for-length-exceeded-from-lldp-community.patch @@ -0,0 +1,35 @@ +From fdb789c348fdcde6d5ef8b837d7f33718bc0862b Mon Sep 17 00:00:00 2001 +From: sudhanshukumar22 +Date: Mon, 23 Nov 2020 20:47:28 -0800 +Subject: [PATCH] Ported fix for https://github.com/lldpd/lldpd/issues/408 from + community + +--- + src/lib/atom.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/lib/atom.c b/src/lib/atom.c +index f81d3bb..75c1275 100644 +--- a/src/lib/atom.c ++++ b/src/lib/atom.c +@@ -327,7 +327,7 @@ _lldpctl_do_something(lldpctl_conn_t *conn, + conn->state_data[0] = 0; + } + if (conn->state == state_send && +- (state_data == NULL || !strncmp(conn->state_data, state_data, sizeof(conn->state_data)))) { ++ (state_data == NULL || !strncmp(conn->state_data, state_data, sizeof(conn->state_data) - 1))) { + /* We need to send the currently built message */ + rc = lldpctl_send(conn); + if (rc < 0) +@@ -335,7 +335,7 @@ _lldpctl_do_something(lldpctl_conn_t *conn, + conn->state = state_recv; + } + if (conn->state == state_recv && +- (state_data == NULL || !strncmp(conn->state_data, state_data, sizeof(conn->state_data)))) { ++ (state_data == NULL || !strncmp(conn->state_data, state_data, sizeof(conn->state_data) - 1))) { + /* We need to receive the answer */ + while ((rc = ctl_msg_recv_unserialized(&conn->input_buffer, + &conn->input_buffer_len, +-- +2.12.2 + diff --git a/src/lldpd/patch/0011-fix-med-location-len.patch b/src/lldpd/patch/0011-fix-med-location-len.patch new file mode 100644 index 000000000000..2290a94442c1 --- /dev/null +++ b/src/lldpd/patch/0011-fix-med-location-len.patch @@ -0,0 +1,47 @@ +From e9bf329eee94d6d49a17da35aea189179aeed3c6 Mon Sep 17 00:00:00 2001 +From: sudhanshukumar22 +Date: Thu, 24 Dec 2020 09:27:49 -0800 +Subject: [PATCH] From 5c3479463a919193213213e2d8634c754c09aa51 Mon Sep 17 + 00:00:00 2001 From: Vincent Bernat Date: Sun, 6 Dec 2020 + 14:21:04 +0100 Subject: [PATCH] lib: fix LLDP-MED location parsing in + liblldpctl + +Some bounds were not checked correctly when parsing LLDP-MED civic +location fields. This triggers out-of-bound reads (no write) in +lldpcli, ultimately leading to a crash. + +Fix #420 +Signed-off-by: sudhanshukumar22 +--- + src/lib/atoms/med.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/src/lib/atoms/med.c b/src/lib/atoms/med.c +index e1b20fd..595dba4 100644 +--- a/src/lib/atoms/med.c ++++ b/src/lib/atoms/med.c +@@ -540,6 +540,7 @@ _lldpctl_atom_get_str_med_location(lldpctl_atom_t *atom, lldpctl_key_t key) + return NULL; + case lldpctl_k_med_location_country: + if (m->location->format != LLDP_MED_LOCFORMAT_CIVIC) break; ++ if (m->location->data_len < 4) return NULL; + value = _lldpctl_alloc_in_atom(atom, 3); + if (!value) return NULL; + memcpy(value, m->location->data + 2, 2); +@@ -732,8 +733,11 @@ _lldpctl_atom_iter_med_caelements_list(lldpctl_atom_t *atom) + { + struct _lldpctl_atom_med_caelements_list_t *plist = + (struct _lldpctl_atom_med_caelements_list_t *)atom; +- struct ca_iter *iter = _lldpctl_alloc_in_atom(atom, sizeof(struct ca_iter)); +- if (!iter) return NULL; ++ struct ca_iter *iter; ++ if (plist->parent->location->data_len < 4 || ++ *(uint8_t*)plist->parent->location->data < 3 || ++ !(iter = _lldpctl_alloc_in_atom(atom, sizeof(struct ca_iter)))) ++ return NULL; + iter->data = (uint8_t*)plist->parent->location->data + 4; + iter->data_len = *(uint8_t*)plist->parent->location->data - 3; + return (lldpctl_atom_iter_t*)iter; +-- +2.12.2 + diff --git a/src/lldpd/patch/series b/src/lldpd/patch/series index 419fbc96a16f..32fd4c0ca9a7 100644 --- a/src/lldpd/patch/series +++ b/src/lldpd/patch/series @@ -3,3 +3,5 @@ 0004-lldpctl-put-a-lock-around-some-commands-to-avoid-rac.patch 0006-lib-fix-memory-leak.patch 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 From a79eb88052963c2ba18045fe1776a50c6d3452c4 Mon Sep 17 00:00:00 2001 From: xumia <59720581+xumia@users.noreply.github.com> Date: Tue, 5 Jan 2021 19:05:13 +0800 Subject: [PATCH 0015/1674] Install the latest version of the sonic build hooks in slave container (#6348) --- scripts/prepare_slave_container_buildinfo.sh | 3 +++ scripts/versions_manager.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/scripts/prepare_slave_container_buildinfo.sh b/scripts/prepare_slave_container_buildinfo.sh index d66bbe816104..be6fe078bdfb 100755 --- a/scripts/prepare_slave_container_buildinfo.sh +++ b/scripts/prepare_slave_container_buildinfo.sh @@ -4,6 +4,9 @@ SLAVE_DIR=$1 ARCH=$2 DISTRO=$3 +# Install the latest debian package sonic-build-hooks in the slave container +sudo dpkg -i --force-overwrite $SLAVE_DIR/buildinfo/sonic-build-hooks_*.deb > /dev/null + # Enable the build hooks symlink_build_hooks diff --git a/scripts/versions_manager.py b/scripts/versions_manager.py index 59621cdfbbc7..336568bfb4e0 100755 --- a/scripts/versions_manager.py +++ b/scripts/versions_manager.py @@ -190,6 +190,8 @@ def _get_config_module(self, default_module, dist, arch): if ctype not in ctype_components: ctype_components[ctype] = [] for components in ctype_components.values(): + if len(components) == 0: + continue config_component = self._get_config_for_ctype(components, dist, arch) config_components.append(config_component) config_module = VersionModule(self.name, config_components) From 46c2bf0ed4d54ece26764955e043ef3c4ed8fba4 Mon Sep 17 00:00:00 2001 From: Akhilesh Samineni <47657796+AkhileshSamineni@users.noreply.github.com> Date: Tue, 5 Jan 2021 22:52:16 +0530 Subject: [PATCH 0016/1674] After first bootup, the FEATURE table is not present in CONFIG_DB (#5911) Fix the After first bootup(onie-install), the FEATURE table is not present in CONFIG_DB. Fix is done by calling config reload. --- files/image_config/config-setup/config-setup | 36 ++++---------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/files/image_config/config-setup/config-setup b/files/image_config/config-setup/config-setup index 8db3d5c1b4eb..4ed841cd3cdc 100755 --- a/files/image_config/config-setup/config-setup +++ b/files/image_config/config-setup/config-setup @@ -112,10 +112,13 @@ reload_minigraph() } # Reload exisitng config db file on disk +# Usage: reload_configdb reload_configdb() { + CONFIG_FILE=${1} + echo "Reloading existing config db..." - config reload -y -n + config reload ${CONFIG_FILE} -y -n } # Restore SONiC configuration from a backup copy function copy_config_files_and_directories() @@ -171,33 +174,6 @@ ztp_is_enabled() return $rv } -# Load requested SONiC configuration into config DB and initialize it -# Usage: load_config -# -# -load_config() -{ - CONFIG_FILE=${1} - if [ "${CONFIG_FILE}" = "" ]; then - return 1 - fi - - sonic-db-cli CONFIG_DB FLUSHDB - sonic-cfggen -j ${CONFIG_FILE} --write-to-db - if [ $? -ne 0 ]; then - return $? - fi - - if [[ -x /usr/local/bin/db_migrator.py ]]; then - # Migrate the DB to the latest schema version if needed - /usr/local/bin/db_migrator.py -o migrate - fi - - sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1" - return 0 -} - - # Generate requested SONiC configuration and save it as destination file # Usage: generate_config < factory | ztp > # @@ -249,14 +225,14 @@ do_config_initialization() if ! ztp_is_enabled ; then echo "No configuration detected, generating factory default configuration..." generate_config factory ${CONFIG_DB_JSON} - load_config ${CONFIG_DB_JSON} + reload_configdb ${CONFIG_DB_JSON} fi fi if ztp_is_enabled ; then echo "No configuration detected, initiating zero touch provisioning..." generate_config ztp ${TMP_ZTP_CONFIG_DB_JSON} - load_config ${TMP_ZTP_CONFIG_DB_JSON} + reload_configdb ${TMP_ZTP_CONFIG_DB_JSON} rm -f ${TMP_ZTP_CONFIG_DB_JSON} fi From d00dc069459f52f8732ad7f8c1e002ef397934a1 Mon Sep 17 00:00:00 2001 From: Junchao-Mellanox <57339448+Junchao-Mellanox@users.noreply.github.com> Date: Wed, 6 Jan 2021 01:39:52 +0800 Subject: [PATCH 0017/1674] [xcvrd] Remove dependency on SONIC_PLATFORM_API_PY2 and SONIC_PLATFORM_API_PY3 (#6344) Remove the build time dependency on SONIC_PLATFORM_API_PY2 and SONIC_PLATFORM_API_PY3 from xcvrd make rule --- rules/sonic-xcvrd.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules/sonic-xcvrd.mk b/rules/sonic-xcvrd.mk index 5a0c6a44b89d..018363f367fd 100644 --- a/rules/sonic-xcvrd.mk +++ b/rules/sonic-xcvrd.mk @@ -4,7 +4,7 @@ SONIC_XCVRD_PY2 = sonic_xcvrd-1.0-py2-none-any.whl $(SONIC_XCVRD_PY2)_SRC_PATH = $(SRC_PATH)/sonic-platform-daemons/sonic-xcvrd -$(SONIC_XCVRD_PY2)_DEPENDS = $(SONIC_PY_COMMON_PY2) $(SONIC_PLATFORM_COMMON_PY2) $(SONIC_PLATFORM_API_PY2) +$(SONIC_XCVRD_PY2)_DEPENDS = $(SONIC_PY_COMMON_PY2) $(SONIC_PLATFORM_COMMON_PY2) $(SONIC_XCVRD_PY2)_DEBS_DEPENDS = $(LIBSWSSCOMMON) $(PYTHON_SWSSCOMMON) $(SONIC_XCVRD_PY2)_PYTHON_VERSION = 2 SONIC_PYTHON_WHEELS += $(SONIC_XCVRD_PY2) @@ -13,7 +13,7 @@ SONIC_PYTHON_WHEELS += $(SONIC_XCVRD_PY2) SONIC_XCVRD_PY3 = sonic_xcvrd-1.0-py3-none-any.whl $(SONIC_XCVRD_PY3)_SRC_PATH = $(SRC_PATH)/sonic-platform-daemons/sonic-xcvrd -$(SONIC_XCVRD_PY3)_DEPENDS = $(SONIC_PY_COMMON_PY3) $(SONIC_XCVRD_PY2) $(SONIC_PLATFORM_COMMON_PY3) $(SONIC_PLATFORM_API_PY3) +$(SONIC_XCVRD_PY3)_DEPENDS = $(SONIC_PY_COMMON_PY3) $(SONIC_XCVRD_PY2) $(SONIC_PLATFORM_COMMON_PY3) $(SONIC_XCVRD_PY3)_DEBS_DEPENDS = $(LIBSWSSCOMMON) $(PYTHON3_SWSSCOMMON) $(SONIC_XCVRD_PY3)_PYTHON_VERSION = 3 SONIC_PYTHON_WHEELS += $(SONIC_XCVRD_PY3) From 5becc2ac7ee6f7fe628a82d33841748fea8bcd21 Mon Sep 17 00:00:00 2001 From: Vaibhav Hemant Dixit Date: Tue, 5 Jan 2021 10:47:42 -0800 Subject: [PATCH 0018/1674] [determine-reboot-cause] Ignore non-hardware reboot cause (#6349) - Why I did it - Reboot cause prints "Non-Hardware (N/A)" instead of showing the software reboot cause. The issue is mishandling of hardware reboot cause in determine-reboot-cause script. - How I did it Fixed the handling for Non Hardware reboot cause. Ignore if Non-Hardware is present in the hardware_reboot_cause output. Added some code refactoring for simplicity. - How to verify it - With fix, the hardware reboot cause is ignored (if it is non hw): --- .../scripts/determine-reboot-cause | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/sonic-host-services/scripts/determine-reboot-cause b/src/sonic-host-services/scripts/determine-reboot-cause index 8439c78a7016..8f1ee0a39b5d 100755 --- a/src/sonic-host-services/scripts/determine-reboot-cause +++ b/src/sonic-host-services/scripts/determine-reboot-cause @@ -164,35 +164,22 @@ def main(): if os.path.exists(PREVIOUS_REBOOT_CAUSE_FILE): os.remove(PREVIOUS_REBOOT_CAUSE_FILE) - hardware_reboot_cause = None # This variable is kept for future-use purpose. When proc_cmd_line/vendor/software provides # any additional_reboot_info it will be stored as a "comment" in REBOOT_CAUSE_HISTORY_FILE additional_reboot_info = "N/A" - # 1. Check if the previous reboot was warm/fast reboot by testing whether there is "fast|fastfast|warm" in /proc/cmdline + # Check if the previous reboot was warm/fast reboot by testing whether there is "fast|fastfast|warm" in /proc/cmdline proc_cmdline_reboot_cause = find_proc_cmdline_reboot_cause() - # 2. Check if the previous reboot was caused by hardware - # If yes, the hardware reboot cause will be treated as the reboot cause - hardware_reboot_cause = find_hardware_reboot_cause() - - # 3. If there is a REBOOT_CAUSE_FILE, it will contain any software-related - # reboot info. We will use it as the previous cause. - software_reboot_cause = find_software_reboot_cause() - - # The main decision logic of the reboot cause: - # If there is a reboot cause indicated by /proc/cmdline, it should be warmreboot/fastreboot - # the software_reboot_cause which is the content of /hosts/reboot-cause/reboot-cause.txt - # will be treated as the reboot cause - # Elif there is a reboot cause indicated by platform API, - # the hardware_reboot_cause will be treated as the reboot cause - # Else the software_reboot_cause will be treated as the reboot cause - if proc_cmdline_reboot_cause is not None: - previous_reboot_cause = software_reboot_cause - elif hardware_reboot_cause is not REBOOT_CAUSE_NON_HARDWARE: - previous_reboot_cause = hardware_reboot_cause + # If /proc/cmdline does not indicate reboot cause, check if the previous reboot was caused by hardware + if proc_cmdline_reboot_cause is None: + previous_reboot_cause = find_hardware_reboot_cause() + if previous_reboot_cause.startswith(REBOOT_CAUSE_NON_HARDWARE): + # If the reboot cause is non-hardware, get the reboot cause from REBOOT_CAUSE_FILE + previous_reboot_cause = find_software_reboot_cause() else: - previous_reboot_cause = software_reboot_cause + # Get the reboot cause from REBOOT_CAUSE_FILE + previous_reboot_cause = find_software_reboot_cause() # Current time reboot_cause_gen_time = str(datetime.datetime.now().strftime('%Y_%m_%d_%H_%M_%S')) From dd25f774b5d4e5ceda55db1926f33113c18cf87c Mon Sep 17 00:00:00 2001 From: abdosi <58047199+abdosi@users.noreply.github.com> Date: Wed, 6 Jan 2021 00:00:18 -0800 Subject: [PATCH 0019/1674] [rsyslog]: Explicitly set the notify mode for rsyslog imfile module (#6351) Enable the notify mode of rsyslogd imfile module used for supervisord logs in docker container. Setup the mode="inotify" when loading imfile, made sure we are are getting supervisord logs in host immediately. Signed-off-by: Abhishek Dosi --- dockers/docker-base/etc/rsyslog.d/supervisor.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockers/docker-base/etc/rsyslog.d/supervisor.conf b/dockers/docker-base/etc/rsyslog.d/supervisor.conf index ce70f10e6e73..fde8d8a6c994 100644 --- a/dockers/docker-base/etc/rsyslog.d/supervisor.conf +++ b/dockers/docker-base/etc/rsyslog.d/supervisor.conf @@ -1,4 +1,4 @@ -module(load="imfile") #By default notify mode +module(load="imfile" mode="inotify") # Ensure "inotify" mode is used $WorkDirectory /var/log/supervisor # Start Monitoring the file input(type="imfile" From a37aa0850488166c9142ed16735372eaaa542801 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Wed, 6 Jan 2021 06:14:25 -0800 Subject: [PATCH 0020/1674] [sairedis] advance sairedis submodule head (#6365) To incldue following changes: - [ci]: add build for arm64 and armhf (#757) - Use template hgetall, because we will tune the return types of library functions (#759) - [syncd] Fix bulk multi attrs for same key db update (#761) Signed-off-by: Ying Xie --- src/sonic-sairedis | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-sairedis b/src/sonic-sairedis index 754849a476ab..e9401364da28 160000 --- a/src/sonic-sairedis +++ b/src/sonic-sairedis @@ -1 +1 @@ -Subproject commit 754849a476ab64feb163baa23190078a5b1b0586 +Subproject commit e9401364da28259f065b2106fa8590423490f3ea From c6f14c99270918854f1f0d2eb7f85bf59e296fa8 Mon Sep 17 00:00:00 2001 From: Samuel Angebault Date: Sat, 9 Jan 2021 08:05:54 -0800 Subject: [PATCH 0021/1674] [202012][Arista] Update driver submodules (#6397) - Cleanup and Refactor of library internals, logic mostly unchanged. - Enhance debugability with `arista dump` and `arista diag` commands. - Fix power supply detection issue. --- platform/barefoot/sonic-platform-modules-arista | 2 +- platform/broadcom/sonic-platform-modules-arista | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/barefoot/sonic-platform-modules-arista b/platform/barefoot/sonic-platform-modules-arista index adf108419894..937ea8abc1de 160000 --- a/platform/barefoot/sonic-platform-modules-arista +++ b/platform/barefoot/sonic-platform-modules-arista @@ -1 +1 @@ -Subproject commit adf108419894f3b58c0c69722e0be3c72613180e +Subproject commit 937ea8abc1de457b26b7bb7a5208dab6ce40f4a1 diff --git a/platform/broadcom/sonic-platform-modules-arista b/platform/broadcom/sonic-platform-modules-arista index adf108419894..937ea8abc1de 160000 --- a/platform/broadcom/sonic-platform-modules-arista +++ b/platform/broadcom/sonic-platform-modules-arista @@ -1 +1 @@ -Subproject commit adf108419894f3b58c0c69722e0be3c72613180e +Subproject commit 937ea8abc1de457b26b7bb7a5208dab6ce40f4a1 From 7305b55c80c39112724b32e7157b76b68ab69afd Mon Sep 17 00:00:00 2001 From: Aravind Mani <53524901+aravindmani-1@users.noreply.github.com> Date: Thu, 7 Jan 2021 00:42:04 +0530 Subject: [PATCH 0022/1674] DellEMC: Z9332f change SFP detection logic (#6261) - Dynamically change EEPROM driver based on media type. - Otherwise, EEPROM INFO and DOM INFO might not be fetched properly and will result in erroneous output. --- .../z9332f/scripts/z9332f_platform.sh | 2 +- .../z9332f/sonic_platform/sfp.py | 152 ++++++++++++++++-- 2 files changed, 138 insertions(+), 16 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/scripts/z9332f_platform.sh b/platform/broadcom/sonic-platform-modules-dell/z9332f/scripts/z9332f_platform.sh index 91c644f1a6f4..f80207df8ea2 100755 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/scripts/z9332f_platform.sh +++ b/platform/broadcom/sonic-platform-modules-dell/z9332f/scripts/z9332f_platform.sh @@ -58,7 +58,7 @@ switch_board_qsfp() { "new_device") for ((i=10;i<=41;i++)); do - echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-$i/$1 + echo optoe3 0x50 > /sys/bus/i2c/devices/i2c-$i/$1 done ;; diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/sfp.py index ccd1d642640f..7fc50958c9ee 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/sfp.py @@ -1,7 +1,7 @@ #!/usr/bin/env python ############################################################################# -# DELLEMC S5248F +# DELLEMC Z9332F # # Module contains an implementation of SONiC Platform Base API and # provides the platform information @@ -11,6 +11,7 @@ try: import os import time + import subprocess import struct import mmap from sonic_platform_base.sfp_base import SfpBase @@ -157,6 +158,24 @@ 'vendor_date': [SFP_INFO_OFFSET, 84, 8, 'parse_vendor_date'], 'ModuleThreshold': [SFP_DOM_OFFSET, 0, 56, 'parse_alarm_warning_threshold'], } +MEDIA_TYPE_OFFSET = 0 +MEDIA_TYPE_WIDTH = 1 + +SFP_TYPE_LIST = [ + '03' # SFP/SFP+/SFP28 and later +] +QSFP_TYPE_LIST = [ + '0c', # QSFP + '0d', # QSFP+ or later + '11' # QSFP28 or later +] +QSFP_DD_TYPE_LIST = [ + '18' #QSFP-DD Type +] +OSFP_TYPE_LIST=[ + '19' # OSFP 8X Type +] + class Sfp(SfpBase): @@ -164,12 +183,51 @@ class Sfp(SfpBase): DELLEMC Platform-specific Sfp class """ BASE_RES_PATH = "/sys/bus/pci/devices/0000:09:00.0/resource0" + _port_to_i2c_mapping = { + 1: 10, + 2: 11, + 3: 12, + 4: 13, + 5: 14, + 6: 15, + 7: 16, + 8: 17, + 9: 18, + 10: 19, + 11: 20, + 12: 21, + 13: 22, + 14: 23, + 15: 24, + 16: 25, + 17: 26, + 18: 27, + 19: 28, + 20: 29, + 21: 30, + 22: 31, + 23: 32, + 24: 33, + 25: 34, + 26: 35, + 27: 36, + 28: 37, + 29: 38, + 30: 39, + 31: 40, + 32: 41, + 33: 1, + 34: 2 + } def __init__(self, index, sfp_type, eeprom_path): SfpBase.__init__(self) - self.sfp_type = sfp_type self.index = index self.eeprom_path = eeprom_path + #sfp_type is the native port type and media_type is the transceiver type + #media_type will be detected in get_transceiver_info + self.sfp_type = sfp_type + self.media_type = self.sfp_type self.qsfpInfo = sff8436InterfaceId() self.qsfpDomInfo = sff8436Dom() self.sfpInfo = sff8472InterfaceId() @@ -238,7 +296,7 @@ def _get_eeprom_data(self, eeprom_key): eeprom_data = None page_offset = None - if(self.sfp_type == 'QSFP'): + if(self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): page_offset = sff8436_parser[eeprom_key][PAGE_OFFSET] eeprom_data_raw = self._read_eeprom_bytes( self.eeprom_path, @@ -292,6 +350,9 @@ def get_transceiver_info(self): transceiver_info_dict = {} compliance_code_dict = {} transceiver_info_dict = dict.fromkeys(info_dict_keys, 'N/A') + self.media_type = self.set_media_type() + self.reinit_sfp_driver() + # BaseInformation try: iface_data = self._get_eeprom_data('type') @@ -301,7 +362,7 @@ def get_transceiver_info(self): rate_identifier = iface_data['data']['RateIdentifier']['value'] identifier = iface_data['data']['type']['value'] type_abbrv_name=iface_data['data']['type_abbrv_name']['value'] - if(self.sfp_type == 'QSFP'): + if(self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): bit_rate = str( iface_data['data']['Nominal Bit Rate(100Mbs)']['value']) for key in qsfp_compliance_code_tup: @@ -398,7 +459,7 @@ def get_transceiver_threshold_info(self): try: # Module Threshold module_threshold_data = self._get_eeprom_data('ModuleThreshold') - if (self.sfp_type == 'QSFP'): + if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): transceiver_dom_threshold_dict['temphighalarm'] = module_threshold_data['data']['TempHighAlarm']['value'] transceiver_dom_threshold_dict['temphighwarning'] = module_threshold_data['data']['TempHighWarning']['value'] transceiver_dom_threshold_dict['templowalarm'] = module_threshold_data['data']['TempLowAlarm']['value'] @@ -431,7 +492,7 @@ def get_transceiver_threshold_info(self): except (ValueError, TypeError) : pass try: - if (self.sfp_type == 'QSFP'): + if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): channel_threshold_data = self._get_eeprom_data('ChannelThreshold') transceiver_dom_threshold_dict['rxpowerhighalarm'] = channel_threshold_data['data']['RxPowerHighAlarm']['value'] transceiver_dom_threshold_dict['rxpowerhighwarning'] = channel_threshold_data['data']['RxPowerHighWarning']['value'] @@ -598,7 +659,7 @@ def get_rx_los(self): """ rx_los = False try: - if (self.sfp_type == 'QSFP'): + if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): rx_los_data = self._get_eeprom_data('rx_los') # As the function expects a single boolean, if any one channel experience LOS, # is considered LOS for QSFP @@ -618,7 +679,7 @@ def get_tx_fault(self): """ tx_fault = False try: - if (self.sfp_type == 'QSFP'): + if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): tx_fault_data = self._get_eeprom_data('tx_fault') for tx_fault_id in ('Tx1Fault', 'Tx2Fault', 'Tx3Fault', 'Tx4Fault') : tx_fault |= (tx_fault_data['data'][tx_fault_id]['value'] is 'On') @@ -636,7 +697,7 @@ def get_tx_disable(self): """ tx_disable = False try: - if (self.sfp_type == 'QSFP'): + if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): tx_disable_data = self._get_eeprom_data('tx_disable') for tx_disable_id in ('Tx1Disable', 'Tx2Disable', 'Tx3Disable', 'Tx4Disable'): tx_disable |= (tx_disable_data['data'][tx_disable_id]['value'] is 'On') @@ -656,7 +717,7 @@ def get_tx_disable_channel(self): """ tx_disable_channel = 0 try: - if (self.sfp_type == 'QSFP'): + if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): tx_disable_data = self._get_eeprom_data('tx_disable') for tx_disable_id in ('Tx1Disable', 'Tx2Disable', 'Tx3Disable', 'Tx4Disable'): tx_disable_channel <<= 1 @@ -671,7 +732,7 @@ def get_lpmode(self): """ lpmode_state = False try: - if (self.sfp_type == 'QSFP'): + if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): # Port offset starts with 0x4000 port_offset = 16384 + ((self.index-1) * 16) @@ -692,7 +753,7 @@ def get_power_override(self): power_override_state = False try: - if (self.sfp_type == 'QSFP'): + if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): power_override_data = self._get_eeprom_data('power_override') power_override = power_override_data['data']['PowerOverRide']['value'] power_override_state = (power_override is 'On') @@ -730,7 +791,7 @@ def get_tx_bias(self): tx_bias_list = [] try: tx_bias_data = self._get_eeprom_data('ChannelMonitor') - if (self.sfp_type == 'QSFP'): + if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): for tx_bias_id in ('TX1Bias', 'TX2Bias', 'TX3Bias', 'TX4Bias') : tx_bias = tx_bias_data['data'][tx_bias_id]['value'] tx_bias_list.append(tx_bias) @@ -748,7 +809,7 @@ def get_rx_power(self): rx_power_list = [] try: rx_power_data = self._get_eeprom_data('ChannelMonitor') - if (self.sfp_type == 'QSFP'): + if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): for rx_power_id in ('RX1Power', 'RX2Power', 'RX3Power', 'RX4Power'): rx_power = rx_power_data['data'][rx_power_id]['value'] rx_power_list.append(rx_power) @@ -765,7 +826,7 @@ def get_tx_power(self): """ tx_power_list = [] try: - if(self.sfp_type == 'QSFP'): + if(self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): # 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 @@ -895,6 +956,12 @@ def get_status(self): reset = self.get_reset_status() return (not reset) + def get_port_form_factor(self): + """ + Retrieves the native port type + """ + return self.sfp_type + def get_max_port_power(self): """ Retrieves the maximum power allowed on the port in watts @@ -906,3 +973,58 @@ def get_max_port_power(self): """ return (12.0 if self.sfp_type=='QSFP' else 2.5) + def set_media_type(self): + """ + Reads optic eeprom byte to determine media type inserted + """ + eeprom_raw = [] + eeprom_raw = self._read_eeprom_bytes(self.eeprom_path, MEDIA_TYPE_OFFSET, MEDIA_TYPE_WIDTH) + if eeprom_raw is not None: + if eeprom_raw[0] in SFP_TYPE_LIST: + self.media_type = 'SFP' + elif eeprom_raw[0] in QSFP_TYPE_LIST: + self.media_type = 'QSFP' + elif eeprom_raw[0] in QSFP_DD_TYPE_LIST: + self.media_type = 'QSFP-DD' + else: + #Set native port type if EEPROM type is not recognized/readable + self.media_type = self.sfp_type + else: + self.media_type = self.sfp_type + + return self.media_type + + def reinit_sfp_driver(self): + """ + Changes the driver based on media type detected + """ + del_sfp_path = "/sys/class/i2c-adapter/i2c-{0}/delete_device".format(self._port_to_i2c_mapping[self.index]) + new_sfp_path = "/sys/class/i2c-adapter/i2c-{0}/new_device".format(self._port_to_i2c_mapping[self.index]) + driver_path = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/name".format(self._port_to_i2c_mapping[self.index]) + delete_device = "echo 0x50 >" + del_sfp_path + + try: + with os.fdopen(os.open(driver_path, os.O_RDONLY)) as fd: + driver_name = fd.read() + driver_name = driver_name.rstrip('\r\n') + driver_name = driver_name.lstrip(" ") + + #Avoid re-initialization of the QSFP/SFP optic on QSFP/SFP port. + if (self.media_type == 'SFP' and (driver_name == 'optoe1' or driver_name == 'optoe3')): + subprocess.Popen(delete_device, shell=True, stdout=subprocess.PIPE) + new_device = "echo optoe2 0x50 >" + new_sfp_path + subprocess.Popen(new_device, shell=True, stdout=subprocess.PIPE) + time.sleep(2) + elif (self.media_type == 'QSFP' and (driver_name == 'optoe2' or driver_name == 'optoe3')): + subprocess.Popen(delete_device, shell=True, stdout=subprocess.PIPE) + new_device = "echo optoe1 0x50 >" + new_sfp_path + subprocess.Popen(new_device, shell=True, stdout=subprocess.PIPE) + time.sleep(2) + elif (self.media_type == 'QSFP-DD' and (driver_name == 'optoe1' or driver_name == 'optoe2')): + subprocess.Popen(delete_device, shell=True, stdout=subprocess.PIPE) + new_device = "echo optoe3 0x50 >" + new_sfp_path + subprocess.Popen(new_device, shell=True, stdout=subprocess.PIPE) + time.sleep(2) + + except IOError as e: + print("Error: Unable to open file: %s" % str(e)) From c111a68e743e5305c7299e01502a9c2cc07492e5 Mon Sep 17 00:00:00 2001 From: sudhanshukumar22 <51457531+sudhanshukumar22@users.noreply.github.com> Date: Thu, 7 Jan 2021 01:54:57 +0530 Subject: [PATCH 0023/1674] [docker-lldp]: sonic advertise meaningful SysDescription instead of debian (#6114) Sonic devices advertise meaningful system description along with Debian package information. before the fix: ------------- admin@sonic:~$ show lldp neighbors ------------------------------------------------------------------------------- LLDP neighbors: ------------------------------------------------------------------------------- Interface: Ethernet0, via: LLDP, RID: 3, Time: 0 day, 16:36:30 SysName: sonic SysDescr: Debian GNU/Linux 9 (stretch) Linux 4.9.0-11-2-amd64 #1 SMP Debian 4.9.189-3+deb9u2 (2019-11-11) x86_64 ------------------------------------------------------------------------------- After the fix: root@sonic:~# show lldp neighbors Ethernet16 ------------------------------------------------------------------------------- LLDP neighbors: ------------------------------------------------------------------------------- Interface: Ethernet16, via: LLDP, RID: 10, Time: 0 day, 00:01:00 SysName: sonic SysDescr: SONiC Software Version: SONiC.sonic_upstream_1.0_daily_201130_1501_62-dirty-20201130.203529 - HwSku: Accton-AS7816-64X - Distribution: Debian 10.6 - Kernel: 4.19.0-9-2-amd64 ------------------------------------------------------------------------------- Signed-off-by: sudhanshukumar22 --- dockers/docker-lldp/Dockerfile.j2 | 1 + dockers/docker-lldp/lldpdSysDescr.conf.j2 | 1 + dockers/docker-lldp/start.sh | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 dockers/docker-lldp/lldpdSysDescr.conf.j2 diff --git a/dockers/docker-lldp/Dockerfile.j2 b/dockers/docker-lldp/Dockerfile.j2 index 297f7766519b..a1c7a1c1bee2 100644 --- a/dockers/docker-lldp/Dockerfile.j2 +++ b/dockers/docker-lldp/Dockerfile.j2 @@ -43,6 +43,7 @@ COPY ["start.sh", "/usr/bin/"] COPY ["waitfor_lldp_ready.sh", "/usr/bin/"] COPY ["supervisord.conf.j2", "/usr/share/sonic/templates/"] COPY ["lldpd.conf.j2", "/usr/share/sonic/templates/"] +COPY ["lldpdSysDescr.conf.j2", "/usr/share/sonic/templates/"] COPY ["lldpd", "/etc/default/"] COPY ["lldpmgrd", "/usr/bin/"] COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] diff --git a/dockers/docker-lldp/lldpdSysDescr.conf.j2 b/dockers/docker-lldp/lldpdSysDescr.conf.j2 new file mode 100644 index 000000000000..047b3c68b34f --- /dev/null +++ b/dockers/docker-lldp/lldpdSysDescr.conf.j2 @@ -0,0 +1 @@ +configure system description "SONiC Software Version: SONiC.{{ build_version }} - HwSku: {{ DEVICE_METADATA['localhost']['hwsku'] }} - Distribution: Debian {{ debian_version }} - Kernel: {{ kernel_version }}" diff --git a/dockers/docker-lldp/start.sh b/dockers/docker-lldp/start.sh index b2c82d6d0437..5a489884aea9 100755 --- a/dockers/docker-lldp/start.sh +++ b/dockers/docker-lldp/start.sh @@ -1,4 +1,10 @@ #!/usr/bin/env bash +CFGGEN_PARAMS=" \ + -d \ + -t /usr/share/sonic/templates/lldpd.conf.j2 \ + -y /etc/sonic/sonic_version.yml \ + -t /usr/share/sonic/templates/lldpdSysDescr.conf.j2 \ +" if [ "${RUNTIME_OWNER}" == "" ]; then RUNTIME_OWNER="kube" @@ -10,7 +16,7 @@ then ${CTR_SCRIPT} -f lldp -o ${RUNTIME_OWNER} -v ${IMAGE_VERSION} fi -sonic-cfggen -d -t /usr/share/sonic/templates/lldpd.conf.j2 > /etc/lldpd.conf +sonic-cfggen $CFGGEN_PARAMS > /etc/lldpd.conf mkdir -p /var/sonic echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status From 0182c5f5ca1b5f24aa50cc8903b32c9954e44b33 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Wed, 6 Jan 2021 14:47:30 -0800 Subject: [PATCH 0024/1674] [sonic-platform-common][sonic-platform-daemons] Update submodules (#6352) src/sonic-platform-common 9935fca...8664efc (2): Make sonic_sfp Python2 and Python3 compatible (#157) [sffbase.py] Fix to make Python 3-compatible (#156) src/sonic-platform-daemons e6c786b...81318f7 (1): [psud] Fix issue where PSU Fan info is not updated in State DB (#137) Fixes #6341 --- src/sonic-platform-common | 2 +- src/sonic-platform-daemons | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sonic-platform-common b/src/sonic-platform-common index 9935fca570a0..8664efc5472a 160000 --- a/src/sonic-platform-common +++ b/src/sonic-platform-common @@ -1 +1 @@ -Subproject commit 9935fca570a0c99be326049a9d671a2c218ae8e5 +Subproject commit 8664efc5472ae8cab04ad5a3499baa9a9c0d7f89 diff --git a/src/sonic-platform-daemons b/src/sonic-platform-daemons index e6c786bd02e6..81318f7afdb6 160000 --- a/src/sonic-platform-daemons +++ b/src/sonic-platform-daemons @@ -1 +1 @@ -Subproject commit e6c786bd02e6a253fcf67dec895e7c24e940c788 +Subproject commit 81318f7afdb65bd15af387c97152948d22cf9834 From 941c27ce2ae75df54b5d7e38c7a33f00ac900f9f Mon Sep 17 00:00:00 2001 From: carl-nokia <63672637+carl-nokia@users.noreply.github.com> Date: Wed, 6 Jan 2021 18:09:13 -0500 Subject: [PATCH 0025/1674] [Nokia]: Enable Telemetry for armhf and provide required qos files (#6364) * [platform][Nokia]: Add buffers and qos files for config qos reload - providing required files * [platform][armhf]: remove hardcoded disable for Telemetry on armhf Co-authored-by: Carl Keene --- .../armhf-nokia_ixs7215_52x-r0/Nokia-7215/buffers.json.j2 | 8 ++++++++ .../armhf-nokia_ixs7215_52x-r0/Nokia-7215/qos.json.j2 | 1 + platform/marvell-armhf/rules.mk | 1 - slave.mk | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 device/nokia/armhf-nokia_ixs7215_52x-r0/Nokia-7215/buffers.json.j2 create mode 100644 device/nokia/armhf-nokia_ixs7215_52x-r0/Nokia-7215/qos.json.j2 diff --git a/device/nokia/armhf-nokia_ixs7215_52x-r0/Nokia-7215/buffers.json.j2 b/device/nokia/armhf-nokia_ixs7215_52x-r0/Nokia-7215/buffers.json.j2 new file mode 100644 index 000000000000..9495a66c0d07 --- /dev/null +++ b/device/nokia/armhf-nokia_ixs7215_52x-r0/Nokia-7215/buffers.json.j2 @@ -0,0 +1,8 @@ +{# Default values placeholder M0- Marvell SAI TBD buffers configuration #} + +{% 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 #} diff --git a/device/nokia/armhf-nokia_ixs7215_52x-r0/Nokia-7215/qos.json.j2 b/device/nokia/armhf-nokia_ixs7215_52x-r0/Nokia-7215/qos.json.j2 new file mode 100644 index 000000000000..529f1be8a545 --- /dev/null +++ b/device/nokia/armhf-nokia_ixs7215_52x-r0/Nokia-7215/qos.json.j2 @@ -0,0 +1 @@ +# this file empty temporarily until qos supported SAI Marvell diff --git a/platform/marvell-armhf/rules.mk b/platform/marvell-armhf/rules.mk index e53f9531b82b..27d3167edd03 100644 --- a/platform/marvell-armhf/rules.mk +++ b/platform/marvell-armhf/rules.mk @@ -10,7 +10,6 @@ include $(PLATFORM_PATH)/linux-kernel-armhf.mk include $(PLATFORM_PATH)/platform-et6448m.mk include $(PLATFORM_PATH)/platform-nokia.mk -INCLUDE_SYSTEM_TELEMETRY = "" ENABLE_SYNCD_RPC = "" INCLUDE_MGMT_FRAMEWORK = "" diff --git a/slave.mk b/slave.mk index 18e70542f83e..686ecec5c508 100644 --- a/slave.mk +++ b/slave.mk @@ -116,7 +116,7 @@ ifeq ($(SONIC_INCLUDE_SYSTEM_TELEMETRY),y) INCLUDE_SYSTEM_TELEMETRY = y endif -ifneq (,$(filter $(CONFIGURED_ARCH), armhf arm64)) +ifneq (,$(filter $(CONFIGURED_ARCH), arm64)) # Workaround: Force disable Telmetry for ARM, will be removed after fixing issue # Issue: qemu crashes when it uses "go get url" # Qemu Support: https://bugs.launchpad.net/qemu/+bug/1838946 From be82cdbad5e37d65a38e737c4c2a6ccd371a21c0 Mon Sep 17 00:00:00 2001 From: abdosi <58047199+abdosi@users.noreply.github.com> Date: Wed, 6 Jan 2021 18:47:36 -0800 Subject: [PATCH 0026/1674] Updated imfile configuration for supervisord logs (#6368) Updated imfile configuration for supervisord logs for stretch and buster. --- .../etc/rsyslog.d/supervisor.conf | 18 +++++++++--------- .../etc/rsyslog.d/supervisor.conf | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/dockers/docker-base-buster/etc/rsyslog.d/supervisor.conf b/dockers/docker-base-buster/etc/rsyslog.d/supervisor.conf index 7c7a64d7afe0..fde8d8a6c994 100644 --- a/dockers/docker-base-buster/etc/rsyslog.d/supervisor.conf +++ b/dockers/docker-base-buster/etc/rsyslog.d/supervisor.conf @@ -1,9 +1,9 @@ -$ModLoad imfile - -$InputFileName /var/log/supervisor/supervisord.log -$InputFileTag supervisord -$InputFileStateFile state-supervisor -$InputFileSeverity info -$InputFileFacility local0 -$InputFilePersistStateInterval 1 -$InputRunFileMonitor +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-stretch/etc/rsyslog.d/supervisor.conf b/dockers/docker-base-stretch/etc/rsyslog.d/supervisor.conf index 7c7a64d7afe0..fde8d8a6c994 100644 --- a/dockers/docker-base-stretch/etc/rsyslog.d/supervisor.conf +++ b/dockers/docker-base-stretch/etc/rsyslog.d/supervisor.conf @@ -1,9 +1,9 @@ -$ModLoad imfile - -$InputFileName /var/log/supervisor/supervisord.log -$InputFileTag supervisord -$InputFileStateFile state-supervisor -$InputFileSeverity info -$InputFileFacility local0 -$InputFilePersistStateInterval 1 -$InputRunFileMonitor +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") From 7462850ba44315a4e80145ab0091943ef4f9138e Mon Sep 17 00:00:00 2001 From: gechiang <62408185+gechiang@users.noreply.github.com> Date: Thu, 7 Jan 2021 05:46:48 -0800 Subject: [PATCH 0027/1674] [brcm]: BRCM SAI 4.2.1.5-9 Fix _brcm_sai_indexed_data_get () with unexpected queue causing _brcm_sai_switch_assert () after warm reboot (#6374) Starting from build (master) 176 the warm reboot on BRCM Platform started to experience syncd crash. Upon further debug by Ying it was determined that the crash was related to the following new change: [Dynamic buffer calc] Support dynamic buffer calculation (#1338) Ying also debugged further and found The crash was caused by buffer pool profile setting operation SAI_BUFFER_PROFILE_ATTR_SHARED_DYNAMIC_TH A case has filed with BRCM while a potential fix was tried by Ying that seems to have addressed this issue and we are making this change available in master branch so that it will allow further feature validation/testing especially in the warm reboot area. Once an official fix is provided by BRCM, we will then remove this in house fix and apply the official fix. - How to verify it Just perform warm reboot with any master code 175 or above you should see this issue or issue the following cmd will also cause the crash: "mmuconfig -p egress_lossy_profile -a 0" --- platform/broadcom/sai.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index cdd42ff4ed5a..24cf07122e6b 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,8 +1,8 @@ -BRCM_SAI = libsaibcm_4.2.1.5-7_amd64.deb -$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.2/master/buster/libsaibcm_4.2.1.5-8_amd64.deb?sv=2019-12-12&st=2020-12-18T18%3A41%3A23Z&se=2030-12-19T18%3A41%3A00Z&sr=b&sp=r&sig=GFNMn0borytUTFQJf%2F5A0J452XsQ%2FqnzBw5GyjFuYHw%3D" -BRCM_SAI_DEV = libsaibcm-dev_4.2.1.5-7_amd64.deb +BRCM_SAI = libsaibcm_4.2.1.5-9_amd64.deb +$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.2/master/buster/libsaibcm_4.2.1.5-9_amd64.deb?sv=2015-04-05&sr=b&sig=Rbqq%2FH4B71%2BWGzAzTuM3qxEdwpEnuxqFdGIMDpuN8t0%3D&se=2034-09-16T01%3A36%3A13Z&sp=r" +BRCM_SAI_DEV = libsaibcm-dev_4.2.1.5-9_amd64.deb $(eval $(call add_derived_package,$(BRCM_SAI),$(BRCM_SAI_DEV))) -$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.2/master/buster/libsaibcm-dev_4.2.1.5-8_amd64.deb?sv=2019-12-12&st=2020-12-18T18%3A42%3A03Z&se=2030-12-19T18%3A42%3A00Z&sr=b&sp=r&sig=J%2BbRtZVVcZTLs3uqzZs9zObLKFxRgzvJkFL5iyJ48mA%3D" +$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.2/master/buster/libsaibcm-dev_4.2.1.5-9_amd64.deb?sv=2015-04-05&sr=b&sig=C%2Bo7YTkA2076LRfet1rHHlFu%2F6b9qoQiHljjaZCVa20%3D&se=2034-09-16T01%3A37%3A38Z&sp=r" SONIC_ONLINE_DEBS += $(BRCM_SAI) $(BRCM_SAI_DEV)_DEPENDS += $(BRCM_SAI) From 984c833e4cd07fd4e99726cffd2b3228c15a99de Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 7 Jan 2021 05:48:13 -0800 Subject: [PATCH 0028/1674] [system-health] Make `run_command()` Python 3-compliant (#6371) Pass universal_newlines=True parameter to subprocess.Popen(); no longer use .encode('utf-8') on resulting stdout. This was missed in #5886 Note: I would prefer to use text=True instead of universal_newlines=True, as the former is an alias only available in Python 3 and is more understandable than the latter. However, Even though the setup.py file for this package only specifies Python 3, the LGTM tool finds other Python 2 code in the repo and validates the code as Python 2 code and alerts that text=True is an invalid parameter. Will stick with universal_newlines=True for now. Once all Python code in the repo has been converted to Python 3, I will change all universal_newlines=True to text=True. --- src/system-health/health_checker/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/system-health/health_checker/utils.py b/src/system-health/health_checker/utils.py index fe26054e420d..f310002e1e5f 100644 --- a/src/system-health/health_checker/utils.py +++ b/src/system-health/health_checker/utils.py @@ -8,8 +8,8 @@ def run_command(command): :return: Output of the shell command. """ try: - process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) - return process.communicate()[0].encode('utf-8') + process = subprocess.Popen(command, shell=True, universal_newlines=True, stdout=subprocess.PIPE) + return process.communicate()[0] except Exception: return None From 1bdefd16facd142d1a50a6e0e68a418d1567668d Mon Sep 17 00:00:00 2001 From: Renuka Manavalan <47282725+renukamanavalan@users.noreply.github.com> Date: Thu, 7 Jan 2021 16:45:38 -0800 Subject: [PATCH 0029/1674] Take a copy of existing TACACS credentials and restore it during upgrade (#6285) In scenario where upgrade gets config from minigraph, it could miss tacacs credentials as they are not in minigraph. Hence restore explicitly upon load-minigraph, if present. - Why I did it Upon boot, when config migration is required, the switch could load config from minigraph. The config-load from minigraph would wipe off TACACS key and disable login via TACACS, which would disable all remote user access. This change, would re-configure the TACACS if there is a saved copy available. - How I did it When config is loaded from minigraph, look for a TACACS credentials back up (tacacs.json) under /etc/sonic/old_config. If present, load the credentials into running config, before config-save is called. - How to verify it Remove /etc/sonic/config_db.json and do an image update. Upon reboot, w/o this change, you would not be able ssh in as remote user. You may login as admin and check out, "show tacacs" & "show aaa" to verify that tacacs-key is missing and login is not enabled for tacacs. With this change applied, remove /etc/sonic/config_db.json, but save tacacs & aaa credentials as tacacs.json in /etc/sonic/. Upon reboot, you should see remote user access possible. --- files/image_config/config-setup/config-setup | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/files/image_config/config-setup/config-setup b/files/image_config/config-setup/config-setup index 4ed841cd3cdc..9bb7b33b6be6 100755 --- a/files/image_config/config-setup/config-setup +++ b/files/image_config/config-setup/config-setup @@ -41,6 +41,8 @@ CONFIG_SETUP_PRE_MIGRATION_FLAG=${CONFIG_SETUP_VAR_DIR}/pending_pre_migration CONFIG_SETUP_POST_MIGRATION_FLAG=${CONFIG_SETUP_VAR_DIR}/pending_post_migration CONFIG_SETUP_INITIALIZATION_FLAG=${CONFIG_SETUP_VAR_DIR}/pending_initialization +TACACS_JSON_BACKUP=tacacs.json + # Command usage and help usage() { @@ -108,6 +110,11 @@ reload_minigraph() { echo "Reloading minigraph..." config load_minigraph -y -n + if [ -r /etc/sonic/old_config/${TACACS_JSON_BACKUP} ]; then + sonic-cfggen -j /etc/sonic/old_config/${TACACS_JSON_BACKUP} --write-to-db + else + echo "Missing tacacs json to restore tacacs credentials" + fi config save -y } From bfec282a82f94df1b0d368d873ec7e800569c069 Mon Sep 17 00:00:00 2001 From: yozhao101 <56170650+yozhao101@users.noreply.github.com> Date: Thu, 7 Jan 2021 19:52:22 -0800 Subject: [PATCH 0030/1674] [Monit] Monitoring the running status of containers. (#6251) **- Why I did it** This PR aims to monitor the running status of each container. Currently the auto-restart feature was enabled. If a critical process exited unexpected, the container will be restarted. If the container was restarted 3 times during 20 minutes, then it will not run anymore unless we cleared the flag using the command `sudo systemctl reset-failed ` manually. **- How I did it** We will employ Monit to monitor a script. This script will generate the expected running container list and compare it with the current running containers. If there are containers which were expected to run but were not running, then an alerting message will be written into syslog. **- How to verify it** I tested this feature on a lab device `str-a7050-acs-3` which has single ASIC and `str2-n3164-acs-3` which has a Multi-ASIC. First I manually stopped a container by running the command `sudo systemctl stop `, then I checked whether there was an alerting message in the syslog. Signed-off-by: Yong Zhao --- .../build_templates/sonic_debian_extension.j2 | 3 + files/image_config/monit/conf.d/sonic-host | 2 + files/image_config/monit/container_checker | 116 ++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100755 files/image_config/monit/container_checker diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index a301bee59ebd..b1955919149e 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -300,6 +300,9 @@ sudo cp $IMAGE_CONFIGS/monit/conf.d/* $FILESYSTEM_ROOT/etc/monit/conf.d/ sudo chmod 600 $FILESYSTEM_ROOT/etc/monit/conf.d/* sudo cp $IMAGE_CONFIGS/monit/process_checker $FILESYSTEM_ROOT/usr/bin/ sudo chmod 755 $FILESYSTEM_ROOT/usr/bin/process_checker +sudo cp $IMAGE_CONFIGS/monit/container_checker $FILESYSTEM_ROOT/usr/bin/ +sudo chmod 755 $FILESYSTEM_ROOT/usr/bin/container_checker + # Install custom-built openssh sshd sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/openssh-server_*.deb diff --git a/files/image_config/monit/conf.d/sonic-host b/files/image_config/monit/conf.d/sonic-host index 202c49f8d7b2..17d7c64af7e2 100644 --- a/files/image_config/monit/conf.d/sonic-host +++ b/files/image_config/monit/conf.d/sonic-host @@ -31,3 +31,5 @@ check program routeCheck with path "/usr/local/bin/route_check.py" every 5 cycles if status != 0 for 3 cycle then alert repeat every 1 cycles +check program container_checker with path "/usr/bin/container_checker" + if status != 0 for 5 times within 5 cycles then alert repeat every 1 cycles diff --git a/files/image_config/monit/container_checker b/files/image_config/monit/container_checker new file mode 100755 index 000000000000..abfbb34430bb --- /dev/null +++ b/files/image_config/monit/container_checker @@ -0,0 +1,116 @@ +#!/usr/bin/env python3 + +""" +container_checker + +This script is intended to be run by Monit. It will write an alerting message into +syslog if it found containers which were expected to run but were not running. At +the same time, if some containers were unexpected to run, it also writes an alerting +syslog message. Note that if print(...) statement in this script was executed, the +string in it will be appended to Monit syslog messages. + +The following is an example in Monit configuration file to show how Monit will run +this script: + +check program container_checker with path "/usr/bin/container_checker" + if status != 0 for 5 times within 5 cycles then alert repeat every 1 cycles +""" + +import subprocess +import sys + +import swsssdk +from sonic_py_common import multi_asic + + +def get_command_result(command): + """ + @summary: This function will execute the command and return the resulting output. + @return: A string which contains the output of command. + """ + command_stdout = "" + + try: + proc_instance = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, + shell=True, universal_newlines=True) + command_stdout, command_stderr = proc_instance.communicate() + if proc_instance.returncode != 0: + print("Failed to execute the command '{}'. Return code: '{}'".format( + command, proc_instance.returncode)) + sys.exit(1) + except (OSError, ValueError) as err: + print("Failed to execute the command '{}'. Error: '{}'".format(command, err)) + sys.exit(2) + + return command_stdout.rstrip().split("\n") + + +def get_expected_running_containers(): + """ + @summary: This function will get the expected running containers by following the rule: + The 'state' field of container in 'FEATURE' table should not be 'disabled'. Then + if the device has Multi-ASIC, this function will get container list by determining the + value of field 'has_global_scope', the number of ASICs and the value of field + 'has_per_asic_scope'. If the device has single ASIC, the container name was put into + the list. + @return: A set which contains the expected running containers. + """ + config_db = swsssdk.ConfigDBConnector() + config_db.connect() + feature_table = config_db.get_table("FEATURE") + + expected_running_containers = set() + + for container_name in feature_table.keys(): + if feature_table[container_name]["state"] != "disabled": + if multi_asic.is_multi_asic(): + if feature_table[container_name]["has_global_scope"] == "True": + expected_running_containers.add(container_name) + if feature_table[container_name]["has_per_asic_scope"] == "True": + num_asics = multi_asic.get_num_asics() + for asic_id in range(num_asics): + expected_running_containers.add(container_name + str(asic_id)) + else: + expected_running_containers.add(container_name) + + return expected_running_containers + + +def get_current_running_containers(): + """ + @summary: This function will get the current running container list by analyzing the + output of command `docker ps`. + @return: A set which contains the current running contianers. + """ + running_containers = set() + + command = "docker ps" + command_stdout = get_command_result(command) + for line in command_stdout[1:]: + running_containers.add(line.split()[-1].strip()) + + return running_containers + + +def main(): + """ + @summary: This function will compare the difference between the current running containers + and the containers which were expected to run. If containers which were exepcted + to run were not running, then an alerting message will be written into syslog. + """ + expected_running_containers = get_expected_running_containers() + current_running_containers = get_current_running_containers() + + not_running_containers = expected_running_containers.difference(current_running_containers) + if not_running_containers: + print("Expected containers not running: " + ", ".join(not_running_containers)) + sys.exit(3) + + unexpected_running_containers = current_running_containers.difference(expected_running_containers) + if unexpected_running_containers: + print("Unexpected running containers: " + ", ".join(unexpected_running_containers)) + sys.exit(4) + + +if __name__ == "__main__": + main() From 03391f20c51f05a1af2292fd3ca24ce574a229d0 Mon Sep 17 00:00:00 2001 From: pavel-shirshov Date: Fri, 8 Jan 2021 14:03:26 -0800 Subject: [PATCH 0031/1674] [bgpcfgd]: Support default action for "Allow prefix" feature (#6370) * Use 20 and 30 route-map entries instead of 2 and 3 for TSA * Added support for dynamic "Allow list" default action. Co-authored-by: Pavel Shirshov --- dockers/docker-fpm-frr/TSA | 4 +- dockers/docker-fpm-frr/TSB | 4 +- dockers/docker-fpm-frr/TSC | 8 +- .../bgpd/templates/general/policies.conf.j2 | 25 ++- .../frr/bgpd/tsa/bgpd.tsa.isolate.conf.j2 | 4 +- .../frr/bgpd/tsa/bgpd.tsa.unisolate.conf.j2 | 4 +- .../bgpcfgd/managers_allow_list.py | 82 +++++++++- .../data/general/policies.conf/param_all.json | 4 +- .../general/policies.conf/param_deny.json | 4 +- .../general/policies.conf/result_all.conf | 17 +- .../general/policies.conf/result_deny.conf | 17 +- .../tests/data/sonic-cfggen/tsa/isolate.conf | 4 +- .../data/sonic-cfggen/tsa/unisolate.conf | 4 +- src/sonic-bgpcfgd/tests/test_allow_list.py | 146 +++++++++++++++++- 14 files changed, 291 insertions(+), 36 deletions(-) diff --git a/dockers/docker-fpm-frr/TSA b/dockers/docker-fpm-frr/TSA index dc96d32c4582..81816b99db40 100755 --- a/dockers/docker-fpm-frr/TSA +++ b/dockers/docker-fpm-frr/TSA @@ -6,9 +6,9 @@ function check_not_installed() config=$(vtysh -c "show run") for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p'); do - echo "$config" | grep -q "route-map $route_map_name permit 2" + echo "$config" | grep -q "route-map $route_map_name permit 20" c=$((c+$?)) - echo "$config" | grep -q "route-map $route_map_name deny 3" + echo "$config" | grep -q "route-map $route_map_name deny 30" c=$((c+$?)) done return $c diff --git a/dockers/docker-fpm-frr/TSB b/dockers/docker-fpm-frr/TSB index 68eee9c2faff..b7eac390cf46 100755 --- a/dockers/docker-fpm-frr/TSB +++ b/dockers/docker-fpm-frr/TSB @@ -7,10 +7,10 @@ function check_installed() config=$(vtysh -c "show run") for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p'); do - echo "$config" | grep -q "route-map $route_map_name permit 2" + echo "$config" | grep -q "route-map $route_map_name permit 20" c=$((c+$?)) e=$((e+1)) - echo "$config" | grep -q "route-map $route_map_name deny 3" + echo "$config" | grep -q "route-map $route_map_name deny 30" c=$((c+$?)) e=$((e+1)) done diff --git a/dockers/docker-fpm-frr/TSC b/dockers/docker-fpm-frr/TSC index 8c17cea7eea7..5e7d579fc4a2 100755 --- a/dockers/docker-fpm-frr/TSC +++ b/dockers/docker-fpm-frr/TSC @@ -6,9 +6,9 @@ function check_not_installed() config=$(vtysh -c "show run") for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6'); do - echo "$config" | grep -q "route-map $route_map_name permit 2" + echo "$config" | grep -q "route-map $route_map_name permit 20" c=$((c+$?)) - echo "$config" | grep -q "route-map $route_map_name deny 3" + echo "$config" | grep -q "route-map $route_map_name deny 30" c=$((c+$?)) done return $c @@ -21,10 +21,10 @@ function check_installed() config=$(vtysh -c "show run") for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6'); do - echo "$config" | grep -q "route-map $route_map_name permit 2" + echo "$config" | grep -q "route-map $route_map_name permit 20" c=$((c+$?)) e=$((e+1)) - echo "$config" | grep -q "route-map $route_map_name deny 3" + echo "$config" | grep -q "route-map $route_map_name deny 30" c=$((c+$?)) e=$((e+1)) done diff --git a/dockers/docker-fpm-frr/frr/bgpd/templates/general/policies.conf.j2 b/dockers/docker-fpm-frr/frr/bgpd/templates/general/policies.conf.j2 index 29498adcd922..7cf5e148f694 100644 --- a/dockers/docker-fpm-frr/frr/bgpd/templates/general/policies.conf.j2 +++ b/dockers/docker-fpm-frr/frr/bgpd/templates/general/policies.conf.j2 @@ -3,14 +3,22 @@ ! ! ! -{% if constants.bgp.allow_list is defined and constants.bgp.allow_list.enabled is defined and constants.bgp.allow_list.enabled %} -{% if constants.bgp.allow_list.default_action is defined and constants.bgp.allow_list.default_action.strip() == 'deny' %} +{% if constants.bgp.allow_list is defined and constants.bgp.allow_list.enabled is defined and constants.bgp.allow_list.enabled and constants.bgp.allow_list.drop_community is defined %} +! +! +! please don't remove. 65535 entries are default rules +! which works when allow_list is enabled, but new configuration +! is not applied +! +{% if allow_list_default_action == 'deny' %} +! route-map ALLOW_LIST_DEPLOYMENT_ID_0_V4 permit 65535 set community no-export additive ! route-map ALLOW_LIST_DEPLOYMENT_ID_0_V6 permit 65535 set community no-export additive {% else %} +! route-map ALLOW_LIST_DEPLOYMENT_ID_0_V4 permit 65535 set community {{ constants.bgp.allow_list.drop_community }} additive ! @@ -18,14 +26,23 @@ route-map ALLOW_LIST_DEPLOYMENT_ID_0_V6 permit 65535 set community {{ constants.bgp.allow_list.drop_community }} additive {% endif %} ! -route-map FROM_BGP_PEER_V4 permit 2 +bgp community-list standard allow_list_default_community permit no-export +bgp community-list standard allow_list_default_community permit {{ constants.bgp.allow_list.drop_community }} +! +route-map FROM_BGP_PEER_V4 permit 10 call ALLOW_LIST_DEPLOYMENT_ID_0_V4 on-match next ! -route-map FROM_BGP_PEER_V6 permit 2 +route-map FROM_BGP_PEER_V4 permit 11 + match community allow_list_default_community +! +route-map FROM_BGP_PEER_V6 permit 10 call ALLOW_LIST_DEPLOYMENT_ID_0_V6 on-match next ! +route-map FROM_BGP_PEER_V6 permit 11 + match community allow_list_default_community +! {% endif %} ! ! diff --git a/dockers/docker-fpm-frr/frr/bgpd/tsa/bgpd.tsa.isolate.conf.j2 b/dockers/docker-fpm-frr/frr/bgpd/tsa/bgpd.tsa.isolate.conf.j2 index 94287bdcd300..1256d1cd4f96 100644 --- a/dockers/docker-fpm-frr/frr/bgpd/tsa/bgpd.tsa.isolate.conf.j2 +++ b/dockers/docker-fpm-frr/frr/bgpd/tsa/bgpd.tsa.isolate.conf.j2 @@ -1,5 +1,5 @@ -route-map {{ route_map_name }} permit 2 +route-map {{ route_map_name }} permit 20 match {{ ip_protocol }} address prefix-list PL_Loopback{{ ip_version }} set community {{ constants.bgp.traffic_shift_community }} -route-map {{ route_map_name }} deny 3 +route-map {{ route_map_name }} deny 30 ! diff --git a/dockers/docker-fpm-frr/frr/bgpd/tsa/bgpd.tsa.unisolate.conf.j2 b/dockers/docker-fpm-frr/frr/bgpd/tsa/bgpd.tsa.unisolate.conf.j2 index 22244b3ac883..649f6d8e9db8 100644 --- a/dockers/docker-fpm-frr/frr/bgpd/tsa/bgpd.tsa.unisolate.conf.j2 +++ b/dockers/docker-fpm-frr/frr/bgpd/tsa/bgpd.tsa.unisolate.conf.j2 @@ -1,3 +1,3 @@ -no route-map {{ route_map_name }} permit 2 -no route-map {{ route_map_name }} deny 3 +no route-map {{ route_map_name }} permit 20 +no route-map {{ route_map_name }} deny 30 ! diff --git a/src/sonic-bgpcfgd/bgpcfgd/managers_allow_list.py b/src/sonic-bgpcfgd/bgpcfgd/managers_allow_list.py index b58d8bb885c9..1e4eb6e404e2 100644 --- a/src/sonic-bgpcfgd/bgpcfgd/managers_allow_list.py +++ b/src/sonic-bgpcfgd/bgpcfgd/managers_allow_list.py @@ -36,8 +36,6 @@ def __init__(self, common_objs, db, table): db, table, ) - self.cfg_mgr = common_objs["cfg_mgr"] - self.constants = common_objs["constants"] self.key_re = re.compile(r"^DEPLOYMENT_ID\|\d+\|\S+$|^DEPLOYMENT_ID\|\d+$") self.enabled = self.__get_enabled() self.__load_constant_lists() @@ -63,7 +61,8 @@ def set_handler(self, key, data): prefixes_v4 = str(data['prefixes_v4']).split(",") if "prefixes_v6" in data: prefixes_v6 = str(data['prefixes_v6']).split(",") - self.__update_policy(deployment_id, community_value, prefixes_v4, prefixes_v6) + default_action_community = self.__get_default_action_community(data) + self.__update_policy(deployment_id, community_value, prefixes_v4, prefixes_v6, default_action_community) return True def __set_handler_validate(self, key, data): @@ -96,6 +95,9 @@ def __set_handler_validate(self, key, data): if not prefixes_v4 and not prefixes_v6: log_err("BGPAllowListMgr::Received BGP ALLOWED 'SET' message with no prefixes specified: %s" % str(data)) return False + if "default_action" in data and data["default_action"] != "permit" and data["default_action"] != "deny": + log_err("BGPAllowListMgr::Received BGP ALLOWED 'SET' message with invalid 'default_action' field: '%s'" % str(data)) + return False return True def del_handler(self, key): @@ -124,13 +126,14 @@ def __del_handler_validate(self, key): return False return True - def __update_policy(self, deployment_id, community_value, prefixes_v4, prefixes_v6): + def __update_policy(self, deployment_id, community_value, prefixes_v4, prefixes_v6, default_action): """ Update "allow list" policy with parameters :param deployment_id: deployment id which policy will be changed :param community_value: community value to match for the updated policy :param prefixes_v4: a list of v4 prefixes for the updated policy :param prefixes_v6: a list of v6 prefixes for the updated policy + :param default_action: the default action for the policy. should be either 'permit' or 'deny' """ # update all related entries with the information info = deployment_id, community_value, str(prefixes_v4), str(prefixes_v6) @@ -146,6 +149,8 @@ def __update_policy(self, deployment_id, community_value, prefixes_v4, prefixes_ cmds += self.__update_community(names['community'], community_value) cmds += self.__update_allow_route_map_entry(self.V4, names['pl_v4'], names['community'], names['rm_v4']) cmds += self.__update_allow_route_map_entry(self.V6, names['pl_v6'], names['community'], names['rm_v6']) + cmds += self.__update_default_route_map_entry(names['rm_v4'], default_action) + cmds += self.__update_default_route_map_entry(names['rm_v6'], default_action) if cmds: self.cfg_mgr.push_list(cmds) peer_groups = self.__find_peer_group_by_deployment_id(deployment_id) @@ -365,6 +370,52 @@ def __update_allow_route_map_entry(self, af, allow_address_pl_name, community_na cmds.append(" match community %s" % community_name) return cmds + def __update_default_route_map_entry(self, route_map_name, default_action_community): + """ + Add or update default action rule for the route-map. + Default action rule is hardcoded into route-map permit 65535 + :param route_map_name: name of the target route_map + :param default_action_community: community value to mark not-matched prefixes + """ + info = route_map_name, default_action_community + log_debug("BGPAllowListMgr::__update_default_route_map_entry. rm='%s' set_community='%s'" % info) + current_default_action_value = self.__parse_default_action_route_map_entry(route_map_name) + if current_default_action_value != default_action_community: + return [ + 'route-map %s permit 65535' % route_map_name, + ' set community %s additive' % default_action_community + ] + else: + return [] + + def __parse_default_action_route_map_entry(self, route_map_name): + """ + Parse default-action route-map entry + :param route_map_name: Name of the route-map to parse + :return: a community value used for default action + """ + log_debug("BGPAllowListMgr::__parse_default_action_route_map_entries. rm='%s'" % route_map_name) + match_string = 'route-map %s permit 65535' % route_map_name + match_community = re.compile(r'^set community (\S+) additive$') + inside_route_map = False + community_value = "" + conf = self.cfg_mgr.get_text() + for line in conf + [""]: + s_line = line.strip() + if inside_route_map: + matched = match_community.match(s_line) + if matched: + community_value = matched.group(1) + break + else: + log_err("BGPAllowListMgr::Found incomplete route-map '%s' entry. seq_no=65535" % route_map_name) + inside_route_map = False + elif s_line == match_string: + inside_route_map = True + if community_value == "": + log_err("BGPAllowListMgr::Default action community value is not found. route-map '%s' entry. seq_no=65535" % route_map_name) + return community_value + def __remove_allow_route_map_entry(self, af, allow_address_pl_name, community_name, route_map_name): """ Add or update a "Allow address" route-map entry with the parameters @@ -624,3 +675,26 @@ def __af_to_family(self, af): :return: prefix list ip family """ return 'ip' if af == self.V4 else 'ipv6' + + def __get_default_action_community(self, data): + """ + Determine the default action community based on the request. + If request doesn't contain "default_action" field - the default_action value + from the constants is being used + :param data: SET request data + :return: returns community value for "default_action" + """ + drop_community = self.constants["bgp"]["allow_list"]["drop_community"] + if "default_action" in data: + if data["default_action"] == "deny": + return "no-export" + else: # "permit" + return drop_community + else: + if "default_action" in self.constants["bgp"]["allow_list"]: + if self.constants["bgp"]["allow_list"]["default_action"].strip() == "deny": + return "no-export" + else: + return drop_community + else: + return drop_community diff --git a/src/sonic-bgpcfgd/tests/data/general/policies.conf/param_all.json b/src/sonic-bgpcfgd/tests/data/general/policies.conf/param_all.json index 2ed388731ba0..0e08c6a51d03 100644 --- a/src/sonic-bgpcfgd/tests/data/general/policies.conf/param_all.json +++ b/src/sonic-bgpcfgd/tests/data/general/policies.conf/param_all.json @@ -4,9 +4,9 @@ "bgp": { "allow_list": { "enabled": true, - "default_action": "permit", "drop_community": "12345:12345" } } - } + }, + "allow_list_default_action": "permit" } diff --git a/src/sonic-bgpcfgd/tests/data/general/policies.conf/param_deny.json b/src/sonic-bgpcfgd/tests/data/general/policies.conf/param_deny.json index 47cb93082041..b2799abfaa0f 100644 --- a/src/sonic-bgpcfgd/tests/data/general/policies.conf/param_deny.json +++ b/src/sonic-bgpcfgd/tests/data/general/policies.conf/param_deny.json @@ -4,9 +4,9 @@ "bgp": { "allow_list": { "enabled": true, - "default_action": "deny", "drop_community": "12345:12345" } } - } + }, + "allow_list_default_action": "deny" } diff --git a/src/sonic-bgpcfgd/tests/data/general/policies.conf/result_all.conf b/src/sonic-bgpcfgd/tests/data/general/policies.conf/result_all.conf index e4f58f80c92c..8d0c17d592b8 100644 --- a/src/sonic-bgpcfgd/tests/data/general/policies.conf/result_all.conf +++ b/src/sonic-bgpcfgd/tests/data/general/policies.conf/result_all.conf @@ -1,20 +1,33 @@ ! ! template: bgpd/templates/general/policies.conf.j2 ! +! please don't remove. 65535 entries are default rules +! which works when allow_list is enabled, but new configuration +! is not applied +! route-map ALLOW_LIST_DEPLOYMENT_ID_0_V4 permit 65535 set community 12345:12345 additive ! route-map ALLOW_LIST_DEPLOYMENT_ID_0_V6 permit 65535 set community 12345:12345 additive ! -route-map FROM_BGP_PEER_V4 permit 2 +bgp community-list standard allow_list_default_community permit no-export +bgp community-list standard allow_list_default_community permit 12345:12345 +! +route-map FROM_BGP_PEER_V4 permit 10 call ALLOW_LIST_DEPLOYMENT_ID_0_V4 on-match next ! -route-map FROM_BGP_PEER_V6 permit 2 +route-map FROM_BGP_PEER_V4 permit 11 + match community allow_list_default_community +! +route-map FROM_BGP_PEER_V6 permit 10 call ALLOW_LIST_DEPLOYMENT_ID_0_V6 on-match next ! +route-map FROM_BGP_PEER_V6 permit 11 + match community allow_list_default_community +! route-map FROM_BGP_PEER_V4 permit 100 ! route-map TO_BGP_PEER_V4 permit 100 diff --git a/src/sonic-bgpcfgd/tests/data/general/policies.conf/result_deny.conf b/src/sonic-bgpcfgd/tests/data/general/policies.conf/result_deny.conf index 7f9137931e1c..661414bd579c 100644 --- a/src/sonic-bgpcfgd/tests/data/general/policies.conf/result_deny.conf +++ b/src/sonic-bgpcfgd/tests/data/general/policies.conf/result_deny.conf @@ -1,20 +1,33 @@ ! ! template: bgpd/templates/general/policies.conf.j2 ! +! please don't remove. 65535 entries are default rules +! which works when allow_list is enabled, but new configuration +! is not applied +! route-map ALLOW_LIST_DEPLOYMENT_ID_0_V4 permit 65535 set community no-export additive ! route-map ALLOW_LIST_DEPLOYMENT_ID_0_V6 permit 65535 set community no-export additive ! -route-map FROM_BGP_PEER_V4 permit 2 +bgp community-list standard allow_list_default_community permit no-export +bgp community-list standard allow_list_default_community permit 12345:12345 +! +route-map FROM_BGP_PEER_V4 permit 10 call ALLOW_LIST_DEPLOYMENT_ID_0_V4 on-match next ! -route-map FROM_BGP_PEER_V6 permit 2 +route-map FROM_BGP_PEER_V4 permit 11 + match community allow_list_default_community +! +route-map FROM_BGP_PEER_V6 permit 10 call ALLOW_LIST_DEPLOYMENT_ID_0_V6 on-match next ! +route-map FROM_BGP_PEER_V6 permit 11 + match community allow_list_default_community +! route-map FROM_BGP_PEER_V4 permit 100 ! route-map TO_BGP_PEER_V4 permit 100 diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/tsa/isolate.conf b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/tsa/isolate.conf index 7bd155fcdb64..2ea4111dfc26 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/tsa/isolate.conf +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/tsa/isolate.conf @@ -1,5 +1,5 @@ -route-map test_rm_name permit 2 +route-map test_rm_name permit 20 match ip address prefix-list PL_LoopbackV4 set community 12345:555 -route-map test_rm_name deny 3 +route-map test_rm_name deny 30 ! diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/tsa/unisolate.conf b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/tsa/unisolate.conf index db53a69e7ec4..2adeac6e0ef7 100644 --- a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/tsa/unisolate.conf +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/tsa/unisolate.conf @@ -1,3 +1,3 @@ -no route-map test_rm permit 2 -no route-map test_rm deny 3 +no route-map test_rm permit 20 +no route-map test_rm deny 30 ! diff --git a/src/sonic-bgpcfgd/tests/test_allow_list.py b/src/sonic-bgpcfgd/tests/test_allow_list.py index 904ba14f2ecf..6a53e2f49ca7 100644 --- a/src/sonic-bgpcfgd/tests/test_allow_list.py +++ b/src/sonic-bgpcfgd/tests/test_allow_list.py @@ -18,7 +18,9 @@ "deny 0::/0 le 59", "deny 0::/0 ge 65" ] - } + }, + "default_action": "permit", + "drop_community": "123:123" } } } @@ -64,7 +66,12 @@ def test_set_handler_with_community(): "prefixes_v4": "10.20.30.0/24,30.50.0.0/16", "prefixes_v6": "fc00:20::/64,fc00:30::/64", }), - [], + [ + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive' + ], [ 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 10 deny 0.0.0.0/0 le 17', 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 20 permit 10.20.30.0/24 le 32', @@ -90,7 +97,12 @@ def test_set_handler_no_community(): "prefixes_v4": "20.20.30.0/24,40.50.0.0/16", "prefixes_v6": "fc01:20::/64,fc01:30::/64", }), - [], + [ + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive', + ], [ 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4 seq 10 deny 0.0.0.0/0 le 17', 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4 seq 20 permit 20.20.30.0/24 le 32', @@ -184,6 +196,10 @@ def test_set_handler_with_community_data_is_already_presented(): 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 10', ' match ipv6 address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6', ' match community COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive', "" ], [] @@ -206,6 +222,10 @@ def test_set_handler_no_community_data_is_already_presented(): ' match ip address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4', 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 30000', ' match ipv6 address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive', "" ] common_objs = { @@ -259,6 +279,10 @@ def test_set_handler_with_community_update_prefixes_add(): 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 10', ' match ipv6 address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6', ' match community COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive', "" ], [ @@ -295,6 +319,10 @@ def test_set_handler_no_community_update_prefixes_add(): ' match ip address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4', 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 30000', ' match ipv6 address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive', "" ], [ @@ -450,4 +478,114 @@ def test___to_prefix_list(): res_v6 = mgr._BGPAllowListMgr__to_prefix_list(mgr.V6, ["fc00::1/128", "fc00::/64"]) assert res_v6 == ["permit fc00::1/128", "permit fc00::/64 le 128"] -# FIXME: more testcases for coverage +@patch.dict("sys.modules", swsscommon=swsscommon_module_mock) +def construct_BGPAllowListMgr(constants): + from bgpcfgd.managers_allow_list import BGPAllowListMgr + cfg_mgr = MagicMock() + common_objs = { + 'directory': Directory(), + 'cfg_mgr': cfg_mgr, + 'tf': TemplateFabric(), + 'constants': constants, + } + mgr = BGPAllowListMgr(common_objs, "CONFIG_DB", "BGP_ALLOWED_PREFIXES") + return mgr + +def test___get_enabled_enabled(): + constants = { + "bgp": { + "allow_list": { + "enabled": True, + } + } + } + mgr = construct_BGPAllowListMgr(constants) + assert mgr._BGPAllowListMgr__get_enabled() + +def test___get_enabled_disabled_1(): + constants = { + "bgp": { + "allow_list": { + "enabled": False, + } + } + } + mgr = construct_BGPAllowListMgr(constants) + assert not mgr._BGPAllowListMgr__get_enabled() + +def test___get_enabled_disabled_2(): + constants = { + "bgp": { + "allow_list": {} + } + } + mgr = construct_BGPAllowListMgr(constants) + assert not mgr._BGPAllowListMgr__get_enabled() + +def test___get_enabled_disabled_3(): + constants = { + "bgp": {} + } + mgr = construct_BGPAllowListMgr(constants) + assert not mgr._BGPAllowListMgr__get_enabled() + +def test___get_enabled_disabled_4(): + constants = {} + mgr = construct_BGPAllowListMgr(constants) + assert not mgr._BGPAllowListMgr__get_enabled() + +def test___get_default_action_deny(): + constants = { + "bgp": { + "allow_list": { + "enabled": True, + "default_action": "deny", + "drop_community": "123:123" + } + } + } + data = {} + mgr = construct_BGPAllowListMgr(constants) + assert mgr._BGPAllowListMgr__get_default_action_community(data) == "no-export" + +def test___get_default_action_permit_1(): + constants = { + "bgp": { + "allow_list": { + "enabled": True, + "default_action": "permit", + "drop_community": "123:123" + } + } + } + data = {} + mgr = construct_BGPAllowListMgr(constants) + assert mgr._BGPAllowListMgr__get_default_action_community(data) == "123:123" + +def test___get_default_action_permit_2(): + constants = { + "bgp": { + "allow_list": { + "enabled": True, + "drop_community": "123:123" + } + } + } + data = {} + mgr = construct_BGPAllowListMgr(constants) + assert mgr._BGPAllowListMgr__get_default_action_community(data) == "123:123" + +def test___get_default_action_permit_3(): + constants = { + "bgp": { + "allow_list": { + "enabled": False, + "drop_community": "123:123" + } + } + } + data = {} + mgr = construct_BGPAllowListMgr(constants) + assert mgr._BGPAllowListMgr__get_default_action_community(data) == "123:123" + +# FIXME: more testcases for coverage \ No newline at end of file From 88ace50da8c6a0a6d9a5e3d3085753074d4243e9 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Fri, 8 Jan 2021 14:13:25 -0800 Subject: [PATCH 0032/1674] [sonic-swss-common] Update submodule (#6382) Includes sonic-swss-common commits: ``` 71dc350 2021-01-07 | Lower the log level for outdated key for SubscriberStateTable notification (#441) [Qi Luo] 7e40582 2021-01-08 | Add boost dependencies (#442) [Ze Gan] 30a8ddf 2021-01-05 | Change DBConnector::hgetall return type from map to unordered_map (#440) [Qi Luo] 021108d 2021-01-02 | MCLAG Enhancements per HLD https://github.com/Azure/SONiC/pull/596 (#405) [Praveen-Brcm] 54996fc 2021-01-02 | Implement ConfigDBConnector and ConfigDBPipeConnector in C++ (#437) [Qi Luo] 8286525 2020-12-27 | Simply refactor DBConnector hgetall() [Qi Luo] 6d1d33b 2020-12-27 | Fix RedisTransactioner: handle empty deque [Qi Luo] 624e0b8 2020-12-26 | Move complex class constructor as explicit, and fix several mistaken copy constructor usage [Qi Luo] 3b983f9 2020-12-30 | [ci]: add timeout to 180 minutes for arm build (#439) [lguohan] f2e4210 2020-12-29 | Add utility for string and redis (#434) [Ze Gan] 7a885fd 2020-12-29 | [build]: add build check for arm64 and armhf (#436) [lguohan] 47bccc4 2020-12-24 | Add missed vector header to rediscommand.h (#435) [Ze Gan] ``` --- src/sonic-swss-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-swss-common b/src/sonic-swss-common index b423b9c8aa24..71dc350d94a9 160000 --- a/src/sonic-swss-common +++ b/src/sonic-swss-common @@ -1 +1 @@ -Subproject commit b423b9c8aa245ab19352597ad83e7214f42fe74a +Subproject commit 71dc350d94a93a6a13bbcec9d9723809e4d3bae2 From 3e8142fba0b8bf049e4f401f7633662c1ef38b14 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Jan 2021 15:47:29 -0800 Subject: [PATCH 0033/1674] Bump lxml from 4.6.1 to 4.6.2 in /src/sonic-config-engine (#6385) Bumps [lxml](https://github.com/lxml/lxml) from 4.6.1 to 4.6.2. - [Release notes](https://github.com/lxml/lxml/releases) - [Changelog](https://github.com/lxml/lxml/blob/master/CHANGES.txt) - [Commits](https://github.com/lxml/lxml/compare/lxml-4.6.1...lxml-4.6.2) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/sonic-config-engine/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 src/sonic-config-engine/setup.py diff --git a/src/sonic-config-engine/setup.py b/src/sonic-config-engine/setup.py old mode 100755 new mode 100644 index 2483e8ebcf38..c9dfd3609b92 --- 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.1', + 'lxml==4.6.2', 'netaddr==0.8.0', 'pyyaml==5.3.1', 'sonic-py-common', From 2ae182623c9eaefa906b40dc6e750fa8539ab9a4 Mon Sep 17 00:00:00 2001 From: guxianghong Date: Sun, 10 Jan 2021 00:07:30 +0800 Subject: [PATCH 0034/1674] [Centec ARM64]Upgrade Centec syncd docker to buster and Enable Telemetry on ARM64 (#6386) * Enable telemetry for ARM64 by default * [Centec]Upgrade Centec syncd docker to buster; libjemalloc2 have been installed in docker-base-buster, remove libjemalloc1 from docker-syncd-centec's Dockerfile.j2 Co-authored-by: Gu Xianghong --- platform/centec-arm64/docker-syncd-centec.mk | 3 --- platform/centec-arm64/docker-syncd-centec/Dockerfile.j2 | 4 ++-- platform/centec/docker-syncd-centec.mk | 3 --- platform/centec/docker-syncd-centec/Dockerfile.j2 | 2 +- slave.mk | 8 -------- 5 files changed, 3 insertions(+), 17 deletions(-) diff --git a/platform/centec-arm64/docker-syncd-centec.mk b/platform/centec-arm64/docker-syncd-centec.mk index 9943420660a4..9c3d1b1aff75 100755 --- a/platform/centec-arm64/docker-syncd-centec.mk +++ b/platform/centec-arm64/docker-syncd-centec.mk @@ -10,9 +10,6 @@ $(DOCKER_SYNCD_BASE)_DBG_DEPENDS += $(SYNCD_DBG) \ $(LIBSAIMETADATA_DBG) \ $(LIBSAIREDIS_DBG) -SONIC_STRETCH_DOCKERS += $(DOCKER_SYNCD_BASE) -SONIC_STRETCH_DBG_DOCKERS += $(DOCKER_SYNCD_BASE_DBG) - $(DOCKER_SYNCD_BASE)_RUN_OPT += -v /host/warmboot:/var/warmboot $(DOCKER_SYNCD_CENTEC)_RUN_OPT += --privileged -t $(DOCKER_SYNCD_CENTEC)_RUN_OPT += -v /host/machine.conf:/etc/machine.conf diff --git a/platform/centec-arm64/docker-syncd-centec/Dockerfile.j2 b/platform/centec-arm64/docker-syncd-centec/Dockerfile.j2 index 7590d65600b7..b97bfe3d3e18 100755 --- a/platform/centec-arm64/docker-syncd-centec/Dockerfile.j2 +++ b/platform/centec-arm64/docker-syncd-centec/Dockerfile.j2 @@ -1,4 +1,4 @@ -FROM docker-config-engine-stretch +FROM docker-config-engine-buster ARG docker_container_name RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf @@ -19,7 +19,7 @@ RUN apt-get update \ net-tools \ iputils-ping -RUN apt-get -y install libpcap-dev libxml2-dev python-dev swig libsensors4-dev libjemalloc1 nfs-common +RUN apt-get -y install libpcap-dev libxml2-dev python-dev swig libsensors4-dev nfs-common RUN dpkg -i \ {% for deb in docker_syncd_centec_debs.split(' ') -%} diff --git a/platform/centec/docker-syncd-centec.mk b/platform/centec/docker-syncd-centec.mk index ada63a218d4a..75cc45c28559 100644 --- a/platform/centec/docker-syncd-centec.mk +++ b/platform/centec/docker-syncd-centec.mk @@ -10,9 +10,6 @@ $(DOCKER_SYNCD_CENTEC)_DEPENDS += $(SYNCD_DBG) \ $(LIBSAIMETADATA_DBG) \ $(LIBSAIREDIS_DBG) -SONIC_STRETCH_DOCKERS += $(DOCKER_SYNCD_BASE) -SONIC_STRETCH_DBG_DOCKERS += $(DOCKER_SYNCD_BASE_DBG) - $(DOCKER_SYNCD_CENTEC)_RUN_OPT += --privileged -t $(DOCKER_SYNCD_CENTEC)_RUN_OPT += -v /host/machine.conf:/etc/machine.conf $(DOCKER_SYNCD_CENTEC)_RUN_OPT += -v /var/run/docker-syncd:/var/run/sswsyncd diff --git a/platform/centec/docker-syncd-centec/Dockerfile.j2 b/platform/centec/docker-syncd-centec/Dockerfile.j2 index 8bb5041b15ba..ce3b47bcdd77 100755 --- a/platform/centec/docker-syncd-centec/Dockerfile.j2 +++ b/platform/centec/docker-syncd-centec/Dockerfile.j2 @@ -1,4 +1,4 @@ -FROM docker-config-engine-stretch +FROM docker-config-engine-buster ARG docker_container_name RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf diff --git a/slave.mk b/slave.mk index 686ecec5c508..4474817c9c3f 100644 --- a/slave.mk +++ b/slave.mk @@ -116,14 +116,6 @@ ifeq ($(SONIC_INCLUDE_SYSTEM_TELEMETRY),y) INCLUDE_SYSTEM_TELEMETRY = y endif -ifneq (,$(filter $(CONFIGURED_ARCH), arm64)) - # Workaround: Force disable Telmetry for ARM, will be removed after fixing issue - # Issue: qemu crashes when it uses "go get url" - # Qemu Support: https://bugs.launchpad.net/qemu/+bug/1838946 - # Golang Support: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!topic/golang-nuts/1txPOGa4aGc -INCLUDE_SYSTEM_TELEMETRY = n -endif - ifeq ($(SONIC_INCLUDE_RESTAPI),y) INCLUDE_RESTAPI = y endif From 9da8b0faf9dc7fd2ae3238aaf01ab1e7758936cb Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Mon, 11 Jan 2021 08:13:04 -0800 Subject: [PATCH 0035/1674] [utilities] advance utilities submodule head (#6402) - (HEAD, github/master) [storyteller] adding a grep wrapper with predefined scenarios (#1349) - Adding global-timeout, individual command timeout, log files collection (#1249) - Add FW dump with new SAI implementation (#1338) - [unit test][pfcwd] Fix tests that require sudo access (#1340) Signed-off-by: Ying Xie --- src/sonic-utilities | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-utilities b/src/sonic-utilities index 7924bd18d455..0a4365aaa0ad 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit 7924bd18d45547d6c865a42315766bc2324f7eec +Subproject commit 0a4365aaa0adadcb4c3fa448e05f6d2e217bda5f From 264ecb181c8a616a84e08201c1bbe2321e4a7edb Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Mon, 11 Jan 2021 10:18:39 -0800 Subject: [PATCH 0036/1674] [minigraph.py]: Add peer switch hostname to device metadata (#6405) To make the peer switch hostname easily accessible from config DB. Add peer_switch field to DEVICE_METADATA table Signed-off-by: Lawrence Lee --- src/sonic-config-engine/minigraph.py | 4 ++++ src/sonic-config-engine/tests/test_minigraph_case.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 660606b4519d..632cf060b626 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -1178,6 +1178,10 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw if bool(results['PEER_SWITCH']): results['DEVICE_METADATA']['localhost']['subtype'] = 'DualToR' + if len(results['PEER_SWITCH'].keys()) > 1: + print("Warning: more than one peer switch was found. Only the first will be parsed: {}".format(results['PEER_SWITCH'].keys()[0])) + + results['DEVICE_METADATA']['localhost']['peer_switch'] = list(results['PEER_SWITCH'].keys())[0] if is_storage_device: results['DEVICE_METADATA']['localhost']['storage_device'] = "true" diff --git a/src/sonic-config-engine/tests/test_minigraph_case.py b/src/sonic-config-engine/tests/test_minigraph_case.py index efa8a063b6e5..cf8a7557aeb7 100644 --- a/src/sonic-config-engine/tests/test_minigraph_case.py +++ b/src/sonic-config-engine/tests/test_minigraph_case.py @@ -57,6 +57,11 @@ def test_minigraph_subtype(self): output = self.run_script(argument) self.assertEqual(output.strip(), 'DualToR') + def test_minigraph_peer_switch_hostname(self): + argument = '-m "' + self.sample_graph + '" -v "DEVICE_METADATA[\'localhost\'][\'peer_switch\']"' + output = self.run_script(argument) + self.assertEqual(output.strip(), 'switch2-t0') + def test_additional_json_data(self): argument = '-a \'{"key1":"value1"}\' -v key1' output = self.run_script(argument) From 45b724fe76ddd6b3d2b59e78cd6072edfc0c31e7 Mon Sep 17 00:00:00 2001 From: lguohan Date: Tue, 12 Jan 2021 06:03:12 -0800 Subject: [PATCH 0037/1674] [build]: fix dpkg admindir corruption issue in parallel build (#6408) Fix #119 when parallel build is enable, multiple dpkg-buildpackage instances are running at the same time. /var/lib/dpkg is shared by all instances and the /var/lib/dpkg/updates could be corrupted and cause the build failure. the fix is to use overlay fs to mount separate /var/lib/dpkg for each dpkg-buildpackage instance so that they are not affecting each other. Signed-off-by: Guohan Lu --- .../sonic-platform-modules-brcm-xlr-gts/Makefile | 2 +- rules/functions | 12 ++++++++++++ slave.mk | 8 ++++++-- src/bash/Makefile | 2 +- src/hiredis/Makefile | 2 +- src/ifupdown2/Makefile | 2 +- src/initramfs-tools/Makefile | 2 +- src/iproute2/Makefile | 2 +- src/iptables/Makefile | 2 +- src/isc-dhcp/Makefile | 2 +- src/kdump-tools/Makefile | 2 +- src/libnl3/Makefile | 2 +- src/libteam/Makefile | 2 +- src/libyang1/Makefile | 2 +- src/lldpd/Makefile | 2 +- src/lm-sensors/Makefile | 2 +- src/monit/Makefile | 2 +- src/mpdecimal/Makefile | 2 +- src/ntp/Makefile | 2 +- src/openssh/Makefile | 2 +- src/python3/Makefile | 2 +- src/redis/Makefile | 2 +- src/sflow/hsflowd/Makefile | 2 +- src/sflow/psample/Makefile | 2 +- src/sflow/sflowtool/Makefile | 2 +- src/smartmontools/Makefile | 2 +- src/snmpd/Makefile | 2 +- src/socat/Makefile | 2 +- src/sonic-device-data/Makefile | 2 +- src/sonic-frr/Makefile | 2 +- src/sonic-host-service/Makefile | 2 +- src/swig/Makefile | 2 +- src/systemd-sonic-generator/Makefile | 2 +- src/tacacs/nss/Makefile | 4 ++-- src/tacacs/pam/Makefile | 4 ++-- src/thrift/Makefile | 2 +- 36 files changed, 54 insertions(+), 38 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-brcm-xlr-gts/Makefile b/platform/broadcom/sonic-platform-modules-brcm-xlr-gts/Makefile index cd2a5a101ad5..3f93a0bfe52a 100644 --- a/platform/broadcom/sonic-platform-modules-brcm-xlr-gts/Makefile +++ b/platform/broadcom/sonic-platform-modules-brcm-xlr-gts/Makefile @@ -7,7 +7,7 @@ MAIN_TARGET = $(BRCM_XLR_GTS_PLATFORM_MODULE) $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Build the package export PYBUILD_INSTALL_ARGS_python2=--install-scripts=/dev/null - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) mv $(addprefix ../, $* $(EXTRA_TARGETS)) $(DEST)/ diff --git a/rules/functions b/rules/functions index 104efa3055b7..5ccb111cec72 100644 --- a/rules/functions +++ b/rules/functions @@ -153,3 +153,15 @@ if [ -n "$(1)" ]; then \ done; \ fi endef + +############################################################################### +## Setup overlay fs for dpkg admin directory /var/lib/dpkg +############################################################################### +define SETUP_OVERLAYFS_FOR_DPKG_ADMINDIR +upperdir=$(shell mktemp -d -p $(DPKG_ADMINDIR_PATH)) +workdir=$(shell mktemp -d -p $(DPKG_ADMINDIR_PATH)) +mergedir=$(shell mktemp -d -p $(DPKG_ADMINDIR_PATH)) +sudo mount -t overlay overlay -olowerdir=/var/lib/dpkg,upperdir=$$upperdir,workdir=$$workdir $$mergedir +export SONIC_DPKG_ADMINDIR=$$mergedir +trap "sudo umount $$mergedir && rm -rf $$mergedir $$upperdir $$workdir" EXIT +endef diff --git a/slave.mk b/slave.mk index 4474817c9c3f..728bb8be16cf 100644 --- a/slave.mk +++ b/slave.mk @@ -41,6 +41,7 @@ BUSTER_DEBS_PATH = $(TARGET_PATH)/debs/buster BUSTER_FILES_PATH = $(TARGET_PATH)/files/buster DBG_IMAGE_MARK = dbg DBG_SRC_ARCHIVE_FILE = $(TARGET_PATH)/sonic_src.tar.gz +DPKG_ADMINDIR_PATH = /sonic/dpkg CONFIGURED_PLATFORM := $(shell [ -f .platform ] && cat .platform || echo generic) PLATFORM_PATH = platform/$(CONFIGURED_PLATFORM) @@ -83,6 +84,7 @@ configure : @mkdir -p $(BUSTER_FILES_PATH) @mkdir -p $(PYTHON_DEBS_PATH) @mkdir -p $(PYTHON_WHEELS_PATH) + @mkdir -p $(DPKG_ADMINDIR_PATH) @echo $(PLATFORM) > .platform @echo $(PLATFORM_ARCH) > .arch @@ -419,6 +421,7 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_MAKE_DEBS)) : $(DEBS_PATH)/% : .platform $$(a # Apply series of patches if exist if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && QUILT_PATCHES=../$(notdir $($*_SRC_PATH)).patch quilt push -a; popd; fi # Build project and take package + $(SETUP_OVERLAYFS_FOR_DPKG_ADMINDIR) DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC}" make DEST=$(shell pwd)/$(DEBS_PATH) -C $($*_SRC_PATH) $(shell pwd)/$(DEBS_PATH)/$* $(LOG) # Clean up if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && quilt pop -a -f; [ -d .pc ] && rm -rf .pc; popd; fi @@ -459,9 +462,10 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_DPKG_DEBS)) : $(DEBS_PATH)/% : .platform $$(a # Build project pushd $($*_SRC_PATH) $(LOG_SIMPLE) if [ -f ./autogen.sh ]; then ./autogen.sh $(LOG); fi + $(SETUP_OVERLAYFS_FOR_DPKG_ADMINDIR) $(if $($*_DPKG_TARGET), - DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC} ${$*_DEB_BUILD_OPTIONS}" dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --as-root -T$($*_DPKG_TARGET) $(LOG), - DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC} ${$*_DEB_BUILD_OPTIONS}" dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) $(LOG) + DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC} ${$*_DEB_BUILD_OPTIONS}" dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --as-root -T$($*_DPKG_TARGET) --admindir $$mergedir $(LOG), + DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC} ${$*_DEB_BUILD_OPTIONS}" dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $$mergedir $(LOG) ) popd $(LOG_SIMPLE) # Clean up diff --git a/src/bash/Makefile b/src/bash/Makefile index 602dc01ece70..6576ff92e74a 100644 --- a/src/bash/Makefile +++ b/src/bash/Makefile @@ -10,7 +10,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dget -u https://launchpad.net/debian/+archive/primary/+sourcefiles/bash/$(BASH_VERSION_FULL)/bash_$(BASH_VERSION_FULL).dsc pushd bash-$(BASH_VERSION_MAJOR) - DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) + DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $* $(DEST)/ diff --git a/src/hiredis/Makefile b/src/hiredis/Makefile index 746056e51de5..4935a039e0af 100644 --- a/src/hiredis/Makefile +++ b/src/hiredis/Makefile @@ -14,7 +14,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x hiredis_$(HIREDIS_VERSION_FULL).dsc pushd hiredis-$(HIREDIS_VERSION) - fakeroot debian/rules -j$(SONIC_CONFIG_MAKE_JOBS) binary + dpkg-buildpackage -rfakeroot -d -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $* $(DERIVED_TARGETS) $(DEST)/ diff --git a/src/ifupdown2/Makefile b/src/ifupdown2/Makefile index 66b4df2ec32f..89228bedafae 100644 --- a/src/ifupdown2/Makefile +++ b/src/ifupdown2/Makefile @@ -14,7 +14,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : pushd ./ifupdown2-$(IFUPDOWN2_VERSION) # Build source and Debian packages - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -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/initramfs-tools/Makefile b/src/initramfs-tools/Makefile index 9ef8e78f5479..f57b943d2d4f 100644 --- a/src/initramfs-tools/Makefile +++ b/src/initramfs-tools/Makefile @@ -19,7 +19,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Build the package rm -f debian/*.debhelper.log - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/iproute2/Makefile b/src/iproute2/Makefile index 8748550a1d78..5b354ce8b019 100644 --- a/src/iproute2/Makefile +++ b/src/iproute2/Makefile @@ -17,7 +17,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x iproute2_$(IPROUTE2_VERSION_FULL).dsc pushd iproute2-$(IPROUTE2_VERSION) - dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $* $(DEST)/ diff --git a/src/iptables/Makefile b/src/iptables/Makefile index 3268ab5afea3..681ef5d2dcc3 100644 --- a/src/iptables/Makefile +++ b/src/iptables/Makefile @@ -38,7 +38,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg import -s ../patch/series # Build source and Debian packages - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -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/isc-dhcp/Makefile b/src/isc-dhcp/Makefile index bd957a08a6f5..2adf6bba2aa3 100644 --- a/src/isc-dhcp/Makefile +++ b/src/isc-dhcp/Makefile @@ -23,7 +23,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg import -s ../patch/series # Build source and Debian packages - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -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/kdump-tools/Makefile b/src/kdump-tools/Makefile index 18c2a369b5d7..dadf08503af1 100644 --- a/src/kdump-tools/Makefile +++ b/src/kdump-tools/Makefile @@ -25,7 +25,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg import -s ../patch/series # Build source and Debian packages - fakeroot debian/rules binary-indep + dpkg-buildpackage -rfakeroot -b -us -uc -Tbinary-indep -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd # Move the newly-built .deb packages to the destination directory diff --git a/src/libnl3/Makefile b/src/libnl3/Makefile index a0e9891c9efc..c45ac85b7288 100644 --- a/src/libnl3/Makefile +++ b/src/libnl3/Makefile @@ -21,7 +21,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : git checkout tags/libnl$(subst .,_,$(LIBNL3_VERSION_BASE)) ln -s ../debian debian - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/libteam/Makefile b/src/libteam/Makefile index 9fd5f582ed4d..47f9d1dd21bf 100644 --- a/src/libteam/Makefile +++ b/src/libteam/Makefile @@ -31,7 +31,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : mv tmp/debian libteam/ rm -rf tmp pushd ./libteam - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/libyang1/Makefile b/src/libyang1/Makefile index da6359aa9e12..834893eb0bbe 100644 --- a/src/libyang1/Makefile +++ b/src/libyang1/Makefile @@ -31,7 +31,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Enable large file support for 32-bit arch echo 'add_definitions(-D_FILE_OFFSET_BITS=64)' >> CMakeLists.txt - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -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/lldpd/Makefile b/src/lldpd/Makefile index fa997e3486c8..a336f1e989ae 100644 --- a/src/lldpd/Makefile +++ b/src/lldpd/Makefile @@ -35,7 +35,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg import -s ../patch/series # Build source and Debian packages - env "with_netlink_receive_bufsize=1024*1024" dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + env "with_netlink_receive_bufsize=1024*1024" dpkg-buildpackage -rfakeroot -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/lm-sensors/Makefile b/src/lm-sensors/Makefile index af080a8dba55..a5aa3ba7d885 100644 --- a/src/lm-sensors/Makefile +++ b/src/lm-sensors/Makefile @@ -25,7 +25,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg init stg import -s ../patch/series - DEB_BUILD_OPTIONS=nocheck PROG_EXTRA=sensord dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) + DEB_BUILD_OPTIONS=nocheck PROG_EXTRA=sensord dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/monit/Makefile b/src/monit/Makefile index 4ad9edd79143..570f30cf60f8 100644 --- a/src/monit/Makefile +++ b/src/monit/Makefile @@ -24,7 +24,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg import -s ../patch/series # Build source and Debian packages - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -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/mpdecimal/Makefile b/src/mpdecimal/Makefile index c4ef5b78b49c..b7f82ba702e5 100644 --- a/src/mpdecimal/Makefile +++ b/src/mpdecimal/Makefile @@ -14,7 +14,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x mpdecimal_$(MPDECIMAL_VERSION_FULL).dsc pushd mpdecimal-$(MPDECIMAL_VERSION) - dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $* $(DERIVED_TARGETS) $(DEST)/ diff --git a/src/ntp/Makefile b/src/ntp/Makefile index a128ed6e9967..6d96010be156 100644 --- a/src/ntp/Makefile +++ b/src/ntp/Makefile @@ -39,7 +39,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : sed -i 's/\/usr\/sbin\/ntpd {/\/usr\/sbin\/ntpd flags=(attach_disconnected complain) {/' debian/apparmor-profile # Build source and Debian packages with the symbols - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd diff --git a/src/openssh/Makefile b/src/openssh/Makefile index 888cdb28d168..0fd8642b1285 100644 --- a/src/openssh/Makefile +++ b/src/openssh/Makefile @@ -20,7 +20,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Build package sudo http_proxy=$(http_proxy) apt-get -y build-dep openssh - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/python3/Makefile b/src/python3/Makefile index c5d8c386c1b0..1c37e9d06c45 100644 --- a/src/python3/Makefile +++ b/src/python3/Makefile @@ -35,7 +35,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : fi done - dpkg-buildpackage -rfakeroot -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd cp $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/redis/Makefile b/src/redis/Makefile index e2d9e5828f5b..3a4fe3f4844c 100644 --- a/src/redis/Makefile +++ b/src/redis/Makefile @@ -22,7 +22,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : pushd redis-$(REDIS_VERSION) export ARCH="" - DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) + DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/sflow/hsflowd/Makefile b/src/sflow/hsflowd/Makefile index 3a521bfba158..e29dbcc199bb 100644 --- a/src/sflow/hsflowd/Makefile +++ b/src/sflow/hsflowd/Makefile @@ -21,7 +21,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : chmod u+x debian/rules sed -i -e s/_VERSION_/$(HSFLOWD_VERSION)-$(HSFLOWD_SUBVERSION)/g debian/changelog - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --buildinfo-option=-u. --changes-option=-u. + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) --buildinfo-option=-u. --changes-option=-u. mv $(DERIVED_TARGET) $* $(DEST)/ popd diff --git a/src/sflow/psample/Makefile b/src/sflow/psample/Makefile index 3f03c249989a..bbdefde2289b 100644 --- a/src/sflow/psample/Makefile +++ b/src/sflow/psample/Makefile @@ -13,7 +13,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : pushd ./libpsample git checkout -b libpsample -f e48fad2 - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $* $(DEST)/ diff --git a/src/sflow/sflowtool/Makefile b/src/sflow/sflowtool/Makefile index 10a3f2d24dea..5f2ad995a585 100644 --- a/src/sflow/sflowtool/Makefile +++ b/src/sflow/sflowtool/Makefile @@ -12,7 +12,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : pushd ./sflowtool git checkout -b sflowtool -f 6c2963b - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $* $(DEST)/ diff --git a/src/smartmontools/Makefile b/src/smartmontools/Makefile index 4ac3d6ac315e..8f0f0695659f 100644 --- a/src/smartmontools/Makefile +++ b/src/smartmontools/Makefile @@ -13,7 +13,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x smartmontools_$(SMARTMONTOOLS_VERSION_FULL).dsc pushd smartmontools-$(SMARTMONTOOLS_VERSION_MAJOR) - dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $* $(DEST)/ diff --git a/src/snmpd/Makefile b/src/snmpd/Makefile index 76a62137b1ef..b66af241e5c5 100644 --- a/src/snmpd/Makefile +++ b/src/snmpd/Makefile @@ -29,7 +29,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg init stg import -s ../patch-$(SNMPD_VERSION)/series - fakeroot debian/rules -j$(SONIC_CONFIG_MAKE_JOBS) binary + dpkg-buildpackage -rfakeroot -b -d -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/socat/Makefile b/src/socat/Makefile index 50c2c8d96d2d..cc2cd7238684 100644 --- a/src/socat/Makefile +++ b/src/socat/Makefile @@ -18,7 +18,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Build source and Debian packages pushd socat-1.7.3.1 patch -p0 < ../enable_readline.patch - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -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/sonic-device-data/Makefile b/src/sonic-device-data/Makefile index 3de9c27c041d..3de98ef84b42 100644 --- a/src/sonic-device-data/Makefile +++ b/src/sonic-device-data/Makefile @@ -25,7 +25,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : done; # Build the package - dpkg-buildpackage -rfakeroot -b -us -uc + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd diff --git a/src/sonic-frr/Makefile b/src/sonic-frr/Makefile index 296f0226d2fe..4bac1e42769d 100644 --- a/src/sonic-frr/Makefile +++ b/src/sonic-frr/Makefile @@ -14,7 +14,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg branch --create $(STG_BRANCH) $(FRR_TAG) stg import -s ../patch/series tools/tarsource.sh -V -e '-sonic' - dpkg-buildpackage -rfakeroot -b -us -uc -Ppkg.frr.nortrlib -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -Ppkg.frr.nortrlib -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) stg undo || true git clean -xfdf git checkout $(FRR_BRANCH) diff --git a/src/sonic-host-service/Makefile b/src/sonic-host-service/Makefile index 53eaa4cd510a..c492c1f583ac 100644 --- a/src/sonic-host-service/Makefile +++ b/src/sonic-host-service/Makefile @@ -21,7 +21,7 @@ MAIN_TARGET = sonic-host-service_1.0.0_all.deb INSTALL := /usr/bin/install $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : - dpkg-buildpackage -us -uc -b + dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) mv ../$(MAIN_TARGET) $(DEST)/ SOURCES := $(wildcard '*.*') $(wildcard 'host_modules/*.py') diff --git a/src/swig/Makefile b/src/swig/Makefile index f9deda6a831d..2d3388eba138 100644 --- a/src/swig/Makefile +++ b/src/swig/Makefile @@ -13,7 +13,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : dpkg-source -x swig_$(SWIG_VERSION).dsc pushd ./swig-$(SWIG_VERSION) - dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/systemd-sonic-generator/Makefile b/src/systemd-sonic-generator/Makefile index 973c0d64eaed..0f911ed8a4f9 100644 --- a/src/systemd-sonic-generator/Makefile +++ b/src/systemd-sonic-generator/Makefile @@ -5,7 +5,7 @@ BINARY = systemd-sonic-generator MAIN_TARGET = $(BINARY)_1.0.0_$(CONFIGURED_ARCH).deb $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : - dpkg-buildpackage -us -uc -b + dpkg-buildpackage -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) mv ../$(MAIN_TARGET) $(DEST)/ rm ../$(BINARY)-* ../$(BINARY)_* diff --git a/src/tacacs/nss/Makefile b/src/tacacs/nss/Makefile index c133cafe9212..5fafd93b87fd 100644 --- a/src/tacacs/nss/Makefile +++ b/src/tacacs/nss/Makefile @@ -6,7 +6,7 @@ MAIN_TARGET = libnss-tacplus_$(NSS_TACPLUS_VERSION)_$(CONFIGURED_ARCH).deb GIT_APPLY = am ifneq (,$(filter $(CONFIGURED_ARCH), armhf arm64)) -# Workaround git am issue "Out of memory getdelim failed" +# Workaround git am issue "Out of memory getdelim failed" GIT_APPLY = apply endif @@ -26,7 +26,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : git $(GIT_APPLY) ../0006-fix-compiling-warning-about-token-dereference.patch git $(GIT_APPLY) ../0007-Add-support-for-TACACS-source-address.patch - dpkg-buildpackage -rfakeroot -b -us -uc + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/tacacs/pam/Makefile b/src/tacacs/pam/Makefile index 1f5213915641..503bdcb864f0 100644 --- a/src/tacacs/pam/Makefile +++ b/src/tacacs/pam/Makefile @@ -9,7 +9,7 @@ DERIVED_TARGETS = libtac2_$(PAM_TACPLUS_VERSION)_$(CONFIGURED_ARCH).deb \ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Obtain pam_tacplus rm -rf ./pam_tacplus - git clone https://github.com/jeroennijhof/pam_tacplus.git + git clone https://github.com/jeroennijhof/pam_tacplus.git pushd ./pam_tacplus git checkout -f v1.4.1 @@ -21,7 +21,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : git apply ../0005-pam-Modify-parsing-of-IP-address-and-port-number-to-.patch git apply ../0006-Add-support-for-source-ip-address.patch - dpkg-buildpackage -rfakeroot -b -us -uc + dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/thrift/Makefile b/src/thrift/Makefile index 6039b2e7cfad..2d1d4187135f 100644 --- a/src/thrift/Makefile +++ b/src/thrift/Makefile @@ -26,7 +26,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # saithrift implementation relies on the bug in union serialization # (https://jira.apache.org/jira/browse/THRIFT-3650) patch -p1 < ../patch/0001-Revert-THRIFT-3650-incorrect-union-serialization.patch - CXXFLAGS="-DFORCE_BOOST_SMART_PTR" DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -d -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) + CXXFLAGS="-DFORCE_BOOST_SMART_PTR" DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -d -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $(DERIVED_TARGETS) $* $(DEST)/ From b6de4943fc776494d564b6566a0935501f5cc2fa Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Tue, 12 Jan 2021 06:03:59 -0800 Subject: [PATCH 0038/1674] [sonic-slave]: Upgrade python lxml library version to 4.6.2 (#6404) --- sonic-slave-buster/Dockerfile.j2 | 4 ++-- sonic-slave-stretch/Dockerfile.j2 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sonic-slave-buster/Dockerfile.j2 b/sonic-slave-buster/Dockerfile.j2 index 412830f387d9..2a93c439d71c 100644 --- a/sonic-slave-buster/Dockerfile.j2 +++ b/sonic-slave-buster/Dockerfile.j2 @@ -412,8 +412,8 @@ RUN pip2 install j2cli==0.3.10 # For sonic-mgmt-framework RUN pip2 install "PyYAML==5.3.1" RUN pip3 install "PyYAML==5.3.1" -RUN pip2 install "lxml==4.6.1" -RUN pip3 install "lxml==4.6.1" +RUN pip2 install "lxml==4.6.2" +RUN pip3 install "lxml==4.6.2" # For sonic-platform-common testing RUN pip3 install redis diff --git a/sonic-slave-stretch/Dockerfile.j2 b/sonic-slave-stretch/Dockerfile.j2 index 95c294f4e4c6..53f2791e583a 100644 --- a/sonic-slave-stretch/Dockerfile.j2 +++ b/sonic-slave-stretch/Dockerfile.j2 @@ -366,8 +366,8 @@ 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.1" -RUN pip3 install "lxml==4.6.1" +RUN pip2 install "lxml==4.6.2" +RUN pip3 install "lxml==4.6.2" # For sonic-platform-common testing From 063a485982c20858657ac0695d866d7cd6a0fb8f Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Tue, 12 Jan 2021 06:04:48 -0800 Subject: [PATCH 0039/1674] [minigraph.py]: Force /32 prefix for mux cable server IPv4 loopbacks (#6418) Server IPv4 loopbacks do not always arrive with /32 prefix, which is a requirement for the MUX_CABLE table in config DB Signed-off-by: Lawrence Lee --- src/sonic-config-engine/minigraph.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 632cf060b626..1fd6b7b56e8d 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -1505,7 +1505,12 @@ def get_mux_cable_entries(mux_cable_ports, neighbors, devices): entry = {} neighbor = neighbors[intf]['name'] entry['state'] = 'auto' - entry['server_ipv4'] = devices[neighbor]['lo_addr'] + + # Always force a /32 prefix for server IPv4 loopbacks + server_ipv4_lo_addr = devices[neighbor]['lo_addr'].split("/")[0] + server_ipv4_lo_prefix = ipaddress.ip_network(UNICODE_TYPE(server_ipv4_lo_addr)) + entry['server_ipv4'] = str(server_ipv4_lo_prefix) + if 'lo_addr_v6' in devices[neighbor]: entry['server_ipv6'] = devices[neighbor]['lo_addr_v6'] mux_cable_table[intf] = entry From 6d9b05c03291deb08b01123f7dbc38f758c0f461 Mon Sep 17 00:00:00 2001 From: gechiang <62408185+gechiang@users.noreply.github.com> Date: Tue, 12 Jan 2021 09:51:15 -0800 Subject: [PATCH 0040/1674] Anchor the libprotobuf-dev version based on a fixed version by using debian control dependency (#6420) --- platform/broadcom/sai.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index 24cf07122e6b..fcb175d3d0c5 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,8 +1,8 @@ -BRCM_SAI = libsaibcm_4.2.1.5-9_amd64.deb -$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.2/master/buster/libsaibcm_4.2.1.5-9_amd64.deb?sv=2015-04-05&sr=b&sig=Rbqq%2FH4B71%2BWGzAzTuM3qxEdwpEnuxqFdGIMDpuN8t0%3D&se=2034-09-16T01%3A36%3A13Z&sp=r" -BRCM_SAI_DEV = libsaibcm-dev_4.2.1.5-9_amd64.deb +BRCM_SAI = libsaibcm_4.2.1.5-10_amd64.deb +$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.2/master/buster/libsaibcm_4.2.1.5-10_amd64.deb?sv=2019-12-12&st=2021-01-12T07%3A30%3A31Z&se=2035-01-13T07%3A30%3A00Z&sr=b&sp=r&sig=yCGwk%2FW%2Fg%2FaFxhr0oNSTZ%2BVy5B6kX1WDEsbbyz9J088%3D" +BRCM_SAI_DEV = libsaibcm-dev_4.2.1.5-10_amd64.deb $(eval $(call add_derived_package,$(BRCM_SAI),$(BRCM_SAI_DEV))) -$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.2/master/buster/libsaibcm-dev_4.2.1.5-9_amd64.deb?sv=2015-04-05&sr=b&sig=C%2Bo7YTkA2076LRfet1rHHlFu%2F6b9qoQiHljjaZCVa20%3D&se=2034-09-16T01%3A37%3A38Z&sp=r" +$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.2/master/buster/libsaibcm-dev_4.2.1.5-10_amd64.deb?sv=2019-12-12&st=2021-01-12T07%3A32%3A43Z&se=2035-01-13T07%3A32%3A00Z&sr=b&sp=r&sig=wuCNc6pa12JQCBi%2BM9rLWvVI92ldan9hKNF%2BfVfUWN8%3D" SONIC_ONLINE_DEBS += $(BRCM_SAI) $(BRCM_SAI_DEV)_DEPENDS += $(BRCM_SAI) From 4011e0f559d221e01a6b12c98fba91f16b3fb1c1 Mon Sep 17 00:00:00 2001 From: Kebo Liu Date: Wed, 13 Jan 2021 02:43:57 +0800 Subject: [PATCH 0041/1674] =?UTF-8?q?[Mellanox]=20[platform=20API]=20Fix?= =?UTF-8?q?=20=E2=80=9Clocal=20variable=20'label=5Fport'=20referenced=20be?= =?UTF-8?q?fore=20assignment=E2=80=9D=20error=20(#6419)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In rare case can see that xcvrd failed due to "UnboundLocalError: local variable 'label_port' referenced before assignment" Init "label_port" as None at the beginning of the function, to avoid the case that "label_port" not assigned. --- .../mellanox/mlnx-platform-api/sonic_platform/sfp_event.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py index 5c57e213a196..ba3ab68a9576 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py @@ -278,6 +278,7 @@ def on_pmpe(self, fd_p): port_cnt_p = new_uint32_t_p() uint32_t_p_assign(port_cnt_p,64) label_port_list = [] + label_port = None module_state = 0 rc = sx_lib_host_ifc_recv(fd_p, pkt, pkt_size_p, recv_info_p) @@ -309,9 +310,11 @@ def on_pmpe(self, fd_p): for i in range(port_cnt): port_attributes = sx_port_attributes_t_arr_getitem(port_attributes_list,i) if port_attributes.log_port == logical_port: - lable_port = port_attributes.port_mapping.module_port + label_port = port_attributes.port_mapping.module_port break - label_port_list.append(lable_port) + + if label_port is not None: + label_port_list.append(label_port) delete_uint32_t_p(pkt_size_p) delete_uint8_t_arr(pkt) From 9f89da15baaa096d65ef2f23155dcd1f20682264 Mon Sep 17 00:00:00 2001 From: guxianghong Date: Wed, 13 Jan 2021 04:36:10 +0800 Subject: [PATCH 0042/1674] [Centec] upgrade to buster docker for DOCKER_SYNCD_CENTEC_RPC, docker-saiserver-centec and platform-modules (#6423) Centec syncd have beend upgraded to buster, docker-syncd-centec-rpc do not need generate stretch based docker. Co-authored-by: Xianghong Gu --- platform/centec-arm64/docker-saiserver-centec.mk | 2 +- platform/centec-arm64/docker-syncd-centec-rpc.mk | 1 - platform/centec/docker-syncd-centec-rpc.mk | 1 - platform/centec/platform-modules-embedway.mk | 3 +-- 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/platform/centec-arm64/docker-saiserver-centec.mk b/platform/centec-arm64/docker-saiserver-centec.mk index 770b66b83233..8d1b11bf005e 100755 --- a/platform/centec-arm64/docker-saiserver-centec.mk +++ b/platform/centec-arm64/docker-saiserver-centec.mk @@ -4,7 +4,7 @@ DOCKER_SAISERVER_CENTEC = docker-saiserver-centec.gz $(DOCKER_SAISERVER_CENTEC)_PATH = $(PLATFORM_PATH)/docker-saiserver-centec $(DOCKER_SAISERVER_CENTEC)_DEPENDS += $(SAISERVER) $(DOCKER_SAISERVER_CENTEC)_FILES += $(DSSERVE) $(BCMCMD) -$(DOCKER_SAISERVER_CENTEC)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_STRETCH) +$(DOCKER_SAISERVER_CENTEC)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_BUSTER) SONIC_DOCKER_IMAGES += $(DOCKER_SAISERVER_CENTEC) $(DOCKER_SAISERVER_CENTEC)_CONTAINER_NAME = saiserver diff --git a/platform/centec-arm64/docker-syncd-centec-rpc.mk b/platform/centec-arm64/docker-syncd-centec-rpc.mk index 8d699c91347f..2c441e4fc410 100755 --- a/platform/centec-arm64/docker-syncd-centec-rpc.mk +++ b/platform/centec-arm64/docker-syncd-centec-rpc.mk @@ -12,7 +12,6 @@ $(DOCKER_SYNCD_CENTEC_RPC)_DEPENDS += $(SYNCD_RPC_DBG) \ endif $(DOCKER_SYNCD_CENTEC_RPC)_LOAD_DOCKERS += $(DOCKER_SYNCD_BASE) SONIC_DOCKER_IMAGES += $(DOCKER_SYNCD_CENTEC_RPC) -SONIC_STRETCH_DOCKERS += $(DOCKER_SYNCD_CENTEC_RPC) ifeq ($(ENABLE_SYNCD_RPC),y) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_SYNCD_CENTEC_RPC) endif diff --git a/platform/centec/docker-syncd-centec-rpc.mk b/platform/centec/docker-syncd-centec-rpc.mk index 8915f1c35679..6b912185b7da 100644 --- a/platform/centec/docker-syncd-centec-rpc.mk +++ b/platform/centec/docker-syncd-centec-rpc.mk @@ -12,7 +12,6 @@ $(DOCKER_SYNCD_CENTEC_RPC)_DEPENDS += $(SYNCD_RPC_DBG) \ endif $(DOCKER_SYNCD_CENTEC_RPC)_LOAD_DOCKERS += $(DOCKER_SYNCD_BASE) SONIC_DOCKER_IMAGES += $(DOCKER_SYNCD_CENTEC_RPC) -SONIC_STRETCH_DOCKERS += $(DOCKER_SYNCD_CENTEC_RPC) ifeq ($(ENABLE_SYNCD_RPC),y) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_SYNCD_CENTEC_RPC) endif diff --git a/platform/centec/platform-modules-embedway.mk b/platform/centec/platform-modules-embedway.mk index 366080f04114..c2ddfc327542 100644 --- a/platform/centec/platform-modules-embedway.mk +++ b/platform/centec/platform-modules-embedway.mk @@ -9,5 +9,4 @@ EMBEDWAY_ES6220_PLATFORM_MODULE = platform-modules-embedway-es6220_$(EMBEDWAY_ES $(EMBEDWAY_ES6220_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-embedway $(EMBEDWAY_ES6220_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) $(EMBEDWAY_ES6220_PLATFORM_MODULE)_PLATFORM = x86_64-ew_es6220_x48q2h4-r0 -SONIC_STRETCH_DEBS += $(EMBEDWAY_ES6220_PLATFORM_MODULE) -SONIC_DPKG_DEBS += $(EMBEDWAY_ES6220_PLATFORM_MODULE) \ No newline at end of file +SONIC_DPKG_DEBS += $(EMBEDWAY_ES6220_PLATFORM_MODULE) From d2f684b05c7e4c3e19d779462aae6b8c3fc87898 Mon Sep 17 00:00:00 2001 From: carl-nokia <63672637+carl-nokia@users.noreply.github.com> Date: Tue, 12 Jan 2021 18:05:06 -0500 Subject: [PATCH 0043/1674] [Platform][nokia]: python3-smbus package add with python3 and jinja fixes (#6416) fix platform driver breakage due to python3 upgrade and fix load minigraph errors with config load_minigraph -y **- How I did it** added python3-smbus to the pmon docker template since the previous was python2 specific fixed additional "ord" python2 specific code fixed the jinja templates used by qos reload - the template logic required data to be parsed **- How to verify it** run "show platform XXX" commands and verify output run "sudo config load_minigraph -y" and verify configuration run "show interfaces XXX" and verify output Co-authored-by: Carl Keene --- .../armhf-nokia_ixs7215_52x-r0/Nokia-7215/buffers.json.j2 | 2 ++ device/nokia/armhf-nokia_ixs7215_52x-r0/Nokia-7215/qos.json.j2 | 3 ++- dockers/docker-platform-monitor/Dockerfile.j2 | 1 + .../sonic-platform-nokia/7215/sonic_platform/sfp.py | 2 +- .../sonic-platform-nokia/7215/sonic_platform/watchdog.py | 2 +- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/device/nokia/armhf-nokia_ixs7215_52x-r0/Nokia-7215/buffers.json.j2 b/device/nokia/armhf-nokia_ixs7215_52x-r0/Nokia-7215/buffers.json.j2 index 9495a66c0d07..a38350a982bc 100644 --- a/device/nokia/armhf-nokia_ixs7215_52x-r0/Nokia-7215/buffers.json.j2 +++ b/device/nokia/armhf-nokia_ixs7215_52x-r0/Nokia-7215/buffers.json.j2 @@ -6,3 +6,5 @@ {# 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 #} +{} + diff --git a/device/nokia/armhf-nokia_ixs7215_52x-r0/Nokia-7215/qos.json.j2 b/device/nokia/armhf-nokia_ixs7215_52x-r0/Nokia-7215/qos.json.j2 index 529f1be8a545..c28e2e13e974 100644 --- a/device/nokia/armhf-nokia_ixs7215_52x-r0/Nokia-7215/qos.json.j2 +++ b/device/nokia/armhf-nokia_ixs7215_52x-r0/Nokia-7215/qos.json.j2 @@ -1 +1,2 @@ -# this file empty temporarily until qos supported SAI Marvell +{# this file empty temporarily until qos supported SAI Marvell #} +{} diff --git a/dockers/docker-platform-monitor/Dockerfile.j2 b/dockers/docker-platform-monitor/Dockerfile.j2 index b768a3c17e60..9662f7248001 100755 --- a/dockers/docker-platform-monitor/Dockerfile.j2 +++ b/dockers/docker-platform-monitor/Dockerfile.j2 @@ -21,6 +21,7 @@ RUN apt-get update && \ librrd-dev \ rrdtool \ python-smbus \ + python3-smbus \ ethtool \ dmidecode \ i2c-tools \ diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp.py index 1bf3d4c03db0..274db04ded0b 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp.py @@ -210,7 +210,7 @@ def __read_eeprom_specific_bytes(self, offset, num_bytes): sysfsfile_eeprom.seek(offset) raw = sysfsfile_eeprom.read(num_bytes) for n in range(0, num_bytes): - eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2) + eeprom_raw[n] = hex(raw[n])[2:].zfill(2) except Exception as e: pass finally: diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/watchdog.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/watchdog.py index 75ec3ab177ae..5d75a223c523 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/watchdog.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/watchdog.py @@ -15,7 +15,7 @@ """ ioctl constants """ IO_READ = 0x80000000 IO_SIZE_INT = 0x00040000 -IO_TYPE_WATCHDOG = ord('W') << 8 +IO_TYPE_WATCHDOG = 'W' << 8 WDR_INT = IO_READ | IO_SIZE_INT | IO_TYPE_WATCHDOG From 533b7cc676b1c428a99ea4f2f1199ce779641c37 Mon Sep 17 00:00:00 2001 From: dflynn-Nokia <60479697+dflynn-Nokia@users.noreply.github.com> Date: Tue, 12 Jan 2021 19:59:42 -0500 Subject: [PATCH 0044/1674] [Nokia ixs7215] Add SW assist for platform entropy & fix inband mgmt support (#6417) - Improve random number generation during early Sonic initialization by providing SW updates to Linux entropy value. - Improve handling of platform In-Band management port This commit provides the following updates to the Nokia ixs7215 platform 1. The Marvell Armada-38x SOC requires SW assistance to improve the system entropy value available early on in the Sonic boot sequence. 2. The Nokia ixs7215 platform does not have a dedicated Out-Of-Band (OOB) mgmt port and thus requires additional logic to optionally support configuring front panel port 48 as an In-Band mgmt port. This commit provides additional logic to manage and maintain the operation of this In-Band mgmt port. --- .../debian/sonic-platform-nokia-7215.install | 2 ++ .../sonic-platform-nokia/entropy.py | 19 +++++++++++++ .../sonic-platform-nokia/inband_mgmt.sh | 28 +++++++++++++++++++ .../nokia-7215_plt_setup.sh | 3 ++ 4 files changed, 52 insertions(+) create mode 100644 platform/marvell-armhf/sonic-platform-nokia/entropy.py create mode 100644 platform/marvell-armhf/sonic-platform-nokia/inband_mgmt.sh diff --git a/platform/marvell-armhf/sonic-platform-nokia/debian/sonic-platform-nokia-7215.install b/platform/marvell-armhf/sonic-platform-nokia/debian/sonic-platform-nokia-7215.install index 0b867d259f10..dc4df5540d96 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/debian/sonic-platform-nokia-7215.install +++ b/platform/marvell-armhf/sonic-platform-nokia/debian/sonic-platform-nokia-7215.install @@ -3,3 +3,5 @@ nokia-7215_plt_setup.sh usr/sbin 7215/service/nokia-7215init.service etc/systemd/system 7215/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/armhf-nokia_ixs7215_52x-r0 7215/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/armhf-nokia_ixs7215_52x-r0 +entropy.py etc/ +inband_mgmt.sh etc/ diff --git a/platform/marvell-armhf/sonic-platform-nokia/entropy.py b/platform/marvell-armhf/sonic-platform-nokia/entropy.py new file mode 100644 index 000000000000..338e2ad9bcea --- /dev/null +++ b/platform/marvell-armhf/sonic-platform-nokia/entropy.py @@ -0,0 +1,19 @@ +#!/usr/bin/python +import fcntl, struct +import time +from os import path + +RNDADDENTROPY=0x40085203 + +def avail(): + with open("/proc/sys/kernel/random/entropy_avail", mode='r') as avail: + return int(avail.read()) + +if path.exists("/proc/sys/kernel/random/entropy_avail"): + while 1: + while avail() < 2048: + with open('/dev/urandom', 'rb') as urnd, open("/dev/random", mode='wb') as rnd: + d = urnd.read(512) + t = struct.pack('ii', 4 * len(d), len(d)) + d + fcntl.ioctl(rnd, RNDADDENTROPY, t) + time.sleep(30) diff --git a/platform/marvell-armhf/sonic-platform-nokia/inband_mgmt.sh b/platform/marvell-armhf/sonic-platform-nokia/inband_mgmt.sh new file mode 100644 index 000000000000..25455d16ecbf --- /dev/null +++ b/platform/marvell-armhf/sonic-platform-nokia/inband_mgmt.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +#inband_mgmt + +inband_mgmt(){ + # In this platform, one of the network ports is used as mgmt interface. + # This script periodically monitors inband management port eth0 and + # assigns IP address to eth0 if needed. + if [ ! -f /host/machine.conf ]; then + exit 0 + fi + #wait for n/w port init to complete + sleep 60 + while :; do + ip -br link show eth0 2> /dev/null + if [ $? -eq 0 ]; then + ip address show eth0 | grep -qw "inet" 2>/dev/null + if [ $? -ne 0 ]; then + ifconfig eth0 down + systemctl restart networking + fi + sleep 120 + else + sleep 3 + fi + done +} +(inband_mgmt > /dev/null)& diff --git a/platform/marvell-armhf/sonic-platform-nokia/nokia-7215_plt_setup.sh b/platform/marvell-armhf/sonic-platform-nokia/nokia-7215_plt_setup.sh index e4fc716cf5a5..8301999d0d0a 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/nokia-7215_plt_setup.sh +++ b/platform/marvell-armhf/sonic-platform-nokia/nokia-7215_plt_setup.sh @@ -30,6 +30,9 @@ main() { fw_uboot_env_cfg echo "Nokia-IXS7215: /dev/mtd0 FW_ENV_DEFAULT" + + python /etc/entropy.py & + /bin/sh /etc/inband_mgmt.sh } main $@ From ef16128ce8b0eab60f96f9f90732a4362651b2d9 Mon Sep 17 00:00:00 2001 From: xumia <59720581+xumia@users.noreply.github.com> Date: Wed, 13 Jan 2021 18:40:39 +0800 Subject: [PATCH 0045/1674] Fix py3 version changed even version control enabled issue (#6422) * Fix py3 version changed even version control enabled issue * Add some comments and simplify the script * Add the comment to explain how to get the not hooked command --- src/sonic-build-hooks/scripts/buildinfo_base.sh | 7 ++++++- src/sonic-build-hooks/scripts/symlink_build_hooks | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sonic-build-hooks/scripts/buildinfo_base.sh b/src/sonic-build-hooks/scripts/buildinfo_base.sh index d19558c544e3..94b767861467 100755 --- a/src/sonic-build-hooks/scripts/buildinfo_base.sh +++ b/src/sonic-build-hooks/scripts/buildinfo_base.sh @@ -22,15 +22,20 @@ log_err() echo "$1" 1>&2 } +# Get the real command not hooked by sonic-build-hook package get_command() { - local path=$(echo $PATH | sed 's#[^:]*buildinfo/scripts:##' | sed "s#/usr/sbin:##") + # Change the PATH env to get the real command by excluding the command in the hooked folders + local path=$(echo $PATH | sed 's#[^:]*buildinfo/scripts:##' | sed "s#/usr/local/sbin:##") local command=$(PATH=$path which $1) echo $command } check_version_control() { + # The env variable SONIC_VERSION_CONTROL_COMPONENTS examples: + # all -- match all components + # py2,py3,deb -- match py2, py3 and deb only if [[ ",$SONIC_VERSION_CONTROL_COMPONENTS," == *,all,* ]] || [[ ",$SONIC_VERSION_CONTROL_COMPONENTS," == *,$1,* ]]; then echo "y" else diff --git a/src/sonic-build-hooks/scripts/symlink_build_hooks b/src/sonic-build-hooks/scripts/symlink_build_hooks index 7218575ee9ab..2ce5ec27720f 100755 --- a/src/sonic-build-hooks/scripts/symlink_build_hooks +++ b/src/sonic-build-hooks/scripts/symlink_build_hooks @@ -1,7 +1,7 @@ #!/bin/bash HOOK_PATH=/usr/local/share/buildinfo/hooks -TARGET_PATH=/usr/sbin +TARGET_PATH=/usr/local/sbin FILES=$(ls $HOOK_PATH) usage() From 7a102cd785a87ec8a143e97895341de568113f5a Mon Sep 17 00:00:00 2001 From: Vadym Hlushko <62022266+vadymhlushko-mlnx@users.noreply.github.com> Date: Wed, 13 Jan 2021 15:45:05 +0200 Subject: [PATCH 0046/1674] [SN4410] fixed 'port_config.ini' (#6316) Signed-off-by: Vadym Hlushko --- .../ACS-MSN4410/port_config.ini | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) mode change 120000 => 100644 device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/port_config.ini 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 deleted file mode 120000 index 606b074c20e8..000000000000 --- a/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/port_config.ini +++ /dev/null @@ -1 +0,0 @@ -../../x86_64-mlnx_msn4700-r0/ACS-MSN4700/port_config.ini \ No newline at end of file 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 new file mode 100644 index 000000000000..5b76c3a59d40 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/port_config.ini @@ -0,0 +1,33 @@ +# name lanes alias index +Ethernet0 0,1,2,3 etp1 1 +Ethernet8 8,9,10,11 etp2 2 +Ethernet16 16,17,18,19 etp3 3 +Ethernet24 24,25,26,27 etp4 4 +Ethernet32 32,33,34,35 etp5 5 +Ethernet40 40,41,42,43 etp6 6 +Ethernet48 48,49,50,51 etp7 7 +Ethernet56 56,57,58,59 etp8 8 +Ethernet64 64,65,66,67 etp9 9 +Ethernet72 72,73,74,75 etp10 10 +Ethernet80 80,81,82,83 etp11 11 +Ethernet88 88,89,90,91 etp12 12 +Ethernet96 96,97,98,99 etp13 13 +Ethernet104 104,105,106,107 etp14 14 +Ethernet112 112,113,114,115 etp15 15 +Ethernet120 120,121,122,123 etp16 16 +Ethernet128 128,129,130,131 etp17 17 +Ethernet136 136,137,138,139 etp18 18 +Ethernet144 144,145,146,147 etp19 19 +Ethernet152 152,153,154,155 etp20 20 +Ethernet160 160,161,162,163 etp21 21 +Ethernet168 168,169,170,171 etp22 22 +Ethernet176 176,177,178,179 etp23 23 +Ethernet184 184,185,186,187 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 \ No newline at end of file From e6a78b65c5ba3b6789477c91741a86f4b7913e73 Mon Sep 17 00:00:00 2001 From: Samuel Angebault Date: Wed, 13 Jan 2021 08:32:22 -0800 Subject: [PATCH 0047/1674] Update swi-tools in buster Dockerfile (#6414) Fixed swi-tools code to work with `python3` Updated the version of swi-tools downloaded by the `sonic-slave-buster/Dockerfile.j2` Other Dockerfiles still use the `python2` version, though swi-tools is not used within the stretch builder. --- sonic-slave-buster/Dockerfile.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonic-slave-buster/Dockerfile.j2 b/sonic-slave-buster/Dockerfile.j2 index 2a93c439d71c..b372e3e28636 100644 --- a/sonic-slave-buster/Dockerfile.j2 +++ b/sonic-slave-buster/Dockerfile.j2 @@ -479,7 +479,7 @@ RUN update-alternatives --set iptables /usr/sbin/iptables-legacy RUN pip2 install m2crypto==0.36.0 # Install swi tools -RUN pip2 install git+https://github.com/aristanetworks/swi-tools.git@d51761ec0bb93c73039233f3c01ed48235ffad00 +RUN pip3 install git+https://github.com/aristanetworks/swi-tools.git@bead66bf261770237f7dd21ace3774ba04a017e9 {% if CONFIGURED_ARCH != "amd64" -%} # Install node.js for azure pipeline From 78ca4d1c1a82a70eb2aefc75ce4b297bbfaeb646 Mon Sep 17 00:00:00 2001 From: Junchao-Mellanox <57339448+Junchao-Mellanox@users.noreply.github.com> Date: Thu, 14 Jan 2021 01:42:04 +0800 Subject: [PATCH 0048/1674] [Mellanox] Fix issue: need import initialize_sdk_handle in get_sdk_handle (#6435) Found test_sfp.py failed due to use a method without importing it. --- platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py b/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py index c1d93b8ffdac..b5ca79286d1f 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py @@ -113,7 +113,6 @@ def initialize_fan(self): def initialize_sfp(self): from sonic_platform.sfp import SFP - from sonic_platform.sfp import initialize_sdk_handle self.sfp_module = SFP @@ -137,6 +136,7 @@ def initialize_sfp(self): def get_sdk_handle(self): if not self.sdk_handle: + from sonic_platform.sfp import initialize_sdk_handle self.sdk_handle = initialize_sdk_handle() if self.sdk_handle is None: logger.log_error('Failed to open SDK handle') From 43c25d6283b8f7af52cbeb17558f855531a30516 Mon Sep 17 00:00:00 2001 From: Vaibhav Hemant Dixit Date: Wed, 13 Jan 2021 10:18:17 -0800 Subject: [PATCH 0049/1674] [sonic-swss-common] Advance swss-common head to include General Protection error fix (#6436) To include Kernel GP fault seen in *syncd processes: Azure/sonic-swss-common#444 --- src/sonic-swss-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-swss-common b/src/sonic-swss-common index 71dc350d94a9..2db7bea9963a 160000 --- a/src/sonic-swss-common +++ b/src/sonic-swss-common @@ -1 +1 @@ -Subproject commit 71dc350d94a93a6a13bbcec9d9723809e4d3bae2 +Subproject commit 2db7bea9963a988a575b8075e1f6c5369d057230 From e6de7d32863879acfadcc3abcec99ca62876dfc5 Mon Sep 17 00:00:00 2001 From: Kalimuthu-Velappan <53821802+Kalimuthu-Velappan@users.noreply.github.com> Date: Thu, 14 Jan 2021 00:02:42 +0530 Subject: [PATCH 0050/1674] [build]: Fix for missing dependencies in the DPKG framework (#6393) 1. Fixes the missing DPKG file for gbsyncd-vs package 2. Fixes the softlink issue on the Platform-common and ztp package 3. Fixes the PYTHNON_DEBS list is missing for DBG dockers. --- platform/vs/rules.dep | 1 + rules/functions | 1 + rules/sonic-platform-common.dep | 2 +- rules/sonic-ztp.dep | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/platform/vs/rules.dep b/platform/vs/rules.dep index 7d36c819509e..7a5346619e70 100644 --- a/platform/vs/rules.dep +++ b/platform/vs/rules.dep @@ -2,6 +2,7 @@ include $(PLATFORM_PATH)/syncd-vs.dep include $(PLATFORM_PATH)/sonic-version.dep include $(PLATFORM_PATH)/docker-sonic-vs.dep include $(PLATFORM_PATH)/docker-syncd-vs.dep +include $(PLATFORM_PATH)/docker-gbsyncd-vs.dep include $(PLATFORM_PATH)/one-image.dep include $(PLATFORM_PATH)/onie.dep include $(PLATFORM_PATH)/kvm-image.dep diff --git a/rules/functions b/rules/functions index 5ccb111cec72..35b63aeabaf7 100644 --- a/rules/functions +++ b/rules/functions @@ -117,6 +117,7 @@ define add_dbg_docker $(2)_PATH = $($(1)_PATH) $(2)_DBG_DEPENDS += $($(1)_DBG_DEPENDS) $(2)_DBG_IMAGE_PACKAGES += $($(1)_DBG_IMAGE_PACKAGES) +$(2)_PYTHON_DEBS += $($(1)_PYTHON_DEBS) $(2)_PYTHON_WHEELS += $($(1)_PYTHON_WHEELS) $(2)_LOAD_DOCKERS += $($(1)_LOAD_DOCKERS) $(2)_CACHE_MODE += $($(1)_CACHE_MODE) diff --git a/rules/sonic-platform-common.dep b/rules/sonic-platform-common.dep index f93240135988..e921c4df01af 100644 --- a/rules/sonic-platform-common.dep +++ b/rules/sonic-platform-common.dep @@ -2,7 +2,7 @@ SPATH := $($(SONIC_PLATFORM_COMMON_PY2)_SRC_PATH) DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/sonic-platform-common.mk rules/sonic-platform-common.dep DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) -SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files|grep -Ev "sonic_sfp|sonic_eeprom")) +SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files|grep -Ev "^sonic_sfp|^sonic_eeprom")) $(SONIC_PLATFORM_COMMON_PY2)_CACHE_MODE := GIT_CONTENT_SHA $(SONIC_PLATFORM_COMMON_PY2)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) diff --git a/rules/sonic-ztp.dep b/rules/sonic-ztp.dep index 32890c5d74b6..bf6622ddb505 100644 --- a/rules/sonic-ztp.dep +++ b/rules/sonic-ztp.dep @@ -2,7 +2,7 @@ SPATH := $($(SONIC_ZTP)_SRC_PATH) DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/sonic-ztp.mk rules/sonic-ztp.dep DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) -SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files|grep -Ev "inband-ztp-ip|dhclient-exit-hooks.d/ztp")) +SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files|grep -Ev "dhclient-enter-hooks.d|dhclient-exit-hooks.d")) $(SONIC_ZTP)_CACHE_MODE := GIT_CONTENT_SHA From b94e2fd676113b22c749458ef1348187a0410306 Mon Sep 17 00:00:00 2001 From: Kebo Liu Date: Thu, 14 Jan 2021 07:18:05 +0800 Subject: [PATCH 0051/1674] [sonic-linux-kernel]: Update sonic-linux-kernel submodule (#6433) Update sonic-linux-kernel pointer to pick up new commits: - Backport patches to increase critical threshold for ASIC and validate transceiver temperature a7c1af7c44edde90dff49d672071139043bcdb65 https://github.com/Azure/sonic-linux-kernel/commit/548e8e0be49692050ea4071d5e9945816bc5aacc - [ci]: Set up CI with Azure Pipelines 548e8e0be49692050ea4071d5e9945816bc5aacc https://github.com/Azure/sonic-linux-kernel/commit/a7c1af7c44edde90dff49d672071139043bcdb65 Signed-off-by: Kebo Liu --- src/sonic-linux-kernel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-linux-kernel b/src/sonic-linux-kernel index 6f53047ae257..548e8e0be496 160000 --- a/src/sonic-linux-kernel +++ b/src/sonic-linux-kernel @@ -1 +1 @@ -Subproject commit 6f53047ae2579ca406fe48983d704a2c8a43f68b +Subproject commit 548e8e0be49692050ea4071d5e9945816bc5aacc From bd5147bbed769db9d37fea8e97f29d31f966aede Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 14 Jan 2021 00:29:21 -0800 Subject: [PATCH 0052/1674] [swss] Depend on Python 3 version of swsscommon rather than Python 2 (#6432) The only Python code in the SwSS package, restore_neighbors.py, was recently converted to Python 3 and most dependencies were updated as part of #6207. However, the SwSS makefile still listed the Python 2 version of the swsscommon package as a dependency. This caused Python 2-related packages to be installed in containers unnecessarily. --- rules/swss.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/swss.mk b/rules/swss.mk index 210333614555..e4d18cf2eb3d 100644 --- a/rules/swss.mk +++ b/rules/swss.mk @@ -8,7 +8,7 @@ $(SWSS)_DEPENDS += $(LIBSAIREDIS_DEV) $(LIBSAIMETADATA_DEV) $(LIBTEAM_DEV) \ $(SWSS)_UNINSTALLS = $(LIBSAIVS_DEV) $(SWSS)_RDEPENDS += $(LIBSAIREDIS) $(LIBSAIMETADATA) $(LIBTEAM) \ - $(LIBTEAMDCTL) $(LIBSWSSCOMMON) $(PYTHON_SWSSCOMMON) + $(LIBTEAMDCTL) $(LIBSWSSCOMMON) $(PYTHON3_SWSSCOMMON) SONIC_DPKG_DEBS += $(SWSS) SWSS_DBG = swss-dbg_1.0.0_$(CONFIGURED_ARCH).deb From 80c1926aa22ef7042a4fc96d32ad259330a05cf0 Mon Sep 17 00:00:00 2001 From: Stepan Blyshchak <38952541+stepanblyschak@users.noreply.github.com> Date: Thu, 14 Jan 2021 10:34:34 +0200 Subject: [PATCH 0053/1674] [snmpagent] update submodule (#6169) Includes below sonic-snmpagent commits ``` dfde06e 2021-01-13 | Revert "[rfc1213] Interface MIB add l3 vlan interfaces & aggregate rif counters (#169)" (#191) [Stepan Blyshchak] 45edd7e 2021-01-04 | [snmpagent] Fix hardcoded qsfp lane count by reading sensor status from DB (#184) [Junchao-Mellanox] 3b72a6f 2021-01-02 | Fix: handle empty LOC_CHASSIS_TABLE (#190) [Qi Luo] 4aad821 2020-12-29 | [sysName]: Implement sysName OID (#185) [SuvarnaMeenakshi] 8efb4bb 2020-12-29 | [rfc1213] fix counter value type (#189) [Stepan Blyshchak] 025483a 2020-12-23 | [RouteUpdater]: Fix multi_asic mock function implementation and multi_asic variable name (#186) [SuvarnaMeenakshi] 381ae47 2020-12-10 | [mibs] b'VLAN_TABLE:' -> 'VLAN_TABLE' (#181) [Stepan Blyshchak] e54036c 2020-12-09 | [rfc1213] Interface MIB add l3 vlan interfaces & aggregate rif counters (#169) [Stepan Blyshchak] fd1eae7 2020-11-24 | Set swsscommon logging level (#178) [Qi Luo] 706d504 2020-11-23 | Improve MockRedis _encode(): so it will work on all types of value (#179) [Qi Luo] 64c93a1 2020-11-16 | [RFC4292][Namespace]: Fix implementation of RouteUpdater for multi-asic platform (#176) [SuvarnaMeenakshi] b8f19ee 2020-11-12 | [sonic-snmpagent] SONiC physical entity mib extension (#168) [Junchao-Mellanox] 6b94ec3 2020-11-05 | Replace swsssdk.SonicV2Connector with swsscommon.SonicV2Connector (SWIG wrapper of C++ implementation) in production code (#162) [Qi Luo] ``` Signed-off-by: Stepan Blyshchak Co-authored-by: Qi Luo --- src/sonic-snmpagent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-snmpagent b/src/sonic-snmpagent index 57e54d956193..dfde06e2f5d7 160000 --- a/src/sonic-snmpagent +++ b/src/sonic-snmpagent @@ -1 +1 @@ -Subproject commit 57e54d9561934b853a44185bbb401207f4503292 +Subproject commit dfde06e2f5d70e23882af6c0f1af4ae43ec2fa43 From 238ff9f289b255212393e12e2a75b19377dc0d5d Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 14 Jan 2021 10:26:15 -0800 Subject: [PATCH 0054/1674] [sonic-platform-common] Enable pytest during build for Python 3 package (#6442) **- Why I did it** To enable running Pytest unit tests before building the Python 3 sonic-platform-common package **- How I did it** - Add Python 3 sonic-config-engine package as a dependency of Python 3 sonic-platform-common package (needed for both runtime and unit tests) - No longer disable unit tests when building Python 3 sonic-platform-common package --- rules/sonic-platform-common.mk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rules/sonic-platform-common.mk b/rules/sonic-platform-common.mk index a734abfd6d72..b3dd0155d59e 100644 --- a/rules/sonic-platform-common.mk +++ b/rules/sonic-platform-common.mk @@ -10,8 +10,7 @@ SONIC_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY2) SONIC_PLATFORM_COMMON_PY3 = sonic_platform_common-1.0-py3-none-any.whl $(SONIC_PLATFORM_COMMON_PY3)_SRC_PATH = $(SRC_PATH)/sonic-platform-common $(SONIC_PLATFORM_COMMON_PY3)_PYTHON_VERSION = 3 -$(SONIC_PLATFORM_COMMON_PY3)_DEPENDS += $(SONIC_PY_COMMON_PY3) +$(SONIC_PLATFORM_COMMON_PY3)_DEPENDS += $(SONIC_PY_COMMON_PY3) $(SONIC_CONFIG_ENGINE_PY3) # Synthetic dependency just to avoid race condition $(SONIC_PLATFORM_COMMON_PY3)_DEPENDS += $(SONIC_PLATFORM_COMMON_PY2) -$(SONIC_PLATFORM_COMMON_PY3)_TEST = n SONIC_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY3) From cd8417afd73209de75c83e33679941ce1a66f293 Mon Sep 17 00:00:00 2001 From: pavel-shirshov Date: Thu, 14 Jan 2021 11:09:16 -0800 Subject: [PATCH 0055/1674] [docker-frr]: Use egrep with regexp to match correct TSA rules (#6403) **- Why I did it** Earlier today we found a bug in the SONiC TSA implementation. TSC shows incorrect output (see below) in case we have a route-map which contains TSA route-map as a prefix. ``` admin@str-s6100-acs-1:~$ TSC Traffic Shift Check: System Mode: Not consistent ``` The reason is that TSC implementation has too loose regexps in TSA utilities, which match wrong route-map entries: For example, current TSC matches following ``` route-map TO_BGP_PEER_V4 permit 200 route-map TO_BGP_PEER_V6 permit 200 ``` But it should match only ``` route-map TO_BGP_PEER_V4 permit 20 route-map TO_BGP_PEER_V4 deny 30 route-map TO_BGP_PEER_V6 permit 20 route-map TO_BGP_PEER_V6 deny 30 ``` **- How I did it** I fixed it by using egrep with `^` and `$` regexp markers which match begin and end of the line. **- How to verify it** 1. Add follwing entry to FRR config: ``` str-s6100-acs-1# str-s6100-acs-1# conf t str-s6100-acs-1(config)# route-map TO_BGP_PEER_V4 permit 200 str-s6100-acs-1(config-route-map)# end ``` 2. Use the TSC command and check output. It should show normal. ``` admin@str-s6100-acs-1:~$ TSC Traffic Shift Check: System Mode: Normal``` --- dockers/docker-fpm-frr/TSA | 4 ++-- dockers/docker-fpm-frr/TSB | 4 ++-- dockers/docker-fpm-frr/TSC | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dockers/docker-fpm-frr/TSA b/dockers/docker-fpm-frr/TSA index 81816b99db40..524e4297d1c0 100755 --- a/dockers/docker-fpm-frr/TSA +++ b/dockers/docker-fpm-frr/TSA @@ -6,9 +6,9 @@ function check_not_installed() config=$(vtysh -c "show run") for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p'); do - echo "$config" | grep -q "route-map $route_map_name permit 20" + echo "$config" | egrep -q "^route-map $route_map_name permit 20$" c=$((c+$?)) - echo "$config" | grep -q "route-map $route_map_name deny 30" + echo "$config" | egrep -q "^route-map $route_map_name deny 30$" c=$((c+$?)) done return $c diff --git a/dockers/docker-fpm-frr/TSB b/dockers/docker-fpm-frr/TSB index b7eac390cf46..8592ad76cf69 100755 --- a/dockers/docker-fpm-frr/TSB +++ b/dockers/docker-fpm-frr/TSB @@ -7,10 +7,10 @@ function check_installed() config=$(vtysh -c "show run") for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p'); do - echo "$config" | grep -q "route-map $route_map_name permit 20" + echo "$config" | egrep -q "^route-map $route_map_name permit 20$" c=$((c+$?)) e=$((e+1)) - echo "$config" | grep -q "route-map $route_map_name deny 30" + echo "$config" | egrep -q "^route-map $route_map_name deny 30$" c=$((c+$?)) e=$((e+1)) done diff --git a/dockers/docker-fpm-frr/TSC b/dockers/docker-fpm-frr/TSC index 5e7d579fc4a2..c7fd8a2ff157 100755 --- a/dockers/docker-fpm-frr/TSC +++ b/dockers/docker-fpm-frr/TSC @@ -6,9 +6,9 @@ function check_not_installed() config=$(vtysh -c "show run") for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6'); do - echo "$config" | grep -q "route-map $route_map_name permit 20" + echo "$config" | egrep -q "^route-map $route_map_name permit 20$" c=$((c+$?)) - echo "$config" | grep -q "route-map $route_map_name deny 30" + echo "$config" | egrep -q "^route-map $route_map_name deny 30$" c=$((c+$?)) done return $c @@ -21,10 +21,10 @@ function check_installed() config=$(vtysh -c "show run") for route_map_name in $(echo "$config" | sed -ne 's/ neighbor \S* route-map \(\S*\) out/\1/p' | egrep 'V4|V6'); do - echo "$config" | grep -q "route-map $route_map_name permit 20" + echo "$config" | egrep -q "^route-map $route_map_name permit 20$" c=$((c+$?)) e=$((e+1)) - echo "$config" | grep -q "route-map $route_map_name deny 30" + echo "$config" | egrep -q "^route-map $route_map_name deny 30$" c=$((c+$?)) e=$((e+1)) done From a1951ea1983ddf1d7ffd485392a8deddb7e025e2 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Fri, 15 Jan 2021 07:48:11 -0800 Subject: [PATCH 0056/1674] [warm boot finalizer] only wait for enabled components to reconcile (#6454) * [warm boot finalizer] only wait for enabled components to reconcile Define the component with its associated service. Only wait for components that have associated service enabled to reconcile during warm reboot. Signed-off-by: Ying Xie --- .../warmboot-finalizer/finalize-warmboot.sh | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/files/image_config/warmboot-finalizer/finalize-warmboot.sh b/files/image_config/warmboot-finalizer/finalize-warmboot.sh index 094fff2133f7..172fd95ab2e9 100755 --- a/files/image_config/warmboot-finalizer/finalize-warmboot.sh +++ b/files/image_config/warmboot-finalizer/finalize-warmboot.sh @@ -2,8 +2,15 @@ VERBOSE=no -# Check components -COMP_LIST="orchagent neighsyncd bgp natsyncd" +# Define components that needs to reconcile during warm +# boot: +# The key is the name of the service that the components belong to. +# The value is list of component names that will reconcile. +declare -A RECONCILE_COMPONENTS=( \ + ["swss"]="orchagent neighsyncd" \ + ["bgp"]="bgp" \ + ["nat"]="natsyncd" \ + ) EXP_STATE="reconciled" ASSISTANT_SCRIPT="/usr/local/bin/neighbor_advertiser" @@ -18,6 +25,20 @@ function debug() } +function get_component_list() +{ + SVC_LIST=${!RECONCILE_COMPONENTS[@]} + COMPONENT_LIST="" + for service in ${SVC_LIST}; do + components=${RECONCILE_COMPONENTS[${service}]} + status=$(sonic-db-cli CONFIG_DB HGET "FEATURE|${service}" state) + if [[ x"${status}" == x"enabled" || x"${status}" == x"always_enabled" ]]; then + COMPONENT_LIST="${COMPONENT_LIST} ${components}" + fi + done +} + + function check_warm_boot() { WARM_BOOT=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable` @@ -53,9 +74,9 @@ function check_list() RET_LIST='' for comp in $@; do state=`get_component_state ${comp}` - if [[ x"${state}" != x"${EXP_STATE}" ]]; then + if [[ x"${state}" != x"${EXP_STATE}" ]]; then RET_LIST="${RET_LIST} ${comp}" - fi + fi done echo ${RET_LIST} @@ -102,13 +123,17 @@ fi restore_counters_folder -list=${COMP_LIST} +get_component_list + +debug "Waiting for components: '${COMPONENT_LIST}' to reconcile ..." + +list=${COMPONENT_LIST} # Wait up to 5 minutes for i in `seq 60`; do list=`check_list ${list}` if [[ -z "${list}" ]]; then - break + break fi sleep 5 done From ed0ac08e449d599f472b3b0f4007e872e8b55323 Mon Sep 17 00:00:00 2001 From: Junchao-Mellanox <57339448+Junchao-Mellanox@users.noreply.github.com> Date: Sat, 16 Jan 2021 00:00:15 +0800 Subject: [PATCH 0057/1674] [Mellanox] PSU and module thermals are no longer child of chassis (#6460) In order to build up device hierachy, PSU and module thermals are no longer child of chassis. PSU thermal belongs to PSU objects and SFP thermals belong to SFP object now. Need align this change in platform.json. Move thermal objects to correct parent device --- .../x86_64-mlnx_msn2700-r0/platform.json | 338 +++++++++++------- 1 file changed, 203 insertions(+), 135 deletions(-) diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/platform.json b/device/mellanox/x86_64-mlnx_msn2700-r0/platform.json index cdb3e52fd682..38abbc40bb49 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/platform.json +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/platform.json @@ -75,13 +75,23 @@ { "name": "psu_1_fan_1" } + ], + "thermals": [ + { + "name": "PSU-1 Temp" + } ] }, { "name": "PSU 2", "fans": [ { - "name": "psu_2_fan_1" + "name": "PSU-2 Temp" + } + ], + "thermals": [ + { + "name": "xSFP module 1 Temp" } ] } @@ -104,206 +114,264 @@ }, { "name": "CPU Pack Temp" - }, - { - "name": "PSU-1 Temp" - }, - { - "name": "PSU-2 Temp" - }, - { - "name": "xSFP module 1 Temp" - }, - { - "name": "xSFP module 2 Temp" - }, - { - "name": "xSFP module 3 Temp" - }, - { - "name": "xSFP module 4 Temp" - }, - { - "name": "xSFP module 5 Temp" - }, - { - "name": "xSFP module 6 Temp" - }, - { - "name": "xSFP module 7 Temp" - }, - { - "name": "xSFP module 8 Temp" - }, - { - "name": "xSFP module 9 Temp" - }, - { - "name": "xSFP module 10 Temp" - }, - { - "name": "xSFP module 11 Temp" - }, - { - "name": "xSFP module 12 Temp" - }, - { - "name": "xSFP module 13 Temp" - }, - { - "name": "xSFP module 14 Temp" - }, - { - "name": "xSFP module 15 Temp" - }, - { - "name": "xSFP module 16 Temp" - }, - { - "name": "xSFP module 17 Temp" - }, - { - "name": "xSFP module 18 Temp" - }, - { - "name": "xSFP module 19 Temp" - }, - { - "name": "xSFP module 20 Temp" - }, - { - "name": "xSFP module 21 Temp" - }, - { - "name": "xSFP module 22 Temp" - }, - { - "name": "xSFP module 23 Temp" - }, - { - "name": "xSFP module 24 Temp" - }, - { - "name": "xSFP module 25 Temp" - }, - { - "name": "xSFP module 26 Temp" - }, - { - "name": "xSFP module 27 Temp" - }, - { - "name": "xSFP module 28 Temp" - }, - { - "name": "xSFP module 29 Temp" - }, - { - "name": "xSFP module 30 Temp" - }, - { - "name": "xSFP module 31 Temp" - }, - { - "name": "xSFP module 32 Temp" } ], "sfps": [ { - "name": "sfp1" + "name": "sfp1", + "thermals": [ + { + "name": "xSFP module 1 Temp" + } + ] }, { - "name": "sfp2" + "name": "sfp2", + "thermals": [ + { + "name": "xSFP module 2 Temp" + } + ] }, { - "name": "sfp3" + "name": "sfp3", + "thermals": [ + { + "name": "xSFP module 3 Temp" + } + ] }, { - "name": "sfp4" + "name": "sfp4", + "thermals": [ + { + "name": "xSFP module 4 Temp" + } + ] }, { - "name": "sfp5" + "name": "sfp5", + "thermals": [ + { + "name": "xSFP module 5 Temp" + } + ] }, { - "name": "sfp6" + "name": "sfp6", + "thermals": [ + { + "name": "xSFP module 6 Temp" + } + ] }, { - "name": "sfp7" + "name": "sfp7", + "thermals": [ + { + "name": "xSFP module 7 Temp" + } + ] }, { - "name": "sfp8" + "name": "sfp8", + "thermals": [ + { + "name": "xSFP module 8 Temp" + } + ] }, { - "name": "sfp9" + "name": "sfp9", + "thermals": [ + { + "name": "xSFP module 9 Temp" + } + ] }, { - "name": "sfp10" + "name": "sfp10", + "thermals": [ + { + "name": "xSFP module 10 Temp" + } + ] }, { - "name": "sfp11" + "name": "sfp11", + "thermals": [ + { + "name": "xSFP module 11 Temp" + } + ] }, { - "name": "sfp12" + "name": "sfp12", + "thermals": [ + { + "name": "xSFP module 12 Temp" + } + ] }, { - "name": "sfp13" + "name": "sfp13", + "thermals": [ + { + "name": "xSFP module 13 Temp" + } + ] }, { - "name": "sfp14" + "name": "sfp14", + "thermals": [ + { + "name": "xSFP module 14 Temp" + } + ] }, { - "name": "sfp15" + "name": "sfp15", + "thermals": [ + { + "name": "xSFP module 15 Temp" + } + ] }, { - "name": "sfp16" + "name": "sfp16", + "thermals": [ + { + "name": "xSFP module 16 Temp" + } + ] }, { - "name": "sfp17" + "name": "sfp17", + "thermals": [ + { + "name": "xSFP module 17 Temp" + } + ] }, { - "name": "sfp18" + "name": "sfp18", + "thermals": [ + { + "name": "xSFP module 18 Temp" + } + ] }, { - "name": "sfp19" + "name": "sfp19", + "thermals": [ + { + "name": "xSFP module 19 Temp" + } + ] }, { - "name": "sfp20" + "name": "sfp20", + "thermals": [ + { + "name": "xSFP module 20 Temp" + } + ] }, { - "name": "sfp21" + "name": "sfp21", + "thermals": [ + { + "name": "xSFP module 21 Temp" + } + ] }, { - "name": "sfp22" + "name": "sfp22", + "thermals": [ + { + "name": "xSFP module 22 Temp" + } + ] }, { - "name": "sfp23" + "name": "sfp23", + "thermals": [ + { + "name": "xSFP module 23 Temp" + } + ] }, { - "name": "sfp24" + "name": "sfp24", + "thermals": [ + { + "name": "xSFP module 24 Temp" + } + ] }, { - "name": "sfp25" + "name": "sfp25", + "thermals": [ + { + "name": "xSFP module 25 Temp" + } + ] }, { - "name": "sfp26" + "name": "sfp26", + "thermals": [ + { + "name": "xSFP module 26 Temp" + } + ] }, { - "name": "sfp27" + "name": "sfp27", + "thermals": [ + { + "name": "xSFP module 27 Temp" + } + ] }, { - "name": "sfp28" + "name": "sfp28", + "thermals": [ + { + "name": "xSFP module 28 Temp" + } + ] }, { - "name": "sfp29" + "name": "sfp29", + "thermals": [ + { + "name": "xSFP module 29 Temp" + } + ] }, { - "name": "sfp30" + "name": "sfp30", + "thermals": [ + { + "name": "xSFP module 30 Temp" + } + ] }, { - "name": "sfp31" + "name": "sfp31", + "thermals": [ + { + "name": "xSFP module 31 Temp" + } + ] }, { - "name": "sfp32" + "name": "sfp32", + "thermals": [ + { + "name": "xSFP module 32 Temp" + } + ] } ] }, From 21d4df3dcdbc5175ff5cc8c77c8cfbd878249622 Mon Sep 17 00:00:00 2001 From: Kebo Liu Date: Sat, 16 Jan 2021 00:01:11 +0800 Subject: [PATCH 0058/1674] [mellanox][platform api] fix a missing import time module (#6458) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit “time" module was missed to be imported and will cause an error when the branch hit. Signed-off-by: Kebo Liu --- platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py b/platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py index b2e588a63557..ef13bbd89e27 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py @@ -8,6 +8,7 @@ import os import sys import re +import time if sys.version_info.major == 3: from io import StringIO From 4f6e16107975e9dd30379f0ff909ea769af5f1ce Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Fri, 15 Jan 2021 08:03:47 -0800 Subject: [PATCH 0059/1674] [minigraph.py]: Check for empty cluster tag before parsing (#6440) Some non-production minigraphs will have an empty ClusterName tag Signed-off-by: Lawrence Lee --- src/sonic-config-engine/minigraph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 1fd6b7b56e8d..8b9794f2bfb8 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -255,7 +255,7 @@ def parse_png(png, hname, dpg_ecmp_content = None): if name == hname: cluster = device.find(str(QName(ns, "ClusterName"))) - if cluster != None and "str" in cluster.text.lower(): + if cluster != None and cluster.text != None and "str" in cluster.text.lower(): is_storage_device = True if child.tag == str(QName(ns, "DeviceInterfaceLinks")): From 29562d0a4b866b42b36d9fd2a0ad7a94fccada61 Mon Sep 17 00:00:00 2001 From: Roy Lee Date: Sat, 16 Jan 2021 00:06:21 +0800 Subject: [PATCH 0060/1674] [device/accton]: As7816-64x, fix memory leakage on accton fan monitor. (#6168) It's been reported that accton fan monitor process keeps consuming memory after few days. The amount of memory occupied increases in linear and never leased. Signed-off-by: roy_lee --- .../as7816-64x/utils/accton_as7816_monitor.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7816-64x/utils/accton_as7816_monitor.py b/platform/broadcom/sonic-platform-modules-accton/as7816-64x/utils/accton_as7816_monitor.py index a8dcba0f77db..217351ad2a3c 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7816-64x/utils/accton_as7816_monitor.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7816-64x/utils/accton_as7816_monitor.py @@ -54,6 +54,9 @@ class accton_as7816_monitor(object): def __init__(self, log_file, log_level): """Needs a logger and a logger level.""" + + self.thermal = ThermalUtil() + self.fan = FanUtil() # set up logging to file logging.basicConfig( filename=log_file, @@ -83,8 +86,8 @@ def manage_fans(self): 4: [max_duty, 57000, sys.maxsize], } - thermal = ThermalUtil() - fan = FanUtil() + thermal = self.thermal + fan = self.fan for x in range(fan.get_idx_fan_start(), fan.get_num_fans()+1): fan_status = fan.get_fan_status(x) if fan_status is None: From c40e43aadb214e6ab934ccd5a72a90d44de7c165 Mon Sep 17 00:00:00 2001 From: brandonchuang Date: Sun, 3 Jan 2021 00:02:30 +0800 Subject: [PATCH 0061/1674] [device/accton] Fix accton driver not been installed (#6327) Accton util applies lsmod to check if drivers are installed. But lsmod may return error on startup and skip module installation. Signed-off-by: Brandon Chuang --- .../as5712-54x/utils/accton_as5712_util.py | 7 ++++--- .../as5812-54t/utils/accton_as5812_util.py | 9 +++++---- .../as5812-54x/utils/accton_as5812_util.py | 6 ++++-- .../as5835-54t/utils/accton_as5835_54t_util.py | 9 +++++---- .../as5835-54x/utils/accton_as5835_54x_util.py | 7 ++++--- .../as6712-32x/utils/accton_as6712_util.py | 6 ++++-- .../as7312-54x/utils/accton_as7312_util.py | 9 +++++---- .../as7312-54xs/utils/accton_as7312_util.py | 9 +++++---- .../as7315-27xb/utils/accton_as7315_util.py | 9 +++++---- .../as7326-56x/utils/accton_as7326_util.py | 7 ++++--- .../as7712-32x/utils/accton_as7712_util.py | 9 +++++---- .../as7716-32x/utils/accton_as7716_util.py | 6 ++++-- .../as7716-32xb/utils/accton_as7716_32xb_util.py | 6 ++++-- .../as7726-32x/utils/accton_as7726_32x_util.py | 6 ++++-- .../as7816-64x/utils/accton_as7816_util.py | 9 +++++---- .../as9716-32d/utils/accton_as9716_32d_util.py | 6 ++++-- .../minipack/utils/accton_minipack_util.py | 6 ++++-- 17 files changed, 75 insertions(+), 51 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-accton/as5712-54x/utils/accton_as5712_util.py b/platform/broadcom/sonic-platform-modules-accton/as5712-54x/utils/accton_as5712_util.py index ff5d883f1fe8..ed9667da8c99 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5712-54x/utils/accton_as5712_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5712-54x/utils/accton_as5712_util.py @@ -240,11 +240,12 @@ def log_os_system(cmd, show): return status, output def driver_inserted(): - ret, lsmod = log_os_system("ls /sys/module/ | grep accton", 0) + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) logging.info('mods:'+lsmod) - if not lsmod: + if ret : return False - + else : + return True kos = [ 'depmod -ae', diff --git a/platform/broadcom/sonic-platform-modules-accton/as5812-54t/utils/accton_as5812_util.py b/platform/broadcom/sonic-platform-modules-accton/as5812-54t/utils/accton_as5812_util.py index e5ec4fa856d2..3859c3279c45 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5812-54t/utils/accton_as5812_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5812-54t/utils/accton_as5812_util.py @@ -145,11 +145,12 @@ def log_os_system(cmd, show): return status, output def driver_check(): - ret, lsmod = log_os_system("lsmod| grep accton", 0) + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) logging.info('mods:'+lsmod) - if len(lsmod) ==0: - return False - return True + if ret : + return False + else : + return True kos = [ 'modprobe i2c_dev', diff --git a/platform/broadcom/sonic-platform-modules-accton/as5812-54x/utils/accton_as5812_util.py b/platform/broadcom/sonic-platform-modules-accton/as5812-54x/utils/accton_as5812_util.py index be4b5a450c19..464c85745f90 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5812-54x/utils/accton_as5812_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5812-54x/utils/accton_as5812_util.py @@ -240,10 +240,12 @@ def log_os_system(cmd, show): return status, output def driver_inserted(): - ret, lsmod = log_os_system("ls /sys/module | grep accton", 0) + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) logging.info('mods:'+lsmod) - if len(lsmod) ==0: + if ret : return False + else : + return True diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54t/utils/accton_as5835_54t_util.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54t/utils/accton_as5835_54t_util.py index 84625fd6dbf9..48e49cbaba13 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5835-54t/utils/accton_as5835_54t_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54t/utils/accton_as5835_54t_util.py @@ -145,11 +145,12 @@ def log_os_system(cmd, show): return status, output def driver_check(): - ret, lsmod = log_os_system("lsmod| grep accton", 0) + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) logging.info('mods:'+lsmod) - if len(lsmod) ==0: - return False - return True + if ret : + return False + else : + return True diff --git a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/utils/accton_as5835_54x_util.py b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/utils/accton_as5835_54x_util.py index 87ef06f0de16..738a1766fbef 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as5835-54x/utils/accton_as5835_54x_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as5835-54x/utils/accton_as5835_54x_util.py @@ -145,11 +145,12 @@ def log_os_system(cmd, show): return status, output def driver_check(): - ret, lsmod = log_os_system("ls /sys/module/ | grep accton", 0) + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) logging.info('mods:'+lsmod) - if len(lsmod) ==0: + if ret : return False - return True + else : + return True diff --git a/platform/broadcom/sonic-platform-modules-accton/as6712-32x/utils/accton_as6712_util.py b/platform/broadcom/sonic-platform-modules-accton/as6712-32x/utils/accton_as6712_util.py index 20968d57a91f..10cdac787309 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as6712-32x/utils/accton_as6712_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as6712-32x/utils/accton_as6712_util.py @@ -249,10 +249,12 @@ def log_os_system(cmd, show): return status, output def driver_inserted(): - ret, lsmod = log_os_system("lsmod| grep accton", 0) + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) logging.info('mods:'+lsmod) - if len(lsmod) ==0: + if ret : return False + else : + return True 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 db58d769b3aa..b4516c07fae7 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 @@ -150,11 +150,12 @@ def log_os_system(cmd, show): def driver_check(): - (ret, lsmod) = log_os_system('ls /sys/module/ | grep accton', 0) - logging.info('mods:' + lsmod) - if not lsmod: + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) + logging.info('mods:'+lsmod) + if ret : return False - return True + else : + return True kos = [ diff --git a/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/utils/accton_as7312_util.py b/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/utils/accton_as7312_util.py index 4b2ebbe1cca2..f6a21bdd3df9 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/utils/accton_as7312_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7312-54xs/utils/accton_as7312_util.py @@ -145,11 +145,12 @@ def log_os_system(cmd, show): return status, output def driver_check(): - ret, lsmod = log_os_system("lsmod| grep accton", 0) + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) logging.info('mods:'+lsmod) - if len(lsmod) ==0: - return False - return True + if ret : + return False + else : + return True 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 869a7784f0d9..e3810e42102e 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 @@ -147,11 +147,12 @@ def log_os_system(cmd, show): return status, output def driver_check(): - ret, lsmod = log_os_system("lsmod| grep accton", 0) + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) logging.info('mods:'+lsmod) - if len(lsmod) ==0: - return False - return True + if ret : + return False + else : + return True diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_util.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_util.py index cc04c1de38a9..c5d047e9d4e0 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_util.py @@ -178,11 +178,12 @@ def log_os_system(cmd, show): return status, output def driver_check(): - ret, lsmod = log_os_system("lsmod| grep accton", 0) + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) logging.info('mods:'+lsmod) - if len(lsmod) ==0: + if ret : return False - return True + else : + return True diff --git a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/utils/accton_as7712_util.py b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/utils/accton_as7712_util.py index 9741c506b2d1..8ebc39e6c9c1 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7712-32x/utils/accton_as7712_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7712-32x/utils/accton_as7712_util.py @@ -145,11 +145,12 @@ def log_os_system(cmd, show): return status, output def driver_check(): - ret, lsmod = log_os_system("lsmod| grep accton", 0) + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) logging.info('mods:'+lsmod) - if len(lsmod) ==0: - return False - return True + if ret : + return False + else : + return True diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/utils/accton_as7716_util.py b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/utils/accton_as7716_util.py index 7be4a00b0478..142ce754a5c7 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/utils/accton_as7716_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/utils/accton_as7716_util.py @@ -267,10 +267,12 @@ def log_os_system(cmd, show): return status, output def driver_inserted(): - ret, lsmod = log_os_system("lsmod| grep accton", 0) + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) logging.info('mods:'+lsmod) - if len(lsmod) ==0: + if ret : return False + else : + return True #'modprobe cpr_4011_4mxx', diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/utils/accton_as7716_32xb_util.py b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/utils/accton_as7716_32xb_util.py index 0f1f0d66fddb..3a31d253f633 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/utils/accton_as7716_32xb_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32xb/utils/accton_as7716_32xb_util.py @@ -240,10 +240,12 @@ def log_os_system(cmd, show): return status, output def driver_inserted(): - ret, lsmod = log_os_system("lsmod| grep accton", 0) + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) logging.info('mods:'+lsmod) - if len(lsmod) ==0: + if ret : return False + else : + return True kos = [ diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/accton_as7726_32x_util.py b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/accton_as7726_32x_util.py index 590add7e925f..a6aa855174be 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/accton_as7726_32x_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/accton_as7726_32x_util.py @@ -248,10 +248,12 @@ def log_os_system(cmd, show): return status, output def driver_inserted(): - ret, lsmod = log_os_system("lsmod| grep accton", 0) + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) logging.info('mods:'+lsmod) - if len(lsmod) ==0: + if ret : return False + else : + return True def cpld_reset_mac(): ret, lsmod = log_os_system("i2cset -y 0 0x77 0x1", 0) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7816-64x/utils/accton_as7816_util.py b/platform/broadcom/sonic-platform-modules-accton/as7816-64x/utils/accton_as7816_util.py index 0dad870c9718..3aae150dad5c 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7816-64x/utils/accton_as7816_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7816-64x/utils/accton_as7816_util.py @@ -167,11 +167,12 @@ def log_os_system(cmd, show): return status, output def driver_check(): - ret, lsmod = log_os_system("lsmod| grep accton", 0) + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) logging.info('mods:'+lsmod) - if len(lsmod) ==0: - return False - return True + if ret : + return False + else : + return True diff --git a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/utils/accton_as9716_32d_util.py b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/utils/accton_as9716_32d_util.py index 61d19d0ac7fd..898fcaa0f0d3 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/utils/accton_as9716_32d_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/utils/accton_as9716_32d_util.py @@ -254,10 +254,12 @@ def log_os_system(cmd, show): return status, output def driver_inserted(): - ret, lsmod = log_os_system("lsmod| grep accton", 0) + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) logging.info('mods:'+lsmod) - if len(lsmod) ==0: + if ret : return False + else : + return True kos = [ diff --git a/platform/broadcom/sonic-platform-modules-accton/minipack/utils/accton_minipack_util.py b/platform/broadcom/sonic-platform-modules-accton/minipack/utils/accton_minipack_util.py index cf8e91faf549..25979963bb30 100755 --- a/platform/broadcom/sonic-platform-modules-accton/minipack/utils/accton_minipack_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/minipack/utils/accton_minipack_util.py @@ -181,10 +181,12 @@ def log_os_system(cmd, show): return status, output def driver_inserted(): - ret, lsmod = log_os_system("lsmod| grep accton", 0) + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) logging.info('mods:'+lsmod) - if len(lsmod) ==0: + if ret : return False + else : + return True From 120a8da50d41225ecae0d00ba74b913040b4f729 Mon Sep 17 00:00:00 2001 From: Wirut Getbamrung Date: Sat, 16 Jan 2021 01:20:47 +0700 Subject: [PATCH 0062/1674] [device/celestica]: Add thermalctld support on DX010 platform APIs (#6089) **- Why I did it** - The thermalctld daemon on the Pmon docker requires support from the thermal manager API. **- How I did it** - Removed the old function for detecting a faulty fan. - Removed the old function for detecting excess temperature. - Implement thermal_manager APIs based on ThermalManagerBase - Implement thermal_conditions APIs based on ThermalPolicyConditionBase - Implement thermal_actions APIs based on ThermalPolicyActionBase - Implement thermal_info APIs based on ThermalPolicyInfoBase - Add thermal_policy.json --- .../x86_64-cel_seastone-r0/fancontrol-B2F | 3 +- .../x86_64-cel_seastone-r0/fancontrol-F2B | 3 +- .../sonic_platform/chassis.py | 12 +- .../sonic_platform/fan.py | 18 +- .../sonic_platform/thermal.py | 144 +++++++++++---- .../sonic_platform/thermal_actions.py | 78 +++++++++ .../sonic_platform/thermal_conditions.py | 77 ++++++++ .../sonic_platform/thermal_infos.py | 165 ++++++++++++++++++ .../sonic_platform/thermal_manager.py | 46 +++++ .../system_health_monitoring_config.json | 16 ++ .../thermal_overload_control.sh | 0 .../thermal_policy.json | 93 ++++++++++ .../debian/platform-modules-dx010.install | 1 - .../debian/platform-modules-dx010.postinst | 1 + .../dx010/scripts/fancontrol.sh | 83 +++------ .../services/fancontrol/fancontrol | 52 +----- 16 files changed, 647 insertions(+), 145 deletions(-) create mode 100644 device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal_actions.py create mode 100644 device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal_conditions.py create mode 100644 device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal_infos.py create mode 100644 device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal_manager.py create mode 100644 device/celestica/x86_64-cel_seastone-r0/system_health_monitoring_config.json rename {platform/broadcom/sonic-platform-modules-cel/dx010/scripts => device/celestica/x86_64-cel_seastone-r0}/thermal_overload_control.sh (100%) create mode 100644 device/celestica/x86_64-cel_seastone-r0/thermal_policy.json diff --git a/device/celestica/x86_64-cel_seastone-r0/fancontrol-B2F b/device/celestica/x86_64-cel_seastone-r0/fancontrol-B2F index 61b1c386f3d8..f3277db14df2 100644 --- a/device/celestica/x86_64-cel_seastone-r0/fancontrol-B2F +++ b/device/celestica/x86_64-cel_seastone-r0/fancontrol-B2F @@ -9,5 +9,4 @@ MINSTOP=13-002e/pwm1=89 13-002e/pwm2=89 13-002e/pwm3=89 13-002e/pwm4=89 13-002e/ MINPWM=13-002e/pwm1=89 13-002e/pwm2=89 13-002e/pwm3=89 13-002e/pwm4=89 13-002e/pwm5=89 13-004d/pwm1=89 13-004d/pwm2=89 13-004d/pwm3=89 13-004d/pwm4=89 13-004d/pwm5=89 MAXPWM=13-002e/pwm1=255 13-002e/pwm2=255 13-002e/pwm3=255 13-002e/pwm4=255 13-002e/pwm5=255 13-004d/pwm1=255 13-004d/pwm2=255 13-004d/pwm3=255 13-004d/pwm4=255 13-004d/pwm5=255 THYST=13-002e/pwm1=3 13-002e/pwm2=3 13-002e/pwm3=3 13-002e/pwm4=3 13-002e/pwm5=3 13-004d/pwm1=3 13-004d/pwm2=3 13-004d/pwm3=3 13-004d/pwm4=3 13-004d/pwm5=3 -MAXTEMPCRIT=/sys/bus/i2c/devices/7-004a/hwmon/hwmon*/temp1_input=65 /sys/bus/i2c/devices/14-0048/hwmon/hwmon*/temp1_input=75 -MAXTEMPTYPE=/sys/bus/i2c/devices/7-004a/hwmon/hwmon*/temp1_input=ASIC /sys/bus/i2c/devices/14-0048/hwmon/hwmon*/temp1_input=CPU + diff --git a/device/celestica/x86_64-cel_seastone-r0/fancontrol-F2B b/device/celestica/x86_64-cel_seastone-r0/fancontrol-F2B index b851d0a6d6ca..dc67e2623cc2 100644 --- a/device/celestica/x86_64-cel_seastone-r0/fancontrol-F2B +++ b/device/celestica/x86_64-cel_seastone-r0/fancontrol-F2B @@ -9,5 +9,4 @@ MINSTOP=13-002e/pwm1=89 13-002e/pwm2=89 13-002e/pwm3=89 13-002e/pwm4=89 13-002e/ MINPWM=13-002e/pwm1=89 13-002e/pwm2=89 13-002e/pwm3=89 13-002e/pwm4=89 13-002e/pwm5=89 13-004d/pwm1=89 13-004d/pwm2=89 13-004d/pwm3=89 13-004d/pwm4=89 13-004d/pwm5=89 MAXPWM=13-002e/pwm1=255 13-002e/pwm2=255 13-002e/pwm3=255 13-002e/pwm4=255 13-002e/pwm5=255 13-004d/pwm1=255 13-004d/pwm2=255 13-004d/pwm3=255 13-004d/pwm4=255 13-004d/pwm5=255 THYST=13-002e/pwm1=3 13-002e/pwm2=3 13-002e/pwm3=3 13-002e/pwm4=3 13-002e/pwm5=3 13-004d/pwm1=3 13-004d/pwm2=3 13-004d/pwm3=3 13-004d/pwm4=3 13-004d/pwm5=3 -MAXTEMPCRIT=/sys/bus/i2c/devices/7-004a/hwmon/hwmon*/temp1_input=75 /sys/bus/i2c/devices/14-0048/hwmon/hwmon*/temp1_input=75 -MAXTEMPTYPE=/sys/bus/i2c/devices/7-004a/hwmon/hwmon*/temp1_input=ASIC /sys/bus/i2c/devices/14-0048/hwmon/hwmon*/temp1_input=CPU + diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/chassis.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/chassis.py index 49c79263815d..1b5c5773e27b 100644 --- a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/chassis.py +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/chassis.py @@ -74,8 +74,9 @@ def __initialize_fan(self): def __initialize_thermals(self): from sonic_platform.thermal import Thermal + airflow = self.__get_air_flow() for index in range(0, NUM_THERMAL): - thermal = Thermal(index) + thermal = Thermal(index, airflow) self._thermal_list.append(thermal) def __initialize_eeprom(self): @@ -88,6 +89,11 @@ def __initialize_components(self): component = Component(index) self._component_list.append(component) + def __get_air_flow(self): + air_flow_path = '/usr/share/sonic/device/{}/fan_airflow'.format(self._api_helper.platform) if self.is_host else '/usr/share/sonic/platform/fan_airflow' + air_flow = self._api_helper.read_one_line_file(air_flow_path) + return air_flow or 'B2F' + def get_base_mac(self): """ Retrieves the base MAC address for the chassis @@ -291,3 +297,7 @@ def get_status(self): A boolean value, True if device is operating properly, False if not """ return True + + def get_thermal_manager(self): + from .thermal_manager import ThermalManager + return ThermalManager diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/fan.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/fan.py index 10875ee30753..bf2b27019b63 100644 --- a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/fan.py +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/fan.py @@ -304,4 +304,20 @@ def get_status(self): Returns: A boolean value, True if device is operating properly, False if not """ - return self.get_presence() and self.get_speed() > 0 + status = 1 + if self.is_psu_fan: + fan_fault_sysfs_name = "fan1_fault" + fan_fault_sysfs_path = self.__search_file_by_name( + self.psu_hwmon_path, fan_fault_sysfs_name) + status = self._api_helper.read_one_line_file(fan_fault_sysfs_path) + + elif self.get_presence(): + chip = self.emc2305_chip_mapping[self.fan_index] + device = chip['device'] + fan_index = chip['index_map'] + sysfs_path = "%s%s/%s" % ( + EMC2305_PATH, device, 'fan{}_fault') + sysfs_path = sysfs_path.format(fan_index[self.fan_tray_index]) + status = self._api_helper.read_one_line_file(sysfs_path) + + return False if int(status) != 0 else True diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal.py index 9e891b65e405..2b38ef94d6c4 100644 --- a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal.py +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal.py @@ -16,46 +16,75 @@ except ImportError as e: raise ImportError(str(e) + "- required module not found") +THERMAL_INFO = { + 0: { + "F2B_max": 50, + "B2F_max": 55, + "postion": "asic", + "name": "Front-panel temp sensor 1", + "i2c_path": "i2c-5/5-0048/hwmon/hwmon1", # u4 system-inlet + }, + 1: { + "F2B_max": 50, + "B2F_max": 55, + "postion": "asic", + "name": "Front-panel temp sensor 2", + "i2c_path": "i2c-6/6-0049/hwmon/hwmon2", # u2 system-inlet + }, + 2: { + "F2B_max": 70, + "F2B_max_crit": 75, + "B2F_max": 60, + "B2F_max_crit": 65, + "postion": "asic", + "name": "ASIC temp sensor", + "i2c_path": "i2c-7/7-004a/hwmon/hwmon3", # u44 bmc56960-on-board + }, + 3: { + "F2B_max": 70, + "F2B_max_crit": 75, + "B2F_max": 70, + "B2F_max_crit": 75, + "postion": "cpu", + "name": "Rear-panel temp sensor 1", + "i2c_path": "i2c-14/14-0048/hwmon/hwmon4", # u9200 cpu-on-board + }, + 4: { + "F2B_max": 70, + "B2F_max": 55, + "postion": "cpu", + "name": "Rear-panel temp sensor 2", + "i2c_path": "i2c-15/15-004e/hwmon/hwmon5" # u9201 system-outlet + } +} +NULL_VAL = "N/A" +I2C_ADAPTER_PATH = "/sys/class/i2c-adapter" + class Thermal(ThermalBase): """Platform-specific Thermal class""" - THERMAL_NAME_LIST = [] - I2C_ADAPTER_PATH = "/sys/class/i2c-adapter" SS_CONFIG_PATH = "/usr/share/sonic/device/x86_64-cel_seastone-r0/sensors.conf" - def __init__(self, thermal_index): + def __init__(self, thermal_index, airflow): self.index = thermal_index self._api_helper = APIHelper() - - # Add thermal name - self.THERMAL_NAME_LIST.append("Front-panel temp sensor 1") - self.THERMAL_NAME_LIST.append("Front-panel temp sensor 2") - self.THERMAL_NAME_LIST.append("ASIC temp sensor") - self.THERMAL_NAME_LIST.append("Rear-panel temp sensor 1") - self.THERMAL_NAME_LIST.append("Rear-panel temp sensor 2") - - # Set hwmon path - i2c_path = { - 0: "i2c-5/5-0048/hwmon/hwmon1", # u4 system-inlet - 1: "i2c-6/6-0049/hwmon/hwmon2", # u2 system-inlet - 2: "i2c-7/7-004a/hwmon/hwmon3", # u44 bmc56960-on-board - 3: "i2c-14/14-0048/hwmon/hwmon4", # u9200 cpu-on-board - 4: "i2c-15/15-004e/hwmon/hwmon5" # u9201 system-outlet - }.get(self.index, None) - - self.hwmon_path = "{}/{}".format(self.I2C_ADAPTER_PATH, i2c_path) - self.ss_key = self.THERMAL_NAME_LIST[self.index] + self._airflow = airflow + self._thermal_info = THERMAL_INFO[self.index] + self._hwmon_path = "{}/{}".format(I2C_ADAPTER_PATH, + self._thermal_info["i2c_path"]) + self.name = self.get_name() + self.postion = self._thermal_info["postion"] self.ss_index = 1 def __get_temp(self, temp_file): - temp_file_path = os.path.join(self.hwmon_path, temp_file) + temp_file_path = os.path.join(self._hwmon_path, temp_file) raw_temp = self._api_helper.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) + temp_file_path = os.path.join(self._hwmon_path, file_name) try: with open(temp_file_path, 'w') as fd: fd.write(str(temperature)) @@ -80,8 +109,17 @@ def get_high_threshold(self): A float number, the high threshold temperature of thermal in Celsius up to nearest thousandth of one degree Celsius, e.g. 30.125 """ - temp_file = "temp{}_max".format(self.ss_index) - return self.__get_temp(temp_file) + max_crit_key = '{}_max'.format(self._airflow) + return self._thermal_info.get(max_crit_key, None) + + def get_low_threshold(self): + """ + Retrieves the low threshold temperature of thermal + Returns: + A float number, the low threshold temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + return 0.0 def set_high_threshold(self, temperature): """ @@ -102,7 +140,7 @@ def set_high_threshold(self, temperature): f.seek(0) ss_found = False for idx, val in enumerate(content): - if self.ss_key in val: + if self.name in val: ss_found = True elif ss_found and temp_file in val: content[idx] = " set {} {}\n".format( @@ -115,13 +153,43 @@ def set_high_threshold(self, temperature): return is_set & file_set + def set_low_threshold(self, temperature): + """ + Sets the low 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 + """ + return False + + def get_high_critical_threshold(self): + """ + Retrieves the high critical threshold temperature of thermal + Returns: + A float number, the high critical threshold temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + max_crit_key = '{}_max_crit'.format(self._airflow) + return self._thermal_info.get(max_crit_key, None) + + def get_low_critical_threshold(self): + """ + Retrieves the low critical threshold temperature of thermal + Returns: + A float number, the low critical threshold temperature of thermal in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + return 0.0 + 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] + return self._thermal_info["name"] def get_presence(self): """ @@ -130,9 +198,25 @@ def get_presence(self): 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) + temp_file_path = os.path.join(self._hwmon_path, temp_file) return os.path.isfile(temp_file_path) + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + return NULL_VAL + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return NULL_VAL + def get_status(self): """ Retrieves the operational status of the device @@ -143,7 +227,7 @@ def get_status(self): return False fault_file = "temp{}_fault".format(self.ss_index) - fault_file_path = os.path.join(self.hwmon_path, fault_file) + fault_file_path = os.path.join(self._hwmon_path, fault_file) if not os.path.isfile(fault_file_path): return True diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal_actions.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal_actions.py new file mode 100644 index 000000000000..545db861f683 --- /dev/null +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal_actions.py @@ -0,0 +1,78 @@ + +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_infos import ChassisInfo +from .helper import APIHelper + + +@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: + """ + if ChassisInfo.INFO_NAME in thermal_info_dict: + chassis_info_obj = thermal_info_dict[ChassisInfo.INFO_NAME] + chassis = chassis_info_obj.get_chassis() + thermal_manager = chassis.get_thermal_manager() + if self.status: + thermal_manager.start_thermal_control_algorithm() + else: + thermal_manager.stop_thermal_control_algorithm() + + +@thermal_json_object('switch.power_cycling') +class SwitchPolicyAction(ThermalPolicyActionBase): + """ + Base class for thermal action. Once all thermal conditions in a thermal policy are matched, + all predefined thermal action will be executed. + """ + + def execute(self, thermal_info_dict): + """ + Take action when thermal condition matches. For example, power cycle the switch. + :param thermal_info_dict: A dictionary stores all thermal information. + :return: + """ + thermal_overload_position_path = '/tmp/thermal_overload_position' + thermal_overload_position = APIHelper().read_one_line_file( + thermal_overload_position_path) + + cmd = 'bash /usr/share/sonic/platform/thermal_overload_control.sh {}'.format( + thermal_overload_position) + APIHelper().run_command(cmd) diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal_conditions.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal_conditions.py new file mode 100644 index 000000000000..1eee8ea91ab5 --- /dev/null +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal_conditions.py @@ -0,0 +1,77 @@ +from sonic_platform_base.sonic_thermal_control.thermal_condition_base import ThermalPolicyConditionBase +from sonic_platform_base.sonic_thermal_control.thermal_json_object import thermal_json_object + + +class FanCondition(ThermalPolicyConditionBase): + def get_fan_info(self, thermal_info_dict): + from .thermal_infos import FanInfo + if FanInfo.INFO_NAME in thermal_info_dict and isinstance(thermal_info_dict[FanInfo.INFO_NAME], FanInfo): + return thermal_info_dict[FanInfo.INFO_NAME] + else: + return None + + +@thermal_json_object('fan.any.absence') +class AnyFanAbsenceCondition(FanCondition): + def is_match(self, thermal_info_dict): + fan_info_obj = self.get_fan_info(thermal_info_dict) + return len(fan_info_obj.get_absence_fans()) > 0 if fan_info_obj else False + + +@thermal_json_object('fan.any.fault') +class AnyFanFaultCondition(FanCondition): + def is_match(self, thermal_info_dict): + fan_info_obj = self.get_fan_info(thermal_info_dict) + return len(fan_info_obj.get_fault_fans()) > 0 if fan_info_obj else False + + +@thermal_json_object('fan.all.presence') +class AllFanPresenceCondition(FanCondition): + def is_match(self, thermal_info_dict): + fan_info_obj = self.get_fan_info(thermal_info_dict) + return len(fan_info_obj.get_absence_fans()) == 0 if fan_info_obj else False + + +@thermal_json_object('fan.all.good') +class AllFanGoodCondition(FanCondition): + def is_match(self, thermal_info_dict): + fan_info_obj = self.get_fan_info(thermal_info_dict) + return len(fan_info_obj.get_fault_fans()) == 0 if fan_info_obj else False + + +class ThermalCondition(ThermalPolicyConditionBase): + def get_thermal_info(self, thermal_info_dict): + from .thermal_infos import ThermalInfo + if ThermalInfo.INFO_NAME in thermal_info_dict and isinstance(thermal_info_dict[ThermalInfo.INFO_NAME], ThermalInfo): + return thermal_info_dict[ThermalInfo.INFO_NAME] + else: + return None + + +@thermal_json_object('thermal.over.high_threshold') +class ThermalOverHighCriticalCondition(ThermalCondition): + def is_match(self, thermal_info_dict): + thermal_info_obj = self.get_thermal_info(thermal_info_dict) + if thermal_info_obj: + return thermal_info_obj.is_over_high_threshold() + else: + return False + + +@thermal_json_object('thermal.over.high_critical_threshold') +class ThermalOverHighCriticalCondition(ThermalCondition): + def is_match(self, thermal_info_dict): + thermal_info_obj = self.get_thermal_info(thermal_info_dict) + if thermal_info_obj: + return thermal_info_obj.is_over_high_critical_threshold() + else: + return False + +@thermal_json_object('thermal.all.good') +class ThermalGoodCondition(ThermalCondition): + def is_match(self, thermal_info_dict): + thermal_info_obj = self.get_thermal_info(thermal_info_dict) + if thermal_info_obj: + return not thermal_info_obj.is_over_threshold() + else: + return False diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal_infos.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal_infos.py new file mode 100644 index 000000000000..a680b31b634f --- /dev/null +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal_infos.py @@ -0,0 +1,165 @@ +from sonic_platform_base.sonic_thermal_control.thermal_info_base import ThermalPolicyInfoBase +from sonic_platform_base.sonic_thermal_control.thermal_json_object import thermal_json_object +from .helper import APIHelper +import time + + +@thermal_json_object('fan_info') +class FanInfo(ThermalPolicyInfoBase): + """ + Fan information needed by thermal policy + """ + + # Fan information name + INFO_NAME = 'fan_info' + + def __init__(self): + self._absence_fans = set() + self._presence_fans = set() + self._fault_fans = set() + self._status_changed = False + + def collect(self, chassis): + """ + Collect absence and presence fans. + :param chassis: The chassis object + :return: + """ + self._status_changed = False + for fan in chassis.get_all_fans(): + presence = fan.get_presence() + status = fan.get_status() + if presence and fan not in self._presence_fans: + self._presence_fans.add(fan) + self._status_changed = True + if fan in self._absence_fans: + self._absence_fans.remove(fan) + elif not presence and fan not in self._absence_fans: + self._absence_fans.add(fan) + self._status_changed = True + if fan in self._presence_fans: + self._presence_fans.remove(fan) + + if not status and fan not in self._fault_fans: + self._fault_fans.add(fan) + self._status_changed = True + + elif status and fan in self._fault_fans: + self._fault_fans.remove(fan) + self._status_changed = True + + def get_absence_fans(self): + """ + Retrieves absence fans + :return: A set of absence fans + """ + return self._absence_fans + + def get_presence_fans(self): + """ + Retrieves presence fans + :return: A set of presence fans + """ + return self._presence_fans + + def get_fault_fans(self): + """ + Retrieves fault fans + :return: A set of fault fans + """ + return self._fault_fans + + def is_status_changed(self): + """ + Retrieves if the status of fan information changed + :return: True if status changed else False + """ + return self._status_changed + + +@thermal_json_object('thermal_info') +class ThermalInfo(ThermalPolicyInfoBase): + """ + Thermal information needed by thermal policy + """ + + # Fan information name + INFO_NAME = 'thermal_info' + + def collect(self, chassis): + """ + Collect thermal sensor temperature change status + :param chassis: The chassis object + :return: + """ + self._over_high_threshold = False + self._over_high_critical_threshold = False + self._thermal_overload_position = 'cpu' + + # Calculate average temp within the device + temp = 0 + num_of_thermals = chassis.get_num_thermals() + for index in range(num_of_thermals): + thermal = chassis.get_thermal(index) + temp = thermal.get_temperature() + high_threshold = thermal.get_high_threshold() + high_critical_threshold = thermal.get_high_critical_threshold() + + if high_threshold and temp > high_threshold: + self._over_high_threshold = True + + if high_critical_threshold and temp > high_critical_threshold: + self._thermal_overload_position = thermal.postion + self._over_high_critical_threshold = True + + def is_over_threshold(self): + """ + Retrieves if the temperature is over any threshold + :return: True if the temperature is over any threshold else False + """ + return self._over_high_threshold or self._over_high_critical_threshold + + def is_over_high_critical_threshold(self): + """ + Retrieves if the temperature is over high critical threshold + :return: True if the temperature is over high critical threshold else False + """ + thermal_overload_position_path = '/tmp/thermal_overload_position' + if self._over_high_critical_threshold: + APIHelper().write_txt_file(thermal_overload_position_path, + self._thermal_overload_position) + time.sleep(1) + return self._over_high_critical_threshold + + def is_over_high_threshold(self): + """ + Retrieves if the temperature is over high threshold + :return: True if the temperature is over high threshold else False + """ + return self._over_high_threshold + + +@thermal_json_object('chassis_info') +class ChassisInfo(ThermalPolicyInfoBase): + """ + Chassis information needed by thermal policy + """ + INFO_NAME = 'chassis_info' + + def __init__(self): + self._chassis = None + + def collect(self, chassis): + """ + Collect platform chassis. + :param chassis: The chassis object + :return: + """ + self._chassis = chassis + + def get_chassis(self): + """ + Retrieves platform chassis object + :return: A platform chassis object. + """ + return self._chassis diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal_manager.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal_manager.py new file mode 100644 index 000000000000..9f057cf1f37f --- /dev/null +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal_manager.py @@ -0,0 +1,46 @@ +from sonic_platform_base.sonic_thermal_control.thermal_manager_base import ThermalManagerBase +from .helper import APIHelper +from .thermal_actions import * +from .thermal_conditions import * +from .thermal_infos import * + +class ThermalManager(ThermalManagerBase): + FSC_ALGORITHM_CMD = 'service fancontrol {}' + + @classmethod + def start_thermal_control_algorithm(cls): + """ + Start vendor specific thermal control algorithm. The default behavior of this function is a no-op. + :return: + """ + return cls._enable_fancontrol_service(True) + + @classmethod + def stop_thermal_control_algorithm(cls): + """ + Stop thermal control algorithm + Returns: + bool: True if set success, False if fail. + """ + return cls._enable_fancontrol_service(False) + + @classmethod + def deinitialize(cls): + """ + Destroy thermal manager, including any vendor specific cleanup. The default behavior of this function + is a no-op. + :return: + """ + return cls._enable_fancontrol_service(True) + + @classmethod + def _enable_fancontrol_service(cls, enable): + """ + Control thermal by fcs algorithm + Args: + enable: Bool, indicate enable the algorithm or not + Returns: + bool: True if set success, False if fail. + """ + cmd = 'start' if enable else 'stop' + return APIHelper().run_command(cls.FSC_ALGORITHM_CMD.format(cmd)) diff --git a/device/celestica/x86_64-cel_seastone-r0/system_health_monitoring_config.json b/device/celestica/x86_64-cel_seastone-r0/system_health_monitoring_config.json new file mode 100644 index 000000000000..4dc38d035ab4 --- /dev/null +++ b/device/celestica/x86_64-cel_seastone-r0/system_health_monitoring_config.json @@ -0,0 +1,16 @@ +{ + "services_to_ignore": [], + "devices_to_ignore": [ + "asic", + "psu.temperature", + "PSU2 Fan", + "PSU1 Fan" + ], + "user_defined_checkers": [], + "polling_interval": 60, + "led_color": { + "fault": "orange", + "normal": "green", + "booting": "orange_blink" + } +} \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-cel/dx010/scripts/thermal_overload_control.sh b/device/celestica/x86_64-cel_seastone-r0/thermal_overload_control.sh similarity index 100% rename from platform/broadcom/sonic-platform-modules-cel/dx010/scripts/thermal_overload_control.sh rename to device/celestica/x86_64-cel_seastone-r0/thermal_overload_control.sh diff --git a/device/celestica/x86_64-cel_seastone-r0/thermal_policy.json b/device/celestica/x86_64-cel_seastone-r0/thermal_policy.json new file mode 100644 index 000000000000..f937b6bd4456 --- /dev/null +++ b/device/celestica/x86_64-cel_seastone-r0/thermal_policy.json @@ -0,0 +1,93 @@ +{ + "thermal_control_algorithm": { + "run_at_boot_up": "true" + }, + "info_types": [ + { + "type": "chassis_info" + }, + { + "type": "fan_info" + }, + { + "type": "thermal_info" + } + ], + "policies": [ + { + "name": "any fan absence", + "conditions": [ + { + "type": "fan.any.absence" + } + ], + "actions": [ + { + "type": "thermal_control.control", + "status": "false" + } + ] + }, + { + "name": "any fan broken", + "conditions": [ + { + "type": "fan.any.fault" + } + ], + "actions": [ + { + "type": "thermal_control.control", + "status": "false" + } + ] + }, + { + "name": "any thermal over threshold", + "conditions": [ + { + "type": "thermal.over.high_threshold" + } + ], + "actions": [ + { + "type": "thermal_control.control", + "status": "false" + } + ] + }, + { + "name": "temp over high critical threshold", + "conditions": [ + { + "type": "thermal.over.high_critical_threshold" + } + ], + "actions": [ + { + "type": "switch.power_cycling" + } + ] + }, + { + "name": "all fan presence / thermal no warning", + "conditions": [ + { + "type": "fan.all.presence" + }, + { + "type": "fan.all.good" + }, + { + "type": "thermal.all.good" + } + ], + "actions": [ + { + "type": "thermal_control.control", + "status": "true" + } + ] + } + ] +} \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-dx010.install b/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-dx010.install index d7720cea90f4..a36e2cd1377c 100644 --- a/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-dx010.install +++ b/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-dx010.install @@ -3,7 +3,6 @@ dx010/cfg/dx010-modules.conf etc/modules-load.d dx010/systemd/platform-modules-dx010.service lib/systemd/system dx010/scripts/fancontrol.sh etc/init.d dx010/scripts/fancontrol.service lib/systemd/system -dx010/scripts/thermal_overload_control.sh usr/local/bin services/fancontrol/fancontrol usr/local/bin dx010/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-cel_seastone-r0 services/platform_api/platform_api_mgnt.sh usr/local/bin diff --git a/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-dx010.postinst b/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-dx010.postinst index 8dbf0ece6676..b198584282db 100644 --- a/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-dx010.postinst +++ b/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-dx010.postinst @@ -6,4 +6,5 @@ systemctl start platform-modules-dx010.service systemctl start fancontrol.service /usr/local/bin/platform_api_mgnt.sh install +/etc/init.d/fancontrol.sh install diff --git a/platform/broadcom/sonic-platform-modules-cel/dx010/scripts/fancontrol.sh b/platform/broadcom/sonic-platform-modules-cel/dx010/scripts/fancontrol.sh index 75ad6c65b37f..21274ed6e27d 100644 --- a/platform/broadcom/sonic-platform-modules-cel/dx010/scripts/fancontrol.sh +++ b/platform/broadcom/sonic-platform-modules-cel/dx010/scripts/fancontrol.sh @@ -7,75 +7,42 @@ # Default-Start: 2 3 4 5 # Default-Stop: # Short-Description: fancontrol -# Description: fan speed regulator +# Description: fancontrol configuration selector ### END INIT INFO . /lib/lsb/init-functions [ -f /etc/default/rcS ] && . /etc/default/rcS -PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin -DAEMON=/usr/local/bin/fancontrol -DESC="fan speed regulator" -NAME="fancontrol" -PIDFILE=/var/run/fancontrol.pid MAIN_CONF=/usr/share/sonic/device/x86_64-cel_seastone-r0/fancontrol -DEVPATH=/sys/devices/pci0000:00/0000:00:13.0/i2c-*/i2c-13/13-002e GPIO_DIR=/sys/class/gpio -BASE_GPIO=$(find $GPIO_DIR | grep gpiochip | grep -o '[[:digit:]]*') -DIRGPIO_START=15 -test -x $DAEMON || exit 0 +init() { + DIRGPIO_START=15 + BASE_GPIO=$(find $GPIO_DIR | grep gpiochip | grep -o '[[:digit:]]*') + FANDIR_GPIO_NUMBER=$((DIRGPIO_START + BASE_GPIO)) + FANDIR_VALUE=$(cat ${GPIO_DIR}/gpio${FANDIR_GPIO_NUMBER}/value) + DIRGPIO_START=$((DIRGPIO_START + 1)) + FANDIR=$([ $FANDIR_VALUE = 1 ] && echo "B2F" || echo "F2B") + CONF=${MAIN_CONF}-${FANDIR} + echo $FANDIR > /usr/share/sonic/device/x86_64-cel_seastone-r0/fan_airflow +} -for i in 1 2 3 4 5 -do - FANFAULT=$(cat ${DEVPATH}/fan${i}_fault) - [ $FANFAULT = 1 ] && continue - FANDIR_GPIO_NUMBER=$((DIRGPIO_START + BASE_GPIO)) - FANDIR_VALUE=$(cat ${GPIO_DIR}/gpio${FANDIR_GPIO_NUMBER}/value) - DIRGPIO_START=$((DIRGPIO_START+1)) - FANDIR=$([ $FANDIR_VALUE = 1 ] && echo "B2F" || echo "F2B") -done -CONF=${MAIN_CONF}-${FANDIR} +install() { + find /var/lib/docker/overlay*/ -path */sbin/fancontrol -exec cp /usr/local/bin/fancontrol {} \; +} case "$1" in - start) - if [ -f $CONF ] ; then - if $DAEMON --check $CONF 1>/dev/null 2>/dev/null ; then - log_daemon_msg "Starting $DESC" "$NAME\n" - start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON $CONF - log_end_msg $? - else - log_failure_msg "Not starting fancontrol, broken configuration file; please re-run pwmconfig." - fi - else - if [ "$VERBOSE" != no ]; then - log_warning_msg "Not starting fancontrol; run pwmconfig first." - fi - fi - ;; - stop) - log_daemon_msg "Stopping $DESC" "$NAME" - start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --startas $DAEMON $CONF - rm -f $PIDFILE - log_end_msg $? - ;; - restart) - $0 stop - sleep 3 - $0 start - ;; - force-reload) - if start-stop-daemon --stop --test --quiet --pidfile $PIDFILE --startas $DAEMON $CONF ; then - $0 restart - fi - ;; - status) - status_of_proc $DAEMON $NAME $CONF && exit 0 || exit $? - ;; - *) - log_success_msg "Usage: /etc/init.d/fancontrol {start|stop|restart|force-reload|status}" - exit 1 - ;; +start) + init + cp $CONF $MAIN_CONF + ;; +install) + install + ;; +*) + log_success_msg "Usage: /etc/init.d/fancontrol {start} | {install}" + exit 1 + ;; esac exit 0 diff --git a/platform/broadcom/sonic-platform-modules-cel/services/fancontrol/fancontrol b/platform/broadcom/sonic-platform-modules-cel/services/fancontrol/fancontrol index cdd5005e3688..da32acedd2f9 100755 --- a/platform/broadcom/sonic-platform-modules-cel/services/fancontrol/fancontrol +++ b/platform/broadcom/sonic-platform-modules-cel/services/fancontrol/fancontrol @@ -180,42 +180,6 @@ function LoadConfig } -function CheckFanFault() -{ - let fancount=0 - while (( $fancount < ${#AFCFANFAULT[@]} )) # go through all fan fault. - do - fault=`cat ${AFCFANFAULT[$fancount]}` - if [[ "$fault" == "1" ]] - then - return 1 # fan fault detected - fi - let fancount=$fancount+1 - done - return 0 -} - -function CheckTempOver() -{ - let tempcount=0 - while (( $tempcount < ${#CSTEMP[@]} )) # go through all temp. - do - ctemp=`cat ${CSTEMP[$tempcount]}` - let maxcrit="${CSMAXTEMPCRIT[$tempcount]}*1000" - if [ $ctemp -ge $maxcrit ] - then - logger "Thermal overload : ${CSMAXTEMPTYPE[$tempcount]} temperature ${ctemp} > ${maxcrit}" - if [ -f "$THERMAL_OVERLOAD_CONTROL_FILE" ] - then - toc_cmd="${THERMAL_OVERLOAD_CONTROL_FILE} ${CSMAXTEMPTYPE[$tempcount],,}" - bash $toc_cmd - exit 1 - fi - fi - let tempcount=$tempcount+1 - done - return 0 -} function DevicePath() { @@ -508,18 +472,6 @@ function UpdateFanSpeeds maxpwm=${AFCMAXPWM[$fcvcount]} let tHyst="${AFCTHYST[$fcvcount]}*1000" - #if some fan fault detected all pwm=100% - CheckFanFault - if [ $? -ne 0 ] - then - echo $MAX > $pwmo - let fcvcount=$fcvcount+1 - continue - fi - - #check thermal overload - CheckTempOver - read tval < ${tsens} if [ $? -ne 0 ] then @@ -619,7 +571,7 @@ function UpdateFanSpeeds echo $minsa > $pwmo # Sleep while still handling signals sleep 1 & - wait $! + wait fi fi echo $pwmval > $pwmo # write new value to pwm output @@ -658,5 +610,5 @@ do UpdateFanSpeeds # Sleep while still handling signals sleep $INTERVAL & - wait $! + wait done From 824d7adc2dff3a4c3c9a2ba4842e01bdfcf4ebda Mon Sep 17 00:00:00 2001 From: Kebo Liu Date: Sat, 16 Jan 2021 03:38:31 +0800 Subject: [PATCH 0063/1674] [Mellanox] Make determine-reboot-cause service start after hw-management service (#6465) **- Why I did it** On the Mellanox platform, reboot cause is fetched from some certain sysfs which is created by the hw-management service. So determine-reboot-cause service shall start after hw-management, otherwise it could fail due to the related sysfs is not available yet. **- How I did it** Add a patch to the hw-management service to make sure determine-reboot-cause service should start after it. Signed-off-by: Kebo Liu --- ...mine-reboot-cause-service-start-afte.patch | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 platform/mellanox/hw-management/0001-Make-SONiC-determine-reboot-cause-service-start-afte.patch diff --git a/platform/mellanox/hw-management/0001-Make-SONiC-determine-reboot-cause-service-start-afte.patch b/platform/mellanox/hw-management/0001-Make-SONiC-determine-reboot-cause-service-start-afte.patch new file mode 100644 index 000000000000..11539e606369 --- /dev/null +++ b/platform/mellanox/hw-management/0001-Make-SONiC-determine-reboot-cause-service-start-afte.patch @@ -0,0 +1,26 @@ +From 1a1011b6da491d35001df5a7204d4eecb2769767 Mon Sep 17 00:00:00 2001 +From: keboliu +Date: Fri, 15 Jan 2021 14:41:16 +0800 +Subject: [PATCH] Make SONiC determine-reboot-cause service start after hw-mgmt + service + +Signed-off-by: Kebo Liu +--- + debian/hw-management.hw-management.service | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/debian/hw-management.hw-management.service b/debian/hw-management.hw-management.service +index 39a2a54..2104b87 100755 +--- a/debian/hw-management.hw-management.service ++++ b/debian/hw-management.hw-management.service +@@ -1,6 +1,7 @@ + [Unit] + Description=Chassis HW management service of Mellanox systems + Documentation=man:hw-management.service(8) ++Before=determine-reboot-cause.service + + [Service] + Type=oneshot +-- +1.9.1 + From 0d93b233d239d1f64b51bdc572e005182d88aa10 Mon Sep 17 00:00:00 2001 From: dflynn-Nokia <60479697+dflynn-Nokia@users.noreply.github.com> Date: Sun, 17 Jan 2021 01:04:19 -0500 Subject: [PATCH 0064/1674] [build arm] fix sonic-slave-buster build break (#6469) When building the sonic-slave-buster docker container, the node.js package is installed to meet the requirements of the Azure DevOPs pipleline build. Recently this install of node.js has been failing. This commit fixes that build break by upgrading the sonic-slave-buster build to install version 14.x of node.js which is the current LTS version for buster. --- sonic-slave-buster/Dockerfile.j2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sonic-slave-buster/Dockerfile.j2 b/sonic-slave-buster/Dockerfile.j2 index b372e3e28636..641a1f3f2433 100644 --- a/sonic-slave-buster/Dockerfile.j2 +++ b/sonic-slave-buster/Dockerfile.j2 @@ -483,7 +483,8 @@ RUN pip3 install git+https://github.com/aristanetworks/swi-tools.git@bead66bf261 {% if CONFIGURED_ARCH != "amd64" -%} # Install node.js for azure pipeline -RUN apt-get install -y node.js +RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - +RUN apt-get install -y nodejs # Tell azure pipeline to use node.js in the docker LABEL "com.azure.dev.pipelines.agent.handler.node.path"="/usr/bin/node" From c7058a6d157c4a1423fb767110180d9dc144a3a8 Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Sun, 17 Jan 2021 00:23:11 -0800 Subject: [PATCH 0065/1674] [minigraph.py]: Don't create mux table entries for servers w/o loopbacks (#6457) Avoid sonic-cfggen crashing when a server does not have a configured loopback address in the minigraph Signed-off-by: Lawrence Lee --- src/sonic-config-engine/minigraph.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 8b9794f2bfb8..f30e668251a3 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -1506,14 +1506,17 @@ def get_mux_cable_entries(mux_cable_ports, neighbors, devices): neighbor = neighbors[intf]['name'] entry['state'] = 'auto' - # Always force a /32 prefix for server IPv4 loopbacks - server_ipv4_lo_addr = devices[neighbor]['lo_addr'].split("/")[0] - server_ipv4_lo_prefix = ipaddress.ip_network(UNICODE_TYPE(server_ipv4_lo_addr)) - entry['server_ipv4'] = str(server_ipv4_lo_prefix) - - if 'lo_addr_v6' in devices[neighbor]: - entry['server_ipv6'] = devices[neighbor]['lo_addr_v6'] - mux_cable_table[intf] = entry + if devices[neighbor]['lo_addr'] is not None: + # Always force a /32 prefix for server IPv4 loopbacks + server_ipv4_lo_addr = devices[neighbor]['lo_addr'].split("/")[0] + server_ipv4_lo_prefix = ipaddress.ip_network(UNICODE_TYPE(server_ipv4_lo_addr)) + entry['server_ipv4'] = str(server_ipv4_lo_prefix) + + if 'lo_addr_v6' in devices[neighbor]: + entry['server_ipv6'] = devices[neighbor]['lo_addr_v6'] + mux_cable_table[intf] = entry + else: + print("Warning: no server IPv4 loopback found for {}, skipping mux cable table entry".format(neighbor)) return mux_cable_table From 17148d70fcdc99228fa31c78ab7a23ea3efd13c6 Mon Sep 17 00:00:00 2001 From: lguohan Date: Sun, 17 Jan 2021 11:05:33 -0800 Subject: [PATCH 0066/1674] [kvm]: add debug cmd for build_kvm_image.sh (#6472) dump netstat info on error Signed-off-by: Guohan Lu --- scripts/build_kvm_image.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/build_kvm_image.sh b/scripts/build_kvm_image.sh index e0a7ec2feff4..4531ca25a5f7 100755 --- a/scripts/build_kvm_image.sh +++ b/scripts/build_kvm_image.sh @@ -22,6 +22,7 @@ on_exit() on_error() { + netstat -antp echo "============= kvm_log ==============" cat $kvm_log } @@ -51,12 +52,12 @@ create_disk prepare_installer_disk echo "Prepare memory for KVM build: $vs_build_prepare_mem" -sudo mount proc /proc -t proc || true +mount proc /proc -t proc || true free -m if [[ "$vs_build_prepare_mem" == "yes" ]]; then # Force o.s. to drop cache and compact memory so that KVM can get 2G memory - sudo bash -c 'echo 1 > /proc/sys/vm/drop_caches' - sudo bash -c 'echo 1 > /proc/sys/vm/compact_memory' + bash -c 'echo 1 > /proc/sys/vm/drop_caches' + bash -c 'echo 1 > /proc/sys/vm/compact_memory' free -m fi From 9acbc591e1aa51c0bedbcfe5b46e17b71c5b921e Mon Sep 17 00:00:00 2001 From: lguohan Date: Mon, 18 Jan 2021 13:10:27 -0800 Subject: [PATCH 0067/1674] [mellanox]: fix mellanox hw-management build (#6471) use dpkg-buildpackage build with fakeroot Signed-off-by: Guohan Lu --- platform/mellanox/hw-management/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/mellanox/hw-management/Makefile b/platform/mellanox/hw-management/Makefile index 608c94e6b02a..eb087b47bfff 100644 --- a/platform/mellanox/hw-management/Makefile +++ b/platform/mellanox/hw-management/Makefile @@ -8,7 +8,7 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : pushd hw-mgmt git am ../*.patch chmod +x ./debian/rules - sudo ./debian/rules binary KVERSION=$(KVERSION) + KVERSION=$(KVERSION) dpkg-buildpackage -us -uc -b -rfakeroot -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd mv $* $(DEST)/ From 5079de764749eaadbc564c742ef432e045728ef1 Mon Sep 17 00:00:00 2001 From: Shi Su <67605788+shi-su@users.noreply.github.com> Date: Tue, 19 Jan 2021 00:23:36 -0800 Subject: [PATCH 0068/1674] [bgpd]: Check zebra is ready to connect when starting bgpd (#6478) Fix #5026 There is a race condition between zebra server accepts connections and bgpd tries to connect. Bgpd has a chance to try to connect before zebra is ready. In this scenario, bgpd will try again after 10 seconds and operate as normal within these 10 seconds. As a consequence, whatever bgpd tries to sent to zebra will be missing in the 10 seconds. To avoid such a scenario, bgpd should start after zebra is ready to accept connections. --- dockers/docker-fpm-frr/Dockerfile.j2 | 1 + dockers/docker-fpm-frr/bgpd.sh | 33 +++++++++++++++++++ .../frr/supervisord/supervisord.conf.j2 | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100755 dockers/docker-fpm-frr/bgpd.sh diff --git a/dockers/docker-fpm-frr/Dockerfile.j2 b/dockers/docker-fpm-frr/Dockerfile.j2 index ab8b585899f9..69e3655d0c39 100644 --- a/dockers/docker-fpm-frr/Dockerfile.j2 +++ b/dockers/docker-fpm-frr/Dockerfile.j2 @@ -55,6 +55,7 @@ COPY ["TSB", "/usr/bin/TSB"] COPY ["TSC", "/usr/bin/TSC"] COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] COPY ["critical_processes", "/etc/supervisor"] +COPY ["bgpd.sh", "/usr/bin/"] RUN chmod a+x /usr/bin/TSA && \ chmod a+x /usr/bin/TSB && \ chmod a+x /usr/bin/TSC diff --git a/dockers/docker-fpm-frr/bgpd.sh b/dockers/docker-fpm-frr/bgpd.sh new file mode 100755 index 000000000000..c61a594a1efc --- /dev/null +++ b/dockers/docker-fpm-frr/bgpd.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +addr="127.0.0.1" +port=2601 + +function help() +{ + echo "This script aims to ensure zebra is ready to accept connections before starting bgpd" + echo "Usage: $0 [options] [bgpd options]" + echo "Options:" + echo " -a Zebra address" + echo " -o Zebra port" + exit 1 +} + +while getopts ":a:o:h" opt; do + case "${opt}" in + h) help + ;; + a) addr=${OPTARG} + ;; + o) port=${OPTARG} + ;; + esac +done +shift $((OPTIND-1)) + +timeout 5s bash -c -- "until Date: Tue, 19 Jan 2021 15:57:42 -0800 Subject: [PATCH 0069/1674] [submodule] Update sonic-sairedis submodule pointer (#6496) [ci]: download artifacts from master branch (#768) Do not create fabric port if mapping is not available (#769) [syncd] Comparison logic log also current attr value on set operation (#763) Add fabric port test to vslib (#737) [ci]: use sonicbld pool (#766) [tests] Remove exit command blocking all tests to run (#765) [vslib]: adapt macsec sai 1.7.1 (#755) Add support for SAI_SWITCH_ATTR_AVAILABLE_IPMC_ENTRY needed by CRM (#756) Signed-off-by: Danny Allen --- src/sonic-sairedis | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-sairedis b/src/sonic-sairedis index e9401364da28..02d0371d2e0f 160000 --- a/src/sonic-sairedis +++ b/src/sonic-sairedis @@ -1 +1 @@ -Subproject commit e9401364da28259f065b2106fa8590423490f3ea +Subproject commit 02d0371d2e0fc6f87d7859346d86c638df82c464 From deea12403a29046cf43c57b56518b47837db55e9 Mon Sep 17 00:00:00 2001 From: shlomibitton <60430976+shlomibitton@users.noreply.github.com> Date: Wed, 20 Jan 2021 19:10:35 +0200 Subject: [PATCH 0070/1674] [submodule]: update sonic-utilities (#6485) - [route_check.py] - update includes checks on subscriptions (https://github.com/Azure/sonic-utilities/pull/1344) - Validations checks while adding a member to PortChannel and removing a member from a Portchannel (https://github.com/Azure/sonic-utilities/pull/1328) - [show] Add subcommand to show midplane status for modular chassis (https://github.com/Azure/sonic-utilities/pull/1267) - [pytest][qos][config] Added pytests for "config qos reload" commands" (https://github.com/Azure/sonic-utilities/pull/1346) - Drop explict 3 seconds pause between two object updates/deletes. (https://github.com/Azure/sonic-utilities/pull/1359) - [show]fix for show muxcable status by replacing "hostname" to "peer_switch" for deriving tor ipv4_address (https://github.com/Azure/sonic-utilities/pull/1360) - [PFCWD] Fix 'start' pfcwd command (https://github.com/Azure/sonic-utilities/pull/1345) Signed-off-by: Shlomi Bitton --- src/sonic-utilities | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-utilities b/src/sonic-utilities index 0a4365aaa0ad..2cbeccbc520b 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit 0a4365aaa0adadcb4c3fa448e05f6d2e217bda5f +Subproject commit 2cbeccbc520b2e767ba8dab9a30657ebc3806002 From 15c54235221c334146cd1b2069e366aeaface4d9 Mon Sep 17 00:00:00 2001 From: KISHORE KUNAL <64033340+kishorekunal01@users.noreply.github.com> Date: Wed, 20 Jan 2021 15:00:29 -0800 Subject: [PATCH 0071/1674] [frr]: ADD L3 VNI EVPN Support for SONiC, Send RMAC and VLAN along with prefix to fpmsyncd. (#4806) Currently FRR is send Prefix with VNI information to FPMSYNCD. This PR allows FRR to send RMAC with EVPN Type5 prefix to fpmsyncd. This is a temp fix. This patch will be removed once neighorch is ready to handle the Prefix and ARP (containing RMAC) separately. --- .../0008-Add-support-of-bgp-l3vni-evpn.patch | 162 ++++++++++++++++++ src/sonic-frr/patch/series | 2 +- 2 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 src/sonic-frr/patch/0008-Add-support-of-bgp-l3vni-evpn.patch diff --git a/src/sonic-frr/patch/0008-Add-support-of-bgp-l3vni-evpn.patch b/src/sonic-frr/patch/0008-Add-support-of-bgp-l3vni-evpn.patch new file mode 100644 index 000000000000..8a32e77a825e --- /dev/null +++ b/src/sonic-frr/patch/0008-Add-support-of-bgp-l3vni-evpn.patch @@ -0,0 +1,162 @@ +From 2e9ed539d29f13d874c6a5ab3120bf4bb26ab2bb Mon Sep 17 00:00:00 2001 +From: Kishore Kunal +Date: Fri, 15 Jan 2021 15:52:13 -0800 +Subject: [PATCH] This is temp patch till Prefix to ARP indirection is add in neighorch + +--- + lib/nexthop.c | 1 + + lib/nexthop.h | 7 ++++++- + zebra/rt_netlink.c | 2 +- + zebra/zapi_msg.c | 2 ++ + zebra/zebra_dplane.c | 2 +- + zebra/zebra_fpm_netlink.c | 19 +++++++++++++++++++ + 6 files changed, 30 insertions(+), 3 deletions(-) + +diff --git a/lib/nexthop.c b/lib/nexthop.c +index 0ea72d03e..02e826048 100644 +--- a/lib/nexthop.c ++++ b/lib/nexthop.c +@@ -657,6 +657,7 @@ void nexthop_copy_no_recurse(struct nexthop *copy, + nexthop_add_labels(copy, nexthop->nh_label_type, + nexthop->nh_label->num_labels, + &nexthop->nh_label->label[0]); ++ memcpy(©->nh_encap.encap_data.rmac, &nexthop->nh_encap.encap_data.rmac, ETH_ALEN); + } + + void nexthop_copy(struct nexthop *copy, const struct nexthop *nexthop, +diff --git a/lib/nexthop.h b/lib/nexthop.h +index cadcea1f4..fd959eb9e 100644 +--- a/lib/nexthop.h ++++ b/lib/nexthop.h +@@ -71,6 +71,11 @@ enum nh_encap_type { + /* Backup index value is limited */ + #define NEXTHOP_BACKUP_IDX_MAX 255 + ++struct vxlan_nh_encap { ++ vni_t vni; ++ struct ethaddr rmac; ++}; ++ + /* Nexthop structure. */ + struct nexthop { + struct nexthop *next; +@@ -140,7 +145,7 @@ struct nexthop { + /* Encapsulation information. */ + enum nh_encap_type nh_encap_type; + union { +- vni_t vni; ++ struct vxlan_nh_encap encap_data; + } nh_encap; + + /* SR-TE color used for matching SR-TE policies */ +diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c +index 50b1a62d8..d8249f8e0 100644 +--- a/zebra/rt_netlink.c ++++ b/zebra/rt_netlink.c +@@ -1590,7 +1590,7 @@ static int netlink_route_nexthop_encap(struct nlmsghdr *n, size_t nlen, + return false; + + if (!nl_attr_put32(n, nlen, 0 /* VXLAN_VNI */, +- nh->nh_encap.vni)) ++ nh->nh_encap.encap_data.vni)) + return false; + nl_attr_nest_end(n, nest); + break; +diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c +index e436e5a28..c10d50797 100644 +--- a/zebra/zapi_msg.c ++++ b/zebra/zapi_msg.c +@@ -1477,6 +1477,7 @@ static struct nexthop *nexthop_from_zapi(struct route_entry *re, + zebra_vxlan_evpn_vrf_route_add( + api_nh->vrf_id, &api_nh->rmac, + &vtep_ip, &api->prefix); ++ memcpy(&(nexthop->nh_encap.encap_data.rmac), &api_nh->rmac, ETH_ALEN); + } + break; + case NEXTHOP_TYPE_IPV6: +@@ -1511,6 +1512,7 @@ static struct nexthop *nexthop_from_zapi(struct route_entry *re, + zebra_vxlan_evpn_vrf_route_add( + api_nh->vrf_id, &api_nh->rmac, + &vtep_ip, &api->prefix); ++ memcpy(&(nexthop->nh_encap.encap_data.rmac), &api_nh->rmac, ETH_ALEN); + } + break; + case NEXTHOP_TYPE_BLACKHOLE: +diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c +index abd0adb64..e66d7aae5 100644 +--- a/zebra/zebra_dplane.c ++++ b/zebra/zebra_dplane.c +@@ -1891,7 +1891,7 @@ int dplane_ctx_route_init(struct zebra_dplane_ctx *ctx, enum dplane_op_e op, + zl3vni = zl3vni_from_vrf(nexthop->vrf_id); + if (zl3vni && is_l3vni_oper_up(zl3vni)) { + nexthop->nh_encap_type = NET_VXLAN; +- nexthop->nh_encap.vni = zl3vni->vni; ++ nexthop->nh_encap.encap_data.vni = zl3vni->vni; + } + } + +diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c +index 2c0741363..2731f64fb 100644 +--- a/zebra/zebra_fpm_netlink.c ++++ b/zebra/zebra_fpm_netlink.c +@@ -129,10 +129,12 @@ static const char *fpm_nh_encap_type_to_str(enum fpm_nh_encap_type_t encap_type) + + struct vxlan_encap_info_t { + vni_t vni; ++ struct ethaddr rmac; + }; + + enum vxlan_encap_info_type_t { + VXLAN_VNI = 0, ++ VXLAN_RMAC = 1, + }; + + struct fpm_nh_encap_info_t { +@@ -238,6 +240,8 @@ static int netlink_route_info_add_nh(struct netlink_route_info *ri, + + /* Add VNI to VxLAN encap info */ + nhi.encap_info.vxlan_encap.vni = zl3vni->vni; ++ memcpy(&nhi.encap_info.vxlan_encap.rmac, &(nexthop->nh_encap.encap_data.rmac), ++ ETH_ALEN); + } + } + +@@ -454,9 +458,16 @@ static int netlink_route_info_encode(struct netlink_route_info *ri, + nl_attr_put16(&req->n, in_buf_len, RTA_ENCAP_TYPE, + encap); + vxlan = &nhi->encap_info.vxlan_encap; ++ char buf[ETHER_ADDR_STRLEN]; ++ ++ zfpm_debug( ++ "%s: VNI:%d RMAC:%s", __func__, vxlan->vni, ++ prefix_mac2str(&vxlan->rmac, buf, sizeof(buf))); + nest = nl_attr_nest(&req->n, in_buf_len, RTA_ENCAP); + nl_attr_put32(&req->n, in_buf_len, VXLAN_VNI, + vxlan->vni); ++ nl_attr_put(&req->n, in_buf_len, VXLAN_RMAC, ++ &vxlan->rmac, sizeof(vxlan->rmac)); + nl_attr_nest_end(&req->n, nest); + break; + } +@@ -490,10 +501,18 @@ static int netlink_route_info_encode(struct netlink_route_info *ri, + nl_attr_put16(&req->n, in_buf_len, RTA_ENCAP_TYPE, + encap); + vxlan = &nhi->encap_info.vxlan_encap; ++ char rmac_buf[ETHER_ADDR_STRLEN]; ++ ++ zfpm_debug("%s: Multi VNI:%d RMAC:%s", __func__, ++ vxlan->vni, ++ prefix_mac2str(&vxlan->rmac, rmac_buf, ++ sizeof(rmac_buf))); + inner_nest = + nl_attr_nest(&req->n, in_buf_len, RTA_ENCAP); + nl_attr_put32(&req->n, in_buf_len, VXLAN_VNI, + vxlan->vni); ++ nl_attr_put(&req->n, in_buf_len, VXLAN_RMAC, ++ &vxlan->rmac, sizeof(vxlan->rmac)); + nl_attr_nest_end(&req->n, inner_nest); + break; + } +-- +2.18.0 + diff --git a/src/sonic-frr/patch/series b/src/sonic-frr/patch/series index d7c209e9b478..69dd5991a7cb 100644 --- a/src/sonic-frr/patch/series +++ b/src/sonic-frr/patch/series @@ -4,4 +4,4 @@ 0004-Allow-BGP-attr-NEXT_HOP-to-be-0.0.0.0-due-to-allevia.patch 0005-nexthops-compare-vrf-only-if-ip-type.patch 0007-frr-remove-frr-log-outchannel-to-var-log-frr.log.patch - +0008-Add-support-of-bgp-l3vni-evpn.patch From 039f5c253c917a98a40308b379f9bc336bee1cfc Mon Sep 17 00:00:00 2001 From: Tamer Ahmed Date: Thu, 21 Jan 2021 00:25:08 -0800 Subject: [PATCH 0072/1674] [submodule]: Update SONiC Utilities Submodule (#6507) Changes in this update: 37695c8 [show]: Use TCP Connection For Muxcable Commands (#1371) 8119ba2 Validations checks while creating and deleting a Portchannel (#1326) 3df267e [config] Fix Breakout mode option and BREAKOUT_CFG table check method (#1270) 9bd709b [show] Fix show arp in case with FDB entries, linked to default VLAN (#1357) bc2d27e [generate_dump]: fix syntax error signed-of-by: Tamer Ahmed --- src/sonic-utilities | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-utilities b/src/sonic-utilities index 2cbeccbc520b..37695c83cf86 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit 2cbeccbc520b2e767ba8dab9a30657ebc3806002 +Subproject commit 37695c83cf86b7a163fcf2ffef949b116fe9d2b9 From c5b7370a8fabfcb62d79a37ecd87c192108f0726 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Thu, 21 Jan 2021 08:28:32 -0800 Subject: [PATCH 0073/1674] [baseimage]: Cleanup sudoers file (#6518) --- files/image_config/sudoers/sudoers | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/files/image_config/sudoers/sudoers b/files/image_config/sudoers/sudoers index 9e59c8854305..4c2e684b4b1f 100644 --- a/files/image_config/sudoers/sudoers +++ b/files/image_config/sudoers/sudoers @@ -23,9 +23,8 @@ Cmnd_Alias READ_ONLY_CMDS = /bin/cat /var/log/syslog*, \ /sbin/brctl show, \ /usr/bin/docker exec snmp cat /etc/snmp/snmpd.conf, \ /usr/bin/docker exec bgp cat /etc/quagga/bgpd.conf, \ - /usr/bin/docker exec * ps aux, \ /usr/bin/docker images *, \ - /usr/bin/docker ps*, \ + /usr/bin/docker ps *, \ /usr/bin/lldpctl, \ /usr/bin/sensors, \ /usr/bin/tail -F /var/log/syslog, \ From 77ec2ee14e2fbc808bf75db8a913609872d614db Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Thu, 21 Jan 2021 11:14:15 -0800 Subject: [PATCH 0074/1674] [sonic-swss] Update submodule (#6336) Including below commits: 36f7332 2021-01-14 | modified ERR log to NOTICE log for FDB notification failure after VLAN delete (#1595) [madhanmellanox] c21c883 2021-01-12 | [ci]: download artifacts from master branch build (#1597) [lguohan] a1d03a4 2021-01-12 | [fgnhgorch] Match mode changes for Fine Grained ECMP (#1565) [anish-n] 1b65f3d 2021-01-12 | [ci]: use sonicbld pool (#1594) [lguohan] 48ae866 2021-01-12 | [pfcwd] Update PFC storm detection logic for Mellanox platforms (#1586) [Volodymyr Samotiy] 850001f 2021-01-12 | [FPMSYNCD] Evpn/Vxlan related changes to support FRR7.5(#1585) [KISHORE KUNAL] 64ca9bb 2021-01-12 | [ci]: only copy artifacts when build is successful (#1590) [lguohan] 17d0dae 2021-01-11 | [Fdborch] Fix for arm compilation (#1592) [Prince Sunny] 693a02c 2021-01-08 | [gearbox] Add support for "hwinfo" field (#1547) [Baptiste Covolato] 7e3b2c6 2021-01-09 | [Evpn Warmreboot] Added Dependancy check logic in VrfMgr (#1466) [nkelapur] a960e2e 2021-01-09 | [Orchagent]: FdbOrch changes for EVPN VXLAN (#1275) [Pankaj Jain] 097cfda 2021-01-08 | [swss test] update setup guide for swss tests (#1582) [Ying Xie] b42253a 2021-01-05 | Fix for armhf build (#1580) [Qi Luo] d8c1465 2021-01-05 | [dvs] Update/disable DVS tests with new FRR 7.5 behavior (#1579) [Danny Allen] f6c7422 2021-01-05 | ASIC internal temperature sensors support (#1517) [Santhosh Kumar T] 0aa9ef2 2021-01-01 | Simply by auto iterator type, because we will tune the return types of library functions (#1577) [Qi Luo] 773238b 2020-12-31 | [build]: Fix format string for size_t (#1576) [Qi Luo] 7ba4e43 2020-12-30 | [fgnhgorch] add warm reboot support for fgnhg (#1538) [weixchen1215] 4cf6617 2020-12-30 | [ci]: add build for arm64 and armhf (#1572) [lguohan] 6ebc0ed 2020-12-29 | [ci]: add azure-pipeline for amd64 (#1571) [lguohan] e32b9d0 2020-12-29 | [FDBSYNCD] Added pytest for fdbsyncd (#1560) [KISHORE KUNAL] a43f6be 2020-12-30 | [crm] Add support for snat, dnat and ipmc crm resources (#1511) [Prabhu Sreenivasan] 7fc3888 2020-12-29 | PY Test script for EVPN L3 VxLAN (#1330) [Tapash Das] 6eb36d9 2020-12-27 | vlanmgr changes related to EVPN VxLan warmboot (#1460) [anilkpan] Signed-off-by: Guohan Lu --- src/sonic-swss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-swss b/src/sonic-swss index 321291aa7aca..36f7332ddab5 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit 321291aa7aca89a3ccef2bed36aff074eac1054f +Subproject commit 36f7332ddab56c618513c4b57edc99e3b735c27c From 28b62bee3fd0cd9a56a525c0e38da4ec05014799 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Wed, 20 Jan 2021 12:06:08 -0800 Subject: [PATCH 0075/1674] sonic-config-engine uses libswsscommon instead of swsssdk (#6406) **- Why I did it** swsssdk will be deprecated. Migrate sonic-config-engine to use libswsscommon library instead **- How to verify it** Unit test --- platform/vs/docker-sonic-vs/start.sh | 8 +++++--- rules/sonic-config.mk | 6 ++++-- src/sonic-config-engine/portconfig.py | 2 +- src/sonic-config-engine/redis_bcc.py | 4 ++-- src/sonic-config-engine/sonic-cfggen | 2 +- src/sonic-swss-common | 2 +- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/platform/vs/docker-sonic-vs/start.sh b/platform/vs/docker-sonic-vs/start.sh index 7b246a49de1a..7ee70efa0815 100755 --- a/platform/vs/docker-sonic-vs/start.sh +++ b/platform/vs/docker-sonic-vs/start.sh @@ -31,6 +31,11 @@ if [[ -f /usr/share/sonic/virtual_chassis/default_config.json ]]; then CHASS_CFG="-j /usr/share/sonic/virtual_chassis/default_config.json" fi +# Note: libswsscommon requires a dabase_config file in /var/run/redis/sonic-db/ +# Prepare this file before any dependent application, such as sonic-cfggen +mkdir -p /var/run/redis/sonic-db +cp /etc/default/sonic-db/database_config.json /var/run/redis/sonic-db/ + SYSTEM_MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}') sonic-cfggen -a '{"DEVICE_METADATA":{"localhost": {"mac": "'$SYSTEM_MAC_ADDRESS'", "buffer_model": "traditional"}}}' $CHASS_CFG --print-data > /etc/sonic/init_cfg.json @@ -68,9 +73,6 @@ else echo "10.8.1.200 redis_chassis.server" >> /etc/hosts fi -mkdir -p /var/run/redis/sonic-db -cp /etc/default/sonic-db/database_config.json /var/run/redis/sonic-db/ - supervisorctl start redis-server start_chassis_db=`sonic-cfggen -v DEVICE_METADATA.localhost.start_chassis_db -y $chassisdb_cfg_file` diff --git a/rules/sonic-config.mk b/rules/sonic-config.mk index 996e311b5fee..e8e59fc1b92d 100644 --- a/rules/sonic-config.mk +++ b/rules/sonic-config.mk @@ -2,7 +2,8 @@ SONIC_CONFIG_ENGINE_PY2 = sonic_config_engine-1.0-py2-none-any.whl $(SONIC_CONFIG_ENGINE_PY2)_SRC_PATH = $(SRC_PATH)/sonic-config-engine -$(SONIC_CONFIG_ENGINE_PY2)_DEPENDS += $(SWSSSDK_PY2) $(SONIC_PY_COMMON_PY2) +$(SONIC_CONFIG_ENGINE_PY2)_DEPENDS += $(SONIC_PY_COMMON_PY2) +$(SONIC_CONFIG_ENGINE_PY2)_DEBS_DEPENDS += $(PYTHON_SWSSCOMMON) $(SONIC_CONFIG_ENGINE_PY2)_PYTHON_VERSION = 2 SONIC_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY2) @@ -10,7 +11,8 @@ SONIC_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY2) SONIC_CONFIG_ENGINE_PY3 = sonic_config_engine-1.0-py3-none-any.whl $(SONIC_CONFIG_ENGINE_PY3)_SRC_PATH = $(SRC_PATH)/sonic-config-engine -$(SONIC_CONFIG_ENGINE_PY3)_DEPENDS += $(SWSSSDK_PY3) $(SONIC_PY_COMMON_PY3) +$(SONIC_CONFIG_ENGINE_PY3)_DEPENDS += $(SONIC_PY_COMMON_PY3) +$(SONIC_CONFIG_ENGINE_PY3)_DEBS_DEPENDS += $(PYTHON3_SWSSCOMMON) # Synthetic dependency to avoid building the Python 2 and 3 packages # simultaneously and any potential conflicts which may arise $(SONIC_CONFIG_ENGINE_PY3)_DEPENDS += $(SONIC_CONFIG_ENGINE_PY2) diff --git a/src/sonic-config-engine/portconfig.py b/src/sonic-config-engine/portconfig.py index d20212eb55aa..8a3177f31b9a 100644 --- a/src/sonic-config-engine/portconfig.py +++ b/src/sonic-config-engine/portconfig.py @@ -5,7 +5,7 @@ import re import sys - from swsssdk import ConfigDBConnector + from swsscommon.swsscommon import ConfigDBConnector from sonic_py_common import device_info except ImportError as e: raise ImportError("%s - required module not found" % str(e)) diff --git a/src/sonic-config-engine/redis_bcc.py b/src/sonic-config-engine/redis_bcc.py index 1045e0c5c8b8..c9d3ebca239f 100644 --- a/src/sonic-config-engine/redis_bcc.py +++ b/src/sonic-config-engine/redis_bcc.py @@ -19,11 +19,11 @@ def load_bytecode(self, bucket): return code = self._client.get(self._client.LOGLEVEL_DB, self.REDIS_HASH, bucket.key) if code is not None: - bucket.bytecode_from_string(b64decode(code)) + bucket.bytecode_from_string(b64decode(code.encode())) def dump_bytecode(self, bucket): if self._client is None: return self._client.set(self._client.LOGLEVEL_DB, self.REDIS_HASH, - bucket.key, b64encode(bucket.bytecode_to_string())) + bucket.key, b64encode(bucket.bytecode_to_string()).decode()) diff --git a/src/sonic-config-engine/sonic-cfggen b/src/sonic-config-engine/sonic-cfggen index af638c2c2826..0f9ffafad635 100755 --- a/src/sonic-config-engine/sonic-cfggen +++ b/src/sonic-config-engine/sonic-cfggen @@ -43,7 +43,7 @@ from portconfig import get_port_config, get_breakout_mode from redis_bcc import RedisBytecodeCache from sonic_py_common.multi_asic import get_asic_id_from_name, is_multi_asic from sonic_py_common import device_info -from swsssdk import SonicV2Connector, ConfigDBConnector, SonicDBConfig, ConfigDBPipeConnector +from swsscommon.swsscommon import SonicV2Connector, ConfigDBConnector, SonicDBConfig, ConfigDBPipeConnector PY3x = sys.version_info >= (3, 0) diff --git a/src/sonic-swss-common b/src/sonic-swss-common index 2db7bea9963a..2f79bb49d138 160000 --- a/src/sonic-swss-common +++ b/src/sonic-swss-common @@ -1 +1 @@ -Subproject commit 2db7bea9963a988a575b8075e1f6c5369d057230 +Subproject commit 2f79bb49d13820f2c108e4e27a2a12181713662f From 4220f1c2dd964b81fa34a2eff3dba5d0f3cc2fb3 Mon Sep 17 00:00:00 2001 From: Tamer Ahmed Date: Thu, 21 Jan 2021 12:11:04 -0800 Subject: [PATCH 0076/1674] [sonic-swss-common]: Update Submodule (#6508) Update in this change: 640a218 [packaging]: Add Support For Libboost v1.71.0 (#449) signed-off-by: Tamer Ahmed --- src/sonic-swss-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-swss-common b/src/sonic-swss-common index 2f79bb49d138..640a218759b5 160000 --- a/src/sonic-swss-common +++ b/src/sonic-swss-common @@ -1 +1 @@ -Subproject commit 2f79bb49d13820f2c108e4e27a2a12181713662f +Subproject commit 640a218759b5b490d505cadaca652f4821bba878 From 1923920b3353f1dd091df3159e68afb05e7f2d3c Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Thu, 21 Jan 2021 15:05:35 -0800 Subject: [PATCH 0077/1674] [minigraph.py]: Force /128 prefix for server IPv6 loopbacks (#6524) Meet the requirement for the MUX_CABLE table that IPv6 loopbacks have a /128 prefix Note that this change only affects the MUX_CABLE table, all other tables continue to use the loopback address provided in minigraph. Signed-off-by: Lawrence Lee --- src/sonic-config-engine/minigraph.py | 6 ++++-- src/sonic-config-engine/tests/simple-sample-graph-case.xml | 2 +- src/sonic-config-engine/tests/test_minigraph_case.py | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index f30e668251a3..ba81e8faf771 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -1512,8 +1512,10 @@ def get_mux_cable_entries(mux_cable_ports, neighbors, devices): server_ipv4_lo_prefix = ipaddress.ip_network(UNICODE_TYPE(server_ipv4_lo_addr)) entry['server_ipv4'] = str(server_ipv4_lo_prefix) - if 'lo_addr_v6' in devices[neighbor]: - entry['server_ipv6'] = devices[neighbor]['lo_addr_v6'] + if 'lo_addr_v6' in devices[neighbor] and devices[neighbor]['lo_addr_v6'] is not None: + server_ipv6_lo_addr = devices[neighbor]['lo_addr_v6'].split('/')[0] + server_ipv6_lo_prefix = ipaddress.ip_network(UNICODE_TYPE(server_ipv6_lo_addr)) + entry['server_ipv6'] = str(server_ipv6_lo_prefix) mux_cable_table[intf] = entry else: print("Warning: no server IPv4 loopback found for {}, skipping mux cable table entry".format(neighbor)) 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 d9a21158c4a2..ce0174adc8dd 100644 --- a/src/sonic-config-engine/tests/simple-sample-graph-case.xml +++ b/src/sonic-config-engine/tests/simple-sample-graph-case.xml @@ -303,7 +303,7 @@ 10.10.10.1/32 - fe80::0001/128 + fe80::0001/80 10.0.0.1/32 diff --git a/src/sonic-config-engine/tests/test_minigraph_case.py b/src/sonic-config-engine/tests/test_minigraph_case.py index cf8a7557aeb7..6fa7c5352d05 100644 --- a/src/sonic-config-engine/tests/test_minigraph_case.py +++ b/src/sonic-config-engine/tests/test_minigraph_case.py @@ -165,7 +165,7 @@ def test_minigraph_neighbor_metadata(self): 'server1': { 'hwsku': 'server-sku', 'lo_addr': '10.10.10.1/32', - 'lo_addr_v6': 'fe80::0001/128', + 'lo_addr_v6': 'fe80::0001/80', 'mgmt_addr': '10.0.0.1/32', 'type': 'Server' }, @@ -275,12 +275,12 @@ def test_minigraph_mux_cable_table(self): 'Ethernet4': { 'state': 'auto', 'server_ipv4': '10.10.10.1/32', - 'server_ipv6': 'fe80::0001/128' + 'server_ipv6': 'fe80::1/128' }, 'Ethernet8': { 'state': 'auto', 'server_ipv4': '10.10.10.2/32', - 'server_ipv6': 'fe80::0002/128' + 'server_ipv6': 'fe80::2/128' } } From dbe71dfdeb9495f050f379c9bebbd158404d7f17 Mon Sep 17 00:00:00 2001 From: abdosi <58047199+abdosi@users.noreply.github.com> Date: Fri, 22 Jan 2021 08:29:27 -0800 Subject: [PATCH 0078/1674] Updated BBR to use peer group name as prefix. (#6515) To make BBR configured for peer-group if it's name starts with (prefixed) with the string define in constants.yml instead of exact string match. --- src/sonic-bgpcfgd/bgpcfgd/managers_bbr.py | 7 ++-- src/sonic-bgpcfgd/tests/test_bbr.py | 40 +++++++++++++++++++++-- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/sonic-bgpcfgd/bgpcfgd/managers_bbr.py b/src/sonic-bgpcfgd/bgpcfgd/managers_bbr.py index 27f3646ac421..0e82d0a4b6d5 100644 --- a/src/sonic-bgpcfgd/bgpcfgd/managers_bbr.py +++ b/src/sonic-bgpcfgd/bgpcfgd/managers_bbr.py @@ -113,9 +113,10 @@ def __set_prepare_config(self, status): for af in ["ipv4", "ipv6"]: cmds.append(" address-family %s" % af) for pg_name in sorted(self.bbr_enabled_pgs.keys()): - if pg_name in available_peer_groups and af in self.bbr_enabled_pgs[pg_name]: - cmds.append(" %sneighbor %s allowas-in 1" % (prefix_of_commands, pg_name)) - peer_groups_to_restart.add(pg_name) + for peer_group_name in available_peer_groups: + if peer_group_name.startswith(pg_name) and af in self.bbr_enabled_pgs[pg_name]: + cmds.append(" %sneighbor %s allowas-in 1" % (prefix_of_commands, peer_group_name)) + peer_groups_to_restart.add(peer_group_name) return cmds, list(peer_groups_to_restart) def __get_available_peer_groups(self): diff --git a/src/sonic-bgpcfgd/tests/test_bbr.py b/src/sonic-bgpcfgd/tests/test_bbr.py index 45b8aa7c8f07..b11277bae7b8 100644 --- a/src/sonic-bgpcfgd/tests/test_bbr.py +++ b/src/sonic-bgpcfgd/tests/test_bbr.py @@ -252,7 +252,7 @@ def test___set_validation_4(): def test___set_validation_5(): __set_validation_common("all", {"status": "disabled"}, None, True) -def __set_prepare_config_common(status, bbr_enabled_pgs, available_pgs, expected_cmds): +def __set_prepare_config_common(status, bbr_enabled_pgs, available_pgs, expected_cmds, bbr_applied_pgs=None): cfg_mgr = MagicMock() common_objs = { 'directory': Directory(), @@ -269,10 +269,10 @@ def __set_prepare_config_common(status, bbr_enabled_pgs, available_pgs, expected } } m.bbr_enabled_pgs = bbr_enabled_pgs - m._BBRMgr__get_available_peer_groups = MagicMock(return_value = available_pgs) + m._BBRMgr__get_available_peer_groups = MagicMock(return_value = sorted(available_pgs)) cmds, peer_groups = m._BBRMgr__set_prepare_config(status) assert cmds == expected_cmds - assert set(peer_groups) == available_pgs + assert set(peer_groups) == (available_pgs if not bbr_applied_pgs else bbr_applied_pgs) def test___set_prepare_config_enabled(): __set_prepare_config_common("enabled", { @@ -327,7 +327,41 @@ def test___set_prepare_config_disabled_part(): ' no neighbor PEER_V4 allowas-in 1', ' no neighbor PEER_V6 allowas-in 1', ]) +def test___set_prepare_config_enabled_multiple_peers(): + __set_prepare_config_common("enabled", { + "PEER_V4": ["ipv4"], + "PEER_V6": ["ipv6"], + }, {"PEER_V4", "PEER_V4_DEPLOYMENT_ID_0", "PEER_V4_DEPLOYMENT_ID_1", "PEER_V6", "PEER_V6_DEPLOYMENT_ID_0", "PEER_V6_DEPLOYMENT_ID_1", "PEER_INVALID"}, + [ + 'router bgp 65500', + ' address-family ipv4', + ' neighbor PEER_V4 allowas-in 1', + ' neighbor PEER_V4_DEPLOYMENT_ID_0 allowas-in 1', + ' neighbor PEER_V4_DEPLOYMENT_ID_1 allowas-in 1', + ' address-family ipv6', + ' neighbor PEER_V6 allowas-in 1', + ' neighbor PEER_V6_DEPLOYMENT_ID_0 allowas-in 1', + ' neighbor PEER_V6_DEPLOYMENT_ID_1 allowas-in 1', + ], + {"PEER_V4", "PEER_V4_DEPLOYMENT_ID_0", "PEER_V4_DEPLOYMENT_ID_1", "PEER_V6", "PEER_V6_DEPLOYMENT_ID_0", "PEER_V6_DEPLOYMENT_ID_1"}) +def test___set_prepare_config_disabled_multiple_peers(): + __set_prepare_config_common("disabled", { + "PEER_V4": ["ipv4"], + "PEER_V6": ["ipv6"], + }, {"PEER_V4", "PEER_V4_DEPLOYMENT_ID_0", "PEER_V4_DEPLOYMENT_ID_1", "PEER_V6", "PEER_V6_DEPLOYMENT_ID_0", "PEER_V6_DEPLOYMENT_ID_1", "PEER_INVALID"}, + [ + 'router bgp 65500', + ' address-family ipv4', + ' no neighbor PEER_V4 allowas-in 1', + ' no neighbor PEER_V4_DEPLOYMENT_ID_0 allowas-in 1', + ' no neighbor PEER_V4_DEPLOYMENT_ID_1 allowas-in 1', + ' address-family ipv6', + ' no neighbor PEER_V6 allowas-in 1', + ' no neighbor PEER_V6_DEPLOYMENT_ID_0 allowas-in 1', + ' no neighbor PEER_V6_DEPLOYMENT_ID_1 allowas-in 1', + ], + {"PEER_V4", "PEER_V4_DEPLOYMENT_ID_0", "PEER_V4_DEPLOYMENT_ID_1", "PEER_V6", "PEER_V6_DEPLOYMENT_ID_0", "PEER_V6_DEPLOYMENT_ID_1"}) def test__get_available_peer_groups(): cfg_mgr = MagicMock() From 32c20bdbe4a655d074cebba13f5124902a8b06da Mon Sep 17 00:00:00 2001 From: Prince Sunny Date: Fri, 22 Jan 2021 09:31:53 -0800 Subject: [PATCH 0079/1674] Submodule update swss-common (#6525) --- src/sonic-swss-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-swss-common b/src/sonic-swss-common index 640a218759b5..e49b18f2512a 160000 --- a/src/sonic-swss-common +++ b/src/sonic-swss-common @@ -1 +1 @@ -Subproject commit 640a218759b5b490d505cadaca652f4821bba878 +Subproject commit e49b18f2512a9331579cea37ab199730051a68e9 From 9dfee1f09a9d6e0d38f9282da4f0df2e5908d37b Mon Sep 17 00:00:00 2001 From: Samuel Angebault Date: Fri, 22 Jan 2021 07:12:01 -0800 Subject: [PATCH 0080/1674] [pmon]: Run ledd using python3 unless excluded (#6528) **- Why I did it** Ledd is the last daemon that is not enabled to run in python3. Even though there is a plan to deprecate this daemon and to replace it by something else it's one simple step toward python2 deprecation. **- How I did it** Changed the `command=` line for `ledd` in the `supervisord` configuration of `pmon`. Copied what was done for other daemons. **- How to verify it** Booting a product that has a `led_control.py` should now show the ledd running in python3. I ran `python3 -m pylint` on all `led_control.py` plugin which means that most of them should be python3 compliant. There is however still a risk that some might not work. --- dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2 b/dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2 index 7f816d33394d..3de20178b224 100644 --- a/dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2 +++ b/dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2 @@ -68,7 +68,7 @@ dependent_startup_wait_for=rsyslogd:running {% if not skip_ledd %} [program:ledd] -command=/usr/local/bin/ledd +command={% if API_VERSION == 3 and 'ledd' not in python2_daemons %}python3 {% else %} python2 {% endif %}/usr/local/bin/ledd priority=5 autostart=false autorestart=false From 1239310e02485fed1d1fea380684ed8b1b00b7b4 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Sat, 23 Jan 2021 00:25:11 -0800 Subject: [PATCH 0081/1674] [docker-config-engine-stretch]: Add missing dependency PYTHON2_SWSSCOMMON (#6538) Otherwise all the docker image derived from docker-config-engine-stretch will have broken SONIC_CONFIG_ENGINE_PY2 The bug is introduced in #6406 --- rules/docker-config-engine-stretch.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/rules/docker-config-engine-stretch.mk b/rules/docker-config-engine-stretch.mk index 485e10fbb713..ad112bb034dc 100644 --- a/rules/docker-config-engine-stretch.mk +++ b/rules/docker-config-engine-stretch.mk @@ -2,6 +2,7 @@ DOCKER_CONFIG_ENGINE_STRETCH = docker-config-engine-stretch.gz $(DOCKER_CONFIG_ENGINE_STRETCH)_PATH = $(DOCKERS_PATH)/docker-config-engine-stretch +$(DOCKER_CONFIG_ENGINE_STRETCH)_DEPENDS += $(LIBSWSSCOMMON) $(PYTHON2_SWSSCOMMON) $(DOCKER_CONFIG_ENGINE_STRETCH)_PYTHON_WHEELS += $(SWSSSDK_PY2) $(DOCKER_CONFIG_ENGINE_STRETCH)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY2) $(DOCKER_CONFIG_ENGINE_STRETCH)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY2) From bedd05bb4384accd627241af4fada8ff872b6860 Mon Sep 17 00:00:00 2001 From: Danny Allen Date: Sat, 23 Jan 2021 00:26:46 -0800 Subject: [PATCH 0082/1674] [DellEMC Z9332f] Remove duplicate ipmihelper.py script (#6536) Fixes #6445 Because the ipmihelper.py script in the 9332 folder is slightly different than the common one (due to LGTM fixes), when the common one gets copied during build time it causes the workspace/build to become dirty. Signed-off-by: Danny Allen --- .../common/ipmihelper.py | 6 +- .../z9332f/sonic_platform/ipmihelper.py | 269 ------------------ 2 files changed, 3 insertions(+), 272 deletions(-) delete mode 100644 platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/ipmihelper.py diff --git a/platform/broadcom/sonic-platform-modules-dell/common/ipmihelper.py b/platform/broadcom/sonic-platform-modules-dell/common/ipmihelper.py index f70c505d4914..ceeaebfbf047 100644 --- a/platform/broadcom/sonic-platform-modules-dell/common/ipmihelper.py +++ b/platform/broadcom/sonic-platform-modules-dell/common/ipmihelper.py @@ -38,7 +38,7 @@ def get_ipmitool_raw_output(args): proc.wait() if not proc.returncode: result = stdout.rstrip('\n') - except: + except EnvironmentError: pass for i in result.split(): @@ -180,7 +180,7 @@ def _get_ipmitool_fru_print(self): proc.wait() if not proc.returncode: result = stdout.decode('utf-8').rstrip('\n') - except: + except EnvironmentError: pass return result @@ -253,7 +253,7 @@ def get_fru_data(self, offset, count=1): proc.wait() if not proc.returncode: result = stdout.decode('utf-8').rstrip('\n') - except: + except EnvironmentError: is_valid = False if (not result) or (not is_valid): diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/ipmihelper.py b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/ipmihelper.py deleted file mode 100644 index ceeaebfbf047..000000000000 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/ipmihelper.py +++ /dev/null @@ -1,269 +0,0 @@ -#!/usr/bin/python3 - -######################################################################## -# DellEMC -# -# Module contains implementation of IpmiSensor and IpmiFru classes that -# provide Sensor's and FRU's information respectively. -# -######################################################################## - -import subprocess -import re - -# IPMI Request Network Function Codes -NetFn_SensorEvent = 0x04 -NetFn_Storage = 0x0A - -# IPMI Sensor Device Commands -Cmd_GetSensorReadingFactors = 0x23 -Cmd_GetSensorThreshold = 0x27 -Cmd_GetSensorReading = 0x2D - -# IPMI FRU Device Commands -Cmd_ReadFRUData = 0x11 - -def get_ipmitool_raw_output(args): - """ - Returns a list the elements of which are the individual bytes of - ipmitool raw command output. - """ - result_bytes = list() - result = "" - command = "ipmitool raw {}".format(args) - try: - proc = subprocess.Popen(command.split(), stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - stdout = proc.communicate()[0] - proc.wait() - if not proc.returncode: - result = stdout.rstrip('\n') - except EnvironmentError: - pass - - for i in result.split(): - result_bytes.append(int(i, 16)) - - return result_bytes - -class IpmiSensor(object): - - # Sensor Threshold types and their respective bit masks - THRESHOLD_BIT_MASK = { - "LowerNonCritical" : 0, - "LowerCritical" : 1, - "LowerNonRecoverable" : 2, - "UpperNonCritical" : 3, - "UpperCritical" : 4, - "UpperNonRecoverable" : 5 - } - - def __init__(self, sensor_id, is_discrete=False): - self.id = sensor_id - self.is_discrete = is_discrete - - def _get_converted_sensor_reading(self, raw_value): - """ - Returns a 2 element tuple(bool, int) in which first element - provides the validity of the reading and the second element is - the converted sensor reading - """ - # Get Sensor Reading Factors - cmd_args = "{} {} {} {}".format(NetFn_SensorEvent, - Cmd_GetSensorReadingFactors, - self.id, raw_value) - factors = get_ipmitool_raw_output(cmd_args) - - if len(factors) != 7: - return False, 0 - - # Compute Twos complement - def get_twos_complement(val, bits): - if val & (1 << (bits - 1)): - val = val - (1 << bits) - return val - - # Calculate actual sensor value from the raw sensor value - # using the sensor reading factors. - M = get_twos_complement(((factors[2] & 0xC0) << 8) | factors[1], 10) - B = get_twos_complement(((factors[4] & 0xC0) << 8) | factors[3], 10) - R_exp = get_twos_complement((factors[6] & 0xF0) >> 4, 4) - B_exp = get_twos_complement(factors[6] & 0x0F, 4) - - converted_reading = ((M * raw_value) + (B * 10**B_exp)) * 10**R_exp - - return True, converted_reading - - def get_reading(self): - """ - For Threshold sensors, returns the sensor reading. - For Discrete sensors, returns the state value. - - Returns: - A tuple (bool, int) where the first element provides the - validity of the reading and the second element provides the - sensor reading/state value. - """ - # Get Sensor Reading - cmd_args = "{} {} {}".format(NetFn_SensorEvent, Cmd_GetSensorReading, - self.id) - output = get_ipmitool_raw_output(cmd_args) - if len(output) != 4: - return False, 0 - - # Check reading/state unavailable - if output[1] & 0x20: - return False, 0 - - if self.is_discrete: - state = ((output[3] & 0x7F) << 8) | output[2] - return True, state - else: - return self._get_converted_sensor_reading(output[0]) - - def get_threshold(self, threshold_type): - """ - Returns the sensor's threshold value for a given threshold type. - - Args: - threshold_type (str) - one of the below mentioned - threshold type strings - - "LowerNonCritical" - "LowerCritical" - "LowerNonRecoverable" - "UpperNonCritical" - "UpperCritical" - "UpperNonRecoverable" - Returns: - A tuple (bool, int) where the first element provides the - validity of that threshold and second element provides the - threshold value. - """ - # Thresholds are not valid for discrete sensors - if self.is_discrete: - raise TypeError("Threshold is not applicable for Discrete Sensor") - - if threshold_type not in list(self.THRESHOLD_BIT_MASK.keys()): - raise ValueError("Invalid threshold type {} provided. Valid types " - "are {}".format(threshold_type, - list(self.THRESHOLD_BIT_MASK.keys()))) - - bit_mask = self.THRESHOLD_BIT_MASK[threshold_type] - - # Get Sensor Threshold - cmd_args = "{} {} {}".format(NetFn_SensorEvent, Cmd_GetSensorThreshold, - self.id) - thresholds = get_ipmitool_raw_output(cmd_args) - if len(thresholds) != 7: - return False, 0 - - valid_thresholds = thresholds.pop(0) - # Check whether particular threshold is readable - if valid_thresholds & (1 << bit_mask): - return self._get_converted_sensor_reading(thresholds[bit_mask]) - else: - return False, 0 - -class IpmiFru(object): - - def __init__(self, fru_id): - self.id = fru_id - - def _get_ipmitool_fru_print(self): - result = "" - command = "ipmitool fru print {}".format(self.id) - try: - proc = subprocess.Popen(command.split(), stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - stdout = proc.communicate()[0] - proc.wait() - if not proc.returncode: - result = stdout.decode('utf-8').rstrip('\n') - except EnvironmentError: - pass - - return result - - def _get_from_fru(self, info): - """ - Returns a string containing the info from FRU - """ - fru_output = self._get_ipmitool_fru_print() - if not fru_output: - return "NA" - - info_req = re.search(r"%s\s*:(.*)" % info, fru_output) - if not info_req: - return "NA" - - return info_req.group(1).strip() - - def get_board_serial(self): - """ - Returns a string containing the Serial Number of the device. - """ - return self._get_from_fru('Board Serial') - - def get_board_part_number(self): - """ - Returns a string containing the Part Number of the device. - """ - return self._get_from_fru('Board Part Number') - - def get_board_mfr_id(self): - """ - Returns a string containing the manufacturer id of the FRU. - """ - return self._get_from_fru('Board Mfg') - - def get_board_product(self): - """ - Returns a string containing the manufacturer id of the FRU. - """ - return self._get_from_fru('Board Product') - - def get_fru_data(self, offset, count=1): - """ - Reads and returns the FRU data at the provided offset. - - Args: - offset (int) - FRU offset to read - count (int) - Number of bytes to read [optional, default = 1] - Returns: - A tuple (bool, list(int)) where the first element provides - the validity of the data read and the second element is a - list, the elements of which are the individual bytes of the - FRU data read. - """ - result_bytes = list() - is_valid = True - result = "" - - offset_LSB = offset & 0xFF - offset_MSB = offset & 0xFF00 - command = "ipmitool raw {} {} {} {} {} {}".format(NetFn_Storage, - Cmd_ReadFRUData, - self.id, offset_LSB, - offset_MSB, count) - try: - proc = subprocess.Popen(command.split(), stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - stdout = proc.communicate()[0] - proc.wait() - if not proc.returncode: - result = stdout.decode('utf-8').rstrip('\n') - except EnvironmentError: - is_valid = False - - if (not result) or (not is_valid): - return False, result_bytes - - for i in result.split(): - result_bytes.append(int(i, 16)) - - read_count = result_bytes.pop(0) - if read_count != count: - return False, result_bytes - else: - return True, result_bytes From 50912ad966db66158a8661ca42e4bf43ccaba1a0 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Sat, 23 Jan 2021 00:28:04 -0800 Subject: [PATCH 0083/1674] [sonic-platform-daemons] Update submodule (#6535) Submodule changes to be committed: * src/sonic-platform-daemons 81318f7...e72f6cd (3): > [ledd] Minor refactor; add unit tests (#143) > [thermalctld] Report unit test coverage (#141) > [psud] Increase unit test coverage (#140) --- src/sonic-platform-daemons | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-platform-daemons b/src/sonic-platform-daemons index 81318f7afdb6..e72f6cd95881 160000 --- a/src/sonic-platform-daemons +++ b/src/sonic-platform-daemons @@ -1 +1 @@ -Subproject commit 81318f7afdb65bd15af387c97152948d22cf9834 +Subproject commit e72f6cd958810e3af9b18a71bc078dbb8c5d6cac From 6a50042b669c8ee138238d20ed04ea9a3631197e Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Sat, 23 Jan 2021 00:29:13 -0800 Subject: [PATCH 0084/1674] [process-reboot-cause] Make process-reboot-cause executable (#6534) process-reboot-cause script should be executable. --- src/sonic-host-services/scripts/process-reboot-cause | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 src/sonic-host-services/scripts/process-reboot-cause diff --git a/src/sonic-host-services/scripts/process-reboot-cause b/src/sonic-host-services/scripts/process-reboot-cause old mode 100644 new mode 100755 From ceecc8f9d41ed5366ba44846df78b1992c15bb23 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 14 Jan 2021 10:25:40 -0800 Subject: [PATCH 0085/1674] Remove things needed for building Python 3 from source (#6441) **- Why I did it** Prior to SONiC using Debian Buster, we needed to build Python 3.5 or newer from source for installation in the SNMP container, becuase it wasn't available from the Debian repository for Jessie or Stretch. Now that all containers are based on Buster, we simply install Python 3.7 from the Debian repository in the host as well as all containers. We are no longer building Python 3 from source, so the Makefile is unused and we no longer need to install build dependencies in the slave containers. **- How I did it** - Remove Python 3 makefile - No longer install Python 3 build dependencies in the slave containers. --- sonic-slave-buster/Dockerfile.j2 | 22 +++------------- sonic-slave-jessie/Dockerfile.j2 | 18 ------------- sonic-slave-stretch/Dockerfile.j2 | 18 ------------- src/python3/.gitignore | 3 --- src/python3/Makefile | 43 ------------------------------- 5 files changed, 3 insertions(+), 101 deletions(-) delete mode 100644 src/python3/.gitignore delete mode 100644 src/python3/Makefile diff --git a/sonic-slave-buster/Dockerfile.j2 b/sonic-slave-buster/Dockerfile.j2 index 641a1f3f2433..3d55446b6142 100644 --- a/sonic-slave-buster/Dockerfile.j2 +++ b/sonic-slave-buster/Dockerfile.j2 @@ -197,24 +197,6 @@ RUN apt-get update && apt-get install -y \ lua-cjson-dev \ # For mft kernel module build dkms \ -# For python3.5 build - sharutils \ - libncursesw5-dev \ - libbz2-dev \ - liblzma-dev \ - libgdbm-dev \ - tk-dev \ - blt-dev \ - libmpdec-dev \ - libbluetooth-dev \ - locales \ - libsqlite3-dev \ - libgpm2 \ - time \ - net-tools \ - xvfb \ - python-sphinx \ - python3-sphinx \ # For Jenkins static analysis, unit testing and code coverage cppcheck \ clang \ @@ -320,7 +302,9 @@ RUN apt-get update && apt-get install -y \ libxml2-utils \ xsltproc \ python-lxml \ - libexpat1-dev + libexpat1-dev \ +# For kdump-tools + libbz2-dev # Build fix for ARMHF buster libsairedis {%- if CONFIGURED_ARCH == "armhf" %} diff --git a/sonic-slave-jessie/Dockerfile.j2 b/sonic-slave-jessie/Dockerfile.j2 index 2914deb7842d..f103dfb789b9 100644 --- a/sonic-slave-jessie/Dockerfile.j2 +++ b/sonic-slave-jessie/Dockerfile.j2 @@ -176,24 +176,6 @@ RUN apt-get update && apt-get install -y \ libjemalloc-dev \ # For mft kernel module build dkms \ -# For python3.5 build - sharutils \ - libncursesw5-dev \ - libbz2-dev \ - liblzma-dev \ - libgdbm-dev \ - tk-dev \ - blt-dev \ - libmpdec-dev \ - libbluetooth-dev \ - locales \ - libsqlite3-dev \ - libgpm2 \ - time \ - net-tools \ - xvfb \ - python-sphinx \ - python3-sphinx \ # For Jenkins static analysis, unit testing and code coverage cppcheck \ clang \ diff --git a/sonic-slave-stretch/Dockerfile.j2 b/sonic-slave-stretch/Dockerfile.j2 index 53f2791e583a..103a9cd77831 100644 --- a/sonic-slave-stretch/Dockerfile.j2 +++ b/sonic-slave-stretch/Dockerfile.j2 @@ -196,24 +196,6 @@ RUN apt-get update && apt-get install -y \ lua-cjson-dev \ # For mft kernel module build dkms \ -# For python3.5 build - sharutils \ - libncursesw5-dev \ - libbz2-dev \ - liblzma-dev \ - libgdbm-dev \ - tk-dev \ - blt-dev \ - libmpdec-dev \ - libbluetooth-dev \ - locales \ - libsqlite3-dev \ - libgpm2 \ - time \ - net-tools \ - xvfb \ - python-sphinx \ - python3-sphinx \ # For Jenkins static analysis, unit testing and code coverage cppcheck \ clang \ diff --git a/src/python3/.gitignore b/src/python3/.gitignore deleted file mode 100644 index a0991ff4402b..000000000000 --- a/src/python3/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!.gitignore -!Makefile diff --git a/src/python3/Makefile b/src/python3/Makefile deleted file mode 100644 index 1c37e9d06c45..000000000000 --- a/src/python3/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -.ONESHELL: -SHELL = /bin/bash -.SHELLFLAGS += -e - -PYTHON_VER=3.6.0 -PYTHON_DEB_VER=1 -PYTHON_PNAME=python3.6 - -MAIN_TARGET = lib$(PYTHON_PNAME)-minimal_$(PYTHON_VER)-$(PYTHON_DEB_VER)_$(CONFIGURED_ARCH).deb -DERIVED_TARGETS = lib$(PYTHON_PNAME)-stdlib_$(PYTHON_VER)-$(PYTHON_DEB_VER)_$(CONFIGURED_ARCH).deb \ - lib$(PYTHON_PNAME)_$(PYTHON_VER)-$(PYTHON_DEB_VER)_$(CONFIGURED_ARCH).deb \ - $(PYTHON_PNAME)-minimal_$(PYTHON_VER)-$(PYTHON_DEB_VER)_$(CONFIGURED_ARCH).deb \ - $(PYTHON_PNAME)_$(PYTHON_VER)-$(PYTHON_DEB_VER)_$(CONFIGURED_ARCH).deb \ - lib$(PYTHON_PNAME)-dev_$(PYTHON_VER)-$(PYTHON_DEB_VER)_$(CONFIGURED_ARCH).deb - #$(PYTHON_PNAME)-dev_$(PYTHON_VER)-$(PYTHON_DEB_VER)_$(CONFIGURED_ARCH).deb - -$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : - # Remove any stale files - rm -rf $(PYTHON_PNAME)-$(PYTHON_VER) - - ## Obtaining the python3 - wget 'https://sonicstorage.blob.core.windows.net/packages/$(PYTHON_PNAME)_$(PYTHON_VER).orig.tar.xz?sv=2015-04-05&sr=b&sig=d42Wh1CA9NZvlskhW4fpWcHVgc7N3IKhdFzyeO2zbRA%3D&se=2027-02-02T01%3A00%3A57Z&sp=r' -O $(PYTHON_PNAME)_$(PYTHON_VER).orig.tar.xz - wget 'https://sonicstorage.blob.core.windows.net/packages/$(PYTHON_PNAME)_$(PYTHON_VER)-$(PYTHON_DEB_VER).debian.tar.xz?sv=2015-04-05&sr=b&sig=KLX9pMJ3zpQvGBo6ZjzoZXgooMJRUUwMx8ZaTJtywK0%3D&se=2027-02-02T00%3A59%3A34Z&sp=r' -O $(PYTHON_PNAME)_$(PYTHON_VER)-$(PYTHON_DEB_VER).debian.tar.xz - wget 'https://sonicstorage.blob.core.windows.net/packages/$(PYTHON_PNAME)_$(PYTHON_VER)-$(PYTHON_DEB_VER).dsc?sv=2015-04-05&sr=b&sig=95s%2FC4vKY6bRKtkUTz%2BmHLqOllBOYbfP3zV5ayAuzSM%3D&se=2027-02-02T01%3A00%3A26Z&sp=r' -O $(PYTHON_PNAME)_$(PYTHON_VER)-$(PYTHON_DEB_VER).dsc - - ## Build - dpkg-source -x $(PYTHON_PNAME)_$(PYTHON_VER)-$(PYTHON_DEB_VER).dsc - pushd $(PYTHON_PNAME)-$(PYTHON_VER) - mk-build-deps - - # put a lock here because dpkg does not allow installing packages in parallel - while true; do - if mkdir $(DEST)/dpkg_lock &> /dev/null; then - { echo here && (sudo dpkg -i $(PYTHON_PNAME)-build-deps_$(PYTHON_VER)-$(PYTHON_DEB_VER)_$(CONFIGURED_ARCH).deb || sudo apt-get install -f) && rm -d $(DEST)/dpkg_lock && break; } || { rm -d $(DEST)/dpkg_lock && exit 1 ; } - fi - done - - dpkg-buildpackage -rfakeroot -us -uc -b -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) - popd - - cp $(DERIVED_TARGETS) $* $(DEST)/ - -$(addprefix $(DEST)/, $(DERIVED_TARGETS)): $(DEST)/% : $(DEST)/$(MAIN_TARGET) From 59fd5fd3b8121b0cf3d4244a182fee6e43805489 Mon Sep 17 00:00:00 2001 From: Tamer Ahmed Date: Sat, 23 Jan 2021 00:29:35 -0800 Subject: [PATCH 0086/1674] [build-docker-buster]: Install libboost 1.171 In Build Docker (#6532) Installing newst buster version of libboost (v1.71) in build docker. signed-off-by: Tamer Ahmed --- sonic-slave-buster/Dockerfile.j2 | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/sonic-slave-buster/Dockerfile.j2 b/sonic-slave-buster/Dockerfile.j2 index 3d55446b6142..b8234e19d01b 100644 --- a/sonic-slave-buster/Dockerfile.j2 +++ b/sonic-slave-buster/Dockerfile.j2 @@ -61,7 +61,6 @@ RUN apt-get update && apt-get install -y \ dh-exec \ kmod \ libtinyxml2-6a \ - libboost-program-options1.67-dev \ libtinyxml2-dev \ python \ python-pip \ @@ -121,7 +120,6 @@ RUN apt-get update && apt-get install -y \ module-assistant \ # For thrift build\ gem2deb \ - libboost-all-dev \ libevent-dev \ libglib2.0-dev \ libqt4-dev \ @@ -304,7 +302,27 @@ RUN apt-get update && apt-get install -y \ python-lxml \ libexpat1-dev \ # For kdump-tools - libbz2-dev + libbz2-dev \ +# For linkmgrd + libboost1.71-dev \ + libboost-program-options1.71-dev \ + libboost-system1.71-dev \ + libboost-thread1.71-dev \ + libboost-atomic1.71-dev \ + libboost-chrono1.71-dev \ + libboost-container1.71-dev \ + libboost-context1.71-dev \ + libboost-contract1.71-dev \ + libboost-coroutine1.71-dev \ + libboost-date-time1.71-dev \ + libboost-fiber1.71-dev \ + libboost-filesystem1.71-dev \ + libboost-graph-parallel1.71-dev \ + libboost-log1.71-dev \ + libboost-regex1.71-dev \ + googletest \ + libgtest-dev \ + libgcc-8-dev # Build fix for ARMHF buster libsairedis {%- if CONFIGURED_ARCH == "armhf" %} From c8b3a709f1aa23161ff8d3f46dbd24e43342d427 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Sat, 23 Jan 2021 00:32:06 -0800 Subject: [PATCH 0087/1674] [sonic-host-services] Report unit test coverage (#6533) To view unit test coverage of sonic-host-services package upon build --- src/sonic-host-services/pytest.ini | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/sonic-host-services/pytest.ini diff --git a/src/sonic-host-services/pytest.ini b/src/sonic-host-services/pytest.ini new file mode 100644 index 000000000000..83b74d373c06 --- /dev/null +++ b/src/sonic-host-services/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +addopts = --cov=scripts --cov-report html --cov-report term --cov-report xml From df76e33bb3fc5f79e1085bd2118c097fa8e75753 Mon Sep 17 00:00:00 2001 From: Antonina Melnyk <74662630+antoninamelnyk@users.noreply.github.com> Date: Mon, 25 Jan 2021 02:32:18 +0200 Subject: [PATCH 0088/1674] [barefoot] Fixes for platform API (#6487) There was a mismatch with Eeprom class methods names and methods called from Eeprom class. Signed-off-by: Antonina Melnyk antoninax.melnyk@intel.com --- .../sonic_platform/eeprom.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 e25d224c1e8b..df24172709d3 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 @@ -136,14 +136,17 @@ def eeprom_parse(self): return True - def serial_number_str(self): + def serial_str(self): return self.eeprom.prod_ser_num def system_eeprom_info(self): return self.eeprom.__dict__ - def get_base_mac(self): - return self.eeprom.ext_mac_addr + def base_mac_addr(self): + return self.eeprom.ext_mac_addr.rstrip('\x00') def part_number_str(self): return self.eeprom.prod_part_num + + def modelstr(self): + return self.eeprom.prod_name From 7e2b7553bce642e1bd018d2a2d7d015f7b30e6ad Mon Sep 17 00:00:00 2001 From: Dmytro Shevchuk <68949102+dmytroxshevchuk@users.noreply.github.com> Date: Mon, 25 Jan 2021 03:46:33 +0200 Subject: [PATCH 0089/1674] [sonic-cfggen] parse optional fec and autoneg fields from hwsku.json (#6155) **- Why I did it** For now `hwsku.json` and `platform.json` dont support optional fields. For example no way to add `fec` or `autoneg` field using `platform.json` and `hwsku.json`. **- How I did it** Added parsing of optional fields from hwsku.json. **- How to verify it** Add optional field to `hwsku.json`. After first boot will be generated new `config_db.json` or you can generate it using `sonic-cfggen` command. In this file must be optional field from `hwsku.json` or check using command `redis-cli hgetall PORT_TABLE:Ethernet0` Example of `hwsku.json`, that must be parsed: ``` { "interfaces": { "Ethernet0": { "default_brkout_mode": "1x100G[40G]", "fec": "rs", "autoneg": "0" }, ... } ``` Example of generated `config_db.json`: ``` "PORT": { "Ethernet0": { "alias": "Ethernet0", "lanes": "0,1,2,3", "speed": "100000", "index": "1", "admin_status": "up", "fec": "rs", "autoneg": "0", "mtu": "9100" }, ``` So, we can see this entries in redis db: ``` admin@sonic:~$ redis-cli hgetall PORT_TABLE:Ethernet0 1) "alias" 2) "Ethernet0" 3) "lanes" 4) "0,1,2,3" 5) "speed" 6) "100000" 7) "index" 8) "1" 9) "admin_status" 10) "up" 11) "fec" 12) "rs" 13) "autoneg" 14) "0" 15) "mtu" 16) "9100" 17) "description" 18) "" 19) "oper_status" 20) "up" ``` Also its way to fix `show interface status`, `FEC` field but also need add `FEC` field to `hwsku.json`. Before: ``` admin@sonic:~$ show interfaces status Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC ----------- --------------- ------- ----- ----- ----------- ------ ------ ------- --------------- ---------- Ethernet0 0,1,2,3 100G 9100 N/A Ethernet0 routed up up QSFP28 or later N/A ``` After: ``` admin@sonic:~$ show interfaces status Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC ----------- --------------- ------- ----- ----- ----------- ------ ------ ------- --------------- ---------- Ethernet0 0,1,2,3 100G 9100 rs Ethernet0 routed up up QSFP28 or later N/A ``` --- src/sonic-config-engine/portconfig.py | 7 ++ src/sonic-device-data/src/Makefile | 3 + .../tests/hwsku_json_checker | 91 +++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100755 src/sonic-device-data/tests/hwsku_json_checker diff --git a/src/sonic-config-engine/portconfig.py b/src/sonic-config-engine/portconfig.py index 8a3177f31b9a..478198e5af84 100644 --- a/src/sonic-config-engine/portconfig.py +++ b/src/sonic-config-engine/portconfig.py @@ -24,6 +24,7 @@ BRKOUT_MODE = "default_brkout_mode" CUR_BRKOUT_MODE = "brkout_mode" 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})\))?' @@ -250,6 +251,12 @@ def parse_platform_json_file(hwsku_json_file, platform_json_file): brkout_mode = hwsku_dict[INTF_KEY][intf][BRKOUT_MODE] child_ports = get_child_ports(intf, brkout_mode, platform_json_file) + + # take optional fields from hwsku.json + for key, item in hwsku_dict[INTF_KEY][intf].items(): + if key in OPTIONAL_HWSKU_ATTRIBUTES: + child_ports.get(intf)[key] = item + ports.update(child_ports) if not ports: diff --git a/src/sonic-device-data/src/Makefile b/src/sonic-device-data/src/Makefile index 10525fdeb27e..5ecefbf37960 100644 --- a/src/sonic-device-data/src/Makefile +++ b/src/sonic-device-data/src/Makefile @@ -14,4 +14,7 @@ test: for f in $$(find ../../../device -name platform.json); do ./platform_json_checker $$f done + for f in $$(find ../../../device -name hwsku.json); do + ./hwsku_json_checker $$f + done popd diff --git a/src/sonic-device-data/tests/hwsku_json_checker b/src/sonic-device-data/tests/hwsku_json_checker new file mode 100755 index 000000000000..6fd3d82c4cfb --- /dev/null +++ b/src/sonic-device-data/tests/hwsku_json_checker @@ -0,0 +1,91 @@ +#!/usr/bin/env python3 + +import glob +import json +import re +import sys + +# Global variable +PORT_ATTRIBUTES = ["default_brkout_mode"] +OPTIONAL_PORT_ATTRIBUTES = ["fec", "autoneg"] +PORT_REG = "Ethernet(\d+)" +HWSKU_JSON = '*hwsku.json' +INTF_KEY = "interfaces" + +def usage(): + print("Usage: " + sys.argv[0] + " ") + sys.exit(1) + +def check_port_attr(port_attr): + for each_key in port_attr: + if each_key not in PORT_ATTRIBUTES and each_key not in OPTIONAL_PORT_ATTRIBUTES: + print("Error: " + each_key + " is not the correct Port attribute.") + return False + if not port_attr[each_key]: + print("Error: " + each_key + " has no value.") + return False + if not isinstance(port_attr[each_key], str): + print("Error:value type of " + each_key + " must be string.") + return False + return True + +def check_file(hwsku_json_file): + try: + hwsku_cap_file = open(hwsku_json_file,"r") + hwsku_data_data = hwsku_cap_file.read() + hwsku_dict = json.loads(hwsku_data_data) + + for each_port in hwsku_dict[INTF_KEY]: + # Validate port at top level + port_id = re.search(PORT_REG, each_port) + if port_id is None: + print("Error: Unknown Interface " + str(each_port) + " at top level") + return False + + port_attr = hwsku_dict[INTF_KEY][each_port] + + # Check mandatory attributes + for each_key in PORT_ATTRIBUTES: + if each_key not in port_attr: + print("Error: " + each_key + " of " + each_port + " is/are missing") + return False + + #Validate port attributes for each port + if not check_port_attr(port_attr): + return False + except IOError: + print("Error: Cannot open file " + hwsku_json_file) + return False + except ValueError as e: + print("Error in parsing json file " + hwsku_json_file + " ") + print(str(e)) + return False + return True + +def main(argv): + if len(argv) > 0 and argv[0] == "-h": + usage() + + # Load target file + if len(argv) == 0: + files = glob.glob(HWSKU_JSON) + else: + files = argv + + all_good = True + + for f in files: + good = check_file(f) + if good: + print("File " + f + " passed validity check") + else: + print("File " + f + " failed validity check") + + all_good = all_good and good + + if not all_good: + sys.exit(-1) + + +if __name__ == "__main__": + main(sys.argv[1:]) From 154a6ab6c52609bd925cc7441297329a8929a0d0 Mon Sep 17 00:00:00 2001 From: Zhenhong Zhao Date: Sun, 24 Jan 2021 17:57:03 -0800 Subject: [PATCH 0090/1674] [frrcfgd] introduce frrcfgd to manage frr config when frr_mgmt_framework_config is true (#5142) - Support for non-template based FRR configurations (BGP, route-map, OSPF, static route..etc) using config DB schema. - Support for save & restore - Jinja template based config-DB data read and apply to FRR during startup **- How I did it** - add frrcfgd service - when frr_mgmg_framework_config is set, frrcfgd starts in bgp container - when user changed the BGP or other related table entries in config DB, frrcfgd will run corresponding VTYSH commands to program on FRR. - add jinja template to generate FRR config file to be used by FRR daemons while bgp container restarted **- How to verify it** 1. Add/delete data on config DB and then run VTYSH "show running-config" command to check if FRR configuration changed. 1. Restart bgp container and check if generated FRR config file is correct and run VTYSH "show running-config" command to check if FRR configuration is consistent with attributes in config DB Co-authored-by: Zhenhong Zhao --- dockers/docker-fpm-frr/Dockerfile.j2 | 1 - dockers/docker-fpm-frr/critical_processes | 5 - dockers/docker-fpm-frr/docker_init.sh | 22 +- .../docker-fpm-frr/frr/bgpd/gen_bgpd.conf.j2 | 5 + dockers/docker-fpm-frr/frr/frr_vars.j2 | 15 +- dockers/docker-fpm-frr/frr/gen_frr.conf.j2 | 5 + .../frr/staticd/gen_staticd.conf.j2 | 5 + .../frr/supervisord/critical_processes.j2 | 12 + .../frr/supervisord/supervisord.conf.j2 | 45 + rules/docker-fpm-frr.mk | 2 +- rules/sonic-frr-mgmt-framework.dep | 8 + rules/sonic-frr-mgmt-framework.mk | 13 + src/sonic-frr-mgmt-framework/.gitignore | 12 + .../frrcfgd/__init__.py | 0 .../frrcfgd/frrcfgd.py | 3795 +++++++++++++++++ src/sonic-frr-mgmt-framework/pytest.ini | 2 + src/sonic-frr-mgmt-framework/setup.cfg | 5 + src/sonic-frr-mgmt-framework/setup.py | 51 + .../templates/bfdd/bfdd.conf.j2 | 91 + .../bgpd/bgpd.conf.db.addr_family.evpn.j2 | 78 + .../bgpd/bgpd.conf.db.addr_family.j2 | 143 + .../templates/bgpd/bgpd.conf.db.comm_list.j2 | 54 + .../templates/bgpd/bgpd.conf.db.j2 | 204 + .../templates/bgpd/bgpd.conf.db.nbr_af.j2 | 150 + .../bgpd/bgpd.conf.db.nbr_or_peer.j2 | 103 + .../templates/bgpd/bgpd.conf.db.pref_list.j2 | 30 + .../templates/bgpd/bgpd.conf.db.route_map.j2 | 150 + .../templates/bgpd/bgpd.conf.j2 | 15 + .../templates/frr/frr.conf.j2 | 30 + .../templates/ospfd/ospfd.conf.db.area.j2 | 37 + .../ospfd/ospfd.conf.db.comm_list.j2 | 129 + .../ospfd/ospfd.conf.db.distributeroute.j2 | 52 + .../ospfd/ospfd.conf.db.interface.j2 | 76 + .../ospfd/ospfd.conf.db.policyrange.j2 | 16 + .../templates/ospfd/ospfd.conf.db.vlink.j2 | 29 + .../templates/ospfd/ospfd.conf.j2 | 6 + .../templates/staticd/staticd.conf.j2 | 22 + .../templates/staticd/staticd.db.conf.j2 | 153 + .../staticd/staticd.db.default_route.conf.j2 | 9 + .../tests/__init__.py | 0 .../tests/test_config.py | 176 + .../tests/test_constructor.py | 234 + 42 files changed, 5976 insertions(+), 14 deletions(-) delete mode 100644 dockers/docker-fpm-frr/critical_processes create mode 100644 dockers/docker-fpm-frr/frr/bgpd/gen_bgpd.conf.j2 create mode 100644 dockers/docker-fpm-frr/frr/gen_frr.conf.j2 create mode 100644 dockers/docker-fpm-frr/frr/staticd/gen_staticd.conf.j2 create mode 100644 dockers/docker-fpm-frr/frr/supervisord/critical_processes.j2 create mode 100644 rules/sonic-frr-mgmt-framework.dep create mode 100644 rules/sonic-frr-mgmt-framework.mk create mode 100644 src/sonic-frr-mgmt-framework/.gitignore create mode 100644 src/sonic-frr-mgmt-framework/frrcfgd/__init__.py create mode 100755 src/sonic-frr-mgmt-framework/frrcfgd/frrcfgd.py create mode 100644 src/sonic-frr-mgmt-framework/pytest.ini create mode 100644 src/sonic-frr-mgmt-framework/setup.cfg create mode 100755 src/sonic-frr-mgmt-framework/setup.py create mode 100644 src/sonic-frr-mgmt-framework/templates/bfdd/bfdd.conf.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.addr_family.evpn.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.addr_family.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.comm_list.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.nbr_af.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.nbr_or_peer.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.pref_list.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.route_map.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/frr/frr.conf.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.area.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.comm_list.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.distributeroute.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.interface.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.policyrange.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.vlink.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/staticd/staticd.conf.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/staticd/staticd.db.conf.j2 create mode 100644 src/sonic-frr-mgmt-framework/templates/staticd/staticd.db.default_route.conf.j2 create mode 100644 src/sonic-frr-mgmt-framework/tests/__init__.py create mode 100644 src/sonic-frr-mgmt-framework/tests/test_config.py create mode 100644 src/sonic-frr-mgmt-framework/tests/test_constructor.py diff --git a/dockers/docker-fpm-frr/Dockerfile.j2 b/dockers/docker-fpm-frr/Dockerfile.j2 index 69e3655d0c39..302f38c8b579 100644 --- a/dockers/docker-fpm-frr/Dockerfile.j2 +++ b/dockers/docker-fpm-frr/Dockerfile.j2 @@ -54,7 +54,6 @@ COPY ["TSA", "/usr/bin/TSA"] COPY ["TSB", "/usr/bin/TSB"] COPY ["TSC", "/usr/bin/TSC"] COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] -COPY ["critical_processes", "/etc/supervisor"] COPY ["bgpd.sh", "/usr/bin/"] RUN chmod a+x /usr/bin/TSA && \ chmod a+x /usr/bin/TSB && \ diff --git a/dockers/docker-fpm-frr/critical_processes b/dockers/docker-fpm-frr/critical_processes deleted file mode 100644 index 2631fee15e66..000000000000 --- a/dockers/docker-fpm-frr/critical_processes +++ /dev/null @@ -1,5 +0,0 @@ -program:zebra -program:staticd -program:bgpd -program:fpmsyncd -program:bgpcfgd diff --git a/dockers/docker-fpm-frr/docker_init.sh b/dockers/docker-fpm-frr/docker_init.sh index 94cd7fbb1322..96149de4c379 100755 --- a/dockers/docker-fpm-frr/docker_init.sh +++ b/dockers/docker-fpm-frr/docker_init.sh @@ -6,16 +6,25 @@ mkdir -p /etc/supervisor/conf.d CFGGEN_PARAMS=" \ -d \ -y /etc/sonic/constants.yml \ - -t /usr/share/sonic/templates/supervisord/frr_vars.j2 \ + -t /usr/share/sonic/templates/frr_vars.j2 \ -t /usr/share/sonic/templates/supervisord/supervisord.conf.j2,/etc/supervisor/conf.d/supervisord.conf \ - -t /usr/share/sonic/templates/bgpd/bgpd.conf.j2,/etc/frr/bgpd.conf \ + -t /usr/share/sonic/templates/bgpd/gen_bgpd.conf.j2,/etc/frr/bgpd.conf \ + -t /usr/share/sonic/templates/supervisord/critical_processes.j2,/etc/supervisor/critical_processes \ -t /usr/share/sonic/templates/zebra/zebra.conf.j2,/etc/frr/zebra.conf \ - -t /usr/share/sonic/templates/staticd/staticd.conf.j2,/etc/frr/staticd.conf \ - -t /usr/share/sonic/templates/frr.conf.j2,/etc/frr/frr.conf \ + -t /usr/share/sonic/templates/staticd/gen_staticd.conf.j2,/etc/frr/staticd.conf \ + -t /usr/share/sonic/templates/gen_frr.conf.j2,/etc/frr/frr.conf \ -t /usr/share/sonic/templates/isolate.j2,/usr/sbin/bgp-isolate \ -t /usr/share/sonic/templates/unisolate.j2,/usr/sbin/bgp-unisolate \ + -t /usr/local/sonic/frrcfgd/bfdd.conf.j2,/etc/frr/bfdd.conf \ + -t /usr/local/sonic/frrcfgd/ospfd.conf.j2,/etc/frr/ospfd.conf \ " -CONFIG_TYPE=$(sonic-cfggen $CFGGEN_PARAMS) + +FRR_VARS=$(sonic-cfggen $CFGGEN_PARAMS) +MGMT_FRAMEWORK_CONFIG=$(echo $FRR_VARS | jq -r '.frr_mgmt_framework_config') +CONFIG_TYPE=$(echo $FRR_VARS | jq -r '.docker_routing_config_mode') +if [ -z "$MGMT_FRAMEWORK_CONFIG" ] || [ "$MGMT_FRAMEWORK_CONFIG" == "false" ]; then + rm /etc/frr/bfdd.conf /etc/frr/ospfd.conf +fi update_default_gw() { @@ -52,7 +61,8 @@ if [ -z "$CONFIG_TYPE" ] || [ "$CONFIG_TYPE" == "separated" ]; then rm -f /etc/frr/frr.conf elif [ "$CONFIG_TYPE" == "unified" ]; then echo "service integrated-vtysh-config" > /etc/frr/vtysh.conf - rm -f /etc/frr/bgpd.conf /etc/frr/zebra.conf /etc/frr/staticd.conf + rm -f /etc/frr/bgpd.conf /etc/frr/zebra.conf /etc/frr/staticd.conf \ + /etc/frr/bfdd.conf /etc/frr/ospfd.conf /etc/frr/pimd.conf fi chown -R frr:frr /etc/frr/ diff --git a/dockers/docker-fpm-frr/frr/bgpd/gen_bgpd.conf.j2 b/dockers/docker-fpm-frr/frr/bgpd/gen_bgpd.conf.j2 new file mode 100644 index 000000000000..bb6d7f6a5a65 --- /dev/null +++ b/dockers/docker-fpm-frr/frr/bgpd/gen_bgpd.conf.j2 @@ -0,0 +1,5 @@ +{% if DEVICE_METADATA.localhost.frr_mgmt_framework_config is defined and DEVICE_METADATA.localhost.frr_mgmt_framework_config == "true" %} + {% include "/usr/local/sonic/frrcfgd/bgpd.conf.j2" %} +{% else %} + {% include "/usr/share/sonic/templates/bgpd/bgpd.conf.j2" %} +{% endif %} diff --git a/dockers/docker-fpm-frr/frr/frr_vars.j2 b/dockers/docker-fpm-frr/frr/frr_vars.j2 index 9909604e5f1c..662608a1fd8b 100644 --- a/dockers/docker-fpm-frr/frr/frr_vars.j2 +++ b/dockers/docker-fpm-frr/frr/frr_vars.j2 @@ -1 +1,14 @@ -{{ DEVICE_METADATA["localhost"]["docker_routing_config_mode"] }} +{ + "frr_mgmt_framework_config": + {% if "frr_mgmt_framework_config" in DEVICE_METADATA["localhost"].keys() %} + "{{ DEVICE_METADATA["localhost"]["frr_mgmt_framework_config"] }}" + {% else %} + "" + {% endif %}, + "docker_routing_config_mode": + {% if "docker_routing_config_mode" in DEVICE_METADATA["localhost"].keys() %} + "{{ DEVICE_METADATA["localhost"]["docker_routing_config_mode"] }}" + {% else %} + "" + {% endif %} +} diff --git a/dockers/docker-fpm-frr/frr/gen_frr.conf.j2 b/dockers/docker-fpm-frr/frr/gen_frr.conf.j2 new file mode 100644 index 000000000000..181437da07a0 --- /dev/null +++ b/dockers/docker-fpm-frr/frr/gen_frr.conf.j2 @@ -0,0 +1,5 @@ +{% if DEVICE_METADATA.localhost.frr_mgmt_framework_config is defined and DEVICE_METADATA.localhost.frr_mgmt_framework_config == "true" %} + {% include "/usr/local/sonic/frrcfgd/frr.conf.j2" %} +{% else %} + {% include "/usr/share/sonic/templates/frr.conf.j2" %} +{% endif %} diff --git a/dockers/docker-fpm-frr/frr/staticd/gen_staticd.conf.j2 b/dockers/docker-fpm-frr/frr/staticd/gen_staticd.conf.j2 new file mode 100644 index 000000000000..1346c9a4993b --- /dev/null +++ b/dockers/docker-fpm-frr/frr/staticd/gen_staticd.conf.j2 @@ -0,0 +1,5 @@ +{% if DEVICE_METADATA.localhost.frr_mgmt_framework_config is defined and DEVICE_METADATA.localhost.frr_mgmt_framework_config == "true" %} + {% include "/usr/local/sonic/frrcfgd/staticd.conf.j2" %} +{% else %} + {% include "/usr/share/sonic/templates/staticd/staticd.conf.j2" %} +{% endif %} diff --git a/dockers/docker-fpm-frr/frr/supervisord/critical_processes.j2 b/dockers/docker-fpm-frr/frr/supervisord/critical_processes.j2 new file mode 100644 index 000000000000..9a90a5c94eb8 --- /dev/null +++ b/dockers/docker-fpm-frr/frr/supervisord/critical_processes.j2 @@ -0,0 +1,12 @@ +program:zebra +program:staticd +program:bgpd +program:fpmsyncd +{% if DEVICE_METADATA.localhost.frr_mgmt_framework_config is defined and DEVICE_METADATA.localhost.frr_mgmt_framework_config == "true" %} +program:bfdd +program:ospfd +program:pimd +program:frrcfgd +{% else %} +program:bgpcfgd +{% endif %} diff --git a/dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2 b/dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2 index e71d6fa71323..dc52bd1b5336 100644 --- a/dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2 +++ b/dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2 @@ -50,6 +50,20 @@ stderr_logfile=syslog dependent_startup=true dependent_startup_wait_for=zebra:running +{% if DEVICE_METADATA.localhost.frr_mgmt_framework_config is defined and DEVICE_METADATA.localhost.frr_mgmt_framework_config == "true" %} +[program:bfdd] +command=/usr/lib/frr/bfdd -A 127.0.0.1 +priority=4 +stopsignal=KILL +autostart=false +autorestart=false +startsecs=0 +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=zebra:running +{% endif %} + [program:bgpd] command=/usr/bin/bgpd.sh -A 127.0.0.1 -M snmp priority=5 @@ -62,6 +76,32 @@ stderr_logfile=syslog dependent_startup=true dependent_startup_wait_for=zebra:running +{% if DEVICE_METADATA.localhost.frr_mgmt_framework_config is defined and DEVICE_METADATA.localhost.frr_mgmt_framework_config == "true" %} +[program:ospfd] +command=/usr/lib/frr/ospfd -A 127.0.0.1 -M snmp +priority=5 +stopsignal=KILL +autostart=false +autorestart=false +startsecs=0 +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=zebra:running + +[program:pimd] +command=/usr/lib/frr/pimd -A 127.0.0.1 +priority=5 +stopsignal=KILL +autostart=false +autorestart=false +startsecs=0 +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=zebra:running +{% endif %} + [program:fpmsyncd] command=fpmsyncd priority=6 @@ -73,8 +113,13 @@ stderr_logfile=syslog dependent_startup=true dependent_startup_wait_for=bgpd:running +{% if DEVICE_METADATA.localhost.frr_mgmt_framework_config is defined and DEVICE_METADATA.localhost.frr_mgmt_framework_config == "true" %} +[program:frrcfgd] +command=/usr/local/bin/frrcfgd +{% else %} [program:bgpcfgd] command=/usr/local/bin/bgpcfgd +{% endif %} priority=6 autostart=false autorestart=false diff --git a/rules/docker-fpm-frr.mk b/rules/docker-fpm-frr.mk index e6473ef5eeef..d4aace307a19 100644 --- a/rules/docker-fpm-frr.mk +++ b/rules/docker-fpm-frr.mk @@ -5,7 +5,7 @@ DOCKER_FPM_FRR = $(DOCKER_FPM_FRR_STEM).gz DOCKER_FPM_FRR_DBG = $(DOCKER_FPM_FRR_STEM)-$(DBG_IMAGE_MARK).gz $(DOCKER_FPM_FRR)_PATH = $(DOCKERS_PATH)/$(DOCKER_FPM_FRR_STEM) -$(DOCKER_FPM_FRR)_PYTHON_WHEELS += $(SONIC_BGPCFGD) +$(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) diff --git a/rules/sonic-frr-mgmt-framework.dep b/rules/sonic-frr-mgmt-framework.dep new file mode 100644 index 000000000000..318c4edd1da8 --- /dev/null +++ b/rules/sonic-frr-mgmt-framework.dep @@ -0,0 +1,8 @@ +SPATH := $($(SONIC_FRR_MGMT_FRAMEWORK)_SRC_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/sonic-frr-mgmt-framework.mk rules/sonic-frr-mgmt-framework.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +DEP_FILES += $(shell git ls-files $(SPATH)) + +$(SONIC_FRR_MGMT_FRAMEWORK)_CACHE_MODE := GIT_CONTENT_SHA +$(SONIC_FRR_MGMT_FRAMEWORK)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(SONIC_FRR_MGMT_FRAMEWORK)_DEP_FILES := $(DEP_FILES) diff --git a/rules/sonic-frr-mgmt-framework.mk b/rules/sonic-frr-mgmt-framework.mk new file mode 100644 index 000000000000..dfe981b440a9 --- /dev/null +++ b/rules/sonic-frr-mgmt-framework.mk @@ -0,0 +1,13 @@ +# sonic-frr-mgmt-framework package + +SONIC_FRR_MGMT_FRAMEWORK = sonic_frr_mgmt_framework-1.0-py3-none-any.whl +$(SONIC_FRR_MGMT_FRAMEWORK)_SRC_PATH = $(SRC_PATH)/sonic-frr-mgmt-framework +# These dependencies are only needed because they are dependencies +# of sonic-config-engine and frrcfgd explicitly calls sonic-cfggen +# as part of its unit tests. +# TODO: Refactor unit tests so that these dependencies are not needed + +$(SONIC_FRR_MGMT_FRAMEWORK)_DEPENDS += $(SONIC_CONFIG_ENGINE_PY3) +$(SONIC_FRR_MGMT_FRAMEWORK)_DEBS_DEPENDS += $(PYTHON_SWSSCOMMON) +$(SONIC_FRR_MGMT_FRAMEWORK)_PYTHON_VERSION = 3 +SONIC_PYTHON_WHEELS += $(SONIC_FRR_MGMT_FRAMEWORK) diff --git a/src/sonic-frr-mgmt-framework/.gitignore b/src/sonic-frr-mgmt-framework/.gitignore new file mode 100644 index 000000000000..f6411e4ee01e --- /dev/null +++ b/src/sonic-frr-mgmt-framework/.gitignore @@ -0,0 +1,12 @@ +.eggs/ +build/ +dist/ +*.egg-info/ +frrcfgd/*.pyc +tests/*.pyc +tests/__pycache__/ +.idea +.coverage +frrcfgd/__pycache__/ +venv +tests/.coverage* diff --git a/src/sonic-frr-mgmt-framework/frrcfgd/__init__.py b/src/sonic-frr-mgmt-framework/frrcfgd/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/src/sonic-frr-mgmt-framework/frrcfgd/frrcfgd.py b/src/sonic-frr-mgmt-framework/frrcfgd/frrcfgd.py new file mode 100755 index 000000000000..e3b8c3f264c8 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/frrcfgd/frrcfgd.py @@ -0,0 +1,3795 @@ +#!/usr/bin/env python + +import copy +import subprocess +import time +import syslog +import os +from swsssdk import ConfigDBConnector +import socket +import threading +import queue +import signal +import re +import logging +import netaddr +import io +import struct + +class CachedDataWithOp: + OP_NONE = 0 + OP_ADD = 1 + OP_DELETE = 2 + OP_UPDATE = 3 + + STAT_SUCC = 0 + STAT_FAIL = 1 + + def __init__(self, data = None, op = OP_NONE): + self.data = data + self.op = op + self.status = self.STAT_FAIL + + def __repr__(self): + op_str = '' + if self.op == self.OP_NONE: + op_str = 'NONE' + elif self.op == self.OP_ADD: + op_str = 'ADD' + elif self.op == self.OP_DELETE: + op_str = 'DELETE' + elif self.op == self.OP_UPDATE: + op_str = 'UPDATE' + return '(%s, %s)' % (self.data, op_str) + +bgpd_client = None + +def g_run_command(table, command, use_bgpd_client, daemons, ignore_fail = False): + syslog.syslog(syslog.LOG_DEBUG, "execute command {} for table {}.".format(command, table)) + if not command.startswith('vtysh '): + use_bgpd_client = False + if use_bgpd_client: + if not bgpd_client.run_vtysh_command(table, command, daemons) and not ignore_fail: + syslog.syslog(syslog.LOG_ERR, 'command execution failure. Command: "{}"'.format(command)) + return False + else: + p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE) + stdout = p.communicate()[0] + p.wait() + if p.returncode != 0 and not ignore_fail: + syslog.syslog(syslog.LOG_ERR, '[bgp cfgd] command execution returned {}. Command: "{}", stdout: "{}"'.\ + format(p.returncode, command, stdout)) + return False + return True + +def extract_cmd_daemons(cmd_str): + # daemon list could be given within brackets at head of input lines + dm_mark = re.match(r'\[(?P.+)\]', cmd_str) + if dm_mark is not None and 'daemons' in dm_mark.groupdict(): + cmd_str = cmd_str[dm_mark.end():] + daemons = dm_mark.groupdict()['daemons'].split(',') + else: + daemons = None + return (daemons, cmd_str) + +class BgpdClientMgr(threading.Thread): + VTYSH_MARK = 'vtysh ' + PROXY_SERVER_ADDR = '/etc/frr/bgpd_client_sock' + ALL_DAEMONS = ['bgpd', 'zebra', 'staticd', 'bfdd', 'ospfd', 'pimd'] + TABLE_DAEMON = { + 'DEVICE_METADATA': ['bgpd'], + 'BGP_GLOBALS': ['bgpd'], + 'BGP_GLOBALS_AF': ['bgpd'], + 'PREFIX_SET': ['bgpd'], + 'COMMUNITY_SET': ['bgpd'], + 'EXTENDED_COMMUNITY_SET': ['bgpd'], + 'ROUTE_MAP': ['zebra', 'bgpd', 'ospfd'], + 'PREFIX': ['zebra', 'bgpd', 'ospfd', 'pimd'], + 'BGP_PEER_GROUP': ['bgpd'], + 'BGP_NEIGHBOR': ['bgpd'], + 'BGP_PEER_GROUP_AF': ['bgpd'], + 'BGP_NEIGHBOR_AF': ['bgpd'], + 'BGP_GLOBALS_LISTEN_PREFIX': ['bgpd'], + 'NEIGHBOR_SET': ['bgpd'], + 'NEXTHOP_SET': ['bgpd'], + 'TAG_SET': ['bgpd'], + 'AS_PATH_SET': ['bgpd'], + 'ROUTE_REDISTRIBUTE': ['bgpd'], + 'BGP_GLOBALS_AF_AGGREGATE_ADDR': ['bgpd'], + 'BGP_GLOBALS_AF_NETWORK': ['bgpd'], + 'VRF': ['zebra'], + 'BGP_GLOBALS_EVPN_VNI': ['bgpd'], + 'BGP_GLOBALS_EVPN_RT': ['bgpd'], + 'BGP_GLOBALS_EVPN_VNI_RT': ['bgpd'], + 'BFD_PEER': ['bfdd'], + 'BFD_PEER_SINGLE_HOP': ['bfdd'], + 'BFD_PEER_MULTI_HOP': ['bfdd'], + 'IP_SLA': ['iptrackd'], + 'OSPFV2_ROUTER': ['ospfd'], + 'OSPFV2_ROUTER_AREA': ['ospfd'], + 'OSPFV2_ROUTER_AREA_VIRTUAL_LINK': ['ospfd'], + 'OSPFV2_ROUTER_AREA_NETWORK': ['ospfd'], + 'OSPFV2_ROUTER_AREA_POLICY_ADDRESS_RANGE': ['ospfd'], + 'OSPFV2_ROUTER_DISTRIBUTE_ROUTE': ['ospfd'], + 'OSPFV2_INTERFACE': ['ospfd'], + 'OSPFV2_ROUTER_PASSIVE_INTERFACE': ['ospfd'], + 'STATIC_ROUTE': ['staticd'], + 'PIM_GLOBALS': ['pimd'], + 'PIM_INTERFACE': ['pimd'], + 'IGMP_INTERFACE': ['pimd'], + 'IGMP_INTERFACE_QUERY': ['pimd'], + } + VTYSH_CMD_DAEMON = [(r'show (ip|ipv6) route($|\s+\S+)', ['zebra']), + (r'show ip mroute($|\s+\S+)', ['pimd']), + (r'show bfd($|\s+\S+)', ['bfdd']), + (r'clear bfd($|\s+\S+)', ['bfdd']), + (r'clear ip mroute($|\s+\S+)', ['pimd']), + (r'clear ip pim($|\s+\S+)', ['pimd']), + (r'show ip ospf($|\s+\S+)', ['ospfd']), + (r'show ip pim($|\s+\S+)', ['pimd']), + (r'show ip igmp($|\s+\S+)', ['pimd']), + (r'clear ip ospf($|\s+\S+)', ['ospfd']), + (r'show ip sla($|\s+\S+)', ['iptrackd']), + (r'clear ip sla($|\s+\S+)', ['iptrackd']), + (r'clear ip igmp($|\s+\S+)', ['pimd']), + (r'.*', ['bgpd'])] + @staticmethod + def __create_proxy_socket(): + try: + os.unlink(BgpdClientMgr.PROXY_SERVER_ADDR) + except OSError: + if os.path.exists(BgpdClientMgr.PROXY_SERVER_ADDR): + raise + sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + sock.bind(BgpdClientMgr.PROXY_SERVER_ADDR) + sock.listen(1) + return sock + @staticmethod + def __get_reply(sock): + reply_msg = None + ret_code = None + msg_buf = io.StringIO() + while True: + try: + rd_msg = sock.recv(16384) + msg_buf.write(rd_msg.decode()) + except socket.timeout: + syslog.syslog(syslog.LOG_ERR, 'socket reading timeout') + break + if len(rd_msg) < 4: + rd_msg = msg_buf.getvalue() + if len(rd_msg) < 4: + continue + msg_tail = rd_msg[-4:] + if isinstance(msg_tail, str): + msg_tail = bytes(msg_tail, 'utf-8') + if msg_tail[0] == 0 and msg_tail[1] == 0 and msg_tail[2] == 0: + ret_code = msg_tail[3] + reply_msg = msg_buf.getvalue()[:-4] + break + msg_buf.close() + return (ret_code, reply_msg) + @staticmethod + def __send_data(sock, data): + if isinstance(data, str): + data = bytes(data, 'utf-8') + sock.sendall(data) + def __create_frr_client(self): + self.client_socks = {} + for daemon in self.ALL_DAEMONS: + sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + serv_addr = '/run/frr/%s.vty' % daemon + retry_cnt = 0 + while True: + try: + sock.connect(serv_addr) + break + except socket.error as msg: + syslog.syslog(syslog.LOG_ERR, 'failed to connect to frr daemon %s: %s' % (daemon, msg)) + retry_cnt += 1 + if retry_cnt > 100 or not main_loop: + syslog.syslog(syslog.LOG_ERR, 're-tried too many times, give up') + for _, sock in self.client_socks.items(): + sock.close() + return False + time.sleep(2) + continue + sock.settimeout(120) + self.client_socks[daemon] = sock + for daemon, sock in self.client_socks.items(): + syslog.syslog(syslog.LOG_DEBUG, 'send initial enable command to %s' % daemon) + try: + self.__send_data(sock, 'enable\0') + except socket.error as msg: + syslog.syslog(syslog.LOG_ERR, 'failed to send initial enable command to %s' % daemon) + return False + ret_code, reply = self.__get_reply(sock) + if ret_code is None: + syslog.syslog(syslog.LOG_ERR, 'failed to get command response for enable command from %s' % daemon) + return False + if ret_code != 0: + syslog.syslog(syslog.LOG_ERR, 'enable command failed: ret_code=%d' % ret_code) + syslog.syslog(syslog.LOG_ERR, reply) + return False + return True + def __init__(self): + super(BgpdClientMgr, self).__init__(name = 'VTYSH sub-process manager') + if not self.__create_frr_client(): + syslog.syslog(syslog.LOG_ERR, 'failed to create socket to FRR daemon') + raise RuntimeError('connect to FRR daemon failed') + self.proxy_running = True + self.lock = threading.Lock() + self.proxy_sock = self.__create_proxy_socket() + self.cmd_to_daemon = [] + for pat, daemons in self.VTYSH_CMD_DAEMON: + try: + self.cmd_to_daemon.append((re.compile(pat), daemons)) + except Exception: + syslog.syslog(syslog.LOG_ERR, 'invalid regex format: %s' % pat) + continue + def __get_cmd_daemons(self, cmd_list): + cmn_daemons = None + for cmd in cmd_list: + found = False + for re_comp, daemons in self.cmd_to_daemon: + if re_comp.match(cmd.strip()) is not None: + found = True + break + if not found: + syslog.syslog(syslog.LOG_ERR, 'no matched daemons found for command %s' % cmd) + return None + if cmn_daemons is None: + cmn_daemons = set(daemons) + else: + cmn_daemons = cmn_daemons.intersection(set(daemons)) + if len(cmn_daemons) == 0: + return [] + return list(cmn_daemons) + def __proc_command(self, command, daemons): + syslog.syslog(syslog.LOG_DEBUG, 'VTYSH CMD: %s daemons: %s' % (command, daemons)) + resp = '' + ret_val = False + for daemon in daemons: + sock = self.client_socks.get(daemon, None) + if sock is None: + syslog.syslog(syslog.LOG_ERR, 'daemon %s is not connected' % daemon) + continue + try: + self.__send_data(sock, command + '\0') + except socket.error as msg: + syslog.syslog(syslog.LOG_ERR, 'failed to send command to frr daemon: %s' % msg) + return (False, None) + ret_code, reply = self.__get_reply(sock) + if ret_code is None or ret_code != 0: + if ret_code is None: + syslog.syslog(syslog.LOG_ERR, 'failed to get reply from frr daemon') + continue + else: + syslog.syslog(syslog.LOG_DEBUG, '[%s] command return code: %d' % (daemon, ret_code)) + syslog.syslog(syslog.LOG_DEBUG, reply) + else: + # command is running successfully by at least one daemon + ret_val = True + resp += reply + return (ret_val, resp) + def run_vtysh_command(self, table, command, daemons): + if not command.startswith(self.VTYSH_MARK): + syslog.syslog(syslog.LOG_ERR, 'command %s is not for vtysh config' % command) + return False + cmd_line = command[len(self.VTYSH_MARK):] + cmd_list = re.findall(r"-c\s+'([^']+)'\s*", cmd_line) + cmd_list.append('end') + if daemons is None: + daemons = self.TABLE_DAEMON.get(table, None) + if daemons is None: + daemons = self.__get_cmd_daemons(cmd_list) + if daemons is None or len(daemons) == 0: + syslog.syslog(syslog.LOG_ERR, 'no common daemon list found for given commands') + return False + ret_val = True + with self.lock: + for cmd in cmd_list: + succ, _ = self.__proc_command(cmd.strip(), daemons) + if not succ: + ret_val = False + return ret_val + @staticmethod + def __read_all(sock, data_len): + in_buf = io.StringIO() + left_len = data_len + while left_len > 0: + data = sock.recv(left_len) + if data is None: + break + in_buf.write(data) + left_len -= len(data) + return in_buf.getvalue() + def shutdown(self): + syslog.syslog(syslog.LOG_DEBUG, 'terminate bgpd client manager') + if self.is_alive(): + self.proxy_running = False + sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + try: + sock.connect(self.PROXY_SERVER_ADDR) + finally: + sock.close() + self.join() + for _, sock in self.client_socks.items(): + sock.close() + def run(self): + syslog.syslog(syslog.LOG_DEBUG, 'entering VTYSH proxy thread') + while self.proxy_running: + syslog.syslog(syslog.LOG_DEBUG, 'waiting for client connection ...') + conn_sock, clnt_addr = self.proxy_sock.accept() + if not self.proxy_running: + conn_sock.close() + break + try: + syslog.syslog(syslog.LOG_DEBUG, 'client connection from %s' % clnt_addr) + data = self.__read_all(conn_sock, 4) + if len(data) == 4: + data_len = struct.unpack('>I', data)[0] + in_cmd = self.__read_all(conn_sock, data_len) + if len(in_cmd) == data_len: + daemons, in_cmd = extract_cmd_daemons(in_cmd) + in_lines = in_cmd.splitlines() + if daemons is None: + daemons = self.__get_cmd_daemons(in_lines) + if daemons is not None and len(daemons) > 0: + with self.lock: + for line in in_lines: + _, reply = self.__proc_command(line.strip(), daemons) + if reply is not None: + self.__send_data(conn_sock, reply) + else: + syslog.syslog(syslog.LOG_ERR, 'failed running VTYSH command') + else: + syslog.syslog(syslog.LOG_ERR, 'could not find common daemons for input commands') + else: + syslog.syslog(syslog.LOG_ERR, 'read data of length %d is not expected length %d' % (data_len, len(in_cmd))) + else: + syslog.syslog(syslog.LOG_ERR, 'invalid data length %d' % len(data)) + except socket.error as msg: + syslog.syslog(syslog.LOG_ERR, 'socket writing failed: %s' % msg) + finally: + syslog.syslog(syslog.LOG_DEBUG, 'closing data socket from client') + conn_sock.close() + syslog.syslog(syslog.LOG_DEBUG, 'leaving VTYSH proxy thread') +class BGPPeerGroup: + def __init__(self, vrf): + self.vrf = vrf + self.ref_nbrs = set() + +def get_command_cmn(daemon, cmd_str, op, st_idx, vals, bool_values): + chk_val = None + if op == CachedDataWithOp.OP_DELETE: + if bool_values is not None and len(bool_values) >= 3: + # set to default if given + cmd_enable = bool_values[2] + else: + cmd_enable = False + else: + cmd_enable = True + if bool_values is not None: + if len(vals) <= st_idx: + syslog.syslog(syslog.LOG_ERR, 'No bool token of index %d for running cmd: %s' % (st_idx, cmd_str)) + return None + chk_val = vals[st_idx] + if type(chk_val) is dict: + cmd_enable = False + for _, v in chk_val.items(): + if not v[1]: + continue + if v[0] == bool_values[0]: + cmd_enable = True + break + else: + if chk_val == bool_values[0]: + cmd_enable = True + elif chk_val == bool_values[1]: + cmd_enable = False + else: + syslog.syslog(syslog.LOG_ERR, 'Input token %s is neither %s or %s for cmd: %s' % + (chk_val, bool_values[0], bool_values[1], cmd_str)) + return None + else: + cmd_enable = True + cmd_args = [] + for idx in range(len(vals)): + if bool_values is not None and idx == st_idx: + continue + cmd_args.append(CommandArgument(daemon, cmd_enable, vals[idx])) + return [cmd_str.format(*cmd_args, no = CommandArgument(daemon, cmd_enable))] + +def hdl_set_extcomm(daemon, cmd_str, op, st_idx, args, is_inline): + if is_inline: + if type(args[0]) is list: + com_list = args[0] + else: + com_list = [args[0]] + else: + com_set = daemon.extcomm_set_list.get(args[0], None) + if com_set is None or not com_set.is_configurable(): + syslog.syslog(syslog.LOG_ERR, 'extended community set %s not found or configured' % args[0]) + return None + com_list = com_set.mbr_list + rt_cnt = soo_cnt = 0 + for comm in com_list: + if comm.startswith(CommunityList.RT_TYPE_MARK): + rt_cnt += 1 + elif comm.startswith(CommunityList.SOO_TYPE_MARK): + soo_cnt += 1 + cmd_list = [] + if op != CachedDataWithOp.OP_DELETE: + for comm_type in ['rt', 'soo']: + cmd_list.append(('no set extcommunity %s' % comm_type, True)) + if rt_cnt > 0: + new_args = ((args[0], True),) + args[1:] + cmd_list += get_command_cmn(daemon, cmd_str, op, st_idx, new_args, None) + if soo_cnt > 0: + new_args = ((args[0], False),) + args[1:] + cmd_list += get_command_cmn(daemon, cmd_str, op, st_idx, new_args, None) + return cmd_list + +def hdl_set_asn(daemon, cmd_str, op, st_idx, args, data): + if 0 not in args[0]: + return None + if op == CachedDataWithOp.OP_DELETE: + if args[0][0][1]: + args[0][1] = ('0', True) + else: + args[0].pop(1, None) + op = CachedDataWithOp.OP_UPDATE + return get_command_cmn(daemon, cmd_str, op, st_idx, args, data) + +def hdl_set_asn_list(daemon, cmd_str, op, st_idx, args, data): + if op == CachedDataWithOp.OP_DELETE: + args = ('',) + return get_command_cmn(daemon, cmd_str, op, st_idx, args, data) + +def hdl_set_pim_hello_parms (daemon, cmd_str, op, st_idx, args, data): + if op == CachedDataWithOp.OP_DELETE: + args = ('',) + return get_command_cmn(daemon, cmd_str, op, st_idx, args, data) + +def handle_rmap_set_metric(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + + syslog.syslog(syslog.LOG_INFO, 'handle_rmap_set_metric cmd_str {} op {} st_idx {} args {} data {}'.format( + cmd_str, op, st_idx, args, data)) + + no_op = 'no ' if op == CachedDataWithOp.OP_DELETE else '' + + arg_len = len(args) + metric_action = args[0] if arg_len >= 1 else '' + metric_value = args[1] if arg_len >= 2 else '' + med_value = args[2] if arg_len >= 3 else '' + metric_param = '' + + if metric_action != '' : + if metric_value != '' : + if metric_action == 'METRIC_SET_VALUE' : + metric_param = "{}".format(metric_value) + elif metric_action == 'METRIC_ADD_VALUE' : + metric_param = "+{}".format(metric_value) + elif metric_action == 'METRIC_SUBTRACT_VALUE' : + metric_param = "-{}".format(metric_value) + if metric_action == 'METRIC_SET_RTT' : + metric_param = "rtt" + elif metric_action == 'METRIC_ADD_RTT' : + metric_param = "+rtt" + elif metric_action == 'METRIC_SUBTRACT_RTT' : + metric_param = "-rtt" + + if metric_param == '' and med_value != '' : + metric_param = "{}".format(med_value) + + if op == CachedDataWithOp.OP_DELETE : + metric_param = '' + else : + if metric_param == '' : + syslog.syslog(syslog.LOG_ERR, 'handle_rmap_set_metric not set for {}'.format(args)) + return None + + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, metric_param))) + return cmd_list + +class BGPKeyMapInfo: + def __init__(self, cmd_str, hdlr, data): + self.daemons, self.run_cmd = extract_cmd_daemons(cmd_str) + if hdlr is None: + self.hdl_func = get_command_cmn + else: + self.hdl_func = hdlr + self.data = data + def same_daemons(self, other): + dset = lambda d: set() if d is None else set(d) + return dset(self.daemons) == dset(other.daemons) + def __eq__(self, other): + return self.same_daemons(other) and self.run_cmd == other.run_cmd + def __ne__(self, other): + return not self.same_daemons(other) or self.run_cmd != other.run_cmd + def __hash__(self): + return hash(self.run_cmd) + def get_command(self, daemon, op, st_idx, *vals): + return self.hdl_func(daemon, self.run_cmd, op, st_idx, vals, self.data) + def __str__(self): + ret_str = '[CMD: %s' % self.run_cmd + if self.hdl_func == get_command_cmn and self.data is not None: + ret_str += ' BOOL: %s/%s' % (self.data[0], self.data[1]) + if len(self.data) >= 3: + ret_str += ' DFT: %s' % self.data[2] + ret_str += ']' + return ret_str + +class BGPKeyMapList(list): + def __init__(self, key_map_list, table_name, table_key = None): + super(BGPKeyMapList, self).__init__() + self.table_name = table_name + self.table_key = table_key + for key_map in key_map_list: + if len(key_map) < 2: + continue + db_field = key_map[0] + cmd_str = key_map[1] + hdl_data = None + hdl_func = None + if len(key_map) >= 3: + if callable(key_map[2]): + hdl_func = key_map[2] + if len(key_map) >= 4: + hdl_data = key_map[3] + else: + if len(key_map[2]) < 2: + continue + hdl_data = key_map[2] + fld_name, fld_key = self.get_map_field_key(db_field) + if fld_name is not None: + if table_key is not None and fld_name in table_key and table_key[fld_name] != fld_key: + continue + if type(db_field) is str: + db_field = fld_name + elif type(db_field) is list: + db_field = copy.copy(db_field) + try: + idx = db_field.index('|'.join([fld_name, fld_key])) + db_field[idx] = fld_name + except ValueError: + pass + super(BGPKeyMapList, self).append((db_field, BGPKeyMapInfo(cmd_str, hdl_func, hdl_data))) + def __eq__(self, other): + return super(BGPKeyMapList, self).__eq__(other) and self.table_name == other.table_name and self.table_key == other.table_key + def __ne__(self, other): + return super(BGPKeyMapList, self).__ne__(other) or self.table_name != other.table_name or self.table_key != other.table_key + @staticmethod + def get_map_field_key(field): + if type(field) is str: + field = [field] + elif type(field) is not list: + return (None, None) + for idx in range(len(field)): + tokens = field[idx].split('|', 1) + if len(tokens) == 2: + return tokens + return (None, None) + @staticmethod + def get_cmd_data(key_list, req_idx_list, opt_idx_list, data, chg_list, no_chg_list, merge_data, is_del): + for idx in req_idx_list: + if idx not in chg_list and idx not in no_chg_list: + syslog.syslog(syslog.LOG_DEBUG, 'mandatory key %s of idx %d not found in list' % (key_list[idx], idx)) + return None + if merge_data: + op = CachedDataWithOp.OP_DELETE if is_del else CachedDataWithOp.OP_UPDATE + cmd_data = {} + for idx in chg_list: + key = key_list[idx] + cmd_data[idx] = (data[key].data, True) + for idx in no_chg_list: + key = key_list[idx] + cmd_data[idx] = (data[key].data, False) + return ((cmd_data,), op) + else: + min_id = lambda id_set: None if len(id_set) == 0 else sorted(list(id_set))[0] + min_chg_id = min_id(chg_list) + if min_chg_id is None: + min_id_chged = False + else: + if min_chg_id in opt_idx_list: + min_id_chged = len(no_chg_list) == 0 + else: + min_unchg_id = min_id(no_chg_list) + min_id_chged = min_unchg_id is None or min_chg_id < min_unchg_id + op = CachedDataWithOp.OP_DELETE if is_del and min_id_chged else CachedDataWithOp.OP_UPDATE + cmd_data = [] + for idx in range(len(key_list)): + if (((not is_del or op == CachedDataWithOp.OP_DELETE) and (idx in chg_list or idx in no_chg_list)) or + (is_del and op == CachedDataWithOp.OP_UPDATE and idx in no_chg_list)): + cmd_data.append(data[key_list[idx]].data) + else: + if idx in opt_idx_list: + cmd_data.append('') + continue + else: + # stop adding following tokens + break + if len(cmd_data) == 0: + return None + idx = len(cmd_data) + while idx < len(key_list): + cmd_data.append('') + idx += 1 + return (tuple(cmd_data), op) + @staticmethod + def is_cmd_covered(src_cmd, dst_cmd): + src_tks = src_cmd.split() + dst_tks = dst_cmd.split() + if len(src_tks) >= len(dst_tks): + return False + for idx in range(len(src_tks)): + if src_tks[idx] != dst_tks[idx]: + return False + return True + @staticmethod + def is_cmd_list_covered(src_list, dst_list): + if len(src_list) == 0: + return True + if len(src_list) > len(dst_list): + return False + for idx in range(len(src_list)): + if not BGPKeyMapList.is_cmd_covered(src_list[idx], dst_list[idx]): + return False + return True + def run_command(self, daemon, table, data, prefix_list=None, *upper_vals): + start_idx = len(upper_vals) + ret_val = False + run_cmd_cnt = 0 + for db_field, key_map in self: + merge_vals = False + if type(db_field) is not list and type(db_field) is not tuple: + db_field = [db_field] + elif type(db_field) is tuple: + db_field = list(db_field) + merge_vals = True + + idx = 0 + req_idx_list = [] + key_list_list = [] + opt_idx_list = set() + run_cmd = True + for dkey in db_field: + optional = False + if len(dkey) > 0 and dkey[0] == '+': + if len(dkey) > 1 and dkey[1] == '+': + opt_idx_list.add(idx) + dkey = dkey[2:] + else: + dkey = dkey[1:] + optional = True + else: + req_idx_list.append(idx) + key_list = [] + for k in dkey.split('&'): + if k in data and isinstance(data[k], CachedDataWithOp): + key_list.append(k) + if not optional and len(key_list) == 0: + run_cmd = False + break + if len(key_list) == 0: + if len(key_list_list) == 0: + key_list_list.append([None]) + else: + for k_lst in key_list_list: + k_lst.append(None) + else: + new_list = [] + if len(key_list_list) == 0: + for k in key_list: + key_list_list.append([k]) + else: + for k_lst in key_list_list: + if len(key_list) == 1: + k_lst.append(key_list[0]) + else: + for k in key_list: + new_list.append(k_lst + [k]) + if len(new_list) > 0: + key_list_list = new_list + idx += 1 + if not run_cmd: + continue + + cmd_list_list = [] + for key_list in key_list_list: + upd_id_list = set() + del_id_list = set() + no_chg_id_list = set() + idx = 0 + for dkey in key_list: + if dkey is not None: + dval = data[dkey] + if dval.op == CachedDataWithOp.OP_NONE: + no_chg_id_list.add(idx) + elif dval.op == CachedDataWithOp.OP_ADD or dval.op == CachedDataWithOp.OP_UPDATE: + upd_id_list.add(idx) + elif dval.op == CachedDataWithOp.OP_DELETE: + del_id_list.add(idx) + idx += 1 + cmd_list = [] + if len(del_id_list) > 0: + data_val_op = self.get_cmd_data(key_list, req_idx_list, opt_idx_list, data, del_id_list, no_chg_id_list, merge_vals, True) + if data_val_op is not None: + cmd = key_map.get_command(daemon, data_val_op[1], start_idx, *(upper_vals + data_val_op[0])) + if cmd is not None: + cmd_list += cmd + else: + syslog.syslog(syslog.LOG_ERR, 'failed to get del cmd from value: %s' % data_val_op[0]) + if len(upd_id_list) > 0: + data_val_op = self.get_cmd_data(key_list, req_idx_list, opt_idx_list, data, upd_id_list, no_chg_id_list, merge_vals, False) + if data_val_op is not None: + cmd = key_map.get_command(daemon, data_val_op[1], start_idx, *(upper_vals + data_val_op[0])) + if cmd is not None: + cmd_list += cmd + else: + syslog.syslog(syslog.LOG_ERR, 'failed to get upd cmd from value: %s' % str(data_val_op[0])) + if len(cmd_list) > 0: + cmd_list_list.append(cmd_list) + cmd_list = [] + for chk_list in cmd_list_list: + if self.is_cmd_list_covered(cmd_list, chk_list): + cmd_list = chk_list + failed = False + if len(cmd_list) > 0: + run_cmd_cnt += 1 + cmd_prefix = 'vtysh ' + for pfx in prefix_list: + cmd_prefix += "-c '%s' " % pfx + for cmd in cmd_list: + ignore_fail = False + if type(cmd) is tuple: + cmd, ignore_fail = cmd + if not g_run_command(table, cmd_prefix + "-c '%s'" % cmd, True, key_map.daemons, ignore_fail): + syslog.syslog(syslog.LOG_ERR, 'failed running FRR command: %s' % cmd) + failed = True + break + if not failed: + ret_val = True + if not failed: + for key_list in key_list_list: + for dkey in key_list: + if dkey in data: + data[dkey].status = CachedDataWithOp.STAT_SUCC + if run_cmd_cnt == 0: + return True + return ret_val + +class CommandArgument(object): + def __init__(self, daemon, enabled, val = None): + self.daemon = daemon + self.enabled = enabled + self.value = val + self.tolower = False + def to_str(self): + if type(self.value) is list or type(self.value) is tuple: + ret_val = ' '.join([v for v in self.value]) + elif type(self.value) is dict: + id_list = self.value.keys() + id_list.sort() + ret_val = ' '.join([self.value[i][0] for i in id_list]) + else: + ret_val = str(self.value) + if self.tolower: + ret_val = ret_val.lower() + return ret_val + @staticmethod + def parse_ext_community(com_str, is_rt = None): + if com_str.startswith(CommunityList.RT_TYPE_MARK): + com_str = com_str[len(CommunityList.RT_TYPE_MARK):] + if is_rt is None: + return 'rt %s' % com_str + else: + return (com_str if is_rt else None) + elif com_str.startswith(CommunityList.SOO_TYPE_MARK): + com_str = com_str[len(CommunityList.SOO_TYPE_MARK):] + if is_rt is None: + return 'soo %s' % com_str + else: + return (None if is_rt else com_str) + return None + def __format__(self, format): + bool_format = {'allow-as-in': 'origin', + 'match-clust-len': 'equal-cluster-length', + 'network-backdoor': 'backdoor', + 'aggr-as-set': 'as-set', + 'aggr-summary-only': 'summary-only', + 'uchg-as-path': 'as-path', + 'uchg-med': 'med', + 'uchg-nh': 'next-hop', + 'rm-as-all': 'all', + 'rm-as-repl': 'replace-AS', + 'mp-as-set': ('as-set', 'no-as-set'), + 'no-prepend': 'no-prepend', + 'replace-as': 'replace-as', + 'blackhole': 'blackhole' + } + if format == 'no-prefix': + return 'no ' if not self.enabled else '' + elif format == 'enable-only' and not self.enabled: + return '' + elif format == 'com-ref': + com_set = self.daemon.comm_set_list.get(self.value, None) + if com_set is not None and com_set.is_configurable(): + return ' '.join(com_set.mbr_list) + elif format == 'ext-com-list': + if type(self.value) is tuple: + com_val, is_rt = self.value + else: + com_val = self.value + is_rt = None + if type(com_val) is list: + com_list = com_val + else: + com_list = [com_val] + frr_com_list = [] + for comm in com_list: + frr_comm = self.parse_ext_community(comm, is_rt) + if frr_comm is not None: + frr_com_list.append(frr_comm) + if is_rt is None: + return ' '.join(frr_com_list) + else: + return ('rt ' if is_rt else 'soo ') + ' '.join(frr_com_list) + elif format == 'ext-com-ref': + com_set_name, is_rt = self.value + com_set = self.daemon.extcomm_set_list.get(com_set_name, None) + if com_set is not None and com_set.is_configurable(): + frr_com_list = [] + for comm in com_set.mbr_list: + frr_comm = self.parse_ext_community(comm, is_rt) + if frr_comm is not None: + frr_com_list.append(frr_comm) + return ('rt ' if is_rt else 'soo ') + ' '.join(frr_com_list) + elif format == 'repeat' and type(self.value) is dict: + if 1 in self.value: + rep_cnt = int(self.value[1][0]) + else: + rep_cnt = 1 + if 0 in self.value: + return ' '.join([self.value[0][0]] * rep_cnt) + elif format == 'neighbor-set': + ret_val = BGPConfigDaemon.get_prefix_set_name(self.value, 'NEIGHBOR_SET') + return ret_val + elif format == 'nexthop-set': + ret_val = BGPConfigDaemon.get_prefix_set_name(self.value, 'NEXTHOP_SET') + return ret_val + elif format == 'peer-ip': + if type(self.value) is list and len(self.value) > 0: + return self.value[0] + else: + return self.value + elif format == 'tx-add-paths': + if self.value == 'tx_all_paths': + return 'addpath-tx-all-paths' + elif self.value == 'tx_best_path_per_as': + return 'addpath-tx-bestpath-per-AS' + elif format == 'shutdown-msg': + if len(self.value) > 0: + self.value = 'message %s' % self.value + elif format == 'default-rmap': + if len(self.value) > 0: + self.value = 'route-map %s' % self.value + elif format in bool_format: + false_val = '' + if type(bool_format[format]) is tuple: + if len(bool_format[format]) == 2: + true_val, false_val = bool_format[format] + else: + true_val = bool_format[format][0] + else: + true_val = bool_format[format] + if self.value == 'true': + self.value = true_val + elif self.value == 'false': + self.value = false_val + elif format == 'restart': + if self.value == 'true': + self.value = 'warning-only' + elif self.value == 'false': + self.value = '' + elif len(self.value) > 0: + self.value = 'restart %s' % self.value + elif format == 'redist-route-map': + if len(self.value) > 0: + self.value = 'route-map %s' % self.to_str() + elif format == 'redist-metric': + if len(self.value) > 0: + self.value = 'metric %s' % self.to_str() + elif format == 'track': + if len(self.value) > 0: + self.value = 'track %s' % self.to_str() + elif format == 'network-policy': + if len(self.value) > 0: + self.value = 'route-map %s' % self.to_str() + elif format == 'src-proto': + if self.value == 'ospf3': + self.value = 'ospf6' + elif format == 'aggr-policy': + if len(self.value) > 0: + self.value = 'route-map %s' % self.to_str() + elif format == 'asn_list': + self.value = ' '.join(self.value.split(',')) + elif format == 'nh-tag': + if len(self.value) > 0: + self.value = 'tag %s' % self.to_str() + elif format == 'nh-vrf': + if len(self.value) > 0: + self.value = 'nexthop-vrf %s' % self.to_str() + elif format == 'tolower': + self.tolower = True + elif format == 'pim_hello_parms': + self.value = ' '.join(self.value.split(',')) + return self.to_str() + +def hdl_send_com(daemon, cmd_str, op, st_idx, args, data): + if len(args) < 2: + return None + cmd_list = [] + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, args[0]), CommandArgument(daemon, True, 'all'), no = CommandArgument(daemon, False))) + if op == CachedDataWithOp.OP_DELETE: + com_type = 'all' + else: + com_type = args[1] + if com_type != 'none': + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, args[0]), CommandArgument(daemon, True, com_type), no = CommandArgument(daemon, True))) + return cmd_list + +def hdl_rm_priv_as(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, args[0]), CommandArgument(daemon, True, ''), CommandArgument(daemon, True, ''), + no = CommandArgument(daemon, False))) + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, args[0]), CommandArgument(daemon, True, 'true'), CommandArgument(daemon, True, ''), + no = CommandArgument(daemon, False))) + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, args[0]), CommandArgument(daemon, True, ''), CommandArgument(daemon, True, 'true'), + no = CommandArgument(daemon, False))) + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, args[0]), CommandArgument(daemon, True, 'true'), CommandArgument(daemon, True, 'true'), + no = CommandArgument(daemon, False))) + if op != CachedDataWithOp.OP_DELETE: + cmd_list += get_command_cmn(daemon, cmd_str, op, st_idx, args, data) + return cmd_list + +def hdl_capa_orf_pfxlist(daemon, cmd_str, op, st_idx, args, data): + if len(args) < 2: + return None + cmd_list = [] + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, args[0]), CommandArgument(daemon, True, 'both'), no = CommandArgument(daemon, False))) + if op != CachedDataWithOp.OP_DELETE: + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, args[0]), CommandArgument(daemon, True, args[1]), no = CommandArgument(daemon, True))) + return cmd_list + +def hdl_com_set(daemon, cmd_str, op, st_idx, args, extended): + if len(args) < 2 or 0 not in args[1] or 1 not in args[1] or 2 not in args[1]: + return None + com_name = args[0] + set_type = args[1][0][0].lower() + arg_str = '{} {}'.format(set_type, com_name) + cmd_list = [] + com_set_list = daemon.comm_set_list if not extended else daemon.extcomm_set_list + if com_name in com_set_list and com_set_list[com_name].is_configurable(): + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, arg_str), no = CommandArgument(daemon, False))) + if op != CachedDataWithOp.OP_DELETE: + match_action = args[1][1][0].lower() + member_list = args[1][2][0] + if match_action == 'all': + if extended and set_type == 'standard': + mbr_str = '{} permit {:ext-com-list}'.format(arg_str, CommandArgument(daemon, True, member_list)) + else: + mbr_str = '{} permit {}'.format(arg_str, ' '.join(member_list)) + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, mbr_str), no = CommandArgument(daemon, True))) + elif match_action == 'any': + for member in member_list: + if extended and set_type == 'standard': + mbr_str = '{} permit {:ext-com-list}'.format(arg_str, CommandArgument(daemon, True, member)) + else: + mbr_str = '{} permit {}'.format(arg_str, member) + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, mbr_str), no = CommandArgument(daemon, True))) + return cmd_list + +def hdl_aspath_set(daemon, cmd_str, op, st_idx, args, data): + if len(args) < 2: + return None + cmd_list = [] + as_set_name = args[0] + if as_set_name in daemon.as_path_set_list: + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, as_set_name), no = CommandArgument(daemon, False))) + if op != CachedDataWithOp.OP_DELETE and len(args[1]) > 0: + for asn in args[1]: + mbr_str = '{} permit {}'.format(as_set_name, asn) + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, mbr_str), no = CommandArgument(daemon, True))) + return cmd_list + +def hdl_ibgp_maxpath(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + if op != CachedDataWithOp.OP_DELETE: + # blindly run no command first + cmd_list = [cmd_str.format(CommandArgument(daemon, True, args[0]), + CommandArgument(daemon, True, 'false'), + no = CommandArgument(daemon, False))] + upd_cmd_list = get_command_cmn(daemon, cmd_str, op, st_idx, args, data) + if upd_cmd_list is None: + return None + return cmd_list + upd_cmd_list + +def hdl_ospf_log(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + + no_op = 'no ' if op == CachedDataWithOp.OP_DELETE else '' + + if (no_op == 'no '): + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, ""))) + elif (args[0] == "DETAIL"): + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, args[0].lower()))) + elif (args[0] == "BRIEF"): + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, ""))) + + return cmd_list + +def handle_ospf_area_auth(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + + no_op = 'no ' if op == CachedDataWithOp.OP_DELETE else '' + + if (args[1] == "MD5HMAC"): + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, args[0]), + CommandArgument(daemon, True, "message-digest"))) + + elif (args[1] == "TEXT"): + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, args[0]), + CommandArgument(daemon, True, ""))) + elif (args[1] == "NONE"): + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, 'no '), + CommandArgument(daemon, True, args[0]), + CommandArgument(daemon, True, ""))) + return cmd_list + +def handle_ospf_area_shortcut(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + + no_op = 'no ' if op == CachedDataWithOp.OP_DELETE else '' + + if (args[1] == "DEFAULT") and (no_op != 'no '): + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, args[0]), + CommandArgument(daemon, True, "default"))) + + elif (args[1] == "ENABLE"): + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, args[0]), + CommandArgument(daemon, True, "enable"))) + elif (args[1] == "DISABLE"): + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, args[0]), + CommandArgument(daemon, True, "disable"))) + return cmd_list + +def handle_ospf_area_vlink_auth(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + + no_op = 'no ' if op == CachedDataWithOp.OP_DELETE else '' + + if (args[2] == "MD5HMAC"): + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, args[0]), + CommandArgument(daemon, True, args[1]), + CommandArgument(daemon, True, "message-digest"))) + elif (args[2] == "NONE"): + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, args[0]), + CommandArgument(daemon, True, args[1]), + CommandArgument(daemon, True, "null"))) + + return cmd_list + +def handle_ospf_area_range_advt(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + + + no_op = 'no ' if op == CachedDataWithOp.OP_DELETE else '' + + if (args[2] == 'true'): + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, args[0]), + CommandArgument(daemon, True, args[1]), + CommandArgument(daemon, True, "advertise"))) + elif (args[2] == 'false'): + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, args[0]), + CommandArgument(daemon, True, args[1]), + CommandArgument(daemon, True, "not-advertise"))) + return cmd_list + +def handle_ospf_abrtype(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + + no_op = 'no ' if op == CachedDataWithOp.OP_DELETE else '' + + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, args[0].lower()))) + + return cmd_list + + +def handle_ospf_if_common(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + if_addr = "" if args[1] == '0.0.0.0' else args[1] + no_op = 'no ' if op == CachedDataWithOp.OP_DELETE else '' + param_value = args[2] + + syslog.syslog(syslog.LOG_INFO, 'handle_ospf_if_common cmd_str {} op {} st_idx {} args {} data {}'.format( + cmd_str, op, st_idx, args, data)) + + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, param_value), + CommandArgument(daemon, True, if_addr))) + return cmd_list + + +def handle_ospf_if_authtype(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + if_addr = "" if args[1] == '0.0.0.0' else args[1] + no_op = 'no ' if op == CachedDataWithOp.OP_DELETE else '' + + authtype = '' + if args[2] == 'TEXT' : + authtype = '' + elif args[2] == 'MD5HMAC' : + authtype = 'message-digest' + elif args[2] == 'NONE' : + authtype = 'null' + else : + syslog.syslog(syslog.LOG_ERR, 'handle_ospf_if_nwtype invalid auth type args {}'.format(args)) + + syslog.syslog(syslog.LOG_INFO, 'handle_ospf_if_authtype cmd_str {} op {} st_idx {} args {} data {}'.format( + cmd_str, op, st_idx, args, data)) + + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, authtype), + CommandArgument(daemon, True, if_addr))) + return cmd_list + + +def handle_ospf_if_md5key(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + if_addr = "" if args[1] == '0.0.0.0' else args[1] + no_op = 'no ' if op == CachedDataWithOp.OP_DELETE else '' + + md5key_id = args[2] + md5key = args[3] + + syslog.syslog(syslog.LOG_INFO, 'handle_ospf_if_md5key cmd_str {} op {} st_idx {} args {} data {}'.format( + cmd_str, op, st_idx, args, data)) + + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, md5key_id), + CommandArgument(daemon, True, md5key), + CommandArgument(daemon, True, if_addr))) + return cmd_list + + +def handle_ospf_if_mtu_ignore(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + if_addr = "" if args[1] == '0.0.0.0' else args[1] + no_op = 'no ' if op == CachedDataWithOp.OP_DELETE else '' + + syslog.syslog(syslog.LOG_INFO, 'handle_ospf_if_mtu_ignore cmd_str {} op {} st_idx {} args {} data {}'.format( + cmd_str, op, st_idx, args, data)) + + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, if_addr))) + return cmd_list + + +def handle_ospf_if_nwtype(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + no_op = 'no ' if op == CachedDataWithOp.OP_DELETE else '' + + nwtype = '' + if args[2] == 'POINT_TO_POINT_NETWORK' : + nwtype = 'point-to-point' + elif args[2] == 'BROADCAST_NETWORK' : + nwtype = 'broadcast' + else : + syslog.syslog(syslog.LOG_ERR, 'handle_ospf_if_nwtype invalid nw type args {}'.format(args)) + + syslog.syslog(syslog.LOG_INFO, 'handle_ospf_if_nwtype cmd_str {} op {} st_idx {} args {} data {}'.format( + cmd_str, op, st_idx, args, data)) + + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, no_op), + CommandArgument(daemon, True, nwtype))) + return cmd_list + +def handle_igmp_if_common(daemon, cmd_str, op, st_idx, args, data): + if len(args) != 1: + return None + cmd_list = [] + param_value = args[0] + + syslog.syslog(syslog.LOG_INFO, 'handle_igmp_if_common cmd_str {} op {} st_idx {} args {} data {}'.format( + cmd_str, op, st_idx, args, data)) + + if op != CachedDataWithOp.OP_DELETE: + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, param_value))) + else: + cmd_list.append('no ' + cmd_str.format(CommandArgument(daemon, True, ''))) + + syslog.syslog(syslog.LOG_INFO, 'handle_igmp_if_common param {}, cmd_list {}'.format(param_value, cmd_list)) + return cmd_list + +def handle_igmp_if_enable(daemon, cmd_str, op, st_idx, args, data): + if len(args) != 1: + return None + cmd_list = [] + param_value = args[0] + + syslog.syslog(syslog.LOG_INFO, 'handle_igmp_if_enable cmd_str {} op {} st_idx {} args {} data {}'.format( + cmd_str, op, st_idx, args, data)) + + if op != CachedDataWithOp.OP_DELETE: + if param_value == 'false': + cmd_list.append('no ' + cmd_str.format(CommandArgument(daemon, True, ''))) + else: + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, ''))) + else: + cmd_list.append('no ' + cmd_str.format(CommandArgument(daemon, True, ''))) + + syslog.syslog(syslog.LOG_INFO, 'handle_igmp_if_enable param {}, cmd_list {}'.format(param_value, cmd_list)) + return cmd_list + +def handle_ip_sla_common(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + + syslog.syslog(syslog.LOG_INFO, 'handle_ip_sla cmd_str {} op {} st_idx {} args {} data {}'.format( + cmd_str, op, st_idx, args, data)) + + if op != CachedDataWithOp.OP_DELETE: + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, args[1]))) + else: + cmd_list.append('no ' + cmd_str.format(CommandArgument(daemon, True, ''))) + + return cmd_list + +def handle_ip_sla_tcp_connect(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + + syslog.syslog(syslog.LOG_INFO, 'handle_ip_sla_tcp_connect cmd_str {} op {} st_idx {} args {} data {}'.format( + cmd_str, op, st_idx, args, data)) + tcp_cmd_token = ("tcp", "connect") + tcp_cmd_str = "-".join(tcp_cmd_token) + tcp_cmd_deconfig = ' no ' + tcp_cmd_str + + if op != CachedDataWithOp.OP_DELETE: + cmd_list.append(' ') + else: + cmd_list.append(tcp_cmd_deconfig) + + return cmd_list + +def handle_ip_sla_icmp_echo(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + + syslog.syslog(syslog.LOG_INFO, 'handle_ip_sla_icmp_echo cmd_str {} op {} st_idx {} args {} data {}'.format( + cmd_str, op, st_idx, args, data)) + icmp_cmd_token = ("icmp", "echo") + icmp_cmd_str = "-".join(icmp_cmd_token) + icmp_cmd_deconfig = ' no ' + icmp_cmd_str + + if op != CachedDataWithOp.OP_DELETE: + cmd_list.append(' ') + syslog.syslog(syslog.LOG_INFO, 'handle_ip_sla_icmp_echo cmd_list {}'.format(cmd_list)) + else: + cmd_list.append(icmp_cmd_deconfig) + + syslog.syslog(syslog.LOG_INFO, 'handle_ip_sla_icmp_echo cmd_list {}'.format(cmd_list)) + return cmd_list + + + +def hdl_af_aggregate(daemon, cmd_str, op, st_idx, args, data): + if len(args) < 5: + return None + cmd_list = [] + if op != CachedDataWithOp.OP_DELETE: + vrf = args[0] + af = args[1] + ip_prefix = args[2] + if vrf in daemon.af_aggr_list and ip_prefix in daemon.af_aggr_list[vrf]: + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, vrf), CommandArgument(daemon, True, af), CommandArgument(daemon, True, ip_prefix), + CommandArgument(daemon, True, ''), CommandArgument(daemon, True, ''), CommandArgument(daemon, True, ''), + no = CommandArgument(daemon, False))) + upd_cmd_list = get_command_cmn(daemon, cmd_str, op, st_idx, args, data) + if upd_cmd_list is None: + return None + return cmd_list + upd_cmd_list + +def hdl_route_redist_set(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + if op != CachedDataWithOp.OP_DELETE: + proto = args[0] + # blindly run no command first + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, proto), CommandArgument(daemon, True, ''), CommandArgument(daemon, True, ''), + no = CommandArgument(daemon, False))) + upd_cmd_list = get_command_cmn(daemon, cmd_str, op, st_idx, args, data) + if upd_cmd_list is None: + return None + return cmd_list + upd_cmd_list + +def hdl_attr_unchanged(daemon, cmd_str, op, st_idx, args, data): + # blindly run no command first + cmd_list = [cmd_str.format(CommandArgument(daemon, True, args[0]), + CommandArgument(daemon, True, ''), + CommandArgument(daemon, True, ''), + CommandArgument(daemon, True, ''), + no = CommandArgument(daemon, False))] + if op != CachedDataWithOp.OP_DELETE: + upd_cmd_list = get_command_cmn(daemon, cmd_str, op, st_idx, args, data) + if upd_cmd_list is None: + return None + cmd_list += upd_cmd_list + return cmd_list + +def hdl_leaf_list_expansion(daemon, cmd_str, op, st_idx, args, data, table_key, item_key): + cmd_list = [] + old_list = [] + if op != CachedDataWithOp.OP_DELETE: + new_list = args[st_idx] + else: + new_list = [] + + syslog.syslog(syslog.LOG_DEBUG, 'handle_leaf_list_expansion {} op {} st_idx {} args {} data {} table_key {} item_key {}'.format( + cmd_str, op, st_idx, args, data, table_key, item_key)) + + if table_key in daemon.table_data_cache.keys(): + cache_tbl_data = daemon.table_data_cache[table_key] + if item_key in cache_tbl_data: + old_list = cache_tbl_data[item_key] + + del_list = list(set(old_list) - set(new_list)) + add_list = list(set(new_list) - set(old_list)) + + for value in add_list: + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, value), no = CommandArgument(daemon, True))) + for value in del_list: + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, value), no = CommandArgument(daemon, False))) + + syslog.syslog(syslog.LOG_DEBUG, 'cmd_list {}'.format(cmd_list)) + return cmd_list + +def hdl_import_list(daemon, cmd_str, op, st_idx, args, data): + return hdl_leaf_list_expansion(daemon, cmd_str, op, st_idx, args, data, daemon.tmp_cache_key, 'import-rts') + +def hdl_export_list(daemon, cmd_str, op, st_idx, args, data): + return hdl_leaf_list_expansion(daemon, cmd_str, op, st_idx, args, data, daemon.tmp_cache_key, 'export-rts') + +def hdl_enum_conversion(daemon, cmd_str, op, st_idx, args, data): + cmd_list = [] + syslog.syslog(syslog.LOG_DEBUG, 'handle_enum_conversion {} op {} st_idx {} args {} data {}'.format( + cmd_str, op, st_idx, args, data)) + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, args[st_idx].lower().replace('_','-')), + no = CommandArgument(daemon, (op != CachedDataWithOp.OP_DELETE)))) + syslog.syslog(syslog.LOG_DEBUG, 'cmd_list {}'.format(cmd_list)) + return cmd_list + +def hdl_confed_peers(daemon, cmd_str, op, st_idx, args, data): + del_list = [] + add_list = [] + if op == CachedDataWithOp.OP_DELETE: + del_list = list(daemon.upd_confed_peers) + daemon.upd_confed_peers.clear() + else: + for peer in args[0]: + if peer not in daemon.upd_confed_peers: + add_list.append(peer) + else: + daemon.upd_confed_peers.remove(peer) + del_list = list(daemon.upd_confed_peers) + daemon.upd_confed_peers = set(args[0]) + cmd_list = [] + if len(del_list) > 0: + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, del_list), no = CommandArgument(daemon, False))) + if len(add_list) > 0: + cmd_list.append(cmd_str.format(CommandArgument(daemon, True, add_list), no = CommandArgument(daemon, True))) + return cmd_list + +def hdl_static_route(daemon, cmd_str, op, st_idx, args, data): + if len(args) < 6: + return None + vrf = args[0] + ip_prefix = args[1] + af = data + if op == CachedDataWithOp.OP_DELETE: + ip_nh_set = IpNextHopSet(af) + else: + arg_list = lambda v: v.split(',') if len(v.strip()) != 0 else None + bkh_list = arg_list(args[2]) + nh_list = arg_list(args[3]) + track_list = arg_list(args[5]) + intf_list = arg_list(args[4]) + tag_list = arg_list(args[6]) + dist_list = arg_list(args[7]) + nh_vrf_list = arg_list(args[8]) + ip_nh_set = IpNextHopSet(af, bkh_list, nh_list, track_list, intf_list, tag_list, dist_list, nh_vrf_list) + cur_nh_set = daemon.static_route_list.get(vrf, {}).get(ip_prefix, IpNextHopSet(af)) + diff_set = ip_nh_set.symmetric_difference(cur_nh_set) + op_cmd_list = {} + for ip_nh in diff_set: + if ip_nh in cur_nh_set: + op = CachedDataWithOp.OP_DELETE + else: + op = CachedDataWithOp.OP_ADD + try: + op_cmds = op_cmd_list.setdefault(op, []) + op_cmds += get_command_cmn(daemon, cmd_str, op, st_idx, [ip_prefix] + ip_nh.get_arg_list(), None) + except socket.error: + syslog.syslog(syslog.LOG_ERR, 'Invalid IP in next-hop %s' % ip_nh) + return None + cmd_list = op_cmd_list.get(CachedDataWithOp.OP_DELETE, []) + cmd_list += op_cmd_list.get(CachedDataWithOp.OP_ADD, []) + daemon.upd_nh_set = ip_nh_set + return cmd_list + +class ExtConfigDBConnector(ConfigDBConnector): + def __init__(self, ns_attrs = None): + super(ExtConfigDBConnector, self).__init__() + self.nosort_attrs = ns_attrs if ns_attrs is not None else {} + def raw_to_typed(self, raw_data, table = ''): + if len(raw_data) == 0: + raw_data = None + data = super(ExtConfigDBConnector, self).raw_to_typed(raw_data) + if data is None: + return None + for key, val in data.items(): + if type(val) is list and key not in self.nosort_attrs.get(table, set()): + val.sort() + return data + def sub_msg_handler(self, msg_item): + if msg_item['type'] == 'pmessage': + key = msg_item['channel'].split(':', 1)[1] + try: + (table, row) = key.split(self.TABLE_NAME_SEPARATOR, 1) + if table in self.handlers: + client = self.get_redis_client(self.db_name) + data = self.raw_to_typed(client.hgetall(key), table) + super(ExtConfigDBConnector, self)._ConfigDBConnector__fire(table, row, data) + except ValueError: + pass #Ignore non table-formated redis entries + except Exception as e: + syslog.syslog(syslog.LOG_ERR, '[bgp cfgd] Failed handling config DB update with exception:' + str(e)) + logging.exception(e) + def listen(self): + """Start listen Redis keyspace events and will trigger corresponding handlers when content of a table changes. + """ + self.pubsub = self.get_redis_client(self.db_name).pubsub() + self.pubsub.psubscribe(**{"__keyspace@{}__:*".format(self.get_dbid(self.db_name)): self.sub_msg_handler}) + self.sub_thread = self.pubsub.run_in_thread(sleep_time = 0.01) + @staticmethod + def get_table_key(table, key): + return table + '&&' + key + def get_table_data(self, table_list): + ret_data = {} + for table in table_list: + table_data = self.get_table(table) + for key, data in table_data.items(): + table_key = self.get_table_key(table, self.serialize_key(key)) + ret_data[table_key] = data + return ret_data + +class CommunityList: + MATCH_ALL = 0 + MATCH_ANY = 1 + RT_TYPE_MARK = 'route-target:' + SOO_TYPE_MARK = 'route-origin:' + def __init__(self, name, extended): + self.name = name + self.is_ext = extended + self.match_action = None + self.is_std = None + self.mbr_list = [] + def is_configurable(self): + return (self.match_action is not None and self.is_std is not None and + len(self.mbr_list) > 0) + def db_data_to_attr(self, name, val): + if name == 'match_action': + if val is None: + self.match_action = None + else: + if val.lower() == 'all': + self.match_action = self.MATCH_ALL + else: + self.match_action = self.MATCH_ANY + elif name == 'set_type': + if val is None: + self.is_std = None + else: + self.is_std = (val.lower() == 'standard') + elif name == 'community_member': + self.mbr_list = [] + if val is not None: + if type(val) is not list: + self.mbr_list = val.split(',') + else: + self.mbr_list = val + +class MatchPrefix: + IPV4_MAXLEN = 32 + IPV6_MAXLEN = 128 + @staticmethod + def normalize_ip_prefix(af, ip_prefix): + ip_mask = ip_prefix.split('/') + ip_addr = ip_mask[0] + if len(ip_mask) < 2: + mask_len = MatchPrefix.IPV4_MAXLEN if af == socket.AF_INET else MatchPrefix.IPV6_MAXLEN + return '%s/%d' % (ip_addr, mask_len) + mask_len = int(ip_mask[1]) + ip_net = netaddr.IPNetwork('%s/%d' % (ip_addr, mask_len)) + try: + normal_ip = socket.inet_ntop(af, ip_net.cidr.ip.packed) + except ValueError: + return None + return '%s/%d' % (normal_ip, mask_len) + def __init__(self, af, ip_prefix, len_range = None, action = 'permit'): + self.ip_prefix = self.normalize_ip_prefix(af, ip_prefix) + if self.ip_prefix is None: + raise ValueError + if len_range is not None: + min_len, max_len = len_range.split('..') + self.min_len = int(min_len) + self.max_len = int(max_len) + _, pfx_len = self.ip_prefix.split('/') + if int(pfx_len) >= self.min_len: + self.min_len = None + elif ((af == socket.AF_INET and self.max_len == self.IPV4_MAXLEN) or + (af == socket.AF_INET6 and self.max_len == self.IPV6_MAXLEN)): + self.max_len = None + else: + self.min_len = self.max_len = None + self.action = action + def __hash__(self): + return hash((self.ip_prefix, self.min_len, self.max_len)) + def __str__(self): + ret_str = '%s %s' % (self.action.lower(), self.ip_prefix) + if self.min_len is not None: + ret_str += ' ge %d' % self.min_len + if self.max_len is not None: + ret_str += ' le %d' % self.max_len + return ret_str + def __eq__(self, other): + return (self.ip_prefix == other.ip_prefix and + self.min_len == other.min_len and + self.max_len == other.max_len) + def __ne__(self, other): + return (self.ip_prefix != other.ip_prefix or + self.min_len != other.min_len or + self.max_len != other.max_len) + +class MatchPrefixList(list): + def __init__(self, af_mode = None): + super(MatchPrefixList, self).__init__() + if af_mode is None: + self.af = None + else: + self.af = socket.AF_INET if af_mode == 'ipv4' else socket.AF_INET6 + def __eq__(self, other): + return super(MatchPrefixList, self).__eq__(other) and self.af == other.af + def __ne__(self, other): + return super(MatchPrefixList, self).__ne__(other) or self.af != other.af + @staticmethod + def __get_ip_af(ip_pfx): + ip_pfx = ip_pfx.split('/') + ip_addr = ip_pfx[0] + af_list = [socket.AF_INET, socket.AF_INET6] + for af in af_list: + try: + socket.inet_pton(af, ip_addr) + return af + except socket.error: + continue + return None + def add_prefix(self, ip_pfx, len_range = None, action = 'permit'): + af = self.__get_ip_af(ip_pfx) + if self.af is None: + self.af = af + else: + if self.af != af: + syslog.syslog(syslog.LOG_ERR, 'af of prefix %s is not the same as prefix set' % ip_pfx) + raise ValueError + self.append(MatchPrefix(self.af, ip_pfx, len_range, action)) + return self[-1] + def get_prefix(self, ip_pfx, len_range = None, action = 'permit'): + if self.af is None: + return (None, None) + prefix = MatchPrefix(self.af, ip_pfx, len_range, action) + try: + idx = self.index(prefix) + except ValueError: + return (None, None) + return (self[idx], idx) + +class AggregateAddr: + def __init__(self): + self.as_set = False + self.summary_only = False + +class IpNextHop: + def __init__(self, af_id, blackhole, dst_ip, track, if_name, tag, dist, vrf): + zero_ip = lambda af: '0.0.0.0' if af == socket.AF_INET else '::' + self.af = af_id + self.blackhole = 'false' if blackhole is None or blackhole == '' else blackhole + self.distance = 0 if dist is None else int(dist) + self.track = 0 if track is None else int(track) + if self.blackhole == 'true': + dst_ip = if_name = vrf = None + self.ip = zero_ip(af_id) if dst_ip is None else dst_ip + self.interface = '' if if_name is None else if_name + self.tag = 0 if tag is None else int(tag) + self.nh_vrf = '' if vrf is None else vrf + if self.blackhole != 'true' and self.is_zero_ip() and len(self.interface.strip()) == 0: + syslog.syslog(syslog.LOG_ERR, 'Mandatory attribute not found for nexthop') + raise ValueError + def __eq__(self, other): + return (self.af == other.af and self.blackhole == other.blackhole and + self.ip == other.ip and self.track == other.track and self.interface == other.interface and + self.tag == other.tag and self.distance == other.distance and self.nh_vrf == other.nh_vrf) + def __ne__(self, other): + return (self.af != other.af or self.blackhole != other.blackhole or + self.ip != other.ip or self.track != other.track or self.interface != other.interface or + self.tag != other.tag or self.distance != other.distance or self.nh_vrf != other.nh_vrf) + def __hash__(self): + return hash((self.af, self.blackhole, self.ip, self.track, self.interface, self.tag, self.distance, self.nh_vrf)) + def __str__(self): + return 'AF %d BKH %s IP %s TRACK %d INTF %s TAG %d DIST %d VRF %s' % ( + self.af, self.blackhole, self.ip, self.track, self.interface, self.tag, self.distance, self.nh_vrf) + def is_zero_ip(self): + return sum([x for x in socket.inet_pton(self.af, self.ip)]) == 0 + def get_arg_list(self): + arg = lambda x: '' if x is None else x + num_arg = lambda x: '' if x is None or x == 0 else str(x) + ip_arg = lambda : '' if self.ip is None else ('' if self.is_zero_ip() else self.ip) + return [self.blackhole, ip_arg(), arg(self.interface), num_arg(self.track), num_arg(self.tag), num_arg(self.distance), arg(self.nh_vrf)] + +class IpNextHopSet(set): + def __init__(self, af, bkh_list = None, ip_list = None, track_list = None, intf_list = None, tag_list = None, dist_list = None, vrf_list = None): + super(IpNextHopSet, self).__init__() + if bkh_list is None and ip_list is None and intf_list is None: + # empty set, for delete case + return + nums = {len(x) for x in [bkh_list, ip_list, track_list, intf_list, tag_list, dist_list, vrf_list] if x is not None} + if len(nums) != 1: + syslog.syslog(syslog.LOG_ERR, 'Lists of next-hop attribute have different sizes: %s' % nums) + for x in [bkh_list, ip_list, track_list, intf_list, tag_list, dist_list, vrf_list]: + syslog.syslog(syslog.LOG_DEBUG, 'List: %s' % x) + return + nh_cnt = nums.pop() + item = lambda lst, i: lst[i] if lst is not None else None + for idx in range(nh_cnt): + try: + self.add(IpNextHop(af, item(bkh_list, idx), item(ip_list, idx), item(track_list, idx), item(intf_list, idx), + item(tag_list, idx), item(dist_list, idx), item(vrf_list, idx), )) + except ValueError: + continue + @staticmethod + def get_af_norm_prefix(ip_prefix): + for af_id in [socket.AF_INET, socket.AF_INET6]: + new_prefix = MatchPrefix.normalize_ip_prefix(af_id, ip_prefix) + if new_prefix is not None: + return (af_id, new_prefix) + return (None, None) + +class BGPConfigDaemon: + DEFAULT_VRF = 'default' + + global_key_map = [('router_id', '{no:no-prefix}bgp router-id {}'), + (['load_balance_mp_relax', '+as_path_mp_as_set'], '{no:no-prefix}bgp bestpath as-path multipath-relax {:mp-as-set}', ['true', 'false']), + ('always_compare_med', '{no:no-prefix}bgp always-compare-med', ['true', 'false']), + ('external_compare_router_id', '{no:no-prefix}bgp bestpath compare-routerid', ['true', 'false']), + ('ignore_as_path_length', '{no:no-prefix}bgp bestpath as-path ignore', ['true', 'false']), + ('graceful_restart_enable', '{no:no-prefix}bgp graceful-restart', ['true', 'false']), + ('gr_restart_time', '{no:no-prefix}bgp graceful-restart restart-time {}'), + ('gr_stale_routes_time', '{no:no-prefix}bgp graceful-restart stalepath-time {}'), + ('gr_preserve_fw_state', '{no:no-prefix}bgp graceful-restart preserve-fw-state', ['true', 'false']), + ('log_nbr_state_changes', '{no:no-prefix}bgp log-neighbor-changes', ['true', 'false']), + ('rr_cluster_id', '{no:no-prefix}bgp cluster-id {}'), + ('rr_allow_out_policy', '{no:no-prefix}bgp route-reflector allow-outbound-policy', ['true', 'false']), + ('disable_ebgp_connected_rt_check', '{no:no-prefix}bgp disable-ebgp-connected-route-check', ['true', 'false']), + ('fast_external_failover', '{no:no-prefix}bgp fast-external-failover', ['true', 'false', True]), + ('network_import_check', '{no:no-prefix}bgp network import-check', ['true', 'false']), + ('graceful_shutdown', '{no:no-prefix}bgp graceful-shutdown', ['true', 'false']), + ('rr_clnt_to_clnt_reflection', '{no:no-prefix}bgp client-to-client reflection', ['true', 'false', True]), + ('max_dynamic_neighbors', '{no:no-prefix}bgp listen limit {}'), + ('read_quanta', '{no:no-prefix}read-quanta {}'), + ('write_quanta', '{no:no-prefix}write-quanta {}'), + ('coalesce_time', '{no:no-prefix}coalesce-time {}'), + ('route_map_process_delay', '{no:no-prefix}bgp route-map delay-timer {}'), + ('deterministic_med', '{no:no-prefix}bgp deterministic-med', ['true', 'false']), + ('med_confed', '{no:no-prefix}bgp bestpath med confed', ['true', 'false']), + ('med_missing_as_worst', '{no:no-prefix}bgp bestpath med missing-as-worst', ['true', 'false']), + ('compare_confed_as_path', '{no:no-prefix}bgp bestpath as-path confed', ['true', 'false']), + ('default_ipv4_unicast', '{no:no-prefix}bgp default ipv4-unicast', ['true', 'false']), + ('default_local_preference', '{no:no-prefix}bgp default local-preference {}'), + ('default_show_hostname', '{no:no-prefix}bgp default show-hostname', ['true', 'false']), + ('default_shutdown', '{no:no-prefix}bgp default shutdown', ['true', 'false']), + ('default_subgroup_pkt_queue_max', '{no:no-prefix}bgp default subgroup-pkt-queue-max {}'), + (['max_med_time', '+max_med_val'], '{no:no-prefix}bgp max-med on-startup {} {}'), + (['max_delay', '+establish_wait'], '{no:no-prefix}update-delay {} {}'), + ('confed_id', '{no:no-prefix}bgp confederation identifier {}'), + ('confed_peers', '{no:no-prefix}bgp confederation peers {}', hdl_confed_peers), + (['keepalive', 'holdtime'], '{no:no-prefix}timers bgp {} {}'), + (['max_med_admin', '+max_med_admin_val'], '{no:no-prefix}bgp max-med administrative {}', ['true', 'false']) + ] + + global_af_key_map = [(['ebgp_route_distance', + 'ibgp_route_distance', + 'local_route_distance'], '{no:no-prefix}distance bgp {} {} {}'), + ('max_ebgp_paths', '{no:no-prefix}maximum-paths {}'), + (['max_ibgp_paths', + '+ibgp_equal_cluster_length'], '{no:no-prefix}maximum-paths ibgp {} {:match-clust-len}', hdl_ibgp_maxpath), + ('route_download_filter', '{no:no-prefix}table-map {}'), + (['route_flap_dampen', + '+route_flap_dampen_half_life', + '+route_flap_dampen_reuse_threshold', + '+route_flap_dampen_suppress_threshold', + '+route_flap_dampen_max_suppress'], '{no:no-prefix}bgp dampening {} {} {} {}', ['true', 'false']), + ('advertise-all-vni', '{no:no-prefix}advertise-all-vni', ['true','false']), + ('advertise-default-gw', '{no:no-prefix}advertise-default-gw', ['true','false']), + ('advertise-ipv4-unicast', '{no:no-prefix}advertise ipv4 unicast', ['true','false']), + ('advertise-ipv6-unicast', '{no:no-prefix}advertise ipv6 unicast', ['true','false']), + ('default-originate-ipv4', '{no:no-prefix}default-originate ipv4', ['true','false']), + ('default-originate-ipv6', '{no:no-prefix}default-originate ipv6', ['true','false']), + ('autort', '{no:no-prefix}autort {}', hdl_enum_conversion), + ('flooding', '{no:no-prefix}flooding {}'), + ('dad-enabled', '{no:no-prefix}dup-addr-detection', ['true','false']), + (['dad-max-moves', + 'dad-time'], '{no:no-prefix}dup-addr-detection max-moves {} time {}'), + ('dad-freeze', '{no:no-prefix}dup-addr-detection freeze {}'), + ('route-distinguisher', '{no:no-prefix}rd {}'), + ('import-rts', '{no:no-prefix}route-target import {}', hdl_import_list), + ('export-rts', '{no:no-prefix}route-target export {}', hdl_export_list), + ('import_vrf', '{no:no-prefix}import vrf {}'), + ('import_vrf_route_map', '{no:no-prefix}import vrf route-map {}') + ] + + cmn_key_map = [('asn&peer_type', '{no:no-prefix}neighbor {} remote-as {}'), + (['local_asn', '+local_as_no_prepend', + '+local_as_replace_as'], '{no:no-prefix}neighbor {} local-as {} {:no-prepend} {:replace-as}'), + (['admin_status', '+shutdown_message'], '{no:no-prefix}neighbor {} shutdown {:shutdown-msg}', ['false', 'true']), + ('local_addr', '{no:no-prefix}neighbor {} update-source {}'), + ('name', '{no:no-prefix}neighbor {} description {}'), + (['ebgp_multihop', '+ebgp_multihop_ttl'],'{no:no-prefix}neighbor {} ebgp-multihop {}', ['true', 'false']), + ('auth_password', '{no:no-prefix}neighbor {} password {} encrypted'), + (['keepalive', 'holdtime'], '{no:no-prefix}neighbor {} timers {} {}'), + ('conn_retry', '{no:no-prefix}neighbor {} timers connect {}'), + ('min_adv_interval', '{no:no-prefix}neighbor {} advertisement-interval {}'), + ('passive_mode', '{no:no-prefix}neighbor {} passive', ['true', 'false']), + ('capability_ext_nexthop', '{no:no-prefix}neighbor {} capability extended-nexthop', ['true', 'false']), + ('disable_ebgp_connected_route_check', '{no:no-prefix}neighbor {} disable-connected-check', ['true', 'false']), + ('enforce_first_as', '{no:no-prefix}neighbor {} enforce-first-as', ['true', 'false']), + ('solo_peer', '{no:no-prefix}neighbor {} solo', ['true', 'false']), + ('ttl_security_hops', '{no:no-prefix}neighbor {} ttl-security hops {}'), + ('bfd', '{no:no-prefix}neighbor {} bfd', ['true', 'false']), + ('bfd_check_ctrl_plane_failure', '{no:no-prefix}neighbor {} bfd check-control-plane-failure', ['true', 'false']), + ('capability_dynamic', '{no:no-prefix}neighbor {} capability dynamic', ['true', 'false']), + ('dont_negotiate_capability', '{no:no-prefix}neighbor {} dont-capability-negotiate', ['true', 'false']), + ('enforce_multihop', '{no:no-prefix}neighbor {} enforce-multihop', ['true', 'false']), + ('override_capability', '{no:no-prefix}neighbor {} override-capability', ['true', 'false']), + ('peer_port', '{no:no-prefix}neighbor {} port {}'), + ('strict_capability_match', '{no:no-prefix}neighbor {} strict-capability-match', ['true', 'false']) + ] + + nbr_key_map = [('peer_group_name', '{no:no-prefix}neighbor {} peer-group {}')] + + nbr_af_key_map = [(['allow_as_in', '+allow_as_count&allow_as_origin'], '{no:no-prefix}neighbor {} allowas-in {:allow-as-in}', ['true', 'false']), + ('admin_status|ipv4', '{no:no-prefix}neighbor {} activate', ['true', 'false', False]), + ('admin_status|ipv6', '{no:no-prefix}neighbor {} activate', ['true', 'false', False]), + ('admin_status|l2vpn', '{no:no-prefix}neighbor {} activate', ['true', 'false', False]), + (['send_default_route', '+default_rmap'], '{no:no-prefix}neighbor {} default-originate {:default-rmap}', ['true', 'false']), + ('default_rmap', '{no:no-prefix}neighbor {} default-originate route-map {}'), + (['max_prefix_limit', '++max_prefix_warning_threshold', + '+max_prefix_restart_interval&max_prefix_warning_only'], '{no:no-prefix}neighbor {} maximum-prefix {} {} {:restart}'), + ('route_map_in', '{no:no-prefix}neighbor {} route-map {} in'), + ('route_map_out', '{no:no-prefix}neighbor {} route-map {} out'), + ('soft_reconfiguration_in', '{no:no-prefix}neighbor {} soft-reconfiguration inbound', ['true', 'false']), + ('unsuppress_map_name', '{no:no-prefix}neighbor {} unsuppress-map {}'), + ('rrclient', '{no:no-prefix}neighbor {} route-reflector-client', ['true', 'false']), + ('weight', '{no:no-prefix}neighbor {} weight {}'), + ('as_override', '{no:no-prefix}neighbor {} as-override', ['true', 'false']), + ('send_community', '{no:no-prefix}neighbor {} send-community {}', hdl_send_com), + ('tx_add_paths', '{no:no-prefix}neighbor {} {:tx-add-paths}'), + (['++unchanged_as_path', + '++unchanged_med', '++unchanged_nexthop'], '{no:no-prefix}neighbor {} attribute-unchanged {:uchg-as-path} {:uchg-med} {:uchg-nh}', hdl_attr_unchanged), + ('filter_list_in', '{no:no-prefix}neighbor {} filter-list {} in'), + ('filter_list_out', '{no:no-prefix}neighbor {} filter-list {} out'), + ('nhself', '{no:no-prefix}neighbor {} next-hop-self', ['true', 'false']), + ('nexthop_self_force', '{no:no-prefix}neighbor {} next-hop-self force', ['true', 'false']), + ('prefix_list_in', '{no:no-prefix}neighbor {} prefix-list {} in'), + ('prefix_list_out', '{no:no-prefix}neighbor {} prefix-list {} out'), + (['remove_private_as_enabled', + '++remove_private_as_all', + '+replace_private_as'], '{no:no-prefix}neighbor {} remove-private-AS {:rm-as-all} {:rm-as-repl}', hdl_rm_priv_as, ['true', 'false']), + ('cap_orf', '{no:no-prefix}neighbor {} capability orf prefix-list {}', hdl_capa_orf_pfxlist), + ('route_server_client', '{no:no-prefix}neighbor {} route-server-client', ['true', 'false']), + ] + + route_map_key_map = [('match_interface', '{no:no-prefix}match interface {}'), + ('match_prefix_set|ipv4', '{no:no-prefix}match ip address prefix-list {}'), + ('match_prefix_set|ipv6', '{no:no-prefix}match ipv6 address prefix-list {}'), + ('match_neighbor', '[bgpd]{no:no-prefix}match peer {:peer-ip}'), + ('match_tag', '{no:no-prefix}match tag {}'), + ('match_protocol', '[zebra]{no:no-prefix}match source-protocol {:src-proto}'), + ('match_next_hop_set|ipv4', '{no:no-prefix}match ip next-hop prefix-list {}'), + ('match_next_hop_set|ipv6', '{no:no-prefix}match ip next-hop prefix-list {}'), #match ipv6 next-hop prefix-list not suppported by frr + ('match_med', '{no:no-prefix}match metric {}'), + ('match_origin', '[bgpd]{no:no-prefix}match origin {:tolower}'), + ('match_local_pref', '[bgpd]{no:no-prefix}match local-preference {}'), + ('match_community', '[bgpd]{no:no-prefix}match community {}'), + ('match_ext_community', '[bgpd]{no:no-prefix}match extcommunity {}'), + ('match_as_path', '[bgpd]{no:no-prefix}match as-path {}'), + ('match_src_vrf', '[bgpd]{no:no-prefix}match source-vrf {}'), + ('call_route_map', '{no:no-prefix}call {:enable-only}'), + ('set_origin', '[bgpd]{no:no-prefix}set origin {:tolower}'), + ('set_local_pref', '[bgpd]{no:no-prefix}set local-preference {}'), + ('set_next_hop', '{no:no-prefix}set ip next-hop {}'), + ('set_ipv6_next_hop_global', '[bgpd]{no:no-prefix}set ipv6 next-hop global {}'), + ('set_ipv6_next_hop_prefer_global', '[bgpd]{no:no-prefix}set ipv6 next-hop prefer-global', ['true', 'false']), + (['set_metric_action', '+set_metric', '+set_med'], '{}set metric {} ', handle_rmap_set_metric), + ('set_med', '{no:no-prefix}set metric {}'), + (('set_asn', '+set_repeat_asn'), '[bgpd]{no:no-prefix}set as-path prepend {:repeat}', hdl_set_asn), + ('set_asn_list', '[bgpd]{no:no-prefix}set as-path prepend {:asn_list}', hdl_set_asn_list), + ('set_community_inline', '[bgpd]{no:no-prefix}set community {}'), + ('set_community_ref', '[bgpd]{no:no-prefix}set community {:com-ref}'), + ('set_ext_community_inline', '[bgpd]{no:no-prefix}set extcommunity {:ext-com-list}', hdl_set_extcomm, True), + ('set_ext_community_ref', '[bgpd]{no:no-prefix}set extcommunity {:ext-com-ref}', hdl_set_extcomm, False) + ] + + bfd_peer_shop_key_map = [('enabled', '{no:no-prefix}shutdown', ['false', 'true']), + ('desired-minimum-tx-interval', '{no:no-prefix}transmit-interval {}'), + ('required-minimum-receive', '{no:no-prefix}receive-interval {}'), + ('desired-minimum-echo-receive', '{no:no-prefix}echo-interval {}'), + ('detection-multiplier', '{no:no-prefix}detect-multiplier {}'), + ('echo-active', '{no:no-prefix}echo-mode', ['true', 'false']) + ] + + bfd_peer_mhop_key_map = [('enabled', '{no:no-prefix}shutdown', ['false', 'true']), + ('desired-minimum-tx-interval', '{no:no-prefix}transmit-interval {}'), + ('required-minimum-receive', '{no:no-prefix}receive-interval {}'), + ('detection-multiplier', '{no:no-prefix}detect-multiplier {}'), + ] + + listen_prefix_key_map = [('peer_group', '{no:no-prefix}bgp listen range {} peer-group {}')] + + community_set_key_map = [(('set_type', 'match_action', 'community_member'), '{no:no-prefix}bgp community-list {}', hdl_com_set, False)] + extcommunity_set_key_map = [(('set_type', 'match_action', 'community_member'), '{no:no-prefix}bgp extcommunity-list {}', hdl_com_set, True)] + + aspath_set_key_map = [('as_path_set_member', '{no:no-prefix}bgp as-path access-list {}', hdl_aspath_set)] + + route_redist_key_map = [(['protocol', '++metric', '+route_map'], + '{no:no-prefix}redistribute {} {:redist-metric} {:redist-route-map}', hdl_route_redist_set)] + + af_aggregate_key_map = [(['ip_prefix', '++as_set', '++summary_only', '+policy'], + '{no:no-prefix}aggregate-address {2} {3:aggr-as-set} {4:aggr-summary-only} {5:aggr-policy}', hdl_af_aggregate)] + + af_network_key_map = [(['ip_prefix', '++policy', '+backdoor'], '{no:no-prefix}network {2} {3:network-policy} {4:network-backdoor}')] + + global_evpn_vni_key_map = [('advertise-default-gw', '{no:no-prefix}advertise-default-gw', ['true','false']), + ('route-distinguisher', '{no:no-prefix}rd {}'), + ('import-rts', '{no:no-prefix}route-target import {}', hdl_import_list), + ('export-rts', '{no:no-prefix}route-target export {}', hdl_export_list)] + + ospfv2_global_key_map = [('enable', '{no:no-prefix}'), + ('auto-cost-reference-bandwidth', '{no:no-prefix}auto-cost reference-bandwidth {}'), + ('ospf-rfc1583-compatible', '{no:no-prefix}compatible rfc1583', ['true', 'false']), + ('max-metric-administrative', '{no:no-prefix}max-metric router-lsa administrative', ['true', 'false']), + ('max-metric-on-shutdown', '{no:no-prefix}max-metric router-lsa on-shutdown {}'), + ('max-metric-on-startup', '{no:no-prefix}max-metric router-lsa on-startup {}'), + ('router-id', '{no:no-prefix}ospf router-id {}'), + ('abr-type', '{}ospf abr-type {:abrtype}', handle_ospf_abrtype), + ('write-multiplier', '{no:no-prefix}write-multiplier {}'), + ('passive-interface-default', '{no:no-prefix}passive-interface default', ['true', 'false']), + ('lsa-refresh-timer', '{no:no-prefix}refresh timer {}'), + ('lsa-min-arrival-timer', '{no:no-prefix}timers lsa min-arrival {}'), + ('lsa-min-interval-timer', '{no:no-prefix}timers throttle lsa all {}'), + (['spf-initial-delay', 'spf-maximum-delay', 'spf-throttle-delay'], '{no:no-prefix}timers throttle spf {} {} {}'), + ('log-adjacency-changes', '{}log-adjacency-changes {}', hdl_ospf_log), + ('default-metric', '{no:no-prefix}default-metric {}'), + ('distance-all', '{no:no-prefix}distance {}'), + ('distance-external', '{no:no-prefix}distance ospf external {}'), + ('distance-inter-area', '{no:no-prefix}distance ospf inter-area {}'), + ('distance-intra-area', '{no:no-prefix}distance ospf intra-area {}')] + + ospfv2_area_key_map = [('stub', '{no:no-prefix}area {} stub'), + ('stub-no-summary', '{no:no-prefix}area {} stub no-summary'), + ('import-list', '{no:no-prefix}area {} import-list {}'), + ('export-list', '{no:no-prefix}area {} export-list {}'), + ('filter-list-in', '{no:no-prefix}area {} filter-list prefix {} in'), + ('filter-list-out', '{no:no-prefix}area {} filter-list prefix {} out'), + ('authentication', '{}area {} authentication {}', handle_ospf_area_auth), + ('stub-default-cost', '{no:no-prefix}area {} default-cost {}'), + ('shortcut', '{}area {} shortcut {}', handle_ospf_area_shortcut)] + + ospfv2_area_vlink_key_map = [('enable', '{no:no-prefix}area {} virtual-link {}'), + ('dead-interval', '{no:no-prefix}area {} virtual-link {} dead-interval {}'), + ('hello-interval', '{no:no-prefix}area {} virtual-link {} hello-interval {}'), + ('retransmission-interval', '{no:no-prefix}area {} virtual-link {} retransmit-interval {}'), + ('transmit-delay', '{no:no-prefix}area {} virtual-link {} transmit-delay {}'), + ('authentication-type', '{}area {} virtual-link {} authentication {}', handle_ospf_area_vlink_auth), + ('authentication-key', '{no:no-prefix}area {} virtual-link {} authentication-key {}'), + (['authentication-key-id', 'authentication-md5-key'], '{no:no-prefix}area {} virtual-link {} authentication message-digest message-digest-key {} md5 {}')] + + ospfv2_area_range_key_map =[('advertise', '{} area {} range {} {}', handle_ospf_area_range_advt), + ('metric', '{no:no-prefix} area {} range {} cost {}'), + ('substitue-prefix', '{no:no-prefix} area {} range {} substitute {}')] + + ospfv2_distribution_key_map = [('route-map|BGP|IMPORT', '{no:no-prefix}distribute-list {} out bgp'), + ('route-map|STATIC|IMPORT', '{no:no-prefix}distribute-list {} out static')] + + ospfv2_interface_key_map = [ + ('area-id', '{}ip ospf area {} {}', handle_ospf_if_common), + ('authentication-type', '{}ip ospf authentication {} {}', handle_ospf_if_authtype), + ('authentication-key', '{}ip ospf authentication-key {} {}', handle_ospf_if_common), + ('bfd-enable', '{no:no-prefix}ip ospf bfd ', ['true', 'false']), + ('metric', '{}ip ospf cost {} {}', handle_ospf_if_common), + ('dead-interval', '{}ip ospf dead-interval {} {}', handle_ospf_if_common), + ('hello-multiplier', '{}ip ospf dead-interval minimal hello-multiplier {} {}', handle_ospf_if_common), + ('hello-interval', '{}ip ospf hello-interval {} {}', handle_ospf_if_common), + (['authentication-key-id', '+authentication-md5-key'], '{}ip ospf message-digest-key {} md5 {} {}', handle_ospf_if_md5key), + ('mtu-ignore', '{}ip ospf mtu-ignore {}', handle_ospf_if_mtu_ignore), + ('network-type', '{}ip ospf network {}', handle_ospf_if_nwtype), + ('priority', '{}ip ospf priority {} {}', handle_ospf_if_common), + ('retransmission-interval', '{}ip ospf retransmit-interval {} {}', handle_ospf_if_common), + ('transmit-delay', '{}ip ospf transmit-delay {} {}', handle_ospf_if_common), + ] + static_route_map = [(['ip_prefix|ipv4', '++blackhole', '++nexthop', '++ifname', '++track', '++tag', '++distance', '++nexthop-vrf'], + '{no:no-prefix}ip route {} {:blackhole} {} {} {:track} {:nh-tag} {} {:nh-vrf}', hdl_static_route, socket.AF_INET), + (['ip_prefix|ipv6', '++blackhole', '++nexthop', '++ifname', '++track', '++tag', '++distance', '++nexthop-vrf'], + '{no:no-prefix}ipv6 route {} {:blackhole} {} {} {:track} {:nh-tag} {} {:nh-vrf} ', hdl_static_route, socket.AF_INET6)] + pim_interface_key_map = [('mode', '{no:no-prefix}ip pim', ['sm','']), + ('dr-priority', '{no:no-prefix}ip pim drpriority {}'), + ('hello-interval', '{no:no-prefix}ip pim hello {:pim_hello_parms}', + hdl_set_pim_hello_parms), + ('bfd-enabled', '{no:no-prefix}ip pim bfd', ['true', 'false']), + ] + pim_global_key_map = [('join-prune-interval', '{no:no-prefix}ip pim join-prune-interval {}'), + ('keep-alive-timer', '{no:no-prefix}ip pim keep-alive-timer {}'), + ('ssm-ranges', '{no:no-prefix}ip pim ssm prefix-list {}'), + ('ecmp-enabled', '{no:no-prefix}ip pim ecmp', ['true', 'false']), + ('ecmp-rebalance-enabled', '{no:no-prefix}ip pim ecmp rebalance',['true', 'false']), + ] + + igmp_mcast_grp_key_map =[('enable', '{no:no-prefix}ip igmp join {} {}'), + ] + + igmp_interface_config_key_map = [ + ('enabled', 'ip igmp {}', handle_igmp_if_enable), + ('version', '{no:no-prefix}ip igmp version {}'), + ('query-interval', 'ip igmp query-interval {}', handle_igmp_if_common), + ('query-max-response-time', 'ip igmp query-max-response-time {}', handle_igmp_if_common), + ('last-member-query-count', 'ip igmp last-member-query-count {}', handle_igmp_if_common), + ('last-member-query-interval', 'ip igmp last-member-query-interval {}', handle_igmp_if_common), + ] + ip_sla_key_map = [ + ('sla_id', '{no:no-prefix}ip sla {}'), + ('frequency', 'frequency {}', handle_ip_sla_common), + ('threshold', 'threshold {}', handle_ip_sla_common), + ('timeout', 'timeout {}', handle_ip_sla_common), + ('tcp_source_port', 'source-port {}', handle_ip_sla_common), + ('tcp_source_ip', 'source-address {}', handle_ip_sla_common), + ('tcp_dst_ip', 'tcp-connect {} port {}', handle_ip_sla_tcp_connect), + ('tcp_vrf', 'source-vrf {}', handle_ip_sla_common), + ('tcp_dst_port', 'tcp-connect {} port {}', handle_ip_sla_tcp_connect), + ('tcp_source_interface', 'source-interface {}', handle_ip_sla_common), + ('tcp_ttl', 'ttl {}', handle_ip_sla_common), + ('tcp_tos', 'tos {}', handle_ip_sla_common), + ('icmp_source_interface', 'source-interface {}', handle_ip_sla_common), + ('icmp_source_ip', 'source-address {}', handle_ip_sla_common), + ('icmp_dst_ip', 'icmp-echo {}', handle_ip_sla_icmp_echo), + ('icmp_vrf', 'source-vrf {}', handle_ip_sla_common), + ('icmp_size', 'request-data-size {}', handle_ip_sla_common), + ('icmo_ttl', 'ttl {}', handle_ip_sla_common), + ('icmp_tos', 'tos {}', handle_ip_sla_common), + ] + + + tbl_to_key_map = {'BGP_GLOBALS': global_key_map, + 'BGP_GLOBALS_AF': global_af_key_map, + 'BGP_GLOBALS_LISTEN_PREFIX': listen_prefix_key_map, + 'BGP_NEIGHBOR': cmn_key_map[0:2] + nbr_key_map + cmn_key_map[2:], + 'BGP_PEER_GROUP': cmn_key_map, + 'BGP_NEIGHBOR_AF': nbr_af_key_map, + 'BGP_PEER_GROUP_AF': nbr_af_key_map, + 'ROUTE_MAP': route_map_key_map, + 'COMMUNITY_SET': community_set_key_map, + 'EXTENDED_COMMUNITY_SET': extcommunity_set_key_map, + 'AS_PATH_SET': aspath_set_key_map, + 'ROUTE_REDISTRIBUTE': route_redist_key_map, + 'BGP_GLOBALS_AF_AGGREGATE_ADDR': af_aggregate_key_map, + 'BGP_GLOBALS_AF_NETWORK': af_network_key_map, + 'BGP_GLOBALS_EVPN_VNI': global_evpn_vni_key_map, + 'BFD_PEER_SINGLE_HOP': bfd_peer_shop_key_map, + 'BFD_PEER_MULTI_HOP': bfd_peer_mhop_key_map, + 'IP_SLA': ip_sla_key_map, + 'OSPFV2_ROUTER': ospfv2_global_key_map, + 'OSPFV2_ROUTER_AREA': ospfv2_area_key_map, + 'OSPFV2_ROUTER_AREA_VIRTUAL_LINK':ospfv2_area_vlink_key_map, + 'OSPFV2_ROUTER_AREA_POLICY_ADDRESS_RANGE':ospfv2_area_range_key_map, + 'OSPFV2_INTERFACE': ospfv2_interface_key_map, + 'STATIC_ROUTE': static_route_map, + 'PIM_GLOBALS': pim_global_key_map, + 'PIM_INTERFACE': pim_interface_key_map, + 'IGMP_INTERFACE': igmp_mcast_grp_key_map, + 'IGMP_INTERFACE_QUERY': igmp_interface_config_key_map + } + + vrf_tables = {'BGP_GLOBALS', 'BGP_GLOBALS_AF', + 'BGP_NEIGHBOR', 'BGP_PEER_GROUP', 'BGP_NEIGHBOR_AF', 'BGP_PEER_GROUP_AF', + 'BGP_GLOBALS_LISTEN_PREFIX', 'ROUTE_REDISTRIBUTE', + 'BGP_GLOBALS_AF_AGGREGATE_ADDR', 'BGP_GLOBALS_AF_NETWORK', + 'BGP_GLOBALS_EVPN_RT', 'BGP_GLOBALS_EVPN_VNI', 'BGP_GLOBALS_EVPN_VNI_RT'} + + @staticmethod + def __peer_is_ip(peer): + try: + socket.inet_pton(socket.AF_INET, peer) + return True + except socket.error: + pass + try: + socket.inet_pton(socket.AF_INET6, peer) + return True + except socket.error: + pass + return False + + def __init__(self): + self.config_db = ExtConfigDBConnector({'STATIC_ROUTE': {'nexthop', 'ifname', 'distance', 'nexthop-vrf', 'blackhole', 'track'}}) + try: + self.config_db.connect() + except Exception as e: + syslog.syslog(syslog.LOG_ERR, '[bgp cfgd] Failed connecting to config DB with exception:' + str(e)) + db_entry = self.config_db.get_entry('DEVICE_METADATA', 'localhost') + if 'bgp_asn' in db_entry: + self.metadata_asn = db_entry['bgp_asn'] + else: + self.metadata_asn = None + if 'docker_routing_config_mode' in db_entry: + self.config_mode = db_entry['docker_routing_config_mode'] + else: + self.config_mode = "separated" + # VRF ==> local_as + self.bgp_asn = {} + # VRF ==> confederation peer list + self.bgp_confed_peers = {} + glb_table = self.config_db.get_table('BGP_GLOBALS') + for vrf, entry in glb_table.items(): + if 'local_asn' in entry: + self.bgp_asn[vrf] = entry['local_asn'] + syslog.syslog(syslog.LOG_DEBUG, 'Init Config DB Data: VRF %s Local_ASN %s' % (vrf, self.bgp_asn[vrf])) + if 'confed_peers' in entry: + self.bgp_confed_peers[vrf] = set(entry['confed_peers']) + # VRF ==> grp_name ==> peer_group + self.bgp_peer_group = {} + # VRF ==> set of interface neighbor + self.bgp_intf_nbr = {} + nbr_table = self.config_db.get_table('BGP_NEIGHBOR') + pg_table = self.config_db.get_table('BGP_PEER_GROUP') + for key, entry in pg_table.items(): + vrf, pg = key + self.bgp_peer_group.setdefault(vrf, {})[pg] = BGPPeerGroup(vrf) + syslog.syslog(syslog.LOG_DEBUG, 'Init Config DB Data: VRF %s Peer_Group %s' % (vrf, pg)) + for key, entry in nbr_table.items(): + if len(key) != 2: + continue + vrf, peer = key + if 'peer_group_name' in entry: + pg_name = entry['peer_group_name'] + if vrf in self.bgp_peer_group and pg_name in self.bgp_peer_group[vrf]: + self.bgp_peer_group[vrf][pg_name].ref_nbrs.add(peer) + syslog.syslog(syslog.LOG_DEBUG, 'Init Config DB Data: VRF %s Neighbor %s Peer_Group %s' % + (vrf, peer, pg_name)) + if not self.__peer_is_ip(peer): + self.bgp_intf_nbr.setdefault(vrf, set()).add(peer) + # map_name ==> seq_no ==> operation + self.route_map = {} + rtmap_table = self.config_db.get_table('ROUTE_MAP') + for key, entry in rtmap_table.items(): + rtmap_name, seq_no = key + syslog.syslog(syslog.LOG_DEBUG, 'Init Config DB Data: Route_Map %s Seq_NO %s' % (rtmap_name, seq_no)) + if 'route_operation' in entry: + self.route_map.setdefault(rtmap_name, {})[seq_no] = entry['route_operation'] + + self.comm_set_list = {} + comm_table = self.config_db.get_table('COMMUNITY_SET') + for key, entry in comm_table.items(): + syslog.syslog(syslog.LOG_DEBUG, 'Init Config DB Data: Community %s' % key) + self.comm_set_list[key] = CommunityList(key, False) + for k, v in entry.items(): + self.comm_set_list[key].db_data_to_attr(k, v) + self.extcomm_set_list = {} + extcomm_table = self.config_db.get_table('EXTENDED_COMMUNITY_SET') + for key, entry in extcomm_table.items(): + syslog.syslog(syslog.LOG_DEBUG, 'Init Config DB Data: Extended_Community %s' % key) + self.extcomm_set_list[key] = CommunityList(key, True) + for k, v in entry.items(): + self.extcomm_set_list[key].db_data_to_attr(k, v) + self.prefix_set_list = {} + pfx_set_table = self.config_db.get_table('PREFIX_SET') + for key, entry in pfx_set_table.items(): + if 'mode' in entry: + syslog.syslog(syslog.LOG_DEBUG, 'Init Config DB Data: Prefix_Set %s mode %s' % (key, entry['mode'])) + self.prefix_set_list[key] = MatchPrefixList(entry['mode'].lower()) + pfx_table = self.config_db.get_table('PREFIX') + for key, entry in pfx_table.items(): + pfx_set_name, ip_pfx, len_range = key + syslog.syslog(syslog.LOG_DEBUG, 'Init Config DB Data: Prefix %s range %s of set %s' % (ip_pfx, len_range, pfx_set_name)) + if len_range == 'exact': + len_range = None + if pfx_set_name in self.prefix_set_list and 'action' in entry: + try: + self.prefix_set_list[pfx_set_name].add_prefix(ip_pfx, len_range, entry['action']) + except ValueError: + pass + self.as_path_set_list = {} + aspath_table = self.config_db.get_table('AS_PATH_SET') + for key, entry in aspath_table.items(): + if 'as_path_set_member' in entry: + syslog.syslog(syslog.LOG_DEBUG, 'Init Config DB Data: AS_Path_Set %s member %s' % (key, entry['as_path_set_member'])) + self.as_path_set_list[key] = entry['as_path_set_member'][:] + self.tag_set_list = {} + + self.af_aggr_list = {} + af_aggr_table = self.config_db.get_table('BGP_GLOBALS_AF_AGGREGATE_ADDR') + for key, entry in af_aggr_table.items(): + vrf, af_type, ip_pfx = key + af, _ = af_type.lower().split('_') + norm_ip_pfx = MatchPrefix.normalize_ip_prefix((socket.AF_INET if af == 'ipv4' else socket.AF_INET6), ip_pfx) + if norm_ip_pfx is not None: + syslog.syslog(syslog.LOG_DEBUG, 'Init Config DB Data: AF Aggregate Prefix %s of vrf %s AF %s' % (norm_ip_pfx, vrf, af)) + aggr_obj = AggregateAddr() + for k, v in entry.items(): + if v == 'true': + setattr(aggr_obj, k, True) + self.af_aggr_list.setdefault(vrf, {})[norm_ip_pfx] = aggr_obj + + self.vrf_vni_map = {} + vrf_table = self.config_db.get_table('VRF') + for key, entry in vrf_table.items(): + if 'vni' in entry: + self.vrf_vni_map[key] = entry['vni'] + + # VRF ==> ip_prefix ==> nexthop list + self.static_route_list = {} + sroute_table = self.config_db.get_table('STATIC_ROUTE') + get_list = lambda v: v.split(',') if v is not None else None + for key, entry in sroute_table.items(): + if type(key) is tuple and len(key) == 2: + vrf, ip_prefix = key + else: + vrf = self.DEFAULT_VRF + ip_prefix = key + af, ip_prefix = IpNextHopSet.get_af_norm_prefix(ip_prefix) + nh_attr = lambda k: get_list(entry.get(k, None)) + self.static_route_list.setdefault(vrf, {})[ip_prefix] = IpNextHopSet(af, + nh_attr('blackhole'), nh_attr('nexthop'),nh_attr('track'), + nh_attr('ifname'), nh_attr('tag'), nh_attr('distance'), + nh_attr('nexthop-vrf')) + + self.table_handler_list = [ + ('VRF', self.vrf_handler), + ('DEVICE_METADATA', self.metadata_handler), + ('BGP_GLOBALS', self.bgp_global_handler), + ('BGP_GLOBALS_AF', self.bgp_af_handler), + ('PREFIX_SET', self.bgp_table_handler_common), + ('PREFIX', self.bgp_table_handler_common), + ('COMMUNITY_SET', self.comm_set_handler), + ('EXTENDED_COMMUNITY_SET', self.comm_set_handler), + ('ROUTE_MAP', self.bgp_table_handler_common), + ('BGP_PEER_GROUP', self.bgp_neighbor_handler), + ('BGP_NEIGHBOR', self.bgp_neighbor_handler), + ('BGP_PEER_GROUP_AF', self.bgp_table_handler_common), + ('BGP_NEIGHBOR_AF', self.bgp_table_handler_common), + ('BGP_GLOBALS_LISTEN_PREFIX', self.bgp_table_handler_common), + ('BGP_GLOBALS_EVPN_VNI', self.bgp_table_handler_common), + ('BGP_GLOBALS_EVPN_RT', self.bgp_table_handler_common), + ('BGP_GLOBALS_EVPN_VNI_RT', self.bgp_table_handler_common), + ('BFD_PEER', self.bfd_handler), + ('NEIGHBOR_SET', self.bgp_table_handler_common), + ('NEXTHOP_SET', self.bgp_table_handler_common), + ('TAG_SET', self.bgp_table_handler_common), + ('AS_PATH_SET', self.bgp_table_handler_common), + ('ROUTE_REDISTRIBUTE', self.bgp_table_handler_common), + ('BGP_GLOBALS_AF_AGGREGATE_ADDR', self.bgp_table_handler_common), + ('BGP_GLOBALS_AF_NETWORK', self.bgp_table_handler_common), + ('BFD_PEER_SINGLE_HOP', self.bgp_table_handler_common), + ('BFD_PEER_MULTI_HOP', self.bgp_table_handler_common), + ('IP_SLA', self.bgp_table_handler_common), + ('OSPFV2_ROUTER', self.bgp_table_handler_common), + ('OSPFV2_ROUTER_AREA', self.bgp_table_handler_common), + ('OSPFV2_ROUTER_AREA_VIRTUAL_LINK', self.bgp_table_handler_common), + ('OSPFV2_ROUTER_AREA_NETWORK', self.bgp_table_handler_common), + ('OSPFV2_ROUTER_AREA_POLICY_ADDRESS_RANGE', self.bgp_table_handler_common), + ('OSPFV2_ROUTER_DISTRIBUTE_ROUTE', self.bgp_table_handler_common), + ('OSPFV2_INTERFACE', self.bgp_table_handler_common), + ('OSPFV2_ROUTER_PASSIVE_INTERFACE', self.bgp_table_handler_common), + ('STATIC_ROUTE', self.bgp_table_handler_common), + ('PIM_GLOBALS', self.bgp_table_handler_common), + ('PIM_INTERFACE', self.bgp_table_handler_common), + ('IGMP_INTERFACE', self.bgp_table_handler_common), + ('IGMP_INTERFACE_QUERY', self.bgp_table_handler_common) + ] + self.bgp_message = queue.Queue(0) + self.table_data_cache = self.config_db.get_table_data([tbl for tbl, _ in self.table_handler_list]) + syslog.syslog(syslog.LOG_DEBUG, 'Init Cached DB data') + for key, entry in self.table_data_cache.items(): + syslog.syslog(syslog.LOG_DEBUG, ' %-20s : %s' % (key, entry)) + if self.config_mode == "unified": + for table, _ in self.table_handler_list: + table_list = self.config_db.get_table(table) + for key, data in table_list.items(): + syslog.syslog(syslog.LOG_DEBUG, 'config replay for table {} key {}'.format(table, key)) + upd_data = {} + for upd_key, upd_val in data.items(): + upd_data[upd_key] = CachedDataWithOp(upd_val, CachedDataWithOp.OP_ADD) + self.bgp_message.put((self.config_db.serialize_key(key), False, table, upd_data)) + upd_data_list = [] + self.__update_bgp(upd_data_list) + for table1, key1, data1 in upd_data_list: + table_key = ExtConfigDBConnector.get_table_key(table1, key1) + self.__update_cache_data(table_key, data1) + + def subscribe_all(self): + for table, hdlr in self.table_handler_list: + self.config_db.subscribe(table, hdlr) + + @staticmethod + def __run_command(table, command, daemons = None): + return g_run_command(table, command, True, daemons) + + def metadata_handler(self, table, key, data): + if key != 'localhost': + syslog.syslog(syslog.LOG_DEBUG, 'not localhost data update') + return + if data is None or 'bgp_asn' not in data: + self.metadata_asn = None + else: + self.metadata_asn = data['bgp_asn'] + + def bfd_handler(self, table, key, data): + syslog.syslog(syslog.LOG_INFO, '[bgp cfgd](bfd) value for {} changed to {}'.format(key, data)) + #get frr bfd session key + key_params = key.split('|') + cmd = 'peer {}'.format(key_params[0]) + if len(key_params) == 4 and key_params[3] == 'multihop': + cmd = cmd + ' multihop ' + if key_params[1] != 'null': + cmd = cmd + ' local-address ' + key_params[1] + if key_params[2] != 'null': + cmd = cmd + ' interface ' + key_params[2] + if not data: + #BFD peer is deleted + command = "vtysh -c 'configure terminal' -c 'bfd' -c 'no {}'".format(cmd) + self.__run_command(table, command) + else: + #create/update case + command = "vtysh -c 'configure terminal' -c 'bfd' -c '{}'".format(cmd) + for param in data: + if param == 'transmit_interval': + command = command + " -c 'transmit-interval {}'".format(data[param]) + elif param == 'receive_interval': + command = command + " -c 'receive-interval {}'".format(data[param]) + elif param == 'multiplier': + command = command + " -c 'detect-multiplier {}'".format(data[param]) + elif param == 'echo_mode' and data[param] == 'true': + command = command + " -c 'echo-mode'" + elif param == 'echo_interval': + command = command + " -c 'echo-interval {}'".format(data[param]) + elif param == 'label': + command = command + " -c 'label {}'".format(data[param]) + elif param == 'admin_status' and data[param] == 'up': + command = command + " -c 'no shutdown'" + elif param == 'admin_status' and data[param] == 'down': + command = command + " -c 'shutdown'" + self.__run_command(table, command) + + def vrf_handler(self, table, key, data): + syslog.syslog(syslog.LOG_INFO, '[bgp cfgd](vrf) value for {} changed to {}'.format(key, data)) + #get vrf key + key_params = key.split('|') + cmd = 'vrf {}'.format(key_params[0]) + if not data: + #VRF is deleted + command = "vtysh -c 'configure terminal' -c '{}'".format(cmd) + if key_params[0] in self.vrf_vni_map: + command = command + " -c 'no vni {}'".format(self.vrf_vni_map[key_params[0]]) + del self.vrf_vni_map[key_params[0]] + self.__run_command(table, command) + else: + #create/update case + command = "vtysh -c 'configure terminal' -c '{}'".format(cmd) + positive_execute = False + for param in data: + if param == 'vni': + if data[param] != '0': + command = command + " -c 'vni {}'".format(data[param]) + self.vrf_vni_map[key_params[0]] = data[param] + positive_execute = True + elif key_params[0] in self.vrf_vni_map: + command = command + " -c 'no vni {}'".format(self.vrf_vni_map[key_params[0]]) + del self.vrf_vni_map[key_params[0]] + positive_execute = True + if positive_execute == True: + self.__run_command(table, command) + + def __get_vrf_asn(self, vrf): + if vrf in self.bgp_asn: + return self.bgp_asn[vrf] + if vrf == self.DEFAULT_VRF and self.metadata_asn is not None: + return self.metadata_asn + return None + + def __delete_vrf_asn(self, vrf, table, data): + if vrf != self.DEFAULT_VRF and vrf not in self.bgp_asn: + syslog.syslog(syslog.LOG_ERR, 'non-default VRF {} was not configured'.format(vrf)) + return False + local_asn = self.__get_vrf_asn(vrf) + if local_asn is None: + syslog.syslog(syslog.LOG_ERR, 'failed to get local ASN of VRF {} for delete'.format(vrf)) + return False + command = "vtysh -c 'configure terminal' -c 'no router bgp {}".format(local_asn) + if vrf != self.DEFAULT_VRF: + command += " vrf {}'".format(vrf) + else: + command += "'" + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete local_asn for VRF %s' % vrf) + return False + if vrf in self.bgp_asn: + del(self.bgp_asn[vrf]) + for dkey, dval in data.items(): + # force delete all VRF instance attributes in cache + dval.status = CachedDataWithOp.STAT_SUCC + dval.op = CachedDataWithOp.OP_DELETE + return True + + def __cleanup_nbr_cache(self, vrf, nbr): + nbr_key = ExtConfigDBConnector.get_table_key('BGP_NEIGHBOR', + self.config_db.serialize_key((vrf, nbr))) + self.table_data_cache.pop(nbr_key, None) + for af in ['ipv4', 'ipv6']: + nbr_af_key = ExtConfigDBConnector.get_table_key('BGP_NEIGHBOR_AF', + self.config_db.serialize_key((vrf, nbr, af + '_unicast'))) + self.table_data_cache.pop(nbr_af_key, None) + + def __delete_vrf_neighbor(self, vrf, peer, data, is_peer_grp): + if is_peer_grp: + if vrf in self.bgp_peer_group and peer in self.bgp_peer_group[vrf]: + del(self.bgp_peer_group[vrf][peer]) + else: + if vrf in self.bgp_peer_group: + for _, peer_grp in self.bgp_peer_group[vrf].items(): + if peer in peer_grp.ref_nbrs: + peer_grp.ref_nbrs.remove(peer) + if not self.__peer_is_ip(peer) and vrf in self.bgp_intf_nbr and peer in self.bgp_intf_nbr[vrf]: + self.bgp_intf_nbr[vrf].remove(peer) + self.__cleanup_nbr_cache(vrf, peer) + for dkey, dval in data.items(): + # bypass cache update because cache entry was removed + dval.status = CachedDataWithOp.STAT_SUCC + dval.op = CachedDataWithOp.OP_NONE + + def __delete_pg_neighbors(self, vrf, pg_name): + syslog.syslog(syslog.LOG_DEBUG, + 'delete all associated neighbors of peer group %s of vrf %s from cache' % (pg_name, vrf)) + if vrf in self.bgp_peer_group and pg_name in self.bgp_peer_group[vrf]: + peer_grp = self.bgp_peer_group[vrf][pg_name] + for nbr in peer_grp.ref_nbrs: + if vrf in self.bgp_intf_nbr and nbr in self.bgp_intf_nbr[vrf]: + self.bgp_intf_nbr[vrf].remove(nbr) + self.__cleanup_nbr_cache(vrf, nbr) + peer_grp.ref_nbrs.clear() + + def __delete_route_map(self, map_name, seq_no, data): + if map_name in self.route_map and seq_no in self.route_map[map_name]: + del(self.route_map[map_name][seq_no]) + for dkey, dval in data.items(): + # force delete all neighbor attributes in cache + dval.status = CachedDataWithOp.STAT_SUCC + dval.op = CachedDataWithOp.OP_DELETE + + @staticmethod + def __vrf_based_table(table_name): + return table_name in BGPConfigDaemon.vrf_tables + + @staticmethod + def get_prefix_set_name(orig_name, table_name): + new_name = orig_name + if table_name == 'NEIGHBOR_SET': + new_name += '_neighbor' + elif table_name == 'NEXTHOP_SET': + new_name += '_nexthop' + return new_name + + def __apply_dep_vrf_table(self, vrf, table_name, *table_key, **extra_args): + if len(table_key) > 0: + new_key = (vrf,) + table_key + entry_list = {new_key: self.config_db.get_entry(table_name, new_key)} + else: + entry_list = self.config_db.get_table(table_name) + match_fn = extra_args.get('match', None) + for key, data in entry_list.items(): + if data is None or len(key) == 0 or key[0] != vrf: + continue + if match_fn is not None and not match_fn(data): + continue + syslog.syslog(syslog.LOG_DEBUG, 'attr re-apply for vrf {} table {} key {} data {}'.format(vrf, table_name, key, data)) + upd_data = {} + for upd_key, upd_val in data.items(): + upd_data[upd_key] = CachedDataWithOp(upd_val, CachedDataWithOp.OP_ADD) + self.bgp_message.put((self.config_db.serialize_key(key), False, table_name, upd_data)) + + @staticmethod + def __nbr_impl_action(data, peer, is_pg): + if is_pg: + chk_attrs = ['asn'] + elif BGPConfigDaemon.__peer_is_ip(peer): + chk_attrs = ['asn', 'peer_group_name'] + else: + chk_attrs = ['peer_group_name'] + for attr in chk_attrs: + val = data.get(attr, None) + if val is not None: + if val.op == CachedDataWithOp.OP_ADD: + return 'apply' + elif val.op == CachedDataWithOp.OP_DELETE: + return 'delete' + return None + + def __apply_config_op_success(self, data, cfg_data={}): + op_list = [ CachedDataWithOp.OP_NONE, CachedDataWithOp.OP_ADD, + CachedDataWithOp.OP_DELETE, CachedDataWithOp.OP_UPDATE ] + if len(cfg_data) == 0: + for dkey, dval in data.items(): + dval.status = CachedDataWithOp.STAT_SUCC + else : + for dkey, dval in data.items(): + if dkey in cfg_data.keys(): + if cfg_data[dkey] not in op_list : + syslog.syslog(syslog.LOG_INFO, 'Invalid op {} received'.format(cfg_data[dkey])) + continue + dval.status = CachedDataWithOp.STAT_SUCC + dval.op = cfg_data[dkey] + syslog.syslog(syslog.LOG_INFO, 'apply_config_op_success on {}.'.format(data)) + + def __apply_config_delete_success(self, data): + for dkey, dval in data.items(): + dval.status = CachedDataWithOp.STAT_SUCC + dval.op = CachedDataWithOp.OP_DELETE + + def __ospf_delete (self, data): + for dkey, dval in data.items(): + # force delete all peer attributes in cache + dval.status = CachedDataWithOp.STAT_SUCC + dval.op = CachedDataWithOp.OP_DELETE + + def __ospf_apply_config(self, data, rmapoper, metricoper, metrictypeoper, alwaysoper, acclistoper): + for dkey, dval in data.items(): + + if 'route-map' == dkey: + dval.status = CachedDataWithOp.STAT_SUCC + dval.op = rmapoper + + if 'metric' == dkey: + dval.status = CachedDataWithOp.STAT_SUCC + dval.op = metricoper + + if 'metric-type' == dkey: + dval.status = CachedDataWithOp.STAT_SUCC + dval.op = metrictypeoper + + if 'always' == dkey: + dval.status = CachedDataWithOp.STAT_SUCC + dval.op = alwaysoper + + if 'access-list' == dkey: + dval.status = CachedDataWithOp.STAT_SUCC + dval.op = acclistoper + + def __delete_bfd_peer(self, data): + for dkey, dval in data.items(): + # force delete all peer attributes in cache + dval.status = CachedDataWithOp.STAT_SUCC + dval.op = CachedDataWithOp.OP_DELETE + + def __bfd_handle_delete (self, data): + cmd_suffix = "" + if 'desired-minimum-tx-interval' in data: + dval = data['desired-minimum-tx-interval'] + cmd_suffix = "transmit-interval 300" + elif 'required-minimum-receive' in data: + dval = data['required-minimum-receive'] + cmd_suffix = "receive-interval 300" + elif 'detection-multiplier' in data: + dval = data['detection-multiplier'] + cmd_suffix = "detect-multiplier 3" + elif 'desired-minimum-echo-receive' in data: + dval = data['desired-minimum-echo-receive'] + cmd_suffix = "echo-interval 300" + if cmd_suffix != "": + return cmd_suffix, dval.op + + return cmd_suffix, None + + def __update_bgp(self, data_list): + while not self.bgp_message.empty(): + key, del_table, table, data = self.bgp_message.get() + if table == 'STATIC_ROUTE' and len(key.split('|')) == 1: + key = self.DEFAULT_VRF + '|' + key + key_list = key.split('|', 1) + if table == 'BGP_NEIGHBOR' and len(key_list) == 1: + # bypass non-compatible neighbor table + continue + data_list.append((table, key, data)) + if len(key_list) > 1: + key = key_list[1] + else: + key = None + prefix = key_list[0] + syslog.syslog(syslog.LOG_INFO, 'value for table {} prefix {} key {} changed to {}'.format(table, prefix, key, data)) + if self.__vrf_based_table(table): + vrf = prefix + local_asn = self.__get_vrf_asn(vrf) + if local_asn is None and (table != 'BGP_GLOBALS' or 'local_asn' not in data): + syslog.syslog(syslog.LOG_DEBUG, 'ignore table {} update because local_asn for VRF {} was not configured'.\ + format(table, vrf)) + continue + if table in self.tbl_to_key_map: + tbl_key = None + if table == 'BGP_NEIGHBOR_AF' or table == 'BGP_PEER_GROUP_AF' and key is not None: + _, af_ip_type = key.split('|') + tbl_key, _ = af_ip_type.lower().split('_') + tbl_key = {'admin_status': tbl_key} + elif table == 'ROUTE_MAP': + tbl_key = {} + for attr_name, table_name in {'match_prefix_set': 'PREFIX', 'match_next_hop_set': 'PREFIX'}.items(): + if attr_name in data: + pfx_set_name = self.get_prefix_set_name(data[attr_name].data, table_name) + if pfx_set_name in self.prefix_set_list: + af_mode = self.prefix_set_list[pfx_set_name].af + tbl_key[attr_name] = 'ipv4' if af_mode == socket.AF_INET else 'ipv6' + elif table == 'STATIC_ROUTE': + af_id, new_key = IpNextHopSet.get_af_norm_prefix(key) + if new_key is not None: + key = new_key + tbl_key = {'ip_prefix': ('ipv4' if af_id == socket.AF_INET else 'ipv6')} + key_map = BGPKeyMapList(self.tbl_to_key_map[table], table, tbl_key) + else: + key_map = None + if table == 'BGP_GLOBALS': + if not del_table: + if 'local_asn' in data: + dval = data['local_asn'] + if dval.op == CachedDataWithOp.OP_DELETE: + # delete local_asn will delete whole VRF instance + self.__delete_vrf_asn(vrf, table, data) + continue + prog_asn = True + if dval.op == CachedDataWithOp.OP_UPDATE: + syslog.syslog(syslog.LOG_ERR, 'local_asn could not be modified') + prog_asn = False + if dval.op == CachedDataWithOp.OP_NONE: + prog_asn = False + if prog_asn: + command = "vtysh -c 'configure terminal' -c 'router bgp {} vrf {}' -c 'no bgp default ipv4-unicast'".format(dval.data, vrf) + if self.__run_command(table, command): + syslog.syslog(syslog.LOG_DEBUG, 'set local_asn %s to VRF %s, re-apply all VRF related tables' % (dval.data, vrf)) + self.bgp_asn[vrf] = dval.data + self.__apply_dep_vrf_table(vrf, 'ROUTE_REDISTRIBUTE') + dval.status = CachedDataWithOp.STAT_SUCC + else: + syslog.syslog(syslog.LOG_ERR, 'failed to set local_asn %s to VRF %s' % (dval.data, vrf)) + else: + dval.status = CachedDataWithOp.STAT_SUCC + if 'confed_peers' in data: + self.upd_confed_peers = copy.copy(self.bgp_confed_peers.get(vrf, set())) + local_asn = self.__get_vrf_asn(vrf) + if local_asn is None: + syslog.syslog(syslog.LOG_ERR, 'local ASN for VRF %s was not configured' % vrf) + continue + cmd_prefix = ['configure terminal', 'router bgp {} vrf {}'.format(local_asn, vrf)] + if not key_map.run_command(self, table, data, cmd_prefix): + syslog.syslog(syslog.LOG_ERR, 'failed running BGP global config command') + continue + if 'confed_peers' in data: + self.bgp_confed_peers[vrf] = copy.copy(self.upd_confed_peers) + else: + self.__delete_vrf_asn(vrf, table, data) + elif table == 'BGP_GLOBALS_AF': + af, ip_type = key.lower().split('_') + #this is to temporarily make table cache key accessible to key_map handler function + self.tmp_cache_key = 'BGP_GLOBALS_AF&&{}|{}'.format(vrf, key.lower()) + syslog.syslog(syslog.LOG_INFO, 'Set address family global to {} {} cache-key to {}'.format(af, ip_type, self.tmp_cache_key)) + cmd_prefix = ['configure terminal', + 'router bgp {} vrf {}'.format(local_asn, vrf), + 'address-family {} {}'.format(af, ip_type)] + if not key_map.run_command(self, table, data, cmd_prefix): + syslog.syslog(syslog.LOG_ERR, 'failed running BGP global AF config command') + continue + self.tmp_cache_key = '' + elif table == 'BGP_GLOBALS_LISTEN_PREFIX': + syslog.syslog(syslog.LOG_INFO, 'Set BGP listen prefix {}'.format(key)) + cmd_prefix = ['configure terminal', + 'router bgp {} vrf {}'.format(local_asn, vrf)] + if not key_map.run_command(self, table, data, cmd_prefix, key): + syslog.syslog(syslog.LOG_ERR, 'failed running BGP global listen prefix config command') + continue + elif table == 'BGP_NEIGHBOR' or table == 'BGP_PEER_GROUP': + is_peer_group = table == 'BGP_PEER_GROUP' + if not del_table: + if is_peer_group: + # if peer group is not created, create it before setting other attributes + if key not in self.bgp_peer_group.setdefault(vrf, {}): + command = "vtysh -c 'configure terminal' -c 'router bgp {} vrf {}' ".format(local_asn, vrf) + command += "-c 'neighbor {} peer-group'".format(key) + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to create peer-group %s for VRF %s' % (key, vrf)) + continue + self.bgp_peer_group[vrf][key] = BGPPeerGroup(vrf) + elif not self.__peer_is_ip(key): + if key not in self.bgp_intf_nbr.setdefault(vrf, set()): + command = "vtysh -c 'configure terminal' -c 'router bgp {} vrf {}' ".format(local_asn, vrf) + command += "-c 'neighbor {} interface'".format(key) + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to create neighbor of interface %s for VRF %s' % (key, vrf)) + continue + self.bgp_intf_nbr[vrf].add(key) + bfd_val = data.get('bfd', None) + if (bfd_val is not None and (bfd_val.op == CachedDataWithOp.OP_ADD or bfd_val.op == CachedDataWithOp.OP_UPDATE) and + bfd_val.data == 'true'): + cp_chk_val = data.get('bfd_check_ctrl_plane_failure', None) + if cp_chk_val is not None and cp_chk_val.op == CachedDataWithOp.OP_NONE and cp_chk_val.data == 'true': + cp_chk_val.op = CachedDataWithOp.OP_ADD + cmd_prefix = ['configure terminal', 'router bgp {} vrf {}'.format(local_asn, vrf)] + if not key_map.run_command(self, table, data, cmd_prefix, key): + syslog.syslog(syslog.LOG_ERR, 'failed running BGP neighbor config command') + continue + if ('peer_group_name' in data and + (data['peer_group_name'].op == CachedDataWithOp.OP_ADD or + data['peer_group_name'].op == CachedDataWithOp.OP_DELETE)): + dval = data['peer_group_name'] + if vrf not in self.bgp_peer_group or dval.data not in self.bgp_peer_group[vrf]: + # should not happen because vtysh command will fail if peer_group not exists + syslog.syslog(syslog.LOG_ERR, 'invalid peer-group %s was referenced' % dval.data) + continue + peer_grp = self.bgp_peer_group[vrf][dval.data] + if dval.op == CachedDataWithOp.OP_ADD: + peer_grp.ref_nbrs.add(key) + else: + peer_grp.ref_nbrs.discard(key) + nbr_action = self.__nbr_impl_action(data, key, is_peer_group) + if nbr_action == 'delete': + if not is_peer_group and self.__peer_is_ip(key): + # delete asn or peer_group will delete all neighbor + self.__delete_vrf_neighbor(vrf, key, data, False) + elif is_peer_group: + # clear associated neighbor list in cache + self.__delete_pg_neighbors(vrf, key) + elif nbr_action == 'apply': + if is_peer_group: + syslog.syslog(syslog.LOG_DEBUG, 'apply attributes to FRR for vrf %s peer_group %s' % (vrf, key)) + match_pg = lambda data: data.get('peer_group', None) == key + self.__apply_dep_vrf_table(vrf, 'BGP_GLOBALS_LISTEN_PREFIX', match = match_pg) + match_nbr = lambda data: data.get('peer_group_name', None) == key + self.__apply_dep_vrf_table(vrf, 'BGP_NEIGHBOR', match = match_nbr) + else: + for af in ['ipv4_unicast', 'ipv6_unicast']: + syslog.syslog(syslog.LOG_DEBUG, 'apply attributes to FRR for vrf %s neighbor %s af %s' % (vrf, key, af)) + self.__apply_dep_vrf_table(vrf, 'BGP_NEIGHBOR_AF', key, af) + else: + # Neighbor is deleted + if is_peer_group: + # clear associated neighbor list in cache + self.__delete_pg_neighbors(vrf, key) + command = "vtysh -c 'configure terminal' -c 'router bgp {} vrf {}' -c 'no neighbor {}'".\ + format(local_asn, vrf, key) + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete VRF %s bgp neigbor %s' % (vrf, key)) + self.__delete_vrf_neighbor(vrf, key, data, is_peer_group) + elif table == 'BGP_NEIGHBOR_AF' or table == 'BGP_PEER_GROUP_AF': + nbr, af_type = key.split('|') + af, ip_type = af_type.lower().split('_') + syslog.syslog(syslog.LOG_INFO, 'Set address family for neighbor {} to {} {}'.format(nbr, af, ip_type)) + cmd_prefix = ['configure terminal', + 'router bgp {} vrf {}'.format(local_asn, vrf), + 'address-family {} {}'.format(af, ip_type)] + if not key_map.run_command(self, table, data, cmd_prefix, nbr): + syslog.syslog(syslog.LOG_ERR, 'failed running BGP neighbor AF config command') + continue + elif table == 'COMMUNITY_SET' or table == 'EXTENDED_COMMUNITY_SET': + comm_set_name = prefix + syslog.syslog(syslog.LOG_INFO, 'Set community set {} for table {}'.format(comm_set_name, table)) + cmd_prefix = ['configure terminal'] + if not key_map.run_command(self, table, data, cmd_prefix, comm_set_name): + syslog.syslog(syslog.LOG_ERR, 'failed running BGP community config command') + continue + extended = (table != 'COMMUNITY_SET') + comm_set = (self.comm_set_list if not extended else self.extcomm_set_list).setdefault(comm_set_name, + CommunityList(comm_set_name, extended)) + if del_table: + del((self.comm_set_list if not extended else self.extcomm_set_list)[comm_set_name]) + else: + for dkey, dval in data.items(): + if dval.op == CachedDataWithOp.OP_DELETE: + upd_val = None + else: + upd_val = dval.data + comm_set.db_data_to_attr(dkey, upd_val) + elif table == 'PREFIX_SET': + pfx_set_name = prefix + if not del_table: + if pfx_set_name in self.prefix_set_list: + syslog.syslog(syslog.LOG_DEBUG, 'prefix-set %s exists with af %d' % + (pfx_set_name, self.prefix_set_list[pfx_set_name].af)) + continue + if 'mode' not in data: + syslog.syslog(syslog.LOG_ERR, 'no mode given for prefix-set %s' % pfx_set_name) + continue + set_mode = data['mode'].data.lower() + self.prefix_set_list[pfx_set_name] = MatchPrefixList(set_mode) + else: + if pfx_set_name in self.prefix_set_list: + del(self.prefix_set_list[pfx_set_name]) + for _, dval in data.items(): + dval.status = CachedDataWithOp.STAT_SUCC + elif table == 'PREFIX' or table == 'NEIGHBOR_SET' or table == 'NEXTHOP_SET': + pfx_set_name = self.get_prefix_set_name(prefix, table) + if table == 'PREFIX': + if pfx_set_name not in self.prefix_set_list: + syslog.syslog(syslog.LOG_ERR, 'could not find prefix-set %s from cache' % pfx_set_name) + continue + ip_pfx, len_range = key.split('|') + if len_range == 'exact': + len_range = None + pfx_action = data.get('action', None) + if pfx_action is None or pfx_action.op == CachedDataWithOp.OP_NONE: + continue + af = self.prefix_set_list[pfx_set_name].af + if af == socket.AF_INET: + # use table daemons setting + daemons = None + else: + daemons = ['bgpd', 'zebra'] + if pfx_action.op == CachedDataWithOp.OP_DELETE or pfx_action.op == CachedDataWithOp.OP_UPDATE: + del_pfx, pfx_idx = self.prefix_set_list[pfx_set_name].get_prefix(ip_pfx, len_range) + if del_pfx is None: + syslog.syslog(syslog.LOG_ERR, 'prefix of {} with range {} not found from prefix-set {}'.\ + format(ip_pfx, len_range, pfx_set_name)) + continue + command = "vtysh -c 'configure terminal' -c 'no {} prefix-list {} {}'".\ + format(('ip' if af == socket.AF_INET else 'ipv6'), pfx_set_name, str(del_pfx)) + if not self.__run_command(table, command, daemons): + syslog.syslog(syslog.LOG_ERR, 'failed to delete prefix %s with range %s from set %s' % + (ip_pfx, len_range, pfx_set_name)) + continue + del(self.prefix_set_list[pfx_set_name][pfx_idx]) + if pfx_action.op == CachedDataWithOp.OP_ADD or pfx_action.op == CachedDataWithOp.OP_UPDATE: + try: + add_pfx = self.prefix_set_list[pfx_set_name].add_prefix(ip_pfx, len_range, pfx_action.data) + except ValueError: + syslog.syslog(syslog.LOG_ERR, 'failed to update prefix-set %s in cache with prefix %s range %s' % + (pfx_set_name, ip_pfx, len_range)) + continue + command = "vtysh -c 'configure terminal' -c '{} prefix-list {} {}'".\ + format(('ip' if af == socket.AF_INET else 'ipv6'), pfx_set_name, str(add_pfx)) + if not self.__run_command(table, command, daemons): + syslog.syslog(syslog.LOG_ERR, 'failed to add prefix %s with range %s to set %s' % + (ip_pfx, len_range, pfx_set_name)) + # revert cached update on failure + del_pfx, pfx_idx = self.prefix_set_list[pfx_set_name].get_prefix(ip_pfx, len_range) + if del_pfx is not None: + del(self.prefix_set_list[pfx_set_name][pfx_idx]) + continue + else: + if 'address' not in data or data['address'].op == CachedDataWithOp.OP_NONE: + continue + ip_addr_list = data['address'].data + if pfx_set_name in self.prefix_set_list: + af = self.prefix_set_list[pfx_set_name].af + command = "vtysh -c 'configure terminal' -c 'no {} prefix-list {}'".\ + format(('ip' if af == socket.AF_INET else 'ipv6'), pfx_set_name) + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete existing prefix-set {}'.format(pfx_set_name)) + continue + del(self.prefix_set_list[pfx_set_name]) + if not del_table: + prefix_set = MatchPrefixList() + for ip_addr in ip_addr_list: + try: + prefix_set.add_prefix(ip_addr) + except ValueError: + continue + for prefix in prefix_set: + command = "vtysh -c 'configure terminal' -c '{} prefix-list {} {}'".\ + format(('ip' if prefix_set.af == socket.AF_INET else 'ipv6'), pfx_set_name, str(prefix)) + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete existing prefix-set {}'.format(pfx_set_name)) + continue + self.prefix_set_list[pfx_set_name] = prefix_set + for _, dval in data.items(): + dval.status = CachedDataWithOp.STAT_SUCC + elif table == 'AS_PATH_SET': + as_set_name = prefix + syslog.syslog(syslog.LOG_INFO, 'Set AS path set {} for table {}'.format(as_set_name, table)) + cmd_prefix = ['configure terminal'] + if not key_map.run_command(self, table, data, cmd_prefix, as_set_name): + syslog.syslog(syslog.LOG_ERR, 'failed running BGP AS path set config command') + continue + as_set_data = data.get('as_path_set_member', None) + if as_set_data is not None and (as_set_data.op == CachedDataWithOp.OP_DELETE or len(as_set_data.data) == 0): + del_table = True + if del_table: + self.as_path_set_list.pop(as_set_name, None) + elif as_set_data is not None: + self.as_path_set_list[as_set_name] = as_set_data.data[:] + elif table == 'TAG_SET': + tag_set_name = prefix + if not del_table and 'tag_value' not in data: + continue + tag_set_data = data.get('tag_value', None) + if tag_set_data is not None and (tag_set_data.op == CachedDataWithOp.OP_DELETE or len(tag_set_data.data) == 0): + del_table = True + if not del_table: + self.tag_set_list[tag_set_name] = set(tag_set_data.data) + else: + self.tag_set_list.pop(tag_set_name, None) + for _, dval in data.items(): + dval.status = CachedDataWithOp.STAT_SUCC + elif table == 'BGP_GLOBALS_EVPN_VNI': + af_type, vni = key.split('|') + af, ip_type = af_type.lower().split('_') + #this is to temporarily make table cache key accessible to key_map handler function + self.tmp_cache_key = 'BGP_GLOBALS_EVPN_VNI&&{}|{}|{}'.format(vrf, af_type, vni) + syslog.syslog(syslog.LOG_INFO, 'Set address family for VNI {} to {} {} cache-key to {}'.format(vni, af, ip_type, self.tmp_cache_key)) + cmd_prefix = ['configure terminal', + 'router bgp {} vrf {}'.format(local_asn, vrf), + 'address-family {} {}'.format(af, ip_type), + 'vni {}'.format(vni)] + if not key_map.run_command(self, table, data, cmd_prefix): + syslog.syslog(syslog.LOG_ERR, 'failed running BGP L2VPN_EVPN VNI config command') + continue + self.tmp_cache_key = '' + if del_table: + cmd = "vtysh -c 'configure terminal'" + cmd += " -c 'router bgp {} vrf {}'".format(local_asn, vrf) + cmd += " -c 'address-family {} {}'".format(af, ip_type) + cmd += " -c 'no vni {}'".format(vni) + if not self.__run_command(table, cmd): + syslog.syslog(syslog.LOG_ERR, 'failed running BGP L2VPN_EVPN VNI unconfig command') + continue + else: + if not data: + cmd = "vtysh -c 'configure terminal'" + cmd += " -c 'router bgp {} vrf {}'".format(local_asn, vrf) + cmd += " -c 'address-family {} {}'".format(af, ip_type) + cmd += " -c 'vni {}'".format(vni) + if not self.__run_command(table, cmd): + syslog.syslog(syslog.LOG_ERR, 'failed running BGP L2VPN_EVPN VNI config command') + continue + elif table == 'BGP_GLOBALS_EVPN_RT': + af_type, rt = key.split('|') + af, ip_type = af_type.lower().split('_') + nostr = "no " if del_table else "" + syslog.syslog(syslog.LOG_INFO, 'Set address family for RT {} to {} {}'.format(rt, af, ip_type)) + cmd = "vtysh -c 'configure terminal'" + cmd += " -c 'router bgp {} vrf {}'".format(local_asn, vrf) + cmd += " -c 'address-family {} {}'".format(af, ip_type) + cmd += " -c '{}route-target {} {}'".format(nostr,data['route-target-type'].data, rt) + cache_tbl_key = 'BGP_GLOBALS_EVPN_RT&&{}|L2VPN_EVPN|{}'.format(vrf, rt) + if not del_table and cache_tbl_key in self.table_data_cache.keys(): + new_rttype = data['route-target-type'].data + cache_tbl_data = self.table_data_cache[cache_tbl_key] + if 'route-target-type' in cache_tbl_data: + old_rttype = cache_tbl_data['route-target-type'] + if new_rttype == "export": + if old_rttype == "import" or old_rttype == "both": + cmd += " -c 'no route-target import {}'".format(rt) + if new_rttype == "import": + if old_rttype == "export" or old_rttype == "both": + cmd += " -c 'no route-target export {}'".format(rt) + if not self.__run_command(table, cmd): + syslog.syslog(syslog.LOG_ERR, 'failed running BGP L2VPN_EVPN RT config command') + continue + else: + data['route-target-type'].status = CachedDataWithOp.STAT_SUCC + elif table == 'BGP_GLOBALS_EVPN_VNI_RT': + af_type, vni, rt = key.split('|') + af, ip_type = af_type.lower().split('_') + nostr = "no " if del_table else "" + syslog.syslog(syslog.LOG_INFO, 'Set address family for VNI {} RT {} to {} {}'.format(vni, rt, af, ip_type)) + cmd = "vtysh -c 'configure terminal'" + cmd += " -c 'router bgp {} vrf {}'".format(local_asn, vrf) + cmd += " -c 'address-family {} {}'".format(af, ip_type) + cmd += " -c 'vni {}'".format(vni) + cmd += " -c '{}route-target {} {}'".format(nostr,data['route-target-type'].data, rt) + cache_tbl_key = 'BGP_GLOBALS_EVPN_VNI_RT&&{}|L2VPN_EVPN|{}|{}'.format(vrf, vni, rt) + if not del_table and cache_tbl_key in self.table_data_cache.keys(): + new_rttype = data['route-target-type'].data + cache_tbl_data = self.table_data_cache[cache_tbl_key] + if 'route-target-type' in cache_tbl_data: + old_rttype = cache_tbl_data['route-target-type'] + if new_rttype == "export": + if old_rttype == "import" or old_rttype == "both": + cmd += " -c 'no route-target import {}'".format(rt) + if new_rttype == "import": + if old_rttype == "export" or old_rttype == "both": + cmd += " -c 'no route-target export {}'".format(rt) + if not self.__run_command(table, cmd): + syslog.syslog(syslog.LOG_ERR, 'failed running BGP L2VPN_EVPN VNI RT config command') + continue + else: + data['route-target-type'].status = CachedDataWithOp.STAT_SUCC + elif table == 'ROUTE_MAP': + map_name = prefix + seq_no = key + if not del_table: + if 'route_operation' in data: + dval = data['route_operation'] + if dval.op != CachedDataWithOp.OP_NONE: + enable = (dval.op != CachedDataWithOp.OP_DELETE) + no_arg = CommandArgument(self, enable) + command = "vtysh -c 'configure terminal' -c '{:no-prefix}route-map {} {} {}'".\ + format(no_arg, map_name, dval.data, seq_no) + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to configure route-map {} seq {}'.format(map_name, seq_no)) + continue + if dval.op == CachedDataWithOp.OP_DELETE: + self.__delete_route_map(map_name, seq_no, data) + continue + self.route_map.setdefault(map_name, {})[seq_no] = dval.data + for k, v in data.items(): + if v.op == CachedDataWithOp.OP_NONE: + v.op = CachedDataWithOp.OP_UPDATE + dval.status = CachedDataWithOp.STAT_SUCC + if map_name not in self.route_map or seq_no not in self.route_map[map_name]: + syslog.syslog(syslog.LOG_ERR, 'route-map {} seq {} not found for update'.format(map_name, seq_no)) + continue + cmd_prefix = ['configure terminal', + 'route-map {} {} {}'.format(map_name, self.route_map[map_name][seq_no], seq_no)] + if not key_map.run_command(self, table, data, cmd_prefix): + syslog.syslog(syslog.LOG_ERR, 'failed running route-map config command') + continue + else: + if map_name not in self.route_map or seq_no not in self.route_map[map_name]: + syslog.syslog(syslog.LOG_ERR, 'route-map {} seq {} not found for delete'.format(map_name, seq_no)) + continue + command = "vtysh -c 'configure terminal' -c 'no route-map {} {} {}'".\ + format(map_name, self.route_map[map_name][seq_no], seq_no) + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed running route-map delete command') + continue + self.__delete_route_map(map_name, seq_no, data) + elif table == 'ROUTE_REDISTRIBUTE': + src_proto, dst_proto, af = key.split('|') + if af == 'ipv6' and src_proto == 'ospf3': + src_proto = 'ospf6' + ip_type = 'unicast' + syslog.syslog(syslog.LOG_INFO, 'Set route distribute for src_proto {} dst_proto {} {}'.\ + format(src_proto, dst_proto, af, ip_type)) + if dst_proto != 'bgp': + syslog.syslog(syslog.LOG_ERR, 'only bgp could be used as dst protocol, but {} was given'.format(dst_proto)) + continue + op = CachedDataWithOp.OP_DELETE if del_table else CachedDataWithOp.OP_UPDATE + data['protocol'] = CachedDataWithOp(src_proto, op) + cmd_prefix = ['configure terminal', + 'router bgp {} vrf {}'.format(local_asn, vrf), + 'address-family {} {}'.format(af, ip_type)] + ret_val = key_map.run_command(self, table, data, cmd_prefix) + del(data['protocol']) + if not ret_val: + syslog.syslog(syslog.LOG_ERR, 'failed running BGP route redistribute config command') + continue + elif table == 'BGP_GLOBALS_AF_AGGREGATE_ADDR' or table == 'BGP_GLOBALS_AF_NETWORK': + af_type, ip_prefix = key.split('|') + af, ip_type = af_type.lower().split('_') + norm_ip_prefix = MatchPrefix.normalize_ip_prefix((socket.AF_INET if af == 'ipv4' else socket.AF_INET6), ip_prefix) + if norm_ip_prefix is None: + syslog.syslog(syslog.LOG_ERR, 'invalid IP prefix format %s for af %s' % (ip_prefix, af)) + continue + syslog.syslog(syslog.LOG_INFO, 'Set address family for IP prefix {} to {} {}'.format(norm_ip_prefix, af, ip_type)) + op = CachedDataWithOp.OP_DELETE if del_table else CachedDataWithOp.OP_UPDATE + data['ip_prefix'] = CachedDataWithOp(norm_ip_prefix, op) + cmd_prefix = ['configure terminal', + 'router bgp {} vrf {}'.format(local_asn, vrf), + 'address-family {} {}'.format(af, ip_type)] + ret_val = key_map.run_command(self, table, data, cmd_prefix, vrf, af) + del(data['ip_prefix']) + if not ret_val: + syslog.syslog(syslog.LOG_ERR, 'failed running BGP IP prefix AF config command') + continue + if table == 'BGP_GLOBALS_AF_AGGREGATE_ADDR': + if not del_table: + aggr_obj = AggregateAddr() + for attr in ['as_set', 'summary_only']: + if attr in data and data[attr].op != CachedDataWithOp.OP_DELETE and data[attr].data == 'true': + setattr(aggr_obj, attr, True) + self.af_aggr_list.setdefault(vrf, {})[norm_ip_prefix] = aggr_obj + else: + if vrf in self.af_aggr_list: + self.af_aggr_list[vrf].pop(norm_ip_prefix, None) + + elif table == 'BFD_PEER_SINGLE_HOP': + key = prefix + '|' + key + remoteaddr, interface, vrf, localaddr = key.split('|') + if not del_table: + if not 'null' in localaddr: + syslog.syslog(syslog.LOG_INFO, 'Set BFD single hop peer {} {} {} {}'.format(remoteaddr, vrf, interface, localaddr)) + + suffix_cmd, oper = self.__bfd_handle_delete (data) + if suffix_cmd and oper == CachedDataWithOp.OP_DELETE: + command = "vtysh -c 'configure terminal' -c 'bfd' -c 'peer {} local-address {} vrf {} interface {}' -c '{}'".\ + format(remoteaddr, localaddr, vrf, interface, suffix_cmd) + + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete single-hop peer {}'.format(key)) + continue + else: + cmd_prefix = ['configure terminal', + 'bfd', + 'peer {} local-address {} vrf {} interface {}'.format(remoteaddr, localaddr, vrf, interface)] + if not key_map.run_command(self, table, data, cmd_prefix): + syslog.syslog(syslog.LOG_ERR, 'failed running BFD single-hop config command') + continue + + else: + syslog.syslog(syslog.LOG_INFO, 'Set BFD single hop peer {} {} {}'.format(remoteaddr, vrf, interface)) + + suffix_cmd, oper = self.__bfd_handle_delete (data) + + if suffix_cmd and oper == CachedDataWithOp.OP_DELETE: + command = "vtysh -c 'configure terminal' -c 'bfd' -c 'peer {} vrf {} interface {}' -c '{}'".\ + format(remoteaddr, vrf, interface, suffix_cmd) + + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete single-hop peer {}'.format(key)) + continue + else: + syslog.syslog(syslog.LOG_INFO, 'Set BFD single hop peer {} {} {}'.format(remoteaddr, vrf, interface)) + cmd_prefix = ['configure terminal', + 'bfd', + 'peer {} vrf {} interface {}'.format(remoteaddr, vrf, interface)] + if not key_map.run_command(self, table, data, cmd_prefix): + syslog.syslog(syslog.LOG_ERR, 'failed running BFD single-hop config command') + continue + else: + if 'local-address' in data: + dval = data['local-address'] + localaddr = dval.data + syslog.syslog(syslog.LOG_INFO, 'Delete BFD single hop to {} {} {}'.format(remoteaddr, vrf, interface, localaddr)) + command = "vtysh -c 'configure terminal' -c 'bfd' -c 'no peer {} local-address {} vrf {} interface {}'".\ + format(remoteaddr, localaddr, vrf, interface) + else: + syslog.syslog(syslog.LOG_INFO, 'Delete BFD single hop to {} {} {}'.format(remoteaddr, vrf, interface)) + command = "vtysh -c 'configure terminal' -c 'bfd' -c 'no peer {} vrf {} interface {}'".\ + format(remoteaddr, vrf, interface) + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete single-hop peer {}'.format(key)) + continue + self.__delete_bfd_peer(data) + elif table == 'BFD_PEER_MULTI_HOP': + key = prefix + '|' + key + remoteaddr, interface, vrf, localaddr = key.split('|') + if not del_table: + syslog.syslog(syslog.LOG_INFO, 'Set BFD multi hop to {} {} {} {}'.format(remoteaddr, interface, vrf, localaddr)) + suffix_cmd, oper = self.__bfd_handle_delete (data) + if suffix_cmd and oper == CachedDataWithOp.OP_DELETE: + if not 'null' in interface: + command = "vtysh -c 'configure terminal' -c 'bfd' -c 'peer {} local-address {} vrf {} interface {}' -c '{}'".\ + format(remoteaddr, localaddr, vrf, interface, suffix_cmd) + else: + command = "vtysh -c 'configure terminal' -c 'bfd' -c 'peer {} local-address {} vrf {}' -c '{}'".\ + format(remoteaddr, localaddr, vrf, suffix_cmd) + + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete single-hop peer {}'.format(key)) + continue + else: + if not 'null' in interface: + cmd_prefix = ['configure terminal', + 'bfd', + 'peer {} vrf {} multihop local-address {} interface {}'.format(remoteaddr, vrf, localaddr, interface)] + else: + cmd_prefix = ['configure terminal', + 'bfd', + 'peer {} vrf {} multihop local-address {}'.format(remoteaddr, vrf, localaddr)] + + if not key_map.run_command(self, table, data, cmd_prefix): + syslog.syslog(syslog.LOG_ERR, 'failed running BFD multi-hop config command') + continue + else: + syslog.syslog(syslog.LOG_INFO, 'Delete BFD multi hop to {} {} {} {}'.format(remoteaddr, vrf, localaddr, interface)) + if not 'null' in interface: + command = "vtysh -c 'configure terminal' -c 'bfd' -c 'no peer {} vrf {} multihop local-address {} interface {}'".\ + format(remoteaddr, vrf, localaddr, interface) + else: + command = "vtysh -c 'configure terminal' -c 'bfd' -c 'no peer {} vrf {} multihop local-address {}'".\ + format(remoteaddr, vrf, localaddr) + + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete multihop peer {}'.format(key)) + continue + self.__delete_bfd_peer(data) + elif table == 'IP_SLA': + sla_id = prefix + icmp_config = False + tcp_config = False + cmd_prefix = ['configure terminal'] + ipsla_table = self.config_db.get_table('IP_SLA') + syslog.syslog(syslog.LOG_INFO, 'Config ip sla data {}'.format(data)) + found_in_configdb = False + for key, entry in ipsla_table.items(): + ipsla_id = key + if sla_id == ipsla_id: + found_in_configdb = True + break + syslog.syslog(syslog.LOG_INFO, 'Config ip sla found_in_configdb {}'.format(found_in_configdb)) + if 'icmp_source_interface' in data or 'icmp_source_ip' in data or 'icmp_size' in data or 'icmp_dst_ip' in data or 'icmp_vrf' in data or 'icmp_ttl' in data or 'icmp_tos' in data: + cmd_prefix = ['configure terminal','ip sla {}'.format(sla_id)] + icmp_config = True + for key, entry in ipsla_table.items(): + ipsla_id = key + if sla_id == ipsla_id: + if 'icmp_dst_ip' in entry: + icmp_cmd = ("icmp", "echo") + icmp_cmd_str = "-".join(icmp_cmd) + icmp_cmd_mode = icmp_cmd_str + " " + entry['icmp_dst_ip'] + syslog.syslog(syslog.LOG_INFO, 'Data: icmp_cmd_str %s icmp_cmd_mode %s' % (icmp_cmd_str, icmp_cmd_mode)) + + cmd_prefix = ['configure terminal','ip sla {}'.format(sla_id), icmp_cmd_mode] + chk_icmp_attrs = ['icmp_source_interface', 'icmp_source_ip', 'icmp_size', 'icmp_vrf', 'icmp_tos', 'icmp_ttl'] + chk_icmp_attrs_dict = {'icmp_source_interface':'source-interface ', 'icmp_source_ip':'source-address ', 'icmp_size':'request-data-size ', 'icmp_vrf':'source-vrf ', 'icmp_tos':'tos ', 'icmp_ttl':'ttl '} + for attr in chk_icmp_attrs: + if attr in data and data[attr].op != CachedDataWithOp.OP_DELETE: + command = "vtysh -c 'configure terminal' -c 'ip sla {}' -c '{}' -c '{} {}'".\ + format(sla_id, icmp_cmd_mode, chk_icmp_attrs_dict[attr], data[attr].data) + syslog.syslog(syslog.LOG_INFO, 'Execute Icmp Cmd {}'.format(command)) + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to add icmp config for ip sla {}'.format(sla_id)) + continue + + syslog.syslog(syslog.LOG_INFO, 'Done with Icmp {}'.format(sla_id)) + if not key_map.run_command(self, table, data, cmd_prefix, sla_id): + syslog.syslog(syslog.LOG_ERR, 'failed running ip sla command') + continue + if 'tcp_source_interface' in data or 'tcp_source_port' in data or 'tcp_source_ip' in data or 'tcp_dst_ip' in data or 'tcp_dst_port' in data or 'tcp_vrf' in data or 'tcp_ttl' in data or 'tcp_tos' in data: + cmd_prefix = ['configure terminal','ip sla {}'.format(sla_id)] + tcp_config = True + for key, entry in ipsla_table.items(): + ipsla_id = key + if sla_id == ipsla_id: + if 'tcp_dst_ip' in entry and 'tcp_dst_port' in entry: + tcp_cmd = ("tcp", "connect") + tcp_cmd_str = "-".join(tcp_cmd) + tcp_cmd_mode = tcp_cmd_str + " " + entry['tcp_dst_ip'] + " port " + entry['tcp_dst_port'] + syslog.syslog(syslog.LOG_INFO, 'Init Config DB Data: tcp_cmd_str %s tcp_cmd_mode %s' % (tcp_cmd_str, tcp_cmd_mode)) + cmd_prefix = ['configure terminal','ip sla {}'.format(sla_id), tcp_cmd_mode] + chk_tcp_attrs = ['tcp_source_interface', 'tcp_source_ip', 'tcp_source_port', 'tcp_vrf', 'tcp_tos', 'tcp_ttl'] + chk_tcp_attrs_dict = {'tcp_source_interface':'source-interface ', 'tcp_source_ip':'source-address ', 'tcp_source_port':'source-port ', 'tcp_vrf':'source-vrf ', 'tcp_tos':'tos ', 'tcp_ttl':'ttl '} + for attr in chk_tcp_attrs: + if attr in data and data[attr].op != CachedDataWithOp.OP_DELETE: + command = "vtysh -c 'configure terminal' -c 'ip sla {}' -c '{}' -c '{} {}'".\ + format(sla_id, tcp_cmd_mode, chk_tcp_attrs_dict[attr], data[attr].data) + syslog.syslog(syslog.LOG_INFO, 'Execute Tcp Cmd {}'.format(command)) + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to add Tcp config for ip sla {}'.format(sla_id)) + continue + + syslog.syslog(syslog.LOG_INFO, 'Done with Tcp {}'.format(sla_id)) + if not key_map.run_command(self, table, data, cmd_prefix, sla_id): + syslog.syslog(syslog.LOG_ERR, 'failed running ip sla command') + continue + if 'frequency' in data or 'threshold' in data or 'timeout' in data: + syslog.syslog(syslog.LOG_INFO, 'ip sla mode Configure freq/thresh/timeout for sla {}'.format(sla_id)) + cmd_prefix = ['configure terminal','ip sla {}'.format(sla_id)] + if not key_map.run_command(self, table, data, cmd_prefix, sla_id): + syslog.syslog(syslog.LOG_ERR, 'failed running ip sla command') + continue + + elif icmp_config == False or tcp_config == False: + syslog.syslog(syslog.LOG_INFO, 'Basic mode Configure for ip sla {}'.format(sla_id)) + cmd_prefix = ['configure terminal'] + + # Always delete ip sla if it is not found in configdb + if not found_in_configdb: + command = "vtysh -c 'configure terminal' -c 'no ip sla {}'".format(sla_id) + syslog.syslog(syslog.LOG_ERR, 'Entry deleted in ip sla config db') + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete router ip sla {}'.format(sla_id)) + continue + elif not key_map.run_command(self, table, data, cmd_prefix, sla_id): + syslog.syslog(syslog.LOG_ERR, 'failed running ip sla command') + continue + + elif table == 'OSPFV2_ROUTER': + vrf = prefix + if not del_table: + syslog.syslog(syslog.LOG_INFO, 'Create router ospf vrf {}'.format(vrf)) + + cmd_prefix = ['configure terminal', + 'router ospf vrf {}'.format(vrf)] + + if not key_map.run_command(self, table, data, cmd_prefix): + syslog.syslog(syslog.LOG_ERR, 'failed running ospf config command') + continue + else: + command = "vtysh -c 'configure terminal' -c 'no router ospf vrf {}'".format(vrf) + + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete router ospf vrf {}'.format(vrf)) + continue + else: + self.__ospf_delete(data) + + elif table == 'OSPFV2_ROUTER_AREA': + vrf = prefix + syslog.syslog(syslog.LOG_INFO, 'Create router ospf vrf {}'.format(vrf)) + + cmd_prefix = ['configure terminal', + 'router ospf vrf {}'.format(vrf)] + + if not key_map.run_command(self, table, data, cmd_prefix, key): + syslog.syslog(syslog.LOG_ERR, 'failed running ospf config command') + continue + elif table == 'OSPFV2_ROUTER_AREA_VIRTUAL_LINK': + vrf = prefix + + keyvals = key.split('|') + area = keyvals[0] + vlinkid = keyvals[1] + + syslog.syslog(syslog.LOG_INFO, 'Create router ospf vrf {}, Vlink: {}, tableop {}'.format(vrf, data, del_table)) + + if data == {}: + command = "vtysh -c 'configure terminal' -c 'router ospf vrf {}' -c 'no area {} virtual-link {}'".\ + format(vrf, area, vlinkid) + + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete vlink {} {}'.format(area, vlinkid)) + continue + else: + self.__ospf_delete(data) + else: + cmd_prefix = ['configure terminal', + 'router ospf vrf {}'.format(vrf)] + + if not key_map.run_command(self, table, data, cmd_prefix, area, vlinkid): + syslog.syslog(syslog.LOG_ERR, 'failed running ospf config command') + continue + + if del_table: + command = "vtysh -c 'configure terminal' -c 'router ospf vrf {}' -c 'no area {} virtual-link {}'".\ + format(vrf, area, vlinkid) + + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete vlink {} {}'.format(area, vlinkid)) + continue + else: + self.__ospf_delete(data) + + elif table == 'OSPFV2_ROUTER_AREA_NETWORK': + vrf = prefix + syslog.syslog(syslog.LOG_INFO, 'Create router ospf vrf {}'.format(vrf)) + + keyvals = key.split('|') + area = keyvals[0] + network = keyvals[1] + + if not del_table: + command = "vtysh -c 'configure terminal' -c 'router ospf vrf {}' -c 'network {} area {}'".\ + format(vrf, network, area) + + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to create network {} {}'.format(area, network)) + continue + else: + command = "vtysh -c 'configure terminal' -c 'router ospf vrf {}' -c 'no network {} area {}'".\ + format(vrf, network, area) + + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete network {} {}'.format(area, network)) + continue + else: + self.__ospf_delete(data) + + elif table == 'OSPFV2_ROUTER_AREA_POLICY_ADDRESS_RANGE': + vrf = prefix + + keyvals = key.split('|') + area = keyvals[0] + range = keyvals[1] + + syslog.syslog(syslog.LOG_INFO, 'Create router ospf vrf {}'.format(vrf)) + + if data == {}: + if not del_table: + command = "vtysh -c 'configure terminal' -c 'router ospf vrf {}' -c 'area {} range {}'".\ + format(vrf, area, range) + + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to create range {} {}'.format(area, range)) + continue + else: + command = "vtysh -c 'configure terminal' -c 'router ospf vrf {}' -c 'no area {} range {}'".\ + format(vrf, area, range) + + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete range {} {}'.format(area, range)) + continue + else: + self.__ospf_delete(data) + else: + cmd_prefix = ['configure terminal', + 'router ospf vrf {}'.format(vrf)] + + if not key_map.run_command(self, table, data, cmd_prefix, area, range): + syslog.syslog(syslog.LOG_ERR, 'failed running ospf config command') + continue + + elif table == 'OSPFV2_ROUTER_DISTRIBUTE_ROUTE': + vrf = prefix + + keyvals = key.split('|') + protocol = keyvals[0] + direction = keyvals[1] + + if (protocol == "DIRECTLY_CONNECTED"): + protocol = "CONNECTED" + + syslog.syslog(syslog.LOG_INFO, 'Create redistribute-list {} {}'.format(protocol, direction)) + + cmd_suffix = "" + del_cmd_suffix = "" + cmd_oper = "" + rmapcmd = "" + metriccmd = "" + metrictypecmd = "" + alwayscmd = "" + acclistname = "" + rmapoper = "" + metricoper = "" + metrictypeoper = "" + alwaysoper = "" + acclistoper = "" + + if 'route-map' in data: + dval = data['route-map'] + rmapoper = dval.op + rmapcmd = " route-map {}".format(dval.data) + + if 'access-list' in data: + dval = data['access-list'] + acclistoper = dval.op + acclistname = dval.data + + if 'metric' in data: + dval = data['metric'] + metricoper = dval.op + metriccmd = " metric {}".format(dval.data) + + if 'metric-type' in data: + dval = data['metric-type'] + metrictypeoper = dval.op + + if dval.data == "TYPE_1": + metrictypecmd = " metric-type 1" + else: + metrictypecmd = " metric-type 2" + + if 'always' in data: + dval = data['always'] + alwaysoper = dval.op + alwayscmd = " always" + + if not del_table: + + if ((rmapoper == CachedDataWithOp.OP_DELETE) or + (metricoper == CachedDataWithOp.OP_DELETE) or + (metrictypeoper == CachedDataWithOp.OP_DELETE) or + (alwaysoper == CachedDataWithOp.OP_DELETE) or + (acclistoper == CachedDataWithOp.OP_DELETE)): + + cmd_oper = "no" + + if (alwaysoper == CachedDataWithOp.OP_DELETE): + del_cmd_suffix = alwayscmd + if (rmapoper == CachedDataWithOp.OP_DELETE): + del_cmd_suffix = rmapcmd + if (metricoper == CachedDataWithOp.OP_DELETE): + del_cmd_suffix = metriccmd + if (metrictypeoper == CachedDataWithOp.OP_DELETE): + del_cmd_suffix = metrictypecmd + + if (direction == "EXPORT"): + if (cmd_oper != "no"): + cmd_suffix = "distribute-list {} out {}".format(acclistname, protocol.lower()) + else: + cmd_suffix = "no distribute-list {} out {}".format(acclistname, protocol.lower()) + + command = "vtysh -c 'configure terminal' -c 'router ospf vrf {}' -c '{}'".\ + format(vrf, cmd_suffix) + + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to create distribute-list {} {}'.format(protocol, direction)) + continue + else: + self.__ospf_apply_config(data, rmapoper, metricoper, metrictypeoper, alwaysoper, acclistoper) + elif (direction == "IMPORT"): + if (cmd_oper != "no"): + if (protocol == "DEFAULT_ROUTE"): + cmd_suffix = cmd_suffix + "default-information originate" + alwayscmd + rmapcmd + metriccmd + metrictypecmd + else: + cmd_suffix = cmd_suffix + "redistribute {}".format(protocol.lower()) + rmapcmd + metriccmd + metrictypecmd + else: + if (protocol == "DEFAULT_ROUTE"): + cmd_suffix = "no default-information originate" + del_cmd_suffix + else: + cmd_suffix = "no redistribute {}".format(protocol.lower()) + del_cmd_suffix + + command = "vtysh -c 'configure terminal' -c 'router ospf vrf {}' -c '{}'".\ + format(vrf, cmd_suffix) + + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to create default-info/redistribute {} {}'.format(protocol, direction)) + continue + else: + self.__ospf_apply_config(data, rmapoper, metricoper, metrictypeoper, alwaysoper, acclistoper) + else: + if (direction == "IMPORT"): + command = "" + if (protocol == "DEFAULT_ROUTE"): + command = "vtysh -c 'configure terminal' -c 'router ospf vrf {}' -c 'no default-information originate'".\ + format(vrf) + else: + command = "vtysh -c 'configure terminal' -c 'router ospf vrf {}' -c 'no redistribute {}'".\ + format(vrf, protocol.lower()) + + if (command != ""): + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete default-info/redistribute {}'.format(protocol.lower())) + continue + else: + self.__ospf_delete(data) + else: + if (acclistname != ""): + command = "vtysh -c 'configure terminal' -c 'router ospf vrf {}' -c 'no distribute-list {} out {}'".\ + format(vrf, acclistname, protocol.lower()) + + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete distribute-list {} {}'.format(protocol, direction)) + continue + + self.__ospf_delete(data) + + elif table == 'OSPFV2_INTERFACE': + + key = prefix + '|' + key + if_name, if_addr = key.split('|') + + vrf = "" + if 'vrf_name' in data : + vrf = 'vrf {}'.format(data['vrf_name'].data) + + cmd_prefix = ['configure terminal', + 'interface {} {}'.format(if_name, vrf) ] + + if del_table and len(data) == 0: + syslog.syslog(syslog.LOG_INFO, 'Delete table {} {} data {}'.format(key, vrf, data)) + + cmd_data = {} + cache_tbl_key = 'OSPFV2_INTERFACE&&{}|{}'.format(if_name, if_addr) + syslog.syslog(syslog.LOG_INFO, 'Row delete key {}'.format(cache_tbl_key)) + + if cache_tbl_key in self.table_data_cache.keys(): + cache_tbl_data = self.table_data_cache[cache_tbl_key] + syslog.syslog(syslog.LOG_INFO, 'Row delete cached data {} '.format(cache_tbl_data)) + + for key, data in cache_tbl_data.items() : + cached_op_data = CachedDataWithOp(data, CachedDataWithOp.OP_DELETE) + cmd_data.update({ key : cached_op_data } ) + + syslog.syslog(syslog.LOG_INFO, 'Row delete cmd data {} '.format(cmd_data)) + + if len(cmd_data) : + if not key_map.run_command(self, table, cmd_data, cmd_prefix, if_name, if_addr): + syslog.syslog(syslog.LOG_INFO, 'failed running interface no ip ospf config command') + self.__apply_config_delete_success(cmd_data) + continue + else : + self.__apply_config_delete_success(cmd_data) + + else : + syslog.syslog(syslog.LOG_INFO, 'Create/update ospf {} interface {} in {}'.format(key, if_name, vrf)) + + #Work arround for router area config fail, update area every time + if 'area-id' in data.keys(): + dval = data['area-id'] + if dval.op == CachedDataWithOp.OP_NONE : + dval.op = CachedDataWithOp.OP_ADD + + if not key_map.run_command(self, table, data, cmd_prefix, if_name, if_addr): + syslog.syslog(syslog.LOG_ERR, 'failed running interface ip ospf config command') + if 'area-id' in data.keys(): + dval = data['area-id'] + if dval.op == CachedDataWithOp.OP_DELETE: + #Work arround for router area config delete fail + self.__apply_config_op_success(data, {'area-id': dval.op } ) + syslog.syslog(syslog.LOG_INFO, 'area-id delete enforced') + continue + else : + self.__apply_config_op_success(data) + + elif table == 'OSPFV2_ROUTER_PASSIVE_INTERFACE': + syslog.syslog(syslog.LOG_INFO, 'Create passive interface') + + vrf = prefix + + keyvals = key.split('|') + if_name = keyvals[0] + if_addr = keyvals[1] + + syslog.syslog(syslog.LOG_INFO, 'Create passive interface vrf {}'.format(vrf)) + + if (if_addr == "0.0.0.0"): + if_addr = "" + + if data == {}: + if not del_table: + + command = "vtysh -c 'configure terminal' -c 'router ospf vrf {}' -c 'passive-interface {} {}'".\ + format(vrf, if_name, if_addr) + + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to create passive interface {} {}'.format(if_name, if_addr)) + continue + else: + command = "vtysh -c 'configure terminal' -c 'router ospf vrf {}' -c 'no passive-interface {} {}'".\ + format(vrf, if_name, if_addr) + + if not self.__run_command(table, command): + syslog.syslog(syslog.LOG_ERR, 'failed to delete passive interface {} {}'.format(if_name, if_addr)) + continue + + elif table == 'STATIC_ROUTE': + vrf = prefix + syslog.syslog(syslog.LOG_INFO, 'Set static IP route for vrf {} prefix {}'.format(vrf, key)) + op = CachedDataWithOp.OP_DELETE if del_table else CachedDataWithOp.OP_UPDATE + data['ip_prefix'] = CachedDataWithOp(key, op) + cmd_prefix = ['configure terminal', 'vrf {}'.format(vrf)] + ret_val = key_map.run_command(self, table, data, cmd_prefix, vrf) + del(data['ip_prefix']) + if not ret_val: + syslog.syslog(syslog.LOG_ERR, 'failed running static route config command') + continue + self.static_route_list.setdefault(vrf, {})[key] = self.upd_nh_set + elif table == 'PIM_INTERFACE': + + vrf = prefix + af, if_name = key.split('|') + syslog.syslog(syslog.LOG_INFO, + 'PIM interface update for vrf {}, af: {}, interface {}'.format(vrf, af, if_name)) + cmd_prefix = ['configure terminal', + 'interface {}'.format(if_name)] + syslog.syslog(syslog.LOG_INFO, + 'Create/update PIM interface: key {} interface {} in {}'.format(key, if_name, vrf)) + + # If sparse-mode has been disabled, clear other interface + # entries in cache so that they will be re-programmed in FRR + # on re-enabling of sparse-mode. + + if 'mode' in data: + modeval = data['mode'] + modeval_pim_mode = modeval.data + modeval_op = modeval.op + if (modeval_op == CachedDataWithOp.OP_DELETE): + syslog.syslog(syslog.LOG_INFO, + "Flushing PIM interface cache for deletion " + "of PIM sparse-mode") + for dkey, dval in data.items(): + dval.status = CachedDataWithOp.STAT_SUCC + dval.op = CachedDataWithOp.OP_DELETE + + # Only send the VTYSH command to FRR if the PIM interface mode + # is present in the update. + if not key_map.run_command(self, table, data, cmd_prefix): + syslog.syslog(syslog.LOG_ERR, 'failed running PIM config command') + continue + + elif table == 'PIM_GLOBALS': + + vrf = prefix + + af = key.split('|') + syslog.syslog(syslog.LOG_INFO, + 'PIM global update for vrf {}, af: {}'.format(vrf, af)) + + cmd_prefix = ['configure terminal', + 'vrf {}'.format(vrf)] + + syslog.syslog(syslog.LOG_INFO, + 'Create/update PIM global {} af {} in {}'.format(key, af, vrf)) + + # if not key_map.run_command(self, table, data, cmd_prefix, vrf, af): + if not key_map.run_command(self, table, data, cmd_prefix): + syslog.syslog(syslog.LOG_ERR, 'failed running PIM config command') + continue + + elif table == 'IGMP_INTERFACE': + ifname = prefix + + syslog.syslog(syslog.LOG_INFO, 'IGMP Interface MCast Grp ifname {} prefix {}'.format(ifname, key)) + + keyvals = key.split('|') + mcast_grp = keyvals[0] + source_ip = keyvals[1] + + syslog.syslog(syslog.LOG_INFO, 'Configure ip igmp join interface {}, mcast_grp {}, source_ip {}'.format(ifname, mcast_grp, source_ip)) + + cmd_prefix = ['configure terminal', + 'interface {}'.format(ifname)] + + if not key_map.run_command(self, table, data, cmd_prefix, mcast_grp, source_ip): + syslog.syslog(syslog.LOG_ERR, 'failed running ip igmp join config command') + continue + + + elif table == 'IGMP_INTERFACE_QUERY': + ifname = prefix + + syslog.syslog(syslog.LOG_INFO, 'IGMP Interface {} Config prefix {}'.format(ifname, key)) + + cmd_prefix = ['configure terminal', + 'interface {}'.format(ifname)] + + if not key_map.run_command(self, table, data, cmd_prefix): + syslog.syslog(syslog.LOG_ERR, 'failed running ip igmp interface config command') + continue + + + def __add_op_to_data(self, table_key, data, comb_attr_list): + cached_data = self.table_data_cache.setdefault(table_key, {}) + for key in cached_data: + if key in data: + # both in cache and data, update/none + data[key] = (CachedDataWithOp(data[key], CachedDataWithOp.OP_NONE) if data[key] == cached_data[key] else + CachedDataWithOp(data[key], CachedDataWithOp.OP_UPDATE)) + else: + # in cache but not in data, delete + data[key] = CachedDataWithOp(cached_data[key], CachedDataWithOp.OP_DELETE) + for key in data: + if not isinstance(data[key], CachedDataWithOp): + # in data but not in cache, add + data[key] = CachedDataWithOp(data[key], CachedDataWithOp.OP_ADD) + # combo attributes handling + op_list = [CachedDataWithOp.OP_DELETE, CachedDataWithOp.OP_ADD, CachedDataWithOp.OP_UPDATE, CachedDataWithOp.OP_NONE] + for key_set in comb_attr_list: + all_in = True + op_idx = len(op_list) - 1 + for key in key_set: + if key not in data: + all_in = False + break + idx = op_list.index(data[key].op) + if idx >= 0 and idx < op_idx: + op_idx = idx + if all_in: + for key in key_set: + data[key].op = op_list[op_idx] + else: + # if one key doesn't exist, clean the whole key set + for key in key_set: + data.pop(key, None) + + def __update_cache_data(self, table_key, data): + cached_data = self.table_data_cache.setdefault(table_key, {}) + for key, val in data.items(): + if not isinstance(val, CachedDataWithOp) or val.op == CachedDataWithOp.OP_NONE or val.status == CachedDataWithOp.STAT_FAIL: + syslog.syslog(syslog.LOG_DEBUG, 'ignore cache update for %s because of %s%s%s' % + (key, ('' if isinstance(val, CachedDataWithOp) else 'INV_DATA '), + ('NO_OP ' if isinstance(val, CachedDataWithOp) and val.op == CachedDataWithOp.OP_NONE else ''), + ('STAT_FAIL ' if isinstance(val, CachedDataWithOp) and val.status == CachedDataWithOp.STAT_FAIL else ''))) + continue + if val.op == CachedDataWithOp.OP_ADD or val.op == CachedDataWithOp.OP_UPDATE: + cached_data[key] = val.data + syslog.syslog(syslog.LOG_INFO, 'Add {} data {} to cache'.format(key, cached_data[key])) + elif val.op == CachedDataWithOp.OP_DELETE: + syslog.syslog(syslog.LOG_INFO, 'delete {} data {} from cache'.format(key, cached_data.get(key, ''))) + cached_data.pop(key, None) + if len(cached_data) == 0: + syslog.syslog(syslog.LOG_INFO, 'delete table row {} from cache'.format(table_key)) + del(self.table_data_cache[table_key]) + + + def bgp_table_handler_common(self, table, key, data, comb_attr_list = []): + syslog.syslog(syslog.LOG_DEBUG, '----------------------------------') + syslog.syslog(syslog.LOG_DEBUG, ' BGP table handling') + syslog.syslog(syslog.LOG_DEBUG, '----------------------------------') + syslog.syslog(syslog.LOG_DEBUG, 'table : %s' % table) + syslog.syslog(syslog.LOG_DEBUG, 'key : %s' % key) + op_str = ('DELETE' if data is None else 'SET') + del_table = False + if data is None: + data = {} + del_table = True + syslog.syslog(syslog.LOG_DEBUG, 'op : %s' % op_str) + syslog.syslog(syslog.LOG_DEBUG, 'data :') + for dkey, dval in data.items(): + syslog.syslog(syslog.LOG_DEBUG, ' %-10s - %s' % (dkey, dval)) + syslog.syslog(syslog.LOG_DEBUG, '') + table_key = ExtConfigDBConnector.get_table_key(table, key) + self.__add_op_to_data(table_key, data, comb_attr_list) + self.bgp_message.put((key, del_table, table, data)) + upd_data_list = [] + self.__update_bgp(upd_data_list) + for table, key, data in upd_data_list: + table_key = ExtConfigDBConnector.get_table_key(table, key) + self.__update_cache_data(table_key, data) + + def bgp_global_handler(self, table, key, data): + self.bgp_table_handler_common(table, key, data, [{'keepalive', 'holdtime'}]) + + def bgp_af_handler(self, table, key, data): + self.bgp_table_handler_common(table, key, data, [{'ebgp_route_distance', 'ibgp_route_distance', 'local_route_distance'}, + {'route_flap_dampen_reuse_threshold', 'route_flap_dampen_suppress_threshold', 'route_flap_dampen_max_suppress'}]) + + def bgp_neighbor_handler(self, table, key, data): + self.bgp_table_handler_common(table, key, data, [{'keepalive', 'holdtime'}]) + + def comm_set_handler(self, table, key, data): + self.bgp_table_handler_common(table, key, data, [{'set_type', 'match_action', 'community_member'}]) + + def bfd_shop_handler(self, table, key, data): + self.bgp_table_handler_common(table, key, data, [{'remote-address', 'vrf', 'interface'}, + {'remote-address', 'vrf', 'interface', 'local-address'}]) + def bfd_mhop_handler(self, table, key, data): + self.bgp_table_handler_common(table, key, data, [{'remote-address', 'vrf', 'local-address'}]) + + def start(self): + self.subscribe_all() + self.config_db.listen() + def stop(self): + self.config_db.sub_thread.stop() + if self.config_db.sub_thread.is_alive(): + self.config_db.sub_thread.join() + +main_loop = True + +def sig_handler(signum, frame): + global main_loop + syslog.syslog(syslog.LOG_DEBUG, 'entering signal handler') + main_loop = False + +def main(): + global bgpd_client + for sig_num in [signal.SIGTERM, signal.SIGINT]: + signal.signal(sig_num, sig_handler) + syslog.syslog(syslog.LOG_DEBUG, 'entering BGP configuration daemon') + bgpd_client = BgpdClientMgr() + bgpd_client.start() + daemon = BGPConfigDaemon() + daemon.start() + while main_loop: + signal.pause() + syslog.syslog(syslog.LOG_DEBUG, 'leaving BGP configuration daemon') + bgpd_client.shutdown() + daemon.stop() + +if __name__ == "__main__": + main() diff --git a/src/sonic-frr-mgmt-framework/pytest.ini b/src/sonic-frr-mgmt-framework/pytest.ini new file mode 100644 index 000000000000..c857ef5cd502 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +addopts = --cov=frrcfgd --cov-report term diff --git a/src/sonic-frr-mgmt-framework/setup.cfg b/src/sonic-frr-mgmt-framework/setup.cfg new file mode 100644 index 000000000000..00ed5efbcbad --- /dev/null +++ b/src/sonic-frr-mgmt-framework/setup.cfg @@ -0,0 +1,5 @@ +[aliases] +test=pytest +[tool:pytest] +addopts = --verbose +python_files = tests/*.py diff --git a/src/sonic-frr-mgmt-framework/setup.py b/src/sonic-frr-mgmt-framework/setup.py new file mode 100755 index 000000000000..d8681d1bbd88 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/setup.py @@ -0,0 +1,51 @@ +import setuptools + +setuptools.setup( + name = 'sonic-frr-mgmt-framework', + version = '1.0', + description = 'Utility to dynamically configuration FRR based on config DB data update event', + url = 'https://github.com/Azure/sonic-buildimage', + packages = setuptools.find_packages(), + entry_points = { + 'console_scripts': [ + 'frrcfgd = frrcfgd.frrcfgd:main', + ] + }, + install_requires = [ + 'jinja2>=2.10', + 'netaddr==0.8.0', + 'pyyaml==5.3.1', + 'zipp==1.2.0', # importlib-resources needs zipp and seems to have a bug where it will try to import too new of a version for Python 2 + ], + setup_requires = [ + 'pytest-runner', + 'wheel' + ], + tests_require = [ + 'pytest', + 'pytest-cov', + 'sonic-config-engine' + ], + data_files = [('sonic/frrcfgd', ['templates/bgpd/bgpd.conf.j2', + 'templates/bgpd/bgpd.conf.db.j2', + 'templates/bgpd/bgpd.conf.db.route_map.j2', + 'templates/bgpd/bgpd.conf.db.pref_list.j2', + 'templates/bgpd/bgpd.conf.db.nbr_or_peer.j2', + 'templates/bgpd/bgpd.conf.db.nbr_af.j2', + 'templates/bgpd/bgpd.conf.db.comm_list.j2', + 'templates/bgpd/bgpd.conf.db.addr_family.j2', + 'templates/bgpd/bgpd.conf.db.addr_family.evpn.j2', + 'templates/bfdd/bfdd.conf.j2', + 'templates/ospfd/ospfd.conf.j2', + 'templates/ospfd/ospfd.conf.db.area.j2', + 'templates/ospfd/ospfd.conf.db.comm_list.j2', + 'templates/ospfd/ospfd.conf.db.distributeroute.j2', + 'templates/ospfd/ospfd.conf.db.interface.j2', + 'templates/ospfd/ospfd.conf.db.policyrange.j2', + 'templates/ospfd/ospfd.conf.db.vlink.j2', + 'templates/staticd/staticd.conf.j2', + 'templates/staticd/staticd.db.conf.j2', + 'templates/staticd/staticd.db.default_route.conf.j2', + 'templates/frr/frr.conf.j2']) + ] +) diff --git a/src/sonic-frr-mgmt-framework/templates/bfdd/bfdd.conf.j2 b/src/sonic-frr-mgmt-framework/templates/bfdd/bfdd.conf.j2 new file mode 100644 index 000000000000..a4c07c026375 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/bfdd/bfdd.conf.j2 @@ -0,0 +1,91 @@ +! +{% block banner %} +! =========== Managed by sonic-cfggen DO NOT edit manually! ==================== +! generated by templates/frr/bfd.conf.j2 with config DB data +! file: bfd.conf +! +{% endblock banner %} +! +{% block bfd_shop_peers %} +{% if BFD_PEER_SINGLE_HOP %} +bfd +{% for (peer_key, peer_info) in BFD_PEER_SINGLE_HOP.items() %} +{% set peer_args = '' %} +{% if peer_key[0] != 'null' %} +{% set peer_args = peer_args~' '~'peer'~' '~peer_key[0] %} +{% endif %} +{% if peer_key[1] != 'null' %} +{% set peer_args = peer_args~' '~'interface'~' '~peer_key[1] %} +{% endif %} +{% if peer_key[2] != 'null' %} +{% set peer_args = peer_args~' '~'vrf'~' '~peer_key[2] %} +{% endif %} +{% if peer_key[3] != 'null' %} +{% set peer_args = peer_args~' '~'local-address'~' '~peer_key[3] %} +{% endif %} +{{ peer_args }} +{# set the bfd peer timers #} +{% if (peer_info['desired-minimum-tx-interval'] is defined and peer_info['desired-minimum-tx-interval'] | int != 300) %} + transmit-interval {{ peer_info['desired-minimum-tx-interval'] }} +{% endif %} +{% if (peer_info['required-minimum-receive'] is defined and peer_info['required-minimum-receive'] | int != 300) %} + receive-interval {{ peer_info['required-minimum-receive'] }} +{% endif %} +{% if (peer_info['detection-multiplier'] is defined and peer_info['detection-multiplier'] | int != 3) %} + detect-multiplier {{ peer_info['detection-multiplier'] }} +{% endif %} +{% if (peer_info['echo-active'] is defined and peer_info['echo-active'] != 'false') %} + echo-mode +{% endif %} +{% if (peer_info['desired-minimum-echo-receive'] is defined and peer_info['desired-minimum-echo-receive'] | int != 50) %} + echo-interval {{ peer_info['desired-minimum-echo-receive'] }} +{% endif %} +{% if (peer_info['enabled'] is defined and peer_info['enabled'] == 'true') %} + no shutdown +{% else %} + shutdown +{% endif %} + ! +{% endfor %} +! +{% endif %} +{% endblock bfd_shop_peers%} +{% block bfd_mhop_peers %} +{% if BFD_PEER_MULTI_HOP %} +bfd +{% for (peer_key, peer_info) in BFD_PEER_MULTI_HOP.items() %} +{% set peer_args = '' %} +{% if peer_key[0] != 'null' %} +{% set peer_args = peer_args~' '~'peer'~' '~peer_key[0] %} +{% endif %} +{% if peer_key[1] != 'null' %} +{% set peer_args = peer_args~' '~'interface'~' '~peer_key[1] %} +{% endif %} +{% if peer_key[2] != 'null' %} +{% set peer_args = peer_args~' '~'vrf'~' '~peer_key[2] %} +{% endif %} +{% if peer_key[3] != 'null' %} +{% set peer_args = peer_args~' '~'local-address'~' '~peer_key[3] %} +{% endif %} +{% set peer_args = peer_args~' '~'multihop' %} +{{ peer_args }} +{# set the bfd peer timers #} +{% if (peer_info['desired-minimum-tx-interval'] is defined and peer_info['desired-minimum-tx-interval'] | int != 300) %} + transmit-interval {{ peer_info['desired-minimum-tx-interval'] }} +{% endif %} +{% if (peer_info['required-minimum-receive'] is defined and peer_info['required-minimum-receive'] | int != 300) %} + receive-interval {{ peer_info['required-minimum-receive'] }} +{% endif %} +{% if (peer_info['detection-multiplier'] is defined and peer_info['detection-multiplier'] | int != 3) %} + detect-multiplier {{ peer_info['detection-multiplier'] }} +{% endif %} +{% if (peer_info['enabled'] is defined and peer_info['enabled'] == 'true') %} + no shutdown +{% else %} + shutdown +{% endif %} + ! +{% endfor %} +! +{% endif %} +{% endblock bfd_mhop_peers%} diff --git a/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.addr_family.evpn.j2 b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.addr_family.evpn.j2 new file mode 100644 index 000000000000..c0db96c24dd7 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.addr_family.evpn.j2 @@ -0,0 +1,78 @@ +{% if 'advertise-all-vni' in af_val and af_val['advertise-all-vni'] == 'true' %} + advertise-all-vni +{% endif %} +{% if 'autort' in af_val %} + autort {{af_val['autort']}} +{% endif %} +{% if 'advertise-default-gw' in af_val and af_val['advertise-default-gw'] == 'true' %} + advertise-default-gw +{% endif %} +{% if 'dad-enabled' in af_val and 'dad-max-moves' in af_val and 'dad-time' in af_val %} + dup-addr-detection max-moves {{af_val['dad-max-moves']}} time {{af_val['dad-time']}} +{% endif %} +{% if 'dad-freeze' in af_val %} + dup-addr-detection freeze {{af_val['dad-freeze']}} +{% endif %} +{% if 'advertise-ipv4-unicast' in af_val and af_val['advertise-ipv4-unicast'] == 'true' %} + advertise ipv4 unicast +{% endif %} +{% if 'advertise-ipv6-unicast' in af_val and af_val['advertise-ipv6-unicast'] == 'true' %} + advertise ipv6 unicast +{% endif %} +{% if 'default-originate-ipv4' in af_val and af_val['default-originate-ipv4'] == 'true' %} + default-originate ipv4 +{% endif %} +{% if 'default-originate-ipv6' in af_val and af_val['default-originate-ipv6'] == 'true' %} + default-originate ipv6 +{% endif %} +{% if 'route-distinguisher' in af_val %} + rd {{af_val['route-distinguisher']}} +{% endif %} +{% if 'import-rts' in af_val %} +{% for irt in af_val['import-rts'] %} + route-target import {{irt}} +{% endfor %} +{% endif %} +{% if 'export-rts' in af_val %} +{% for irt in af_val['export-rts'] %} + route-target export {{irt}} +{% endfor %} +{% endif %} +{% if BGP_GLOBALS_EVPN_RT is defined and BGP_GLOBALS_EVPN_RT|length > 0 %} +{% for evpn_rt_key, evpn_rt_val in BGP_GLOBALS_EVPN_RT.items() %} +{% if vrf == evpn_rt_key[0] %} + route-target {{evpn_rt_val['route-target-type']}} {{evpn_rt_key[2]}} +{% endif %} +{% endfor %} +{% endif %} +{% if BGP_GLOBALS_EVPN_VNI is defined and BGP_GLOBALS_EVPN_VNI|length > 0 %} +{% for vni_key, vni_val in BGP_GLOBALS_EVPN_VNI.items() %} +{% if vrf == vni_key[0] %} + vni {{vni_key[2]}} +{% if 'route-distinguisher' in vni_val %} + rd {{vni_val['route-distinguisher']}} +{% endif %} +{% if 'import-rts' in vni_val %} +{% for irt in vni_val['import-rts'] %} + route-target import {{irt}} +{% endfor %} +{% endif %} +{% if 'export-rts' in vni_val %} +{% for irt in vni_val['export-rts'] %} + route-target export {{irt}} +{% endfor %} +{% endif %} +{% if BGP_GLOBALS_EVPN_VNI_RT is defined and BGP_GLOBALS_EVPN_VNI_RT|length > 0 %} +{% for vni_rt_key, vni_rt_val in BGP_GLOBALS_EVPN_VNI_RT.items() %} +{% if vrf == vni_rt_key[0] and vni_key[2] == vni_rt_key[2] %} + route-target {{vni_rt_val['route-target-type']}} {{vni_rt_key[3]}} +{% endif %} +{% endfor %} +{% endif %} +{% if 'advertise-default-gw' in vni_val and vni_val['advertise-default-gw'] == 'true' %} + advertise-default-gw +{% endif %} + exit-vni +{% endif %} +{% endfor %} +{% endif %} \ No newline at end of file diff --git a/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.addr_family.j2 b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.addr_family.j2 new file mode 100644 index 000000000000..9bf005518cc3 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.addr_family.j2 @@ -0,0 +1,143 @@ +{# -----------------------------------------------------------------------------------------#} +{# this is invoked with the "vrf" variable set #} +{# -----------------------------------------------------------------------------------------#} +{# -------address-family --------------------------- #} +{% if (BGP_GLOBALS_AF is defined and BGP_GLOBALS_AF|length > 0) or + (BGP_GLOBALS_AF_NETWORK is defined and BGP_GLOBALS_AF_NETWORK|length > 0) or + (BGP_GLOBALS_AF_AGGREGATE_ADDR is defined and BGP_GLOBALS_AF_AGGREGATE_ADDR|length > 0) or + (ROUTE_REDISTRIBUTE is defined and ROUTE_REDISTRIBUTE|length > 0) or + (BGP_PEER_GROUP_AF is defined and BGP_PEER_GROUP_AF|length > 0) or + (BGP_NEIGHBOR_AF is defined and BGP_NEIGHBOR_AF|length > 0) %} +{% set af_str_map = { 'ipv4_unicast': 'ipv4', 'ipv6_unicast':'ipv6', 'l2vpn_evpn':'l2vpn'} %} +{% set safi_str_map = { 'ipv4_unicast': 'unicast', 'ipv6_unicast':'unicast', 'l2vpn_evpn':'evpn'} %} +{% for af, af_str in af_str_map|dictsort %} + ! + address-family {{af_str}} {{safi_str_map[af]}} +{% if BGP_GLOBALS_AF is defined and BGP_GLOBALS_AF|length > 0 %} +{% for af_key, af_val in BGP_GLOBALS_AF.items() %} +{% if vrf == af_key[0] and af == af_key[1] %} +{% if 'ebgp_route_distance' in af_val and 'ibgp_route_distance' in af_val and 'local_route_distance' in af_val %} + distance bgp {{af_val['ebgp_route_distance']}} {{af_val['ibgp_route_distance']}} {{af_val['local_route_distance']}} +{% endif %} +{% if 'import_vrf' in af_val %} + import vrf {{af_val['import_vrf']}} +{% endif %} +{% if 'import_vrf_route_map' in af_val %} + import vrf route-map {{af_val['import_vrf_route_map']}} +{% endif %} +{% endif %} +{% endfor %} +{% endif %} +{# ------- network-prefix --------------------------- #} +{% if BGP_GLOBALS_AF_NETWORK is defined and BGP_GLOBALS_AF_NETWORK|length > 0 %} +{% for af_nw_key, af_nw_val in BGP_GLOBALS_AF_NETWORK.items() %} +{% if vrf == af_nw_key[0] and af == af_nw_key[1] %} +{% set af_nw_ns = namespace(nw_end = '') %} +{% if 'backdoor' in af_nw_val and af_nw_val['backdoor'] == 'true' %} +{% set af_nw_ns.nw_end = 'backdoor ' %} +{% endif %} +{% if 'policy' in af_nw_val %} +{% set af_nw_ns.nw_end = af_nw_ns.nw_end + 'route-map ' + af_nw_val['policy'] %} +{% endif %} + network {{af_nw_key[2]}} {{af_nw_ns.nw_end}} +{% endif %} +{% endfor %} +{% endif %} +{# ------- network-prefix end --------------------------- #} +{# ------- aggregate-prefix -Start--------------------------- #} +{% if BGP_GLOBALS_AF_AGGREGATE_ADDR is defined and BGP_GLOBALS_AF_AGGREGATE_ADDR|length > 0 %} +{% for af_ag_key, af_ag_val in BGP_GLOBALS_AF_AGGREGATE_ADDR.items() %} +{% set af_ag_ns = namespace(ag_end = '') %} +{% if vrf == af_ag_key[0] and af == af_ag_key[1] %} +{% if 'as_set' in af_ag_val and af_ag_val['as_set'] == 'true' %} +{% set af_ag_ns.ag_end = 'as-set ' %} +{% endif %} +{% if 'summary_only' in af_ag_val and af_ag_val['summary_only'] == 'true' %} +{% set af_ag_ns.ag_end = af_ag_ns.ag_end + 'summary-only' %} +{% endif %} + aggregate-address {{af_ag_key[2]}} {{af_ag_ns.ag_end}} +{% endif %} +{% endfor %} +{% endif %} +{# ------- aggregate-prefix - End --------------------------- #} +{# ------- redistribute - Start --------------------------- #} +{% if ROUTE_REDISTRIBUTE is defined and ROUTE_REDISTRIBUTE|length > 0 %} +{% for rr_key, rr_val in ROUTE_REDISTRIBUTE.items() %} +{% if vrf == rr_key[0] and af_str == rr_key[3] %} +{% if 'route_map' in rr_val %} +{% for rmap in rr_val['route_map'] %} + redistribute {{rr_key[1]}} route-map {{rmap}} +{% endfor %} +{% else %} + redistribute {{rr_key[1]}} +{% endif %} +{% endif %} +{% endfor %} +{% endif %} +{# ------- redistribute - End ----------------------------- #} +{# ------- peer-group af--------------------------- #} +{% if BGP_PEER_GROUP_AF is defined and BGP_PEER_GROUP_AF|length > 0 %} +{% for n_af_key, n_af_val in BGP_PEER_GROUP_AF.items() %} +{% if vrf == n_af_key[0] and af == n_af_key[2] %} +{% set nbr_name = n_af_key[1] %} +{% include "bgpd.conf.db.nbr_af.j2" %} +{% endif %} +{% endfor %} +{% endif %} +{# ------- peer-group af end --------------------------- #} +{# ------- neighbor af--------------------------- #} +{% if BGP_NEIGHBOR_AF is defined and BGP_NEIGHBOR_AF|length > 0 %} +{% for n_af_key, n_af_val in BGP_NEIGHBOR_AF.items() %} +{% if vrf == n_af_key[0] and af == n_af_key[2] %} +{% set nbr_name = n_af_key[1] %} +{% include "bgpd.conf.db.nbr_af.j2" %} +{% endif %} +{% endfor %} +{% endif %} +{# ------- neighbor af end --------------------------- #} +{% if BGP_GLOBALS_AF is defined and BGP_GLOBALS_AF|length > 0 %} +{% for af_key, af_val in BGP_GLOBALS_AF.items() %} +{% if vrf == af_key[0] and af == af_key[1] %} +{# -------bgp dampen - start--------------------------- #} +{% if 'route_flap_dampen' in af_val and af_val['route_flap_dampen'] == 'true' %} +{% set ns = namespace(route_dampen = '') %} +{% if 'route_flap_dampen_half_life' in af_val %} +{% set ns.route_dampen = ns.route_dampen + af_val['route_flap_dampen_half_life'] + ' ' %} +{% if 'route_flap_dampen_reuse_threshold' in af_val %} +{% set ns.route_dampen = ns.route_dampen + af_val['route_flap_dampen_reuse_threshold'] + ' ' %} +{% if 'route_flap_dampen_suppress_threshold' in af_val %} +{% set ns.route_dampen = ns.route_dampen + af_val['route_flap_dampen_suppress_threshold'] + ' ' %} +{% if 'route_flap_dampen_max_suppress' in af_val %} +{% set ns.route_dampen = ns.route_dampen + af_val['route_flap_dampen_max_suppress'] + ' ' %} +{% endif %} +{% endif %} +{% endif %} +{% endif %} + bgp dampening {{ns.route_dampen}} +{% endif %} +{# -------bgp dampen - end --------------------------- #} +{% if 'max_ebgp_paths' in af_val %} + maximum-paths {{af_val['max_ebgp_paths']}} +{% endif %} +{% if 'max_ibgp_paths' in af_val %} +{% set ns = namespace(max_ibgp = af_val['max_ibgp_paths']) %} +{% if 'ibgp_equal_cluster_length' in af_val and af_val['ibgp_equal_cluster_length'] == 'true' %} +{% set ns.max_ibgp = ns.max_ibgp + ' equal-cluster-length' %} +{% endif %} + maximum-paths ibgp {{ns.max_ibgp}} +{% endif %} +{% if 'route_download_filter' in af_val %} + table-map {{af_val['route_download_filter']}} +{% endif %} +{# -------bgp evpn - start --------------------------- #} +{% if af == 'l2vpn_evpn' %} +{% include "bgpd.conf.db.addr_family.evpn.j2" %} +{% endif %} +{# -------bgp evpn - end --------------------------- #} +{% endif %} +{% endfor %} +{% endif %} + exit-address-family +{% endfor %} +{% endif %} +{# -------address-family end --------------------------- #} diff --git a/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.comm_list.j2 b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.comm_list.j2 new file mode 100644 index 000000000000..3fcce07ddc9c --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.comm_list.j2 @@ -0,0 +1,54 @@ +{# ------------------------------------------------------------------------------------ #} +{% if (COMMUNITY_SET is defined and COMMUNITY_SET|length > 0) or + (EXTENDED_COMMUNITY_SET is defined and EXTENDED_COMMUNITY_SET|length >0) %} +! +{% endif %} +{# ------------------------------------------------------------------------------------ #} +{% if COMMUNITY_SET is defined and COMMUNITY_SET|length > 0 %} +{% for cm_key, cm_val in COMMUNITY_SET.items() %} +{% if 'set_type' in cm_val and 'match_action' in cm_val and 'community_member' in cm_val %} +{% if cm_val['match_action']|lower == 'all' %} +{% set ns = namespace(cm_list = '') %} +{% for cm in cm_val['community_member'] %} +{% set ns.cm_list = ns.cm_list + cm + ' ' %} +{% endfor %} +bgp community-list {{cm_val['set_type']|lower}} {{cm_key}} permit {{ns.cm_list}} +{% elif cm_val['match_action']|lower == 'any' %} +{% for cm in cm_val['community_member'] %} +bgp community-list {{cm_val['set_type']|lower}} {{cm_key}} permit {{cm}} +{% endfor %} +{% endif %} +{% endif %} +{% endfor %} +{% endif %} +{# ------------------------------------------------------------------------------------ #} +{% if EXTENDED_COMMUNITY_SET is defined and EXTENDED_COMMUNITY_SET|length > 0 %} +{% for cm_key, cm_val in EXTENDED_COMMUNITY_SET.items() %} +{% if 'set_type' in cm_val and 'match_action' in cm_val and 'community_member' in cm_val %} +{% if cm_val['match_action']|lower == 'all' %} +{% set ns = namespace(cm_list = '') %} +{% for cm in cm_val['community_member'] %} +{% if 'route-target' in cm %} +{% set ns.cm_list = ns.cm_list + 'rt ' + cm[13:] + ' ' %} +{% elif 'route-origin' in cm %} +{% set ns.cm_list = ns.cm_list + 'soo ' + cm[13:] + ' ' %} +{% else %} +{% set ns.cm_list = ns.cm_list + cm + ' ' %} +{% endif %} +{% endfor %} +bgp extcommunity-list {{cm_val['set_type']|lower}} {{cm_key}} permit {{ns.cm_list}} +{% elif cm_val['match_action']|lower == 'any' %} +{% for cm in cm_val['community_member'] %} +{% if 'route-target' in cm %} +bgp extcommunity-list {{cm_val['set_type']|lower}} {{cm_key}} permit rt {{cm[13:]}} +{% elif 'route-origin' in cm %} +bgp extcommunity-list {{cm_val['set_type']|lower}} {{cm_key}} permit soo {{cm[13:]}} +{% else %} +bgp extcommunity-list {{cm_val['set_type']|lower}} {{cm_key}} permit {{cm}} +{% endif %} +{% endfor %} +{% endif %} +{% endif %} +{% endfor %} +{% endif %} +{# ------------------------------------------------------------------------------------ #} diff --git a/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.j2 b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.j2 new file mode 100644 index 000000000000..4b49813e4c93 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.j2 @@ -0,0 +1,204 @@ +! template: bgpd/bgpd.conf.db.j2 +! +! BGP configuration using config DB BGP instance tables +! +{# ------------------------------------------------------------------------------------ #} +{% include "bgpd.conf.db.pref_list.j2" %} +{# ------------------------------------------------------------------------------------ #} +{# ------------------------------------------------------------------------------------ #} +{% include "bgpd.conf.db.route_map.j2" %} +{# ------------------------------------------------------------------------------------ #} +{% if AS_PATH_SET is defined and AS_PATH_SET|length > 0 %} +! +{% for key, val in AS_PATH_SET.items() %} +{% if 'as_path_set_member' in val %} +{% for path in val['as_path_set_member'] %} +bgp as-path access-list {{key}} permit {{path}} +{% endfor %} +{% endif %} +{% endfor %} +{% endif %} +{# ------------------------------------------------------------------------------------ #} +{% include "bgpd.conf.db.comm_list.j2" %} +{# ------------------------------------------------------------------------------------ #} +{% if BGP_GLOBALS is defined and BGP_GLOBALS|length > 0 %} +{% for vrf, bgp_sess in BGP_GLOBALS.items() %} +{% if 'local_asn' in bgp_sess %} +! +{% if vrf == 'default' %} +router bgp {{ bgp_sess['local_asn']}} +{% else %} +router bgp {{ bgp_sess['local_asn']}} vrf {{ vrf }} +{% endif %} +{% if 'fast_external_failover' in bgp_sess and bgp_sess['fast_external_failover'] == 'false' %} + no bgp fast-external-failover +{% endif %} +{% if 'router_id' in bgp_sess %} + bgp router-id {{bgp_sess['router_id']}} +{% endif %} +{% if 'log_nbr_state_changes' in bgp_sess and bgp_sess['log_nbr_state_changes'] == 'true' %} + bgp log-neighbor-changes +{% endif %} +{% if 'always_compare_med' in bgp_sess and bgp_sess['always_compare_med'] == 'true' %} + bgp always-compare-med +{% endif %} +{# --------------------------bgp default - start -------------------------------------- #} +{% if 'default_ipv4_unicast' in bgp_sess and bgp_sess['default_ipv4_unicast'] == 'true' %} + bgp default ipv4-unicast +{% else %} + no bgp default ipv4-unicast +{% endif %} +{% if 'default_local_preference' in bgp_sess %} + bgp default local-preference {{bgp_sess['default_local_preference']}} +{% endif %} +{% if 'default_show_hostname' in bgp_sess and bgp_sess['default_show_hostname'] == 'true' %} + bgp default show-hostname +{% endif %} +{% if 'default_shutdown' in bgp_sess and bgp_sess['default_shutdown'] == 'true' %} + bgp default shutdown +{% endif %} +{% if 'default_subgroup_pkt_queue_max' in bgp_sess %} + bgp default subgroup-pkt-queue-max {{bgp_sess['default_subgroup_pkt_queue_max']}} +{% endif %} +{# --------------------------bgp default - end ---------------------------------------- #} +{% if 'rr_clnt_to_clnt_reflection' in bgp_sess and bgp_sess['rr_clnt_to_clnt_reflection'] == 'false' %} + no bgp client-to-client reflection +{% endif %} +{% if 'rr_cluster_id' in bgp_sess %} + bgp cluster-id {{bgp_sess['rr_cluster_id']}} +{% endif %} +{% if 'disable_ebgp_connected_rt_check' in bgp_sess and bgp_sess['disable_ebgp_connected_rt_check'] == 'true' %} + bgp disable-ebgp-connected-route-check +{% endif %} +{% if 'deterministic_med' in bgp_sess and bgp_sess['deterministic_med'] == 'true' %} + bgp deterministic-med +{% endif %} +{% if 'max_delay' in bgp_sess %} +{% set ns = namespace(max_delay = '') %} +{% set ns.max_delay = ns.max_delay + bgp_sess['max_delay'] %} +{% if 'establish_wait' in bgp_sess %} +{% set ns.max_delay = ns.max_delay + ' ' + bgp_sess['establish_wait'] %} +{% endif %} + update-delay {{ns.max_delay}} +{% endif %} +{% if 'max_med_time' in bgp_sess %} +{% set ns = namespace(max_med = '') %} +{% set ns.max_med = ns.max_med + bgp_sess['max_med_time'] %} +{% if 'max_med_val' in bgp_sess %} +{% set ns.max_med = ns.max_med + ' ' + bgp_sess['max_med_val'] %} +{% endif %} + bgp max-med on-startup {{ns.max_med}} +{% endif %} +{% if 'max_med_admin' in bgp_sess %} +{% set adm_ns = namespace(admin_val = '') %} +{% if 'max_med_admin_val' in bgp_sess %} +{% set adm_ns.admin_val = adm_ns.admin_val + ' ' + bgp_sess['max_med_admin_val'] %} +{% endif %} + bgp max-med administrative {{adm_ns.admin_val}} +{% endif %} +{% if 'read_quanta' in bgp_sess %} + read-quanta {{bgp_sess['read_quanta']}} +{% endif %} +{% if 'write_quanta' in bgp_sess %} + write-quanta {{bgp_sess['write_quanta']}} +{% endif %} +{% if 'coalesce_time' in bgp_sess %} + coalesce-time {{bgp_sess['coalesce_time']}} +{% endif %} +{# --------------------------bgp graceful-restart - start ----------------------------- #} +{% if 'gr_stale_routes_time' in bgp_sess %} + bgp graceful-restart stalepath-time {{bgp_sess['gr_stale_routes_time']}} +{% endif %} +{% if 'gr_restart_time' in bgp_sess %} + bgp graceful-restart restart-time {{bgp_sess['gr_restart_time']}} +{% endif %} +{% if 'graceful_restart_enable' in bgp_sess and bgp_sess['graceful_restart_enable'] == 'true' %} + bgp graceful-restart +{% endif %} +{% if 'graceful_shutdown' in bgp_sess and bgp_sess['graceful_shutdown'] == 'true' %} + bgp graceful-shutdown +{% endif %} +{% if 'gr_preserve_fw_state' in bgp_sess and bgp_sess['gr_preserve_fw_state'] == 'true' %} + bgp graceful-restart preserve-fw-state +{% endif %} +{# --------------------------bgp graceful-restart - end ----------------------------- #} +{# --------------------------bgp bestpath as-path - start ----------------------------- #} +{% if 'ignore_as_path_length' in bgp_sess %} + bgp bestpath as-path ignore +{% endif %} +{% if 'compare_confed_as_path' in bgp_sess and bgp_sess['compare_confed_as_path'] == 'true' %} + bgp bestpath as-path confed +{% endif %} +{% if 'load_balance_mp_relax' in bgp_sess and bgp_sess['load_balance_mp_relax'] == 'true' %} +{% set mp_ns = namespace(mp_val = '') %} +{% if 'as_path_mp_as_set' in bgp_sess and bgp_sess['as_path_mp_as_set'] == 'true' %} +{% set mp_ns.mp_val = mp_ns.mp_val + 'as-set' %} +{% elif 'as_path_mp_as_set' in bgp_sess and bgp_sess['as_path_mp_as_set'] == 'false' %} +{% set mp_ns.mp_val = mp_ns.mp_val + 'no-as-set' %} +{% endif %} + bgp bestpath as-path multipath-relax {{mp_ns.mp_val}} +{% endif %} +{# --------------------------bgp bestpath as-path - end ----------------------------- #} +{% if 'rr_allow_out_policy' in bgp_sess and bgp_sess['rr_allow_out_policy'] == 'true' %} + bgp route-reflector allow-outbound-policy +{% endif %} +{% if 'external_compare_router_id' in bgp_sess %} + bgp bestpath compare-routerid +{% endif %} +{% if 'med_confed' in bgp_sess and bgp_sess['med_confed'] == 'true' %} + bgp bestpath med confed +{% endif %} +{% if 'med_missing_as_worst' in bgp_sess and bgp_sess['med_missing_as_worst'] == 'true' %} + bgp bestpath med confed missing-as-worst +{% endif %} +{% if 'network_import_check' in bgp_sess and bgp_sess['network_import_check'] == 'true' %} + bgp network import-check +{% endif %} +{# -------globals end --------------------------- #} +{# -------peer-group --------------------------- #} +{% if BGP_PEER_GROUP is defined and BGP_PEER_GROUP|length > 0 %} +{% for peer_group, nbr_or_peer in BGP_PEER_GROUP.items() %} +{% if vrf == peer_group[0] %} +{% set name_or_ip = peer_group[1] %} +{% set nbr_or_peer_type = 'peer-group' %} +{% include "bgpd.conf.db.nbr_or_peer.j2" %} +{% endif %} +{% endfor %} +{% endif %} +{# -------peer-group end --------------------------- #} +{# -------neighbor --------------------------- #} +{% if BGP_NEIGHBOR is defined and BGP_NEIGHBOR|length > 0 %} +{% for nbr_addr, nbr_or_peer in BGP_NEIGHBOR.items() %} +{% if nbr_addr is not string and nbr_addr|length > 1 %} +{% if vrf == nbr_addr[0] %} +{% set name_or_ip = nbr_addr[1] %} +{% set nbr_or_peer_type = 'neighbor' %} +{% include "bgpd.conf.db.nbr_or_peer.j2" %} +{% endif %} +{% endif %} +{% endfor %} +{% endif %} +{# -------neighbor end --------------------------- #} +{% if 'max_dynamic_neighbors' in bgp_sess %} + bgp listen limit {{bgp_sess['max_dynamic_neighbors']}} +{% endif %} +{% if 'route_map_process_delay' in bgp_sess %} + bgp route-map delay-timer {{bgp_sess['route_map_process_delay']}} +{% endif %} +{# -------listen-prefix --------------------------- #} +{% if BGP_GLOBALS_LISTEN_PREFIX is defined and BGP_GLOBALS_LISTEN_PREFIX|length > 0 %} +{% for lpfx, lpfx_val in BGP_GLOBALS_LISTEN_PREFIX.items() %} +{% if vrf == lpfx[0] %} +{% if 'peer_group' in lpfx_val %} + bgp listen range {{lpfx[1]}} peer-group {{lpfx_val['peer_group']}} +{% endif %} +{% endif %} +{% endfor %} +{% endif %} +{# -------listen-prefix end --------------------------- #} +{# -------address-family --------------------------- #} +{% include "bgpd.conf.db.addr_family.j2" %} +{# -------address-family --------------------------- #} +{% endif %} +{% endfor %} +{% endif %} diff --git a/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.nbr_af.j2 b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.nbr_af.j2 new file mode 100644 index 000000000000..8afb64e991cc --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.nbr_af.j2 @@ -0,0 +1,150 @@ +{# ------------------------------------------------------------ #} +{# this is called with the "vrf" and "address-family matched #} +{# ------------------------------------------------------------ #} +{% if 'admin_status' in n_af_val %} +{% if n_af_val['admin_status'] == 'true' %} + neighbor {{nbr_name}} activate +{% else %} + no neighbor {{nbr_name}} activate +{% endif %} +{% endif %} +{% if 'tx_add_paths' in n_af_val %} +{% if n_af_val['tx_add_paths'] == 'tx_all_paths' %} + neighbor {{nbr_name}} addpath-tx-all-paths +{% elif n_af_val['tx_add_paths'] == 'tx_best_path_per_as' %} + neighbor {{nbr_name}} addpath-tx-bestpath-per-AS +{% endif %} +{% endif %} +{% if 'nhself' in n_af_val and n_af_val['nhself'] == 'true' %} +{% if 'nexthop_self_force' in n_af_val and n_af_val['nexthop_self_force'] == 'true' %} + neighbor {{nbr_name}} next-hop-self force +{% else %} + neighbor {{nbr_name}} next-hop-self +{% endif %} +{% endif %} +{% if 'remove_private_as_enabled' in n_af_val and n_af_val['remove_private_as_enabled'] == 'true' %} +{% set ns = namespace(rpas_str='') %} +{% if 'remove_private_as_all' in n_af_val and n_af_val['remove_private_as_all'] == 'true' %} +{% set ns.rpas_str = ns.rpas_str + ' all' %} +{% endif %} +{% if 'replace_private_as' in n_af_val and n_af_val['replace_private_as'] == 'true' %} +{% set ns.rpas_str = ns.rpas_str + ' replace-AS' %} +{% endif %} + neighbor {{nbr_name}} remove-private-AS{{ns.rpas_str}} +{% endif %} +{% if 'send_community' in n_af_val %} +{% if n_af_val['send_community'] == 'standard' %} + no neighbor {{nbr_name}} send-community extended + no neighbor {{nbr_name}} send-community large +{% elif n_af_val['send_community'] == 'extended' %} + no neighbor {{nbr_name}} send-community + no neighbor {{nbr_name}} send-community large +{% elif n_af_val['send_community'] == 'large' %} + no neighbor {{nbr_name}} send-community + no neighbor {{nbr_name}} send-community extended +{% elif n_af_val['send_community'] == 'both' %} + no neighbor {{nbr_name}} send-community large +{% elif n_af_val['send_community'] == 'none' %} + no neighbor {{nbr_name}} send-community all +{% endif %} +{% endif %} +{% if 'as_override' in n_af_val and n_af_val['as_override'] == 'true' %} + neighbor {{nbr_name}} as-override +{% endif %} +{% if 'send_default_route' in n_af_val and n_af_val['send_default_route'] == 'true' %} +{% if 'default_rmap' in n_af_val %} + neighbor {{nbr_name}} default-originate route-map {{n_af_val['default_rmap']}} +{% else %} + neighbor {{nbr_name}} default-originate +{% endif %} +{% endif %} +{% if 'rrclient' in n_af_val and n_af_val['rrclient'] == 'true' %} + neighbor {{nbr_name}} route-reflector-client +{% endif %} +{% if 'soft_reconfiguration_in' in n_af_val and n_af_val['soft_reconfiguration_in'] == 'true' %} + neighbor {{nbr_name}} soft-reconfiguration inbound +{% endif %} +{# ------- maximum-prefix --------------------------- #} +{% if 'max_prefix_limit' in n_af_val %} +{% set ns = namespace(mpfx_str='maximum-prefix ' + n_af_val['max_prefix_limit']) %} +{% if 'max_prefix_warning_threshold' in n_af_val %} +{% set ns.mpfx_str = ns.mpfx_str + ' ' + n_af_val['max_prefix_warning_threshold'] %} +{% endif %} +{% if 'max_prefix_restart_interval' in n_af_val %} +{% set ns.mpfx_str = ns.mpfx_str + ' restart ' + n_af_val['max_prefix_restart_interval'] %} +{% elif 'max_prefix_warning_only' in n_af_val and n_af_val['max_prefix_warning_only'] == 'true' %} +{% set ns.mpfx_str = ns.mpfx_str + ' warning-only' %} +{% endif %} + neighbor {{nbr_name}} {{ns.mpfx_str}} +{% endif %} +{# ------- maximum-prefix end --------------------------- #} +{% if 'route_server_client' in n_af_val and n_af_val['route_server_client'] == 'true' %} + neighbor {{nbr_name}} route-server-client +{% endif %} +{# ------- allow-as --------------------------- #} +{% if 'allow_as_in' in n_af_val and n_af_val['allow_as_in'] == 'true' %} +{% if 'allow_as_origin' in n_af_val and n_af_val['allow_as_origin'] == 'true' %} + neighbor {{nbr_name}} allowas-in origin +{% elif 'allow_as_count' in n_af_val %} + neighbor {{nbr_name}} allowas-in {{n_af_val['allow_as_count']}} +{% else %} + neighbor {{nbr_name}} allowas-in +{% endif %} +{% endif %} +{# ------- allow-as end --------------------------- #} +{% if 'add_path_tx_all' in n_af_val and n_af_val['add_path_tx_all'] == 'true' %} + neighbor {{nbr_name}} addpath-tx-all-paths +{% endif %} +{% if 'add_path_tx_bestpath' in n_af_val and n_af_val['add_path_tx_bestpath'] == 'true' %} + neighbor {{nbr_name}} addpath-tx-bestpath-per-AS +{% endif %} +{% if 'cap_orf' in n_af_val %} + neighbor {{nbr_name}} capability orf prefix-list {{n_af_val['cap_orf']}} +{% endif %} +{% if 'weight' in n_af_val %} + neighbor {{nbr_name}} weight {{n_af_val['weight']}} +{% endif %} +{% if 'prefix_list_in' in n_af_val %} + neighbor {{nbr_name}} prefix-list {{n_af_val['prefix_list_in']}} in +{% endif %} +{% if 'prefix_list_out' in n_af_val %} + neighbor {{nbr_name}} prefix-list {{n_af_val['prefix_list_out']}} out +{% endif %} +{# ------- route-map in --------------------------- #} +{% if 'route_map_in' in n_af_val %} +{% for map in n_af_val['route_map_in'] %} + neighbor {{nbr_name}} route-map {{map}} in +{% endfor %} +{% endif %} +{# ------- route-map in end --------------------------- #} +{# ------- route-map out --------------------------- #} +{% if 'route_map_out' in n_af_val %} +{% for map in n_af_val['route_map_out'] %} + neighbor {{nbr_name}} route-map {{map}} out +{% endfor %} +{% endif %} +{# ------- route-map out end --------------------------- #} +{% if 'unsuppress_map_name' in n_af_val %} + neighbor {{nbr_name}} unsuppress-map {{n_af_val['unsuppress_map_name']}} +{% endif %} +{% if 'filter_list_in' in n_af_val %} + neighbor {{nbr_name}} filter-list {{n_af_val['filter_list_in']}} in +{% endif %} +{% if 'filter_list_out' in n_af_val %} + neighbor {{nbr_name}} filter-list {{n_af_val['filter_list_out']}} out +{% endif %} +{# ------- attribute-unchanged --------------------------- #} +{% set attr = '' %} +{% if 'unchanged_as_path' in n_af_val and n_af_val['unchanged_as_path'] == 'true' %} +{% set attr = 'as-path ' %} +{% endif %} +{% if 'unchanged_med' in n_af_val and n_af_val['unchanged_med'] == 'true' %} +{% set attr = attr + 'med ' %} +{% endif %} +{% if 'unchanged_nexthop' in n_af_val and n_af_val['unchanged_nexthop'] == 'true' %} +{% set attr = attr + 'next-hop' %} +{% endif %} +{% if attr != '' %} + neighbor {{nbr_name}} attribute-unchanged {{attr}} +{% endif %} +{# ------- attribute-unchanged end --------------------------- #} diff --git a/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.nbr_or_peer.j2 b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.nbr_or_peer.j2 new file mode 100644 index 000000000000..8fc5e061ad56 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.nbr_or_peer.j2 @@ -0,0 +1,103 @@ +{# ------------------------------------------------------------- #} +{# this is called with the "vrf" matched #} +{# nbr_or_peer contains the information for the neighbor or peer #} +{# name_or_ip will be the IP or the name of the neighbor or peer #} +{# ------------------------------------------------------------- #} +{% set ns_intf = namespace(intf_arg = '') %} +{% if nbr_or_peer_type == 'peer-group' %} + neighbor {{name_or_ip}} peer-group +{% else %} +{% if not (name_or_ip | ipv4 or name_or_ip | ipv6) %} +{% set ns_intf.intf_arg = 'interface ' %} +{% endif %} +{% endif %} +{% set remote_as = '' %} +{% if 'asn' in nbr_or_peer %} +{% set remote_as = nbr_or_peer['asn'] %} +{% endif %} +{% if 'peer_type' in nbr_or_peer %} +{% set remote_as = nbr_or_peer['peer_type'] %} +{% endif %} +{% if remote_as != '' %} + neighbor {{name_or_ip}} {{ns_intf.intf_arg}}remote-as {{remote_as}} +{% endif %} +{% if 'peer_group_name' in nbr_or_peer %} + neighbor {{name_or_ip}} {{ns_intf.intf_arg}}peer-group {{nbr_or_peer['peer_group_name']}} +{% endif %} +{% if 'local_asn' in nbr_or_peer %} + neighbor {{name_or_ip}} local-as {{nbr_or_peer['local_asn']}} +{% endif %} +{% if 'name' in nbr_or_peer %} + neighbor {{name_or_ip}} description {{nbr_or_peer['name']}} +{% endif %} +{% if 'admin_status' in nbr_or_peer and nbr_or_peer['admin_status'] == 'false' %} +{% if 'shutdown_message' in nbr_or_peer %} + neighbor {{name_or_ip}} shutdown message {{nbr_or_peer['shutdown_message']}} +{% else %} + neighbor {{name_or_ip}} shutdown +{% endif %} +{% endif %} +{% if 'bfd' in nbr_or_peer and nbr_or_peer['bfd'] == 'true' %} + neighbor {{name_or_ip}} bfd +{% endif %} +{% if 'ttl_security_hops' in nbr_or_peer %} + neighbor {{name_or_ip}} ttl-security hops {{nbr_or_peer['ttl_security_hops']}} +{% endif %} +{% if 'auth_password' in nbr_or_peer %} + neighbor {{name_or_ip}} password {{nbr_or_peer['auth_password']}} encrypted +{% endif %} +{% if 'solo_peer' in nbr_or_peer and nbr_or_peer['solo_peer'] == 'true' %} + neighbor {{name_or_ip}} solo +{% endif %} +{% if 'peer_port' in nbr_or_peer %} + neighbor {{name_or_ip}} port {{nbr_or_peer['peer_port']}} +{% endif %} +{% if 'passive_mode' in nbr_or_peer and nbr_or_peer['passive_mode'] == 'true' %} + neighbor {{name_or_ip}} passive +{% endif %} +{% set mhop = '' %} +{% if 'ebgp_multihop' in nbr_or_peer and nbr_or_peer['ebgp_multihop'] == 'true' %} +{% set mhop = 255 %} +{% endif %} +{% if 'ebgp_multihop_ttl' in nbr_or_peer %} +{% set mhop = nbr_or_peer['ebgp_multihop_ttl'] %} +{% endif %} +{% if mhop != '' %} + neighbor {{name_or_ip}} ebgp-multihop {{mhop}} +{% endif %} +{% if 'disable_ebgp_connected_route_check' in nbr_or_peer and nbr_or_peer['disable_ebgp_connected_route_check'] == 'true' %} + neighbor {{name_or_ip}} disable-connected-check +{% endif %} +{% if 'enforce_first_as' in nbr_or_peer and nbr_or_peer['enforce_first_as'] == 'true' %} + neighbor {{name_or_ip}} enforce-first-as +{% endif %} +{% if 'local_addr' in nbr_or_peer %} + neighbor {{name_or_ip}} update-source {{nbr_or_peer['local_addr']}} +{% endif %} +{% if 'strict_capability_match' in nbr_or_peer and nbr_or_peer['strict_capability_match'] == true %} + neighbor {{name_or_ip}} strict-capability-match {{nbr_or_peer['strict_capability_match']}} +{% endif %} +{% if 'min_adv_interval' in nbr_or_peer %} + neighbor {{name_or_ip}} advertisement-interval {{nbr_or_peer['min_adv_interval']}} +{% endif %} +{% if 'keepalive' in nbr_or_peer and 'holdtime' in nbr_or_peer %} + neighbor {{name_or_ip}} timers {{nbr_or_peer['keepalive']}} {{nbr_or_peer['holdtime']}} +{% endif %} +{% if 'conn_retry' in nbr_or_peer %} + neighbor {{name_or_ip}} timers connect {{nbr_or_peer['conn_retry']}} +{% endif %} +{% if 'capability_dynamic' in nbr_or_peer and nbr_or_peer['capability_dynamic'] == 'true' %} + neighbor {{name_or_ip}} capability dynamic +{% endif %} +{% if 'capability_ext_nexthop' in nbr_or_peer and nbr_or_peer['capability_ext_nexthop'] == 'true' %} + neighbor {{name_or_ip}} capability extended-nexthop +{% endif %} +{% if 'dont_negotiate_capability' in nbr_or_peer and nbr_or_peer['dont_negotiate_capability'] == 'true' %} + neighbor {{name_or_ip}} dont-capability-negotiate +{% endif %} +{% if 'enforce_multihop' in nbr_or_peer and nbr_or_peer['enforce_multihop'] == 'true' %} + neighbor {{name_or_ip}} enforce-multihop +{% endif %} +{% if 'override_capability' in nbr_or_peer and nbr_or_peer['override_capability'] == 'true' %} + neighbor {{name_or_ip}} override-capability +{% endif %} diff --git a/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.pref_list.j2 b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.pref_list.j2 new file mode 100644 index 000000000000..3409c51be06f --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.pref_list.j2 @@ -0,0 +1,30 @@ +{# ------------------------------------------------------------------------------------ #} +{% if (PREFIX_SET is defined and PREFIX_SET|length > 0) and + (PREFIX is defined and PREFIX|length > 0) %} +{% set modes = ['IPv4', 'IPv6'] %} +{% set ip_str = {'IPv4':'ip', 'IPv6':'ipv6' } %} +{% for md in modes %} +! +{% for key, val in PREFIX_SET.items() %} +{% if 'mode' in val %} +{% for pf_key, pf_val in PREFIX.items() %} +{% if pf_key[0] == key and md == val['mode'] %} +{% if pf_key[2] == 'exact' %} +{{ip_str[md]}} prefix-list {{key}} permit {{pf_key[1]}} +{% else %} +{% set len = pf_key[1].split('/')[1] %} +{% set rb = pf_key[2].split('..')[0] %} +{% set re = pf_key[2].split('..')[1] %} +{% if rb > len %} +{{ip_str[md]}} prefix-list {{key}} permit {{pf_key[1]}} ge {{rb}} le {{re}} +{% else %} +{{ip_str[md]}} prefix-list {{key}} permit {{pf_key[1]}} le {{re}} +{% endif %} +{% endif %} +{% endif %} +{% endfor %} +{% endif %} +{% endfor %} +{% endfor %} +{% endif %} +{# ------------------------------------------------------------------------------------ #} diff --git a/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.route_map.j2 b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.route_map.j2 new file mode 100644 index 000000000000..29a4817dc281 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.db.route_map.j2 @@ -0,0 +1,150 @@ +{% if ROUTE_MAP is defined and ROUTE_MAP|length > 0 %} +{% for rm_key, rm_val in ROUTE_MAP.items() %} +{% if 'route_operation' in rm_val %} +! +route-map {{rm_key[0]}} {{rm_val['route_operation']}} {{rm_key[1]}} +{% if 'match_as_path' in rm_val %} + match as-path {{rm_val['match_as_path']}} +{% endif %} +{% if 'call_route_map' in rm_val %} + call {{rm_val['call_route_map']}} +{% endif %} +{% if 'match_community' in rm_val %} + match community {{rm_val['match_community']}} +{% endif %} +{% if 'match_ext_community' in rm_val %} + match extcommunity {{rm_val['match_ext_community']}} +{% endif %} +{% if 'match_interface' in rm_val %} + match interface {{rm_val['match_interface']}} +{% endif %} +{% if 'match_tag' in rm_val %} + match tag {{rm_val['match_tag'][0]}} +{% endif %} +{% if 'match_src_vrf' in rm_val %} + match source-vrf {{rm_val['match_src_vrf']}} +{% endif %} +{# ---------------match ip/ipv6-Start-------------------------- #} +{% set ip_str = {'ipv4':'ip', 'ipv6':'ipv6' } %} +{% if PREFIX_SET is defined and PREFIX_SET|length > 0 %} +{% if 'match_prefix_set' in rm_val %} +{% for pfx_key, pfx_val in PREFIX_SET.items() %} +{% if rm_val['match_prefix_set'] == pfx_key %} + match {{ip_str[pfx_val['mode']]}} address prefix-list {{rm_val['match_prefix_set']}} +{% endif %} +{% endfor %} +{% endif %} +{% if 'match_next_hop_set' in rm_val %} +{% for pfx_key, pfx_val in PREFIX_SET.items() %} +{% if rm_val['match_next_hop_set'] == pfx_key %} + match {{ip_str[pfx_val['mode']]}} next-hop prefix-list {{rm_val['match_next_hop_set']}} +{% endif %} +{% endfor %} +{% endif %} +{% endif %} +{# ---------------match ip/ipv6- End-------------------------- #} +{% if 'match_local_pref' in rm_val %} + match local-preference {{rm_val['match_local_pref']}} +{% endif %} +{% if 'match_med' in rm_val %} + match metric {{rm_val['match_med']}} +{% endif %} +{% if 'match_origin' in rm_val %} + match origin {{rm_val['match_origin']|lower}} +{% endif %} +{% if 'match_neighbor' in rm_val %} + match peer {{rm_val['match_neighbor'][0]}} +{% endif %} +{% if 'match_protocol' in rm_val %} + match source-protocol {{rm_val['match_protocol']}} +{% endif %} +{# ---------------set as-path prepend - Start ----------------- #} +{% if 'set_asn' in rm_val and 'set_repeat_asn' in rm_val %} +{% set ns = namespace(as_str='') %} +{% if rm_val['set_repeat_asn'] > 0 %} +{% for i in range(rm_val['set_repeat_asn']|int) %} +{% set ns.as_str = ns.as_str+' '+rm_val['set_asn'] %} +{% endfor %} +{% else %} +{% set ns.as_str = rm_val['set_asn'] %} +{% endif %} + set as-path prepend{{ns.as_str}} +{% endif %} +{# ---------------set as-path prepend - End ------------------- #} +{# ---------------set community - Start------------------------ #} +{% if 'set_community_inline' in rm_val %} +{% set ns = namespace(comms = '') %} +{% for cm in rm_val['set_community_inline'] %} +{% set ns.comms = ns.comms + ' ' + cm %} +{% endfor %} + set community{{ns.comms}} +{% endif %} +{# ---------------set community - End-------------------------- #} +{% if 'set_community_ref' in rm_val %} + set community {{rm_val['set_community_ref']}} +{% endif %} +{# ---------------set extcommunity - Start--------------------- #} +{% if 'set_ext_community_inline' in rm_val %} +{% set ec_ns = namespace(rt_str='', soo_str='') %} +{% for ext_comm in rm_val['set_ext_community_inline'] %} +{% set comm = ext_comm.split(':') %} +{% if comm[0] == 'route-target' %} +{% set ec_ns.rt_str = ec_ns.rt_str+' '+comm[1]+':'+comm[2] %} +{% endif %} +{% if comm[0] == 'route-origin' %} +{% set ec_ns.soo_str = ec_ns.soo_str+' '+comm[1]+':'+comm[2] %} +{% endif %} +{% endfor %} +{% if ec_ns.rt_str != '' %} + set extcommunity rt{{ec_ns.rt_str}} +{% endif %} +{% if ec_ns.soo_str != '' %} + set extcommunity soo{{ec_ns.rt_str}} +{% endif %} +{% endif %} +{# ---------------set extcommunity - End----------------------- #} +{% if 'set_ext_community_ref' in rm_val %} + set extcommunity {{rm_val['set_ext_community_ref']}} +{% endif %} +{% if 'set_next_hop' in rm_val %} + set ip next-hop {{rm_val['set_next_hop']}} +{% endif %} +{% if 'set_ipv6_next_hop_global' in rm_val %} + set ipv6 next-hop global {{rm_val['set_ipv6_next_hop_global']}} +{% endif %} +{% if 'set_ipv6_next_hop_prefer_global' in rm_val and rm_val['set_ipv6_next_hop_prefer_global'] == 'true' %} + set ipv6 next-hop prefer-global +{% endif %} +{% if 'set_local_preference' in rm_val %} + set local-preference {{rm_val['set_local_preference']}} +{% endif %} +{# ---------------set metric and med - Start--------------------- #} +{% if 'set_metric_action' in rm_val %} +{% if 'set_metric' in rm_val %} +{% if rm_val['set_metric_action'] == 'METRIC_SET_VALUE' %} + set metric {{rm_val['set_metric']}} +{% elif rm_val['set_metric_action'] == 'METRIC_ADD_VALUE' %} + set metric +{{rm_val['set_metric']}} +{% elif rm_val['set_metric_action'] == 'METRIC_SUBTRACT_VALUE' %} + set metric -{{rm_val['set_metric']}} +{% endif %} +{% endif %} +{% if rm_val['set_metric_action'] == 'METRIC_SET_RTT' %} + set metric rtt +{% elif rm_val['set_metric_action'] == 'METRIC_ADD_RTT' %} + set metric +rtt +{% elif rm_val['set_metric_action'] == 'METRIC_SUBTRACT_RTT' %} + set metric -rtt +{% endif %} +{% elif 'set_med' in rm_val %} + set metric {{rm_val['set_med']}} +{% elif 'set_metric' in rm_val %} + set metric {{rm_val['set_metric']}} +{% endif %} +{# ---------------set metric and med - End--------------------- #} +{% if 'set_origin' in rm_val %} + set origin {{rm_val['set_origin']|lower}} +{% endif %} +{% endif %} +{% endfor %} +{% endif %} diff --git a/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.j2 b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.j2 new file mode 100644 index 000000000000..e37ad2a32056 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/bgpd/bgpd.conf.j2 @@ -0,0 +1,15 @@ +{% block banner %} +! =========== Managed by sonic-cfggen DO NOT edit manually! ==================== +! generated by templates/quagga/bgpd.conf.j2 with config DB data +! file: bgpd.conf +! +{% endblock banner %} +! +{% include "common/daemons.common.conf.j2" %} +! +agentx +! +{% include "bgpd.conf.db.j2" %} +! +! end of template: bgpd/bgpd.conf.j2 +! diff --git a/src/sonic-frr-mgmt-framework/templates/frr/frr.conf.j2 b/src/sonic-frr-mgmt-framework/templates/frr/frr.conf.j2 new file mode 100644 index 000000000000..f1f015a6e7a6 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/frr/frr.conf.j2 @@ -0,0 +1,30 @@ +! +{% block banner %} +! =========== Managed by sonic-cfggen DO NOT edit manually! ==================== +! generated by templates/frr.conf.j2 with config DB data +! file: frr.conf +! +{% endblock banner %} +! +{% include "common/daemons.common.conf.j2" %} +! +agentx +! +{% include "zebra/zebra.interfaces.conf.j2" %} +! +{% if MGMT_VRF_CONFIG %} +{% if MGMT_VRF_CONFIG['vrf_global']['mgmtVrfEnabled'] == 'false' %} +{% include "staticd.db.default_route.conf.j2" %} +{% endif %} +{% else %} +{% include "staticd.db.default_route.conf.j2" %} +{% endif %} +! +{% include "staticd.db.conf.j2" %} +! +{% include "bgpd.conf.db.j2" %} +! +{% include "ospfd.conf.j2" %} +! +{% include "bfdd.conf.j2" %} +! diff --git a/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.area.j2 b/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.area.j2 new file mode 100644 index 000000000000..4dfaad02798a --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.area.j2 @@ -0,0 +1,37 @@ +{% set areaid = areakey[1] %} +{% if 'authentication' in area_instance %} +{% if area_instance['authentication'] == "MD5HMAC" %} + area {{ areaid }} authentication message-digest +{% else %} + area {{ areaid }} authentication +{% endif %} +{% endif %} +{% if 'stub-no-summary' in area_instance %} +{% if area_instance['stub-no-summary'] == 'true' %} + area {{ areaid }} stub no-summary +{% endif %} +{% else %} +{% if 'stub' in area_instance %} +{% if area_instance['stub'] == 'true' %} + area {{ areaid }} stub +{% endif %} +{% endif %} +{% endif %} +{% if 'stub-default-cost' in area_instance %} + area {{ areaid }} default-cost {{ area_instance['stub-default-cost'] }} +{% endif %} +{% if 'import-list' in area_instance %} + area {{ areaid }} import-list {{ area_instance['import-list'] }} +{% endif %} +{% if 'export-list' in area_instance %} + area {{ areaid }} export-list {{ area_instance['export-list'] }} +{% endif %} +{% if 'filter-list-in' in area_instance %} + area {{ areaid }} filter-list prefix {{ area_instance['filter-list-in'] }} in +{% endif %} +{% if 'filter-list-out' in area_instance %} + area {{ areaid }} filter-list prefix {{ area_instance['filter-list-out'] }} out +{% endif %} +{% if 'shortcut' in area_instance %} + area {{ areaid }} shortcut {{ (area_instance['shortcut']).lower() }} +{% endif %} diff --git a/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.comm_list.j2 b/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.comm_list.j2 new file mode 100644 index 000000000000..f6fcfe897fe8 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.comm_list.j2 @@ -0,0 +1,129 @@ +{# ------------------------------------------------------------------------------------ #} +{# ------------------------------------------------------------------------------------ #} +{% if OSPFV2_ROUTER is defined and OSPFV2_ROUTER|length > 0 %} +{% for vrf, ospf_instance in OSPFV2_ROUTER.items() %} +! +router ospf vrf {{ vrf }} +{% if 'router-id' in ospf_instance %} + ospf router-id {{ ospf_instance['router-id'] }} +{% endif %} +{% if 'abr-type' in ospf_instance %} + ospf abr-type {{ (ospf_instance['abr-type']).lower() }} +{% endif %} +{% if 'auto-cost-reference-bandwidth' in ospf_instance %} + auto-cost reference-bandwidth {{ (ospf_instance['auto-cost-reference-bandwidth']) }} +{% endif %} +{% if 'log-adjacency-changes' in ospf_instance %} +{% if ospf_instance['log-adjacency-changes'] == 'DETAIL' %} + log-adjacency-changes detail +{% else %} + log-adjacency-changes +{% endif %} +{% endif %} +{% if 'default-metric' in ospf_instance %} + default-metric {{ ospf_instance['default-metric'] }} +{% endif %} +{% if 'ospf-rfc1583-compatible' in ospf_instance %} +{% if ospf_instance['ospf-rfc1583-compatible'] == 'true' %} + compatible rfc1583 +{% endif %} +{% endif %} +{% if 'passive-interface-default' in ospf_instance %} + passive-interface default +{% endif %} +{% if 'write-multiplier' in ospf_instance %} + write-multiplier {{ ospf_instance['write-multiplier'] }} +{% endif %} +{% if 'spf-throttle-delay' in ospf_instance and 'spf-initial-delay' in ospf_instance and 'spf-maximum-delay' in ospf_instance %} + timers throttle spf {{ ospf_instance['spf-throttle-delay'] }} {{ ospf_instance['spf-initial-delay'] }} {{ ospf_instance['spf-maximum-delay'] }} +{% endif %} +{% if 'lsa-min-interval-timer' in ospf_instance %} + timers throttle lsa all {{ ospf_instance['lsa-min-interval-timer'] }} +{% endif %} +{% if 'lsa-min-arrival-timer' in ospf_instance %} + timers lsa min-arrival {{ ospf_instance['lsa-min-arrival-timer'] }} +{% endif %} +{% if 'lsa-refresh-timer' in ospf_instance %} + refresh timer {{ ospf_instance['lsa-refresh-timer'] }} +{% endif %} +{% if 'max-metric-administrative' in ospf_instance %} +{% if ospf_instance['max-metric-administrative'] == 'true' %} + max-metric router-lsa administrative +{% endif %} +{% endif %} +{% if 'max-metric-on-startup' in ospf_instance %} + max-metric router-lsa on-startup {{ ospf_instance['max-metric-on-startup'] }} +{% endif %} +{% if 'max-metric-on-shutdown' in ospf_instance %} + max-metric router-lsa on-shutdown {{ ospf_instance['max-metric-on-shutdown'] }} +{% endif %} +{% if 'distance-all' in ospf_instance %} + distance {{ ospf_instance['distance-all'] }} +{% endif %} +{% if 'distance-inter-area' in ospf_instance or 'distance-intra-area' in ospf_instance or 'distance-external' in ospf_instance%} +{% set distance_cmd = '' %} +{% set distance_cmd = 'distance ospf' %} +{% if 'distance-intra-area' in ospf_instance %} +{% set distance_cmd = distance_cmd + ' intra-area ' + ospf_instance['distance-intra-area'] %} +{% endif %} +{% if 'distance-inter-area' in ospf_instance %} +{% set distance_cmd = distance_cmd + ' inter-area ' + ospf_instance['distance-inter-area'] %} +{% endif %} +{% if 'distance-external' in ospf_instance %} +{% set distance_cmd = distance_cmd + ' external ' + ospf_instance['distance-external'] %} +{% endif %} + {{ distance_cmd }} +{% endif %} +{# -------OSPFV2_ROUTER end --------------------------- #} +{# -------OSPFV2_ROUTER_AREA Begin --------------------------- #} +{% if OSPFV2_ROUTER_AREA is defined and OSPFV2_ROUTER_AREA|length > 0 %} +{% for areakey, area_instance in OSPFV2_ROUTER_AREA.items() %} +{% include "ospfd.conf.db.area.j2" %} +{% endfor %} +{% endif %} +{# -------OSPFV2_ROUTER_AREA end --------------------------- #} +{# -------OSPFV2_ROUTER_AREA_NETWORK Begin --------------------------- #} +{% if OSPFV2_ROUTER_AREA_NETWORK is defined and OSPFV2_ROUTER_AREA_NETWORK|length > 0 %} +{% for networkkey, ospf_network_instance in OSPFV2_ROUTER_AREA_NETWORK.items() %} +{% set networkareaid = networkkey[1] %} +{% set networkid = networkkey[2] %} + network {{ networkid }} area {{ networkareaid }} +{% endfor %} +{% endif %} +{# -------OSPFV2_ROUTER_AREA_NETWORK end --------------------------- #} +{# -------OSPFV2_ROUTER_AREA_VIRTUAL_LINK Begin --------------------------- #} +{% if OSPFV2_ROUTER_AREA_VIRTUAL_LINK is defined and OSPFV2_ROUTER_AREA_VIRTUAL_LINK|length > 0 %} +{% for vlinkkey, vlink_instance in OSPFV2_ROUTER_AREA_VIRTUAL_LINK.items() %} +{% include "ospfd.conf.db.vlink.j2" %} +{% endfor %} +{% endif %} +{# -------OSPFV2_ROUTER_AREA_VIRTUAL_LINK end --------------------------- #} +{# -------OSPFV2_ROUTER_AREA_POLICY_ADDRESS_RANGE Begin --------------------------- #} +{% if OSPFV2_ROUTER_AREA_POLICY_ADDRESS_RANGE is defined and OSPFV2_ROUTER_AREA_POLICY_ADDRESS_RANGE|length > 0 %} +{% for rangekey, area_range_instance in OSPFV2_ROUTER_AREA_POLICY_ADDRESS_RANGE.items() %} +{% include "ospfd.conf.db.policyrange.j2" %} +{% endfor %} +{% endif %} +{# -------OSPFV2_ROUTER_AREA_POLICY_ADDRESS_RANGE end --------------------------- #} +{# -------OSPFV2_ROUTER_DISTRIBUTE_ROUTE Begin --------------------------- #} +{% if OSPFV2_ROUTER_DISTRIBUTE_ROUTE is defined and OSPFV2_ROUTER_DISTRIBUTE_ROUTE|length > 0 %} +{% for routekey, route_instance in OSPFV2_ROUTER_DISTRIBUTE_ROUTE.items() %} +{% include "ospfd.conf.db.distributeroute.j2" %} +{% endfor %} +{% endif %} +{# -------OSPFV2_ROUTER_DISTRIBUTE_ROUTE end --------------------------- #} +{# -------OSPFV2_ROUTER_PASSIVE_INTERFACE Begin --------------------------- #} +{% if OSPFV2_ROUTER_PASSIVE_INTERFACE is defined and OSPFV2_ROUTER_PASSIVE_INTERFACE|length > 0 %} +{% for passintfkey, passintf_instance in OSPFV2_ROUTER_PASSIVE_INTERFACE.items() %} +{% set passintfname = passintfkey[1] %} +{% set passintfaddr = passintfkey[2] %} +{% if passintfaddr == '0.0.0.0' %} + passive-interface {{ passintfname }} +{% else %} + passive-interface {{ passintfname }} {{ passintfaddr }} +{% endif %} +{% endfor %} +{% endif %} +{# -------OSPFV2_ROUTER_PASSIVE_INTERFACE end --------------------------- #} +{% endfor %} +{% endif %} diff --git a/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.distributeroute.j2 b/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.distributeroute.j2 new file mode 100644 index 000000000000..d13ac7ada5b6 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.distributeroute.j2 @@ -0,0 +1,52 @@ +{% set routeproto = routekey[1] %} +{% set routedirection = routekey[2] %} +{% set generic_protocols = [ "BGP", "KERNEL", "STATIC", "DIRECTLY_CONNECTED"] %} +{% if routeproto == "DEFAULT_ROUTE" and routedirection == "IMPORT" %} +{% set defaultinfo_cmd = '' %} +{% set defaultinfo_cmd = 'default-information originate' %} +{% if 'always' in route_instance %} +{% if route_instance['always'] == 'true' %} +{% set defaultinfo_cmd = defaultinfo_cmd + ' always' %} +{% endif %} +{% endif %} +{% if 'metric' in route_instance %} +{% set defaultinfo_cmd = defaultinfo_cmd + ' metric ' + route_instance['metric'] %} +{% endif %} +{% if 'metric-type' in route_instance %} +{% if route_instance['metric-type'] == "TYPE_1"%} +{% set defaultinfo_cmd = defaultinfo_cmd + ' metric-type ' + '1' %} +{% endif %} +{% endif %} +{% if 'route-map' in route_instance %} +{% set defaultinfo_cmd = defaultinfo_cmd + ' route-map ' + route_instance['route-map'] %} +{% endif %} + {{ defaultinfo_cmd }} +{% elif routedirection == "IMPORT" and routeproto in generic_protocols %} +{% set redistribute_cmd = '' %} +{% if routeproto == "DIRECTLY_CONNECTED" %} +{% set redistribute_cmd = 'redistribute ' + 'connected' %} +{% else %} +{% set redistribute_cmd = 'redistribute ' + routeproto.lower() %} +{% endif %} +{% if 'metric' in route_instance %} +{% set redistribute_cmd = redistribute_cmd + ' metric ' + route_instance['metric'] %} +{% endif %} +{% if 'metric-type' in route_instance %} +{% if route_instance['metric-type'] == "TYPE_1"%} +{% set redistribute_cmd = redistribute_cmd + ' metric-type ' + '1' %} +{% endif %} +{% endif %} +{% if 'route-map' in route_instance %} +{% set redistribute_cmd = redistribute_cmd + ' route-map ' + route_instance['route-map'] %} +{% endif %} + {{ redistribute_cmd }} +{% elif routedirection == "EXPORT" and routeproto in generic_protocols %} +{% if 'route-map' in route_instance %} +{% if routeproto == "DIRECTLY_CONNECTED" %} + distribute-list {{ route_instance['route-map'] }} out connected +{% else %} + distribute-list {{ route_instance['route-map'] }} out {{ routeproto.lower() }} +{% endif %} +{% endif %} +{% endif %} + diff --git a/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.interface.j2 b/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.interface.j2 new file mode 100644 index 000000000000..7969c81f2dad --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.interface.j2 @@ -0,0 +1,76 @@ +{# ------------------------------------------------------------------------------------ #} +{# ------------------------------------------------------------------------------------ #} +{% if OSPFV2_INTERFACE is defined and OSPFV2_INTERFACE|length > 0 %} +{% for (intfkey, ospf_intf_instance) in OSPFV2_INTERFACE.items() %} +! +{% set intfname = intfkey[0] %} +{% set intfaddr = intfkey[1] %} +{% if intfaddr == "0.0.0.0" %} +{% set intfaddr = "" %} +{% endif %} +interface {{ intfname }} +{% if 'area-id' in ospf_intf_instance %} + ip ospf area {{ ospf_intf_instance['area-id'] }} {{ intfaddr }} +{% endif %} +{% if 'network-type' in ospf_intf_instance %} +{% if ospf_intf_instance['network-type'] == 'BROADCAST_NETWORK' %} + ip ospf network broadcast {{ intfaddr }} +{% endif %} +{% if ospf_intf_instance['network-type'] == 'POINT_TO_POINT_NETWORK' %} + ip ospf network point-to-point {{ intfaddr }} +{% endif %} +{% endif %} +{% if 'metric' in ospf_intf_instance %} + ip ospf cost {{ ospf_intf_instance['metric'] }} {{ intfaddr }} +{% endif %} +{% if 'priority' in ospf_intf_instance %} + ip ospf priority {{ ospf_intf_instance['priority'] }} {{ intfaddr }} +{% endif %} +{% if 'mtu-ignore' in ospf_intf_instance %} +{% if ospf_intf_instance['mtu-ignore'] == 'true' %} + ip ospf mtu-ignore {{ intfaddr }} +{% endif %} +{% endif %} +{% if 'bfd-enable' in ospf_intf_instance %} +{% if ospf_intf_instance['bfd-enable'] == 'true' %} + ip ospf bfd +{% endif %} +{% endif %} +{% if 'authentication-type' in ospf_intf_instance %} +{% if ospf_intf_instance['authentication-type'] == 'MD5HMAC' %} + ip ospf authentication message-digest {{ intfaddr }} +{% endif %} +{% if ospf_intf_instance['authentication-type'] == 'NONE' %} + ip ospf authentication null {{ intfaddr }} +{% endif %} +{% if ospf_intf_instance['authentication-type'] == 'TEXT' %} + ip ospf authentication {{ intfaddr }} +{% endif %} +{% endif %} +{% if 'authentication-key' in ospf_intf_instance %} + ip ospf authentication-key {{ ospf_intf_instance['authentication-key'] }} {{ intfaddr }} +{% endif %} +{% if 'authentication-key-id' in ospf_intf_instance and 'authentication-md5-key' in ospf_intf_instance %} + ip ospf message-digest-key {{ ospf_intf_instance['authentication-key-id'] }} md5 {{ ospf_intf_instance['authentication-md5-key'] }} {{ intfaddr }} +{% endif %} +{% if 'dead-interval' in ospf_intf_instance %} + ip ospf dead-interval {{ ospf_intf_instance['dead-interval'] }} {{ intfaddr }} +{% endif %} +{% if 'dead-interval-minimal' in ospf_intf_instance %} +{% if 'hello-multiplier' in ospf_intf_instance %} + ip ospf dead-interval minimal hello-multiplier {{ ospf_intf_instance['hello-multiplier'] }} {{ intfaddr }} +{% else %} + ip ospf dead-interval minimal {{ intfaddr }} +{% endif %} +{% endif %} +{% if 'hello-interval' in ospf_intf_instance %} + ip ospf hello-interval {{ ospf_intf_instance['hello-interval'] }} {{ intfaddr }} +{% endif %} +{% if 'retransmission-interval' in ospf_intf_instance %} + ip ospf retransmit-interval {{ ospf_intf_instance['retransmission-interval'] }} {{ intfaddr }} +{% endif %} +{% if 'transmit-delay' in ospf_intf_instance %} + ip ospf transmit-delay {{ ospf_intf_instance['transmit-delay'] }} {{ intfaddr }} +{% endif %} +{% endfor %} +{% endif %} diff --git a/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.policyrange.j2 b/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.policyrange.j2 new file mode 100644 index 000000000000..8d82b41c0827 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.policyrange.j2 @@ -0,0 +1,16 @@ +{% set rangeareaid = rangekey[1] %} +{% set rangeid = rangekey[2] %} + area {{ rangeareaid }} range {{ rangeid }} +{% if 'advertise' in area_range_instance %} +{% if area_range_instance['advertise'] == 'true' %} + area {{ rangeareaid }} range {{ rangeid }} advertise +{% else %} + area {{ rangeareaid }} range {{ rangeid }} not-advertise +{% endif %} +{% endif %} +{% if 'metric' in area_range_instance %} + area {{ rangeareaid }} range {{ rangeid }} advertise cost {{ area_range_instance['metric'] }} +{% endif %} +{% if 'substitue-prefix' in area_range_instance %} + area {{ rangeareaid }} range {{ rangeid }} substitute {{ area_range_instance['substitue-prefix'] }} +{% endif %} \ No newline at end of file diff --git a/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.vlink.j2 b/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.vlink.j2 new file mode 100644 index 000000000000..653db9f5458b --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.db.vlink.j2 @@ -0,0 +1,29 @@ +{% set vlinkareaid = vlinkkey[1] %} +{% set vlinkid = vlinkkey[2] %} + area {{ vlinkareaid }} virtual-link {{ vlinkid }} +{% if 'authentication' in vlink_instance %} +{% if vlink_instance['authentication'] == 'MD5HMAC' %} + area {{ vlinkareaid }} virtual-link {{ vlinkid }} authentication message-digest +{% else %} + area {{ vlinkareaid }} virtual-link {{ vlinkid }} null +{% endif %} +{% endif %} +{% if 'authentication-key' in vlink_instance %} + area {{ vlinkareaid }} virtual-link {{ vlinkid }} authentication-key {{ vlink_instance['authentication-key'] }} +{% endif %} +{% if 'authentication-key-id' in vlink_instance and 'authentication-md5-key' in vlink_instance %} + area {{ vlinkareaid }} virtual-link {{ vlinkid }} authentication message-digest message-digest-key {{ vlink_instance['authentication-key-id'] }} md5 {{ vlink_instance['authentication-md5-key'] }} +{% endif %} +{% if 'dead-interval' in vlink_instance %} + area {{ vlinkareaid }} virtual-link {{ vlinkid }} dead-interval {{ vlink_instance['dead-interval'] }} +{% endif %} +{% if 'hello-interval' in vlink_instance %} + area {{ vlinkareaid }} virtual-link {{ vlinkid }} hello-interval {{ vlink_instance['hello-interval'] }} +{% endif %} +{% if 'retransmission-interval' in vlink_instance %} + area {{ vlinkareaid }} virtual-link {{ vlinkid }} retransmit-interval {{ vlink_instance['retransmission-interval'] }} +{% endif %} +{% if 'transmit-delay' in vlink_instance %} + area {{ vlinkareaid }} virtual-link {{ vlinkid }} transmit-delay {{ vlink_instance['transmit-delay'] }} +{% endif %} + diff --git a/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.j2 b/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.j2 new file mode 100644 index 000000000000..d9ace5972dab --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/ospfd/ospfd.conf.j2 @@ -0,0 +1,6 @@ +! template: ospfd/ospfd.conf.j2 +! +! OSPF configuration using config DB OSPF instance tables +! +{% include "ospfd.conf.db.comm_list.j2" %} +{% include "ospfd.conf.db.interface.j2" %} diff --git a/src/sonic-frr-mgmt-framework/templates/staticd/staticd.conf.j2 b/src/sonic-frr-mgmt-framework/templates/staticd/staticd.conf.j2 new file mode 100644 index 000000000000..0ab193f4a1f8 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/staticd/staticd.conf.j2 @@ -0,0 +1,22 @@ + +{% block banner %} +! =========== Managed by sonic-cfggen DO NOT edit manually! ==================== +! generated by templates/frr/staticd.conf.j2 using config DB data +! file: staticd.conf +! +{% endblock banner %} +! +{% with agentx='false' %} +{% include "common/daemons.common.conf.j2" %} +{% endwith %} +! +{% if MGMT_VRF_CONFIG %} +{% if MGMT_VRF_CONFIG['vrf_global']['mgmtVrfEnabled'] == 'false' %} +{% include "staticd.db.default_route.conf.j2" %} +{% endif %} +{% else %} +{% include "staticd.db.default_route.conf.j2" %} +{% endif %} +! +{% include "staticd.db.conf.j2" %} +! diff --git a/src/sonic-frr-mgmt-framework/templates/staticd/staticd.db.conf.j2 b/src/sonic-frr-mgmt-framework/templates/staticd/staticd.db.conf.j2 new file mode 100644 index 000000000000..238f0f1acb61 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/staticd/staticd.db.conf.j2 @@ -0,0 +1,153 @@ +! template: staticd/staticd.db.conf.j2 +! +! Static Route configuration using config DB static route table +! +{% macro iproute(ip_prefix, nh_blackhole, nh_ip, nh_intf, nh_dist, nh_tag, nh_vrf) %} + {%- set ns = namespace(str = None) %} + {%- set ip_addr = ip_prefix.split('/')[0] %} + {%- if ip_addr|ipv4 %} + {%- set ns.str = 'ip route' %} + {%- else %} + {%- set ns.str = 'ipv6 route' %} + {%- endif %} + {%- if nh_blackhole %} + {#- ------------------------------ blackhole route ------------------------------ #} + {%- for item in [ip_prefix, 'blackhole', nh_tag, nh_dist] %} + {%- if item != None %} + {%- set ns.str = ns.str + ' ' + item %} + {%- endif %} + {%- endfor %} + {%- else %} + {#- ------------------------------ non-blackhole route ------------------------------ #} + {%- for item in [ip_prefix, nh_ip, nh_intf, nh_tag, nh_dist, nh_vrf] %} + {%- if item != None %} + {%- set ns.str = ns.str + ' ' + item %} + {%- endif %} + {%- endfor %} + {%- endif %} +{{ ns.str }} +{%- endmacro %} +{% if STATIC_ROUTE is defined and STATIC_ROUTE|length > 0 %} + {%- set vrf_rt_list = {} %} + {%- for key, val in STATIC_ROUTE.items() %} + {#- ------------------------------ for each route - start ------------------------------ #} + {%- set rt = namespace(vrf = 'default', ip_prefix = '', nh_num = 0, nh_list = [], valid = True) %} + {%- if key is not string and key|length > 1 %} + {%- set rt.vrf = key[0] %} + {%- set rt.ip_prefix = key[1] %} + {%- else %} + {%- set rt.ip_prefix = key %} + {%- endif %} + {%- set nh_attr = {} %} + {#- ------------------------------ get nh count - start ------------------------------ #} + {%- for fld_key, fld_val in val.items() if rt.valid %} + {%- set attr_list = fld_val.split(',') %} + {%- if rt.nh_num == 0 %} + {%- set rt.nh_num = attr_list|length %} + {%- else %} + {%- if rt.nh_num != attr_list|length %} + {%- set rt.valid = False %} + {%- endif %} + {%- endif %} + {%- if nh_attr.update({fld_key: attr_list}) %} + {%- endif %} + {%- endfor %} + {#- ------------------------------ get nh count - end ------------------------------ #} + {%- if rt.valid %} + {%- for nh_idx in range(rt.nh_num) %} + {#- ------------------------------ parse nh - start ------------------------------ #} + {%- set nh = namespace(blackhole = False, ip = None, intf = None, dist = None, tag = None, vrf = None) %} + {#- ------------------------------ nexthop blackhole ------------------------------ #} + {%- if 'blackhole' in nh_attr %} + {%- set nh.blackhole = nh_attr['blackhole'][nh_idx] %} + {%- if nh.blackhole == 'true' %} + {%- set nh.blackhole = True %} + {%- else %} + {%- set nh.blackhole = False %} + {%- endif %} + {%- endif %} + {#- ------------------------------ nexthop IP ------------------------------ #} + {%- if 'nexthop' in nh_attr %} + {%- set nh.ip = nh_attr['nexthop'][nh_idx] %} + {%- if nh.ip == '0.0.0.0' or nh.ip == '::' %} + {%- set nh.ip = None %} + {%- endif %} + {%- endif %} + {#- ------------------------------ nexthop interface ------------------------------ #} + {%- if 'ifname' in nh_attr %} + {%- set nh.intf = nh_attr['ifname'][nh_idx] %} + {%- if nh.intf == '' %} + {%- set nh.intf = None %} + {%- endif %} + {%- endif %} + {#- ------------------------------ nexthop distance ------------------------------ #} + {%- if 'distance' in nh_attr %} + {%- set nh.dist = nh_attr['distance'][nh_idx] %} + {%- if nh.dist == '0' %} + {%- set nh.dist = None %} + {%- endif %} + {%- endif %} + {#- ------------------------------ nexthop tag ------------------------------ #} + {%- if 'tag' in nh_attr %} + {%- set nh.tag = nh_attr['tag'][nh_idx] %} + {%- if nh.tag == '0' %} + {%- set nh.tag = None %} + {%- endif %} + {%- if nh.tag != None %} + {%- set nh.tag = 'tag ' + nh.tag %} + {%- endif %} + {%- endif %} + {#- ------------------------------ nexthop VRF ------------------------------ #} + {%- if 'nexthop-vrf' in nh_attr %} + {%- set nh.vrf = nh_attr['nexthop-vrf'][nh_idx] %} + {%- if nh.vrf == '' %} + {%- set nh.vrf = None %} + {%- endif %} + {%- if nh.vrf != None %} + {%- set nh.vrf = 'nexthop-vrf ' + nh.vrf %} + {%- endif %} + {%- endif %} + {#- ------------------------------ parse nh - end ------------------------------ #} + {%- if nh.blackhole or nh.ip != None or nh.intf != None %} + {%- if rt.nh_list.append(nh) %} + {%- endif %} + {%- endif %} + {%- endfor %} + {#- ------------------------------ for each route - end ------------------------------ #} + {%- if not rt.vrf in vrf_rt_list %} + {%- if vrf_rt_list.update({rt.vrf: []}) %} + {%- endif %} + {%- endif %} + {%- if vrf_rt_list[rt.vrf].append(rt) %} + {%- endif %} + {%- endif %} + {%- endfor %} + +{# ------------------------------ dump route - start ------------------------------ #} +{# ------------------------------ default VRF ------------------------------ #} +{% for vrf, rt_list in vrf_rt_list.items() if vrf == 'default' %} +{% for rt in rt_list %} +{% if rt.valid %} +{% for nh in rt.nh_list %} +{{ iproute(rt.ip_prefix, nh.blackhole, nh.ip, nh.intf, nh.dist, nh.tag, nh.vrf) }} +{% endfor %} +{% endif %} +{% endfor %} +{% endfor %} +{# ------------------------------ non-default VRF ------------------------------ #} +{% for vrf, rt_list in vrf_rt_list.items() if vrf != 'default' %} +! +vrf {{ vrf }} +{% for rt in rt_list %} +{% if rt.valid %} +{% for nh in rt.nh_list %} + {{ iproute(rt.ip_prefix, nh.blackhole, nh.ip, nh.intf, nh.dist, nh.tag, nh.vrf) }} +{% endfor %} +{% endif %} +{% endfor %} + exit-vrf +! +{% endfor %} +{# ------------------------------ dump route - end ------------------------------ #} + +{% endif %} diff --git a/src/sonic-frr-mgmt-framework/templates/staticd/staticd.db.default_route.conf.j2 b/src/sonic-frr-mgmt-framework/templates/staticd/staticd.db.default_route.conf.j2 new file mode 100644 index 000000000000..63d532203aaa --- /dev/null +++ b/src/sonic-frr-mgmt-framework/templates/staticd/staticd.db.default_route.conf.j2 @@ -0,0 +1,9 @@ +! +{% block default_route %} +! set static default route to mgmt gateway as a backup to learned default +{% if MGMT_INTERFACE %} +{% for (name, prefix) in MGMT_INTERFACE|pfx_filter %} +{% endfor %} +{% endif %} +{% endblock default_route %} +! diff --git a/src/sonic-frr-mgmt-framework/tests/__init__.py b/src/sonic-frr-mgmt-framework/tests/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/src/sonic-frr-mgmt-framework/tests/test_config.py b/src/sonic-frr-mgmt-framework/tests/test_config.py new file mode 100644 index 000000000000..ed31c1e28ec8 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/tests/test_config.py @@ -0,0 +1,176 @@ +import copy +import re +from unittest.mock import MagicMock, NonCallableMagicMock, patch + +swsssdk_module_mock = MagicMock(ConfigDBConnector = NonCallableMagicMock) + +@patch.dict('sys.modules', swsssdk = swsssdk_module_mock) +def test_contructor(): + from frrcfgd.frrcfgd import BGPConfigDaemon + daemon = BGPConfigDaemon() + daemon.start() + for table, hdlr in daemon.table_handler_list: + daemon.config_db.subscribe.assert_any_call(table, hdlr) + daemon.config_db.pubsub.psubscribe.assert_called_once() + daemon.stop() + daemon.config_db.sub_thread.stop.assert_called() + daemon.config_db.sub_thread.is_alive.assert_called_once() + daemon.config_db.sub_thread.join.assert_called_once() + +class CmdMapTestInfo: + data_buf = {} + def __init__(self, table, key, data, exp_cmd, no_del = False, neg_cmd = None, + chk_data = None, daemons = None, ignore_tail = False): + self.table_name = table + self.key = key + self.data = data + self.vtysh_cmd = exp_cmd + self.no_del = no_del + self.vtysh_neg_cmd = neg_cmd + self.chk_data = chk_data + self.daemons = daemons + self.ignore_tail = ignore_tail + @classmethod + def add_test_data(cls, test): + assert(isinstance(test.data, dict)) + cls.data_buf.setdefault( + test.table_name, {}).setdefault(test.key, {}).update(test.data) + @classmethod + def del_test_data(cls, test): + assert(test.table_name in cls.data_buf and + test.key in cls.data_buf[test.table_name]) + cache_data = cls.data_buf[test.table_name][test.key] + assert(isinstance(test.data, dict)) + for k, v in test.data.items(): + assert(k in cache_data and cache_data[k] == v) + del(cache_data[k]) + @classmethod + def get_test_data(cls, test): + assert(test.table_name in cls.data_buf and + test.key in cls.data_buf[test.table_name]) + return copy.deepcopy(cls.data_buf[test.table_name][test.key]) + @staticmethod + def compose_vtysh_cmd(cmd_list, negtive = False): + cmdline = 'vtysh' + for cmd in cmd_list: + cmd = cmd.format('no ' if negtive else '') + cmdline += " -c '%s'" % cmd + return cmdline + def check_running_cmd(self, mock, is_del): + if is_del: + vtysh_cmd = self.vtysh_cmd if self.vtysh_neg_cmd is None else self.vtysh_neg_cmd + else: + vtysh_cmd = self.vtysh_cmd + if callable(vtysh_cmd): + cmds = [] + for call in mock.call_args_list: + assert(call[0][0] == self.table_name) + cmds.append(call[0][1]) + vtysh_cmd(is_del, cmds, self.chk_data) + else: + if self.ignore_tail is None: + mock.assert_called_with(self.table_name, self.compose_vtysh_cmd(vtysh_cmd, is_del), + True, self.daemons) + else: + mock.assert_called_with(self.table_name, self.compose_vtysh_cmd(vtysh_cmd, is_del), + True, self.daemons, self.ignore_tail) + +def hdl_confed_peers_cmd(is_del, cmd_list, chk_data): + assert(len(chk_data) >= len(cmd_list)) + if is_del: + chk_data = list(reversed(chk_data)) + for idx, cmd in enumerate(cmd_list): + last_cmd = re.findall(r"-c\s+'([^']+)'\s*", cmd)[-1] + neg_cmd = False + if last_cmd.startswith('no '): + neg_cmd = True + last_cmd = last_cmd[len('no '):] + assert(last_cmd.startswith('bgp confederation peers ')) + peer_set = set(last_cmd[len('bgp confederation peers '):].split()) + if is_del or (len(chk_data) >= 3 and idx == 0): + assert(neg_cmd) + else: + assert(not neg_cmd) + assert(peer_set == chk_data[idx]) + +conf_cmd = 'configure terminal' +conf_bgp_cmd = lambda vrf, asn: [conf_cmd, 'router bgp %d vrf %s' % (asn, vrf)] +conf_no_bgp_cmd = lambda vrf, asn: [conf_cmd, 'no router bgp %d%s' % (asn, '' if vrf == 'default' else ' vrf %s' % vrf)] +conf_bgp_dft_cmd = lambda vrf, asn: conf_bgp_cmd(vrf, asn) + ['no bgp default ipv4-unicast'] +conf_bgp_af_cmd = lambda vrf, asn, af: conf_bgp_cmd(vrf, asn) + ['address-family %s unicast' % af] + +bgp_globals_data = [ + CmdMapTestInfo('BGP_GLOBALS', 'default', {'local_asn': 100}, + conf_bgp_dft_cmd('default', 100), False, conf_no_bgp_cmd('default', 100), None, None, None), + CmdMapTestInfo('BGP_GLOBALS', 'default', {'router_id': '1.1.1.1'}, + conf_bgp_cmd('default', 100) + ['{}bgp router-id 1.1.1.1']), + CmdMapTestInfo('BGP_GLOBALS', 'default', {'load_balance_mp_relax': 'true'}, + conf_bgp_cmd('default', 100) + ['{}bgp bestpath as-path multipath-relax ']), + CmdMapTestInfo('BGP_GLOBALS', 'default', {'as_path_mp_as_set': 'true'}, + conf_bgp_cmd('default', 100) + ['bgp bestpath as-path multipath-relax as-set'], False, + conf_bgp_cmd('default', 100) + ['bgp bestpath as-path multipath-relax ']), + CmdMapTestInfo('BGP_GLOBALS', 'default', {'always_compare_med': 'false'}, + conf_bgp_cmd('default', 100) + ['no bgp always-compare-med']), + CmdMapTestInfo('BGP_GLOBALS', 'default', {'external_compare_router_id': 'true'}, + conf_bgp_cmd('default', 100) + ['{}bgp bestpath compare-routerid']), + CmdMapTestInfo('BGP_GLOBALS', 'default', {'ignore_as_path_length': 'true'}, + conf_bgp_cmd('default', 100) + ['{}bgp bestpath as-path ignore']), + CmdMapTestInfo('BGP_GLOBALS', 'default', {'graceful_restart_enable': 'true'}, + conf_bgp_cmd('default', 100) + ['{}bgp graceful-restart']), + CmdMapTestInfo('BGP_GLOBALS', 'default', {'gr_restart_time': '10'}, + conf_bgp_cmd('default', 100) + ['{}bgp graceful-restart restart-time 10']), + CmdMapTestInfo('BGP_GLOBALS', 'default', {'gr_stale_routes_time': '20'}, + conf_bgp_cmd('default', 100) + ['{}bgp graceful-restart stalepath-time 20']), + CmdMapTestInfo('BGP_GLOBALS', 'default', {'gr_preserve_fw_state': 'true'}, + conf_bgp_cmd('default', 100) + ['{}bgp graceful-restart preserve-fw-state']), + CmdMapTestInfo('BGP_GLOBALS_AF', 'default|ipv4_unicast', {'ebgp_route_distance': '100', + 'ibgp_route_distance': '115', + 'local_route_distance': '238'}, + conf_bgp_af_cmd('default', 100, 'ipv4') + ['{}distance bgp 100 115 238']), + CmdMapTestInfo('BGP_GLOBALS_AF', 'default|ipv6_unicast', {'advertise-all-vni': 'true'}, + conf_bgp_af_cmd('default', 100, 'ipv6') + ['{}advertise-all-vni']), + CmdMapTestInfo('BGP_GLOBALS', 'Vrf_red', {'local_asn': 200}, + conf_bgp_dft_cmd('Vrf_red', 200), False, conf_no_bgp_cmd('Vrf_red', 200), None, None, None), + CmdMapTestInfo('BGP_GLOBALS', 'Vrf_red', {'med_confed': 'true'}, + conf_bgp_cmd('Vrf_red', 200) + ['{}bgp bestpath med confed']), + CmdMapTestInfo('BGP_GLOBALS', 'Vrf_red', {'confed_peers': ['2', '10', '5']}, + hdl_confed_peers_cmd, True, None, [{'2', '10', '5'}]), + CmdMapTestInfo('BGP_GLOBALS', 'Vrf_red', {'confed_peers': ['10', '8']}, + hdl_confed_peers_cmd, False, None, [{'2', '5'}, {'8'}, {'10', '8'}]), + CmdMapTestInfo('BGP_GLOBALS', 'Vrf_red', {'keepalive': '300', 'holdtime': '900'}, + conf_bgp_cmd('Vrf_red', 200) + ['{}timers bgp 300 900']), + CmdMapTestInfo('BGP_GLOBALS', 'Vrf_red', {'max_med_admin': 'true', 'max_med_admin_val': '20'}, + conf_bgp_cmd('Vrf_red', 200) + ['{}bgp max-med administrative 20']), + CmdMapTestInfo('BGP_GLOBALS_AF', 'Vrf_red|ipv4_unicast', {'import_vrf': 'Vrf_test'}, + conf_bgp_af_cmd('Vrf_red', 200, 'ipv4') + ['{}import vrf Vrf_test']), + CmdMapTestInfo('BGP_GLOBALS_AF', 'Vrf_red|ipv6_unicast', {'import_vrf_route_map': 'test_map'}, + conf_bgp_af_cmd('Vrf_red', 200, 'ipv6') + ['{}import vrf route-map test_map']), +] + +@patch.dict('sys.modules', swsssdk = swsssdk_module_mock) +@patch('frrcfgd.frrcfgd.g_run_command') +def data_set_del_test(test_data, run_cmd): + from frrcfgd.frrcfgd import BGPConfigDaemon + daemon = BGPConfigDaemon() + data_buf = {} + # add data in list + for test in test_data: + run_cmd.reset_mock() + hdlr = [h for t, h in daemon.table_handler_list if t == test.table_name] + assert(len(hdlr) == 1) + CmdMapTestInfo.add_test_data(test) + hdlr[0](test.table_name, test.key, CmdMapTestInfo.get_test_data(test)) + test.check_running_cmd(run_cmd, False) + # delete data in reverse direction + for test in reversed(test_data): + if test.no_del: + continue + run_cmd.reset_mock() + hdlr = [h for t, h in daemon.table_handler_list if t == test.table_name] + assert(len(hdlr) == 1) + CmdMapTestInfo.del_test_data(test) + hdlr[0](test.table_name, test.key, CmdMapTestInfo.get_test_data(test)) + test.check_running_cmd(run_cmd, True) + +def test_bgp_globals(): + data_set_del_test(bgp_globals_data) diff --git a/src/sonic-frr-mgmt-framework/tests/test_constructor.py b/src/sonic-frr-mgmt-framework/tests/test_constructor.py new file mode 100644 index 000000000000..14faa36d2e66 --- /dev/null +++ b/src/sonic-frr-mgmt-framework/tests/test_constructor.py @@ -0,0 +1,234 @@ +import socket +import pytest +from unittest.mock import MagicMock, NonCallableMagicMock, patch + +swsssdk_module_mock = MagicMock(ConfigDBConnector = NonCallableMagicMock) + +with patch.dict('sys.modules', swsssdk = swsssdk_module_mock): + from frrcfgd.frrcfgd import CachedDataWithOp + from frrcfgd.frrcfgd import BGPPeerGroup + from frrcfgd.frrcfgd import BGPKeyMapInfo + from frrcfgd.frrcfgd import BGPKeyMapList + from frrcfgd.frrcfgd import get_command_cmn + from frrcfgd.frrcfgd import CommunityList + from frrcfgd.frrcfgd import MatchPrefix + from frrcfgd.frrcfgd import MatchPrefixList + from frrcfgd.frrcfgd import AggregateAddr + from frrcfgd.frrcfgd import IpNextHop + from frrcfgd.frrcfgd import IpNextHopSet + +def test_data_with_op(): + data = CachedDataWithOp() + assert(data.data is None) + assert(data.op == CachedDataWithOp.OP_NONE) + data = CachedDataWithOp(10, CachedDataWithOp.OP_ADD) + assert(data.data == 10) + assert(data.op == CachedDataWithOp.OP_ADD) + +def test_peer_group(): + pg = BGPPeerGroup('Vrf_red') + assert(pg.vrf == 'Vrf_red') + assert(len(pg.ref_nbrs) == 0) + +def test_command_map(): + def cmd_hdlr(): + pass + key_map1 = BGPKeyMapInfo('test command', cmd_hdlr, None) + assert(key_map1.daemons is None) + assert(key_map1.run_cmd == 'test command') + assert(key_map1.hdl_func == cmd_hdlr) + assert(key_map1.data is None) + key_map2 = BGPKeyMapInfo('[bgpd,ospfd]daemon command', None, 100) + assert(key_map2.daemons == ['bgpd', 'ospfd']) + assert(key_map2.run_cmd == 'daemon command') + assert(key_map2.hdl_func == get_command_cmn) + assert(key_map2.data == 100) + +def get_cmd_map_list(attr_list, map_key = None): + map_list = [] + for attr in attr_list: + tokens = attr[0].split('|', 1) + if len(tokens) == 2: + key = tokens[1] + else: + key = None + if map_key is not None and key is not None and map_key != key: + continue + cmd_hdlr = cmd_data = None + if len(attr) >= 4: + cmd_hdlr = attr[2] + cmd_data = attr[3] + elif len(attr) == 3: + cmd_data = attr[2] + map_list.append(BGPKeyMapInfo(attr[1], cmd_hdlr, cmd_data)) + return map_list + +def test_command_map_list(): + def cmd_hdlr(num): + pass + map_list = [('abc', 'set attribute abc'), + ('defg', 'system config', cmd_hdlr, 10), + ('test', 'system test', [20, 30]), + ('xyz', 'config test'), + ('ip_cmd|ipv4', 'test on ipv4'), + ('ip_cmd|ipv6', 'test on ipv6')] + cmd_map_list = BGPKeyMapList(map_list, 'frrcfg', {'ip_cmd': 'ipv4'}) + chk_map_list = get_cmd_map_list(map_list, 'ipv4') + for idx, cmd_map in enumerate(cmd_map_list): + assert(chk_map_list[idx] == cmd_map[1]) + cmd_map_list = BGPKeyMapList(map_list, 'frrcfg', {'ip_cmd': 'ipv6'}) + chk_map_list = get_cmd_map_list(map_list, 'ipv6') + for idx, cmd_map in enumerate(cmd_map_list): + assert(chk_map_list[idx] == cmd_map[1]) + +def test_community_list(): + for ext in [False, True]: + comm_list = CommunityList('comm', ext) + assert(comm_list.name == 'comm') + assert(comm_list.is_ext == ext) + assert(comm_list.match_action is None) + assert(comm_list.is_std is None) + assert(len(comm_list.mbr_list) == 0) + +def test_match_prefix(): + pfx = MatchPrefix(socket.AF_INET, '1.2.3.4/16') + assert(pfx.ip_prefix == '1.2.0.0/16') + assert(pfx.min_len is None) + assert(pfx.max_len is None) + assert(pfx.action == 'permit') + pfx = MatchPrefix(socket.AF_INET, '10.10.10.10/24', '25..29', 'deny') + assert(pfx.ip_prefix == '10.10.10.0/24') + assert(pfx.min_len == 25) + assert(pfx.max_len == 29) + assert(pfx.action == 'deny') + pfx = MatchPrefix(socket.AF_INET, '100.0.0.0/8', '16..32') + assert(pfx.ip_prefix == '100.0.0.0/8') + assert(pfx.min_len == 16) + assert(pfx.max_len is None) + assert(pfx.action == 'permit') + pfx = MatchPrefix(socket.AF_INET, '20.20.20.20/28', '25..30', 'deny') + assert(pfx.ip_prefix == '20.20.20.16/28') + assert(pfx.min_len is None) + assert(pfx.max_len == 30) + assert(pfx.action == 'deny') + + pfx = MatchPrefix(socket.AF_INET6, '1:2::3:4/64') + assert(pfx.ip_prefix == '1:2::/64') + assert(pfx.min_len is None) + assert(pfx.max_len is None) + assert(pfx.action == 'permit') + pfx = MatchPrefix(socket.AF_INET6, '10:10::10:10/64', '70..100', 'deny') + assert(pfx.ip_prefix == '10:10::/64') + assert(pfx.min_len == 70) + assert(pfx.max_len == 100) + assert(pfx.action == 'deny') + pfx = MatchPrefix(socket.AF_INET6, '1001::/16', '16..128') + assert(pfx.ip_prefix == '1001::/16') + assert(pfx.min_len is None) + assert(pfx.max_len == 128) + assert(pfx.action == 'permit') + +def test_match_prefix_list(): + ipv4_pfx_attrs = [('10.1.1.1/16', '18..24', 'permit'), + ('20.2.2.2/24', None, 'deny'), + ('30.3.3.3/8', '10..32', 'permit'), + ('40.4.4.4/28', '20..30', 'deny')] + ipv6_pfx_attrs = [('1000:1::1/64', '80..120', 'permit'), + ('2000:2::2/96', None, 'deny'), + ('3000:3::3/32', '40..128', 'permit'), + ('4000:4::4/80', '60..100', 'deny')] + + pfx_list = MatchPrefixList() + for attr in ipv4_pfx_attrs: + pfx_list.add_prefix(*attr) + assert(pfx_list.af == socket.AF_INET) + assert(len(pfx_list) == len(ipv4_pfx_attrs)) + chk_pfx_list = [] + for attr in ipv4_pfx_attrs: + chk_pfx_list.append(MatchPrefix(socket.AF_INET, *attr)) + assert(all([x == y for x, y in zip(chk_pfx_list, pfx_list)])) + + pfx_list = MatchPrefixList() + for attr in ipv6_pfx_attrs: + pfx_list.add_prefix(*attr) + assert(pfx_list.af == socket.AF_INET6) + assert(len(pfx_list) == len(ipv6_pfx_attrs)) + chk_pfx_list = [] + for attr in ipv6_pfx_attrs: + chk_pfx_list.append(MatchPrefix(socket.AF_INET6, *attr)) + assert(all([x == y for x, y in zip(chk_pfx_list, pfx_list)])) + +def test_match_prefix_list_fail(): + pfx_list = MatchPrefixList() + pfx_list.add_prefix('1.2.3.0/24') + with pytest.raises(ValueError): + pfx_list.add_prefix('1::/64') + +def test_aggregate_address(): + addr = AggregateAddr() + assert(addr.as_set == False) + assert(addr.summary_only == False) + +def test_ip_nexthop(): + for af in [socket.AF_INET, socket.AF_INET6]: + nh = IpNextHop(af, None, None, None, 'Loopback0', None, None, None) + assert(nh.af == af) + assert(nh.blackhole == 'false') + assert(nh.ip == ('0.0.0.0' if af == socket.AF_INET else '::')) + assert(nh.track == 0) + assert(nh.interface == 'Loopback0') + assert(nh.tag == 0) + assert(nh.distance == 0) + assert(nh.nh_vrf == '') + arg_list = nh.get_arg_list() + assert(arg_list == ['false', '', 'Loopback0'] + [''] * 4) + nh = IpNextHop(af, 'true', '1.1.1.1' if af == socket.AF_INET else '1::1', + 1, 'Ethernet0', 100, 2, 'default') + assert(nh.blackhole == 'true') + assert(nh.ip == ('0.0.0.0' if af == socket.AF_INET else '::')) + assert(nh.track == 1) + assert(nh.interface == '') + assert(nh.tag == 100) + assert(nh.distance == 2) + assert(nh.nh_vrf == '') + arg_list = nh.get_arg_list() + assert(arg_list == ['true', '', '', '1', '100', '2', '']) + nh = IpNextHop(socket.AF_INET, 'false', '1.2.3.4', 5, 'Ethernet1', 2345, 3, 'Vrf_red') + assert(nh.af == socket.AF_INET) + assert(nh.blackhole == 'false') + assert(nh.ip == '1.2.3.4') + assert(nh.track == 5) + assert(nh.interface == 'Ethernet1') + assert(nh.tag == 2345) + assert(nh.distance == 3) + assert(nh.nh_vrf == 'Vrf_red') + arg_list = nh.get_arg_list() + assert(arg_list == ['false', '1.2.3.4', 'Ethernet1', '5', '2345', '3', 'Vrf_red']) + nh = IpNextHop(socket.AF_INET6, 'false', '1001:1::2002', 6, 'Ethernet2', 9000, 4, 'Vrf_blue') + assert(nh.af == socket.AF_INET6) + assert(nh.blackhole == 'false') + assert(nh.ip == '1001:1::2002') + assert(nh.track == 6) + assert(nh.interface == 'Ethernet2') + assert(nh.tag == 9000) + assert(nh.distance == 4) + assert(nh.nh_vrf == 'Vrf_blue') + arg_list = nh.get_arg_list() + assert(arg_list == ['false', '1001:1::2002', 'Ethernet2', '6', '9000', '4', 'Vrf_blue']) + +def test_nexthop_set(): + for af in [socket.AF_INET, socket.AF_INET6]: + nh_set = IpNextHopSet(af) + bkh_list = ['false', 'false', 'false', 'true'] + ip_list = ['1.1.1.1', '2.2.2.2', '3.3.3.3', None] + ip6_list = ['1::1', '2::2', '3::3', None] + intf_list = [None, 'Vlan0', 'Loopback1', None] + tag_list = [1000, 2000, 3000, 4000] + vrf_list = ['default', 'Vrf_red', 'Vrf_blue', None] + nh_set = IpNextHopSet(af, bkh_list, ip_list if af == socket.AF_INET else ip6_list, None, + intf_list, tag_list, None, vrf_list) + test_set = set() + for idx in range(len(ip_list)): + test_set.add(IpNextHop(af, bkh_list[idx], ip_list[idx] if af == socket.AF_INET else ip6_list[idx], + None, intf_list[idx], tag_list[idx], None, vrf_list[idx])) + assert(nh_set == test_set) From 3b3161050eaa050d95e14ad819d87b88bdf2bfd7 Mon Sep 17 00:00:00 2001 From: lguohan Date: Sun, 24 Jan 2021 21:01:47 -0800 Subject: [PATCH 0091/1674] [submodule]: update sonic-sairedis (#6544) * 20b9573 2021-01-24 | [SAI]: update SAI submodule (#775) (HEAD, origin/master, origin/HEAD) [lguohan] * 667c33d 2021-01-22 | [syncd] Comparison logic add support to LABEL attribute with higher priority (#764) [Kamil Cudnik] * aaf5b98 2021-01-22 | [vslib]: Fix missing MACsec Create Port action (#770) [Ze Gan] Signed-off-by: Guohan Lu --- src/sonic-sairedis | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-sairedis b/src/sonic-sairedis index 02d0371d2e0f..20b9573437f3 160000 --- a/src/sonic-sairedis +++ b/src/sonic-sairedis @@ -1 +1 @@ -Subproject commit 02d0371d2e0fc6f87d7859346d86c638df82c464 +Subproject commit 20b9573437f3194c5281f28922ab5d5d8a913e4e From e6c98eab3ebf9405dcfd642ac865f634ec6d746e Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Sun, 24 Jan 2021 22:50:49 -0800 Subject: [PATCH 0092/1674] [submodule]: update sonic-swss * 01c3abd 2021-01-23 | Enhance dynamic buffer calculation and bug fixes (#1601) (HEAD, origin/202012) [Stephen Sun] * e7af660 2021-01-24 | [fpmsyncd] Skip routes to eth0 or docker0 (#1606) [Shi Su] Signed-off-by: Guohan Lu --- src/sonic-swss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-swss b/src/sonic-swss index 36f7332ddab5..01c3abd3cf30 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit 36f7332ddab56c618513c4b57edc99e3b735c27c +Subproject commit 01c3abd3cf30c76824b736fe65093fa065385c67 From 80ba3a4f6f3a51ddb5c73c0bad2587d14b542120 Mon Sep 17 00:00:00 2001 From: Tamer Ahmed Date: Mon, 25 Jan 2021 10:48:48 -0800 Subject: [PATCH 0093/1674] [dhcp-relay]: Launch DHCP Relay On L3 Vlan (#6527) Recent changes brought l2 vlan concept which do not have DHCP clients behind them and so DHCP relay is not required. Also, dhcpmon fails to launch on those vlans as their interfaces lack IP addresses. This PR limit launch of both DHCP relay and dhcpmon to L3 vlans only. singed-off-by: Tamer Ahmed --- .../docker-dhcp-relay.supervisord.conf.j2 | 22 +++++++++---------- .../tests/t0-sample-graph.xml | 17 ++++++++++++++ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/dockers/docker-dhcp-relay/docker-dhcp-relay.supervisord.conf.j2 b/dockers/docker-dhcp-relay/docker-dhcp-relay.supervisord.conf.j2 index 59d6c1f5f2c7..20f631ad47c1 100644 --- a/dockers/docker-dhcp-relay/docker-dhcp-relay.supervisord.conf.j2 +++ b/dockers/docker-dhcp-relay/docker-dhcp-relay.supervisord.conf.j2 @@ -39,11 +39,11 @@ dependent_startup=true dependent_startup_wait_for=rsyslogd:running {# If our configuration has VLANs... #} -{% if VLAN %} +{% if VLAN_INTERFACE %} {# Count how many VLANs require a DHCP relay agent... #} {% set num_relays = { 'count': 0 } %} -{% for vlan_name in VLAN %} -{% if VLAN[vlan_name]['dhcp_servers'] %} +{% for vlan_name in VLAN_INTERFACE %} +{% if VLAN and vlan_name in VLAN and VLAN[vlan_name]['dhcp_servers'] %} {% set _dummy = num_relays.update({'count': num_relays.count + 1}) %} {% endif %} {% endfor %} @@ -52,8 +52,8 @@ dependent_startup_wait_for=rsyslogd:running [group:isc-dhcp-relay] programs= {%- set add_preceding_comma = { 'flag': False } %} -{% for vlan_name in VLAN %} -{% if VLAN[vlan_name]['dhcp_servers'] %} +{% for vlan_name in VLAN_INTERFACE %} +{% if VLAN and vlan_name in VLAN and VLAN[vlan_name]['dhcp_servers'] %} {% if add_preceding_comma.flag %},{% endif %} {% set _dummy = add_preceding_comma.update({'flag': True}) %} isc-dhcp-relay-{{ vlan_name }} @@ -63,8 +63,8 @@ isc-dhcp-relay-{{ vlan_name }} {# Create a program entry for each DHCP relay agent instance #} {% set relay_for_ipv4 = { 'flag': False } %} -{% for vlan_name in VLAN %} -{% if VLAN[vlan_name]['dhcp_servers'] %} +{% for vlan_name in VLAN_INTERFACE %} +{% if VLAN and vlan_name in VLAN and VLAN[vlan_name]['dhcp_servers'] %} {% for dhcp_server in VLAN[vlan_name]['dhcp_servers'] %} {% if dhcp_server | ipv4 %} {% set _dummy = relay_for_ipv4.update({'flag': True}) %} @@ -106,8 +106,8 @@ dependent_startup_wait_for=start:exited [group:dhcpmon] programs= {%- set add_preceding_comma = { 'flag': False } %} -{% for vlan_name in VLAN %} -{% if VLAN[vlan_name]['dhcp_servers'] %} +{% for vlan_name in VLAN_INTERFACE %} +{% if VLAN and vlan_name in VLAN and VLAN[vlan_name]['dhcp_servers'] %} {% if add_preceding_comma.flag %},{% endif %} {% set _dummy = add_preceding_comma.update({'flag': True}) %} dhcpmon-{{ vlan_name }} @@ -117,8 +117,8 @@ dhcpmon-{{ vlan_name }} {# Create a program entry for each DHCP MONitor instance #} {% set relay_for_ipv4 = { 'flag': False } %} -{% for vlan_name in VLAN %} -{% if VLAN[vlan_name]['dhcp_servers'] %} +{% for vlan_name in VLAN_INTERFACE %} +{% if VLAN and vlan_name in VLAN and VLAN[vlan_name]['dhcp_servers'] %} {% for dhcp_server in VLAN[vlan_name]['dhcp_servers'] %} {% if dhcp_server | ipv4 %} {% set _dummy = relay_for_ipv4.update({'flag': True}) %} diff --git a/src/sonic-config-engine/tests/t0-sample-graph.xml b/src/sonic-config-engine/tests/t0-sample-graph.xml index 237a2ff0f532..63f892fe6d04 100644 --- a/src/sonic-config-engine/tests/t0-sample-graph.xml +++ b/src/sonic-config-engine/tests/t0-sample-graph.xml @@ -237,11 +237,28 @@ fortyGigE0/4;fortyGigE0/8;fortyGigE0/12;fortyGigE0/16;fortyGigE0/20;fortyGigE0/24;fortyGigE0/28;fortyGigE0/32;fortyGigE0/36;fortyGigE0/40;fortyGigE0/44;fortyGigE0/48;fortyGigE0/52;fortyGigE0/56;fortyGigE0/60;fortyGigE0/64;fortyGigE0/68;fortyGigE0/72;fortyGigE0/76;fortyGigE0/80;fortyGigE0/84;fortyGigE0/88;fortyGigE0/92;fortyGigE0/96 False 0.0.0.0/0 + 192.0.0.1;192.0.0.2 1000 1000 192.168.0.0/27 + + + + + Vlan99 + fortyGigE0/100 + False + 0.0.0.0/0 + + UserDefinedL2Vlan + 192.0.0.1;192.0.0.2 + 99 + 99 + + + From a0fd862620898c6e3276e457f4fbd996fbbcf92f Mon Sep 17 00:00:00 2001 From: Kebo Liu Date: Tue, 26 Jan 2021 02:52:22 +0800 Subject: [PATCH 0094/1674] [mellanox]: Update SDK to 4.4.2308, FW to *.2008.2308 (#6552) Bugs fixes: All | Kernel | During system reload when CPU is loaded with heavy traffic, a Kernel Panic may occur. All | Modules, Port split | FW stuck when device rebooted with locked Optical Transceivers in split mode Spectrum-3 | PFC | On Spectrum-3 systems, slow reaction time to Rx pause packets on 40GbE ports may lead to buffer overflow on servers. Spectrum-3 | SN4700, Port Split | On rare occasion SN4700, conducting 100G split (4x25G) in NRZ when splitter port 1 or 2 are down, ports 3 and 4 will also go down. Enahncments: All | Kernel | new notification on ISSU start, so other kernel drivers can disable any interface to ASIC Signed-off-by: Kebo Liu --- platform/mellanox/fw.mk | 6 +++--- platform/mellanox/sdk-src/sx-kernel/Switch-SDK-drivers | 2 +- platform/mellanox/sdk.mk | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/platform/mellanox/fw.mk b/platform/mellanox/fw.mk index 5c9a7442b98f..094a038c31b2 100644 --- a/platform/mellanox/fw.mk +++ b/platform/mellanox/fw.mk @@ -11,17 +11,17 @@ else FW_FROM_URL = n endif -MLNX_SPC_FW_VERSION = 13.2008.2208 +MLNX_SPC_FW_VERSION = 13.2008.2308 MLNX_SPC_FW_FILE = fw-SPC-rel-$(subst .,_,$(MLNX_SPC_FW_VERSION))-EVB.mfa $(MLNX_SPC_FW_FILE)_PATH = $(MLNX_FW_BASE_PATH) $(MLNX_SPC_FW_FILE)_URL = $(MLNX_FW_BASE_URL)/$(MLNX_SPC_FW_FILE) -MLNX_SPC2_FW_VERSION = 29.2008.2208 +MLNX_SPC2_FW_VERSION = 29.2008.2308 MLNX_SPC2_FW_FILE = fw-SPC2-rel-$(subst .,_,$(MLNX_SPC2_FW_VERSION))-EVB.mfa $(MLNX_SPC2_FW_FILE)_PATH = $(MLNX_FW_BASE_PATH) $(MLNX_SPC2_FW_FILE)_URL = $(MLNX_FW_BASE_URL)/$(MLNX_SPC2_FW_FILE) -MLNX_SPC3_FW_VERSION = 30.2008.2208 +MLNX_SPC3_FW_VERSION = 30.2008.2308 MLNX_SPC3_FW_FILE = fw-SPC3-rel-$(subst .,_,$(MLNX_SPC3_FW_VERSION))-EVB.mfa $(MLNX_SPC3_FW_FILE)_PATH = $(MLNX_FW_BASE_PATH) $(MLNX_SPC3_FW_FILE)_URL = $(MLNX_FW_BASE_URL)/$(MLNX_SPC3_FW_FILE) diff --git a/platform/mellanox/sdk-src/sx-kernel/Switch-SDK-drivers b/platform/mellanox/sdk-src/sx-kernel/Switch-SDK-drivers index f2d3ccc99c03..68f452e52bbb 160000 --- a/platform/mellanox/sdk-src/sx-kernel/Switch-SDK-drivers +++ b/platform/mellanox/sdk-src/sx-kernel/Switch-SDK-drivers @@ -1 +1 @@ -Subproject commit f2d3ccc99c03a54a874278d33ae77c38586eb70b +Subproject commit 68f452e52bbbe9a9f68926867dd9ffcee41e15a9 diff --git a/platform/mellanox/sdk.mk b/platform/mellanox/sdk.mk index e020d1a575cf..7ae3289f249c 100644 --- a/platform/mellanox/sdk.mk +++ b/platform/mellanox/sdk.mk @@ -1,6 +1,6 @@ MLNX_SDK_BASE_PATH = $(PLATFORM_PATH)/sdk-src/sx-kernel/Switch-SDK-drivers/bin/ MLNX_SDK_PKG_BASE_PATH = $(MLNX_SDK_BASE_PATH)/$(BLDENV)/ -MLNX_SDK_VERSION = 4.4.2208 +MLNX_SDK_VERSION = 4.4.2308 MLNX_SDK_ISSU_VERSION = 101 MLNX_SDK_DEB_VERSION = $(subst -,.,$(subst _,.,$(MLNX_SDK_VERSION))) From be281536e1817b3857e8b3eb84c85c7de3959679 Mon Sep 17 00:00:00 2001 From: bingwang-ms <66248323+bingwang-ms@users.noreply.github.com> Date: Wed, 27 Jan 2021 15:01:42 +0800 Subject: [PATCH 0095/1674] [bgpmon]: Fix exception in bgpmon caused by duplicate bgp neighbor ID (#6546) * Fix exception in bgpmon caused by duplicate keys It is possible that BGP neighbors in IPv4 and IPv6 address families share the same name (such as bgp monitor). However, such case is not handled in bgpmon, and an Exception will be raised. This commit will address the issue by Using set instead of list to avoid duplicate keys. --- src/sonic-bgpcfgd/bgpmon/bgpmon.py | 37 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/sonic-bgpcfgd/bgpmon/bgpmon.py b/src/sonic-bgpcfgd/bgpmon/bgpmon.py index c20c2110a6b2..2b50bd6cf58d 100755 --- a/src/sonic-bgpcfgd/bgpmon/bgpmon.py +++ b/src/sonic-bgpcfgd/bgpmon/bgpmon.py @@ -4,20 +4,20 @@ Description: bgpmon.py -- populating bgp related information in stateDB. script is started by supervisord in bgp docker when the docker is started. - Initial creation of this daemon is to assist SNMP agent in obtaining the + Initial creation of this daemon is to assist SNMP agent in obtaining the BGP related information for its MIB support. The MIB that this daemon is assisting is for the CiscoBgp4MIB (Neighbor state only). If there are other - BGP related items that needs to be updated in a periodic manner in the + BGP related items that needs to be updated in a periodic manner in the future, then more can be added into this process. The script check if there are any bgp activities by monitoring the bgp frr.log file timestamp. If activity is detected, then it will request bgp - neighbor state via vtysh cli interface. This bgp activity monitoring is + neighbor state via vtysh cli interface. This bgp activity monitoring is done periodically (every 15 second). When triggered, it looks specifically for the neighbor state in the json output of show ip bgp neighbors json and update the state DB for each neighbor accordingly. In order to not disturb and hold on to the State DB access too long and - removal of the stale neighbors (neighbors that was there previously on + removal of the stale neighbors (neighbors that was there previously on previous get request but no longer there in the current get request), a "previous" neighbor dictionary will be kept and used to determine if there is a need to perform update or the peer is stale to be removed from the @@ -34,13 +34,13 @@ class BgpStateGet: def __init__(self): - # list peer_l stores the Neighbor peer Ip address + # set peer_l stores the Neighbor peer Ip address # dic peer_state stores the Neighbor peer state entries - # list new_peer_l stores the new snapshot of Neighbor peer ip address + # set new_peer_l stores the new snapshot of Neighbor peer ip address # dic new_peer_state stores the new snapshot of Neighbor peer states - self.peer_l = [] + self.peer_l = set() self.peer_state = {} - self.new_peer_l = [] + self.new_peer_l = set() self.new_peer_state = {} self.cached_timestamp = 0 self.db = swsssdk.SonicV2Connector() @@ -67,7 +67,7 @@ def bgp_activity_detected(self): def update_new_peer_states(self, peer_dict): peer_l = peer_dict["peers"].keys() - self.new_peer_l.extend(peer_l) + self.new_peer_l.update(peer_l) for peer in peer_l: self.new_peer_state[peer] = peer_dict["peers"][peer]["state"] @@ -80,8 +80,8 @@ def get_all_neigh_states(self): return peer_info = json.loads(output) - # cmd ran successfully, safe to Clean the "new" lists/dic for new snapshot - del self.new_peer_l[:] + # cmd ran successfully, safe to Clean the "new" set/dict for new snapshot + self.new_peer_l.clear() self.new_peer_state.clear() for key, value in peer_info.items(): if key == "ipv4Unicast" or key == "ipv6Unicast": @@ -115,8 +115,7 @@ def flush_pipe(self, data): def update_neigh_states(self): data = {} - for i in range (0, len(self.new_peer_l)): - peer = self.new_peer_l[i] + for peer in self.new_peer_l: key = "NEIGH_STATE_TABLE|%s" % peer if peer in self.peer_l: # only update the entry if state changed @@ -125,7 +124,7 @@ def update_neigh_states(self): state = self.new_peer_state[peer] data[key] = {'state':state} self.peer_state[peer] = state - # remove this neighbor from old list since it is accounted for + # remove this neighbor from old set since it is accounted for self.peer_l.remove(peer) else: # New neighbor found case. Add to dictionary and state DB @@ -135,19 +134,19 @@ def update_neigh_states(self): if len(data) > PIPE_BATCH_MAX_COUNT: self.flush_pipe(data) # Check for stale state entries to be cleaned up - while len(self.peer_l) > 0: + for peer in self.peer_l: # remove this from the stateDB and the current neighbor state entry - peer = self.peer_l.pop(0) del_key = "NEIGH_STATE_TABLE|%s" % peer data[del_key] = None - del self.peer_state[peer] + if peer in self.peer_state: + del self.peer_state[peer] if len(data) > PIPE_BATCH_MAX_COUNT: self.flush_pipe(data) # If anything in the pipeline not yet flushed, flush them now if len(data) > 0: self.flush_pipe(data) - # Save the new List - self.peer_l = self.new_peer_l[:] + # Save the new set + self.peer_l = self.new_peer_l.copy() def main(): From 3706b31b490d32fcae50aea350f967d1e3b0bf37 Mon Sep 17 00:00:00 2001 From: Kebo Liu Date: Wed, 27 Jan 2021 21:39:54 +0800 Subject: [PATCH 0096/1674] Add hw-mgmt patch to support SDK OFFLINE event for handling flow within service firmware upgrade (#6550) During ISSU, "mlxsw_minimal" driver still trying to access firmware, in some cases FW could return some wrong critical threshold value which will cause switch shutdown. **- How I did it** In order to prevent "mlxsw_minimal" driver from accessing ASIC during ISSU, SDK will raise "OFFLINE" 'udev' event at the early beginning of such flow. When this event is received, hw-management will remove "mlxsw_minimal" driver. There is no need to implement the opposite "ONLINE" event since this flow is ended up with "kexec". **- How to verify it** repeatedly perform warm reboot, make sure there is no switch shutdown occurred. --- ...dd-support-for-SDK-OFFLINE-event-for.patch | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 platform/mellanox/hw-management/0002-hw-mgmt-events-Add-support-for-SDK-OFFLINE-event-for.patch diff --git a/platform/mellanox/hw-management/0002-hw-mgmt-events-Add-support-for-SDK-OFFLINE-event-for.patch b/platform/mellanox/hw-management/0002-hw-mgmt-events-Add-support-for-SDK-OFFLINE-event-for.patch new file mode 100644 index 000000000000..6c58f7299c2c --- /dev/null +++ b/platform/mellanox/hw-management/0002-hw-mgmt-events-Add-support-for-SDK-OFFLINE-event-for.patch @@ -0,0 +1,30 @@ +From 3e511778248403968e0a02857b7003f352669ba3 Mon Sep 17 00:00:00 2001 +From: Vadim Pasternak +Date: Wed, 13 Jan 2021 13:19:17 +0200 +Subject: [PATCH] hw-mgmt: events: Add support for SDK OFFLINE event for + handling flow with in service firmware upgrade + +In order to prevent "mlxsw_minimal" driver access to ASIC during in +service firmware upgrade flow, SDK will raise "OFFLINE" 'udev' event +at early beginning of such flow. When this event is received, +hw-managemnet will remove "mlxsw_minimal" driver. +There is no need to implement opposite "ONLINE" event, since this flow +is ended up with "kexec". + +Signed-off-by: Vadim Pasternak +--- + usr/lib/udev/rules.d/50-hw-management-events.rules | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/usr/lib/udev/rules.d/50-hw-management-events.rules b/usr/lib/udev/rules.d/50-hw-management-events.rules +index cf4219e..33ea1bc 100644 +--- a/usr/lib/udev/rules.d/50-hw-management-events.rules ++++ b/usr/lib/udev/rules.d/50-hw-management-events.rules +@@ -269,3 +269,4 @@ SUBSYSTEM=="i2c", DEVPATH=="/devices/platform/mlxplat/i2c_mlxcpld*/i2c-*/i2c-*/* + # SDK + SUBSYSTEM=="pci", DRIVERS=="sx_core", ACTION=="add", RUN+="/usr/bin/hw-management-thermal-events.sh add sxcore add" + SUBSYSTEM=="pci", DRIVERS=="sx_core", ACTION=="remove", RUN+="/usr/bin/hw-management-thermal-events.sh rm sxcore remove" ++SUBSYSTEM=="pci", DRIVERS=="sx_core", ACTION=="offline", RUN+="/usr/bin/hw-management-thermal-events.sh rm sxcore remove" +-- +1.9.1 + From 0b2abafcdebcc03ed70c8cec50fdba4857499d18 Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Sat, 23 Jan 2021 01:27:20 -0800 Subject: [PATCH 0097/1674] [docker-ptf]: build docker ptf - combine docker-ptf-saithrift into docker-ptf docker - build docker-ptf under platform vs - remove docker-ptf for other platforms Signed-off-by: Guohan Lu --- dockers/docker-ptf-saithrift/Dockerfile.j2 | 17 --------------- dockers/docker-ptf/Dockerfile.j2 | 14 ++++++++++++- .../brcm_interface_to_front_map.ini | 0 .../msn_2700_interface_to_front_map.ini | 0 platform/barefoot/docker-ptf-bfn.mk | 5 ----- platform/barefoot/rules.mk | 1 - platform/broadcom/docker-ptf-brcm.dep | 10 --------- platform/broadcom/docker-ptf-brcm.mk | 8 ------- platform/broadcom/rules.dep | 1 - platform/broadcom/rules.mk | 1 - platform/cavium/docker-ptf-cavm.mk | 8 ------- platform/cavium/rules.mk | 1 - platform/centec-arm64/docker-ptf-centec.mk | 7 ------- platform/centec-arm64/rules.mk | 1 - platform/centec/docker-ptf-centec.mk | 8 ------- platform/centec/rules.mk | 1 - platform/innovium/docker-ptf-invm.mk | 8 ------- platform/innovium/rules.mk | 1 - platform/marvell-arm64/docker-ptf-mrvl.mk | 8 ------- platform/marvell-arm64/rules.mk | 1 - platform/marvell-armhf/docker-ptf-mrvl.mk | 8 ------- platform/marvell-armhf/rules.mk | 1 - platform/mellanox/docker-ptf-mlnx.dep | 10 --------- platform/mellanox/docker-ptf-mlnx.mk | 8 ------- platform/mellanox/rules.dep | 1 - platform/mellanox/rules.mk | 1 - platform/nephos/docker-ptf-nephos.mk | 8 ------- platform/nephos/rules.mk | 1 - {rules => platform/vs}/docker-ptf.dep | 4 ++-- {rules => platform/vs}/docker-ptf.mk | 4 ++-- platform/vs/libsaithrift-dev.dep | 13 ++++++++++++ platform/vs/libsaithrift-dev.mk | 21 +++++++++++++++++++ platform/vs/rules.dep | 2 ++ platform/vs/rules.mk | 2 ++ 34 files changed, 55 insertions(+), 130 deletions(-) delete mode 100644 dockers/docker-ptf-saithrift/Dockerfile.j2 rename dockers/{docker-ptf-saithrift => docker-ptf}/brcm_interface_to_front_map.ini (100%) rename dockers/{docker-ptf-saithrift => docker-ptf}/msn_2700_interface_to_front_map.ini (100%) delete mode 100644 platform/barefoot/docker-ptf-bfn.mk delete mode 100644 platform/broadcom/docker-ptf-brcm.dep delete mode 100644 platform/broadcom/docker-ptf-brcm.mk delete mode 100644 platform/cavium/docker-ptf-cavm.mk delete mode 100755 platform/centec-arm64/docker-ptf-centec.mk delete mode 100644 platform/centec/docker-ptf-centec.mk delete mode 100755 platform/innovium/docker-ptf-invm.mk delete mode 100644 platform/marvell-arm64/docker-ptf-mrvl.mk delete mode 100644 platform/marvell-armhf/docker-ptf-mrvl.mk delete mode 100644 platform/mellanox/docker-ptf-mlnx.dep delete mode 100644 platform/mellanox/docker-ptf-mlnx.mk delete mode 100644 platform/nephos/docker-ptf-nephos.mk rename {rules => platform/vs}/docker-ptf.dep (62%) rename {rules => platform/vs}/docker-ptf.mk (57%) create mode 100644 platform/vs/libsaithrift-dev.dep create mode 100644 platform/vs/libsaithrift-dev.mk diff --git a/dockers/docker-ptf-saithrift/Dockerfile.j2 b/dockers/docker-ptf-saithrift/Dockerfile.j2 deleted file mode 100644 index 3076de4878b6..000000000000 --- a/dockers/docker-ptf-saithrift/Dockerfile.j2 +++ /dev/null @@ -1,17 +0,0 @@ -FROM docker-ptf - -## Make apt-get non-interactive -ENV DEBIAN_FRONTEND=noninteractive - -COPY \ -{% for deb in docker_ptf_saithrift_debs.split(' ') -%} -debs/{{ deb }}{{' '}} -{%- endfor -%} -debs/ - -RUN dpkg -i \ -{% for deb in docker_ptf_saithrift_debs.split(' ') -%} -debs/{{ deb }}{{' '}} -{%- endfor %} - -COPY ["*.ini", "/etc/ptf/"] diff --git a/dockers/docker-ptf/Dockerfile.j2 b/dockers/docker-ptf/Dockerfile.j2 index faa927d9db89..43eefcd9eeff 100644 --- a/dockers/docker-ptf/Dockerfile.j2 +++ b/dockers/docker-ptf/Dockerfile.j2 @@ -78,7 +78,7 @@ RUN rm -rf /debs \ && apt-get -y autoclean \ && apt-get -y autoremove \ && rm -rf /var/lib/apt/lists/* \ - && wget --https-only https://bootstrap.pypa.io/get-pip.py \ + && wget --https-only https://bootstrap.pypa.io/2.7/get-pip.py \ && python get-pip.py \ && rm -f get-pip.py \ && pip install setuptools \ @@ -146,6 +146,18 @@ RUN git clone https://github.com/lguohan/gnxi.git \ && cd gnmi_cli_py \ && pip install -r requirements.txt +COPY \ +{% for deb in docker_ptf_debs.split(' ') -%} +debs/{{ deb }}{{' '}} +{%- endfor -%} +debs/ + +RUN dpkg -i \ +{% for deb in docker_ptf_debs.split(' ') -%} +debs/{{ deb }}{{' '}} +{%- endfor %} + +COPY ["*.ini", "/etc/ptf/"] EXPOSE 22 8009 ENTRYPOINT ["/usr/local/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"] diff --git a/dockers/docker-ptf-saithrift/brcm_interface_to_front_map.ini b/dockers/docker-ptf/brcm_interface_to_front_map.ini similarity index 100% rename from dockers/docker-ptf-saithrift/brcm_interface_to_front_map.ini rename to dockers/docker-ptf/brcm_interface_to_front_map.ini diff --git a/dockers/docker-ptf-saithrift/msn_2700_interface_to_front_map.ini b/dockers/docker-ptf/msn_2700_interface_to_front_map.ini similarity index 100% rename from dockers/docker-ptf-saithrift/msn_2700_interface_to_front_map.ini rename to dockers/docker-ptf/msn_2700_interface_to_front_map.ini diff --git a/platform/barefoot/docker-ptf-bfn.mk b/platform/barefoot/docker-ptf-bfn.mk deleted file mode 100644 index 573e9cd9cffa..000000000000 --- a/platform/barefoot/docker-ptf-bfn.mk +++ /dev/null @@ -1,5 +0,0 @@ -# docker image for docker-ptf - -DOCKER_PTF_BFN = docker-ptf-bfn.gz -$(DOCKER_PTF_BFN)_PATH = $(DOCKERS_PATH)/docker-ptf-saithrift -$(DOCKER_PTF_BFN)_LOAD_DOCKERS += $(DOCKER_PTF) diff --git a/platform/barefoot/rules.mk b/platform/barefoot/rules.mk index a2948b12892b..98dcef0f7b8a 100644 --- a/platform/barefoot/rules.mk +++ b/platform/barefoot/rules.mk @@ -10,7 +10,6 @@ include $(PLATFORM_PATH)/docker-syncd-bfn-rpc.mk include $(PLATFORM_PATH)/one-aboot.mk include $(PLATFORM_PATH)/one-image.mk include $(PLATFORM_PATH)/libsaithrift-dev.mk -include $(PLATFORM_PATH)/docker-ptf-bfn.mk include $(PLATFORM_PATH)/bfn-platform.mk #include $(PLATFORM_PATH)/bfn-platform-wnc.mk #include $(PLATFORM_PATH)/bfn-platform-ingrasys.mk diff --git a/platform/broadcom/docker-ptf-brcm.dep b/platform/broadcom/docker-ptf-brcm.dep deleted file mode 100644 index b899d058d445..000000000000 --- a/platform/broadcom/docker-ptf-brcm.dep +++ /dev/null @@ -1,10 +0,0 @@ - -DPATH := $($(DOCKER_PTF_BRCM)_PATH) -DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/docker-ptf-brcm.mk platform/broadcom/docker-ptf-brcm.dep -DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) -DEP_FILES += $(shell git ls-files $(DPATH)) - -$(DOCKER_PTF_BRCM)_CACHE_MODE := GIT_CONTENT_SHA -$(DOCKER_PTF_BRCM)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) -$(DOCKER_PTF_BRCM)_DEP_FILES := $(DEP_FILES) - diff --git a/platform/broadcom/docker-ptf-brcm.mk b/platform/broadcom/docker-ptf-brcm.mk deleted file mode 100644 index 35780aea76ca..000000000000 --- a/platform/broadcom/docker-ptf-brcm.mk +++ /dev/null @@ -1,8 +0,0 @@ -# docker image for docker-ptf-brcm - -DOCKER_PTF_BRCM = docker-ptf-brcm.gz -$(DOCKER_PTF_BRCM)_PATH = $(DOCKERS_PATH)/docker-ptf-saithrift -$(DOCKER_PTF_BRCM)_DEPENDS += $(PYTHON_SAITHRIFT) -$(DOCKER_PTF_BRCM)_LOAD_DOCKERS += $(DOCKER_PTF) -SONIC_DOCKER_IMAGES += $(DOCKER_PTF_BRCM) -SONIC_STRETCH_DOCKERS += $(DOCKER_PTF_BRCM) diff --git a/platform/broadcom/rules.dep b/platform/broadcom/rules.dep index d8142ae3fb76..2e2d44ed018a 100644 --- a/platform/broadcom/rules.dep +++ b/platform/broadcom/rules.dep @@ -22,4 +22,3 @@ include $(PLATFORM_PATH)/one-pde-image.dep include $(PLATFORM_PATH)/raw-image.dep include $(PLATFORM_PATH)/one-aboot.dep include $(PLATFORM_PATH)/libsaithrift-dev.dep -include $(PLATFORM_PATH)/docker-ptf-brcm.dep diff --git a/platform/broadcom/rules.mk b/platform/broadcom/rules.mk index 34edfa0d37fd..fbe0dd689a2e 100644 --- a/platform/broadcom/rules.mk +++ b/platform/broadcom/rules.mk @@ -19,7 +19,6 @@ include $(PLATFORM_PATH)/one-image.mk include $(PLATFORM_PATH)/raw-image.mk include $(PLATFORM_PATH)/one-aboot.mk include $(PLATFORM_PATH)/libsaithrift-dev.mk -include $(PLATFORM_PATH)/docker-ptf-brcm.mk BCMCMD = bcmcmd $(BCMCMD)_URL = "https://sonicstorage.blob.core.windows.net/packages/20190307/bcmcmd?sv=2015-04-05&sr=b&sig=sUdbU7oVbh5exbXXHVL5TDFBTWDDBASHeJ8Cp0B0TIc%3D&se=2038-05-06T22%3A34%3A19Z&sp=r" diff --git a/platform/cavium/docker-ptf-cavm.mk b/platform/cavium/docker-ptf-cavm.mk deleted file mode 100644 index ea96fd050bfe..000000000000 --- a/platform/cavium/docker-ptf-cavm.mk +++ /dev/null @@ -1,8 +0,0 @@ -# docker image for docker-ptf-cavm - -DOCKER_PTF_CAVM = docker-ptf-cavm.gz -$(DOCKER_PTF_CAVM)_PATH = $(DOCKERS_PATH)/docker-ptf-saithrift -$(DOCKER_PTF_CAVM)_DEPENDS += $(PYTHON_SAITHRIFT_CAVM) -$(DOCKER_PTF_CAVM)_LOAD_DOCKERS += $(DOCKER_PTF) -SONIC_DOCKER_IMAGES += $(DOCKER_PTF_CAVM) -SONIC_STRETCH_DOCKERS += $(DOCKER_PTF_CAVM) diff --git a/platform/cavium/rules.mk b/platform/cavium/rules.mk index bbc2e4d2d2f0..a526774d2951 100644 --- a/platform/cavium/rules.mk +++ b/platform/cavium/rules.mk @@ -5,7 +5,6 @@ include $(PLATFORM_PATH)/cavm-platform-modules.mk include $(PLATFORM_PATH)/cavm-xpnet.mk include $(PLATFORM_PATH)/one-image.mk include $(PLATFORM_PATH)/libsaithrift-dev.mk -include $(PLATFORM_PATH)/docker-ptf-cavm.mk SONIC_ALL += $(SONIC_ONE_IMAGE) \ $(DOCKER_FPM) \ diff --git a/platform/centec-arm64/docker-ptf-centec.mk b/platform/centec-arm64/docker-ptf-centec.mk deleted file mode 100755 index 3d4fe50e5f1f..000000000000 --- a/platform/centec-arm64/docker-ptf-centec.mk +++ /dev/null @@ -1,7 +0,0 @@ -# docker image for docker-ptf-centec - -DOCKER_PTF_CENTEC = docker-ptf-centec.gz -$(DOCKER_PTF_CENTEC)_PATH = $(DOCKERS_PATH)/docker-ptf-saithrift -$(DOCKER_PTF_CENTEC)_DEPENDS += $(PYTHON_SAITHRIFT) -$(DOCKER_PTF_CENTEC)_LOAD_DOCKERS += $(DOCKER_PTF) -SONIC_DOCKER_IMAGES += $(DOCKER_PTF_CENTEC) diff --git a/platform/centec-arm64/rules.mk b/platform/centec-arm64/rules.mk index 79e1ab12b880..1982f86b757c 100755 --- a/platform/centec-arm64/rules.mk +++ b/platform/centec-arm64/rules.mk @@ -3,7 +3,6 @@ include $(PLATFORM_PATH)/docker-syncd-centec.mk include $(PLATFORM_PATH)/docker-syncd-centec-rpc.mk include $(PLATFORM_PATH)/one-image.mk include $(PLATFORM_PATH)/libsaithrift-dev.mk -include $(PLATFORM_PATH)/docker-ptf-centec.mk include $(PLATFORM_PATH)/tsingma-bsp.mk include $(PLATFORM_PATH)/platform-modules-centec-e530.mk diff --git a/platform/centec/docker-ptf-centec.mk b/platform/centec/docker-ptf-centec.mk deleted file mode 100644 index 47284f71756c..000000000000 --- a/platform/centec/docker-ptf-centec.mk +++ /dev/null @@ -1,8 +0,0 @@ -# docker image for docker-ptf-centec - -DOCKER_PTF_CENTEC = docker-ptf-centec.gz -$(DOCKER_PTF_CENTEC)_PATH = $(DOCKERS_PATH)/docker-ptf-saithrift -$(DOCKER_PTF_CENTEC)_DEPENDS += $(PYTHON_SAITHRIFT) -$(DOCKER_PTF_CENTEC)_LOAD_DOCKERS += $(DOCKER_PTF) -SONIC_DOCKER_IMAGES += $(DOCKER_PTF_CENTEC) -SONIC_STRETCH_DOCKERS += $(DOCKER_PTF_CENTEC) diff --git a/platform/centec/rules.mk b/platform/centec/rules.mk index 52bb0275abff..182248ec1ac6 100644 --- a/platform/centec/rules.mk +++ b/platform/centec/rules.mk @@ -5,7 +5,6 @@ include $(PLATFORM_PATH)/docker-syncd-centec.mk include $(PLATFORM_PATH)/docker-syncd-centec-rpc.mk include $(PLATFORM_PATH)/one-image.mk include $(PLATFORM_PATH)/libsaithrift-dev.mk -include $(PLATFORM_PATH)/docker-ptf-centec.mk SONIC_ALL += $(SONIC_ONE_IMAGE) diff --git a/platform/innovium/docker-ptf-invm.mk b/platform/innovium/docker-ptf-invm.mk deleted file mode 100755 index 53ba41e9d386..000000000000 --- a/platform/innovium/docker-ptf-invm.mk +++ /dev/null @@ -1,8 +0,0 @@ -# docker image for docker-ptf-invm - -DOCKER_PTF_INVM = docker-ptf-invm.gz -$(DOCKER_PTF_INVM)_PATH = $(DOCKERS_PATH)/docker-ptf-saithrift -$(DOCKER_PTF_INVM)_DEPENDS += $(PYTHON_SAITHRIFT_INVM) -$(DOCKER_PTF_INVM)_LOAD_DOCKERS += $(DOCKER_PTF) -SONIC_DOCKER_IMAGES += $(DOCKER_PTF_INVM) -SONIC_STRETCH_DOCKERS += $(DOCKER_PTF_INVM) diff --git a/platform/innovium/rules.mk b/platform/innovium/rules.mk index 0387a4ba30f0..ea23466ad578 100755 --- a/platform/innovium/rules.mk +++ b/platform/innovium/rules.mk @@ -6,7 +6,6 @@ include $(PLATFORM_PATH)/docker-syncd-invm-rpc.mk include $(PLATFORM_PATH)/one-image.mk include $(PLATFORM_PATH)/libsaithrift-dev.mk include $(PLATFORM_PATH)/python-saithrift.mk -include $(PLATFORM_PATH)/docker-ptf-invm.mk SONIC_ALL += $(SONIC_INVM_ONE_IMAGE) \ $(DOCKER_FPM) \ diff --git a/platform/marvell-arm64/docker-ptf-mrvl.mk b/platform/marvell-arm64/docker-ptf-mrvl.mk deleted file mode 100644 index 72c860aec868..000000000000 --- a/platform/marvell-arm64/docker-ptf-mrvl.mk +++ /dev/null @@ -1,8 +0,0 @@ -# docker image for docker-ptf-mrvl - -DOCKER_PTF_MRVL = docker-ptf-mrvl.gz -$(DOCKER_PTF_MRVL)_PATH = $(DOCKERS_PATH)/docker-ptf-saithrift -$(DOCKER_PTF_MRVL)_DEPENDS += $(PYTHON_SAITHRIFT) -$(DOCKER_PTF_MRVL)_LOAD_DOCKERS += $(DOCKER_PTF) -SONIC_DOCKER_IMAGES += $(DOCKER_PTF_MRVL) -SONIC_STRETCH_DOCKERS += $(DOCKER_PTF_MRVL) diff --git a/platform/marvell-arm64/rules.mk b/platform/marvell-arm64/rules.mk index c3d7092ebb82..f8e4c12a49ff 100644 --- a/platform/marvell-arm64/rules.mk +++ b/platform/marvell-arm64/rules.mk @@ -4,7 +4,6 @@ include $(PLATFORM_PATH)/docker-syncd-mrvl.mk include $(PLATFORM_PATH)/docker-syncd-mrvl-rpc.mk include $(PLATFORM_PATH)/docker-saiserver-mrvl.mk include $(PLATFORM_PATH)/libsaithrift-dev.mk -include $(PLATFORM_PATH)/docker-ptf-mrvl.mk include $(PLATFORM_PATH)/one-image.mk include $(PLATFORM_PATH)/linux-kernel-arm64.mk INCLUDE_SYSTEM_TELEMETRY = "" diff --git a/platform/marvell-armhf/docker-ptf-mrvl.mk b/platform/marvell-armhf/docker-ptf-mrvl.mk deleted file mode 100644 index 72c860aec868..000000000000 --- a/platform/marvell-armhf/docker-ptf-mrvl.mk +++ /dev/null @@ -1,8 +0,0 @@ -# docker image for docker-ptf-mrvl - -DOCKER_PTF_MRVL = docker-ptf-mrvl.gz -$(DOCKER_PTF_MRVL)_PATH = $(DOCKERS_PATH)/docker-ptf-saithrift -$(DOCKER_PTF_MRVL)_DEPENDS += $(PYTHON_SAITHRIFT) -$(DOCKER_PTF_MRVL)_LOAD_DOCKERS += $(DOCKER_PTF) -SONIC_DOCKER_IMAGES += $(DOCKER_PTF_MRVL) -SONIC_STRETCH_DOCKERS += $(DOCKER_PTF_MRVL) diff --git a/platform/marvell-armhf/rules.mk b/platform/marvell-armhf/rules.mk index 27d3167edd03..58b9654956f3 100644 --- a/platform/marvell-armhf/rules.mk +++ b/platform/marvell-armhf/rules.mk @@ -4,7 +4,6 @@ include $(PLATFORM_PATH)/docker-syncd-mrvl.mk include $(PLATFORM_PATH)/docker-syncd-mrvl-rpc.mk include $(PLATFORM_PATH)/docker-saiserver-mrvl.mk include $(PLATFORM_PATH)/libsaithrift-dev.mk -include $(PLATFORM_PATH)/docker-ptf-mrvl.mk include $(PLATFORM_PATH)/one-image.mk include $(PLATFORM_PATH)/linux-kernel-armhf.mk include $(PLATFORM_PATH)/platform-et6448m.mk diff --git a/platform/mellanox/docker-ptf-mlnx.dep b/platform/mellanox/docker-ptf-mlnx.dep deleted file mode 100644 index 652fe0001c76..000000000000 --- a/platform/mellanox/docker-ptf-mlnx.dep +++ /dev/null @@ -1,10 +0,0 @@ -# DPKG FRK - -DPATH := $($(DOCKER_PTF_MLNX)_PATH) -DEP_FILES := $(SONIC_COMMON_FILES_LIST) $(PLATFORM_PATH)/docker-ptf-mlnx.mk $(PLATFORM_PATH)/docker-ptf-mlnx.dep -DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) -DEP_FILES += $(shell git ls-files -- $(DPATH)) - -$(DOCKER_PTF_MLNX)_CACHE_MODE := GIT_CONTENT_SHA -$(DOCKER_PTF_MLNX)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) -$(DOCKER_PTF_MLNX)_DEP_FILES := $(DEP_FILES) diff --git a/platform/mellanox/docker-ptf-mlnx.mk b/platform/mellanox/docker-ptf-mlnx.mk deleted file mode 100644 index eaaa54897d80..000000000000 --- a/platform/mellanox/docker-ptf-mlnx.mk +++ /dev/null @@ -1,8 +0,0 @@ -# docker image for docker-ptf-mlnx - -DOCKER_PTF_MLNX = docker-ptf-mlnx.gz -$(DOCKER_PTF_MLNX)_PATH = $(DOCKERS_PATH)/docker-ptf-saithrift -$(DOCKER_PTF_MLNX)_DEPENDS += $(PYTHON_SAITHRIFT) -$(DOCKER_PTF_MLNX)_LOAD_DOCKERS += $(DOCKER_PTF) -SONIC_DOCKER_IMAGES += $(DOCKER_PTF_MLNX) -SONIC_STRETCH_DOCKERS += $(DOCKER_PTF_MLNX) diff --git a/platform/mellanox/rules.dep b/platform/mellanox/rules.dep index 8986eb2e0808..409857592159 100644 --- a/platform/mellanox/rules.dep +++ b/platform/mellanox/rules.dep @@ -11,7 +11,6 @@ include $(PLATFORM_PATH)/docker-syncd-mlnx-rpc.dep include $(PLATFORM_PATH)/docker-saiserver-mlnx.dep include $(PLATFORM_PATH)/one-image.dep include $(PLATFORM_PATH)/libsaithrift-dev.dep -include $(PLATFORM_PATH)/docker-ptf-mlnx.dep include $(PLATFORM_PATH)/mlnx-ffb.dep include $(PLATFORM_PATH)/issu-version.dep include $(PLATFORM_PATH)/mlnx-onie-fw-update.dep diff --git a/platform/mellanox/rules.mk b/platform/mellanox/rules.mk index 1e2ca78a195b..179e20f3fff5 100644 --- a/platform/mellanox/rules.mk +++ b/platform/mellanox/rules.mk @@ -9,7 +9,6 @@ include $(PLATFORM_PATH)/docker-syncd-mlnx-rpc.mk include $(PLATFORM_PATH)/docker-saiserver-mlnx.mk include $(PLATFORM_PATH)/one-image.mk include $(PLATFORM_PATH)/libsaithrift-dev.mk -include $(PLATFORM_PATH)/docker-ptf-mlnx.mk include $(PLATFORM_PATH)/mlnx-ffb.mk include $(PLATFORM_PATH)/issu-version.mk include $(PLATFORM_PATH)/mlnx-onie-fw-update.mk diff --git a/platform/nephos/docker-ptf-nephos.mk b/platform/nephos/docker-ptf-nephos.mk deleted file mode 100644 index 15855bc89a1f..000000000000 --- a/platform/nephos/docker-ptf-nephos.mk +++ /dev/null @@ -1,8 +0,0 @@ -# docker image for docker-ptf-nephos - -DOCKER_PTF_NEPHOS = docker-ptf-nephos.gz -$(DOCKER_PTF_NEPHOS)_PATH = $(DOCKERS_PATH)/docker-ptf-saithrift -$(DOCKER_PTF_NEPHOS)_DEPENDS += $(PYTHON_SAITHRIFT_NEPHOS) -$(DOCKER_PTF_NEPHOS)_LOAD_DOCKERS += $(DOCKER_PTF) -SONIC_DOCKER_IMAGES += $(DOCKER_PTF_NEPHOS) -SONIC_STRETCH_DOCKERS += $(DOCKER_PTF_NEPHOS) diff --git a/platform/nephos/rules.mk b/platform/nephos/rules.mk index 8950c665deef..4ee2443e7585 100644 --- a/platform/nephos/rules.mk +++ b/platform/nephos/rules.mk @@ -7,7 +7,6 @@ include $(PLATFORM_PATH)/docker-syncd-nephos.mk include $(PLATFORM_PATH)/docker-syncd-nephos-rpc.mk include $(PLATFORM_PATH)/one-image.mk include $(PLATFORM_PATH)/libsaithrift-dev.mk -include $(PLATFORM_PATH)/docker-ptf-nephos.mk NPX_DIAG = npx_diag $(NPX_DIAG)_URL = "https://github.com/NephosInc/SONiC/raw/master/sdk/npx_diag" diff --git a/rules/docker-ptf.dep b/platform/vs/docker-ptf.dep similarity index 62% rename from rules/docker-ptf.dep rename to platform/vs/docker-ptf.dep index d62019e9b386..8cd9f7b7a279 100644 --- a/rules/docker-ptf.dep +++ b/platform/vs/docker-ptf.dep @@ -1,10 +1,10 @@ DPATH := $($(DOCKER_PTF)_PATH) -DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/docker-ptf.mk rules/docker-ptf.dep +DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/vs/docker-ptf.mk platform/vs/docker-ptf.dep DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) DEP_FILES += $(shell git ls-files $(DPATH)) -$(DOCKER_PTF)_CACHE_MODE := GIT_CONTENT_SHA +$(DOCKER_PTF)_CACHE_MODE := GIT_CONTENT_SHA $(DOCKER_PTF)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) $(DOCKER_PTF)_DEP_FILES := $(DEP_FILES) diff --git a/rules/docker-ptf.mk b/platform/vs/docker-ptf.mk similarity index 57% rename from rules/docker-ptf.mk rename to platform/vs/docker-ptf.mk index b2d45068334d..4fde844fe24b 100644 --- a/rules/docker-ptf.mk +++ b/platform/vs/docker-ptf.mk @@ -1,7 +1,7 @@ -# docker image for ptf +# docker image for docker-ptf DOCKER_PTF = docker-ptf.gz $(DOCKER_PTF)_PATH = $(DOCKERS_PATH)/docker-ptf -$(DOCKER_PTF)_DEPENDS += $(LIBTHRIFT) $(PYTHON_THRIFT) $(PTF) +$(DOCKER_PTF)_DEPENDS += $(LIBTHRIFT) $(PYTHON_THRIFT) $(PTF) $(PYTHON_SAITHRIFT) SONIC_DOCKER_IMAGES += $(DOCKER_PTF) SONIC_STRETCH_DOCKERS += $(DOCKER_PTF) diff --git a/platform/vs/libsaithrift-dev.dep b/platform/vs/libsaithrift-dev.dep new file mode 100644 index 000000000000..be1d3f74b23f --- /dev/null +++ b/platform/vs/libsaithrift-dev.dep @@ -0,0 +1,13 @@ +#DPKG FRK +SPATH := $($(LIBSAITHRIFT_DEV)_SRC_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/libsaithrift-dev.mk platform/broadcom/libsaithrift-dev.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +SMDEP_PATHS := $(SPATH) $(SPATH)/bm/behavioral-model $(SPATH)/test/ptf $(SPATH)/test/saithrift/ctypesgen +$(foreach path, $(SMDEP_PATHS), $(eval $(path) :=$(filter-out $(SMDEP_PATHS),$(addprefix $(path)/, $(shell cd $(path) && git ls-files | grep -Ev " " ))))) + +$(LIBSAITHRIFT_DEV)_CACHE_MODE := GIT_CONTENT_SHA +$(LIBSAITHRIFT_DEV)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(LIBSAITHRIFT_DEV)_DEP_FILES := $(DEP_FILES) +$(LIBSAITHRIFT_DEV)_SMDEP_FILES := $(foreach path, $(SMDEP_PATHS), $($(path))) +$(LIBSAITHRIFT_DEV)_SMDEP_PATHS := $(SMDEP_PATHS) + diff --git a/platform/vs/libsaithrift-dev.mk b/platform/vs/libsaithrift-dev.mk new file mode 100644 index 000000000000..915210f99f0e --- /dev/null +++ b/platform/vs/libsaithrift-dev.mk @@ -0,0 +1,21 @@ +# libsaithrift-dev package + +SAI_VER = 0.9.4 + +LIBSAITHRIFT_DEV = libsaithrift-dev_$(SAI_VER)_$(CONFIGURED_ARCH).deb +$(LIBSAITHRIFT_DEV)_SRC_PATH = $(SRC_PATH)/sonic-sairedis/SAI +$(LIBSAITHRIFT_DEV)_DEPENDS += $(LIBTHRIFT) $(LIBTHRIFT_DEV) $(PYTHON_THRIFT) $(THRIFT_COMPILER) \ + $(LIBSAIVS) $(LIBSAIVS_DEV) $(LIBSAIMETADATA) $(LIBSAIMETADATA_DEV) +$(LIBSAITHRIFT_DEV)_RDEPENDS += $(LIBTHRIFT) $(LIBSAIVS) $(LIBSAIMETADATA) +SONIC_DPKG_DEBS += $(LIBSAITHRIFT_DEV) + +PYTHON_SAITHRIFT = python-saithrift_$(SAI_VER)_$(CONFIGURED_ARCH).deb +$(eval $(call add_extra_package,$(LIBSAITHRIFT_DEV),$(PYTHON_SAITHRIFT))) + +SAISERVER = saiserver_$(SAI_VER)_$(CONFIGURED_ARCH).deb +$(SAISERVER)_RDEPENDS += $(LIBTHRIFT) $(LIBSAIVS) +$(eval $(call add_extra_package,$(LIBSAITHRIFT_DEV),$(SAISERVER))) + +SAISERVER_DBG = saiserver-dbg_$(SAI_VER)_$(CONFIGURED_ARCH).deb +$(SAISERVER_DBG)_RDEPENDS += $(SAISERVER) +$(eval $(call add_extra_package,$(LIBSAITHRIFT_DEV),$(SAISERVER_DBG))) diff --git a/platform/vs/rules.dep b/platform/vs/rules.dep index 7a5346619e70..0d485e8004d1 100644 --- a/platform/vs/rules.dep +++ b/platform/vs/rules.dep @@ -3,6 +3,8 @@ include $(PLATFORM_PATH)/sonic-version.dep include $(PLATFORM_PATH)/docker-sonic-vs.dep include $(PLATFORM_PATH)/docker-syncd-vs.dep include $(PLATFORM_PATH)/docker-gbsyncd-vs.dep +include $(PLATFORM_PATH)/docker-ptf.dep +include $(PLATFORM_PATH)/libsaithrift-dev.dep include $(PLATFORM_PATH)/one-image.dep include $(PLATFORM_PATH)/onie.dep include $(PLATFORM_PATH)/kvm-image.dep diff --git a/platform/vs/rules.mk b/platform/vs/rules.mk index 66e8bad5fe78..cbb52847edfa 100644 --- a/platform/vs/rules.mk +++ b/platform/vs/rules.mk @@ -3,6 +3,8 @@ include $(PLATFORM_PATH)/sonic-version.mk include $(PLATFORM_PATH)/docker-sonic-vs.mk include $(PLATFORM_PATH)/docker-syncd-vs.mk include $(PLATFORM_PATH)/docker-gbsyncd-vs.mk +include $(PLATFORM_PATH)/docker-ptf.mk +include $(PLATFORM_PATH)/libsaithrift-dev.mk include $(PLATFORM_PATH)/one-image.mk include $(PLATFORM_PATH)/onie.mk include $(PLATFORM_PATH)/kvm-image.mk From 11a8e89f27870c0ed20c8b56efb542c6f36a0afd Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Sat, 23 Jan 2021 23:41:00 -0800 Subject: [PATCH 0098/1674] [build]: add _BUILD_ENV to specify env for dpkg-buildpackage Signed-off-by: Guohan Lu --- platform/vs/libsaithrift-dev.mk | 1 + slave.mk | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/platform/vs/libsaithrift-dev.mk b/platform/vs/libsaithrift-dev.mk index 915210f99f0e..ba8a63d539ac 100644 --- a/platform/vs/libsaithrift-dev.mk +++ b/platform/vs/libsaithrift-dev.mk @@ -7,6 +7,7 @@ $(LIBSAITHRIFT_DEV)_SRC_PATH = $(SRC_PATH)/sonic-sairedis/SAI $(LIBSAITHRIFT_DEV)_DEPENDS += $(LIBTHRIFT) $(LIBTHRIFT_DEV) $(PYTHON_THRIFT) $(THRIFT_COMPILER) \ $(LIBSAIVS) $(LIBSAIVS_DEV) $(LIBSAIMETADATA) $(LIBSAIMETADATA_DEV) $(LIBSAITHRIFT_DEV)_RDEPENDS += $(LIBTHRIFT) $(LIBSAIVS) $(LIBSAIMETADATA) +$(LIBSAITHRIFT_DEV)_BUILD_ENV = platform=vs SONIC_DPKG_DEBS += $(LIBSAITHRIFT_DEV) PYTHON_SAITHRIFT = python-saithrift_$(SAI_VER)_$(CONFIGURED_ARCH).deb diff --git a/slave.mk b/slave.mk index 728bb8be16cf..775e566a1532 100644 --- a/slave.mk +++ b/slave.mk @@ -464,8 +464,8 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_DPKG_DEBS)) : $(DEBS_PATH)/% : .platform $$(a if [ -f ./autogen.sh ]; then ./autogen.sh $(LOG); fi $(SETUP_OVERLAYFS_FOR_DPKG_ADMINDIR) $(if $($*_DPKG_TARGET), - DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC} ${$*_DEB_BUILD_OPTIONS}" dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --as-root -T$($*_DPKG_TARGET) --admindir $$mergedir $(LOG), - DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC} ${$*_DEB_BUILD_OPTIONS}" dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $$mergedir $(LOG) + ${$*_BUILD_ENV} DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC} ${$*_DEB_BUILD_OPTIONS}" dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --as-root -T$($*_DPKG_TARGET) --admindir $$mergedir $(LOG), + ${$*_BUILD_ENV} DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS_GENERIC} ${$*_DEB_BUILD_OPTIONS}" dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $$mergedir $(LOG) ) popd $(LOG_SIMPLE) # Clean up From e469460ef368e325a9c8c6a82828efd5acc8b7aa Mon Sep 17 00:00:00 2001 From: dflynn-Nokia <60479697+dflynn-Nokia@users.noreply.github.com> Date: Wed, 27 Jan 2021 15:27:41 -0500 Subject: [PATCH 0099/1674] [docker-config-engine-stretch]: Fix dependency typo PYTHON2_SWSSCOMMON (#6568) This commit fixes a typo in the fix delivered in PR #6538 syncd fails on the armhf platform within sonic-config-engine/portconfig.py when importing the following 'from swsscommon.swsscommon import ConfigDBConnector' --- rules/docker-config-engine-stretch.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/docker-config-engine-stretch.mk b/rules/docker-config-engine-stretch.mk index ad112bb034dc..7e90c1587a9d 100644 --- a/rules/docker-config-engine-stretch.mk +++ b/rules/docker-config-engine-stretch.mk @@ -2,7 +2,7 @@ DOCKER_CONFIG_ENGINE_STRETCH = docker-config-engine-stretch.gz $(DOCKER_CONFIG_ENGINE_STRETCH)_PATH = $(DOCKERS_PATH)/docker-config-engine-stretch -$(DOCKER_CONFIG_ENGINE_STRETCH)_DEPENDS += $(LIBSWSSCOMMON) $(PYTHON2_SWSSCOMMON) +$(DOCKER_CONFIG_ENGINE_STRETCH)_DEPENDS += $(LIBSWSSCOMMON) $(PYTHON_SWSSCOMMON) $(DOCKER_CONFIG_ENGINE_STRETCH)_PYTHON_WHEELS += $(SWSSSDK_PY2) $(DOCKER_CONFIG_ENGINE_STRETCH)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY2) $(DOCKER_CONFIG_ENGINE_STRETCH)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY2) From 7fc8caa36b45000ebc46b5d6631e0959c06774f8 Mon Sep 17 00:00:00 2001 From: Kebo Liu Date: Thu, 28 Jan 2021 04:29:28 +0800 Subject: [PATCH 0100/1674] [mellanox]: Update SAI to sonic2012 1.18.1.0 (#6566) Changes in the new release: 1. Policy based hashing optimization 2. New attribute support for Max port headroom 3. Tunnel ECN map fixes 4. Tunnel EVPN skeleton extensions (peer attrib, maps) 5. Bridge port admin not affecting port admin (optimize port down time) 6. CRM new API for neighbors and tunnel termination entries 7. Improve FDB event for flush by bridge port (before, null bridge was reported to SONiC, now the bridge will be extracted from bridge port) 8. DHCP L2 v4+v6 traps (for ZTP use case) 9. Generic counter implementation Signed-off-by: Kebo Liu --- platform/mellanox/mlnx-sai.mk | 2 +- platform/mellanox/mlnx-sai/SAI-Implementation | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/mellanox/mlnx-sai.mk b/platform/mellanox/mlnx-sai.mk index 0c1795cf41a3..7f16a72cc076 100644 --- a/platform/mellanox/mlnx-sai.mk +++ b/platform/mellanox/mlnx-sai.mk @@ -1,6 +1,6 @@ # Mellanox SAI -MLNX_SAI_VERSION = SAIRel1.18.0.2-master +MLNX_SAI_VERSION = SAIRel1.18.1.0 export MLNX_SAI_VERSION diff --git a/platform/mellanox/mlnx-sai/SAI-Implementation b/platform/mellanox/mlnx-sai/SAI-Implementation index ad1e9c7279e5..2902c78672eb 160000 --- a/platform/mellanox/mlnx-sai/SAI-Implementation +++ b/platform/mellanox/mlnx-sai/SAI-Implementation @@ -1 +1 @@ -Subproject commit ad1e9c7279e544b93fef9a40fb41df375338b55e +Subproject commit 2902c78672eb9602296fd17654f29a21ddaf8290 From fc825f9a58671164a115ce9b3e6830194418a800 Mon Sep 17 00:00:00 2001 From: Shi Su <67605788+shi-su@users.noreply.github.com> Date: Wed, 27 Jan 2021 12:36:02 -0800 Subject: [PATCH 0101/1674] [FRR] Create a separate script to wait zebra to be ready to receive connections (#6519) The requirement for zebra to be ready to accept connections is a generic problem that is not specific to bgpd. Making the script to wait for zebra socket a separate script and let bgpd and staticd to wait for zebra socket. --- dockers/docker-fpm-frr/Dockerfile.j2 | 5 +++-- .../frr/supervisord/supervisord.conf.j2 | 17 ++++++++++++++--- dockers/docker-fpm-frr/{bgpd.sh => zsocket.sh} | 11 +++++++---- 3 files changed, 24 insertions(+), 9 deletions(-) rename dockers/docker-fpm-frr/{bgpd.sh => zsocket.sh} (70%) diff --git a/dockers/docker-fpm-frr/Dockerfile.j2 b/dockers/docker-fpm-frr/Dockerfile.j2 index 302f38c8b579..360d64a12b82 100644 --- a/dockers/docker-fpm-frr/Dockerfile.j2 +++ b/dockers/docker-fpm-frr/Dockerfile.j2 @@ -54,9 +54,10 @@ COPY ["TSA", "/usr/bin/TSA"] COPY ["TSB", "/usr/bin/TSB"] COPY ["TSC", "/usr/bin/TSC"] COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] -COPY ["bgpd.sh", "/usr/bin/"] +COPY ["zsocket.sh", "/usr/bin/"] RUN chmod a+x /usr/bin/TSA && \ chmod a+x /usr/bin/TSB && \ - chmod a+x /usr/bin/TSC + chmod a+x /usr/bin/TSC && \ + chmod a+x /usr/bin/zsocket.sh ENTRYPOINT ["/usr/bin/docker_init.sh"] diff --git a/dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2 b/dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2 index dc52bd1b5336..a6327936954f 100644 --- a/dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2 +++ b/dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2 @@ -39,6 +39,17 @@ stderr_logfile=syslog dependent_startup=true dependent_startup_wait_for=rsyslogd:running +[program:zsocket] +command=/usr/bin/zsocket.sh +priority=4 +autostart=false +autorestart=false +startsecs=0 +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=zebra:running + [program:staticd] command=/usr/lib/frr/staticd -A 127.0.0.1 priority=4 @@ -48,7 +59,7 @@ startsecs=0 stdout_logfile=syslog stderr_logfile=syslog dependent_startup=true -dependent_startup_wait_for=zebra:running +dependent_startup_wait_for=zsocket:exited {% if DEVICE_METADATA.localhost.frr_mgmt_framework_config is defined and DEVICE_METADATA.localhost.frr_mgmt_framework_config == "true" %} [program:bfdd] @@ -65,7 +76,7 @@ dependent_startup_wait_for=zebra:running {% endif %} [program:bgpd] -command=/usr/bin/bgpd.sh -A 127.0.0.1 -M snmp +command=/usr/lib/frr/bgpd -A 127.0.0.1 -M snmp priority=5 stopsignal=KILL autostart=false @@ -74,7 +85,7 @@ startsecs=0 stdout_logfile=syslog stderr_logfile=syslog dependent_startup=true -dependent_startup_wait_for=zebra:running +dependent_startup_wait_for=zsocket:exited {% if DEVICE_METADATA.localhost.frr_mgmt_framework_config is defined and DEVICE_METADATA.localhost.frr_mgmt_framework_config == "true" %} [program:ospfd] diff --git a/dockers/docker-fpm-frr/bgpd.sh b/dockers/docker-fpm-frr/zsocket.sh similarity index 70% rename from dockers/docker-fpm-frr/bgpd.sh rename to dockers/docker-fpm-frr/zsocket.sh index c61a594a1efc..111492f960ed 100755 --- a/dockers/docker-fpm-frr/bgpd.sh +++ b/dockers/docker-fpm-frr/zsocket.sh @@ -5,8 +5,8 @@ port=2601 function help() { - echo "This script aims to ensure zebra is ready to accept connections before starting bgpd" - echo "Usage: $0 [options] [bgpd options]" + echo "This script aims to ensure zebra is ready to accept connections" + echo "Usage: $0 [options]" echo "Options:" echo " -a Zebra address" echo " -o Zebra port" @@ -23,11 +23,14 @@ while getopts ":a:o:h" opt; do ;; esac done -shift $((OPTIND-1)) +start=$(date +%s.%N) timeout 5s bash -c -- "until Date: Thu, 21 Jan 2021 12:57:49 -0800 Subject: [PATCH 0102/1674] [supervisord] Monitoring the critical processes with supervisord. (#6242) - Why I did it Initially, we used Monit to monitor critical processes in each container. If one of critical processes was not running or crashed due to some reasons, then Monit will write an alerting message into syslog periodically. If we add a new process in a container, the corresponding Monti configuration file will also need to update. It is a little hard for maintenance. Currently we employed event listener of Supervisod to do this monitoring. Since processes in each container are managed by Supervisord, we can only focus on the logic of monitoring. - How I did it We borrowed the event listener of Supervisord to monitor critical processes in containers. The event listener will take following steps if it was notified one of critical processes exited unexpectedly: The event listener will first check whether the auto-restart mechanism was enabled for this container or not. If auto-restart mechanism was enabled, event listener will kill the Supervisord process, which should cause the container to exit and subsequently get restarted. If auto-restart mechanism was not enabled for this contianer, the event listener will enter a loop which will first sleep 1 minute and then check whether the process is running. If yes, the event listener exits. If no, an alerting message will be written into syslog. - How to verify it First, we need checked whether the auto-restart mechanism of a container was enabled or not by running the command show feature status. If enabled, one critical process should be selected and killed manually, then we need check whether the container will be restarted or not. Second, we can disable the auto-restart mechanism if it was enabled at step 1 by running the commnad sudo config feature autorestart disabled. Then one critical process should be selected and killed. After that, we will see the alerting message which will appear in the syslog every 1 minute. - Which release branch to backport (provide reason below if selected) 201811 201911 [x ] 202006 --- dockers/docker-database/supervisord.conf.j2 | 2 +- .../docker-dhcp-relay.supervisord.conf.j2 | 2 +- .../frr/supervisord/supervisord.conf.j2 | 2 +- dockers/docker-fpm-gobgp/supervisord.conf | 2 +- dockers/docker-fpm-quagga/supervisord.conf | 2 +- dockers/docker-lldp/supervisord.conf.j2 | 2 +- dockers/docker-nat/supervisord.conf | 2 +- dockers/docker-orchagent/supervisord.conf | 2 +- .../docker-pmon.supervisord.conf.j2 | 2 +- ...cker-router-advertiser.supervisord.conf.j2 | 2 +- dockers/docker-sflow/supervisord.conf | 2 +- dockers/docker-snmp/supervisord.conf | 2 +- dockers/docker-sonic-restapi/supervisord.conf | 2 +- .../docker-sonic-telemetry/supervisord.conf | 2 +- dockers/docker-teamd/supervisord.conf | 2 +- files/scripts/supervisor-proc-exit-listener | 146 ++++++++++++------ .../docker-syncd-bfn/supervisord.conf | 2 +- .../docker-syncd-brcm/supervisord.conf | 2 +- .../cavium/docker-syncd-cavm/supervisord.conf | 2 +- .../docker-syncd-centec/supervisord.conf | 2 +- .../docker-syncd-centec/supervisord.conf | 2 +- .../docker-syncd-mrvl/supervisord.conf | 2 +- .../docker-syncd-mrvl/supervisord.conf | 2 +- .../docker-syncd-mrvl/supervisord.conf | 2 +- .../docker-syncd-mlnx/supervisord.conf | 2 +- .../docker-syncd-nephos/supervisord.conf | 2 +- .../vs/docker-gbsyncd-vs/supervisord.conf | 2 +- platform/vs/docker-syncd-vs/supervisord.conf | 2 +- .../py2/docker-dhcp-relay.supervisord.conf | 2 +- .../py3/docker-dhcp-relay.supervisord.conf | 2 +- 30 files changed, 130 insertions(+), 74 deletions(-) diff --git a/dockers/docker-database/supervisord.conf.j2 b/dockers/docker-database/supervisord.conf.j2 index 65a172b3743a..616475fb07ce 100644 --- a/dockers/docker-database/supervisord.conf.j2 +++ b/dockers/docker-database/supervisord.conf.j2 @@ -5,7 +5,7 @@ nodaemon=true [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name database -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/dockers/docker-dhcp-relay/docker-dhcp-relay.supervisord.conf.j2 b/dockers/docker-dhcp-relay/docker-dhcp-relay.supervisord.conf.j2 index 20f631ad47c1..19a6cc294f7f 100644 --- a/dockers/docker-dhcp-relay/docker-dhcp-relay.supervisord.conf.j2 +++ b/dockers/docker-dhcp-relay/docker-dhcp-relay.supervisord.conf.j2 @@ -14,7 +14,7 @@ buffer_size=50 [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name dhcp_relay -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2 b/dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2 index a6327936954f..dd43e0cc4ec7 100644 --- a/dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2 +++ b/dockers/docker-fpm-frr/frr/supervisord/supervisord.conf.j2 @@ -14,7 +14,7 @@ buffer_size=50 [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name bgp -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/dockers/docker-fpm-gobgp/supervisord.conf b/dockers/docker-fpm-gobgp/supervisord.conf index b814dc024fa3..e7e3ee9f301a 100644 --- a/dockers/docker-fpm-gobgp/supervisord.conf +++ b/dockers/docker-fpm-gobgp/supervisord.conf @@ -5,7 +5,7 @@ nodaemon=true [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name bgp -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/dockers/docker-fpm-quagga/supervisord.conf b/dockers/docker-fpm-quagga/supervisord.conf index 7397a7428a08..470dea18a16d 100644 --- a/dockers/docker-fpm-quagga/supervisord.conf +++ b/dockers/docker-fpm-quagga/supervisord.conf @@ -5,7 +5,7 @@ nodaemon=true [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name bgp -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/dockers/docker-lldp/supervisord.conf.j2 b/dockers/docker-lldp/supervisord.conf.j2 index 4692f7bf2a18..3a84caee3040 100644 --- a/dockers/docker-lldp/supervisord.conf.j2 +++ b/dockers/docker-lldp/supervisord.conf.j2 @@ -14,7 +14,7 @@ buffer_size=25 [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name lldp -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/dockers/docker-nat/supervisord.conf b/dockers/docker-nat/supervisord.conf index 8555f2a48ae6..f03b0b3772b8 100644 --- a/dockers/docker-nat/supervisord.conf +++ b/dockers/docker-nat/supervisord.conf @@ -14,7 +14,7 @@ buffer_size=25 [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name nat -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/dockers/docker-orchagent/supervisord.conf b/dockers/docker-orchagent/supervisord.conf index 37ddade2edcf..538f251c2621 100644 --- a/dockers/docker-orchagent/supervisord.conf +++ b/dockers/docker-orchagent/supervisord.conf @@ -14,7 +14,7 @@ buffer_size=100 [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name swss -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2 b/dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2 index 3de20178b224..c205d3cc25dc 100644 --- a/dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2 +++ b/dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2 @@ -14,7 +14,7 @@ buffer_size=100 [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name pmon -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/dockers/docker-router-advertiser/docker-router-advertiser.supervisord.conf.j2 b/dockers/docker-router-advertiser/docker-router-advertiser.supervisord.conf.j2 index ae487922859c..5cbfd60322e1 100644 --- a/dockers/docker-router-advertiser/docker-router-advertiser.supervisord.conf.j2 +++ b/dockers/docker-router-advertiser/docker-router-advertiser.supervisord.conf.j2 @@ -14,7 +14,7 @@ buffer_size=25 [eventlistener:supervisor-proc-exit-script] command=/usr/bin/supervisor-proc-exit-listener --container-name radv -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/dockers/docker-sflow/supervisord.conf b/dockers/docker-sflow/supervisord.conf index 8d1bdc5059cb..3ff5ff564544 100644 --- a/dockers/docker-sflow/supervisord.conf +++ b/dockers/docker-sflow/supervisord.conf @@ -14,7 +14,7 @@ buffer_size=25 [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name sflow -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/dockers/docker-snmp/supervisord.conf b/dockers/docker-snmp/supervisord.conf index d1e6d09a8213..414445fdd6d6 100644 --- a/dockers/docker-snmp/supervisord.conf +++ b/dockers/docker-snmp/supervisord.conf @@ -14,7 +14,7 @@ buffer_size=50 [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name snmp -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/dockers/docker-sonic-restapi/supervisord.conf b/dockers/docker-sonic-restapi/supervisord.conf index 74bbc9241576..44508ce88138 100644 --- a/dockers/docker-sonic-restapi/supervisord.conf +++ b/dockers/docker-sonic-restapi/supervisord.conf @@ -14,7 +14,7 @@ buffer_size=25 [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name restapi -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=false diff --git a/dockers/docker-sonic-telemetry/supervisord.conf b/dockers/docker-sonic-telemetry/supervisord.conf index df1e6fa5a354..fa8c86f597c7 100644 --- a/dockers/docker-sonic-telemetry/supervisord.conf +++ b/dockers/docker-sonic-telemetry/supervisord.conf @@ -14,7 +14,7 @@ buffer_size=50 [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name telemetry -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=false diff --git a/dockers/docker-teamd/supervisord.conf b/dockers/docker-teamd/supervisord.conf index 78549a7684f2..04432a31239a 100644 --- a/dockers/docker-teamd/supervisord.conf +++ b/dockers/docker-teamd/supervisord.conf @@ -14,7 +14,7 @@ buffer_size=50 [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name teamd -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/files/scripts/supervisor-proc-exit-listener b/files/scripts/supervisor-proc-exit-listener index 143e539a1689..06e402bd4f6a 100755 --- a/files/scripts/supervisor-proc-exit-listener +++ b/files/scripts/supervisor-proc-exit-listener @@ -2,11 +2,14 @@ import getopt import os +import select import signal import sys import syslog +import time import swsssdk + from supervisor import childutils # Each line of this file should specify either one critical process or one @@ -20,10 +23,18 @@ CRITICAL_PROCESSES_FILE = '/etc/supervisor/critical_processes' # The FEATURE table in config db contains auto-restart field FEATURE_TABLE_NAME = 'FEATURE' -# Read the critical processes/group names from CRITICAL_PROCESSES_FILE +# Value of parameter 'timeout' in select(...) method +SELECT_TIMEOUT_SECS = 1.0 + +# Alerting message will be written into syslog in the following interval +ALERTING_INTERVAL_SECS = 60 def get_critical_group_and_process_list(): + """ + @summary: Read the critical processes/group names from CRITICAL_PROCESSES_FILE. + @return: Two lists which contain critical processes and group names respectively. + """ critical_group_list = [] critical_process_list = [] @@ -49,6 +60,47 @@ def get_critical_group_and_process_list(): return critical_group_list, critical_process_list +def generate_alerting_message(process_name): + """ + @summary: If a critical process was not running, this function will determine it resides in host + or in a specific namespace. Then an alerting message will be written into syslog. + """ + namespace_prefix = os.environ.get("NAMESPACE_PREFIX") + namespace_id = os.environ.get("NAMESPACE_ID") + + if not namespace_prefix or not namespace_id: + namespace = "host" + else: + namespace = namespace_prefix + namespace_id + + syslog.syslog(syslog.LOG_ERR, "Process '{}' is not running in namespace '{}'.".format(process_name, namespace)) + + +def get_autorestart_state(container_name): + """ + @summary: Read the status of auto-restart feature from Config_DB. + @return: Return the status of auto-restart feature. + """ + config_db = swsssdk.ConfigDBConnector() + config_db.connect() + features_table = config_db.get_table(FEATURE_TABLE_NAME) + if not features_table: + syslog.syslog(syslog.LOG_ERR, "Unable to retrieve features table from Config DB. Exiting...") + sys.exit(2) + + if container_name not in features_table: + syslog.syslog(syslog.LOG_ERR, "Unable to retrieve feature '{}'. Exiting...".format(container_name)) + sys.exit(3) + + is_auto_restart = features_table[container_name].get('auto_restart') + if not is_auto_restart: + syslog.syslog( + syslog.LOG_ERR, "Unable to determine auto-restart feature status for '{}'. Exiting...".format(container_name)) + sys.exit(4) + + return is_auto_restart + + def main(argv): container_name = None opts, args = getopt.getopt(argv, "c:", ["container-name="]) @@ -62,51 +114,55 @@ def main(argv): critical_group_list, critical_process_list = get_critical_group_and_process_list() + process_under_alerting = {} + # Transition from ACKNOWLEDGED to READY + childutils.listener.ready() + while True: - # Transition from ACKNOWLEDGED to READY - childutils.listener.ready() - - line = sys.stdin.readline() - headers = childutils.get_headers(line) - payload = sys.stdin.read(int(headers['len'])) - - # Transition from READY to ACKNOWLEDGED - childutils.listener.ok() - - # We only care about PROCESS_STATE_EXITED events - if headers['eventname'] == 'PROCESS_STATE_EXITED': - payload_headers, payload_data = childutils.eventdata(payload + '\n') - - expected = int(payload_headers['expected']) - processname = payload_headers['processname'] - groupname = payload_headers['groupname'] - - # Read the status of auto-restart feature from Config_DB. - config_db = swsssdk.ConfigDBConnector() - config_db.connect() - features_table = config_db.get_table(FEATURE_TABLE_NAME) - if not features_table: - syslog.syslog(syslog.LOG_ERR, "Unable to retrieve features table from Config DB. Exiting...") - sys.exit(2) - - if container_name not in features_table: - syslog.syslog(syslog.LOG_ERR, "Unable to retrieve feature '{}'. Exiting...".format(container_name)) - sys.exit(3) - - restart_feature = features_table[container_name].get('auto_restart') - if not restart_feature: - syslog.syslog( - syslog.LOG_ERR, "Unable to determine auto-restart feature status for '{}'. Exiting...".format(container_name)) - sys.exit(4) - - # If auto-restart feature is not disabled and at the same time - # a critical process exited unexpectedly, terminate supervisor - if (restart_feature != 'disabled' and expected == 0 and - (processname in critical_process_list or groupname in critical_group_list)): - MSG_FORMAT_STR = "Process {} exited unxepectedly. Terminating supervisor..." - msg = MSG_FORMAT_STR.format(payload_headers['processname']) - syslog.syslog(syslog.LOG_INFO, msg) - os.kill(os.getppid(), signal.SIGTERM) + file_descriptor_list = select.select([sys.stdin], [], [], SELECT_TIMEOUT_SECS)[0] + if len(file_descriptor_list) > 0: + line = file_descriptor_list[0].readline() + headers = childutils.get_headers(line) + payload = sys.stdin.read(int(headers['len'])) + + # Handle the PROCESS_STATE_EXITED event + if headers['eventname'] == 'PROCESS_STATE_EXITED': + payload_headers, payload_data = childutils.eventdata(payload + '\n') + + expected = int(payload_headers['expected']) + process_name = payload_headers['processname'] + group_name = payload_headers['groupname'] + + if (process_name in critical_process_list or group_name in critical_group_list) and expected == 0: + is_auto_restart = get_autorestart_state(container_name) + if is_auto_restart != "disabled": + MSG_FORMAT_STR = "Process '{}' exited unexpectedly. Terminating supervisor '{}'" + msg = MSG_FORMAT_STR.format(payload_headers['processname'], container_name) + syslog.syslog(syslog.LOG_INFO, msg) + os.kill(os.getppid(), signal.SIGTERM) + else: + process_under_alerting[process_name] = time.time() + + # Handle the PROCESS_STATE_RUNNING event + elif headers['eventname'] == 'PROCESS_STATE_RUNNING': + payload_headers, payload_data = childutils.eventdata(payload + '\n') + process_name = payload_headers['processname'] + + if process_name in process_under_alerting: + process_under_alerting.pop(process_name) + + # Transition from BUSY to ACKNOWLEDGED + childutils.listener.ok() + + # Transition from ACKNOWLEDGED to READY + childutils.listener.ready() + + # Check whether we need write alerting messages into syslog + for process in process_under_alerting.keys(): + epoch_time = time.time() + if epoch_time - process_under_alerting[process] >= ALERTING_INTERVAL_SECS: + process_under_alerting[process] = epoch_time + generate_alerting_message(process) if __name__ == "__main__": diff --git a/platform/barefoot/docker-syncd-bfn/supervisord.conf b/platform/barefoot/docker-syncd-bfn/supervisord.conf index 39ea308277d7..c83484e5e93b 100644 --- a/platform/barefoot/docker-syncd-bfn/supervisord.conf +++ b/platform/barefoot/docker-syncd-bfn/supervisord.conf @@ -14,7 +14,7 @@ buffer_size=25 [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name syncd -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/platform/broadcom/docker-syncd-brcm/supervisord.conf b/platform/broadcom/docker-syncd-brcm/supervisord.conf index a8e594c47aeb..5e801106972f 100644 --- a/platform/broadcom/docker-syncd-brcm/supervisord.conf +++ b/platform/broadcom/docker-syncd-brcm/supervisord.conf @@ -14,7 +14,7 @@ buffer_size=25 [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name syncd -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/platform/cavium/docker-syncd-cavm/supervisord.conf b/platform/cavium/docker-syncd-cavm/supervisord.conf index 0c6285d46ae0..91b94a258033 100644 --- a/platform/cavium/docker-syncd-cavm/supervisord.conf +++ b/platform/cavium/docker-syncd-cavm/supervisord.conf @@ -5,7 +5,7 @@ nodaemon=true [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name syncd -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/platform/centec-arm64/docker-syncd-centec/supervisord.conf b/platform/centec-arm64/docker-syncd-centec/supervisord.conf index 2cf6814ddaa9..10f406129d9c 100755 --- a/platform/centec-arm64/docker-syncd-centec/supervisord.conf +++ b/platform/centec-arm64/docker-syncd-centec/supervisord.conf @@ -14,7 +14,7 @@ buffer_size=25 [eventlistener:supervisor-proc-exit-listener] command=python2 /usr/bin/supervisor-proc-exit-listener --container-name syncd -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/platform/centec/docker-syncd-centec/supervisord.conf b/platform/centec/docker-syncd-centec/supervisord.conf index 831b7256a43b..6df1893a0be0 100644 --- a/platform/centec/docker-syncd-centec/supervisord.conf +++ b/platform/centec/docker-syncd-centec/supervisord.conf @@ -13,7 +13,7 @@ events=PROCESS_STATE [eventlistener:supervisor-proc-exit-listener] command=python2 /usr/bin/supervisor-proc-exit-listener --container-name syncd -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/platform/marvell-arm64/docker-syncd-mrvl/supervisord.conf b/platform/marvell-arm64/docker-syncd-mrvl/supervisord.conf index 2cf6814ddaa9..10f406129d9c 100644 --- a/platform/marvell-arm64/docker-syncd-mrvl/supervisord.conf +++ b/platform/marvell-arm64/docker-syncd-mrvl/supervisord.conf @@ -14,7 +14,7 @@ buffer_size=25 [eventlistener:supervisor-proc-exit-listener] command=python2 /usr/bin/supervisor-proc-exit-listener --container-name syncd -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/platform/marvell-armhf/docker-syncd-mrvl/supervisord.conf b/platform/marvell-armhf/docker-syncd-mrvl/supervisord.conf index c099bbccbf0f..e633b4fe115c 100644 --- a/platform/marvell-armhf/docker-syncd-mrvl/supervisord.conf +++ b/platform/marvell-armhf/docker-syncd-mrvl/supervisord.conf @@ -14,7 +14,7 @@ buffer_size=25 [eventlistener:supervisor-proc-exit-listener] command=python2 /usr/bin/supervisor-proc-exit-listener --container-name syncd -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/platform/marvell/docker-syncd-mrvl/supervisord.conf b/platform/marvell/docker-syncd-mrvl/supervisord.conf index 85442933cf8e..94be9dd268f6 100644 --- a/platform/marvell/docker-syncd-mrvl/supervisord.conf +++ b/platform/marvell/docker-syncd-mrvl/supervisord.conf @@ -14,7 +14,7 @@ buffer_size=25 [eventlistener:supervisor-proc-exit-listener] command=python2 /usr/bin/supervisor-proc-exit-listener --container-name syncd -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/platform/mellanox/docker-syncd-mlnx/supervisord.conf b/platform/mellanox/docker-syncd-mlnx/supervisord.conf index 9311a255b0c8..8491d762bf51 100644 --- a/platform/mellanox/docker-syncd-mlnx/supervisord.conf +++ b/platform/mellanox/docker-syncd-mlnx/supervisord.conf @@ -14,7 +14,7 @@ buffer_size=25 [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name syncd -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/platform/nephos/docker-syncd-nephos/supervisord.conf b/platform/nephos/docker-syncd-nephos/supervisord.conf index a05bf7bfec73..955021ad2d51 100644 --- a/platform/nephos/docker-syncd-nephos/supervisord.conf +++ b/platform/nephos/docker-syncd-nephos/supervisord.conf @@ -14,7 +14,7 @@ buffer_size=25 [eventlistener:supervisor-proc-exit-listener] command=python2 /usr/bin/supervisor-proc-exit-listener --container-name syncd -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/platform/vs/docker-gbsyncd-vs/supervisord.conf b/platform/vs/docker-gbsyncd-vs/supervisord.conf index 3583ef6b5a8f..52267c8fa58f 100644 --- a/platform/vs/docker-gbsyncd-vs/supervisord.conf +++ b/platform/vs/docker-gbsyncd-vs/supervisord.conf @@ -13,7 +13,7 @@ events=PROCESS_STATE [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name gbsyncd -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/platform/vs/docker-syncd-vs/supervisord.conf b/platform/vs/docker-syncd-vs/supervisord.conf index 7416f23a45e5..6a6d946632e0 100644 --- a/platform/vs/docker-syncd-vs/supervisord.conf +++ b/platform/vs/docker-syncd-vs/supervisord.conf @@ -14,7 +14,7 @@ buffer_size=25 [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name syncd -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/src/sonic-config-engine/tests/sample_output/py2/docker-dhcp-relay.supervisord.conf b/src/sonic-config-engine/tests/sample_output/py2/docker-dhcp-relay.supervisord.conf index a213a2517866..dad758947f22 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/docker-dhcp-relay.supervisord.conf +++ b/src/sonic-config-engine/tests/sample_output/py2/docker-dhcp-relay.supervisord.conf @@ -14,7 +14,7 @@ buffer_size=50 [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name dhcp_relay -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected diff --git a/src/sonic-config-engine/tests/sample_output/py3/docker-dhcp-relay.supervisord.conf b/src/sonic-config-engine/tests/sample_output/py3/docker-dhcp-relay.supervisord.conf index d5338b18cfa1..e2135d05296b 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/docker-dhcp-relay.supervisord.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/docker-dhcp-relay.supervisord.conf @@ -14,7 +14,7 @@ buffer_size=50 [eventlistener:supervisor-proc-exit-listener] command=/usr/bin/supervisor-proc-exit-listener --container-name dhcp_relay -events=PROCESS_STATE_EXITED +events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected From f00bb52f7c8589d8209466fee0a5465595cd043f Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Wed, 27 Jan 2021 09:34:03 -0800 Subject: [PATCH 0103/1674] [proc-exit-listener]: ignore blank lines make proc-exit-listener more rebust Signed-off-by: Guohan Lu --- files/scripts/supervisor-proc-exit-listener | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/files/scripts/supervisor-proc-exit-listener b/files/scripts/supervisor-proc-exit-listener index 06e402bd4f6a..4ac77298c78a 100755 --- a/files/scripts/supervisor-proc-exit-listener +++ b/files/scripts/supervisor-proc-exit-listener @@ -2,6 +2,7 @@ import getopt import os +import re import select import signal import sys @@ -40,6 +41,9 @@ def get_critical_group_and_process_list(): with open(CRITICAL_PROCESSES_FILE, 'r') as file: for line in file: + # ignore blank lines + if re.match(r"^\s*$", line) + continue line_info = line.strip(' \n').split(':') if len(line_info) != 2: syslog.syslog(syslog.LOG_ERR, From 89eb0c4a3c39f7cd8b348976727347f7312050cb Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Wed, 27 Jan 2021 09:34:46 -0800 Subject: [PATCH 0104/1674] [docker-fmp-frr]: remove blank lines in generated critical_process Signed-off-by: Guohan Lu --- dockers/docker-fpm-frr/frr/supervisord/critical_processes.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dockers/docker-fpm-frr/frr/supervisord/critical_processes.j2 b/dockers/docker-fpm-frr/frr/supervisord/critical_processes.j2 index 9a90a5c94eb8..69f4e8e6931e 100644 --- a/dockers/docker-fpm-frr/frr/supervisord/critical_processes.j2 +++ b/dockers/docker-fpm-frr/frr/supervisord/critical_processes.j2 @@ -7,6 +7,6 @@ program:bfdd program:ospfd program:pimd program:frrcfgd -{% else %} +{%- else %} program:bgpcfgd -{% endif %} +{%- endif %} From afd30ee170e35f2ebb26cd5e96808050af9660f3 Mon Sep 17 00:00:00 2001 From: Vaibhav Hemant Dixit Date: Wed, 27 Jan 2021 21:55:18 -0800 Subject: [PATCH 0105/1674] [sonic-sairedis] advance submodule to include fix for syncd crash during shutdown (#6581) Remove unregisterMessageHandler from NetMsgRegistrar thread (#779) --- src/sonic-sairedis | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-sairedis b/src/sonic-sairedis index 20b9573437f3..b1edaef48f01 160000 --- a/src/sonic-sairedis +++ b/src/sonic-sairedis @@ -1 +1 @@ -Subproject commit 20b9573437f3194c5281f28922ab5d5d8a913e4e +Subproject commit b1edaef48f01c24f5dc9f66d79ac143dcbcd89e3 From cb79de1b122b886ab61921c1356a38a4f0dd0a66 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Thu, 28 Jan 2021 02:21:38 -0800 Subject: [PATCH 0106/1674] [build]: stop prompt during build (#6585) Some commands used during build will prompt user interactively, but this is not expected during build. Since most output is collected into log file, user could not see the prompt and feel the build process hangs. - How I did it Use mv command in non interactive mode Redirect stdin to null if command output is collected into log file. --- rules/functions | 2 +- slave.mk | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rules/functions b/rules/functions index 35b63aeabaf7..c6caebe82858 100644 --- a/rules/functions +++ b/rules/functions @@ -48,7 +48,7 @@ log_green = echo -e "$(GREEN)$(1)$(GRAY)" FLUSH_LOG = rm -f $@.log LOG_SIMPLE = &>> $(PROJECT_ROOT)/$@.log || { [ $$? -eq 0 ] || pushd $(PROJECT_ROOT) > /dev/null ; ./update_screen.sh -e $@ ; popd > /dev/null ; false ; } -LOG = |& $(PROJECT_ROOT)/scripts/process_log.sh $(PROCESS_LOG_OPTION) &>> $(PROJECT_ROOT)/$@.log ; test $${PIPESTATUS[-2]} -eq 0 || { [ $$? -eq 0 ] || pushd $(PROJECT_ROOT) > /dev/null ; ./update_screen.sh -e $@ ; popd > /dev/null ; false ; } +LOG = < /dev/null |& $(PROJECT_ROOT)/scripts/process_log.sh $(PROCESS_LOG_OPTION) &>> $(PROJECT_ROOT)/$@.log ; test $${PIPESTATUS[-2]} -eq 0 || { [ $$? -eq 0 ] || pushd $(PROJECT_ROOT) > /dev/null ; ./update_screen.sh -e $@ ; popd > /dev/null ; false ; } ############################################################################### ## Header and footer for each target diff --git a/slave.mk b/slave.mk index 775e566a1532..efe26a85f1a2 100644 --- a/slave.mk +++ b/slave.mk @@ -471,7 +471,7 @@ $(addprefix $(DEBS_PATH)/, $(SONIC_DPKG_DEBS)) : $(DEBS_PATH)/% : .platform $$(a # Clean up if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && quilt pop -a -f; [ -d .pc ] && rm -rf .pc; popd; fi # Take built package(s) - mv $(addprefix $($*_SRC_PATH)/../, $* $($*_DERIVED_DEBS) $($*_EXTRA_DEBS)) $(DEBS_PATH) $(LOG) + mv -f $(addprefix $($*_SRC_PATH)/../, $* $($*_DERIVED_DEBS) $($*_EXTRA_DEBS)) $(DEBS_PATH) $(LOG) # Save the target deb into DPKG cache $(call SAVE_CACHE,$*,$@) @@ -572,7 +572,7 @@ $(addprefix $(PYTHON_DEBS_PATH)/, $(SONIC_PYTHON_STDEB_DEBS)) : $(PYTHON_DEBS_PA # Clean up if [ -f $($*_SRC_PATH).patch/series ]; then pushd $($*_SRC_PATH) && quilt pop -a -f; [ -d .pc ] && rm -rf .pc; popd; fi # Take built package(s) - mv $(addprefix $($*_SRC_PATH)/deb_dist/, $* $($*_DERIVED_DEBS)) $(PYTHON_DEBS_PATH) $(LOG) + mv -f $(addprefix $($*_SRC_PATH)/deb_dist/, $* $($*_DERIVED_DEBS)) $(PYTHON_DEBS_PATH) $(LOG) # Save the target deb into DPKG cache $(call SAVE_CACHE,$*,$@) @@ -609,7 +609,7 @@ $(addprefix $(PYTHON_WHEELS_PATH)/, $(SONIC_PYTHON_WHEELS)) : $(PYTHON_WHEELS_PA # clean up if [ -f ../$(notdir $($*_SRC_PATH)).patch/series ]; then quilt pop -a -f; [ -d .pc ] && rm -rf .pc; fi popd $(LOG_SIMPLE) - mv $($*_SRC_PATH)/dist/$* $(PYTHON_WHEELS_PATH) $(LOG) + mv -f $($*_SRC_PATH)/dist/$* $(PYTHON_WHEELS_PATH) $(LOG) # Save the target deb into DPKG cache $(call SAVE_CACHE,$*,$@) From 03b26d4329d85d2d3d3468ad4bb90c83cd385d11 Mon Sep 17 00:00:00 2001 From: Danny Allen Date: Tue, 2 Feb 2021 11:41:14 -0800 Subject: [PATCH 0107/1674] [submodule][202012]: Update sonic-utiliies submodule (#6635) * c2fb282 2021-01-29 | [ecnconfig] Allow ecn unit test to run without sudo (#1390) [Neetha John] * 6cc635b 2021-01-29 | [sonic-installer] Add information to syslog (#1369) [Dmytro] * 7a8024a 2021-01-27 | Prevent user from adding more then a single untagged VLAN to an interface (#1382) [Eran Dahan] * 41e62c6 2021-01-26 | [pcieutil] Add 'pcie-aer' sub-command to display AER stats (#1169) [Arun Saravanan Balachandran] * 47f412b 2021-01-26 | Improve robustness of consutil plugin loading (#1353) [Samuel Angebault] * 64aa1b8 2021-01-25 | [show] Fix warnings, related to gearbox, while show commands execution (#1343) [maksymbelei95] * ff226d0 2021-01-25 | Prevent configuring IP interface on a port which is a member of VLAN (#1374) [Eran Dahan] * f1522b9 2021-01-21 | [config_mgmt.py]: Set leaf-list to empty list while port breakout. (#1268) [Praveen Chaudhary] * 99c05d5 2021-01-21 | add vlan_intf_object only if there are ipv4 or ipv6 mappings (#1377) [Sumukha Tumkur Vani] * b082684 2021-01-21 | [ecn] Add tests for ecnconfig command (#1372) [Neetha John] * 23e0920 2021-01-21 | [sfpshow] Enhance QSFP-DD DOM information (#1207) [shlomibitton] * f4edba1 2021-01-20 | [ecnconfig] handle backend port names when extracting port I/F ID from the port name (#1361) [Mahesh Maddikayala] Signed-off-by: Danny Allen --- src/sonic-utilities | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-utilities b/src/sonic-utilities index 37695c83cf86..c2fb28254c1e 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit 37695c83cf86b7a163fcf2ffef949b116fe9d2b9 +Subproject commit c2fb28254c1e35a3c7a85a3baaf1c05a4afcd9fe From d146079362c5e01e2558fe507f378027f6d1835c Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 28 Jan 2021 09:44:43 -0800 Subject: [PATCH 0108/1674] [docker-sonic-vs] Install sonic-platform-common package (#6587) **- Why I did it** sonic-utilities will become dependent upon sonic-platform-common as of https://github.com/Azure/sonic-utilities/pull/1386. **- How I did it** - Add sonic-platform-common as a dependency in docker-sonic-vs.mk - Additionally, no longer install Python 2 packages of swsssdk and sonic-py-common, as they should no longer be needed. --- platform/vs/docker-sonic-vs.mk | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/platform/vs/docker-sonic-vs.mk b/platform/vs/docker-sonic-vs.mk index 7b82fce71ee0..c48c8f12c704 100644 --- a/platform/vs/docker-sonic-vs.mk +++ b/platform/vs/docker-sonic-vs.mk @@ -18,10 +18,9 @@ $(DOCKER_SONIC_VS)_DEPENDS += $(SWSS) \ # swsssdk is a dependency of sonic-py-common # TODO: sonic-py-common should depend on swsscommon instead -$(DOCKER_SONIC_VS)_PYTHON_WHEELS += $(SWSSSDK_PY2) \ - $(SWSSSDK_PY3) \ - $(SONIC_PY_COMMON_PY2) \ +$(DOCKER_SONIC_VS)_PYTHON_WHEELS += $(SWSSSDK_PY3) \ $(SONIC_PY_COMMON_PY3) \ + $(SONIC_PLATFORM_COMMON_PY3) \ $(SONIC_YANG_MODELS_PY3) \ $(SONIC_YANG_MGMT_PY3) \ $(SONIC_UTILITIES_PY3) \ From 8f8520eac8ee9a1607775e3237a7077b8b105b8d Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Thu, 28 Jan 2021 10:46:56 -0800 Subject: [PATCH 0109/1674] Bump pyyaml from 5.3.1 to 5.4.1 (#6511) RCE resolved in new version https://github.com/yaml/pyyaml/issues/420 --- sonic-slave-buster/Dockerfile.j2 | 4 ++-- src/sonic-bgpcfgd/setup.py | 2 +- src/sonic-config-engine/setup.py | 2 +- src/sonic-frr-mgmt-framework/setup.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sonic-slave-buster/Dockerfile.j2 b/sonic-slave-buster/Dockerfile.j2 index b8234e19d01b..6b0c347d31e7 100644 --- a/sonic-slave-buster/Dockerfile.j2 +++ b/sonic-slave-buster/Dockerfile.j2 @@ -412,8 +412,8 @@ RUN pip3 uninstall -y enum34 RUN pip2 install j2cli==0.3.10 # For sonic-mgmt-framework -RUN pip2 install "PyYAML==5.3.1" -RUN pip3 install "PyYAML==5.3.1" +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" diff --git a/src/sonic-bgpcfgd/setup.py b/src/sonic-bgpcfgd/setup.py index d6290bccb2b3..ab86ca20ec19 100755 --- a/src/sonic-bgpcfgd/setup.py +++ b/src/sonic-bgpcfgd/setup.py @@ -17,7 +17,7 @@ install_requires = [ 'jinja2>=2.10', 'netaddr==0.8.0', - 'pyyaml==5.3.1', + 'pyyaml==5.4.1', ], setup_requires = [ 'pytest-runner', diff --git a/src/sonic-config-engine/setup.py b/src/sonic-config-engine/setup.py index c9dfd3609b92..d167e0566438 100644 --- a/src/sonic-config-engine/setup.py +++ b/src/sonic-config-engine/setup.py @@ -9,7 +9,7 @@ 'ipaddress==1.0.23', 'lxml==4.6.2', 'netaddr==0.8.0', - 'pyyaml==5.3.1', + 'pyyaml==5.4.1', 'sonic-py-common', ] diff --git a/src/sonic-frr-mgmt-framework/setup.py b/src/sonic-frr-mgmt-framework/setup.py index d8681d1bbd88..d3c9f1dae173 100755 --- a/src/sonic-frr-mgmt-framework/setup.py +++ b/src/sonic-frr-mgmt-framework/setup.py @@ -14,7 +14,7 @@ install_requires = [ 'jinja2>=2.10', 'netaddr==0.8.0', - 'pyyaml==5.3.1', + 'pyyaml==5.4.1', 'zipp==1.2.0', # importlib-resources needs zipp and seems to have a bug where it will try to import too new of a version for Python 2 ], setup_requires = [ From 197f75a246e143cbf89e4cf743079e734f24366a Mon Sep 17 00:00:00 2001 From: arlakshm <55814491+arlakshm@users.noreply.github.com> Date: Thu, 28 Jan 2021 23:12:01 -0800 Subject: [PATCH 0110/1674] [multi asic] add ip netns identify command to sudoer (#6591) Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan - Why I did it The command sudo ip netns identify is used in function get_current_namespace to check in the cli command is running in host context or within a namespace. This function is used for every CLI command and command sudo ip netns identify needs to be added in sudoer files to allow users with RO access to run show cli commands This problem is not there on single asic platforms. - How I did it Add ip netns identify [0-9]* to sudoers file. --- files/image_config/sudoers/sudoers | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/files/image_config/sudoers/sudoers b/files/image_config/sudoers/sudoers index 4c2e684b4b1f..9a7902704194 100644 --- a/files/image_config/sudoers/sudoers +++ b/files/image_config/sudoers/sudoers @@ -35,7 +35,9 @@ Cmnd_Alias READ_ONLY_CMDS = /bin/cat /var/log/syslog*, \ /usr/local/bin/lldpshow, \ /usr/local/bin/psuutil *, \ /usr/local/bin/sonic-installer list, \ - /usr/local/bin/sfputil show * + /usr/local/bin/sfputil show *, \ + /bin/ip netns identify [0-9]* + Cmnd_Alias PASSWD_CMDS = /usr/local/bin/config tacacs passkey *, \ /usr/sbin/chpasswd * From bf16cb473f72c9b6d493cedf7d48b179395db8f0 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Fri, 29 Jan 2021 02:08:56 -0800 Subject: [PATCH 0111/1674] Revert "[build]: disable unit tests for sonic-utilities" (#6598) This reverts commit 470ed18a6bc2ab752ec1f929296f346f15aa0ae5. --- rules/sonic-utilities.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/rules/sonic-utilities.mk b/rules/sonic-utilities.mk index 41d785b06283..7119b4b98eb0 100644 --- a/rules/sonic-utilities.mk +++ b/rules/sonic-utilities.mk @@ -13,5 +13,4 @@ $(SONIC_UTILITIES_PY3)_DEBS_DEPENDS = $(LIBYANG) \ $(LIBYANG_PY3) \ $(LIBSWSSCOMMON) \ $(PYTHON3_SWSSCOMMON) -$(SONIC_UTILITIES_PY3)_TEST = n SONIC_PYTHON_WHEELS += $(SONIC_UTILITIES_PY3) From 24d785a64de3962863989af70f9823c0b6556a63 Mon Sep 17 00:00:00 2001 From: arlakshm <55814491+arlakshm@users.noreply.github.com> Date: Fri, 29 Jan 2021 08:16:32 -0800 Subject: [PATCH 0112/1674] [baseimage]: add docker ps to the sudoer file (#6604) fixes Azure/sonic-utilities#1389 With the recent changes in sudoer files. The show commands fails for the read-only users. The problem here is the 'docker ps' is failing in the function [get_routing_stack()](https://github.com/Azure/sonic-utilities/blob/8a1109ed30576f0287fcd98a4349617f7fb55700/show/main.py#L54) therefore all the CLI commands are failing. Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan --- files/image_config/sudoers/sudoers | 1 + 1 file changed, 1 insertion(+) diff --git a/files/image_config/sudoers/sudoers b/files/image_config/sudoers/sudoers index 9a7902704194..aa03eda13719 100644 --- a/files/image_config/sudoers/sudoers +++ b/files/image_config/sudoers/sudoers @@ -25,6 +25,7 @@ Cmnd_Alias READ_ONLY_CMDS = /bin/cat /var/log/syslog*, \ /usr/bin/docker exec bgp cat /etc/quagga/bgpd.conf, \ /usr/bin/docker images *, \ /usr/bin/docker ps *, \ + /usr/bin/docker ps, \ /usr/bin/lldpctl, \ /usr/bin/sensors, \ /usr/bin/tail -F /var/log/syslog, \ From cb536556e65f3354afa17556884c6f65c7cb195c Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Fri, 29 Jan 2021 10:24:24 -0800 Subject: [PATCH 0113/1674] [build_debian.sh] Freeze pip2 < version 21 (#6597) **- Why I did it** As per https://pypi.org/project/pip/ pip 21.0 does not not support Python 2 from Jan 2021. Most places in the codebase have already been pinned, but this one was missed. **- How I did it** Pin pip2 < version 21 in build_debian.sh --- build_debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_debian.sh b/build_debian.sh index 53ac934bd357..19ee92b8620d 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -418,7 +418,7 @@ done < files/image_config/sysctl/sysctl-net.conf sudo augtool --autosave "$sysctl_net_cmd_string" -r $FILESYSTEM_ROOT # Upgrade pip via PyPI and uninstall the Debian version -sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip2 install --upgrade pip +sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip2 install --upgrade 'pip<21' sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install --upgrade pip sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get purge -y python-pip python3-pip From 5fcb86f77083f21052b08c275eb18871d6e61bba Mon Sep 17 00:00:00 2001 From: dflynn-Nokia <60479697+dflynn-Nokia@users.noreply.github.com> Date: Fri, 29 Jan 2021 14:32:27 -0500 Subject: [PATCH 0114/1674] [submodule] update sonic-sairedis (#6609) This update includes the following changes > [syncd armhf] Fix syncd crash when running community test suites (#777) > Revert "[tests]:Add unittest for MACsec on p2p establishment (#771)" > [tests]:Add unittest for MACsec on p2p establishment (#771) > [tests] Enable azure pipeline make check to respect unittests (#760) --- src/sonic-sairedis | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-sairedis b/src/sonic-sairedis index b1edaef48f01..817a01e4bfa2 160000 --- a/src/sonic-sairedis +++ b/src/sonic-sairedis @@ -1 +1 @@ -Subproject commit b1edaef48f01c24f5dc9f66d79ac143dcbcd89e3 +Subproject commit 817a01e4bfa25d701727d1750989d5cd9f1bbcb3 From 3e70b973427b433586196d77a2e493b0c435a021 Mon Sep 17 00:00:00 2001 From: Volodymyr Boiko <66446128+vboykox@users.noreply.github.com> Date: Sat, 30 Jan 2021 03:29:37 +0200 Subject: [PATCH 0115/1674] [barefoot][platform] platform API 2.0 fixes (#6607) To improve python3 support of berefoot's sonic_platform Signed-off-by: Volodymyr Boyko --- .../sonic_platform/eeprom.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 df24172709d3..a98a6bc1d45a 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 @@ -17,7 +17,7 @@ from sonic_eeprom import eeprom_base from sonic_eeprom import eeprom_tlvinfo - from .platform_thrift_client import thrift_try + from platform_thrift_client import thrift_try except ImportError as e: raise ImportError (str(e) + "- required module not found") @@ -64,6 +64,11 @@ EEPROM_SYMLINK = "/var/run/platform/eeprom/syseeprom" EEPROM_STATUS = "/var/run/platform/eeprom/status" +try: + _str_type = basestring +except NameError: + _str_type = str + class Eeprom(eeprom_tlvinfo.TlvInfoDecoder): def __init__(self): @@ -101,7 +106,7 @@ def eeprom_parse(self): f.close() eeprom_params = "" - for attr, val in self.eeprom.__dict__.iteritems(): + for attr, val in self.eeprom.__dict__.items(): if val is None: continue @@ -109,7 +114,7 @@ def eeprom_parse(self): if elem is None: continue - if isinstance(val, basestring): + if isinstance(val, _str_type): value = val.replace('\0', '') else: value = str(val) From 56a689cf303e0bcdd40da6e071e64c96a39166ff Mon Sep 17 00:00:00 2001 From: gechiang <62408185+gechiang@users.noreply.github.com> Date: Sat, 30 Jan 2021 05:28:33 -0800 Subject: [PATCH 0116/1674] [broadcom]: Fix BRCM Syncd Error:syncd#/supervisord: syncd sh: 1: ethtool: not found (#6615) Starting with BRCM SAI 4.3.1.5 we see the following :ethtool not fount" error in syslog during boot up: ``` Jan 27 07:36:14.712472 str-s6100-acs-1 INFO syncd#/supervisord: syncd sh: 1: Jan 27 07:36:14.712844 str-s6100-acs-1 INFO syncd#/supervisord: syncd ethtool: not found Jan 27 07:36:14.713228 str-s6100-acs-1 INFO syncd#/supervisord: syncd #015 Jan 27 07:36:14.713840 str-s6100-acs-1 INFO syncd#syncd: [0] SAI_API_HOSTIF:_brcm_sai_hostif_speed_set:11894 cmd ethtool -s Ethernet39 speed 40000 rc:32512 Jan 27 07:36:14.717204 str-s6100-acs-1 NOTICE swss#orchagent: :- setHostIntfsOperStatus: Set operation status DOWN to host interface Ethernet39 Jan 27 07:36:14.717204 str-s6100-acs-1 NOTICE swss#orchagent: :- initPort: Initialized port Ethernet39 Jan 27 07:36:14.717204 str-s6100-acs-1 NOTICE swss#orchagent: :- initializePort: Initializing port alias:Ethernet36 pid:1000000000040 Jan 27 07:36:14.726793 str-s6100-acs-1 NOTICE swss#portsyncd: :- onMsg: nlmsg type:16 key:Ethernet36 admin:0 oper:0 addr:4c:76:25:f5:48:80 ifindex:75 master:0 Jan 27 07:36:14.727967 str-s6100-acs-1 NOTICE swss#portsyncd: :- onMsg: Publish Ethernet36(ok) to state db Jan 27 07:36:14.729331 str-s6100-acs-1 NOTICE swss#orchagent: :- addHostIntfs: Create host interface for port Ethernet36 Jan 27 07:36:14.752398 str-s6100-acs-1 INFO syncd#/supervisord: syncd sh: 1: ethtool: not found#015 Jan 27 07:36:14.752689 str-s6100-acs-1 INFO syncd#syncd: [0] SAI_API_HOSTIF:_brcm_sai_hostif_speed_set:11894 cmd ethtool -s Ethernet36 speed 40000 rc:32512 Jan 27 07:36:14.756050 str-s6100-acs-1 NOTICE swss#orchagent: :- setHostIntfsOperStatus: Set operation status DOWN to host interface Ethernet36 Jan 27 07:36:14.757585 str-s6100-acs-1 NOTICE swss#orchagent: :- initPort: Initialized port Ethernet36 ``` It seems that starting with BRCM SAI 4.2.1.5 syncd is using ethtool to set the host interface speed and since this ethtool was not part of the syncd Docker, we observe these "ethtool not found" issue. --- platform/broadcom/docker-syncd-brcm/Dockerfile.j2 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 b/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 index cf597df680de..0ba71bb5d780 100755 --- a/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 +++ b/platform/broadcom/docker-syncd-brcm/Dockerfile.j2 @@ -21,6 +21,9 @@ debs/ ## TODO: add kmod into Depends RUN apt-get install -yf kmod +## BRCM uses ethtool to set host interface speed +RUN apt-get install -y ethtool + COPY ["files/dsserve", "files/bcmcmd", "start.sh", "start_led.sh", "bcmsh", "/usr/bin/"] RUN chmod +x /usr/bin/dsserve /usr/bin/bcmcmd From 47002230a2fe31c41b3175c06a36f2b80fa22cca Mon Sep 17 00:00:00 2001 From: Junchao-Mellanox <57339448+Junchao-Mellanox@users.noreply.github.com> Date: Sun, 31 Jan 2021 15:06:36 +0800 Subject: [PATCH 0117/1674] Check fan speed before check fan status (#6586) **- Why I did it** In thermalctd, when speed of fan exceeds threshold, the fan status will be saved as "bad". So in system health, it is better to check fan speed before fan status. In this case, if fan speed exceeds threshold, we get more detailed information. **- How I did it** Move fan speed check logic before fan status check **- How to verify it** Manual test --- src/system-health/health_checker/hardware_checker.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/system-health/health_checker/hardware_checker.py b/src/system-health/health_checker/hardware_checker.py index cf5b86bea2be..7bbc4bdaca00 100644 --- a/src/system-health/health_checker/hardware_checker.py +++ b/src/system-health/health_checker/hardware_checker.py @@ -89,11 +89,6 @@ def _check_fan_status(self, config): self.set_object_not_ok('Fan', name, '{} is missing'.format(name)) continue - status = data_dict.get('status', 'false') - if status.lower() != 'true': - self.set_object_not_ok('Fan', name, '{} is broken'.format(name)) - continue - if not self._ignore_check(config.ignore_devices, 'fan', name, 'speed'): speed = data_dict.get('speed', None) speed_target = data_dict.get('speed_target', None) @@ -130,6 +125,11 @@ def _check_fan_status(self, config): speed_tolerance)) continue + status = data_dict.get('status', 'false') + if status.lower() != 'true': + self.set_object_not_ok('Fan', name, '{} is broken'.format(name)) + continue + self.set_object_ok('Fan', name) def _check_psu_status(self, config): From bf8a76634c9be7ce519c61402e11cdfc50b6e3c3 Mon Sep 17 00:00:00 2001 From: Stephen Sun <5379172+stephenxs@users.noreply.github.com> Date: Sun, 31 Jan 2021 15:11:33 +0800 Subject: [PATCH 0118/1674] [syncd-rpc docker] Fix issue: ptf_nn_agent isn't able to start in syncd-rpc docker on buster (#6448) - Why I did it Fix issue: ptf_nn_agent isn't able to start in syncd-rpc docker on buster. - How I did it The issue is fixed by installing python-dev, cffi and nnpy for python 2 explicitly. - How to verify it Run copp test on RPC image. --- platform/barefoot/docker-syncd-bfn-rpc/Dockerfile.j2 | 8 +++++--- platform/broadcom/docker-syncd-brcm-rpc/Dockerfile.j2 | 8 +++++--- .../centec-arm64/docker-syncd-centec-rpc/Dockerfile.j2 | 8 +++++--- platform/centec/docker-syncd-centec-rpc/Dockerfile.j2 | 8 +++++--- platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 | 8 +++++--- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/platform/barefoot/docker-syncd-bfn-rpc/Dockerfile.j2 b/platform/barefoot/docker-syncd-bfn-rpc/Dockerfile.j2 index f3c9979dfa63..cf89b26b65e5 100644 --- a/platform/barefoot/docker-syncd-bfn-rpc/Dockerfile.j2 +++ b/platform/barefoot/docker-syncd-bfn-rpc/Dockerfile.j2 @@ -21,6 +21,7 @@ RUN apt-get update \ && apt-get -y install \ net-tools \ python-pip \ + python-setuptools \ build-essential \ libssl-dev \ libffi-dev \ @@ -38,9 +39,10 @@ RUN apt-get update \ && cd .. \ && rm -fr nanomsg-1.0.0 \ && rm -f 1.0.0.tar.gz \ - && pip install cffi==1.7.0 \ - && pip install --upgrade cffi==1.7.0 \ - && pip install nnpy \ + && pip2 install cffi==1.7.0 \ + && pip2 install --upgrade cffi==1.7.0 \ + && pip2 install wheel \ + && pip2 install nnpy \ && mkdir -p /opt \ && cd /opt \ && wget https://raw.githubusercontent.com/p4lang/ptf/master/ptf_nn/ptf_nn_agent.py \ diff --git a/platform/broadcom/docker-syncd-brcm-rpc/Dockerfile.j2 b/platform/broadcom/docker-syncd-brcm-rpc/Dockerfile.j2 index f68fbb661d9c..ada6113ddf43 100644 --- a/platform/broadcom/docker-syncd-brcm-rpc/Dockerfile.j2 +++ b/platform/broadcom/docker-syncd-brcm-rpc/Dockerfile.j2 @@ -21,6 +21,7 @@ RUN apt-get update \ && apt-get -y install \ net-tools \ python-pip \ + python-setuptools \ build-essential \ libssl-dev \ libffi-dev \ @@ -37,9 +38,10 @@ RUN apt-get update \ && cd .. \ && rm -fr nanomsg-1.0.0 \ && rm -f 1.0.0.tar.gz \ - && pip install cffi==1.7.0 \ - && pip install --upgrade cffi==1.7.0 \ - && pip install nnpy \ + && pip2 install cffi==1.7.0 \ + && pip2 install --upgrade cffi==1.7.0 \ + && pip2 install wheel \ + && pip2 install nnpy \ && mkdir -p /opt \ && cd /opt \ && wget https://raw.githubusercontent.com/p4lang/ptf/master/ptf_nn/ptf_nn_agent.py \ diff --git a/platform/centec-arm64/docker-syncd-centec-rpc/Dockerfile.j2 b/platform/centec-arm64/docker-syncd-centec-rpc/Dockerfile.j2 index d6719b224abd..057d93efb6bb 100755 --- a/platform/centec-arm64/docker-syncd-centec-rpc/Dockerfile.j2 +++ b/platform/centec-arm64/docker-syncd-centec-rpc/Dockerfile.j2 @@ -21,6 +21,7 @@ RUN apt-get update \ && apt-get -y install \ net-tools \ python-pip \ + python-setuptools \ build-essential \ libssl-dev \ libffi-dev \ @@ -37,9 +38,10 @@ RUN apt-get update \ && cd .. \ && rm -fr nanomsg-1.0.0 \ && rm -f 1.0.0.tar.gz \ - && pip install cffi==1.7.0 \ - && pip install --upgrade cffi==1.7.0 \ - && pip install nnpy \ + && pip2 install cffi==1.7.0 \ + && pip2 install --upgrade cffi==1.7.0 \ + && pip2 install wheel \ + && pip2 install nnpy \ && mkdir -p /opt \ && cd /opt \ && wget https://raw.githubusercontent.com/p4lang/ptf/master/ptf_nn/ptf_nn_agent.py \ diff --git a/platform/centec/docker-syncd-centec-rpc/Dockerfile.j2 b/platform/centec/docker-syncd-centec-rpc/Dockerfile.j2 index d6719b224abd..057d93efb6bb 100644 --- a/platform/centec/docker-syncd-centec-rpc/Dockerfile.j2 +++ b/platform/centec/docker-syncd-centec-rpc/Dockerfile.j2 @@ -21,6 +21,7 @@ RUN apt-get update \ && apt-get -y install \ net-tools \ python-pip \ + python-setuptools \ build-essential \ libssl-dev \ libffi-dev \ @@ -37,9 +38,10 @@ RUN apt-get update \ && cd .. \ && rm -fr nanomsg-1.0.0 \ && rm -f 1.0.0.tar.gz \ - && pip install cffi==1.7.0 \ - && pip install --upgrade cffi==1.7.0 \ - && pip install nnpy \ + && pip2 install cffi==1.7.0 \ + && pip2 install --upgrade cffi==1.7.0 \ + && pip2 install wheel \ + && pip2 install nnpy \ && mkdir -p /opt \ && cd /opt \ && wget https://raw.githubusercontent.com/p4lang/ptf/master/ptf_nn/ptf_nn_agent.py \ diff --git a/platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 b/platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 index e35c6582d2d0..b9aaa78118e0 100644 --- a/platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 +++ b/platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 @@ -29,6 +29,7 @@ RUN apt-get update \ && apt-get -y install \ net-tools \ python-pip \ + python-setuptools \ build-essential \ libssl-dev \ libffi-dev \ @@ -45,9 +46,10 @@ RUN apt-get update \ && cd .. \ && rm -fr nanomsg-1.0.0 \ && rm -f 1.0.0.tar.gz \ - && pip install cffi==1.7.0 \ - && pip install --upgrade cffi==1.7.0 \ - && pip install nnpy \ + && pip2 install cffi==1.7.0 \ + && pip2 install --upgrade cffi==1.7.0 \ + && pip2 install wheel \ + && pip2 install nnpy \ && mkdir -p /opt \ && cd /opt \ && wget https://raw.githubusercontent.com/p4lang/ptf/master/ptf_nn/ptf_nn_agent.py \ From c4c70d3a28297584a8c0ef7ab23f66877bba7fd8 Mon Sep 17 00:00:00 2001 From: guxianghong Date: Mon, 1 Feb 2021 09:30:30 +0800 Subject: [PATCH 0119/1674] [arm64] disable snmp's parallel make (#6592) snmpd's compile is always failed with file truncated on ARM64 arch, the error log is like "/usr/bin/ld: mibgroup/ip-forward-mib/inetCidrRouteTable/.libs/inetCidrRouteTable_interface.o: file not recognized: file truncated" Co-authored-by: Xianghong Gu --- src/snmpd/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/snmpd/Makefile b/src/snmpd/Makefile index b66af241e5c5..2e0ac828169c 100644 --- a/src/snmpd/Makefile +++ b/src/snmpd/Makefile @@ -29,7 +29,11 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg init stg import -s ../patch-$(SNMPD_VERSION)/series +ifeq ($(CONFIGURED_ARCH), arm64) + dpkg-buildpackage -rfakeroot -b -d -us -uc -j1 --admindir $(SONIC_DPKG_ADMINDIR) +else dpkg-buildpackage -rfakeroot -b -d -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) +endif popd mv $(DERIVED_TARGETS) $* $(DEST)/ From 1ff264b31c5e92e6ff7a110f831665552efc9887 Mon Sep 17 00:00:00 2001 From: lguohan Date: Mon, 1 Feb 2021 12:02:37 -0800 Subject: [PATCH 0120/1674] [frr]: upgrade frr to frr-7.5-s2 tag (#6628) pick-up upstream fixes. important ones - bgpd: Removing "neighbor allowas-in" complete lists * 6b2b5cce3 2021-01-29 | Merge pull request #7977 from ton31337/fix/allowas_in_reset_value_7.5 (HEAD -> frr/7.5, tag: frr-7.5-s2, upstream/stable/7.5, origin/frr/7.5, stable/7.5) [Donald Sharp] |\ | * f403534df 2021-01-28 | bgpd: Removing "neighbor allowas-in" [Kishore Kunal] * | 86e2f106c 2021-01-28 | Merge pull request #7962 from ton31337/fix/bgpd_validate_community_7.5 [Donald Sharp] |\ \ | |/ |/| | * e182af45c 2021-01-05 | bgpd: separate lcommunity validation from tokenizer [Wesley Coakley] | * 2cf37d594 2020-12-30 | bgpd: Validate community list if they are not malformed [Donatas Abraitis] |/ * a4af08a19 2021-01-22 | Merge pull request #7912 from idryzhov/7.5-backports-2021-01 [Donald Sharp] |\ | * 160021013 2021-01-12 | bgpd : multiple memory leak fixes in show commands [Sarita Patra] | * 46a2b560f 2021-01-19 | tools: fix frr-reload BFD profile support [Rafael Zalamena] | * 7f6c81fca 2020-12-02 | ospfd: fix area removal at interface level [ckishimo] | * f7db4dfb1 2021-01-08 | bfdd: update vrf of received packet [Philippe Guibert] | * 4d470f3ef 2021-01-08 | bfdd: enable bfd session if vrf interface available [Philippe Guibert] | * c656985fb 2021-01-08 | bfdd: socket should be bound to vrf interface by default [Philippe Guibert] | * f30c002b8 2021-01-15 | bgpd: Allow peer-groups to have `ttl-security hops` configured [Donald Sharp] | * 85ff76513 2021-01-15 | configure.ac: Correct library name for sysrepo [Bo Zhang] | * d00c543f1 2020-12-04 | bgpd: Handle IPv6 prefixes with IPv4 nexthops for zebra [Donatas Abraitis] | * 87b9b2973 2021-01-06 | zebra: zebra route-map delay-timer is global not per vrf [Donald Sharp] | * 91e1adec9 2021-01-05 | bgpd: Fix default-originate clearing from peer-groups. [zyxwvu Shi] | * 0f2f32fa1 2021-01-05 | isisd: When last area address is removed, resign if we were DR [Karen Schoener] | * 842e99d49 2021-01-02 | vrrpd.yang bug fix: modify augment path to comply with rfc 7950 [Bo Zhang] | * 9616ef937 2020-12-24 | ospfd: fix no show database output when selecting vrf [Louis Scalbert] | * 4c4764e36 2020-11-30 | ospf6d: ospfv3 disable on the interface, but interface prefix still shown in the output [Yash Ranjan] | * 1870dbd86 2020-12-14 | ospf6d: Link LSA is not updated when router priority is modified [Mobashshera Rasool] | * 4883a06c3 2020-12-10 | bgpd: fix evpn route-map vni filter at origin [Chirag Shah] |/ * 9c087052a 2021-01-15 | Merge pull request #7877 from vishaldhingra/static_7_5 [Mark Stapp] |\ | * a687b6b27 2021-01-15 | staticd: Backend cofiguration code to fix table-id problem [vdhingra] | * 52370b494 2021-01-15 | staticd: autogenerated code modifications due to yang changes [vdhingra] | * f9d6511f2 2021-01-15 | staticd: make table-id as the key for path-list [vdhingra] |/ Signed-off-by: Guohan Lu --- rules/frr.mk | 2 +- src/sonic-frr/frr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rules/frr.mk b/rules/frr.mk index 7572beb3b06c..bb6a96a61fa4 100644 --- a/rules/frr.mk +++ b/rules/frr.mk @@ -3,7 +3,7 @@ FRR_VERSION = 7.5 FRR_SUBVERSION = 0 FRR_BRANCH = frr/7.5 -FRR_TAG = frr-7.5-s1 +FRR_TAG = frr-7.5-s2 export FRR_VERSION FRR_SUBVERSION FRR_BRANCH FRR_TAG diff --git a/src/sonic-frr/frr b/src/sonic-frr/frr index 4ed6312d10d3..6b2b5cce3557 160000 --- a/src/sonic-frr/frr +++ b/src/sonic-frr/frr @@ -1 +1 @@ -Subproject commit 4ed6312d10d369f621f69202ad39cfa6a597c59c +Subproject commit 6b2b5cce3557a383942fc194257da77e4e5270e4 From 30b526d1945a23caf7ce96ca7c84287d377ef726 Mon Sep 17 00:00:00 2001 From: Shi Su <67605788+shi-su@users.noreply.github.com> Date: Mon, 1 Feb 2021 21:12:41 -0800 Subject: [PATCH 0121/1674] [Bgpcfgd] Add unit tests (#6634) Add unit tests for bgpcfgd and fix a minor bug in manager_intf.py found in testing --- src/sonic-bgpcfgd/bgpcfgd/managers_intf.py | 2 +- src/sonic-bgpcfgd/tests/test_bgp.py | 111 +++++++++++++++++++++ src/sonic-bgpcfgd/tests/test_db.py | 40 ++++++++ src/sonic-bgpcfgd/tests/test_directory.py | 57 +++++++++++ src/sonic-bgpcfgd/tests/test_frr.py | 68 ++++++++++++- src/sonic-bgpcfgd/tests/test_intf.py | 52 ++++++++++ src/sonic-bgpcfgd/tests/test_setsrc.py | 62 ++++++++++++ 7 files changed, 388 insertions(+), 4 deletions(-) create mode 100644 src/sonic-bgpcfgd/tests/test_bgp.py create mode 100644 src/sonic-bgpcfgd/tests/test_db.py create mode 100644 src/sonic-bgpcfgd/tests/test_directory.py create mode 100644 src/sonic-bgpcfgd/tests/test_intf.py create mode 100644 src/sonic-bgpcfgd/tests/test_setsrc.py diff --git a/src/sonic-bgpcfgd/bgpcfgd/managers_intf.py b/src/sonic-bgpcfgd/bgpcfgd/managers_intf.py index ef4958ad9207..c633c43046e0 100644 --- a/src/sonic-bgpcfgd/bgpcfgd/managers_intf.py +++ b/src/sonic-bgpcfgd/bgpcfgd/managers_intf.py @@ -30,7 +30,7 @@ def set_handler(self, key, data): try: network = netaddr.IPNetwork(str(network_str)) except (netaddr.NotRegisteredError, netaddr.AddrFormatError, netaddr.AddrConversionError): - log_warn("Subnet '%s' format is wrong for interface '%s'" % (network_str, data["interface"])) + log_warn("Subnet '%s' format is wrong for interface '%s'" % (network_str, interface_name)) return True data["interface"] = interface_name data["prefixlen"] = str(network.prefixlen) diff --git a/src/sonic-bgpcfgd/tests/test_bgp.py b/src/sonic-bgpcfgd/tests/test_bgp.py new file mode 100644 index 000000000000..8cbd51c90a4f --- /dev/null +++ b/src/sonic-bgpcfgd/tests/test_bgp.py @@ -0,0 +1,111 @@ +from unittest.mock import MagicMock, patch + +import os +from bgpcfgd.directory import Directory +from bgpcfgd.template import TemplateFabric +from . import swsscommon_test +from .util import load_constants +from swsscommon import swsscommon +import bgpcfgd.managers_bgp + +TEMPLATE_PATH = os.path.abspath('../../dockers/docker-fpm-frr/frr') + +def constructor(): + cfg_mgr = MagicMock() + common_objs = { + 'directory': Directory(), + 'cfg_mgr': cfg_mgr, + 'tf': TemplateFabric(TEMPLATE_PATH), + 'constants': load_constants()['constants'] + } + + return_value_map = { + "['vtysh', '-c', 'show bgp vrfs json']": (0, "{\"vrfs\": {\"default\": {}}}", ""), + "['vtysh', '-c', 'show bgp vrf default neighbors json']": (0, "{\"10.10.10.1\": {}, \"20.20.20.1\": {}, \"fc00:10::1\": {}}", "") + } + + bgpcfgd.managers_bgp.run_command = lambda cmd: return_value_map[str(cmd)] + m = bgpcfgd.managers_bgp.BGPPeerMgrBase(common_objs, "CONFIG_DB", swsscommon.CFG_BGP_NEIGHBOR_TABLE_NAME, "general", True) + assert m.peer_type == "general" + assert m.check_neig_meta == False # Because constants['bgp']['use_neighbors_meta'] is false in constants.yml + + m.directory.put("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME, "localhost", {"bgp_asn": "65100"}) + m.directory.put("CONFIG_DB", swsscommon.CFG_LOOPBACK_INTERFACE_TABLE_NAME, "Loopback0|11.11.11.11/32", {}) + m.directory.put("CONFIG_DB", swsscommon.CFG_LOOPBACK_INTERFACE_TABLE_NAME, "Loopback0|FC00:1::32/128", {}) + m.directory.put("LOCAL", "local_addresses", "30.30.30.30", {"interface": "Ethernet4|30.30.30.30/24"}) + m.directory.put("LOCAL", "local_addresses", "fc00:20::20", {"interface": "Ethernet8|fc00:20::20/96"}) + m.directory.put("LOCAL", "interfaces", "Ethernet4|30.30.30.30/24", {"anything": "anything"}) + m.directory.put("LOCAL", "interfaces", "Ethernet8|fc00:20::20/96", {"anything": "anything"}) + + return m + +@patch('bgpcfgd.managers_bgp.log_info') +def test_update_peer_up(mocked_log_info): + m = constructor() + res = m.set_handler("10.10.10.1", {"admin_status": "up"}) + assert res, "Expect True return value for peer update" + mocked_log_info.assert_called_with("Peer 'default|10.10.10.1' admin state is set to 'up'") + +@patch('bgpcfgd.managers_bgp.log_info') +def test_update_peer_up_ipv6(mocked_log_info): + m = constructor() + res = m.set_handler("fc00:10::1", {"admin_status": "up"}) + assert res, "Expect True return value for peer update" + mocked_log_info.assert_called_with("Peer 'default|fc00:10::1' admin state is set to 'up'") + +@patch('bgpcfgd.managers_bgp.log_info') +def test_update_peer_down(mocked_log_info): + m = constructor() + res = m.set_handler("10.10.10.1", {"admin_status": "down"}) + assert res, "Expect True return value for peer update" + mocked_log_info.assert_called_with("Peer 'default|10.10.10.1' admin state is set to 'down'") + +@patch('bgpcfgd.managers_bgp.log_err') +def test_update_peer_no_admin_status(mocked_log_err): + m = constructor() + res = m.set_handler("10.10.10.1", {"anything": "anything"}) + assert res, "Expect True return value for peer update" + mocked_log_err.assert_called_with("Peer '(default|10.10.10.1)': Can't update the peer. Only 'admin_status' attribute is supported") + +@patch('bgpcfgd.managers_bgp.log_err') +def test_update_peer_invalid_admin_status(mocked_log_err): + m = constructor() + res = m.set_handler("10.10.10.1", {"admin_status": "invalid"}) + assert res, "Expect True return value for peer update" + mocked_log_err.assert_called_with("Peer 'default|10.10.10.1': Can't update the peer. It has wrong attribute value attr['admin_status'] = 'invalid'") + +def test_add_peer(): + m = constructor() + res = m.set_handler("30.30.30.1", {"local_addr": "30.30.30.30", "admin_status": "up"}) + assert res, "Expect True return value" + +def test_add_peer_ipv6(): + m = constructor() + res = m.set_handler("fc00:20::1", {"local_addr": "fc00:20::20", "admin_status": "up"}) + assert res, "Expect True return value" + +@patch('bgpcfgd.managers_bgp.log_warn') +def test_add_peer_no_local_addr(mocked_log_warn): + m = constructor() + res = m.set_handler("30.30.30.1", {"admin_status": "up"}) + assert res, "Expect True return value" + mocked_log_warn.assert_called_with("Peer 30.30.30.1. Missing attribute 'local_addr'") + +@patch('bgpcfgd.managers_bgp.log_debug') +def test_add_peer_invalid_local_addr(mocked_log_debug): + m = constructor() + res = m.set_handler("30.30.30.1", {"local_addr": "40.40.40.40", "admin_status": "up"}) + assert not res, "Expect False return value" + mocked_log_debug.assert_called_with("Peer '30.30.30.1' with local address '40.40.40.40' wait for the corresponding interface to be set") + +@patch('bgpcfgd.managers_bgp.log_info') +def test_del_handler(mocked_log_info): + m = constructor() + m.del_handler("10.10.10.1") + mocked_log_info.assert_called_with("Peer '(default|10.10.10.1)' has been removed") + +@patch('bgpcfgd.managers_bgp.log_warn') +def test_del_handler_nonexist_peer(mocked_log_warn): + m = constructor() + m.del_handler("40.40.40.1") + mocked_log_warn.assert_called_with("Peer '(default|40.40.40.1)' has not been found") diff --git a/src/sonic-bgpcfgd/tests/test_db.py b/src/sonic-bgpcfgd/tests/test_db.py new file mode 100644 index 000000000000..7078bc2735f0 --- /dev/null +++ b/src/sonic-bgpcfgd/tests/test_db.py @@ -0,0 +1,40 @@ +from unittest.mock import MagicMock, patch + +from bgpcfgd.directory import Directory +from bgpcfgd.template import TemplateFabric +from . import swsscommon_test +from swsscommon import swsscommon + +with patch.dict("sys.modules", swsscommon=swsscommon_test): + from bgpcfgd.managers_db import BGPDataBaseMgr + +def test_set_del_handler(): + cfg_mgr = MagicMock() + common_objs = { + 'directory': Directory(), + 'cfg_mgr': cfg_mgr, + 'tf': TemplateFabric(), + 'constants': {}, + } + m = BGPDataBaseMgr(common_objs, "CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME) + assert m.constants == {} + + # test set_handler + res = m.set_handler("test_key1", {"test_value1"}) + assert res, "Returns always True" + assert "test_key1" in m.directory.get_slot(m.db_name, m.table_name) + assert m.directory.get(m.db_name, m.table_name, "test_key1") == {"test_value1"} + + res = m.set_handler("test_key2", {}) + assert res, "Returns always True" + assert "test_key2" in m.directory.get_slot(m.db_name, m.table_name) + assert m.directory.get(m.db_name, m.table_name, "test_key2") == {} + + # test del_handler + m.del_handler("test_key") + assert "test_key" not in m.directory.get_slot(m.db_name, m.table_name) + assert "test_key2" in m.directory.get_slot(m.db_name, m.table_name) + assert m.directory.get(m.db_name, m.table_name, "test_key2") == {} + + m.del_handler("test_key2") + assert "test_key2" not in m.directory.get_slot(m.db_name, m.table_name) diff --git a/src/sonic-bgpcfgd/tests/test_directory.py b/src/sonic-bgpcfgd/tests/test_directory.py new file mode 100644 index 000000000000..b20803ed32c5 --- /dev/null +++ b/src/sonic-bgpcfgd/tests/test_directory.py @@ -0,0 +1,57 @@ +from unittest.mock import MagicMock, patch +from bgpcfgd.directory import Directory + +@patch('bgpcfgd.directory.log_err') +def test_directory(mocked_log_err): + test_values = { + "key1": { + "key1_1": { + "key1_1_1": "value1_1_1", + "key1_1_2": "value1_1_2", + "key1_1_3": "value1_1_3" + } + }, + "key2": { + "value2" + } + } + + directory = Directory() + + # Put test values + directory.put("db_name", "table", "key1", test_values["key1"]) + directory.put("db_name", "table", "key2", test_values["key2"]) + + # Test get_path() + assert directory.get_path("db_name", "table", "") == test_values + assert directory.get_path("db_name", "table", "key1/key1_1/key1_1_1") == "value1_1_1" + assert directory.get_path("db_name", "table", "key1/key_nonexist") == None + + # Test path_exist() + assert directory.path_exist("db_name", "table", "key1/key1_1/key1_1_1") + assert not directory.path_exist("db_name", "table_nonexist", "") + assert not directory.path_exist("db_name", "table", "key1/key_nonexist") + + # Test get_slot() + assert directory.get_slot("db_name", "table") == test_values + + # Test get() + assert directory.get("db_name", "table", "key2") == test_values["key2"] + + # Test remove() + directory.remove("db_name", "table", "key2") + assert not directory.path_exist("db_name", "table", "key2") + + # Test remove() with invalid input + directory.remove("db_name", "table_nonexist", "key2") + mocked_log_err.assert_called_with("Directory: Can't remove key 'key2' from slot 'db_name__table_nonexist'. The slot doesn't exist") + directory.remove("db_name", "table", "key_nonexist") + mocked_log_err.assert_called_with("Directory: Can't remove key 'key_nonexist' from slot 'db_name__table'. The key doesn't exist") + + # Test remove_slot() + directory.remove_slot("db_name", "table") + assert not directory.available("db_name", "table") + + # Test remove_slot() with nonexist table + directory.remove_slot("db_name", "table_nonexist") + mocked_log_err.assert_called_with("Directory: Can't remove slot 'db_name__table_nonexist'. The slot doesn't exist") diff --git a/src/sonic-bgpcfgd/tests/test_frr.py b/src/sonic-bgpcfgd/tests/test_frr.py index 47bdcaa82f10..5a20281fa553 100644 --- a/src/sonic-bgpcfgd/tests/test_frr.py +++ b/src/sonic-bgpcfgd/tests/test_frr.py @@ -1,6 +1,68 @@ -from bgpcfgd.frr import FRR - +from unittest.mock import patch +import bgpcfgd.frr +import pytest def test_constructor(): - f = FRR(["abc", "cde"]) + f = bgpcfgd.frr.FRR(["abc", "cde"]) assert f.daemons == ["abc", "cde"] + +def test_wait_for_daemons(): + bgpcfgd.frr.run_command = lambda cmd, **kwargs: (0, ["abc", "cde"], "") + f = bgpcfgd.frr.FRR(["abc", "cde"]) + f.wait_for_daemons(5) + +def test_wait_for_daemons_fail(): + bgpcfgd.frr.run_command = lambda cmd, **kwargs: (0, ["abc", "non_expected"], "") + f = bgpcfgd.frr.FRR(["abc", "cde"]) + with pytest.raises(Exception): + assert f.wait_for_daemons(5) + +def test_wait_for_daemons_error(): + bgpcfgd.frr.run_command = lambda cmd, **kwargs: (1, ["abc", "cde"], "some error") + f = bgpcfgd.frr.FRR(["abc", "cde"]) + with pytest.raises(Exception): + assert f.wait_for_daemons(5) + +def test_get_config(): + bgpcfgd.frr.run_command = lambda cmd: (0, "expected config", "") + f = bgpcfgd.frr.FRR(["abc", "cde"]) + out = f.get_config() + assert out == "expected config" + +@patch('bgpcfgd.frr.log_crit') +def test_get_config_fail(mocked_log_crit): + bgpcfgd.frr.run_command = lambda cmd: (1, "some config", "some error") + f = bgpcfgd.frr.FRR(["abc", "cde"]) + out = f.get_config() + assert out == "" + mocked_log_crit.assert_called_with("can't update running config: rc=1 out='some config' err='some error'") + +def test_write(): + bgpcfgd.frr.run_command = lambda cmd: (0, "some output", "") + f = bgpcfgd.frr.FRR(["abc", "cde"]) + res = f.write("config context") + assert res, "Expect True return value" + +def test_write_fail(): + bgpcfgd.frr.run_command = lambda cmd: (1, "some output", "some error") + f = bgpcfgd.frr.FRR(["abc", "cde"]) + res = f.write("config context") + assert not res, "Expect False return value" + +def test_restart_peer_groups(): + bgpcfgd.frr.run_command = lambda cmd: (0, "some output", "") + f = bgpcfgd.frr.FRR(["abc", "cde"]) + res = f.restart_peer_groups(["pg_1", "pg_2"]) + assert res, "Expect True return value" + +@patch('bgpcfgd.frr.log_crit') +def test_restart_peer_groups_fail(mocked_log_crit): + return_value_map = { + "['vtysh', '-c', 'clear bgp peer-group pg_1 soft in']": (0, "", ""), + "['vtysh', '-c', 'clear bgp peer-group pg_2 soft in']": (1, "some output", "some error") + } + bgpcfgd.frr.run_command = lambda cmd: return_value_map[str(cmd)] + f = bgpcfgd.frr.FRR(["abc", "cde"]) + res = f.restart_peer_groups(["pg_1", "pg_2"]) + assert not res, "Expect False return value" + mocked_log_crit.assert_called_with("Can't restart bgp peer-group 'pg_2'. rc='1', out='some output', err='some error'") diff --git a/src/sonic-bgpcfgd/tests/test_intf.py b/src/sonic-bgpcfgd/tests/test_intf.py new file mode 100644 index 000000000000..74fa8e471ac6 --- /dev/null +++ b/src/sonic-bgpcfgd/tests/test_intf.py @@ -0,0 +1,52 @@ +from unittest.mock import MagicMock, patch + +from bgpcfgd.directory import Directory +from bgpcfgd.template import TemplateFabric +from swsscommon import swsscommon +from bgpcfgd.managers_intf import InterfaceMgr + +def set_handler_test(manager, key, value): + res = manager.set_handler(key, value) + assert res, "Returns always True" + assert manager.directory.get(manager.db_name, manager.table_name, key) == value + +def del_handler_test(manager, key): + manager.del_handler(key) + assert manager.directory.get_path(manager.db_name, manager.table_name, key) == None + +@patch('bgpcfgd.managers_intf.log_warn') +def test_intf(mocked_log_warn): + cfg_mgr = MagicMock() + common_objs = { + 'directory': Directory(), + 'cfg_mgr': cfg_mgr, + 'tf': TemplateFabric(), + 'constants': {}, + } + m = InterfaceMgr(common_objs, "CONFIG_DB", swsscommon.CFG_VLAN_INTF_TABLE_NAME) + + set_handler_test(m, "Vlan1000", {}) + set_handler_test(m, "Vlan1000|192.168.0.1/21", {}) + + # test set handler with invalid ip network + res = m.set_handler("Vlan1000|invalid_netowrk", {}) + assert res, "Returns always True" + mocked_log_warn.assert_called_with("Subnet 'invalid_netowrk' format is wrong for interface 'Vlan1000'") + + del_handler_test(m, "Vlan1000") + del_handler_test(m, "Vlan1000|192.168.0.1/21") + del_handler_test(m, "Vlan1000|invalid_netowrk") + mocked_log_warn.assert_called_with("Subnet 'invalid_netowrk' format is wrong for interface 'Vlan1000'") + +def test_intf_ipv6(): + cfg_mgr = MagicMock() + common_objs = { + 'directory': Directory(), + 'cfg_mgr': cfg_mgr, + 'tf': TemplateFabric(), + 'constants': {}, + } + m = InterfaceMgr(common_objs, "CONFIG_DB", swsscommon.CFG_VLAN_INTF_TABLE_NAME) + + set_handler_test(m, "Vlan1000|fc02:1000::1/64", {}) + del_handler_test(m, "Vlan1000|fc02:1000::1/64") diff --git a/src/sonic-bgpcfgd/tests/test_setsrc.py b/src/sonic-bgpcfgd/tests/test_setsrc.py new file mode 100644 index 000000000000..5d1a81908837 --- /dev/null +++ b/src/sonic-bgpcfgd/tests/test_setsrc.py @@ -0,0 +1,62 @@ +from unittest.mock import MagicMock, patch + +import os +from bgpcfgd.directory import Directory +from bgpcfgd.template import TemplateFabric +from copy import deepcopy +from . import swsscommon_test +from swsscommon import swsscommon + +with patch.dict("sys.modules", swsscommon=swsscommon_test): + from bgpcfgd.managers_setsrc import ZebraSetSrc + +TEMPLATE_PATH = os.path.abspath('../../dockers/docker-fpm-frr/frr') + +def constructor(): + cfg_mgr = MagicMock() + common_objs = { + 'directory': Directory(), + 'cfg_mgr': cfg_mgr, + 'tf': TemplateFabric(TEMPLATE_PATH), + 'constants': {}, + } + + m = ZebraSetSrc(common_objs, "STATE_DB", swsscommon.STATE_INTERFACE_TABLE_NAME) + assert m.lo_ipv4 == None + assert m.lo_ipv6 == None + + return m + +@patch('bgpcfgd.managers_setsrc.log_info') +def test_set_handler(mocked_log_info): + m = constructor() + res = m.set_handler("Loopback0|10.1.0.32/32", {"state": "ok"}) + assert res, "Returns always True" + mocked_log_info.assert_called_with("The 'set src' configuration with Loopback0 ip '10.1.0.32' has been scheduled to be added") + +@patch('bgpcfgd.managers_setsrc.log_err') +def test_set_handler_no_slash(mocked_log_err): + m = constructor() + res = m.set_handler("Loopback0|10.1.0.32", {"state": "ok"}) + assert res, "Returns always True" + mocked_log_err.assert_called_with("Wrong Loopback0 ip prefix: '10.1.0.32'") + +@patch('bgpcfgd.managers_setsrc.log_info') +def test_set_handler_ipv6(mocked_log_info): + m = constructor() + res = m.set_handler("Loopback0|FC00:1::32/128", {"state": "ok"}) + assert res, "Returns always True" + mocked_log_info.assert_called_with("The 'set src' configuration with Loopback0 ip 'FC00:1::32' has been scheduled to be added") + +@patch('bgpcfgd.managers_setsrc.log_err') +def test_set_handler_invalid_ip(mocked_log_err): + m = constructor() + res = m.set_handler("Loopback0|invalid/ip", {"state": "ok"}) + assert res, "Returns always True" + mocked_log_err.assert_called_with("Got ambiguous ip address 'invalid'") + +@patch('bgpcfgd.managers_setsrc.log_warn') +def test_del_handler(mocked_log_warn): + m = constructor() + m.del_handler("Loopback0|10.1.0.32/32") + mocked_log_warn.assert_called_with("Delete command is not supported for 'zebra set src' templates") From bab136fc8ff44308b7e631d2b51d45c0fedbeaad Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Tue, 2 Feb 2021 03:58:20 -0800 Subject: [PATCH 0122/1674] [proc-exit-listener]: fix syntax error the bug is introduced in commit 34cca20c Signed-off-by: Guohan Lu --- files/scripts/supervisor-proc-exit-listener | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/scripts/supervisor-proc-exit-listener b/files/scripts/supervisor-proc-exit-listener index 4ac77298c78a..e8565b4d52f2 100755 --- a/files/scripts/supervisor-proc-exit-listener +++ b/files/scripts/supervisor-proc-exit-listener @@ -42,7 +42,7 @@ def get_critical_group_and_process_list(): with open(CRITICAL_PROCESSES_FILE, 'r') as file: for line in file: # ignore blank lines - if re.match(r"^\s*$", line) + if re.match(r"^\s*$", line): continue line_info = line.strip(' \n').split(':') if len(line_info) != 2: From 8572f3cee5dd29a05bdf3634947fef8211675323 Mon Sep 17 00:00:00 2001 From: Renuka Manavalan <47282725+renukamanavalan@users.noreply.github.com> Date: Tue, 2 Feb 2021 11:16:37 -0800 Subject: [PATCH 0123/1674] Update minigraph.py to parse kubernetes config from minigraph.xml (#6633) Update minigraph parser to retrieve kubernetes server info from minigraph.xml and update "KUBERNETES_MASTER|SERVER" in running config. Update minigraph parser to include clusterName from minigraph.xml into "DEVICE_METADATA|localhost" --- src/sonic-config-engine/minigraph.py | 41 +++++++++++++++---- .../tests/simple-sample-graph-case.xml | 10 +++++ .../tests/test_minigraph_case.py | 13 +++++- 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index ba81e8faf771..06b799cdeff7 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -84,6 +84,7 @@ def parse_device(device): hwsku = None name = None deployment_id = None + cluster = None for node in device: if node.tag == str(QName(ns, "Address")): @@ -100,11 +101,13 @@ def parse_device(device): deployment_id = node.text elif node.tag == str(QName(ns, "ElementType")): d_type = node.text + elif node.tag == str(QName(ns, "ClusterName")): + cluster = node.text if d_type is None and str(QName(ns3, "type")) in device.attrib: d_type = device.attrib[str(QName(ns3, "type"))] - return (lo_prefix, lo_prefix_v6, mgmt_prefix, name, hwsku, d_type, deployment_id) + return (lo_prefix, lo_prefix_v6, mgmt_prefix, name, hwsku, d_type, deployment_id, cluster) def calculate_lcm_for_ecmp (nhdevices_bank_map, nhip_bank_map): banks_enumerated = {} @@ -244,8 +247,10 @@ def parse_png(png, hname, dpg_ecmp_content = None): if child.tag == str(QName(ns, "Devices")): for device in child.findall(str(QName(ns, "Device"))): - (lo_prefix, lo_prefix_v6, mgmt_prefix, name, hwsku, d_type, deployment_id) = parse_device(device) + (lo_prefix, lo_prefix_v6, mgmt_prefix, name, hwsku, d_type, deployment_id, cluster) = parse_device(device) device_data = {'lo_addr': lo_prefix, 'type': d_type, 'mgmt_addr': mgmt_prefix, 'hwsku': hwsku } + if cluster: + device_data['cluster'] = cluster if deployment_id: device_data['deployment_id'] = deployment_id if lo_prefix_v6: @@ -253,9 +258,7 @@ def parse_png(png, hname, dpg_ecmp_content = None): devices[name] = device_data if name == hname: - cluster = device.find(str(QName(ns, "ClusterName"))) - - if cluster != None and cluster.text != None and "str" in cluster.text.lower(): + if cluster and "str" in cluster.lower(): is_storage_device = True if child.tag == str(QName(ns, "DeviceInterfaceLinks")): @@ -380,8 +383,10 @@ def parse_asic_png(png, asic_name, hostname): if child.tag == str(QName(ns, "Devices")): for device in child.findall(str(QName(ns, "Device"))): - (lo_prefix, lo_prefix_v6, mgmt_prefix, name, hwsku, d_type, deployment_id) = parse_device(device) + (lo_prefix, lo_prefix_v6, mgmt_prefix, name, hwsku, d_type, deployment_id, cluster) = parse_device(device) device_data = {'lo_addr': lo_prefix, 'type': d_type, 'mgmt_addr': mgmt_prefix, 'hwsku': hwsku } + if cluster: + device_data['cluster'] = cluster if deployment_id: device_data['deployment_id'] = deployment_id if lo_prefix_v6: @@ -780,6 +785,7 @@ def parse_meta(meta, hname): region = None cloudtype = None resource_type = None + kube_data = {} device_metas = meta.find(str(QName(ns, "Devices"))) for device in device_metas.findall(str(QName(ns1, "DeviceMetadata"))): if device.find(str(QName(ns1, "Name"))).text.lower() == hname.lower(): @@ -808,7 +814,11 @@ def parse_meta(meta, hname): cloudtype = value elif name == "ResourceType": resource_type = value - return syslog_servers, dhcp_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype, resource_type + elif name == "KubernetesEnabled": + kube_data["enable"] = value + elif name == "KubernetesServerIp": + kube_data["ip"] = value + return syslog_servers, dhcp_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype, resource_type, kube_data def parse_linkmeta(meta, hname): @@ -1097,6 +1107,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw host_lo_intfs = None is_storage_device = False local_devices = [] + kube_data = {} # hostname is the asic_name, get the asic_id from the asic_name if asic_name is not None: @@ -1133,7 +1144,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw elif child.tag == str(QName(ns, "UngDec")): (u_neighbors, u_devices, _, _, _, _, _, _) = parse_png(child, hostname, None) elif child.tag == str(QName(ns, "MetadataDeclaration")): - (syslog_servers, dhcp_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype, resource_type) = parse_meta(child, hostname) + (syslog_servers, dhcp_servers, ntp_servers, tacacs_servers, mgmt_routes, erspan_dst, deployment_id, region, cloudtype, resource_type, kube_data) = parse_meta(child, hostname) elif child.tag == str(QName(ns, "LinkMetadataDeclaration")): linkmetas = parse_linkmeta(child, hostname) elif child.tag == str(QName(ns, "DeviceInfos")): @@ -1174,6 +1185,18 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw } } + cluster = [devices[key] for key in devices if key.lower() == hostname.lower()][0].get('cluster', "") + if cluster: + results['DEVICE_METADATA']['localhost']['cluster'] = cluster + + if kube_data: + results['KUBERNETES_MASTER'] = { + 'SERVER': { + 'disable': str(kube_data.get('enable', '0') == '0'), + 'ip': kube_data.get('ip', '') + } + } + results['PEER_SWITCH'] = get_peer_switch_info(linkmetas, devices) if bool(results['PEER_SWITCH']): @@ -1524,7 +1547,7 @@ def get_mux_cable_entries(mux_cable_ports, neighbors, devices): def parse_device_desc_xml(filename): root = ET.parse(filename).getroot() - (lo_prefix, lo_prefix_v6, mgmt_prefix, hostname, hwsku, d_type, _) = parse_device(root) + (lo_prefix, lo_prefix_v6, mgmt_prefix, hostname, hwsku, d_type, _, _) = parse_device(root) results = {} results['DEVICE_METADATA'] = {'localhost': { 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 ce0174adc8dd..95f501200c83 100644 --- a/src/sonic-config-engine/tests/simple-sample-graph-case.xml +++ b/src/sonic-config-engine/tests/simple-sample-graph-case.xml @@ -390,6 +390,16 @@ 10.0.10.7;10.0.10.8 + + KubernetesEnabled + + 0 + + + KubernetesServerIp + + 10.10.10.10 + diff --git a/src/sonic-config-engine/tests/test_minigraph_case.py b/src/sonic-config-engine/tests/test_minigraph_case.py index 6fa7c5352d05..64e0bb09d730 100644 --- a/src/sonic-config-engine/tests/test_minigraph_case.py +++ b/src/sonic-config-engine/tests/test_minigraph_case.py @@ -1,3 +1,4 @@ +import json import os import subprocess @@ -145,6 +146,11 @@ def test_minigraph_deployment_id(self): output = self.run_script(argument) self.assertEqual(output.strip(), "1") + def test_minigraph_cluster(self): + argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "DEVICE_METADATA[\'localhost\'][\'cluster\']"' + output = self.run_script(argument) + self.assertEqual(output.strip(), "AAA00PrdStr00") + def test_minigraph_neighbor_metadata(self): argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "DEVICE_NEIGHBOR_METADATA"' @@ -195,6 +201,12 @@ def test_metadata_tacacs(self): output = self.run_script(argument) self.assertEqual(output.strip(), "{'10.0.10.7': {'priority': '1', 'tcp_port': '49'}, '10.0.10.8': {'priority': '1', 'tcp_port': '49'}}") + def test_metadata_kube(self): + argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "KUBERNETES_MASTER[\'SERVER\']"' + output = self.run_script(argument) + self.assertEqual(json.loads(output.strip().replace("'", "\"")), + json.loads('{"ip": "10.10.10.10", "disable": "True"}')) + def test_minigraph_mgmt_port(self): argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "MGMT_PORT"' output = self.run_script(argument) @@ -289,4 +301,3 @@ def test_minigraph_mux_cable_table(self): utils.to_dict(output.strip()), expected_table ) - \ No newline at end of file From e35377eddfa085220ae912b7fffd0243e8b1b835 Mon Sep 17 00:00:00 2001 From: Vaibhav Hemant Dixit Date: Tue, 2 Feb 2021 11:26:36 -0800 Subject: [PATCH 0124/1674] [arista]: 7050CX3-32S-C32: Remove unused 10G ports and update speed (#6638) port_config.ini for HWSKU Arista-7050CX3-32S-C32 has missing speed column and duplicated lanes. The incorrect speed causes issues in Orchagent RESTARTCHECK as the below task remains as the remaining item during swss shutdown. --- .../Arista-7050CX3-32S-C32/port_config.ini | 68 +++++++++---------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/port_config.ini b/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/port_config.ini index d3d339076a59..e24a70e97967 100644 --- a/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/port_config.ini +++ b/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/port_config.ini @@ -1,35 +1,33 @@ -# name lanes alias index -Ethernet0 1,2,3,4 Ethernet1/1 1 -Ethernet4 5,6,7,8 Ethernet2/1 2 -Ethernet8 9,10,11,12 Ethernet3/1 3 -Ethernet12 13,14,15,16 Ethernet4/1 4 -Ethernet16 21,22,23,24 Ethernet5/1 5 -Ethernet20 17,18,19,20 Ethernet6/1 6 -Ethernet24 25,26,27,28 Ethernet7/1 7 -Ethernet28 29,30,31,32 Ethernet8/1 8 -Ethernet32 37,38,39,40 Ethernet9/1 9 -Ethernet36 33,34,35,36 Ethernet10/1 10 -Ethernet40 41,42,43,44 Ethernet11/1 11 -Ethernet44 45,46,47,48 Ethernet12/1 12 -Ethernet48 53,54,55,56 Ethernet13/1 13 -Ethernet52 49,50,51,52 Ethernet14/1 14 -Ethernet56 57,58,59,60 Ethernet15/1 15 -Ethernet60 61,62,63,64 Ethernet16/1 16 -Ethernet64 69,70,71,72 Ethernet17/1 17 -Ethernet68 65,66,67,68 Ethernet18/1 18 -Ethernet72 73,74,75,76 Ethernet19/1 19 -Ethernet76 77,78,79,80 Ethernet20/1 20 -Ethernet80 85,86,87,88 Ethernet21/1 21 -Ethernet84 81,82,83,84 Ethernet22/1 22 -Ethernet88 89,90,91,92 Ethernet23/1 23 -Ethernet92 93,94,95,96 Ethernet24/1 24 -Ethernet96 101,102,103,104 Ethernet25/1 25 -Ethernet100 97,98,99,100 Ethernet26/1 26 -Ethernet104 105,106,107,108 Ethernet27/1 27 -Ethernet108 109,110,111,112 Ethernet28/1 28 -Ethernet112 117,118,119,120 Ethernet29/1 29 -Ethernet116 113,114,115,116 Ethernet30/1 30 -Ethernet120 121,122,123,124 Ethernet31/1 31 -Ethernet124 125,126,127,128 Ethernet32/1 32 -Ethernet128 129 Ethernet33 33 -Ethernet132 128 Ethernet34 34 +# name lanes alias index speed +Ethernet0 1,2,3,4 Ethernet1/1 1 100000 +Ethernet4 5,6,7,8 Ethernet2/1 2 100000 +Ethernet8 9,10,11,12 Ethernet3/1 3 100000 +Ethernet12 13,14,15,16 Ethernet4/1 4 100000 +Ethernet16 21,22,23,24 Ethernet5/1 5 100000 +Ethernet20 17,18,19,20 Ethernet6/1 6 100000 +Ethernet24 25,26,27,28 Ethernet7/1 7 100000 +Ethernet28 29,30,31,32 Ethernet8/1 8 100000 +Ethernet32 37,38,39,40 Ethernet9/1 9 100000 +Ethernet36 33,34,35,36 Ethernet10/1 10 100000 +Ethernet40 41,42,43,44 Ethernet11/1 11 100000 +Ethernet44 45,46,47,48 Ethernet12/1 12 100000 +Ethernet48 53,54,55,56 Ethernet13/1 13 100000 +Ethernet52 49,50,51,52 Ethernet14/1 14 100000 +Ethernet56 57,58,59,60 Ethernet15/1 15 100000 +Ethernet60 61,62,63,64 Ethernet16/1 16 100000 +Ethernet64 69,70,71,72 Ethernet17/1 17 100000 +Ethernet68 65,66,67,68 Ethernet18/1 18 100000 +Ethernet72 73,74,75,76 Ethernet19/1 19 100000 +Ethernet76 77,78,79,80 Ethernet20/1 20 100000 +Ethernet80 85,86,87,88 Ethernet21/1 21 100000 +Ethernet84 81,82,83,84 Ethernet22/1 22 100000 +Ethernet88 89,90,91,92 Ethernet23/1 23 100000 +Ethernet92 93,94,95,96 Ethernet24/1 24 100000 +Ethernet96 101,102,103,104 Ethernet25/1 25 100000 +Ethernet100 97,98,99,100 Ethernet26/1 26 100000 +Ethernet104 105,106,107,108 Ethernet27/1 27 100000 +Ethernet108 109,110,111,112 Ethernet28/1 28 100000 +Ethernet112 117,118,119,120 Ethernet29/1 29 100000 +Ethernet116 113,114,115,116 Ethernet30/1 30 100000 +Ethernet120 121,122,123,124 Ethernet31/1 31 100000 +Ethernet124 125,126,127,128 Ethernet32/1 32 100000 From dc474114c54cc1f733a104a5b1af6e31d94cff79 Mon Sep 17 00:00:00 2001 From: Tamer Ahmed Date: Wed, 3 Feb 2021 05:32:09 -0800 Subject: [PATCH 0125/1674] [sairedis] Submodule Update (#6649) Change in this updat: b39e746 Spell check fixes (#783) 373be80 [build-vm] Don't Install Lib Boost 1.67 (#784) signed-off-by: Tamer Ahmed --- src/sonic-sairedis | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-sairedis b/src/sonic-sairedis index 817a01e4bfa2..b39e74610ad7 160000 --- a/src/sonic-sairedis +++ b/src/sonic-sairedis @@ -1 +1 @@ -Subproject commit 817a01e4bfa25d701727d1750989d5cd9f1bbcb3 +Subproject commit b39e74610ad7a842618a025fdadbdc52d530483a From d26a4aff9a41024df2e2547d078fb8d9d69c683c Mon Sep 17 00:00:00 2001 From: Volodymyr Boiko <66446128+vboykox@users.noreply.github.com> Date: Wed, 3 Feb 2021 02:19:43 +0200 Subject: [PATCH 0126/1674] [platform][barefoot] Install sonic_platform to host (#6644) - Why I did it SONiC design requires sonic_platform package to be installed in SONiC host environment, not only in docker containers. - How I did it For now, sonic_platform python wheel package, that is used by pmon, is provided via device-specific platform modules deb packages that unpacks the wheel package file into specific device's directory on lazy-install. The PR makes deb packages' postinst script also install these unpacked wheel packages to host. Signed-off-by: Volodymyr Boyko --- .../debian/postinst | 10 ++++++++ .../debian/postinst | 23 ++++++++++++++++++- .../debian/postinst | 10 ++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100755 platform/barefoot/sonic-platform-modules-bfn-montara/debian/postinst create mode 100644 platform/barefoot/sonic-platform-modules-bfn/debian/postinst diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/debian/postinst b/platform/barefoot/sonic-platform-modules-bfn-montara/debian/postinst new file mode 100755 index 000000000000..a218d59e2652 --- /dev/null +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/debian/postinst @@ -0,0 +1,10 @@ +#!/bin/sh +set -e + +PLATFORM_NAME=x86_64-accton_wedge100bf_32x-r0 +SONIC_PLATFORM_WHEEL_PY2="/usr/share/sonic/device/${PLATFORM_NAME}/sonic_platform-1.0-py2-none-any.whl" +python2 -m pip install ${SONIC_PLATFORM_WHEEL_PY2} +SONIC_PLATFORM_WHEEL_PY3="/usr/share/sonic/device/${PLATFORM_NAME}/sonic_platform-1.0-py3-none-any.whl" +python3 -m pip install ${SONIC_PLATFORM_WHEEL_PY3} + +#DEBHELPER# diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/debian/postinst b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/postinst index a89ac4f4f5b2..90d772ef89df 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-newport/debian/postinst +++ b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/postinst @@ -1,6 +1,27 @@ #!/bin/sh set -e -depmod -a +depmod -a systemctl enable bfn-newport.service systemctl start bfn-newport.service + +PLATFORM_NAME=x86_64-accton_as9516bf_32d-r0 +SONIC_PLATFORM_WHEEL_PY2="/usr/share/sonic/device/${PLATFORM_NAME}/sonic_platform-1.0-py2-none-any.whl" +if [ -e ${SONIC_PLATFORM_WHEEL_PY2} ]; then + python2 -m pip install ${SONIC_PLATFORM_WHEEL_PY2} +fi +SONIC_PLATFORM_WHEEL_PY3="/usr/share/sonic/device/${PLATFORM_NAME}/sonic_platform-1.0-py3-none-any.whl" +if [ -e ${SONIC_PLATFORM_WHEEL_PY3} ]; then + python3 -m pip install ${SONIC_PLATFORM_WHEEL_PY3} +fi + +PLATFORM_NAME=x86_64-accton_as9516_32d-r0 +SONIC_PLATFORM_WHEEL_PY2="/usr/share/sonic/device/${PLATFORM_NAME}/sonic_platform-1.0-py2-none-any.whl" +if [ -e ${SONIC_PLATFORM_WHEEL_PY2} ]; then + python2 -m pip install ${SONIC_PLATFORM_WHEEL_PY2} +fi +SONIC_PLATFORM_WHEEL_PY3="/usr/share/sonic/device/${PLATFORM_NAME}/sonic_platform-1.0-py3-none-any.whl" +if [ -e ${SONIC_PLATFORM_WHEEL_PY3} ]; then + python3 -m pip install ${SONIC_PLATFORM_WHEEL_PY3} +fi + #DEBHELPER# diff --git a/platform/barefoot/sonic-platform-modules-bfn/debian/postinst b/platform/barefoot/sonic-platform-modules-bfn/debian/postinst new file mode 100644 index 000000000000..bd24c078778a --- /dev/null +++ b/platform/barefoot/sonic-platform-modules-bfn/debian/postinst @@ -0,0 +1,10 @@ +#!/bin/sh +set -e + +PLATFORM_NAME=x86_64-accton_wedge100bf_65x-r0 +SONIC_PLATFORM_WHEEL_PY2="/usr/share/sonic/device/${PLATFORM_NAME}/sonic_platform-1.0-py2-none-any.whl" +python2 -m pip install ${SONIC_PLATFORM_WHEEL_PY2} +SONIC_PLATFORM_WHEEL_PY3="/usr/share/sonic/device/${PLATFORM_NAME}/sonic_platform-1.0-py3-none-any.whl" +python3 -m pip install ${SONIC_PLATFORM_WHEEL_PY3} + +#DEBHELPER# From 1b51ee205b268ad2ca109eeec048f04b511402c6 Mon Sep 17 00:00:00 2001 From: Dmytro Shevchuk <68949102+dmytroxshevchuk@users.noreply.github.com> Date: Wed, 3 Feb 2021 22:00:03 +0200 Subject: [PATCH 0127/1674] [barefoot] add platform.json, hwsku.json for mavericks (#6629) platform.json and hwsku.json replacement for deprecated port_config.ini. Also this files need for Dynamic Port Breakout. --- .../mavericks/hwsku.json | 329 +++++++++++++++ .../platform.json | 394 ++++++++++++++++++ 2 files changed, 723 insertions(+) create mode 100644 device/barefoot/x86_64-accton_wedge100bf_65x-r0/mavericks/hwsku.json create mode 100644 device/barefoot/x86_64-accton_wedge100bf_65x-r0/platform.json diff --git a/device/barefoot/x86_64-accton_wedge100bf_65x-r0/mavericks/hwsku.json b/device/barefoot/x86_64-accton_wedge100bf_65x-r0/mavericks/hwsku.json new file mode 100644 index 000000000000..857b00852c0b --- /dev/null +++ b/device/barefoot/x86_64-accton_wedge100bf_65x-r0/mavericks/hwsku.json @@ -0,0 +1,329 @@ +{ + "interfaces": { + "Ethernet0": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet4": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet8": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet12": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet16": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet20": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet24": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet28": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet32": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet36": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet40": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet44": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet48": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet52": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet56": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet60": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet64": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet68": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet72": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet76": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet80": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet84": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet88": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet92": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet96": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet100": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet104": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet108": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet112": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet116": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet120": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet124": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet128": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet132": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet136": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet140": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet144": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet148": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet152": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet156": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet160": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet164": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet168": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet172": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet176": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet180": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet184": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet188": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet192": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet196": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet200": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet204": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet208": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet212": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet216": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet220": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet224": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet228": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet232": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet236": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet240": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet244": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet248": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet252": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet256": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "none" + } + } +} diff --git a/device/barefoot/x86_64-accton_wedge100bf_65x-r0/platform.json b/device/barefoot/x86_64-accton_wedge100bf_65x-r0/platform.json new file mode 100644 index 000000000000..866706a28357 --- /dev/null +++ b/device/barefoot/x86_64-accton_wedge100bf_65x-r0/platform.json @@ -0,0 +1,394 @@ +{ + "interfaces": { + "Ethernet0": { + "index": "1,1,1,1", + "lanes": "0,1,2,3", + "alias_at_lanes": "Ethernet0,Ethernet1,Ethernet2,Ethernet3", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet4": { + "index": "2,2,2,2", + "lanes": "4,5,6,7", + "alias_at_lanes": "Ethernet4,Ethernet5,Ethernet6,Ethernet7", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet8": { + "index": "3,3,3,3", + "lanes": "8,9,10,11", + "alias_at_lanes": "Ethernet8,Ethernet9,Ethernet10,Ethernet11", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet12": { + "index": "4,4,4,4", + "lanes": "12,13,14,15", + "alias_at_lanes": "Ethernet12,Ethernet13,Ethernet14,Ethernet15", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet16": { + "index": "5,5,5,5", + "lanes": "16,17,18,19", + "alias_at_lanes": "Ethernet16,Ethernet17,Ethernet18,Ethernet19", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet20": { + "index": "6,6,6,6", + "lanes": "20,21,22,23", + "alias_at_lanes": "Ethernet20,Ethernet21,Ethernet22,Ethernet23", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet24": { + "index": "7,7,7,7", + "lanes": "24,25,26,27", + "alias_at_lanes": "Ethernet24,Ethernet25,Ethernet26,Ethernet27", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet28": { + "index": "8,8,8,8", + "lanes": "28,29,30,31", + "alias_at_lanes": "Ethernet28,Ethernet29,Ethernet30,Ethernet31", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet32": { + "index": "9,9,9,9", + "lanes": "32,33,34,35", + "alias_at_lanes": "Ethernet32,Ethernet33,Ethernet34,Ethernet35", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet36": { + "index": "10,10,10,10", + "lanes": "36,37,38,39", + "alias_at_lanes": "Ethernet36,Ethernet37,Ethernet38,Ethernet39", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet40": { + "index": "11,11,11,11", + "lanes": "40,41,42,43", + "alias_at_lanes": "Ethernet40,Ethernet41,Ethernet42,Ethernet43", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet44": { + "index": "12,12,12,12", + "lanes": "44,45,46,47", + "alias_at_lanes": "Ethernet44,Ethernet45,Ethernet46,Ethernet47", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet48": { + "index": "13,13,13,13", + "lanes": "48,49,50,51", + "alias_at_lanes": "Ethernet48,Ethernet49,Ethernet50,Ethernet51", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet52": { + "index": "14,14,14,14", + "lanes": "52,53,54,55", + "alias_at_lanes": "Ethernet52,Ethernet53,Ethernet54,Ethernet55", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet56": { + "index": "15,15,15,15", + "lanes": "56,57,58,59", + "alias_at_lanes": "Ethernet56,Ethernet57,Ethernet58,Ethernet59", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet60": { + "index": "16,16,16,16", + "lanes": "60,61,62,63", + "alias_at_lanes": "Ethernet60,Ethernet61,Ethernet62,Ethernet63", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet64": { + "index": "17,17,17,17", + "lanes": "64,65,66,67", + "alias_at_lanes": "Ethernet64,Ethernet65,Ethernet66,Ethernet67", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet68": { + "index": "18,18,18,18", + "lanes": "68,69,70,71", + "alias_at_lanes": "Ethernet68,Ethernet69,Ethernet70,Ethernet71", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet72": { + "index": "19,19,19,19", + "lanes": "72,73,74,75", + "alias_at_lanes": "Ethernet72,Ethernet73,Ethernet74,Ethernet75", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet76": { + "index": "20,20,20,20", + "lanes": "76,77,78,79", + "alias_at_lanes": "Ethernet76,Ethernet77,Ethernet78,Ethernet79", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet80": { + "index": "21,21,21,21", + "lanes": "80,81,82,83", + "alias_at_lanes": "Ethernet80,Ethernet81,Ethernet82,Ethernet83", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet84": { + "index": "22,22,22,22", + "lanes": "84,85,86,87", + "alias_at_lanes": "Ethernet84,Ethernet85,Ethernet86,Ethernet87", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet88": { + "index": "23,23,23,23", + "lanes": "88,89,90,91", + "alias_at_lanes": "Ethernet88,Ethernet89,Ethernet90,Ethernet91", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet92": { + "index": "24,24,24,24", + "lanes": "92,93,94,95", + "alias_at_lanes": "Ethernet92,Ethernet93,Ethernet94,Ethernet95", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet96": { + "index": "25,25,25,25", + "lanes": "96,97,98,99", + "alias_at_lanes": "Ethernet96,Ethernet97,Ethernet98,Ethernet99", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet100": { + "index": "26,26,26,26", + "lanes": "100,101,102,103", + "alias_at_lanes": "Ethernet100,Ethernet101,Ethernet102,Ethernet103", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet104": { + "index": "27,27,27,27", + "lanes": "104,105,106,107", + "alias_at_lanes": "Ethernet104,Ethernet105,Ethernet106,Ethernet107", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet108": { + "index": "28,28,28,28", + "lanes": "108,109,110,111", + "alias_at_lanes": "Ethernet108,Ethernet109,Ethernet110,Ethernet111", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet112": { + "index": "29,29,29,29", + "lanes": "112,113,114,115", + "alias_at_lanes": "Ethernet112,Ethernet113,Ethernet114,Ethernet115", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet116": { + "index": "30,30,30,30", + "lanes": "116,117,118,119", + "alias_at_lanes": "Ethernet116,Ethernet117,Ethernet118,Ethernet119", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet120": { + "index": "31,31,31,31", + "lanes": "120,121,122,123", + "alias_at_lanes": "Ethernet120,Ethernet121,Ethernet122,Ethernet123", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet124": { + "index": "32,32,32,32", + "lanes": "124,125,126,127", + "alias_at_lanes": "Ethernet124,Ethernet125,Ethernet126,Ethernet127", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet128": { + "index": "33,33,33,33", + "lanes": "128,129,130,131", + "alias_at_lanes": "Ethernet128,Ethernet129,Ethernet130,Ethernet131", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet132": { + "index": "34,34,34,34", + "lanes": "132,133,134,135", + "alias_at_lanes": "Ethernet132,Ethernet133,Ethernet134,Ethernet135", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet136": { + "index": "35,35,35,35", + "lanes": "136,137,138,139", + "alias_at_lanes": "Ethernet136,Ethernet137,Ethernet138,Ethernet139", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet140": { + "index": "36,36,36,36", + "lanes": "140,141,142,143", + "alias_at_lanes": "Ethernet140,Ethernet141,Ethernet142,Ethernet143", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet144": { + "index": "37,37,37,37", + "lanes": "144,145,146,147", + "alias_at_lanes": "Ethernet144,Ethernet145,Ethernet146,Ethernet147", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet148": { + "index": "38,38,38,38", + "lanes": "148,149,150,151", + "alias_at_lanes": "Ethernet148,Ethernet149,Ethernet150,Ethernet151", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet152": { + "index": "39,39,39,39", + "lanes": "152,153,154,155", + "alias_at_lanes": "Ethernet152,Ethernet153,Ethernet154,Ethernet155", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet156": { + "index": "40,40,40,40", + "lanes": "156,157,158,159", + "alias_at_lanes": "Ethernet156,Ethernet157,Ethernet158,Ethernet159", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet160": { + "index": "41,41,41,41", + "lanes": "160,161,162,163", + "alias_at_lanes": "Ethernet160,Ethernet161,Ethernet162,Ethernet163", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet164": { + "index": "42,42,42,42", + "lanes": "164,165,166,167", + "alias_at_lanes": "Ethernet164,Ethernet165,Ethernet166,Ethernet167", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet168": { + "index": "43,43,43,43", + "lanes": "168,169,170,171", + "alias_at_lanes": "Ethernet168,Ethernet169,Ethernet170,Ethernet171", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet172": { + "index": "44,44,44,44", + "lanes": "172,173,174,175", + "alias_at_lanes": "Ethernet172,Ethernet173,Ethernet174,Ethernet175", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet176": { + "index": "45,45,45,45", + "lanes": "176,177,178,179", + "alias_at_lanes": "Ethernet176,Ethernet177,Ethernet178,Ethernet179", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet180": { + "index": "46,46,46,46", + "lanes": "180,181,182,183", + "alias_at_lanes": "Ethernet180,Ethernet181,Ethernet182,Ethernet183", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet184": { + "index": "47,47,47,47", + "lanes": "184,185,186,187", + "alias_at_lanes": "Ethernet184,Ethernet185,Ethernet186,Ethernet187", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet188": { + "index": "48,48,48,48", + "lanes": "188,189,190,191", + "alias_at_lanes": "Ethernet188,Ethernet189,Ethernet190,Ethernet191", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet192": { + "index": "49,49,49,49", + "lanes": "192,193,194,195", + "alias_at_lanes": "Ethernet192,Ethernet193,Ethernet194,Ethernet195", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet196": { + "index": "50,50,50,50", + "lanes": "196,197,198,199", + "alias_at_lanes": "Ethernet196,Ethernet197,Ethernet198,Ethernet199", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet200": { + "index": "51,51,51,51", + "lanes": "200,201,202,203", + "alias_at_lanes": "Ethernet200,Ethernet201,Ethernet202,Ethernet203", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet204": { + "index": "52,52,52,52", + "lanes": "204,205,206,207", + "alias_at_lanes": "Ethernet204,Ethernet205,Ethernet206,Ethernet207", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet208": { + "index": "53,53,53,53", + "lanes": "208,209,210,211", + "alias_at_lanes": "Ethernet208,Ethernet209,Ethernet210,Ethernet211", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet212": { + "index": "54,54,54,54", + "lanes": "212,213,214,215", + "alias_at_lanes": "Ethernet212,Ethernet213,Ethernet214,Ethernet215", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet216": { + "index": "55,55,55,55", + "lanes": "216,217,218,219", + "alias_at_lanes": "Ethernet216,Ethernet217,Ethernet218,Ethernet219", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet220": { + "index": "56,56,56,56", + "lanes": "220,221,222,223", + "alias_at_lanes": "Ethernet220,Ethernet221,Ethernet222,Ethernet223", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet224": { + "index": "57,57,57,57", + "lanes": "224,225,226,227", + "alias_at_lanes": "Ethernet224,Ethernet225,Ethernet226,Ethernet227", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet228": { + "index": "58,58,58,58", + "lanes": "228,229,230,231", + "alias_at_lanes": "Ethernet228,Ethernet229,Ethernet230,Ethernet231", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet232": { + "index": "59,59,59,59", + "lanes": "232,233,234,235", + "alias_at_lanes": "Ethernet232,Ethernet233,Ethernet234,Ethernet235", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet236": { + "index": "60,60,60,60", + "lanes": "236,237,238,239", + "alias_at_lanes": "Ethernet236,Ethernet237,Ethernet238,Ethernet239", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet240": { + "index": "61,61,61,61", + "lanes": "240,241,242,243", + "alias_at_lanes": "Ethernet240,Ethernet241,Ethernet242,Ethernet243", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet244": { + "index": "62,62,62,62", + "lanes": "244,245,246,247", + "alias_at_lanes": "Ethernet244,Ethernet245,Ethernet246,Ethernet247", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet248": { + "index": "63,63,63,63", + "lanes": "248,249,250,251", + "alias_at_lanes": "Ethernet248,Ethernet249,Ethernet250,Ethernet251", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet252": { + "index": "64,64,64,64", + "lanes": "252,253,254,255", + "alias_at_lanes": "Ethernet252,Ethernet253,Ethernet254,Ethernet255", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet256": { + "index": "65,65,65,65", + "lanes": "256,257,258,259", + "alias_at_lanes": "Ethernet256,Ethernet257,Ethernet258,Ethernet259", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + } + } +} From 205fe8a8bf2f1a5068cb5a668aeae15e53075f8e Mon Sep 17 00:00:00 2001 From: Shi Su <67605788+shi-su@users.noreply.github.com> Date: Wed, 3 Feb 2021 15:33:49 -0800 Subject: [PATCH 0128/1674] [bgpcfgd]: Fix unit test for bgp manager (#6668) The check for check_neig_meta was not following the value in constants. Fix it to match the value in constants. --- src/sonic-bgpcfgd/tests/test_bgp.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sonic-bgpcfgd/tests/test_bgp.py b/src/sonic-bgpcfgd/tests/test_bgp.py index 8cbd51c90a4f..a4c5ef997725 100644 --- a/src/sonic-bgpcfgd/tests/test_bgp.py +++ b/src/sonic-bgpcfgd/tests/test_bgp.py @@ -12,11 +12,12 @@ def constructor(): cfg_mgr = MagicMock() + constants = load_constants()['constants'] common_objs = { 'directory': Directory(), 'cfg_mgr': cfg_mgr, 'tf': TemplateFabric(TEMPLATE_PATH), - 'constants': load_constants()['constants'] + 'constants': constants } return_value_map = { @@ -27,7 +28,7 @@ def constructor(): bgpcfgd.managers_bgp.run_command = lambda cmd: return_value_map[str(cmd)] m = bgpcfgd.managers_bgp.BGPPeerMgrBase(common_objs, "CONFIG_DB", swsscommon.CFG_BGP_NEIGHBOR_TABLE_NAME, "general", True) assert m.peer_type == "general" - assert m.check_neig_meta == False # Because constants['bgp']['use_neighbors_meta'] is false in constants.yml + assert m.check_neig_meta == ('bgp' in constants and 'use_neighbors_meta' in constants['bgp'] and constants['bgp']['use_neighbors_meta']) m.directory.put("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME, "localhost", {"bgp_asn": "65100"}) m.directory.put("CONFIG_DB", swsscommon.CFG_LOOPBACK_INTERFACE_TABLE_NAME, "Loopback0|11.11.11.11/32", {}) From 9f2a85697f20e51dd5af3ffbbdb6c04f6bb1a46d Mon Sep 17 00:00:00 2001 From: gechiang <62408185+gechiang@users.noreply.github.com> Date: Wed, 3 Feb 2021 15:59:56 -0800 Subject: [PATCH 0129/1674] BRCM SAI 4.3.0.10-4 Fix _brcm_sai_indexed_data_get () with unexpected queue causing _brcm_sai_switch_assert () after warm reboot (#6664) --- platform/broadcom/sai.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index fcb175d3d0c5..1b27d7bc1f88 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,8 +1,8 @@ -BRCM_SAI = libsaibcm_4.2.1.5-10_amd64.deb -$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.2/master/buster/libsaibcm_4.2.1.5-10_amd64.deb?sv=2019-12-12&st=2021-01-12T07%3A30%3A31Z&se=2035-01-13T07%3A30%3A00Z&sr=b&sp=r&sig=yCGwk%2FW%2Fg%2FaFxhr0oNSTZ%2BVy5B6kX1WDEsbbyz9J088%3D" -BRCM_SAI_DEV = libsaibcm-dev_4.2.1.5-10_amd64.deb +BRCM_SAI = libsaibcm_4.3.0.10-4_amd64.deb +$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.0.10-4_amd64.deb?sv=2015-04-05&sr=b&sig=nfseU56PACVqklQ4MC0HvZ7qt7Ou4loQMBA7jx8CSOY%3D&se=2034-10-13T16%3A31%3A22Z&sp=r" +BRCM_SAI_DEV = libsaibcm-dev_4.3.0.10-4_amd64.deb $(eval $(call add_derived_package,$(BRCM_SAI),$(BRCM_SAI_DEV))) -$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.2/master/buster/libsaibcm-dev_4.2.1.5-10_amd64.deb?sv=2019-12-12&st=2021-01-12T07%3A32%3A43Z&se=2035-01-13T07%3A32%3A00Z&sr=b&sp=r&sig=wuCNc6pa12JQCBi%2BM9rLWvVI92ldan9hKNF%2BfVfUWN8%3D" +$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.0.10-4_amd64.deb?sv=2015-04-05&sr=b&sig=4tF26GxI6jmrcvRyCezQ7RL6qMjzip7SFf61eqy%2Bvf4%3D&se=2034-10-13T16%3A31%3A53Z&sp=r" SONIC_ONLINE_DEBS += $(BRCM_SAI) $(BRCM_SAI_DEV)_DEPENDS += $(BRCM_SAI) From 94cb1f01bea92dbfd549ab9adc192733db3928bd Mon Sep 17 00:00:00 2001 From: vdahiya12 <67608553+vdahiya12@users.noreply.github.com> Date: Wed, 3 Feb 2021 17:05:13 -0800 Subject: [PATCH 0130/1674] [sonic-platform-common] submodule update (#6669) This PR updates the following commits in sonic-platform-common 6ad0004 [component] add auto_update_firmware() to support the auto update. (#106) 49076a9 [sonic_y_cable] Add support for measuring BER and EYE scan and running Loopback, PRBS modes on the Y cable (#158) 6b12b4c [sfp] Add parsing the dom_capability to sff8472 (#102) 7fc76b9 [sonic_pcie] Add get_pcie_aer_stats and its common implementation (#144) Signed-off-by: vaibhav-dahiya --- src/sonic-platform-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-platform-common b/src/sonic-platform-common index 8664efc5472a..6ad0004c29a1 160000 --- a/src/sonic-platform-common +++ b/src/sonic-platform-common @@ -1 +1 @@ -Subproject commit 8664efc5472ae8cab04ad5a3499baa9a9c0d7f89 +Subproject commit 6ad0004c29a143a0635ad7f3c81ce652313569cb From ceb7b2c019ab06a03b1728f0064518b0d00184af Mon Sep 17 00:00:00 2001 From: lguohan Date: Wed, 3 Feb 2021 20:08:39 -0800 Subject: [PATCH 0131/1674] [submodule]: update sonic-snmpagent (#6663) * 3885f19 2021-02-02 | let sysDescr_pass use python3 (#195) (HEAD, origin/master, origin/HEAD) [lguohan] * ad302d4 2021-01-28 | Fix: 'key not found' exception in bgp4.py (#192) [bingwang-ms] * 59e2a1c 2021-01-27 | Fix fdb_vlanmac() on corner cases (#193) [Qi Luo] Signed-off-by: Guohan Lu --- src/sonic-snmpagent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-snmpagent b/src/sonic-snmpagent index dfde06e2f5d7..3885f193be05 160000 --- a/src/sonic-snmpagent +++ b/src/sonic-snmpagent @@ -1 +1 @@ -Subproject commit dfde06e2f5d70e23882af6c0f1af4ae43ec2fa43 +Subproject commit 3885f193be05099659808092d22c5f69407cdda4 From a9d3281d56ae8078681eaeb28bbca29f5744dc34 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Wed, 3 Feb 2021 20:17:34 -0800 Subject: [PATCH 0132/1674] [build]: Fix dependency: asyncsnmp should not depend on PYTHON_SWSSCOMMON (#6672) Add dependency: dbsyncd will depend on PYTHON3_SWSSCOMMON --- rules/asyncsnmp-py3.mk | 2 +- rules/dbsyncd-py3.mk | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/rules/asyncsnmp-py3.mk b/rules/asyncsnmp-py3.mk index 990cc4512f8c..2592eb004ee8 100644 --- a/rules/asyncsnmp-py3.mk +++ b/rules/asyncsnmp-py3.mk @@ -5,5 +5,5 @@ $(ASYNCSNMP_PY3)_SRC_PATH = $(SRC_PATH)/sonic-snmpagent $(ASYNCSNMP_PY3)_PYTHON_VERSION = 3 # Depends on sonic-platform-common so it is possible to import sonic_psu $(ASYNCSNMP_PY3)_DEPENDS += $(SWSSSDK_PY3) $(SONIC_PLATFORM_COMMON_PY3) -$(ASYNCSNMP_PY3)_DEBS_DEPENDS += $(LIBSWSSCOMMON) $(PYTHON_SWSSCOMMON) $(PYTHON3_SWSSCOMMON) +$(ASYNCSNMP_PY3)_DEBS_DEPENDS += $(LIBSWSSCOMMON) $(PYTHON3_SWSSCOMMON) SONIC_PYTHON_WHEELS += $(ASYNCSNMP_PY3) diff --git a/rules/dbsyncd-py3.mk b/rules/dbsyncd-py3.mk index 0f150c0c59f5..12cf13cafe3b 100644 --- a/rules/dbsyncd-py3.mk +++ b/rules/dbsyncd-py3.mk @@ -4,4 +4,5 @@ DBSYNCD_PY3 = sonic_d-2.0.0-py3-none-any.whl $(DBSYNCD_PY3)_SRC_PATH = $(SRC_PATH)/sonic-dbsyncd $(DBSYNCD_PY3)_PYTHON_VERSION = 3 $(DBSYNCD_PY3)_DEPENDS += $(SWSSSDK_PY3) +$(DBSYNCD_PY3)_DEBS_DEPENDS += $(LIBSWSSCOMMON) $(PYTHON3_SWSSCOMMON) SONIC_PYTHON_WHEELS += $(DBSYNCD_PY3) From a7d453872f8b2cc8ceee0ca8232c7a2a1f874093 Mon Sep 17 00:00:00 2001 From: Garrick He <32883830+GarrickHe@users.noreply.github.com> Date: Wed, 3 Feb 2021 20:32:13 -0800 Subject: [PATCH 0133/1674] [sFlow] - Fix memory leak (#6662) * Bump version number to 2.0.32-1 to include a fix for a memory-leak found during testing. A wrong API is used to free the cJSON data-structure, which only frees the first pointed-to structure. The proper API should recursively free all structures. Signed-off-by: Garrick He --- rules/sflow.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules/sflow.mk b/rules/sflow.mk index f41bde774f02..7f0ac72bed3f 100644 --- a/rules/sflow.mk +++ b/rules/sflow.mk @@ -1,7 +1,7 @@ # host-sflow package -HSFLOWD_VERSION = 2.0.28 -HSFLOWD_SUBVERSION = 2 +HSFLOWD_VERSION = 2.0.32 +HSFLOWD_SUBVERSION = 1 export HSFLOWD_VERSION HSFLOWD_SUBVERSION HSFLOWD = hsflowd_$(HSFLOWD_VERSION)-$(HSFLOWD_SUBVERSION)_$(CONFIGURED_ARCH).deb From d7e9cba966d5f4b48acc804b1823a2acf525b6b1 Mon Sep 17 00:00:00 2001 From: Eran Dahan Date: Thu, 4 Feb 2021 09:12:28 +0200 Subject: [PATCH 0134/1674] [MLNX] update SAI submodule to include fix for debug dump (#6667) **Why I did it** Disable SDK extended dump due to issue found **How I did it** Update SAI submodule **How to verify it** Verify the SDK extended dump is not called. Signed-off-by: Eran Dahan --- platform/mellanox/mlnx-sai/SAI-Implementation | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/mellanox/mlnx-sai/SAI-Implementation b/platform/mellanox/mlnx-sai/SAI-Implementation index 2902c78672eb..abdc7c069ea8 160000 --- a/platform/mellanox/mlnx-sai/SAI-Implementation +++ b/platform/mellanox/mlnx-sai/SAI-Implementation @@ -1 +1 @@ -Subproject commit 2902c78672eb9602296fd17654f29a21ddaf8290 +Subproject commit abdc7c069ea8714af53cd4337f05bd493f133668 From ad937fbac1d97276b3ab729384bdb4e004f2dd8a Mon Sep 17 00:00:00 2001 From: abdosi <58047199+abdosi@users.noreply.github.com> Date: Thu, 4 Feb 2021 08:15:36 -0800 Subject: [PATCH 0135/1674] Fix Allow prefix Delete case (#6671) When we add allow-list key with action above route-map gets updated . For eg if we add deny action above template will become to no-export community. Now if we delete the key Issue is we still keep the no-export and do not move back to drop community. This PR fixes this issue by rolling back default route-map community value back to constants.yml default action. --- .../bgpcfgd/managers_allow_list.py | 7 +- src/sonic-bgpcfgd/tests/test_allow_list.py | 378 +++++++++++++++++- 2 files changed, 378 insertions(+), 7 deletions(-) diff --git a/src/sonic-bgpcfgd/bgpcfgd/managers_allow_list.py b/src/sonic-bgpcfgd/bgpcfgd/managers_allow_list.py index 1e4eb6e404e2..435be91d20d2 100644 --- a/src/sonic-bgpcfgd/bgpcfgd/managers_allow_list.py +++ b/src/sonic-bgpcfgd/bgpcfgd/managers_allow_list.py @@ -173,6 +173,7 @@ def __remove_policy(self, deployment_id, community_value): msg += " deployment_id '%s'. community: '%s'" log_info(msg % info) + default_action = self.__get_default_action_community() names = self.__generate_names(deployment_id, community_value) self.cfg_mgr.update() cmds = [] @@ -181,6 +182,8 @@ def __remove_policy(self, deployment_id, community_value): cmds += self.__remove_prefix_list(self.V4, names['pl_v4']) cmds += self.__remove_prefix_list(self.V6, names['pl_v6']) cmds += self.__remove_community(names['community']) + cmds += self.__update_default_route_map_entry(names['rm_v4'], default_action) + cmds += self.__update_default_route_map_entry(names['rm_v6'], default_action) if cmds: self.cfg_mgr.push_list(cmds) peer_groups = self.__find_peer_group_by_deployment_id(deployment_id) @@ -676,7 +679,7 @@ def __af_to_family(self, af): """ return 'ip' if af == self.V4 else 'ipv6' - def __get_default_action_community(self, data): + def __get_default_action_community(self, data=None): """ Determine the default action community based on the request. If request doesn't contain "default_action" field - the default_action value @@ -685,7 +688,7 @@ def __get_default_action_community(self, data): :return: returns community value for "default_action" """ drop_community = self.constants["bgp"]["allow_list"]["drop_community"] - if "default_action" in data: + if data and "default_action" in data: if data["default_action"] == "deny": return "no-export" else: # "permit" diff --git a/src/sonic-bgpcfgd/tests/test_allow_list.py b/src/sonic-bgpcfgd/tests/test_allow_list.py index 6a53e2f49ca7..cb0896982a39 100644 --- a/src/sonic-bgpcfgd/tests/test_allow_list.py +++ b/src/sonic-bgpcfgd/tests/test_allow_list.py @@ -4,6 +4,7 @@ from bgpcfgd.directory import Directory from bgpcfgd.template import TemplateFabric import bgpcfgd +from copy import deepcopy swsscommon_module_mock = MagicMock() @@ -26,7 +27,7 @@ } @patch.dict("sys.modules", swsscommon=swsscommon_module_mock) -def set_del_test(op, args, currect_config, expected_config): +def set_del_test(op, args, currect_config, expected_config, update_global_default_action=None): from bgpcfgd.managers_allow_list import BGPAllowListMgr set_del_test.push_list_called = False def push_list(args): @@ -44,10 +45,12 @@ def push_list(args): 'directory': Directory(), 'cfg_mgr': cfg_mgr, 'tf': TemplateFabric(), - 'constants': global_constants, + 'constants': deepcopy(global_constants), } mgr = BGPAllowListMgr(common_objs, "CONFIG_DB", "BGP_ALLOWED_PREFIXES") + if update_global_default_action: + mgr.constants["bgp"]["allow_list"]["default_action"] = update_global_default_action if op == "SET": mgr.set_handler(*args) elif op == "DEL": @@ -89,6 +92,74 @@ def test_set_handler_with_community(): ' match community COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', ] ) +def test_set_handler_with_community_and_permit_action(): + set_del_test( + "SET", + ("DEPLOYMENT_ID|5|1010:2020", { + "prefixes_v4": "10.20.30.0/24,30.50.0.0/16", + "prefixes_v6": "fc00:20::/64,fc00:30::/64", + "default_action":"permit" + }), + [ + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive' + ], + [ + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 10 deny 0.0.0.0/0 le 17', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 20 permit 10.20.30.0/24 le 32', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 30 permit 30.50.0.0/16 le 32', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 10 deny 0::/0 le 59', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 20 deny 0::/0 ge 65', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 30 permit fc00:20::/64 le 128', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 40 permit fc00:30::/64 le 128', + 'bgp community-list standard COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020 permit 1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 10', + ' match ip address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4', + ' match community COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 10', + ' match ipv6 address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6', + ' match community COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + ] + ) + +def test_set_handler_with_community_and_deny_action(): + set_del_test( + "SET", + ("DEPLOYMENT_ID|5|1010:2020", { + "prefixes_v4": "10.20.30.0/24,30.50.0.0/16", + "prefixes_v6": "fc00:20::/64,fc00:30::/64", + "default_action":"deny" + }), + [ + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive' + ], + [ + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 10 deny 0.0.0.0/0 le 17', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 20 permit 10.20.30.0/24 le 32', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 30 permit 30.50.0.0/16 le 32', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 10 deny 0::/0 le 59', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 20 deny 0::/0 ge 65', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 30 permit fc00:20::/64 le 128', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 40 permit fc00:30::/64 le 128', + 'bgp community-list standard COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020 permit 1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 10', + ' match ip address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4', + ' match community COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 10', + ' match ipv6 address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6', + ' match community COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community no-export additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community no-export additive' + ] + ) + def test_set_handler_no_community(): set_del_test( @@ -117,6 +188,66 @@ def test_set_handler_no_community(): ' match ipv6 address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6', ] ) +def test_set_handler_no_community_with_permit_action(): + set_del_test( + "SET", + ("DEPLOYMENT_ID|5", { + "prefixes_v4": "20.20.30.0/24,40.50.0.0/16", + "prefixes_v6": "fc01:20::/64,fc01:30::/64", + "default_action":"permit" + }), + [ + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive', + ], + [ + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4 seq 10 deny 0.0.0.0/0 le 17', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4 seq 20 permit 20.20.30.0/24 le 32', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4 seq 30 permit 40.50.0.0/16 le 32', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6 seq 10 deny 0::/0 le 59', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6 seq 20 deny 0::/0 ge 65', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6 seq 30 permit fc01:20::/64 le 128', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6 seq 40 permit fc01:30::/64 le 128', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 30000', + ' match ip address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 30000', + ' match ipv6 address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6', + ] + ) +def test_set_handler_no_community_with_deny_action(): + set_del_test( + "SET", + ("DEPLOYMENT_ID|5", { + "prefixes_v4": "20.20.30.0/24,40.50.0.0/16", + "prefixes_v6": "fc01:20::/64,fc01:30::/64", + "default_action":"deny" + }), + [ + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive', + ], + [ + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4 seq 10 deny 0.0.0.0/0 le 17', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4 seq 20 permit 20.20.30.0/24 le 32', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4 seq 30 permit 40.50.0.0/16 le 32', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6 seq 10 deny 0::/0 le 59', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6 seq 20 deny 0::/0 ge 65', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6 seq 30 permit fc01:20::/64 le 128', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6 seq 40 permit fc01:30::/64 le 128', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 30000', + ' match ip address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 30000', + ' match ipv6 address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community no-export additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community no-export additive' + ] + ) def test_del_handler_with_community(): set_del_test( @@ -137,6 +268,11 @@ def test_del_handler_with_community(): 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 10', ' match ipv6 address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6', ' match community COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive', + "" ], [ @@ -148,6 +284,155 @@ def test_del_handler_with_community(): ] ) +def test_del_handler_with_exiting_community_deny_action(): + set_del_test( + "DEL", + ("DEPLOYMENT_ID|5|1010:2020",), + [ + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 10 deny 0.0.0.0/0 le 17', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 20 permit 10.20.30.0/24 ge 25', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 30 permit 30.50.0.0/16 ge 17', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 10 deny 0::/0 le 59', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 20 deny 0::/0 ge 65', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 30 permit fc00:20::/64 ge 65', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 40 permit fc00:30::/64 ge 65', + 'bgp community-list standard COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020 permit 1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 10', + ' match ip address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4', + ' match community COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 10', + ' match ipv6 address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6', + ' match community COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community no-export additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community no-export additive', + "" + ], + [ + 'no route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 10', + 'no route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 10', + 'no ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4', + 'no ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6', + 'no bgp community-list standard COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive', + ] + ) + + +def test_del_handler_with_exiting_community_permit_action(): + set_del_test( + "DEL", + ("DEPLOYMENT_ID|5|1010:2020",), + [ + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 10 deny 0.0.0.0/0 le 17', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 20 permit 10.20.30.0/24 ge 25', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 30 permit 30.50.0.0/16 ge 17', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 10 deny 0::/0 le 59', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 20 deny 0::/0 ge 65', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 30 permit fc00:20::/64 ge 65', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 40 permit fc00:30::/64 ge 65', + 'bgp community-list standard COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020 permit 1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 10', + ' match ip address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4', + ' match community COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 10', + ' match ipv6 address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6', + ' match community COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive', + "" + ], + [ + 'no route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 10', + 'no route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 10', + 'no ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4', + 'no ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6', + 'no bgp community-list standard COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + ] + ) + +def test_del_handler_with_exiting_community_deny_action_global_deny(): + set_del_test( + "DEL", + ("DEPLOYMENT_ID|5|1010:2020",), + [ + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 10 deny 0.0.0.0/0 le 17', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 20 permit 10.20.30.0/24 ge 25', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 30 permit 30.50.0.0/16 ge 17', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 10 deny 0::/0 le 59', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 20 deny 0::/0 ge 65', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 30 permit fc00:20::/64 ge 65', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 40 permit fc00:30::/64 ge 65', + 'bgp community-list standard COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020 permit 1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 10', + ' match ip address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4', + ' match community COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 10', + ' match ipv6 address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6', + ' match community COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community no-export additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community no-export additive', + "" + ], + [ + 'no route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 10', + 'no route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 10', + 'no ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4', + 'no ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6', + 'no bgp community-list standard COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + ], + "deny" + ) + + +def test_del_handler_with_exiting_community_permit_action_global_deny(): + set_del_test( + "DEL", + ("DEPLOYMENT_ID|5|1010:2020",), + [ + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 10 deny 0.0.0.0/0 le 17', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 20 permit 10.20.30.0/24 ge 25', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4 seq 30 permit 30.50.0.0/16 ge 17', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 10 deny 0::/0 le 59', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 20 deny 0::/0 ge 65', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 30 permit fc00:20::/64 ge 65', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6 seq 40 permit fc00:30::/64 ge 65', + 'bgp community-list standard COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020 permit 1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 10', + ' match ip address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4', + ' match community COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 10', + ' match ipv6 address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6', + ' match community COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive', + "" + ], + [ + 'no route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 10', + 'no route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 10', + 'no ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V4', + 'no ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020_V6', + 'no bgp community-list standard COMMUNITY_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_1010:2020', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community no-export additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community no-export additive', + ], + "deny" + ) + + def test_del_handler_no_community(): set_del_test( "DEL", @@ -164,6 +449,10 @@ def test_del_handler_no_community(): ' match ip address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4', 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 30000', ' match ipv6 address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive', " " ], [ @@ -173,6 +462,75 @@ def test_del_handler_no_community(): 'no ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6', ] ) +def test_del_handler_with_no_community_deny_action(): + set_del_test( + "DEL", + ("DEPLOYMENT_ID|5",), + [ + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4 seq 10 deny 0.0.0.0/0 le 17', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4 seq 20 permit 20.20.30.0/24 ge 25', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4 seq 30 permit 40.50.0.0/16 ge 17', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6 seq 10 deny 0::/0 le 59', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6 seq 20 deny 0::/0 ge 65', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6 seq 30 permit fc01:20::/64 ge 65', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6 seq 40 permit fc01:30::/64 ge 65', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 30000', + ' match ip address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 30000', + ' match ipv6 address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community no-export additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community no-export additive', + "" + ], + [ + 'no route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 30000', + 'no route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 30000', + 'no ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4', + 'no ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive', + ] + ) +def test_del_handler_with_no_community_permit_action_global_deny(): + set_del_test( + "DEL", + ("DEPLOYMENT_ID|5",), + [ + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4 seq 10 deny 0.0.0.0/0 le 17', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4 seq 20 permit 20.20.30.0/24 ge 25', + 'ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4 seq 30 permit 40.50.0.0/16 ge 17', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6 seq 10 deny 0::/0 le 59', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6 seq 20 deny 0::/0 ge 65', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6 seq 30 permit fc01:20::/64 ge 65', + 'ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6 seq 40 permit fc01:30::/64 ge 65', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 30000', + ' match ip address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 30000', + ' match ipv6 address prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive', + "" + ], + [ + 'no route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 30000', + 'no route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 30000', + 'no ip prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V4', + 'no ipv6 prefix-list PL_ALLOW_LIST_DEPLOYMENT_ID_5_COMMUNITY_empty_V6', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community no-export additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community no-export additive', + ], + "deny" + ) + + def test_set_handler_with_community_data_is_already_presented(): set_del_test( @@ -245,7 +603,12 @@ def test_del_handler_with_community_no_data(): set_del_test( "DEL", ("DEPLOYMENT_ID|5|1010:2020",), - [""], + [ + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive' + ], [] ) @@ -253,7 +616,12 @@ def test_del_handler_no_community_no_data(): set_del_test( "DEL", ("DEPLOYMENT_ID|5",), - [""], + [ + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V4 permit 65535', + ' set community 123:123 additive', + 'route-map ALLOW_LIST_DEPLOYMENT_ID_5_V6 permit 65535', + ' set community 123:123 additive' + ], [] ) @@ -588,4 +956,4 @@ def test___get_default_action_permit_3(): mgr = construct_BGPAllowListMgr(constants) assert mgr._BGPAllowListMgr__get_default_action_community(data) == "123:123" -# FIXME: more testcases for coverage \ No newline at end of file +# FIXME: more testcases for coverage From 3a7441c913cc6f534211892a3b232fa5124dee82 Mon Sep 17 00:00:00 2001 From: xumia <59720581+xumia@users.noreply.github.com> Date: Fri, 5 Feb 2021 01:03:14 +0800 Subject: [PATCH 0136/1674] [build]: Fix syncd dpkg cache dependency issue (#6680) * Fix syncd dpkg cache dependency issue --- platform/broadcom/docker-syncd-brcm.dep | 2 +- platform/mellanox/docker-syncd-mlnx.dep | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/broadcom/docker-syncd-brcm.dep b/platform/broadcom/docker-syncd-brcm.dep index 48fa57f33479..c020a72f2a08 100644 --- a/platform/broadcom/docker-syncd-brcm.dep +++ b/platform/broadcom/docker-syncd-brcm.dep @@ -1,6 +1,6 @@ #DPKG FRK DPATH := $($(DOCKER_SYNCD_BASE)_PATH) -DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/docker-syncd-brcm.mk platform/broadcom/docker-syncd-brcm.dep +DEP_FILES := $(SONIC_COMMON_FILES_LIST) platform/broadcom/docker-syncd-brcm.mk platform/broadcom/docker-syncd-brcm.dep platform/broadcom/sai.mk DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) DEP_FILES += $(shell git ls-files $(DPATH)) diff --git a/platform/mellanox/docker-syncd-mlnx.dep b/platform/mellanox/docker-syncd-mlnx.dep index b8bdfdf625b7..659b09cec8f4 100644 --- a/platform/mellanox/docker-syncd-mlnx.dep +++ b/platform/mellanox/docker-syncd-mlnx.dep @@ -1,7 +1,7 @@ # DPKG FRK DPATH := $($(DOCKER_SYNCD_BASE)_PATH) -DEP_FILES := $(SONIC_COMMON_FILES_LIST) $(PLATFORM_PATH)/docker-syncd-mlnx.mk $(PLATFORM_PATH)/docker-syncd-mlnx.dep +DEP_FILES := $(SONIC_COMMON_FILES_LIST) $(PLATFORM_PATH)/docker-syncd-mlnx.mk $(PLATFORM_PATH)/docker-syncd-mlnx.dep platform/mellanox/mlnx-sai.mk DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) DEP_FILES += $(shell git ls-files -- $(DPATH)) From 0244069666ba072742fdd58b9e1a87e8e4414802 Mon Sep 17 00:00:00 2001 From: Lior Avramov <73036155+liorghub@users.noreply.github.com> Date: Thu, 4 Feb 2021 19:44:16 +0200 Subject: [PATCH 0137/1674] [Mellanox] Update FW upgrade script to use 'mlxfwmanager -d' option for specifying MST device in FW burn operation (#6541) **- Why I did it** Reduce the time it takes for the ASIC FW burn as part of the automatic FW upgrade procedure. **- How I did it** Add -d option to mlxfwmanager tool to use the faster MST device and not the default one which is not the fastest one. **- How to verify it** I manually changed ASIC FW followed by reboot command in order for FW upgrade to take place on deinit. I manually changed ASIC FW followed by hard reset in order for FW upgrade to take place on init. Signed-off-by: liora --- platform/mellanox/mlnx-fw-upgrade.j2 | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/platform/mellanox/mlnx-fw-upgrade.j2 b/platform/mellanox/mlnx-fw-upgrade.j2 index 69f3d621cc44..245ce75d5f18 100755 --- a/platform/mellanox/mlnx-fw-upgrade.j2 +++ b/platform/mellanox/mlnx-fw-upgrade.j2 @@ -29,6 +29,7 @@ declare -r SPC1_ASIC="spc1" declare -r SPC2_ASIC="spc2" declare -r SPC3_ASIC="spc3" declare -r UNKN_ASIC="unknown" +declare -r UNKN_MST="unknown" declare -rA FW_FILE_MAP=( \ [$SPC1_ASIC]="/etc/mlnx/fw-SPC.mfa" \ @@ -152,6 +153,18 @@ function GetAsicType() { exit "${EXIT_FAILURE}" } +function GetMstDevice() { + local _MST_DEVICE="$(ls /dev/mst/*_pci_cr0 2>&1)" + + if [[ ! -c "${_MST_DEVICE}" ]]; then + echo "${UNKN_MST}" + else + echo "${_MST_DEVICE}" + fi + + exit "${EXIT_SUCCESS}" +} + function RunCmd() { local ERROR_CODE="${EXIT_SUCCESS}" @@ -207,7 +220,13 @@ function UpgradeFW() { ExitSuccess "firmware is up to date" else LogNotice "firmware upgrade is required. Installing compatible version..." - RunCmd "${BURN_CMD} -i ${_FW_FILE}" + local -r _MST_DEVICE="$(GetMstDevice)" + if [[ "${_MST_DEVICE}" = "${UNKN_MST}" ]]; then + LogWarning "could not find fastest mst device, using default device" + RunCmd "${BURN_CMD} -i ${_FW_FILE}" + else + RunCmd "${BURN_CMD} -d ${_MST_DEVICE} -i ${_FW_FILE}" + fi fi } From 6bc07c6c11be6d5a16c31365b0f48c82e31cd074 Mon Sep 17 00:00:00 2001 From: dereksun01 <52683998+dereksun01@users.noreply.github.com> Date: Fri, 5 Feb 2021 02:51:12 +0800 Subject: [PATCH 0138/1674] [device] Add as4630_54pe SDK configuration parameters (#5167) **- Why I did it** - Add as4630_54pe SDK configuration parameters. **- How I did it** - Add l3_alpm_enable=2 and ipv6_lpm_128b_enable=1 in hx5-as4630-48x1G+4x25G+2x100G.bcm. Co-authored-by: derek_sun Co-authored-by: derek_sun --- .../hx5-as4630-48x1G+4x25G+2x100G.bcm | 3 +++ .../x86_64-accton_as4630_54pe-r0/custom_led.bin | Bin 952 -> 856 bytes 2 files changed, 3 insertions(+) diff --git a/device/accton/x86_64-accton_as4630_54pe-r0/Accton-AS4630-54PE/hx5-as4630-48x1G+4x25G+2x100G.bcm b/device/accton/x86_64-accton_as4630_54pe-r0/Accton-AS4630-54PE/hx5-as4630-48x1G+4x25G+2x100G.bcm index a7f89ba4c62d..331f6d002647 100755 --- a/device/accton/x86_64-accton_as4630_54pe-r0/Accton-AS4630-54PE/hx5-as4630-48x1G+4x25G+2x100G.bcm +++ b/device/accton/x86_64-accton_as4630_54pe-r0/Accton-AS4630-54PE/hx5-as4630-48x1G+4x25G+2x100G.bcm @@ -19,7 +19,10 @@ l2_mem_entries=32768 #l3_mem_entries=49152 #fpem_mem_entries=16384 l2xmsg_mode=1 +l3_alpm_enable=2 +ipv6_lpm_128b_enable=1 port_flex_enable=1 +ifp_inports_support_enable=1 #3x PM4x10Q (3 * 16 = 48 physical ports) #Doesn't support oversubscribe in Q mode diff --git a/device/accton/x86_64-accton_as4630_54pe-r0/custom_led.bin b/device/accton/x86_64-accton_as4630_54pe-r0/custom_led.bin index b402867a7d204e5575047e5a148a3d4f471d3a71..0f6e37a82492be625674928a121f6394b7e9f964 100644 GIT binary patch literal 856 zcmYk(JxmjE7zXh7-z!k02+CI}QrjL?OZ@;Ui9po5D}Ax4A%GzQSBO_MITr)CFcQ!R zCL|)!0L4TT7bG!6!{kRG42I}%opdtYx@f|z4n9;-hTn6`-E;rvZfE@~U*%4Ya%O#M zjby6Z@b^&E{MKU+&uc%@lksIHKgpu5DzL&8=Zh8bXo3x z5C3{v_Vs*p>6CJphkdlD6j3)y{3oh|pcdR-pr}s%SPiwr@A3$FsZ3rQC9|Ze{;$uk=p1r?|iU|9-Ltvv%xFW)-f#OgjsCEA?-G{_ws5)3fBmC45@X}*fcIS zilnVkO-?4al3T-D*QK?cw{Q3rukcgedDqoS^n8uz9Ig=}(m;iFh(Q#pzy%dh31v_Y zhu|=jKq(Z%K_~(z6v6>000-njK1g5(0X7K1NeDtcoPh>71*buVI`DxXj>8EEz%e)q zUZ@2R)W8v_1~*KZx=XaxjO&j4P@yHfg`qr4YU}e%sePIxyOfa*^8U*1-8JAS3l)43 U-UrGD*ylh literal 952 zcma*lPe_w-7zgm@xA%3M&T9F0bN+d^cW(aw!xTvaU*B!NYEG#YqARFPgBR-HAxf}= zAs9u6a1hK543h-CNam@6or3bR(Iq-f6zaI6bg}Q&kU9h%KF{+UzQ2d(9n0TFt^Q_@aeZquCF{P+&P;ajJ}u$v6ZJ1)2v{S_I(`79qv-(Cfv1vDrQrttWdX%2~v4TTMdc*lrVcJ*3(JpiSJ!wN2-nk|2k9rOMJ?s`p;yQ(D7GHjeC$ zT2@Hz9tm=wn6r3^iQajm;`x0+GNcOF)>_>)s?NMEC zB)S$oh#pKI%m~}(-#_PZzQ(tB?!)ClqV;W}++KiGdE4Z5KRI-v_>aDp8i;D#1x1{XAe1P#y#HmCSFCtRjr~m)} From 57a6fb9f3955306d135c6ea10cc72b54eab8be47 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 4 Feb 2021 12:14:08 -0800 Subject: [PATCH 0139/1674] [pcie-check] Update underlying pcieutil command and add to sudoers file (#6682) - Why I did it As of Azure/sonic-utilities#1297, subcommands of pcieutil have changed to remove the redundant pcie- prefix. This PR adapts calling applications (pcie-check) to the new syntax. Resolves #6676 - How I did it Remove pcie- prefix from pcieutil subcommands in calling applications Also add pcieutil * to sudoers file, as pcieutil requires elevated permissions --- files/image_config/pcie-check/pcie-check.sh | 4 ++-- files/image_config/sudoers/sudoers | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/files/image_config/pcie-check/pcie-check.sh b/files/image_config/pcie-check/pcie-check.sh index 4ef2ce3047f0..4257a2544c4a 100755 --- a/files/image_config/pcie-check/pcie-check.sh +++ b/files/image_config/pcie-check/pcie-check.sh @@ -16,11 +16,11 @@ function debug() function check_and_rescan_pcie_devices() { - PCIE_CHK_CMD='sudo pcieutil pcie-check |grep "$RESULTS"' + PCIE_CHK_CMD='sudo pcieutil check | grep "$RESULTS"' PLATFORM=$(sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) if [ ! -f /usr/share/sonic/device/$PLATFORM/plugins/pcie.yaml ]; then - debug "pcie.yaml does not exist! can't check pcie status!" + debug "pcie.yaml does not exist! Can't check PCIe status!" exit fi diff --git a/files/image_config/sudoers/sudoers b/files/image_config/sudoers/sudoers index aa03eda13719..8ec8799c7cca 100644 --- a/files/image_config/sudoers/sudoers +++ b/files/image_config/sudoers/sudoers @@ -34,6 +34,7 @@ Cmnd_Alias READ_ONLY_CMDS = /bin/cat /var/log/syslog*, \ /usr/local/bin/decode-syseeprom, \ /usr/local/bin/generate_dump, \ /usr/local/bin/lldpshow, \ + /usr/local/bin/pcieutil *, \ /usr/local/bin/psuutil *, \ /usr/local/bin/sonic-installer list, \ /usr/local/bin/sfputil show *, \ From 276fade8c213d16790de0e1d5c4adb641772931f Mon Sep 17 00:00:00 2001 From: Aravind Mani <53524901+aravindmani-1@users.noreply.github.com> Date: Fri, 5 Feb 2021 07:28:03 +0530 Subject: [PATCH 0140/1674] Dell S6000: Fix reboot failure issue (#6656) Reboot command in Dell S6000 failed to reboot the switch. Added retry mechanism and CPU reset. --- .../platform_reboot | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/device/dell/x86_64-dell_s6000_s1220-r0/platform_reboot b/device/dell/x86_64-dell_s6000_s1220-r0/platform_reboot index d973f4f810e1..28f2ec626605 100755 --- a/device/dell/x86_64-dell_s6000_s1220-r0/platform_reboot +++ b/device/dell/x86_64-dell_s6000_s1220-r0/platform_reboot @@ -4,10 +4,11 @@ import sys import os import struct +PORT_RES = '/dev/port' NVRAM_RES = '/dev/nvram' COLD_RESET = 0xE # Cold Reset WARM_RESET = 0x6 # Warm Reset - +RESET_REG = 0xCF9 def io_reg_write(resource, offset, val): fd = os.open(resource, os.O_RDWR) @@ -23,39 +24,40 @@ def io_reg_write(resource, offset, val): return os.close(fd) - def power_reset(val): with open('/sys/devices/platform/dell-s6000-cpld.0/power_reset', 'w') as p: p.write(str(int(val)) + '\n') p.flush() - def gpio_direction(pin, direction): kernpath = '/sys/class/gpio/gpio'+str(pin)+'/direction' with open(('kernpath'), 'w') as p: p.write(str(direction) + '\n') p.flush() - def gpio_set(pin, value): kernpath = '/sys/class/gpio/gpio'+str(pin)+'/value' with open(('kernpath'), 'w') as p: p.write(str(int(value)) + '\n') p.flush() - def gpio_export(value): with open('/sys/class/gpio/export', 'w') as p: p.write(str(int(value)) + '\n') p.flush() - if __name__ == "__main__": + + retry_count = 0 io_reg_write(NVRAM_RES, 0x49, COLD_RESET) - if not os.path.isdir("/sys/class/gpio/gpio10"): - gpio_export(10) - gpio_direction("10", "out") - # Toggle GPIO10 pin (to reset MUX) - gpio_set("10", 1) - gpio_set("10", 0) - power_reset(1) + + while retry_count < 3: + if not os.path.isdir("/sys/class/gpio/gpio10"): + gpio_export(10) + gpio_direction("10", "out") + # Toggle GPIO10 pin (to reset MUX) + gpio_set("10", 1) + gpio_set("10", 0) + power_reset(1) + retry_count += 1 + io_reg_write(PORT_RES, RESET_REG, COLD_RESET) From 0bae3b44ec33f1b325829e29ded5dd8d28d20482 Mon Sep 17 00:00:00 2001 From: Arun Saravanan Balachandran <52521751+ArunSaravananBalachandran@users.noreply.github.com> Date: Fri, 5 Feb 2021 20:30:08 +0000 Subject: [PATCH 0141/1674] DellEMC: S6100, S6000 - Enable thermalctld, Platform API implementation and fixes (#6438) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **- Why I did it** To incorporate the below changes in DellEMC S6100, S6000 platforms. - S6100, S6000: - Enable 'thermalctld' - Implement DeviceBase methods (presence, status, model, serial) for Fantray and Component - Implement ‘get_position_in_parent’, ‘is_replaceable’ methods for all device types - Implement ‘get_status’ method for Fantray - Implement ‘get_temperature’, ‘get_temperature_high_threshold’, ‘get_voltage_high_threshold’, ‘get_voltage_low_threshold’ methods for PSU - Implement ‘get_status_led’, ‘set_status_led’ methods for Chassis - SFP: - Make EEPROM read both Python2 and Python3 compatible - Fix ‘get_tx_disable_channel’ method’s return type - Implement ‘tx_disable’, ‘tx_disable_channel’ and ‘set_power_override’ methods - S6000: - Move PSU thermal sensors from Chassis to respective PSU - Make available the data of both Fans present in each Fantray **- How I did it** - Remove 'skip_thermalctld:true' in pmon_daemon_control.json - Implement the platform API methods in the respective device files - Use `bytearray` for data read from transceiver EEPROM - Change return type of 'get_tx_disable_channel' to match specification in sonic_platform_common/sfp_base.py --- .../pmon_daemon_control.json | 3 +- .../pmon_daemon_control.json | 3 +- .../common/dell_pmc.c | 46 +++++ .../s6000/sonic_platform/chassis.py | 77 ++++++++- .../s6000/sonic_platform/component.py | 53 +++++- .../s6000/sonic_platform/eeprom.py | 14 +- .../s6000/sonic_platform/fan.py | 152 ++++++---------- .../s6000/sonic_platform/fan_drawer.py | 162 +++++++++++++++++- .../s6000/sonic_platform/psu.py | 72 +++++++- .../s6000/sonic_platform/sfp.py | 120 +++++++++---- .../s6000/sonic_platform/thermal.py | 39 ++++- .../s6100/sonic_platform/chassis.py | 81 +++++++++ .../s6100/sonic_platform/component.py | 58 ++++++- .../s6100/sonic_platform/fan.py | 104 +++++------ .../s6100/sonic_platform/fan_drawer.py | 137 ++++++++++++++- .../s6100/sonic_platform/module.py | 19 +- .../s6100/sonic_platform/psu.py | 88 +++++++++- .../s6100/sonic_platform/sfp.py | 119 +++++++++---- .../s6100/sonic_platform/thermal.py | 17 ++ 19 files changed, 1084 insertions(+), 280 deletions(-) diff --git a/device/dell/x86_64-dell_s6000_s1220-r0/pmon_daemon_control.json b/device/dell/x86_64-dell_s6000_s1220-r0/pmon_daemon_control.json index 44871c057e82..94592fa8cebc 100644 --- a/device/dell/x86_64-dell_s6000_s1220-r0/pmon_daemon_control.json +++ b/device/dell/x86_64-dell_s6000_s1220-r0/pmon_daemon_control.json @@ -1,4 +1,3 @@ { - "skip_ledd": true, - "skip_thermalctld": true + "skip_ledd": true } diff --git a/device/dell/x86_64-dell_s6100_c2538-r0/pmon_daemon_control.json b/device/dell/x86_64-dell_s6100_c2538-r0/pmon_daemon_control.json index 44871c057e82..94592fa8cebc 100644 --- a/device/dell/x86_64-dell_s6100_c2538-r0/pmon_daemon_control.json +++ b/device/dell/x86_64-dell_s6100_c2538-r0/pmon_daemon_control.json @@ -1,4 +1,3 @@ { - "skip_ledd": true, - "skip_thermalctld": true + "skip_ledd": true } diff --git a/platform/broadcom/sonic-platform-modules-dell/common/dell_pmc.c b/platform/broadcom/sonic-platform-modules-dell/common/dell_pmc.c index 3193e8b4642f..5712c0fbb552 100644 --- a/platform/broadcom/sonic-platform-modules-dell/common/dell_pmc.c +++ b/platform/broadcom/sonic-platform-modules-dell/common/dell_pmc.c @@ -174,6 +174,9 @@ /* Mailbox PowerOn Reason */ #define TRACK_POWERON_REASON 0x05FF +/* System Status LED */ +#define SYSTEM_STATUS_LED 0x04DF + /* CPU Set IO Modules */ #define CPU_IOM1_CTRL_FLAG 0x04D9 #define CPU_IOM2_CTRL_FLAG 0x04DA @@ -607,6 +610,44 @@ static ssize_t show_mb_poweron_reason(struct device *dev, return sprintf(buf, "0x%x\n", ret); } +/* System Status LED */ +static ssize_t set_sys_status_led(struct device *dev, + struct device_attribute *devattr, const char *buf, size_t count) +{ + int err = 0; + unsigned int dev_data = 0; + struct smf_data *data = dev_get_drvdata(dev); + + if (data->kind == z9100smf) + return -1; + + err = kstrtouint(buf, 16, &dev_data); + if (err) + return err; + + err = smf_write_reg(data, SYSTEM_STATUS_LED, dev_data); + if(err < 0) + return err; + + return count; +} + +static ssize_t show_sys_status_led(struct device *dev, + struct device_attribute *devattr, char *buf) +{ + unsigned int ret = 0; + struct smf_data *data = dev_get_drvdata(dev); + + if (data->kind == z9100smf) + return 0; + + ret = smf_read_reg(data, SYSTEM_STATUS_LED); + if(ret < 0) + return ret; + + return sprintf(buf, "0x%x\n", ret); +} + /* FANIN ATTR */ static ssize_t show_fan_label(struct device *dev, struct device_attribute *attr, char *buf) @@ -2081,12 +2122,17 @@ static SENSOR_DEVICE_ATTR(smf_poweron_reason, S_IRUGO, static SENSOR_DEVICE_ATTR(mb_poweron_reason, S_IRUGO|S_IWUSR, show_mb_poweron_reason, set_mb_poweron_reason, 0); +/* System Status LED */ +static SENSOR_DEVICE_ATTR(sys_status_led, S_IRUGO|S_IWUSR, + show_sys_status_led, set_sys_status_led, 0); + static struct attribute *smf_dell_attrs[] = { &sensor_dev_attr_smf_version.dev_attr.attr, &sensor_dev_attr_smf_firmware_ver.dev_attr.attr, &sensor_dev_attr_smf_reset_reason.dev_attr.attr, &sensor_dev_attr_smf_poweron_reason.dev_attr.attr, &sensor_dev_attr_mb_poweron_reason.dev_attr.attr, + &sensor_dev_attr_sys_status_led.dev_attr.attr, &sensor_dev_attr_fan_tray_presence.dev_attr.attr, &sensor_dev_attr_fan1_airflow.dev_attr.attr, &sensor_dev_attr_fan3_airflow.dev_attr.attr, 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 899754709bcc..7f6e9ec573f4 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 @@ -24,7 +24,7 @@ MAX_S6000_FANTRAY = 3 MAX_S6000_PSU = 2 -MAX_S6000_THERMAL = 10 +MAX_S6000_THERMAL = 6 MAX_S6000_COMPONENT = 4 @@ -44,6 +44,8 @@ class Chassis(ChassisBase): def __init__(self): ChassisBase.__init__(self) + self.status_led_reg = "system_led" + self.supported_led_color = ['green', 'blinking green', 'amber', 'blinking amber'] # Initialize SFP list self.PORT_START = 0 self.PORT_END = 31 @@ -101,13 +103,30 @@ def _get_cpld_register(self, reg_name): try: with open(mb_reg_file, 'r') as fd: rv = fd.read() - except Exception as error: + except IOError: rv = 'ERR' rv = rv.rstrip('\r\n') rv = rv.lstrip(" ") return rv + def _set_cpld_register(self, reg_name, value): + # On successful write, returns the value will be written on + # reg_name and on failure returns 'ERR' + rv = 'ERR' + cpld_reg_file = self.CPLD_DIR+'/'+reg_name + + if (not os.path.isfile(cpld_reg_file)): + return rv + + try: + with open(cpld_reg_file, 'w') as fd: + rv = fd.write(str(value)) + except IOError: + rv = 'ERR' + + return rv + def _nvram_write(self, offset, val): resource = "/dev/nvram" fd = os.open(resource, os.O_RDWR) @@ -179,6 +198,23 @@ 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 -1 + + def is_replaceable(self): + """ + Indicate whether Chassis is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + def get_base_mac(self): """ Retrieves the base MAC address for the chassis @@ -305,4 +341,41 @@ def get_change_event(self, timeout=0): return True, ret_dict return False, ret_dict + 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 + """ + if color not in self.supported_led_color: + return False + + # Change color string format to the one used by driver + color = color.replace('amber', 'yellow') + color = color.replace('blinking ', 'blink_') + rv = self._set_cpld_register(self.status_led_reg, color) + if (rv != 'ERR'): + return True + else: + return False + + 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. + """ + status_led = self._get_cpld_register(self.status_led_reg) + if (status_led != 'ERR'): + status_led = status_led.replace('yellow', 'amber') + status_led = status_led.replace('blink_', 'blinking ') + return status_led + else: + return None diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/component.py index 1e21c233f5d8..d9459be47c4f 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/component.py @@ -29,8 +29,8 @@ class Component(ComponentBase): "booting")], ["System-CPLD", "Used for managing CPU board devices and power"], ["Master-CPLD", ("Used for managing Fan, PSU, system LEDs, QSFP " - "modules (1-16)")], - ["Slave-CPLD", "Used for managing QSFP modules (17-32)"] + "modules (17-32)")], + ["Slave-CPLD", "Used for managing QSFP modules (1-16)"] ] def __init__(self, component_index): @@ -90,6 +90,55 @@ def get_name(self): """ return self.name + def get_model(self): + """ + Retrieves the part number of the component + Returns: + string: Part number of component + """ + return 'NA' + + def get_serial(self): + """ + Retrieves the serial number of the component + Returns: + string: Serial number of component + """ + return 'NA' + + def get_presence(self): + """ + Retrieves the presence of the component + Returns: + bool: True if present, False if not + """ + return True + + def get_status(self): + """ + Retrieves the operational status of the component + Returns: + bool: True if component is operating properly, False if not + """ + 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 -1 + + def is_replaceable(self): + """ + Indicate whether component is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + def get_description(self): """ Retrieves the description of the component 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 ef736089c44b..5afe0112441b 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 @@ -36,8 +36,8 @@ ('Fab Rev', 's', 2) ] -# Fan eeprom fields in format required by EepromDecoder -fan_eeprom_format = [ +# FanTray eeprom fields in format required by EepromDecoder +fantray_eeprom_format = [ ('PPID', 's', 20), ('DPN Rev', 's', 3), ('Service Tag', 's', 7), ('Part Number', 's', 10), ('Part Num Revision', 's', 3), ('Mfg Test', 's', 2), ('Redundant copy', 's', 83), @@ -51,10 +51,10 @@ class Eeprom(TlvInfoDecoder): I2C_DIR = "/sys/class/i2c-adapter/" - def __init__(self, is_psu=False, psu_index=0, is_fan=False, fan_index=0): + def __init__(self, is_psu=False, psu_index=0, is_fantray=False, fantray_index=0): self.is_psu_eeprom = is_psu - self.is_fan_eeprom = is_fan - self.is_sys_eeprom = not (is_psu | is_fan) + self.is_fantray_eeprom = is_fantray + self.is_sys_eeprom = not (is_psu | is_fantray) if self.is_sys_eeprom: self.start_offset = 0 @@ -71,10 +71,10 @@ def __init__(self, is_psu=False, psu_index=0, is_fan=False, fan_index=0): + "i2c-1/1-005{}/eeprom".format(2 - self.index) self.format = psu_eeprom_format else: - self.index = fan_index + self.index = fantray_index self.eeprom_path = self.I2C_DIR \ + "i2c-11/11-005{}/eeprom".format(4 - self.index) - self.format = fan_eeprom_format + self.format = fantray_eeprom_format EepromDecoder.__init__(self, self.eeprom_path, self.format, self.start_offset, '', True) self._load_device_eeprom() diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/fan.py index fbdbf650db73..d5a4f379e90b 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/fan.py @@ -13,7 +13,6 @@ import os import glob from sonic_platform_base.fan_base import FanBase - from sonic_platform.eeprom import Eeprom except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -25,33 +24,37 @@ class Fan(FanBase): """DellEMC Platform-specific Fan class""" - CPLD_DIR = "/sys/devices/platform/dell-s6000-cpld.0/" I2C_DIR = "/sys/class/i2c-adapter/" - - def __init__(self, fan_index, psu_fan=False, dependency=None): + FAN_DEV_MAPPING = { + 1: {1: ("i2c-11/11-002a", 1), 2: ("i2c-11/11-002a", 2)}, + 2: {1: ("i2c-11/11-0029", 3), 2: ("i2c-11/11-0029", 4)}, + 3: {1: ("i2c-11/11-0029", 1), 2: ("i2c-11/11-0029", 2)} + } + + def __init__(self, fantray_index=1, fan_index=1, + psu_index=1, psu_fan=False, dependency=None): self.is_psu_fan = psu_fan self.is_driver_initialized = True if not self.is_psu_fan: # Fan is 1-based in DellEMC platforms - self.index = fan_index + 1 - self.fan_presence_reg = "fan_prs" - self.fan_led_reg = "fan{}_led".format(fan_index) - self.get_fan_speed_reg = self.I2C_DIR + "i2c-11/11-0029/" +\ - "fan{}_input".format(self.index) - self.set_fan_speed_reg = self.I2C_DIR + "i2c-11/11-0029/" +\ - "fan{}_target".format(self.index) - self.eeprom = Eeprom(is_fan=True, fan_index=self.index) + self.fantray_index = fantray_index + self.index = fan_index + self.dependency = dependency + self.get_fan_speed_reg = self.I2C_DIR +\ + "{}/fan{}_input".format(*self.FAN_DEV_MAPPING[fantray_index][fan_index]) + self.set_fan_speed_reg = self.I2C_DIR +\ + "{}/fan{}_target".format(*self.FAN_DEV_MAPPING[fantray_index][fan_index]) self.max_fan_speed = MAX_S6000_FAN_SPEED - self.supported_led_color = ['off', 'green', 'amber'] else: - self.index = fan_index + self.psu_index = psu_index + self.index = 1 self.dependency = dependency self.set_fan_speed_reg = self.I2C_DIR +\ - "i2c-1/1-005{}/fan1_target".format(10 - self.index) + "i2c-1/1-005{}/fan1_target".format(10 - self.psu_index) hwmon_dir = self.I2C_DIR +\ - "i2c-1/1-005{}/hwmon/".format(10 - self.index) + "i2c-1/1-005{}/hwmon/".format(10 - self.psu_index) try: hwmon_node = os.listdir(hwmon_dir)[0] except OSError: @@ -61,43 +64,6 @@ def __init__(self, fan_index, psu_fan=False, dependency=None): self.get_fan_speed_reg = hwmon_dir + hwmon_node + '/fan1_input' self.max_fan_speed = MAX_S6000_PSU_FAN_SPEED - def _get_cpld_register(self, reg_name): - # On successful read, returns the value read from given - # reg_name and on failure returns 'ERR' - rv = 'ERR' - cpld_reg_file = self.CPLD_DIR + reg_name - - if (not os.path.isfile(cpld_reg_file)): - return rv - - try: - with open(cpld_reg_file, 'r') as fd: - rv = fd.read() - except: - rv = 'ERR' - - rv = rv.rstrip('\r\n') - rv = rv.lstrip(" ") - return rv - - def _set_cpld_register(self, reg_name, value): - # On successful write, returns the value will be written on - # reg_name and on failure returns 'ERR' - rv = 'ERR' - cpld_reg_file = self.CPLD_DIR + reg_name - - if (not os.path.isfile(cpld_reg_file)): - print("open error") - return rv - - try: - with open(cpld_reg_file, 'w') as fd: - rv = fd.write(str(value)) - except: - rv = 'ERR' - - return rv - def _get_i2c_register(self, reg_file): # On successful read, returns the value read from given # reg_name and on failure returns 'ERR' @@ -155,9 +121,9 @@ def get_name(self): string: The name of the Fan """ if not self.is_psu_fan: - return "FanTray{}-Fan1".format(self.index) + return "FanTray{}-Fan{}".format(self.fantray_index, self.index) else: - return "PSU{} Fan".format(self.index) + return "PSU{} Fan".format(self.psu_index) def get_presence(self): """ @@ -166,42 +132,23 @@ def get_presence(self): Returns: bool: True if Fan is present, False if not """ - status = False - if self.is_psu_fan: - return self.dependency.get_presence() - - fan_presence = self._get_cpld_register(self.fan_presence_reg) - if (fan_presence != 'ERR'): - fan_presence = int(fan_presence,16) & self.index - if fan_presence: - status = True - - return status + return self.dependency.get_presence() def get_model(self): """ Retrieves the part number of the Fan - Returns: string: Part number of Fan """ - if not self.is_psu_fan: - return self.eeprom.get_part_number() - else: - return 'NA' + return 'NA' def get_serial(self): """ Retrieves the serial number of the Fan - Returns: string: Serial number of Fan """ - # Sample Serial number format "US-01234D-54321-25A-0123-A00" - if not self.is_psu_fan: - return self.eeprom.get_serial_number() - else: - return 'NA' + return 'NA' def get_status(self): """ @@ -218,6 +165,23 @@ def get_status(self): 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 Fan is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + def get_direction(self): """ Retrieves the fan airflow direction @@ -234,11 +198,10 @@ def get_direction(self): if self.is_psu_fan: direction = {1: self.FAN_DIRECTION_EXHAUST, 2: self.FAN_DIRECTION_INTAKE, 3: self.FAN_DIRECTION_EXHAUST, 4: self.FAN_DIRECTION_INTAKE} - fan_direction = self.dependency.eeprom.airflow_fan_type() else: direction = {1: self.FAN_DIRECTION_EXHAUST, 2: self.FAN_DIRECTION_INTAKE} - fan_direction = self.eeprom.airflow_fan_type() + fan_direction = self.dependency.eeprom.airflow_fan_type() return direction.get(fan_direction, self.FAN_DIRECTION_NOT_APPLICABLE) def get_speed(self): @@ -282,8 +245,8 @@ def set_speed(self, speed): Returns: bool: True if set success, False if fail. """ - fan_set = (speed * self.max_fan_speed)/ 100 - rv = self._set_i2c_register(self.set_fan_speed_reg , fan_set) + fan_set = (speed * self.max_fan_speed) // 100 + rv = self._set_i2c_register(self.set_fan_speed_reg, fan_set) if (rv != 'ERR'): return True else: @@ -298,16 +261,9 @@ def set_status_led(self, color): Returns: bool: True if set success, False if fail. """ - if self.is_psu_fan or (color not in self.supported_led_color): - return False - if(color == self.STATUS_LED_COLOR_AMBER): - color = 'yellow' - - rv = self._set_cpld_register(self.fan_led_reg ,color) - if (rv != 'ERR'): - return True - else: - return False + # No LED available for FanTray and PSU Fan + # Return True to avoid thermalctld alarm. + return True def get_status_led(self): """ @@ -316,18 +272,8 @@ def get_status_led(self): Returns: A string, one of the predefined STATUS_LED_COLOR_* strings. """ - if self.is_psu_fan: - # No LED available for PSU Fan - return None - - fan_led = self._get_cpld_register(self.fan_led_reg) - if (fan_led != 'ERR'): - if (fan_led == 'yellow'): - return self.STATUS_LED_COLOR_AMBER - else: - return fan_led - else: - return self.STATUS_LED_COLOR_OFF + # No LED available for FanTray and PSU Fan + return None def get_target_speed(self): """ 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 c8ea283e5ba4..2e5e3446cd80 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 @@ -9,26 +9,176 @@ ######################################################################## try: + import os + from sonic_platform_base.fan_drawer_base import FanDrawerBase + from sonic_platform.eeprom import Eeprom from sonic_platform.fan import Fan except ImportError as e: raise ImportError(str(e) + "- required module not found") +MAX_S6000_FANS_PER_FANTRAY = 2 + class FanDrawer(FanDrawerBase): - """DellEMC Platform-specific Fan class""" + """DellEMC Platform-specific Fan Drawer class""" - def __init__(self, fantray_index): + CPLD_DIR = "/sys/devices/platform/dell-s6000-cpld.0/" + def __init__(self, fantray_index): FanDrawerBase.__init__(self) # FanTray is 1-based in DellEMC platforms - self.fantrayindex = fantray_index + 1 - self._fan_list.append(Fan(fantray_index)) + self.index = fantray_index + 1 + self.eeprom = Eeprom(is_fantray=True, fantray_index=self.index) + self.fantray_presence_reg = "fan_prs" + self.fantray_led_reg = "fan{}_led".format(self.index - 1) + self.supported_led_color = ['off', 'green', 'amber'] + + for i in range(1, MAX_S6000_FANS_PER_FANTRAY+1): + self._fan_list.append(Fan(fantray_index=self.index, fan_index=i, dependency=self)) + + def _get_cpld_register(self, reg_name): + # On successful read, returns the value read from given + # reg_name and on failure returns 'ERR' + rv = 'ERR' + cpld_reg_file = self.CPLD_DIR + reg_name + + if (not os.path.isfile(cpld_reg_file)): + return rv + + try: + with open(cpld_reg_file, 'r') as fd: + rv = fd.read() + except IOError: + rv = 'ERR' + + rv = rv.rstrip('\r\n') + rv = rv.lstrip(" ") + return rv + + def _set_cpld_register(self, reg_name, value): + # On successful write, returns the value will be written on + # reg_name and on failure returns 'ERR' + rv = 'ERR' + cpld_reg_file = self.CPLD_DIR + reg_name + + if (not os.path.isfile(cpld_reg_file)): + return rv + + try: + with open(cpld_reg_file, 'w') as fd: + rv = fd.write(str(value)) + except IOError: + rv = 'ERR' + + return rv def get_name(self): """ - Retrieves the fan drawer name + Retrieves the Fandrawer name Returns: string: The name of the device """ - return "FanTray{}".format(self.fantrayindex) + return "FanTray{}".format(self.index) + + def get_presence(self): + """ + Retrieves the presence of the Fandrawer + + Returns: + bool: True if Fandrawer is present, False if not + """ + presence = False + + fantray_presence = self._get_cpld_register(self.fantray_presence_reg) + if (fantray_presence != 'ERR'): + fantray_presence = int(fantray_presence, 16) & (1 << (self.index - 1)) + if fantray_presence: + presence = True + + return presence + + def get_model(self): + """ + Retrieves the part number of the Fandrawer + + Returns: + string: Part number of Fandrawer + """ + return self.eeprom.get_part_number() + + def get_serial(self): + """ + Retrieves the serial number of the Fandrawer + + Returns: + string: Serial number of Fandrawer + """ + # Sample Serial number format "US-01234D-54321-25A-0123-A00" + return self.eeprom.get_serial_number() + + def get_status(self): + """ + Retrieves the operational status of the Fandrawer + + Returns: + bool: True if Fandrawer is operating properly, False if not + """ + status = True + for fan in self.get_all_fans(): + status &= fan.get_status() + + 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 fan drawer is replaceable. + Returns: + bool: True if it is replaceable. + """ + return True + + def set_status_led(self, color): + """ + Set led to expected color + Args: + color: A string representing the color with which to set the + fandrawer status LED + Returns: + bool: True if set success, False if fail. + """ + if color not in self.supported_led_color: + return False + if color == self.STATUS_LED_COLOR_AMBER: + color = 'yellow' + + rv = self._set_cpld_register(self.fantray_led_reg, color) + if (rv != 'ERR'): + return True + else: + return False + + def get_status_led(self): + """ + Gets the state of the fandrawer status LED + + Returns: + A string, one of the predefined STATUS_LED_COLOR_* strings. + """ + fantray_led = self._get_cpld_register(self.fantray_led_reg) + if (fantray_led != 'ERR'): + if (fantray_led == 'yellow'): + return self.STATUS_LED_COLOR_AMBER + else: + return fantray_led + else: + return self.STATUS_LED_COLOR_OFF 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 af52ccedbc44..e217c0a08c40 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 @@ -15,9 +15,12 @@ from sonic_platform_base.psu_base import PsuBase from sonic_platform.eeprom import Eeprom from sonic_platform.fan import Fan + from sonic_platform.thermal import Thermal except ImportError as e: raise ImportError(str(e) + "- required module not found") +MAX_S6000_THERMALS_PER_PSU = 2 + class Psu(PsuBase): """DellEMC Platform-specific PSU class""" @@ -53,7 +56,10 @@ def __init__(self, psu_index): self.eeprom = Eeprom(is_psu=True, psu_index=self.index) - self._fan_list.append(Fan(self.index, psu_fan=True, dependency=self)) + self._fan_list.append(Fan(psu_index=self.index, psu_fan=True, dependency=self)) + for i in range(1, MAX_S6000_THERMALS_PER_PSU+1): + self._thermal_list.append(Thermal(psu_index=self.index, thermal_index=i, + psu_thermal=True, dependency=self)) def _get_cpld_register(self, reg_name): # On successful read, returns the value read from given @@ -171,6 +177,23 @@ def get_status(self): 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 PSU is replaceable. + Returns: + bool: True if it is replaceable. + """ + return True + def get_voltage(self): """ Retrieves current PSU voltage output @@ -266,3 +289,50 @@ def set_status_led(self, color): # In S6000, the firmware running in the PSU controls the LED # and the PSU LED state cannot be changed from CPU. return False + + def get_temperature(self): + """ + Retrieves current temperature reading from PSU + + Returns: + A float number of current temperature in Celsius up to + nearest thousandth of one degree Celsius, e.g. 30.125 + """ + if self.get_presence(): + return self.get_thermal(0).get_temperature() + else: + return 0.0 + + def get_temperature_high_threshold(self): + """ + Retrieves the high threshold temperature of PSU + + Returns: + A float number, the high threshold temperature of PSU in + Celsius up to nearest thousandth of one degree Celsius, + e.g. 30.125 + """ + if self.get_presence(): + return self.get_thermal(0).get_high_threshold() + else: + return 0.0 + + def get_voltage_high_threshold(self): + """ + Retrieves the high threshold PSU voltage output + + Returns: + A float number, the high threshold output voltage in volts, + e.g. 12.1 + """ + return 12.6 + + def get_voltage_low_threshold(self): + """ + Retrieves the low threshold PSU voltage output + + Returns: + A float number, the low threshold output voltage in volts, + e.g. 12.1 + """ + return 11.4 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 175e601dbe76..b66cb31ec96b 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 @@ -10,6 +10,7 @@ try: import re + import struct import time from sonic_platform_base.sfp_base import SfpBase from sonic_platform_base.sonic_sfp.sff8436 import sff8436InterfaceId @@ -27,6 +28,9 @@ DOM_OFFSET = 0 DOM_OFFSET1 = 384 +QSFP_CONTROL_OFFSET = 86 +QSFP_POWEROVERRIDE_OFFSET = 93 + cable_length_tup = ('Length(km)', 'Length OM3(2m)', 'Length OM2(m)', 'Length OM1(m)', 'Length Cable Assembly(m)') @@ -108,7 +112,7 @@ def __init__(self, index, sfp_type, eeprom_path, sfp_control, sfp_ctrl_idx): SfpBase.__init__(self) self.sfp_type = sfp_type - self.index = index + self.index = index + 1 self.eeprom_path = eeprom_path self.sfp_control = sfp_control self.sfp_ctrl_idx = sfp_ctrl_idx @@ -132,9 +136,10 @@ def _read_eeprom_bytes(self, eeprom_path, offset, num_bytes): eeprom.close() return None + raw = bytearray(raw) try: for n in range(0, num_bytes): - eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2) + eeprom_raw[n] = hex(raw[n])[2:].zfill(2) except BaseException: eeprom.close() return None @@ -588,40 +593,14 @@ def get_tx_disable_channel(self): """ Retrieves the TX disabled channels in this SFP """ - tx_disable = None - tx_disable_list = [] + tx_disable_channel = 0 - tx_disable_data = self._get_eeprom_data('tx_disable') - if (tx_disable_data is not None): - tx_disable = tx_disable_data['data']['Tx1Disable']['value'] - if (tx_disable == 'On'): - tx_disable_list.append(1) - else: - tx_disable_list.append(0) - tx_disable = tx_disable_data['data']['Tx2Disable']['value'] - if (tx_disable == 'On'): - tx_disable_list.append(1) - else: - tx_disable_list.append(0) - tx_disable = tx_disable_data['data']['Tx3Disable']['value'] - if (tx_disable == 'On'): - tx_disable_list.append(1) - else: - tx_disable_list.append(0) - tx_disable = tx_disable_data['data']['Tx4Disable']['value'] - if (tx_disable == 'On'): - tx_disable_list.append(1) - else: - tx_disable_list.append(0) - - bit4 = int(tx_disable_list[3]) * 8 - bit3 = int(tx_disable_list[2]) * 4 - bit2 = int(tx_disable_list[1]) * 2 - bit1 = int(tx_disable_list[0]) * 1 - - tx_disable_channel = hex(bit4 + bit3 + bit2 + bit1) + tx_disable = self.get_tx_disable() + for channel, disable in enumerate(tx_disable): + if disable: + tx_disable_channel |= 1 << channel - return tx_disable_channel + return tx_disable_channel def get_lpmode(self): """ @@ -722,7 +701,6 @@ def get_rx_power(self): return rx_power_list - def get_tx_power(self): """ Retrieves the TX power of this SFP @@ -822,19 +800,68 @@ def tx_disable(self, tx_disable): """ Disable SFP TX for all channels """ - return False + eeprom = None + tx_disable_value = 0xf if tx_disable else 0x0 + + try: + eeprom = open(self.eeprom_path, "r+b") + eeprom.seek(QSFP_CONTROL_OFFSET) + eeprom.write(struct.pack('B', tx_disable_value)) + except IOError: + return False + finally: + if eeprom is not None: + eeprom.close() + time.sleep(0.01) + + return True def tx_disable_channel(self, channel, disable): """ Sets the tx_disable for specified SFP channels """ - return False + eeprom = None + current_state = self.get_tx_disable_channel() + + if disable: + tx_disable_value = current_state | channel + else: + tx_disable_value = current_state & (~channel) + + try: + eeprom = open(self.eeprom_path, "r+b") + eeprom.seek(QSFP_CONTROL_OFFSET) + eeprom.write(struct.pack('B', tx_disable_value)) + except IOError: + return False + finally: + if eeprom is not None: + eeprom.close() + time.sleep(0.01) + + return True def set_power_override(self, power_override, power_set): """ Sets SFP power level using power_override and power_set """ - return False + eeprom = None + power_override_bit = 0x1 if power_override else 0 + power_set_bit = 0x2 if power_set else 0 + value = power_override_bit | power_set_bit + + try: + eeprom = open(self.eeprom_path, "r+b") + eeprom.seek(QSFP_POWEROVERRIDE_OFFSET) + eeprom.write(struct.pack('B', value)) + except IOError: + return False + finally: + if eeprom is not None: + eeprom.close() + time.sleep(0.01) + + return True def get_status(self): """ @@ -848,3 +875,20 @@ def get_status(self): 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 diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/thermal.py index 2f130ebabbb3..ad089a8946a9 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/thermal.py @@ -13,7 +13,6 @@ import os import glob from sonic_platform_base.thermal_base import ThermalBase - from sonic_platform.psu import Psu except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -34,11 +33,20 @@ class Thermal(ThermalBase): 'PSU1-Sensor 1', 'PSU1-Sensor 2', 'PSU2-Sensor 1', 'PSU2-Sensor 2', 'CPU Core 0', 'CPU Core 1') - def __init__(self, thermal_index): - self.index = thermal_index + 1 - self.is_psu_thermal = False + def __init__(self, thermal_index, + psu_index=1, psu_thermal=False, dependency=None): + self.is_psu_thermal = psu_thermal + self.dependency = dependency self.is_driver_initialized = True - self.dependency = None + + if self.is_psu_thermal: + self.index = (2 * psu_index) + thermal_index + 2 + else: + # CPU thermal + if thermal_index > 3: + self.index = thermal_index + 5 + else: + self.index = thermal_index + 1 if self.index < 9: i2c_path = self.I2C_DIR + self.I2C_DEV_MAPPING[self.index - 1][0] @@ -54,10 +62,6 @@ def __init__(self, thermal_index): if self.index == 4: hwmon_temp_suffix = "crit" - - if self.index > 4: - self.is_psu_thermal = True - self.dependency = Psu(self.index / 7) else: dev_path = "/sys/devices/platform/coretemp.0/hwmon/" hwmon_temp_index = self.index - 7 @@ -168,6 +172,23 @@ def get_status(self): else: 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.index + + def is_replaceable(self): + """ + Indicate whether Thermal is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + def get_temperature(self): """ Retrieves current temperature reading from thermal 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 47ef87b951db..f8e009cdbefd 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 @@ -54,9 +54,21 @@ class Chassis(ChassisBase): power_reason_dict[33] = ChassisBase.REBOOT_CAUSE_THERMAL_OVERLOAD_ASIC power_reason_dict[44] = ChassisBase.REBOOT_CAUSE_INSUFFICIENT_FAN_SPEED + status_led_reg_to_color = { + 0x00: 'green', 0x01: 'blinking green', 0x02: 'amber', + 0x04: 'amber', 0x08: 'blinking amber', 0x10: 'blinking amber' + } + + color_to_status_led_reg = { + 'green': 0x00, 'blinking green': 0x01, + 'amber': 0x02, 'blinking amber': 0x08 + } + def __init__(self): ChassisBase.__init__(self) + self.status_led_reg = "sys_status_led" + self.supported_led_color = ['green', 'blinking green', 'amber', 'blinking amber'] # Initialize EEPROM self._eeprom = Eeprom() for i in range(MAX_S6100_MODULE): @@ -113,6 +125,23 @@ def _get_pmc_register(self, reg_name): rv = rv.lstrip(" ") return rv + def _set_pmc_register(self, reg_name, value): + # On successful write, returns the length of value written on + # reg_name and on failure returns 'ERR' + rv = 'ERR' + mb_reg_file = self.MAILBOX_DIR + '/' + reg_name + + if (not os.path.isfile(mb_reg_file)): + return rv + + try: + with open(mb_reg_file, 'w') as fd: + rv = fd.write(str(value)) + except IOError: + rv = 'ERR' + + return rv + def _get_register(self, reg_file): # On successful read, returns the value read from given # reg_name and on failure returns 'ERR' @@ -172,6 +201,23 @@ 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 -1 + + def is_replaceable(self): + """ + Indicate whether Chassis is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + def get_base_mac(self): """ Retrieves the base MAC address for the chassis @@ -325,3 +371,38 @@ def get_change_event(self, timeout=0): break return True, ret_dict + + 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 + """ + if color not in self.supported_led_color: + return False + + value = self.color_to_status_led_reg[color] + rv = self._set_pmc_register(self.status_led_reg, value) + if (rv != 'ERR'): + return True + else: + return False + + 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. + """ + reg_val = self._get_pmc_register(self.status_led_reg) + if (reg_val != 'ERR'): + return self.status_led_reg_to_color.get(int(reg_val, 16), None) + else: + return None diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/component.py index 6b1420a98606..bea180d440b5 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/component.py @@ -39,9 +39,10 @@ class Component(ComponentBase): ] def __init__(self, component_index=0, - is_module=False, iom_index=0, i2c_line=0): + is_module=False, iom_index=0, i2c_line=0, dependency=None): self.is_module_component = is_module + self.dependency = dependency if self.is_module_component: self.index = iom_index @@ -132,6 +133,61 @@ def get_name(self): """ return self.name + def get_model(self): + """ + Retrieves the part number of the component + Returns: + string: Part number of component + """ + return 'NA' + + def get_serial(self): + """ + Retrieves the serial number of the component + Returns: + string: Serial number of component + """ + return 'NA' + + def get_presence(self): + """ + Retrieves the presence of the component + Returns: + bool: True if present, False if not + """ + if self.is_module_component: + return self.dependency.get_presence() + else: + return True + + def get_status(self): + """ + Retrieves the operational status of the component + Returns: + bool: True if component is operating properly, False if not + """ + if self.is_module_component: + return self.dependency.get_status() + else: + 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 -1 + + def is_replaceable(self): + """ + Indicate whether component is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + def get_description(self): """ Retrieves the description of the component diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/fan.py index 8404a8d2bf5f..5b3c8977ac0a 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/fan.py @@ -26,30 +26,23 @@ class Fan(FanBase): HWMON_NODE = os.listdir(HWMON_DIR)[0] MAILBOX_DIR = HWMON_DIR + HWMON_NODE - def __init__(self, fantray_index=1, fan_index=1, psu_fan=False): + def __init__(self, fantray_index=1, psu_index=1, psu_fan=False, dependency=None): self.is_psu_fan = psu_fan if not self.is_psu_fan: - # API index is starting from 0, DellEMC platform index is starting - # from 1 - self.fantrayindex = fantray_index + 1 - self.fanindex = fan_index + 1 - self.fan_presence_reg = "fan{}_fault".format( - 2 * self.fantrayindex - 1) + self.fantrayindex = fantray_index + self.dependency = dependency self.fan_status_reg = "fan{}_alarm".format( 2 * self.fantrayindex - 1) self.get_fan_speed_reg = "fan{}_input".format( 2 * self.fantrayindex - 1) self.get_fan_dir_reg = "fan{}_airflow".format( 2 * self.fantrayindex - 1) - self.fan_serialno_reg = "fan{}_serialno".format( - 2 * self.fantrayindex - 1) self.max_fan_speed = MAX_S6100_FAN_SPEED else: - # PSU Fan index starts from 11 - self.fanindex = fan_index + 10 - self.fan_presence_reg = "fan{}_fault".format(self.fanindex) - self.get_fan_speed_reg = "fan{}_input".format(self.fanindex) - self.get_fan_dir_reg = "fan{}_airflow".format(self.fanindex) + self.psuindex = psu_index + self.fan_presence_reg = "fan{}_fault".format(self.psuindex + 10) + self.get_fan_speed_reg = "fan{}_input".format(self.psuindex + 10) + self.get_fan_dir_reg = "fan{}_airflow".format(self.psuindex + 10) self.max_fan_speed = MAX_S6100_PSU_FAN_SPEED def _get_pmc_register(self, reg_name): @@ -77,10 +70,9 @@ def get_name(self): string: The name of the device """ if not self.is_psu_fan: - return "FanTray{}-Fan{}".format( - self.fantrayindex, self.fanindex - 1) + return "FanTray{}-Fan1".format(self.fantrayindex) else: - return "PSU{} Fan".format(self.fanindex - 10) + return "PSU{} Fan".format(self.psuindex) def get_model(self): """ @@ -88,21 +80,7 @@ def get_model(self): Returns: string: Part number of FAN """ - # For Serial number "US-01234D-54321-25A-0123-A00", the part - # number is "01234D" - if self.is_psu_fan: - return 'NA' - - fan_serialno = self._get_pmc_register(self.fan_serialno_reg) - if (fan_serialno != 'ERR') and self.get_presence(): - if (len(fan_serialno.split('-')) > 1): - fan_partno = fan_serialno.split('-')[1] - else: - fan_partno = 'NA' - else: - fan_partno = 'NA' - - return fan_partno + return 'NA' def get_serial(self): """ @@ -110,15 +88,7 @@ def get_serial(self): Returns: string: Serial number of FAN """ - # Sample Serial number format "US-01234D-54321-25A-0123-A00" - if self.is_psu_fan: - return 'NA' - - fan_serialno = self._get_pmc_register(self.fan_serialno_reg) - if (fan_serialno == 'ERR') or not self.get_presence(): - fan_serialno = 'NA' - - return fan_serialno + return 'NA' def get_presence(self): """ @@ -126,14 +96,17 @@ def get_presence(self): Returns: bool: True if fan is present, False if not """ - status = False - fantray_presence = self._get_pmc_register(self.fan_presence_reg) - if (fantray_presence != 'ERR'): - fantray_presence = int(fantray_presence, 10) - if (~fantray_presence & 0b1): - status = True + if not self.is_psu_fan: + return self.dependency.get_presence() - return status + presence = False + fan_presence = self._get_pmc_register(self.fan_presence_reg) + if (fan_presence != 'ERR'): + fan_presence = int(fan_presence, 10) + if (~fan_presence & 0b1): + presence = True + + return presence def get_status(self): """ @@ -157,6 +130,23 @@ def get_status(self): 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 1 + + def is_replaceable(self): + """ + Indicate whether Fan is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + def get_direction(self): """ Retrieves the fan airflow direction @@ -216,7 +206,6 @@ def set_speed(self, speed): Returns: bool: True if set success, False if fail. """ - # Fan speeds are controlled by Smart-fussion FPGA. return False @@ -229,7 +218,7 @@ def set_status_led(self, color): Returns: bool: True if set success, False if fail. """ - # Leds are controlled by Smart-fussion FPGA. + # No LED available for FanTray and PSU Fan # Return True to avoid thermalctld alarm. return True @@ -240,17 +229,8 @@ def get_status_led(self): Returns: A string, one of the predefined STATUS_LED_COLOR_* strings. """ - if self.is_psu_fan: - # No LED available for PSU Fan - return None - else: - if self.get_presence(): - if self.get_status(): - return self.STATUS_LED_COLOR_GREEN - else: - return self.STATUS_LED_COLOR_AMBER - else: - return self.STATUS_LED_COLOR_OFF + # No LED available for FanTray and PSU Fan + return None def get_target_speed(self): """ @@ -262,5 +242,3 @@ def get_target_speed(self): # Fan speeds are controlled by Smart-fussion FPGA. # Return current speed to avoid false thermalctld alarm. return self.get_speed() - - 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 ada5e93393c9..41e870a63971 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 @@ -9,6 +9,8 @@ ######################################################################## try: + import os + from sonic_platform_base.fan_drawer_base import FanDrawerBase from sonic_platform.fan import Fan except ImportError as e: @@ -16,14 +18,38 @@ class FanDrawer(FanDrawerBase): - """DellEMC Platform-specific Fan class""" + """DellEMC Platform-specific Fan Drawer class""" - def __init__(self, fantray_index): + HWMON_DIR = "/sys/devices/platform/SMF.512/hwmon/" + HWMON_NODE = os.listdir(HWMON_DIR)[0] + MAILBOX_DIR = HWMON_DIR + HWMON_NODE + def __init__(self, fantray_index): FanDrawerBase.__init__(self) # FanTray is 1-based in DellEMC platforms - self.fantrayindex = fantray_index + 1 - self._fan_list.append(Fan(fantray_index)) + self.index = fantray_index + 1 + self.presence_reg = "fan{}_fault".format(2 * self.index - 1) + self.serialno_reg = "fan{}_serialno".format(2 * self.index - 1) + + self._fan_list.append(Fan(self.index, dependency=self)) + + def _get_pmc_register(self, reg_name): + # On successful read, returns the value read from given + # reg_name and on failure returns 'ERR' + rv = 'ERR' + mb_reg_file = self.MAILBOX_DIR+'/'+reg_name + + if (not os.path.isfile(mb_reg_file)): + return rv + try: + with open(mb_reg_file, 'r') as fd: + rv = fd.read() + except Exception as error: + rv = 'ERR' + + rv = rv.rstrip('\r\n') + rv = rv.lstrip(" ") + return rv def get_name(self): """ @@ -31,4 +57,105 @@ def get_name(self): Returns: string: The name of the device """ - return "FanTray{}".format(self.fantrayindex) + return "FanTray{}".format(self.index) + + def get_model(self): + """ + Retrieves the part number of Fandrawer + Returns: + string: Part number of Fandrawer + """ + # For Serial number "US-01234D-54321-25A-0123-A00", the part + # number is "01234D" + fantray_serialno = self._get_pmc_register(self.serialno_reg) + if (fantray_serialno != 'ERR') and self.get_presence(): + if (len(fantray_serialno.split('-')) > 1): + fantray_partno = fantray_serialno.split('-')[1] + else: + fantray_partno = 'NA' + else: + fantray_partno = 'NA' + + return fantray_partno + + def get_serial(self): + """ + Retrieves the serial number of Fandrawer + Returns: + string: Serial number of Fandrawer + """ + # Sample Serial number format "US-01234D-54321-25A-0123-A00" + fantray_serialno = self._get_pmc_register(self.serialno_reg) + if (fantray_serialno == 'ERR') or not self.get_presence(): + fantray_serialno = 'NA' + + return fantray_serialno + + def get_presence(self): + """ + Retrieves the presence of the Fandrawer + Returns: + bool: True if fan is present, False if not + """ + presence = False + fantray_presence = self._get_pmc_register(self.presence_reg) + if (fantray_presence != 'ERR'): + fantray_presence = int(fantray_presence, 10) + if (~fantray_presence & 0b1): + presence = True + + return presence + + def get_status(self): + """ + Retrieves the operational status of the Fandrawer + + Returns: + bool: True if Fandrawer is operating properly, False if not + """ + return self.get_fan(0).get_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 Fandrawer is replaceable. + Returns: + bool: True if it is replaceable. + """ + return True + + 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. + """ + # Leds are controlled by Smart-fussion FPGA. + # Return True to avoid thermalctld alarm. + return True + + def get_status_led(self): + """ + Gets the state of the Fan status LED + + Returns: + A string, one of the predefined STATUS_LED_COLOR_* strings. + """ + if self.get_presence(): + if self.get_fan(0).get_status(): + return self.STATUS_LED_COLOR_GREEN + else: + return self.STATUS_LED_COLOR_AMBER + else: + return self.STATUS_LED_COLOR_OFF 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 6b93bcfd1fa7..923bb5c0550a 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 @@ -63,7 +63,7 @@ def __init__(self, module_index): self.iom_presence_reg = "iom_presence" component = Component(is_module=True, iom_index=self.index, - i2c_line=self.port_i2c_line) + i2c_line=self.port_i2c_line, dependency=self) self._component_list.append(component) eeprom_base = "/sys/class/i2c-adapter/i2c-{0}/i2c-{1}/{1}-0050/eeprom" @@ -157,6 +157,23 @@ def get_status(self): 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 Module is replaceable. + Returns: + bool: True if it is replaceable. + """ + return True + def get_base_mac(self): """ Retrieves the base MAC address for the module 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 48b266daa278..4e528b679e4a 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,13 +34,15 @@ 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_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_temperature_reg = "temp15_input" # Passing True to specify it is a PSU fan - psu_fan = Fan(fan_index=self.index, psu_fan=True) + psu_fan = Fan(psu_index=self.index, psu_fan=True) self._fan_list.append(psu_fan) def _get_pmc_register(self, reg_name): @@ -232,3 +234,87 @@ def set_status_led(self, color): # In S6100, SmartFusion FPGA controls the PSU LED and the PSU # LED state cannot be changed from CPU. return False + + 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 PSU is replaceable. + Returns: + bool: True if it is replaceable. + """ + return True + + def get_temperature(self): + """ + Retrieves current temperature reading from PSU + + Returns: + A float number of current temperature in Celsius up to + nearest thousandth of one degree Celsius, e.g. 30.125 + """ + temperature = 0.0 + if self.get_presence(): + psu_temperature = self._get_pmc_register(self.psu_temperature_reg) + if (psu_temperature != 'ERR'): + temperature = float(psu_temperature) / 1000 + + return temperature + + def get_temperature_high_threshold(self): + """ + Retrieves the high threshold temperature of PSU + + Returns: + A float number, the high threshold temperature of PSU in + Celsius up to nearest thousandth of one degree Celsius, + e.g. 30.125 + """ + return 90.0 + + def get_voltage_high_threshold(self): + """ + Retrieves the high threshold PSU voltage output + + Returns: + A float number, the high threshold output voltage in volts, + e.g. 12.1 + """ + voltage_high_threshold = 0.0 + if self.get_presence(): + psu_type = self._get_pmc_register(self.psu_presence_reg) + if (psu_type != 'ERR'): + psu_type = int(psu_type, 16) + if (psu_type & 0b10): + voltage_high_threshold = 12.6 + else: + voltage_high_threshold = 12.8 + + return voltage_high_threshold + + def get_voltage_low_threshold(self): + """ + Retrieves the low threshold PSU voltage output + + Returns: + A float number, the low threshold output voltage in volts, + e.g. 12.1 + """ + voltage_low_threshold = 0.0 + if self.get_presence(): + psu_type = self._get_pmc_register(self.psu_presence_reg) + if (psu_type != 'ERR'): + psu_type = int(psu_type, 16) + if (psu_type & 0b10): + voltage_low_threshold = 11.4 + else: + voltage_low_threshold = 11.6 + + return voltage_low_threshold 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 6947b6cf2b66..0b242ab74d71 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 @@ -10,6 +10,7 @@ try: import re + import struct import time from sonic_platform_base.sfp_base import SfpBase from sonic_platform_base.sonic_sfp.sff8436 import sff8436InterfaceId @@ -27,6 +28,9 @@ DOM_OFFSET = 0 DOM_OFFSET1 = 384 +QSFP_CONTROL_OFFSET = 86 +QSFP_POWEROVERRIDE_OFFSET = 93 + cable_length_tup = ('Length(km)', 'Length OM3(2m)', 'Length OM2(m)', 'Length OM1(m)', 'Length Cable Assembly(m)') @@ -107,7 +111,7 @@ def __init__(self, index, sfp_type, eeprom_path, sfp_control, sfp_ctrl_idx): SfpBase.__init__(self) self.sfp_type = sfp_type - self.index = index + self.index = index + 1 self.eeprom_path = eeprom_path self.sfp_control = sfp_control self.sfp_ctrl_idx = sfp_ctrl_idx @@ -131,9 +135,10 @@ def _read_eeprom_bytes(self, eeprom_path, offset, num_bytes): eeprom.close() return None + raw = bytearray(raw) try: for n in range(0, num_bytes): - eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2) + eeprom_raw[n] = hex(raw[n])[2:].zfill(2) except BaseException: eeprom.close() return None @@ -594,40 +599,14 @@ def get_tx_disable_channel(self): """ Retrieves the TX disabled channels in this SFP """ - tx_disable = None - tx_disable_list = [] + tx_disable_channel = 0 - tx_disable_data = self._get_eeprom_data('tx_disable') - if (tx_disable_data is not None): - tx_disable = tx_disable_data['data']['Tx1Disable']['value'] - if (tx_disable == 'On'): - tx_disable_list.append(1) - else: - tx_disable_list.append(0) - tx_disable = tx_disable_data['data']['Tx2Disable']['value'] - if (tx_disable == 'On'): - tx_disable_list.append(1) - else: - tx_disable_list.append(0) - tx_disable = tx_disable_data['data']['Tx3Disable']['value'] - if (tx_disable == 'On'): - tx_disable_list.append(1) - else: - tx_disable_list.append(0) - tx_disable = tx_disable_data['data']['Tx4Disable']['value'] - if (tx_disable == 'On'): - tx_disable_list.append(1) - else: - tx_disable_list.append(0) - - bit4 = int(tx_disable_list[3]) * 8 - bit3 = int(tx_disable_list[2]) * 4 - bit2 = int(tx_disable_list[1]) * 2 - bit1 = int(tx_disable_list[0]) * 1 - - tx_disable_channel = hex(bit4 + bit3 + bit2 + bit1) + tx_disable = self.get_tx_disable() + for channel, disable in enumerate(tx_disable): + if disable: + tx_disable_channel |= 1 << channel - return tx_disable_channel + return tx_disable_channel def get_lpmode(self): """ @@ -836,19 +815,68 @@ def tx_disable(self, tx_disable): """ Disable SFP TX for all channels """ - return False + eeprom = None + tx_disable_value = 0xf if tx_disable else 0x0 + + try: + eeprom = open(self.eeprom_path, "r+b") + eeprom.seek(QSFP_CONTROL_OFFSET) + eeprom.write(struct.pack('B', tx_disable_value)) + except IOError: + return False + finally: + if eeprom is not None: + eeprom.close() + time.sleep(0.01) + + return True def tx_disable_channel(self, channel, disable): """ Sets the tx_disable for specified SFP channels """ - return False + eeprom = None + current_state = self.get_tx_disable_channel() + + if disable: + tx_disable_value = current_state | channel + else: + tx_disable_value = current_state & (~channel) + + try: + eeprom = open(self.eeprom_path, "r+b") + eeprom.seek(QSFP_CONTROL_OFFSET) + eeprom.write(struct.pack('B', tx_disable_value)) + except IOError: + return False + finally: + if eeprom is not None: + eeprom.close() + time.sleep(0.01) + + return True def set_power_override(self, power_override, power_set): """ Sets SFP power level using power_override and power_set """ - return False + eeprom = None + power_override_bit = 0x1 if power_override else 0 + power_set_bit = 0x2 if power_set else 0 + value = power_override_bit | power_set_bit + + try: + eeprom = open(self.eeprom_path, "r+b") + eeprom.seek(QSFP_POWEROVERRIDE_OFFSET) + eeprom.write(struct.pack('B', value)) + except IOError: + return False + finally: + if eeprom is not None: + eeprom.close() + time.sleep(0.01) + + return True def get_status(self): """ @@ -862,3 +890,20 @@ def get_status(self): 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 diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/thermal.py index f7037b000c5b..cac17f4b83aa 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/thermal.py @@ -131,6 +131,23 @@ def get_status(self): 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 Thermal is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False + def get_temperature(self): """ Retrieves current temperature reading from thermal From 0e7c295fb37a80bc9ff5f7b961f91dbf6ee15d27 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Fri, 5 Feb 2021 12:47:04 -0800 Subject: [PATCH 0142/1674] [sonic-swss-common] Update submodule (#6686) Includes below commits ``` 9e91e0d 2021-02-04 | Fix: RedisClient.set() should return bool (#454) [Qi Luo] 244a0bf 2021-02-04 | [swig] Add missing functions for ConfigDBConnector (#453) [Qi Luo] e659698 2021-01-22 | [dbconnector] Make sure json is declared as non null object (#452) [Kamil Cudnik] ``` --- src/sonic-swss-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-swss-common b/src/sonic-swss-common index e49b18f2512a..9e91e0d89139 160000 --- a/src/sonic-swss-common +++ b/src/sonic-swss-common @@ -1 +1 @@ -Subproject commit e49b18f2512a9331579cea37ab199730051a68e9 +Subproject commit 9e91e0d891398b468b8087682ae91335791fac51 From 78bf8159e8596dd94c6c67a2a682a2f14c1f7573 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Fri, 5 Feb 2021 14:41:05 -0800 Subject: [PATCH 0143/1674] [platform] Update QSFP method name 'parse_qsfp_dom_capability' -> 'parse_dom_capability' (#6695) **- Why I did it** PR https://github.com/Azure/sonic-platform-common/pull/102 modified the name of the SFF-8436 (QSFP) method to align the method name between all drivers, renaming it from `parse_qsfp_dom_capability` to `parse_dom_capability`. Once the submodule was updated, the callers using the old nomenclature broke. This PR updates all callers to use the new naming convention. **- How I did it** Update the name of the function globally for all calls into the SFF-8436 driver. Note that the QSFP-DD driver still uses the old nomenclature and should be modified similarly. I will open a PR to handle this separately. --- .../x86_64-accton_as7116_54x-r0/sonic_platform/sfp.py | 2 +- .../x86_64-cel_seastone-r0/sonic_platform/sfp.py | 2 +- .../x86_64-cel_silverstone-r0/sonic_platform/sfp.py | 2 +- .../x86_64-dellemc_s5232f_c3538-r0/plugins/sfputil.py | 2 +- .../x86_64-dellemc_s5248f_c3538-r0/plugins/sfputil.py | 2 +- .../x86_64-dellemc_s5296f_c3538-r0/plugins/sfputil.py | 2 +- .../x86_64-dellemc_z9264f_c3538-r0/plugins/sfputil.py | 2 +- .../juniper/x86_64-juniper_qfx5200-r0/plugins/sfputil.py | 2 +- .../juniper/x86_64-juniper_qfx5210-r0/plugins/sfputil.py | 2 +- device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py | 2 +- device/mellanox/x86_64-mlnx_msn4410-r0/plugins/sfputil.py | 2 +- .../services/platform_api/sonic_platform/sfp.py | 2 +- .../s5232f/sonic_platform/sfp.py | 2 +- .../z9264f/sonic_platform/sfp.py | 2 +- .../z9332f/sonic_platform/sfp.py | 2 +- .../d6332/sonic_platform/qsfp.py | 8 ++++---- .../d6356/sonic_platform/qsfp.py | 2 +- .../d7054q28b/sonic_platform/sfp.py | 2 +- platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py | 2 +- .../sonic_platform_pddf_base/pddf_sfp.py | 2 +- 20 files changed, 23 insertions(+), 23 deletions(-) diff --git a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/sfp.py b/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/sfp.py index 9d85b96be730..2006561ffef0 100644 --- a/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/sfp.py +++ b/device/accton/x86_64-accton_as7116_54x-r0/sonic_platform/sfp.py @@ -698,7 +698,7 @@ def get_qsfp_transceiver_bulk_status(self): 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: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability( + qspf_dom_capability_data = sfpi_obj.parse_dom_capability( qsfp_dom_capability_raw, 0) else: return None diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/sfp.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/sfp.py index 9daa005cd2bf..13ae4b8a47ad 100644 --- a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/sfp.py +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/sfp.py @@ -279,7 +279,7 @@ def _dom_capability_detect(self): QSFP_VERSION_COMPLIANCE_OFFSET, QSFP_VERSION_COMPLIANCE_WIDTH) qsfp_version_compliance = int( qsfp_version_compliance_raw[0], 16) - dom_capability = sfpi_obj.parse_qsfp_dom_capability( + dom_capability = sfpi_obj.parse_dom_capability( qsfp_dom_capability_raw, 0) if qsfp_version_compliance >= 0x08: self.dom_temp_supported = dom_capability['data']['Temp_support']['value'] == 'On' diff --git a/device/celestica/x86_64-cel_silverstone-r0/sonic_platform/sfp.py b/device/celestica/x86_64-cel_silverstone-r0/sonic_platform/sfp.py index b04b49ca4382..e909416e9081 100644 --- a/device/celestica/x86_64-cel_silverstone-r0/sonic_platform/sfp.py +++ b/device/celestica/x86_64-cel_silverstone-r0/sonic_platform/sfp.py @@ -328,7 +328,7 @@ def _dom_capability_detect(self): QSFP_VERSION_COMPLIANCE_OFFSET, QSFP_VERSION_COMPLIANCE_WIDTH) qsfp_version_compliance = int( qsfp_version_compliance_raw[0], 16) - dom_capability = sfpi_obj.parse_qsfp_dom_capability( + dom_capability = sfpi_obj.parse_dom_capability( qsfp_dom_capability_raw, 0) if qsfp_version_compliance >= 0x08: self.dom_temp_supported = dom_capability['data']['Temp_support']['value'] == 'On' diff --git a/device/dell/x86_64-dellemc_s5232f_c3538-r0/plugins/sfputil.py b/device/dell/x86_64-dellemc_s5232f_c3538-r0/plugins/sfputil.py index f53e8e944d1e..b56fcc5aafd0 100644 --- a/device/dell/x86_64-dellemc_s5232f_c3538-r0/plugins/sfputil.py +++ b/device/dell/x86_64-dellemc_s5232f_c3538-r0/plugins/sfputil.py @@ -311,7 +311,7 @@ def get_transceiver_dom_info_dict(self, port_num): qsfp_dom_capability_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) if qsfp_dom_capability_raw is not None: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability( + qspf_dom_capability_data = sfpi_obj.parse_dom_capability( qsfp_dom_capability_raw, 0) else: return transceiver_dom_info_dict diff --git a/device/dell/x86_64-dellemc_s5248f_c3538-r0/plugins/sfputil.py b/device/dell/x86_64-dellemc_s5248f_c3538-r0/plugins/sfputil.py index 2b941d028968..dba21ed11bdb 100644 --- a/device/dell/x86_64-dellemc_s5248f_c3538-r0/plugins/sfputil.py +++ b/device/dell/x86_64-dellemc_s5248f_c3538-r0/plugins/sfputil.py @@ -358,7 +358,7 @@ def get_transceiver_dom_info_dict(self, port_num): qsfp_dom_capability_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) if qsfp_dom_capability_raw is not None: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability( + qspf_dom_capability_data = sfpi_obj.parse_dom_capability( qsfp_dom_capability_raw, 0) else: return transceiver_dom_info_dict diff --git a/device/dell/x86_64-dellemc_s5296f_c3538-r0/plugins/sfputil.py b/device/dell/x86_64-dellemc_s5296f_c3538-r0/plugins/sfputil.py index 8b4ab0dcae1a..c270ef47f1e0 100644 --- a/device/dell/x86_64-dellemc_s5296f_c3538-r0/plugins/sfputil.py +++ b/device/dell/x86_64-dellemc_s5296f_c3538-r0/plugins/sfputil.py @@ -305,7 +305,7 @@ def get_transceiver_dom_info_dict(self, port_num): qsfp_dom_capability_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) if qsfp_dom_capability_raw is not None: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability(qsfp_dom_capability_raw, 0) + qspf_dom_capability_data = sfpi_obj.parse_dom_capability(qsfp_dom_capability_raw, 0) else: return transceiver_dom_info_dict diff --git a/device/dell/x86_64-dellemc_z9264f_c3538-r0/plugins/sfputil.py b/device/dell/x86_64-dellemc_z9264f_c3538-r0/plugins/sfputil.py index 5b01882762af..48f722a5d964 100644 --- a/device/dell/x86_64-dellemc_z9264f_c3538-r0/plugins/sfputil.py +++ b/device/dell/x86_64-dellemc_z9264f_c3538-r0/plugins/sfputil.py @@ -378,7 +378,7 @@ def get_transceiver_dom_info_dict(self, port_num): qsfp_dom_capability_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) if qsfp_dom_capability_raw is not None: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability(qsfp_dom_capability_raw, 0) + qspf_dom_capability_data = sfpi_obj.parse_dom_capability(qsfp_dom_capability_raw, 0) else: return transceiver_dom_info_dict diff --git a/device/juniper/x86_64-juniper_qfx5200-r0/plugins/sfputil.py b/device/juniper/x86_64-juniper_qfx5200-r0/plugins/sfputil.py index 54dbdacc1c21..db85347be3f4 100644 --- a/device/juniper/x86_64-juniper_qfx5200-r0/plugins/sfputil.py +++ b/device/juniper/x86_64-juniper_qfx5200-r0/plugins/sfputil.py @@ -870,7 +870,7 @@ def get_transceiver_dom_info_dict(self, port_num): qsfp_dom_capability_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) if qsfp_dom_capability_raw is not None: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability(qsfp_dom_capability_raw, 0) + qspf_dom_capability_data = sfpi_obj.parse_dom_capability(qsfp_dom_capability_raw, 0) else: return None diff --git a/device/juniper/x86_64-juniper_qfx5210-r0/plugins/sfputil.py b/device/juniper/x86_64-juniper_qfx5210-r0/plugins/sfputil.py index a854f8fa2915..673bb05ed107 100644 --- a/device/juniper/x86_64-juniper_qfx5210-r0/plugins/sfputil.py +++ b/device/juniper/x86_64-juniper_qfx5210-r0/plugins/sfputil.py @@ -583,7 +583,7 @@ def get_transceiver_dom_info_dict(self, port_num): qsfp_dom_capability_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) if qsfp_dom_capability_raw is not None: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability(qsfp_dom_capability_raw, 0) + qspf_dom_capability_data = sfpi_obj.parse_dom_capability(qsfp_dom_capability_raw, 0) else: return None diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py index 954ed23d8eac..df60c5256f2a 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py @@ -513,7 +513,7 @@ def get_transceiver_dom_info_dict(self, port_num): qsfp_dom_capability_raw = self._read_eeprom_specific_bytes_via_ethtool( port_num, (offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) if qsfp_dom_capability_raw is not None: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability(qsfp_dom_capability_raw, 0) + qspf_dom_capability_data = sfpi_obj.parse_dom_capability(qsfp_dom_capability_raw, 0) else: return transceiver_dom_info_dict diff --git a/device/mellanox/x86_64-mlnx_msn4410-r0/plugins/sfputil.py b/device/mellanox/x86_64-mlnx_msn4410-r0/plugins/sfputil.py index 336d729e95a6..c94b65881fe9 100644 --- a/device/mellanox/x86_64-mlnx_msn4410-r0/plugins/sfputil.py +++ b/device/mellanox/x86_64-mlnx_msn4410-r0/plugins/sfputil.py @@ -488,7 +488,7 @@ def get_transceiver_dom_info_dict(self, port_num): # in SFF-8636 dom capability definitions evolving with the versions. qsfp_dom_capability_raw = self._read_eeprom_specific_bytes_via_ethtool(port_num, (offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) if qsfp_dom_capability_raw is not None: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability(qsfp_dom_capability_raw, 0) + qspf_dom_capability_data = sfpi_obj.parse_dom_capability(qsfp_dom_capability_raw, 0) else: return transceiver_dom_info_dict diff --git a/platform/broadcom/sonic-platform-modules-cel/services/platform_api/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-cel/services/platform_api/sonic_platform/sfp.py index 17f2756dee1a..5906050fa139 100644 --- a/platform/broadcom/sonic-platform-modules-cel/services/platform_api/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-cel/services/platform_api/sonic_platform/sfp.py @@ -358,7 +358,7 @@ def _dom_capability_detect(self): QSFP_VERSION_COMPLIANCE_OFFSET, QSFP_VERSION_COMPLIANCE_WIDTH) qsfp_version_compliance = int( qsfp_version_compliance_raw[0], 16) - dom_capability = sfpi_obj.parse_qsfp_dom_capability( + dom_capability = sfpi_obj.parse_dom_capability( qsfp_dom_capability_raw, 0) if qsfp_version_compliance >= 0x08: self.dom_temp_supported = dom_capability['data']['Temp_support']['value'] == 'On' diff --git a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/sfp.py index 56f37afea6e8..b2cceab9b08f 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/sfp.py @@ -118,7 +118,7 @@ 'hardware_rev': [QSFP_INFO_OFFSET, 56, 2, 'parse_vendor_rev'], 'serial': [QSFP_INFO_OFFSET, 68, 16, 'parse_vendor_sn'], 'vendor_date': [QSFP_INFO_OFFSET, 84, 8, 'parse_vendor_date'], - 'dom_capability': [QSFP_INFO_OFFSET, 92, 1, 'parse_qsfp_dom_capability'], + 'dom_capability': [QSFP_INFO_OFFSET, 92, 1, 'parse_dom_capability'], 'dom_rev': [QSFP_DOM_OFFSET, 1, 1, 'parse_sfp_dom_rev'], 'ModuleThreshold': [QSFP_DOM_OFFSET1, 128, 24, 'parse_module_threshold_values'], 'ChannelThreshold': [QSFP_DOM_OFFSET1, 176, 16, 'parse_channel_threshold_values'], diff --git a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/sfp.py index 8d9bd36c6abb..225aef90e00a 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/sfp.py @@ -122,7 +122,7 @@ 'hardware_rev': [QSFP_INFO_OFFSET, 56, 2, 'parse_vendor_rev'], 'serial': [QSFP_INFO_OFFSET, 68, 16, 'parse_vendor_sn'], 'vendor_date': [QSFP_INFO_OFFSET, 84, 8, 'parse_vendor_date'], - 'dom_capability': [QSFP_INFO_OFFSET, 92, 1, 'parse_qsfp_dom_capability'], + 'dom_capability': [QSFP_INFO_OFFSET, 92, 1, 'parse_dom_capability'], 'dom_rev': [QSFP_DOM_OFFSET, 1, 1, 'parse_sfp_dom_rev'], 'ModuleThreshold': [QSFP_DOM_OFFSET1, 128, 24, 'parse_module_threshold_values'], 'ChannelThreshold': [QSFP_DOM_OFFSET1, 176, 16, 'parse_channel_threshold_values'], diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/sfp.py index 7fc50958c9ee..ef6a2c5d339a 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/sfp.py @@ -127,7 +127,7 @@ 'hardware_rev': [QSFP_INFO_OFFSET, 56, 2, 'parse_vendor_rev'], 'serial': [QSFP_INFO_OFFSET, 68, 16, 'parse_vendor_sn'], 'vendor_date': [QSFP_INFO_OFFSET, 84, 8, 'parse_vendor_date'], - 'dom_capability': [QSFP_INFO_OFFSET, 92, 1, 'parse_qsfp_dom_capability'], + 'dom_capability': [QSFP_INFO_OFFSET, 92, 1, 'parse_dom_capability'], 'dom_rev': [QSFP_DOM_OFFSET, 1, 1, 'parse_sfp_dom_rev'], 'ModuleThreshold': [QSFP_DOM_OFFSET1, 128, 24, 'parse_module_threshold_values'], 'ChannelThreshold': [QSFP_DOM_OFFSET1, 176, 16, 'parse_channel_threshold_values'], diff --git a/platform/broadcom/sonic-platform-modules-inventec/d6332/sonic_platform/qsfp.py b/platform/broadcom/sonic-platform-modules-inventec/d6332/sonic_platform/qsfp.py index 178ac0cf9aa5..17763cd1264f 100644 --- a/platform/broadcom/sonic-platform-modules-inventec/d6332/sonic_platform/qsfp.py +++ b/platform/broadcom/sonic-platform-modules-inventec/d6332/sonic_platform/qsfp.py @@ -436,7 +436,7 @@ def get_transceiver_bulk_status(self): # 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: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability(qsfp_dom_capability_raw, 0) + qspf_dom_capability_data = sfpi_obj.parse_dom_capability(qsfp_dom_capability_raw, 0) else: return None @@ -793,7 +793,7 @@ def get_tx_bias(self): 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: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability(qsfp_dom_capability_raw, 0) + qspf_dom_capability_data = sfpi_obj.parse_dom_capability(qsfp_dom_capability_raw, 0) else: return None @@ -844,7 +844,7 @@ def get_rx_power(self): 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: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability(qsfp_dom_capability_raw, 0) + qspf_dom_capability_data = sfpi_obj.parse_dom_capability(qsfp_dom_capability_raw, 0) else: return None @@ -895,7 +895,7 @@ def get_tx_power(self): 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: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability(qsfp_dom_capability_raw, 0) + qspf_dom_capability_data = sfpi_obj.parse_dom_capability(qsfp_dom_capability_raw, 0) else: return None diff --git a/platform/broadcom/sonic-platform-modules-inventec/d6356/sonic_platform/qsfp.py b/platform/broadcom/sonic-platform-modules-inventec/d6356/sonic_platform/qsfp.py index c002697d96a3..2cc4b6ca593a 100644 --- a/platform/broadcom/sonic-platform-modules-inventec/d6356/sonic_platform/qsfp.py +++ b/platform/broadcom/sonic-platform-modules-inventec/d6356/sonic_platform/qsfp.py @@ -388,7 +388,7 @@ def get_transceiver_bulk_status(self): # 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: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability(qsfp_dom_capability_raw, 0) + qspf_dom_capability_data = sfpi_obj.parse_dom_capability(qsfp_dom_capability_raw, 0) else: return None diff --git a/platform/broadcom/sonic-platform-modules-inventec/d7054q28b/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-inventec/d7054q28b/sonic_platform/sfp.py index 760aa179c256..a18d98d502f5 100644 --- a/platform/broadcom/sonic-platform-modules-inventec/d7054q28b/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-inventec/d7054q28b/sonic_platform/sfp.py @@ -636,7 +636,7 @@ def get_transceiver_bulk_status(self): 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: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability( + qspf_dom_capability_data = sfpi_obj.parse_dom_capability( qsfp_dom_capability_raw, 0) else: return None diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py index 4b397b3f3ff8..75ae9c8907e1 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py @@ -440,7 +440,7 @@ def _dom_capability_detect(self): if qsfp_dom_capability_raw is not None: qsfp_version_compliance_raw = self._read_eeprom_specific_bytes(QSFP_VERSION_COMPLIANCE_OFFSET, QSFP_VERSION_COMPLIANCE_WIDTH) qsfp_version_compliance = int(qsfp_version_compliance_raw[0], 16) - dom_capability = sfpi_obj.parse_qsfp_dom_capability(qsfp_dom_capability_raw, 0) + dom_capability = sfpi_obj.parse_dom_capability(qsfp_dom_capability_raw, 0) if qsfp_version_compliance >= 0x08: self.dom_temp_supported = dom_capability['data']['Temp_support']['value'] == 'On' self.dom_volt_supported = dom_capability['data']['Voltage_support']['value'] == 'On' 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 index 856f4c748d10..d53c23061b2d 100755 --- 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 @@ -414,7 +414,7 @@ def get_transceiver_bulk_status(self): 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: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability( + qspf_dom_capability_data = sfpi_obj.parse_dom_capability( qsfp_dom_capability_raw, 0) else: return None From c7d8faee18c6b57217509c70eec39fd651c1bdd8 Mon Sep 17 00:00:00 2001 From: Danny Allen Date: Fri, 5 Feb 2021 16:07:49 -0800 Subject: [PATCH 0144/1674] Revert "BRCM SAI 4.3.0.10-4 Fix _brcm_sai_indexed_data_get () with unexpected queue causing _brcm_sai_switch_assert () after warm reboot (#6664)" This reverts commit 9f2a85697f20e51dd5af3ffbbdb6c04f6bb1a46d. --- platform/broadcom/sai.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index 1b27d7bc1f88..fcb175d3d0c5 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,8 +1,8 @@ -BRCM_SAI = libsaibcm_4.3.0.10-4_amd64.deb -$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.0.10-4_amd64.deb?sv=2015-04-05&sr=b&sig=nfseU56PACVqklQ4MC0HvZ7qt7Ou4loQMBA7jx8CSOY%3D&se=2034-10-13T16%3A31%3A22Z&sp=r" -BRCM_SAI_DEV = libsaibcm-dev_4.3.0.10-4_amd64.deb +BRCM_SAI = libsaibcm_4.2.1.5-10_amd64.deb +$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.2/master/buster/libsaibcm_4.2.1.5-10_amd64.deb?sv=2019-12-12&st=2021-01-12T07%3A30%3A31Z&se=2035-01-13T07%3A30%3A00Z&sr=b&sp=r&sig=yCGwk%2FW%2Fg%2FaFxhr0oNSTZ%2BVy5B6kX1WDEsbbyz9J088%3D" +BRCM_SAI_DEV = libsaibcm-dev_4.2.1.5-10_amd64.deb $(eval $(call add_derived_package,$(BRCM_SAI),$(BRCM_SAI_DEV))) -$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.0.10-4_amd64.deb?sv=2015-04-05&sr=b&sig=4tF26GxI6jmrcvRyCezQ7RL6qMjzip7SFf61eqy%2Bvf4%3D&se=2034-10-13T16%3A31%3A53Z&sp=r" +$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.2/master/buster/libsaibcm-dev_4.2.1.5-10_amd64.deb?sv=2019-12-12&st=2021-01-12T07%3A32%3A43Z&se=2035-01-13T07%3A32%3A00Z&sr=b&sp=r&sig=wuCNc6pa12JQCBi%2BM9rLWvVI92ldan9hKNF%2BfVfUWN8%3D" SONIC_ONLINE_DEBS += $(BRCM_SAI) $(BRCM_SAI_DEV)_DEPENDS += $(BRCM_SAI) From bc2a13136a99849ee2b20f43f2ebbe29ea1002ad Mon Sep 17 00:00:00 2001 From: Mahesh Maddikayala <10645050+smaheshm@users.noreply.github.com> Date: Thu, 28 Jan 2021 08:38:47 -0800 Subject: [PATCH 0145/1674] [BCMSAI] Update BCMSAI debian to 4.3.0.10 with 6.5.21 SDK, and opennsl module to 6.5.21 (#6526) BCMSAI 4.3.0.10, 6.5.21 SDK release with enhancements and fixes for vxlan, TD3 MMU, TD4-X9 EA support, etc. --- platform/broadcom/sai-modules.mk | 2 +- platform/broadcom/sai.mk | 8 +- .../broadcom/saibcm-modules/debian/changelog | 7 + .../debian/opennsl-modules.init | 6 +- .../debian/opennsl-modules.install | 1 + platform/broadcom/saibcm-modules/debian/rules | 11 + .../broadcom/saibcm-modules/include/ibde.h | 13 +- .../broadcom/saibcm-modules/include/kcom.h | 15 +- .../saibcm-modules/include/sal/core/sync.h | 13 +- .../saibcm-modules/include/sal/core/thread.h | 13 +- .../saibcm-modules/include/sal/types.h | 13 +- .../saibcm-modules/include/sdk_config.h | 13 +- .../saibcm-modules/include/soc/devids.h | 149 +- .../broadcom/saibcm-modules/make/Make.config | 13 +- .../broadcom/saibcm-modules/make/Make.depend | 13 +- .../broadcom/saibcm-modules/make/Make.kernlib | 13 +- .../broadcom/saibcm-modules/make/Make.lib | 15 +- .../broadcom/saibcm-modules/make/Make.linux | 15 +- .../broadcom/saibcm-modules/make/Make.subdirs | 13 +- .../broadcom/saibcm-modules/make/Make.tools | 13 +- .../saibcm-modules/make/Makefile.linux-gts | 24 +- .../saibcm-modules/make/Makefile.linux-iproc | 13 +- .../make/Makefile.linux-iproc-3_14 | 13 +- .../make/Makefile.linux-iproc-4_4 | 13 +- .../make/Makefile.linux-iproc_64 | 13 +- .../saibcm-modules/make/Makefile.linux-kernel | 13 +- .../make/Makefile.linux-kernel-2_6 | 13 +- .../make/Makefile.linux-kernel-3_6 | 13 +- .../make/Makefile.linux-kernel-4_4 | 13 +- .../make/Makefile.linux-kmodule | 20 +- .../saibcm-modules/make/Makefile.linux-slk | 17 +- .../make/Makefile.linux-x86-common-2_6 | 13 +- .../Makefile.linux-x86-generic-common-2_6 | 14 +- .../Makefile.linux-x86-smp_generic_64-2_6 | 15 +- .../saibcm-modules/make/Makefile.linux-xlr | 24 +- .../saibcm-modules/sdklt/LICENSES/gpl-2.0.txt | 339 +++ .../broadcom/saibcm-modules/sdklt/Makefile | 83 + .../bcm56780_a0/bcm56780_a0_pdma_attach.c | 38 + .../bcm56880_a0/bcm56880_a0_pdma_attach.c | 38 + .../bcm56990_a0/bcm56990_a0_pdma_attach.c | 38 + .../bcm56990_b0/bcm56990_b0_pdma_attach.c | 38 + .../bcm56996_a0/bcm56996_a0_pdma_attach.c | 38 + .../bcmcnet/hmi/cmicd/bcmcnet_cmicd_pdma_hw.c | 530 ++++ .../hmi/cmicd/bcmcnet_cmicd_pdma_rxtx.c | 1062 +++++++ .../bcmcnet/hmi/cmicx/bcmcnet_cmicx_pdma_hw.c | 604 ++++ .../hmi/cmicx/bcmcnet_cmicx_pdma_rxtx.c | 1094 +++++++ .../bcmcnet/include/bcmcnet/bcmcnet_cmicd.h | 369 +++ .../bcmcnet/include/bcmcnet/bcmcnet_cmicx.h | 379 +++ .../bcmcnet/include/bcmcnet/bcmcnet_core.h | 1323 ++++++++ .../bcmcnet/include/bcmcnet/bcmcnet_dev.h | 544 ++++ .../include/bcmcnet/bcmcnet_internal.h | 305 ++ .../bcmcnet/include/bcmcnet/bcmcnet_rxtx.h | 512 ++++ .../bcmcnet/include/bcmcnet/bcmcnet_types.h | 263 ++ .../sdklt/bcmcnet/main/bcmcnet_core.c | 701 +++++ .../sdklt/bcmcnet/main/bcmcnet_dev.c | 1059 +++++++ .../sdklt/bcmcnet/main/bcmcnet_rxtx.c | 708 +++++ .../bcmdrd/include/bcmdrd/bcmdrd_devlist.h | 337 +++ .../sdklt/bcmdrd/include/bcmdrd_config.h | 166 + .../bcmdrd/include/bcmdrd_config_chips.h | 545 ++++ .../saibcm-modules/sdklt/linux/bde/Kbuild | 39 + .../saibcm-modules/sdklt/linux/bde/Makefile | 33 + .../saibcm-modules/sdklt/linux/bde/ngbde.h | 836 +++++ .../sdklt/linux/bde/ngbde_dma.c | 340 +++ .../sdklt/linux/bde/ngbde_iio.c | 143 + .../sdklt/linux/bde/ngbde_intr.c | 550 ++++ .../sdklt/linux/bde/ngbde_ioctl.c | 237 ++ .../sdklt/linux/bde/ngbde_iproc_probe.c | 164 + .../sdklt/linux/bde/ngbde_kapi.c | 216 ++ .../sdklt/linux/bde/ngbde_main.c | 297 ++ .../sdklt/linux/bde/ngbde_pci_probe.c | 211 ++ .../sdklt/linux/bde/ngbde_pgmem.c | 472 +++ .../sdklt/linux/bde/ngbde_pio.c | 97 + .../sdklt/linux/bde/ngbde_procfs.c | 120 + .../sdklt/linux/bde/ngbde_swdev.c | 79 + .../sdklt/linux/include/lkm/lkm.h | 126 + .../sdklt/linux/include/lkm/ngbde_ioctl.h | 345 +++ .../sdklt/linux/include/lkm/ngbde_kapi.h | 169 ++ .../sdklt/linux/include/lkm/ngknet_dev.h | 408 +++ .../sdklt/linux/include/lkm/ngknet_ioctl.h | 112 + .../sdklt/linux/include/net/psample.h | 24 + .../sdklt/linux/include/uapi/linux/psample.h | 35 + .../saibcm-modules/sdklt/linux/knet/Kbuild | 44 + .../saibcm-modules/sdklt/linux/knet/Makefile | 105 + .../sdklt/linux/knet/ngknet_buff.c | 326 ++ .../sdklt/linux/knet/ngknet_buff.h | 83 + .../sdklt/linux/knet/ngknet_callback.c | 315 ++ .../sdklt/linux/knet/ngknet_callback.h | 364 +++ .../sdklt/linux/knet/ngknet_dep.h | 61 + .../sdklt/linux/knet/ngknet_extra.c | 505 ++++ .../sdklt/linux/knet/ngknet_extra.h | 218 ++ .../sdklt/linux/knet/ngknet_linux.c | 173 ++ .../sdklt/linux/knet/ngknet_linux.h | 240 ++ .../sdklt/linux/knet/ngknet_main.c | 2689 +++++++++++++++++ .../sdklt/linux/knet/ngknet_main.h | 278 ++ .../sdklt/linux/knet/ngknet_procfs.c | 655 ++++ .../sdklt/linux/knet/ngknet_procfs.h | 47 + .../sdklt/linux/knet/ngknet_ptp.c | 194 ++ .../sdklt/linux/knet/ngknet_ptp.h | 111 + .../saibcm-modules/sdklt/linux/knetcb/Kbuild | 36 + .../sdklt/linux/knetcb/Makefile | 33 + .../sdklt/linux/knetcb/ngknetcb_main.c | 444 +++ .../sdklt/linux/knetcb/psample-cb.c | 995 ++++++ .../sdklt/linux/knetcb/psample-cb.h | 57 + .../saibcm-modules/sdklt/linux/psample/Kbuild | 18 + .../sdklt/linux/psample/Makefile | 21 + .../sdklt/linux/psample/psample.c | 302 ++ .../broadcom/saibcm-modules/sdklt/make/lkm.mk | 76 + .../sdklt/shr/include/shr/shr_error.h | 195 ++ .../systems/bde/linux/include/linux-bde.h | 59 +- .../systems/bde/linux/include/linux_dma.h | 15 +- .../systems/bde/linux/include/mpool.h | 13 +- .../systems/bde/linux/kernel/Makefile | 13 +- .../bde/linux/kernel/linux-kernel-bde.c | 210 +- .../systems/bde/linux/kernel/linux_dma.c | 228 +- .../systems/bde/linux/kernel/linux_shbde.c | 13 +- .../systems/bde/linux/kernel/linux_shbde.h | 13 +- .../systems/bde/linux/shared/mpool.c | 122 +- .../systems/bde/linux/user/kernel/Makefile | 13 +- .../bde/linux/user/kernel/linux-user-bde.c | 607 +++- .../bde/linux/user/kernel/linux-user-bde.h | 78 +- .../systems/bde/shared/include/shbde.h | 13 +- .../systems/bde/shared/include/shbde_iproc.h | 13 +- .../systems/bde/shared/include/shbde_mdio.h | 13 +- .../systems/bde/shared/include/shbde_pci.h | 13 +- .../systems/bde/shared/shbde_iproc.c | 24 +- .../systems/bde/shared/shbde_mdio.c | 13 +- .../systems/bde/shared/shbde_pci.c | 13 +- .../systems/linux/kernel/modules/Makefile | 13 +- .../linux/kernel/modules/bcm-knet/Makefile | 13 +- .../linux/kernel/modules/bcm-knet/bcm-knet.c | 199 +- .../kernel/modules/bcm-ptp-clock/Makefile | 6 +- .../modules/bcm-ptp-clock/bcm-ptp-clock.c | 676 +++-- .../linux/kernel/modules/include/bcm-knet.h | 14 +- .../linux/kernel/modules/include/gmodule.h | 22 +- .../linux/kernel/modules/include/lkm.h | 16 +- .../linux/kernel/modules/knet-cb/Makefile | 13 +- .../linux/kernel/modules/knet-cb/knet-cb.c | 22 +- .../linux/kernel/modules/knet-cb/psample-cb.c | 22 +- .../linux/kernel/modules/psample/psample.c | 2 +- .../linux/kernel/modules/shared/Makefile | 13 +- .../linux/kernel/modules/shared/gmodule.c | 28 +- .../linux/kernel/modules/shared/ksal.c | 13 +- .../systems/linux/user/common/Makefile | 29 +- .../systems/linux/user/gts/Makefile | 13 +- .../systems/linux/user/iproc-3_14/Makefile | 13 +- .../systems/linux/user/iproc-4_4/Makefile | 13 +- .../systems/linux/user/iproc/Makefile | 13 +- .../systems/linux/user/iproc_64/Makefile | 13 +- .../systems/linux/user/slk/Makefile | 13 +- .../user/x86-smp_generic_64-2_6/Makefile | 13 +- .../systems/linux/user/xlr/Makefile | 13 +- .../broadcom/saibcm-modules/tools/mktool.pl | 13 +- 152 files changed, 27191 insertions(+), 854 deletions(-) create mode 100644 platform/broadcom/saibcm-modules/sdklt/LICENSES/gpl-2.0.txt create mode 100644 platform/broadcom/saibcm-modules/sdklt/Makefile create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56780_a0/bcm56780_a0_pdma_attach.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56880_a0/bcm56880_a0_pdma_attach.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56990_a0/bcm56990_a0_pdma_attach.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56990_b0/bcm56990_b0_pdma_attach.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56996_a0/bcm56996_a0_pdma_attach.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicd/bcmcnet_cmicd_pdma_hw.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicd/bcmcnet_cmicd_pdma_rxtx.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicx/bcmcnet_cmicx_pdma_hw.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicx/bcmcnet_cmicx_pdma_rxtx.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicd.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicx.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_core.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_dev.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_internal.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_rxtx.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_types.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_core.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_dev.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_rxtx.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd/bcmdrd_devlist.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd_config.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd_config_chips.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/bde/Kbuild create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/bde/Makefile create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_dma.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_iio.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_intr.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_ioctl.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_iproc_probe.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_kapi.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_main.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pci_probe.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pgmem.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pio.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_procfs.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_swdev.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/lkm.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngbde_ioctl.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngbde_kapi.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_dev.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_ioctl.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/include/net/psample.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/include/uapi/linux/psample.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knet/Kbuild create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knet/Makefile create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_callback.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_callback.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_dep.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_extra.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_extra.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_linux.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_linux.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_main.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_main.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_procfs.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_procfs.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_ptp.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_ptp.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Kbuild create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Makefile create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knetcb/ngknetcb_main.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.h create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/psample/Kbuild create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/psample/Makefile create mode 100644 platform/broadcom/saibcm-modules/sdklt/linux/psample/psample.c create mode 100644 platform/broadcom/saibcm-modules/sdklt/make/lkm.mk create mode 100644 platform/broadcom/saibcm-modules/sdklt/shr/include/shr/shr_error.h diff --git a/platform/broadcom/sai-modules.mk b/platform/broadcom/sai-modules.mk index 84d97c09ac88..2d4262518c68 100644 --- a/platform/broadcom/sai-modules.mk +++ b/platform/broadcom/sai-modules.mk @@ -1,6 +1,6 @@ # Broadcom SAI modules -BRCM_OPENNSL_KERNEL_VERSION = 4.2.1.3-1 +BRCM_OPENNSL_KERNEL_VERSION = 4.3.0.10-2 BRCM_OPENNSL_KERNEL = opennsl-modules_$(BRCM_OPENNSL_KERNEL_VERSION)_amd64.deb $(BRCM_OPENNSL_KERNEL)_SRC_PATH = $(PLATFORM_PATH)/saibcm-modules diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index fcb175d3d0c5..7a1e6cf99bd1 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,8 +1,8 @@ -BRCM_SAI = libsaibcm_4.2.1.5-10_amd64.deb -$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.2/master/buster/libsaibcm_4.2.1.5-10_amd64.deb?sv=2019-12-12&st=2021-01-12T07%3A30%3A31Z&se=2035-01-13T07%3A30%3A00Z&sr=b&sp=r&sig=yCGwk%2FW%2Fg%2FaFxhr0oNSTZ%2BVy5B6kX1WDEsbbyz9J088%3D" -BRCM_SAI_DEV = libsaibcm-dev_4.2.1.5-10_amd64.deb +BRCM_SAI = libsaibcm_4.3.0.10-2_amd64.deb +$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.0.10-2_amd64.deb?sv=2015-04-05&sr=b&sig=1L2kJwYBuXDc9ObuVBBUS%2F%2FBVIfAA651ig5k6O1ZztE%3D&se=2022-06-10T21%3A25%3A43Z&sp=r" +BRCM_SAI_DEV = libsaibcm-dev_4.3.0.10-2_amd64.deb $(eval $(call add_derived_package,$(BRCM_SAI),$(BRCM_SAI_DEV))) -$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.2/master/buster/libsaibcm-dev_4.2.1.5-10_amd64.deb?sv=2019-12-12&st=2021-01-12T07%3A32%3A43Z&se=2035-01-13T07%3A32%3A00Z&sr=b&sp=r&sig=wuCNc6pa12JQCBi%2BM9rLWvVI92ldan9hKNF%2BfVfUWN8%3D" +$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.0.10-2_amd64.deb?sv=2015-04-05&sr=b&sig=2Vm6o8HtbjI%2BfVoHJUiO5b75USqGra9CLSFXViQm8yM%3D&se=2022-06-10T21%3A26%3A35Z&sp=r" SONIC_ONLINE_DEBS += $(BRCM_SAI) $(BRCM_SAI_DEV)_DEPENDS += $(BRCM_SAI) diff --git a/platform/broadcom/saibcm-modules/debian/changelog b/platform/broadcom/saibcm-modules/debian/changelog index f2b0db31e662..87d659d21a61 100644 --- a/platform/broadcom/saibcm-modules/debian/changelog +++ b/platform/broadcom/saibcm-modules/debian/changelog @@ -1,3 +1,10 @@ +opennsl (4.3.0.10-2) unstable; urgency=medium + + * Update to Broadcom SAI 4.3.0.10 + * Added SDKLT modules 4.3.0.10-2 + + -- Mahesh Maddikayala Thu, 21 Jan 2021 18:36:38 +0000 + opennsl (4.2.1.3-1) unstable; urgency=medium * Update to Broadcom SAI 4.2.1.3 diff --git a/platform/broadcom/saibcm-modules/debian/opennsl-modules.init b/platform/broadcom/saibcm-modules/debian/opennsl-modules.init index 7def10cbff86..09112f5331ce 100755 --- a/platform/broadcom/saibcm-modules/debian/opennsl-modules.init +++ b/platform/broadcom/saibcm-modules/debian/opennsl-modules.init @@ -18,7 +18,9 @@ function create_devices() rm -f /dev/linux-bcm-knet rm -f /dev/linux-bcm-bde rm -f /dev/linux-kernel-bde + rm -f /dev/linux_ngbde + mknod /dev/linux_ngbde c 120 0 mknod /dev/linux-knet-cb c 121 0 mknod /dev/linux-bcm-knet c 122 0 mknod /dev/linux-bcm-bde c 126 0 @@ -57,8 +59,9 @@ function load_kernel_modules() # There is a different psample.ko module getting created at net/psample/psample.ko insmod /lib/modules/$(uname -r)/extra/psample.ko - modprobe linux-bcm-knet use_rx_skb=1 rx_buffer_size=9238 debug=0x5020 + modprobe linux-bcm-knet use_rx_skb=1 rx_buffer_size=9238 debug=0x5020 default_mtu=9100 modprobe linux-knet-cb + modprobe linux_ngbde } function remove_kernel_modules() @@ -68,6 +71,7 @@ function remove_kernel_modules() rmmod linux-bcm-knet rmmod linux-user-bde rmmod linux-kernel-bde + rmmod linux_ngbde } case "$1" in diff --git a/platform/broadcom/saibcm-modules/debian/opennsl-modules.install b/platform/broadcom/saibcm-modules/debian/opennsl-modules.install index 0e8051fbbca7..ebb290820f03 100644 --- a/platform/broadcom/saibcm-modules/debian/opennsl-modules.install +++ b/platform/broadcom/saibcm-modules/debian/opennsl-modules.install @@ -5,3 +5,4 @@ systems/linux/user/x86-smp_generic_64-2_6/linux-knet-cb.ko lib/modules/4.19.0-9- systems/linux/user/x86-smp_generic_64-2_6/psample.ko lib/modules/4.19.0-9-2-amd64/extra systems/linux/user/x86-smp_generic_64-2_6/linux-bcm-ptp-clock.ko lib/modules/4.19.0-9-2-amd64/extra systemd/opennsl-modules.service lib/systemd/system +sdklt/linux/bde/linux_ngbde.ko lib/modules/4.19.0-9-2-amd64/extra diff --git a/platform/broadcom/saibcm-modules/debian/rules b/platform/broadcom/saibcm-modules/debian/rules index 64cc9b6c07e0..4fcf2db75a5f 100755 --- a/platform/broadcom/saibcm-modules/debian/rules +++ b/platform/broadcom/saibcm-modules/debian/rules @@ -67,6 +67,9 @@ kdist_clean: clean KERNDIR=/usr/src/linux-headers-$(KERNVERSION)-common \ KERNEL_SRC=/usr/src/linux-headers-$(KERNVERSION)-amd64 \ $(MAKE) -C systems/linux/user/x86-smp_generic_64-2_6 clean + SDK=$(realpath .) BUILD_KNET_CB=1 BUILD_PSAMPLE=1 \ + KDIR=/usr/src/linux-headers-$(KERNVERSION)-common \ + $(MAKE) -C sdklt/ clean # rm -f driver/*.o driver/*.ko # ### end KERNEL SETUP @@ -100,6 +103,10 @@ build-arch-stamp: KERNEL_SRC=/usr/src/linux-headers-$(KERNVERSION)-amd64 \ $(MAKE) -C systems/linux/user/x86-smp_generic_64-2_6 + SDK=$(realpath .) BUILD_KNET_CB=1 BUILD_PSAMPLE=1 \ + KDIR=/usr/src/linux-headers-$(KERNVERSION)-common \ + $(MAKE) -C sdklt/ kmod + touch $@ #k = $(shell echo $(KVERS) | grep -q ^2.6 && echo k) @@ -128,6 +135,10 @@ clean: KERNEL_SRC=/usr/src/linux-headers-$(KERNVERSION)-amd64 \ $(MAKE) -C systems/linux/user/x86-smp_generic_64-2_6 clean + SDK=$(realpath .) BUILD_KNET_CB=1 BUILD_PSAMPLE=1 \ + KDIR=/usr/src/linux-headers-$(KERNVERSION)-common \ + $(MAKE) -C sdklt/ clean + dh_clean install: DH_OPTIONS= diff --git a/platform/broadcom/saibcm-modules/include/ibde.h b/platform/broadcom/saibcm-modules/include/ibde.h index 5f371b2667c3..fb9d13d1d5fe 100644 --- a/platform/broadcom/saibcm-modules/include/ibde.h +++ b/platform/broadcom/saibcm-modules/include/ibde.h @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: ibde.h,v 1.27 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/include/kcom.h b/platform/broadcom/saibcm-modules/include/kcom.h index eb41e1a5aaf2..5129400ca8cd 100644 --- a/platform/broadcom/saibcm-modules/include/kcom.h +++ b/platform/broadcom/saibcm-modules/include/kcom.h @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: kcom.h,v 1.9 Broadcom SDK $ @@ -341,6 +352,8 @@ typedef struct kcom_msg_version_s { #define KSYNC_M_HW_DEINIT 1 #define KSYNC_M_VERSION 2 #define KSYNC_M_HW_TS_DISABLE 3 +#define KSYNC_M_MTP_TS_UPDATE_ENABLE 4 +#define KSYNC_M_MTP_TS_UPDATE_DISABLE 5 typedef struct kcom_clock_info_s { uint8 cmd; diff --git a/platform/broadcom/saibcm-modules/include/sal/core/sync.h b/platform/broadcom/saibcm-modules/include/sal/core/sync.h index 75dd6ce68312..03fd2facc907 100644 --- a/platform/broadcom/saibcm-modules/include/sal/core/sync.h +++ b/platform/broadcom/saibcm-modules/include/sal/core/sync.h @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: sync.h,v 1.1 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/include/sal/core/thread.h b/platform/broadcom/saibcm-modules/include/sal/core/thread.h index b7ecb722489f..86713d1e0742 100644 --- a/platform/broadcom/saibcm-modules/include/sal/core/thread.h +++ b/platform/broadcom/saibcm-modules/include/sal/core/thread.h @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: thread.h,v 1.1 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/include/sal/types.h b/platform/broadcom/saibcm-modules/include/sal/types.h index 7ed68f43e5e5..43d64dbcc6b9 100644 --- a/platform/broadcom/saibcm-modules/include/sal/types.h +++ b/platform/broadcom/saibcm-modules/include/sal/types.h @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: types.h,v 1.3 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/include/sdk_config.h b/platform/broadcom/saibcm-modules/include/sdk_config.h index 9d781114bdf3..6ce7d77d52d0 100644 --- a/platform/broadcom/saibcm-modules/include/sdk_config.h +++ b/platform/broadcom/saibcm-modules/include/sdk_config.h @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: sdk_config.h,v 1.5 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/include/soc/devids.h b/platform/broadcom/saibcm-modules/include/soc/devids.h index bb91d90be03f..89fabac44537 100644 --- a/platform/broadcom/saibcm-modules/include/soc/devids.h +++ b/platform/broadcom/saibcm-modules/include/soc/devids.h @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * Copyright: (c) 2020 Broadcom. @@ -1274,6 +1285,18 @@ #define BCM56278_A0_REV_ID 1 #define BCM56278_A1_REV_ID 2 +#define BCM56279_DEVICE_ID 0xb279 +#define BCM56279_A1_REV_ID 2 + +#define BCM56575_DEVICE_ID 0xb575 +#define BCM56575_A1_REV_ID 2 + +#define BCM56175_DEVICE_ID 0xb175 +#define BCM56175_A1_REV_ID 2 + +#define BCM56176_DEVICE_ID 0xb176 +#define BCM56176_A1_REV_ID 2 + #define BCM53440_DEVICE_ID 0x8440 #define BCM53440_A0_REV_ID 1 #define BCM53440_B0_REV_ID 0x11 @@ -1404,6 +1427,8 @@ #define BCM56070_A0_REV_ID 1 #define BCM56071_DEVICE_ID 0xb071 #define BCM56071_A0_REV_ID 1 +#define BCM56072_DEVICE_ID 0xb072 +#define BCM56072_A0_REV_ID 1 #define BCM56965_DEVICE_ID 0xb965 @@ -1499,6 +1524,8 @@ #define BCM56471_A0_REV_ID 1 #define BCM56472_DEVICE_ID 0xb472 #define BCM56472_A0_REV_ID 1 +#define BCM56475_DEVICE_ID 0xb475 +#define BCM56475_A0_REV_ID 1 #define BCM53540_DEVICE_ID 0x8540 @@ -1537,19 +1564,6 @@ #define BCM88650_A0_REV_ID ARAD_A0_REV_ID #define BCM88650_B0_REV_ID ARAD_B0_REV_ID #define BCM88650_B1_REV_ID ARAD_B1_REV_ID -#define BCM88750_DEVICE_ID 0x8750 -#define BCM88750_A0_REV_ID 0x0000 -#define BCM88750_B0_REV_ID 0x0011 -#define BCM88753_DEVICE_ID 0x8753 -#define BCM88753_A0_REV_ID 0x0000 -#define BCM88753_B0_REV_ID 0x0011 -#define BCM88754_DEVICE_ID 0x8754 -#define BCM88754_A0_REV_ID 0x0000 -#define BCM88754_ORIGINAL_VENDOR_ID 0x16FC -#define BCM88754_ORIGINAL_DEVICE_ID 0x020F -#define BCM88754_A0_ORIGINAL_REV_ID 0x0001 -#define BCM88755_DEVICE_ID 0x8755 -#define BCM88755_B0_REV_ID 0x0011 #define BCM88770_DEVICE_ID 0x8770 #define BCM88770_A1_REV_ID 0x0002 #define BCM88773_DEVICE_ID 0x8773 @@ -1767,22 +1781,57 @@ #define BCM88820_DEVICE_ID J2C_2ND_DEVICE_ID #define BCM88800_A0_REV_ID J2C_A0_REV_ID #define BCM88800_A1_REV_ID J2C_A1_REV_ID -#define BCM88821_DEVICE_ID 0x8821 -#define BCM88826_DEVICE_ID 0x8826 +#define BCM88801_DEVICE_ID 0x8801 #define BCM88802_DEVICE_ID 0x8802 #define BCM88803_DEVICE_ID 0x8803 #define BCM88804_DEVICE_ID 0x8804 #define BCM88805_DEVICE_ID 0x8805 #define BCM88806_DEVICE_ID 0x8806 +#define BCM88807_DEVICE_ID 0x8807 +#define BCM88808_DEVICE_ID 0x8808 +#define BCM88809_DEVICE_ID 0x8809 +#define BCM8880A_DEVICE_ID 0x880A +#define BCM8880B_DEVICE_ID 0x880B +#define BCM8880C_DEVICE_ID 0x880C +#define BCM8880D_DEVICE_ID 0x880D +#define BCM8880E_DEVICE_ID 0x880E +#define BCM8880F_DEVICE_ID 0x880F +#define BCM88821_DEVICE_ID 0x8821 #define BCM88822_DEVICE_ID 0x8822 #define BCM88823_DEVICE_ID 0x8823 #define BCM88824_DEVICE_ID 0x8824 #define BCM88825_DEVICE_ID 0x8825 +#define BCM88826_DEVICE_ID 0x8826 +#define BCM88827_DEVICE_ID 0x8827 +#define BCM88828_DEVICE_ID 0x8828 +#define BCM88829_DEVICE_ID 0x8829 +#define BCM8882A_DEVICE_ID 0x882A +#define BCM8882B_DEVICE_ID 0x882B +#define BCM8882C_DEVICE_ID 0x882C +#define BCM8882D_DEVICE_ID 0x882D +#define BCM8882E_DEVICE_ID 0x882E +#define BCM8882F_DEVICE_ID 0x882F #define J2P_DEVICE_ID 0x8850 #define J2P_A0_REV_ID DNXC_A0_REV_ID #define BCM88850_DEVICE_ID J2P_DEVICE_ID #define BCM88850_A0_REV_ID J2P_A0_REV_ID +#define BCM88851_DEVICE_ID 0x8851 +#define BCM88852_DEVICE_ID 0x8852 +#define BCM88853_DEVICE_ID 0x8853 +#define BCM88854_DEVICE_ID 0x8854 +#define BCM88855_DEVICE_ID 0x8855 +#define BCM88856_DEVICE_ID 0x8856 +#define BCM88857_DEVICE_ID 0x8857 +#define BCM88858_DEVICE_ID 0x8858 +#define BCM88859_DEVICE_ID 0x8859 +#define BCM8885A_DEVICE_ID 0x885A +#define BCM8885B_DEVICE_ID 0x885B +#define BCM8885C_DEVICE_ID 0x885C +#define BCM8885D_DEVICE_ID 0x885D +#define BCM8885E_DEVICE_ID 0x885E +#define BCM8885F_DEVICE_ID 0x885F + #define Q2A_DEVICE_ID 0x8480 #define Q2A_A0_REV_ID DNXC_A0_REV_ID @@ -1808,6 +1857,24 @@ #define BCM8848E_DEVICE_ID 0x848E #define BCM8848F_DEVICE_ID 0x848F +#define Q2U_DEVICE_ID 0x8280 +#define BCM88280_DEVICE_ID Q2U_DEVICE_ID +#define BCM88281_DEVICE_ID 0x8281 +#define BCM88282_DEVICE_ID 0x8282 +#define BCM88283_DEVICE_ID 0x8283 +#define BCM88284_DEVICE_ID 0x8284 +#define BCM88285_DEVICE_ID 0x8285 +#define BCM88286_DEVICE_ID 0x8286 +#define BCM88287_DEVICE_ID 0x8287 +#define BCM88288_DEVICE_ID 0x8288 +#define BCM88289_DEVICE_ID 0x8289 +#define BCM8828A_DEVICE_ID 0x828A +#define BCM8828B_DEVICE_ID 0x828B +#define BCM8828C_DEVICE_ID 0x828C +#define BCM8828D_DEVICE_ID 0x828D +#define BCM8828E_DEVICE_ID 0x828E +#define BCM8828F_DEVICE_ID 0x828F + #define QAX_DEVICE_ID 0x8470 #define QAX_A0_REV_ID 0x0001 #define QAX_B0_REV_ID 0x0011 @@ -1833,9 +1900,11 @@ #define BCM88270_DEVICE_ID QUX_DEVICE_ID #define BCM88270_A0_REV_ID QUX_A0_REV_ID #define BCM88270_A1_REV_ID QUX_A1_REV_ID +#define BCM88271_DEVICE_ID 0x8271 #define BCM88272_DEVICE_ID 0x8272 #define BCM88273_DEVICE_ID 0x8273 #define BCM88274_DEVICE_ID 0x8274 +#define BCM88276_DEVICE_ID 0x8276 #define BCM88278_DEVICE_ID 0x8278 #define BCM88279_DEVICE_ID 0x8279 @@ -1844,16 +1913,6 @@ #define BCM8206_DEVICE_ID FLAIR_DEVICE_ID #define BCM8206_A0_REV_ID FLAIR_A0_REV_ID -#define ARDON_DEVICE_ID 0x8202 -#define ARDON_A0_REV_ID 0x0000 -#define BCM88202_DEVICE_ID ARDON_DEVICE_ID -#define BCM88202_A0_REV_ID ARDON_A0_REV_ID -#define ARDON_A1_REV_ID 0x0001 -#define BCM88202_A1_REV_ID ARDON_A1_REV_ID -#define ARDON_A2_REV_ID 0x0002 -#define BCM88202_A2_REV_ID ARDON_A2_REV_ID -#define BCM2801PM_DEVICE_ID 0x2801 -#define BCM2801PM_A0_REV_ID 0x0000 #define BCM88360_DEVICE_ID 0x8360 #define BCM88360_A0_REV_ID ARADPLUS_A0_REV_ID #define BCM88361_DEVICE_ID 0x8361 @@ -1901,16 +1960,6 @@ #define BCM88952_A0_REV_ID 0x0001 #define BCM88952_A1_REV_ID 0x0002 -#define BCM88752_DEVICE_ID 0x8752 -#define BCM88752_A0_REV_ID 0x0000 -#define BCM88752_B0_REV_ID 0x0011 - - -#define BCM83207_DEVICE_ID 0x3207 -#define BCM83208_DEVICE_ID 0x3208 -#define BCM83207_A0_REV_ID 0x0001 -#define BCM83208_A0_REV_ID 1 - #define PCP_PCI_VENDOR_ID 0x1172 #define PCP_PCI_DEVICE_ID 0x4 @@ -1930,7 +1979,33 @@ #define BCM56883_DEVICE_ID 0xb883 #define BCM56883_A0_REV_ID 0x0001 #define BCM56883_B0_REV_ID 0x0011 - +#define BCM56889_DEVICE_ID 0xb889 +#define BCM56889_A0_REV_ID 0x0001 +#define BCM56889_B0_REV_ID 0x0011 + +#define BCM56780_DEVICE_ID 0xb780 +#define BCM56780_A0_REV_ID 0x0001 +#define BCM56782_DEVICE_ID 0xb782 +#define BCM56782_A0_REV_ID 0x0001 +#define BCM56784_DEVICE_ID 0xb784 +#define BCM56784_A0_REV_ID 0x0001 +#define BCM56786_DEVICE_ID 0xb786 +#define BCM56786_A0_REV_ID 0x0001 +#define BCM56788_DEVICE_ID 0xb788 +#define BCM56788_A0_REV_ID 0x0001 +#define BCM56789_DEVICE_ID 0xb789 +#define BCM56789_A0_REV_ID 0x0001 + +#define BCM56990_DEVICE_ID 0xb990 +#define BCM56990_A0_REV_ID 0x0001 +#define BCM56990_B0_REV_ID 0x0011 +#define BCM56992_DEVICE_ID 0xb992 +#define BCM56992_B0_REV_ID 0x0011 + +#define BCM56996_DEVICE_ID 0xb996 +#define BCM56996_A0_REV_ID 0x0001 +#define BCM56997_DEVICE_ID 0xb997 +#define BCM56997_A0_REV_ID 0x0001 #endif #endif diff --git a/platform/broadcom/saibcm-modules/make/Make.config b/platform/broadcom/saibcm-modules/make/Make.config index 409a6a49b3f3..b086aa3aa79b 100644 --- a/platform/broadcom/saibcm-modules/make/Make.config +++ b/platform/broadcom/saibcm-modules/make/Make.config @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Make.config,v 1.3 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Make.depend b/platform/broadcom/saibcm-modules/make/Make.depend index de7099387666..802f5f4483c2 100644 --- a/platform/broadcom/saibcm-modules/make/Make.depend +++ b/platform/broadcom/saibcm-modules/make/Make.depend @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Make.depend,v 1.14 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Make.kernlib b/platform/broadcom/saibcm-modules/make/Make.kernlib index 6ec8a1c8df77..94801acd4a69 100644 --- a/platform/broadcom/saibcm-modules/make/Make.kernlib +++ b/platform/broadcom/saibcm-modules/make/Make.kernlib @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Make.kernlib,v 1.7 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Make.lib b/platform/broadcom/saibcm-modules/make/Make.lib index d67325c5dd2f..ac81cc134f6d 100644 --- a/platform/broadcom/saibcm-modules/make/Make.lib +++ b/platform/broadcom/saibcm-modules/make/Make.lib @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Make.lib,v 1.14 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. @@ -62,7 +73,7 @@ endif ifeq ($(LINUX_MAKE_SHARED_LIB),1) $(CC) -shared -Wl,-soname,${lib}.${LIBSUFFIX}${EXTRA_LIB_LDFLAGS} -o ${targetlib} ${BOBJS} -lc else - ${Q}cd $(dir $(word 1,${BOBJS}));$(AR) ${ARFLAGS} $@ $(sort $(notdir ${BOBJS})) + $(AR) ${ARFLAGS} $@ $(sort ${BOBJS}) endif endif # !Borland diff --git a/platform/broadcom/saibcm-modules/make/Make.linux b/platform/broadcom/saibcm-modules/make/Make.linux index 81e88daf16bc..ad18872a34eb 100644 --- a/platform/broadcom/saibcm-modules/make/Make.linux +++ b/platform/broadcom/saibcm-modules/make/Make.linux @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # # $Id: Make.linux,v 1.18 Broadcom SDK $ @@ -85,7 +96,7 @@ endif build: $(MAKE) $(CMD) -DELIVER clean C_COMPILER CXX_COMPILER variable mod bcm user issu: +DELIVER clean C_COMPILER CXX_COMPILER variable mod bcm user issu libopennsa: $(MAKE) $(CMD) $@ clean_d: clean diff --git a/platform/broadcom/saibcm-modules/make/Make.subdirs b/platform/broadcom/saibcm-modules/make/Make.subdirs index 1033e296c0a3..374d817d212d 100644 --- a/platform/broadcom/saibcm-modules/make/Make.subdirs +++ b/platform/broadcom/saibcm-modules/make/Make.subdirs @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Make.subdirs,v 1.8 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Make.tools b/platform/broadcom/saibcm-modules/make/Make.tools index 8ed77727fef2..0d55eb2e653a 100644 --- a/platform/broadcom/saibcm-modules/make/Make.tools +++ b/platform/broadcom/saibcm-modules/make/Make.tools @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Make.tools,v 1.2 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-gts b/platform/broadcom/saibcm-modules/make/Makefile.linux-gts index ddc94afa13fe..726dfdf505bd 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-gts +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-gts @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Makefile.linux-xlr-4_19,v 0.1 Broadcom SDK $ # $Copyright: (c) 2015 Broadcom Corp. @@ -37,6 +48,8 @@ # some basic path variables for tools and kernel source, etc # export XLR_TOOLS_BASE = /projects/ntsw-tools/linux/xlr-419 TOOLCHAIN_DIR = $(XLR_TOOLS_BASE)/buildroot/host/usr +# Target machine for EDK-Host defconfig +TARGET_MACHINE ?= x86_64 KERNDIR = $(XLR_TOOLS_BASE)/kernel/linux # set up cross compile prefix, tools dir variables. # @@ -125,12 +138,21 @@ OPENSRC_BUILD ?= fed21-x86_64 # Hardware interface (see $SDKLT/bcma/sys/probe directory) SYSTEM_INTERFACE ?= ngbde +# Support BCMSIM in the same build +ifeq (1,$(BCM_SIM_PATH_SUPPORT)) +EXTRA_SYSTEM_INTERFACES = plisim +endif + # Turn on direct register access if running on real hardware. ifeq (ngbde,$(SYSTEM_INTERFACE)) +# Except if using multiple probe interfaces +ifeq (,$(EXTRA_SYSTEM_INTERFACES)) LTSW_ADD_CPPFLAGS += -DBCMDRD_CONFIG_MEMMAP_DIRECT=1 endif +endif export SYSTEM_INTERFACE +export EXTRA_SYSTEM_INTERFACES endif ifneq ($(targetplat),user) diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc index 7d8adb98de38..fa4911185aa8 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Makefile.linux-iproc Exp $ # $Copyright: (c) 2007 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc-3_14 b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc-3_14 index 723fea6c73cf..8d9f66aa50a0 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc-3_14 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc-3_14 @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Makefile.linux-iproc-3_6,v 1.1 Broadcom SDK $ # $Copyright: (c) 2007 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc-4_4 b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc-4_4 index df31f84e9d8f..bcef1ff69dd4 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc-4_4 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc-4_4 @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Makefile.linux-iproc Exp $ # $Copyright: (c) 2007 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc_64 b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc_64 index dbccd7e25734..247da7386370 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc_64 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc_64 @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Makefile.linux-iproc Exp $ # $Copyright: (c) 2007 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel index 7cbf8451f91e..ccb0c30d2acc 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Makefile.linux-kernel,v 1.27 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-2_6 b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-2_6 index 559f2ae5e5e5..08461e4c4b7c 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-2_6 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-2_6 @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Makefile.linux-kernel-2_6,v 1.40 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-3_6 b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-3_6 index 0d54c4474fc8..528522ec4bd3 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-3_6 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-3_6 @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Makefile.linux-kernel-3_6,v 1.2 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-4_4 b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-4_4 index 0e8e22e1b32d..c02fc0edd89b 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-4_4 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-4_4 @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Makefile.linux-kernel-2_6,v 1.40 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-kmodule b/platform/broadcom/saibcm-modules/make/Makefile.linux-kmodule index 540c497ea258..46caf00f20b5 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-kmodule +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-kmodule @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Makefile.linux-kmodule-3_6,v 1.2 Broadcom SDK $ # $Copyright: (c) 2006 Broadcom Corp. @@ -61,6 +72,13 @@ KERNBLDDIR ?= $(KERNDIR) # kernel symbols. override EXTRA_CFLAGS = -I${SDK}/include -I${SDK}/systems/linux/kernel/modules/include -I${SDK}/systems/bde/linux/include +# +# If, for any reason, the definition of LD was erased, then +# set it, again. +# +ifeq ($(LD),) +LD = $(CROSS_COMPILE)ld +endif # The precopiled object needs a dummy command file to avoid warnings # from the Kbuild scripts (modpost stage). diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-slk b/platform/broadcom/saibcm-modules/make/Makefile.linux-slk index 00131c2f2af9..656835019a05 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-slk +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-slk @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Makefile.linux-slk-3_14,v 1.2 Broadcom SDK $ # $Copyright: (c) 2013 Broadcom Corp. @@ -27,11 +38,15 @@ endif ifeq (BE,$(ENDIAN_MODE)) TOOLCHAIN_BASE_DIR ?= /projects/ntsw-tools/toolchains/slk/linaro-be TARGET_ARCHITECTURE:=aarch64_be-linux-gnu +# Target machine for EDK-Host defconfig +TARGET_MACHINE ?= slk_be KERNDIR ?= /projects/ntsw-tools/linux/iproc_ldks/slk-be/poky/brcm-released-source/git else TOOLCHAIN_BASE_DIR ?= /projects/ntsw-tools/toolchains/slk/linaro-le # Compiler for target architecture TARGET_ARCHITECTURE:= aarch64-linux-gnu +# Target machine for EDK-Host defconfig +TARGET_MACHINE ?= slk_le # Kernel directory KERNDIR ?= /projects/ntsw-tools/linux/iproc_ldks/slk/poky/brcm-released-source/git endif diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-common-2_6 b/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-common-2_6 index 25e953136bc0..dbd51ee1f627 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-common-2_6 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-common-2_6 @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Makefile.linux-x86-common-2_6,v 1.13 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-generic-common-2_6 b/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-generic-common-2_6 index b443a3d4733d..4b02aa53cda8 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-generic-common-2_6 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-generic-common-2_6 @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Makefile.linux-x86-generic-common-2_6,v 1.2 Broadcom SDK $ # $Copyright: (c) 2008 Broadcom Corp. @@ -48,5 +59,4 @@ AUTOCONF = $(KERNDIR)/include/linux/autoconf.h endif # gcc system include path -# SAI_FIXUP /* SDK-218654 */ SYSINC = $(shell $(CC) -print-search-dirs | grep install | cut -c 10-)include 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 8a97f3954301..9df0bee5a774 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 @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Makefile.linux-x86-smp_generic_64-2_6,v 1.5 Broadcom SDK $ # $Copyright: (c) 2008 Broadcom Corp. @@ -25,7 +36,7 @@ CFGFLAGS += -DSAL_SPL_LOCK_ON_IRQ include ${SDK}/make/Makefile.linux-x86-generic-common-2_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 -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 +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) diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-xlr b/platform/broadcom/saibcm-modules/make/Makefile.linux-xlr index ddc94afa13fe..726dfdf505bd 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-xlr +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-xlr @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # $Id: Makefile.linux-xlr-4_19,v 0.1 Broadcom SDK $ # $Copyright: (c) 2015 Broadcom Corp. @@ -37,6 +48,8 @@ # some basic path variables for tools and kernel source, etc # export XLR_TOOLS_BASE = /projects/ntsw-tools/linux/xlr-419 TOOLCHAIN_DIR = $(XLR_TOOLS_BASE)/buildroot/host/usr +# Target machine for EDK-Host defconfig +TARGET_MACHINE ?= x86_64 KERNDIR = $(XLR_TOOLS_BASE)/kernel/linux # set up cross compile prefix, tools dir variables. # @@ -125,12 +138,21 @@ OPENSRC_BUILD ?= fed21-x86_64 # Hardware interface (see $SDKLT/bcma/sys/probe directory) SYSTEM_INTERFACE ?= ngbde +# Support BCMSIM in the same build +ifeq (1,$(BCM_SIM_PATH_SUPPORT)) +EXTRA_SYSTEM_INTERFACES = plisim +endif + # Turn on direct register access if running on real hardware. ifeq (ngbde,$(SYSTEM_INTERFACE)) +# Except if using multiple probe interfaces +ifeq (,$(EXTRA_SYSTEM_INTERFACES)) LTSW_ADD_CPPFLAGS += -DBCMDRD_CONFIG_MEMMAP_DIRECT=1 endif +endif export SYSTEM_INTERFACE +export EXTRA_SYSTEM_INTERFACES endif ifneq ($(targetplat),user) diff --git a/platform/broadcom/saibcm-modules/sdklt/LICENSES/gpl-2.0.txt b/platform/broadcom/saibcm-modules/sdklt/LICENSES/gpl-2.0.txt new file mode 100644 index 000000000000..d159169d1050 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/LICENSES/gpl-2.0.txt @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/platform/broadcom/saibcm-modules/sdklt/Makefile b/platform/broadcom/saibcm-modules/sdklt/Makefile new file mode 100644 index 000000000000..d6f358c55283 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/Makefile @@ -0,0 +1,83 @@ +# +# $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. +# The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# A copy of the GNU General Public License version 2 (GPLv2) can +# be found in the LICENSES folder.$ +# + +help: + @echo '' + @echo 'Build Linux GPL kernel modules for SDKLT.' + @echo '' + @echo 'Available make targets:' + @echo 'kmod - Build kernel modules' + @echo 'clean - Remove object files' + @echo '' + @echo 'Supported make variables:' + @echo 'KDIR - Linux kernel source directory (mandatory)' + @echo 'CROSS_COPILE - Cross-compiler prefix (optional)' + @echo '' + @echo 'Examples:' + @echo 'make -s KDIR=$$KERNEL/linux kmod' + @echo 'make -s clean' + @echo '' + +ifndef KDIR +nokdir: + @echo 'Error: The $$KDIR environment variable is not set.' + @echo '$$KDIR must point to a configured Linux kernel source tree.' + exit 1 +endif + +export KDIR +export CROSS_COMPILE + +override SDK := $(CURDIR) + +ifeq ($(BUILD_PSAMPLE),1) +PSAMPLE=psample +PSAMPLE_SYMVERS=$(SDK)/linux/psample/Module.symvers +endif + +kmod: bde knet knetcb $(PSAMPLE) + +bde: + $(MAKE) -C $(SDK)/linux/bde SDK=$(SDK) \ + $(TARGET) + ln -sf $(SDK)/linux/bde/*.ko + +knet: bde + $(MAKE) -C $(SDK)/linux/knet SDK=$(SDK) \ + KBUILD_EXTRA_SYMBOLS=$(SDK)/linux/bde/Module.symvers \ + $(TARGET) + ln -sf $(SDK)/linux/knet/*.ko + +knetcb: knet $(PSAMPLE) + $(MAKE) -C $(SDK)/linux/knetcb SDK=$(SDK) \ + KBUILD_EXTRA_SYMBOLS=$(SDK)/linux/knet/Module.symvers \ + KBUILD_EXTRA_SYMBOLS+=$(PSAMPLE_SYMVERS) \ + $(TARGET) + ln -sf $(SDK)/linux/knetcb/*.ko + +ifeq ($(BUILD_PSAMPLE),1) +$(PSAMPLE): + $(MAKE) -C $(SDK)/linux/psample SDK=$(SDK) \ + $(TARGET) + ln -sf $(SDK)/linux/psample/*.ko +endif + +clean: + $(MAKE) kmod TARGET=clean + rm -f *.ko + +.PHONY: help kmod bde knet knetcb $(PSAMPLE) clean diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56780_a0/bcm56780_a0_pdma_attach.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56780_a0/bcm56780_a0_pdma_attach.c new file mode 100644 index 000000000000..e06dcb68bfc8 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56780_a0/bcm56780_a0_pdma_attach.c @@ -0,0 +1,38 @@ +/*! \file bcm56780_a0_pdma_attach.c + * + * Initialize PDMA driver resources. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include + +int +bcm56780_a0_cnet_pdma_attach(struct pdma_dev *dev) +{ + return bcmcnet_cmicx_pdma_driver_attach(dev); +} + +int +bcm56780_a0_cnet_pdma_detach(struct pdma_dev *dev) +{ + return bcmcnet_cmicx_pdma_driver_detach(dev); +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56880_a0/bcm56880_a0_pdma_attach.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56880_a0/bcm56880_a0_pdma_attach.c new file mode 100644 index 000000000000..9a2152e99ac0 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56880_a0/bcm56880_a0_pdma_attach.c @@ -0,0 +1,38 @@ +/*! \file bcm56880_a0_pdma_attach.c + * + * Initialize PDMA driver resources. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include + +int +bcm56880_a0_cnet_pdma_attach(struct pdma_dev *dev) +{ + return bcmcnet_cmicx_pdma_driver_attach(dev); +} + +int +bcm56880_a0_cnet_pdma_detach(struct pdma_dev *dev) +{ + return bcmcnet_cmicx_pdma_driver_detach(dev); +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56990_a0/bcm56990_a0_pdma_attach.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56990_a0/bcm56990_a0_pdma_attach.c new file mode 100644 index 000000000000..7827ef25de3d --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56990_a0/bcm56990_a0_pdma_attach.c @@ -0,0 +1,38 @@ +/*! \file bcm56990_a0_pdma_attach.c + * + * Initialize PDMA driver resources. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include + +int +bcm56990_a0_cnet_pdma_attach(struct pdma_dev *dev) +{ + return bcmcnet_cmicx_pdma_driver_attach(dev); +} + +int +bcm56990_a0_cnet_pdma_detach(struct pdma_dev *dev) +{ + return bcmcnet_cmicx_pdma_driver_detach(dev); +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56990_b0/bcm56990_b0_pdma_attach.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56990_b0/bcm56990_b0_pdma_attach.c new file mode 100644 index 000000000000..e34ae1f0b45c --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56990_b0/bcm56990_b0_pdma_attach.c @@ -0,0 +1,38 @@ +/*! \file bcm56990_b0_pdma_attach.c + * + * Initialize PDMA driver resources. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include + +int +bcm56990_b0_cnet_pdma_attach(struct pdma_dev *dev) +{ + return bcmcnet_cmicx_pdma_driver_attach(dev); +} + +int +bcm56990_b0_cnet_pdma_detach(struct pdma_dev *dev) +{ + return bcmcnet_cmicx_pdma_driver_detach(dev); +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56996_a0/bcm56996_a0_pdma_attach.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56996_a0/bcm56996_a0_pdma_attach.c new file mode 100644 index 000000000000..aab5822f68b7 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56996_a0/bcm56996_a0_pdma_attach.c @@ -0,0 +1,38 @@ +/*! \file bcm56996_a0_pdma_attach.c + * + * Initialize PDMA driver resources. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include + +int +bcm56996_a0_cnet_pdma_attach(struct pdma_dev *dev) +{ + return bcmcnet_cmicx_pdma_driver_attach(dev); +} + +int +bcm56996_a0_cnet_pdma_detach(struct pdma_dev *dev) +{ + return bcmcnet_cmicx_pdma_driver_detach(dev); +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicd/bcmcnet_cmicd_pdma_hw.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicd/bcmcnet_cmicd_pdma_hw.c new file mode 100644 index 000000000000..83ce4d11b97f --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicd/bcmcnet_cmicd_pdma_hw.c @@ -0,0 +1,530 @@ +/*! \file bcmcnet_cmicd_pdma_hw.c + * + * Utility routines for handling BCMCNET hardware (CMICd). + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include +#include + +/*! + * Read 32-bit register + */ +static inline void +cmicd_pdma_reg_read32(struct pdma_hw *hw, uint32_t addr, uint32_t *data) +{ + if (hw->dev->dev_read32) { + hw->dev->dev_read32(hw->dev, addr, data); + } else { + DEV_READ32(&hw->dev->ctrl, addr, data); + } +} + +/*! + * Write 32-bit register + */ +static inline void +cmicd_pdma_reg_write32(struct pdma_hw *hw, uint32_t addr, uint32_t data) +{ + if (hw->dev->dev_write32) { + hw->dev->dev_write32(hw->dev, addr, data); + } else { + DEV_WRITE32(&hw->dev->ctrl, addr, data); + } +} + +/*! + * Enable interrupt for a channel + */ +static inline void +cmicd_pdma_intr_enable(struct pdma_hw *hw, int cmc, int chan, uint32_t mask) +{ + uint32_t reg = CMICD_IRQ_STAT(cmc); + + hw->dev->intr_unmask(hw->dev, cmc, chan, reg, mask); +} + +/*! + * Disable interrupt for a channel + */ +static inline void +cmicd_pdma_intr_disable(struct pdma_hw *hw, int cmc, int chan, uint32_t mask) +{ + uint32_t reg = CMICD_IRQ_STAT(cmc); + + hw->dev->intr_mask(hw->dev, cmc, chan, reg, mask); +} + +/*! + * Initialize HW + */ +static int +cmicd_pdma_hw_init(struct pdma_hw *hw) +{ + dev_mode_t mode = DEV_MODE_MAX; + uint32_t val; + + /* Temporarily upgrade work mode to get HW information in VNET mode. */ + if (hw->dev->mode == DEV_MODE_VNET) { + mode = DEV_MODE_VNET; + hw->dev->mode = DEV_MODE_UNET; + } + + /* Release credits to EP. Only do this once when HW is initialized. */ + hw->hdls.reg_rd32(hw, CMICD_EPINTF_RELEASE_CREDITS, &val); + if (!val) { + hw->hdls.reg_wr32(hw, CMICD_EPINTF_RELEASE_CREDITS, 1); + } + + hw->info.name = CMICD_DEV_NAME; + hw->hdls.reg_rd32(hw, CMICD_CMICM_REV_ID, &val); + hw->info.ver_no = val; + hw->hdls.reg_rd32(hw, CMICD_DEV_REV_ID, &val); + hw->info.dev_id = val & 0xffff; + hw->info.rev_id = val >> 16; + hw->info.num_cmcs = CMICD_PDMA_CMC_MAX; + hw->info.cmc_chans = CMICD_PDMA_CMC_CHAN; + hw->info.num_chans = CMICD_PDMA_CMC_MAX * CMICD_PDMA_CMC_CHAN; + hw->info.rx_dcb_size = CMICD_PDMA_DCB_SIZE; + hw->info.tx_dcb_size = CMICD_PDMA_DCB_SIZE; + hw->info.rx_ph_size = 0; + hw->info.tx_ph_size = 0; + + /* Restore work mode to VNET. */ + if (mode == DEV_MODE_VNET) { + hw->dev->mode = DEV_MODE_VNET; + } + + return SHR_E_NONE; +} + +/*! + * Configure HW + */ +static int +cmicd_pdma_hw_config(struct pdma_hw *hw) +{ + struct dev_ctrl *ctrl = &hw->dev->ctrl; + struct pdma_rx_queue *rxq = NULL; + struct pdma_tx_queue *txq = NULL; + uint32_t val, que_ctrl; + int grp, que; + uint32_t qi; + + for (qi = 0; qi < ctrl->nb_rxq; qi++) { + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[qi]; + grp = rxq->group_id; + que = rxq->chan_id % CMICD_PDMA_CMC_CHAN; + que_ctrl = ctrl->grp[grp].que_ctrl[que]; + + hw->hdls.reg_wr32(hw, CMICD_PDMA_STAT_CLR(grp), CMICD_PDMA_DESC_CMPLT(que)); + hw->hdls.reg_wr32(hw, CMICD_PDMA_STAT_CLR(grp), CMICD_PDMA_DESC_CNTLD(que)); + val = 0; + if (que_ctrl & PDMA_PKT_BYTE_SWAP) { + val |= CMICD_PDMA_PKT_BIG_ENDIAN; + } + if (que_ctrl & PDMA_OTH_BYTE_SWAP) { + val |= CMICD_PDMA_DESC_BIG_ENDIAN; + } + if (!(hw->dev->flags & PDMA_CHAIN_MODE)) { + val |= CMICD_PDMA_CONTINUOUS; + } + val |= CMICD_PDMA_CNTLD_INTR; + val &= ~CMICD_PDMA_DIR; + hw->hdls.reg_wr32(hw, CMICD_PDMA_CTRL(grp, que), val); + } + + for (qi = 0; qi < ctrl->nb_txq; qi++) { + txq = (struct pdma_tx_queue *)ctrl->tx_queue[qi]; + grp = txq->group_id; + que = txq->chan_id % CMICD_PDMA_CMC_CHAN; + que_ctrl = ctrl->grp[grp].que_ctrl[que]; + + hw->hdls.reg_wr32(hw, CMICD_PDMA_STAT_CLR(grp), CMICD_PDMA_DESC_CMPLT(que)); + hw->hdls.reg_wr32(hw, CMICD_PDMA_STAT_CLR(grp), CMICD_PDMA_DESC_CNTLD(que)); + val = 0; + if (que_ctrl & PDMA_PKT_BYTE_SWAP) { + val |= CMICD_PDMA_PKT_BIG_ENDIAN; + } + if (que_ctrl & PDMA_OTH_BYTE_SWAP) { + val |= CMICD_PDMA_DESC_BIG_ENDIAN; + } + if (!(hw->dev->flags & PDMA_CHAIN_MODE)) { + val |= CMICD_PDMA_CONTINUOUS; + } + val |= CMICD_PDMA_CNTLD_INTR | CMICD_PDMA_DIR; + hw->hdls.reg_wr32(hw, CMICD_PDMA_CTRL(grp, que), val); + } + + return SHR_E_NONE; +} + +/*! + * Reset HW + */ +static int +cmicd_pdma_hw_reset(struct pdma_hw *hw) +{ + int gi, qi; + + for (gi = 0; gi < hw->dev->num_groups; gi++) { + if (!hw->dev->ctrl.grp[gi].attached) { + continue; + } + for (qi = 0; qi < CMICD_PDMA_CMC_CHAN; qi++) { + if (1 << qi & hw->dev->ctrl.grp[gi].bm_rxq || + 1 << qi & hw->dev->ctrl.grp[gi].bm_txq) { + hw->hdls.reg_wr32(hw, CMICD_PDMA_CTRL(gi, qi), 0); + } + } + } + + return SHR_E_NONE; +} + +/*! + * Start a channel + */ +static int +cmicd_pdma_chan_start(struct pdma_hw *hw, int chan) +{ + uint32_t val; + int grp, que; + + grp = chan / CMICD_PDMA_CMC_CHAN; + que = chan % CMICD_PDMA_CMC_CHAN; + + hw->hdls.reg_rd32(hw, CMICD_PDMA_CTRL(grp, que), &val); + val |= CMICD_PDMA_ENABLE; + hw->hdls.reg_wr32(hw, CMICD_PDMA_CTRL(grp, que), val); + + MEMORY_BARRIER; + + return SHR_E_NONE; +} + +/*! + * Stop a channel + */ +static int +cmicd_pdma_chan_stop(struct pdma_hw *hw, int chan) +{ + uint32_t val; + int grp, que; + int retry = CMICD_HW_RETRY_TIMES; + + grp = chan / CMICD_PDMA_CMC_CHAN; + que = chan % CMICD_PDMA_CMC_CHAN; + + hw->hdls.reg_rd32(hw, CMICD_PDMA_CTRL(grp, que), &val); + val |= CMICD_PDMA_ENABLE | CMICD_PDMA_ABORT; + hw->hdls.reg_wr32(hw, CMICD_PDMA_CTRL(grp, que), val); + + MEMORY_BARRIER; + + do { + val = ~CMICD_PDMA_ACTIVE(que); + hw->hdls.reg_rd32(hw, CMICD_PDMA_STAT(grp), &val); + } while ((val & CMICD_PDMA_ACTIVE(que)) && (--retry > 0)); + + hw->hdls.reg_rd32(hw, CMICD_PDMA_CTRL(grp, que), &val); + val &= ~(CMICD_PDMA_ENABLE | CMICD_PDMA_ABORT); + hw->hdls.reg_wr32(hw, CMICD_PDMA_CTRL(grp, que), val); + + hw->hdls.reg_wr32(hw, CMICD_PDMA_STAT_CLR(grp), CMICD_PDMA_DESC_CNTLD(que)); + + MEMORY_BARRIER; + + return SHR_E_NONE; +} + +/*! + * Setup a channel + */ +static int +cmicd_pdma_chan_setup(struct pdma_hw *hw, int chan, uint64_t addr) +{ + int grp, que; + + grp = chan / CMICD_PDMA_CMC_CHAN; + que = chan % CMICD_PDMA_CMC_CHAN; + + hw->hdls.reg_wr32(hw, CMICD_PDMA_DESC(grp, que), addr); + + MEMORY_BARRIER; + + return SHR_E_NONE; +} + +/*! + * Set halt point for a channel + */ +static int +cmicd_pdma_chan_goto(struct pdma_hw *hw, int chan, uint64_t addr) +{ + int grp, que; + + grp = chan / CMICD_PDMA_CMC_CHAN; + que = chan % CMICD_PDMA_CMC_CHAN; + + hw->hdls.reg_wr32(hw, CMICD_PDMA_DESC_HALT(grp, que), addr); + + MEMORY_BARRIER; + + return SHR_E_NONE; +} + +/*! + * Clear a channel + */ +static int +cmicd_pdma_chan_clear(struct pdma_hw *hw, int chan) +{ + int grp, que; + + grp = chan / CMICD_PDMA_CMC_CHAN; + que = chan % CMICD_PDMA_CMC_CHAN; + + hw->hdls.reg_wr32(hw, CMICD_PDMA_STAT_CLR(grp), CMICD_PDMA_DESC_CNTLD(que)); + + MEMORY_BARRIER; + + return SHR_E_NONE; +} + +/*! + * Get interrupt number for a channel + */ +static int +cmicd_pdma_chan_intr_num_get(struct pdma_hw *hw, int chan) +{ + int grp, que, start_num, mask_shift; + + grp = chan / CMICD_PDMA_CMC_CHAN; + que = chan % CMICD_PDMA_CMC_CHAN; + + mask_shift = 0; + if (grp > 0) { + mask_shift = CMICD_IRQ_MASK_SHIFT + grp * 32; + } + start_num = CMICD_IRQ_START_NUM + mask_shift; + + return start_num + (que * CMICD_IRQ_NUM_OFFSET); +} + +/*! + * Enable interrupt for a channel + */ +static int +cmicd_pdma_chan_intr_enable(struct pdma_hw *hw, int chan) +{ + int grp, que; + + grp = chan / CMICD_PDMA_CMC_CHAN; + que = chan % CMICD_PDMA_CMC_CHAN; + + cmicd_pdma_intr_enable(hw, grp, que, CMICD_IRQ_DESC_CNTLD(que)); + + return SHR_E_NONE; +} + +/*! + * Disable interrupt for a channel + */ +static int +cmicd_pdma_chan_intr_disable(struct pdma_hw *hw, int chan) +{ + int grp, que; + + grp = chan / CMICD_PDMA_CMC_CHAN; + que = chan % CMICD_PDMA_CMC_CHAN; + + cmicd_pdma_intr_disable(hw, grp, que, CMICD_IRQ_DESC_CNTLD(que)); + + return SHR_E_NONE; +} + +/*! + * Query interrupt status for a channel + * + * In group mode (interrupt processing per CMC), need to query each channel's + * interrupt status. + * + */ +static int +cmicd_pdma_chan_intr_query(struct pdma_hw *hw, int chan) +{ + uint32_t val; + int grp, que; + + grp = chan / CMICD_PDMA_CMC_CHAN; + que = chan % CMICD_PDMA_CMC_CHAN; + + hw->hdls.reg_rd32(hw, CMICD_IRQ_STAT(grp), &val); + + return val & CMICD_IRQ_DESC_CNTLD(que); +} + +/*! + * Check interrupt validity for a channel + * + * In group mode (interrupt processing per CMC), need to check each channel's + * interrupt validity based on its interrupt mask. + * + */ +static int +cmicd_pdma_chan_intr_check(struct pdma_hw *hw, int chan) +{ + int grp, que; + + grp = chan / CMICD_PDMA_CMC_CHAN; + que = chan % CMICD_PDMA_CMC_CHAN; + + if (!(hw->dev->ctrl.grp[grp].irq_mask & CMICD_IRQ_DESC_CNTLD(que))) { + return 0; + } + + return cmicd_pdma_chan_intr_query(hw, chan); +} + +/*! + * Coalesce interrupt for a channel + */ +static int +cmicd_pdma_chan_intr_coalesce(struct pdma_hw *hw, int chan, int count, int timer) +{ + uint32_t val; + int grp, que; + + grp = chan / CMICD_PDMA_CMC_CHAN; + que = chan % CMICD_PDMA_CMC_CHAN; + + val = CMICD_PDMA_INTR_COAL_ENA | + CMICD_PDMA_INTR_THRESH(count) | + CMICD_PDMA_INTR_TIMER(timer); + hw->hdls.reg_wr32(hw, CMICD_PDMA_INTR_COAL(grp, que), val); + + return SHR_E_NONE; +} + +/*! + * Dump registers for a channel + */ +static int +cmicd_pdma_chan_reg_dump(struct pdma_hw *hw, int chan) +{ + uint32_t val; + int grp, que; + + grp = chan / CMICD_PDMA_CMC_CHAN; + que = chan % CMICD_PDMA_CMC_CHAN; + + hw->hdls.reg_rd32(hw, CMICD_PDMA_CTRL(grp, que), &val); + CNET_PR("CMIC_CMC%d_CH%d_DMA_CTRL: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICD_PDMA_DESC(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_DESC%d: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICD_PDMA_CURR_DESC(grp, que), &val); + CNET_PR("CMIC_CMC%d_CH%d_DMA_CURR_DESC: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICD_PDMA_DESC_HALT(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_CH%d_DESC_HALT_ADDR: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICD_PDMA_COS_RX0(grp, que), &val); + CNET_PR("CMIC_CMC%d_CH%d_COS_CTRL_RX_0: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICD_PDMA_COS_RX1(grp, que), &val); + CNET_PR("CMIC_CMC%d_CH%d_COS_CTRL_RX_1: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICD_PDMA_COS_MASK0(grp), &val); + CNET_PR("CMIC_CMC%d_PROGRAMMABLE_COS_MASK0: 0x%08x\n", grp, val); + + hw->hdls.reg_rd32(hw, CMICD_PDMA_COS_MASK1(grp), &val); + CNET_PR("CMIC_CMC%d_PROGRAMMABLE_COS_MASK1: 0x%08x\n", grp, val); + + hw->hdls.reg_rd32(hw, CMICD_PDMA_INTR_COAL(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_CH%d_INTR_COAL: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICD_PDMA_RBUF_THRE(grp, que), &val); + CNET_PR("CMIC_CMC%d_CH%d_RXBUF_THRESHOLD_CONFIG: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICD_PDMA_STAT(grp), &val); + CNET_PR("CMIC_CMC%d_DMA_STAT: 0x%08x\n", grp, val); + + hw->hdls.reg_rd32(hw, CMICD_PDMA_STAT_HI(grp), &val); + CNET_PR("CMIC_CMC%d_DMA_STAT_HI: 0x%08x\n", grp, val); + + hw->hdls.reg_rd32(hw, CMICD_PDMA_STAT_CLR(grp), &val); + CNET_PR("CMIC_CMC%d_DMA_STAT_CLR: 0x%08x\n", grp, val); + + hw->hdls.reg_rd32(hw, CMICD_PDMA_COUNT_RX(grp, que), &val); + CNET_PR("CMIC_CMC%d_PKT_COUNT_CH%d_RXPKT: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICD_PDMA_COUNT_TX(grp, que), &val); + CNET_PR("CMIC_CMC%d_PKT_COUNT_CH%d_TXPKT: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICD_IRQ_STAT(grp), &val); + CNET_PR("CMIC_CMC%d_IRQ_STAT0: 0x%08x\n", grp, val); + + hw->hdls.reg_rd32(hw, CMICD_IRQ_PCI_MASK(grp), &val); + CNET_PR("CMIC_CMC%d_PCIE_IRQ_MASK0: 0x%08x\n", grp, val); + + hw->hdls.reg_rd32(hw, CMICD_DEV_REV_ID, &val); + CNET_PR("CMIC_DEV_REV_ID: 0x%08x\n", val); + + hw->hdls.reg_rd32(hw, CMICD_CMICM_REV_ID, &val); + CNET_PR("CMIC_CMICM_REV_ID: 0x%08x\n", val); + + return SHR_E_NONE; +} + +/*! + * Initialize function pointers + */ +int +bcmcnet_cmicd_pdma_hw_hdls_init(struct pdma_hw *hw) +{ + if (!hw) { + return SHR_E_PARAM; + } + + hw->hdls.reg_rd32 = cmicd_pdma_reg_read32; + hw->hdls.reg_wr32 = cmicd_pdma_reg_write32; + hw->hdls.hw_init = cmicd_pdma_hw_init; + hw->hdls.hw_config = cmicd_pdma_hw_config; + hw->hdls.hw_reset = cmicd_pdma_hw_reset; + hw->hdls.chan_start = cmicd_pdma_chan_start; + hw->hdls.chan_stop = cmicd_pdma_chan_stop; + hw->hdls.chan_setup = cmicd_pdma_chan_setup; + hw->hdls.chan_goto = cmicd_pdma_chan_goto; + hw->hdls.chan_clear = cmicd_pdma_chan_clear; + hw->hdls.chan_intr_num_get = cmicd_pdma_chan_intr_num_get; + hw->hdls.chan_intr_enable = cmicd_pdma_chan_intr_enable; + hw->hdls.chan_intr_disable = cmicd_pdma_chan_intr_disable; + hw->hdls.chan_intr_query = cmicd_pdma_chan_intr_query; + hw->hdls.chan_intr_check = cmicd_pdma_chan_intr_check; + hw->hdls.chan_intr_coalesce = cmicd_pdma_chan_intr_coalesce; + hw->hdls.chan_reg_dump = cmicd_pdma_chan_reg_dump; + + return SHR_E_NONE; +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicd/bcmcnet_cmicd_pdma_rxtx.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicd/bcmcnet_cmicd_pdma_rxtx.c new file mode 100644 index 000000000000..c4a10e160db9 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicd/bcmcnet_cmicd_pdma_rxtx.c @@ -0,0 +1,1062 @@ +/*! \file bcmcnet_cmicd_pdma_rxtx.c + * + * Utility routines for BCMCNET hardware (CMICd) specific Rx/Tx. + * + * Here are the CMIC specific Rx/Tx routines including DCBs resource allocation + * and clean up, DCBs configuration, Rx buffers allocation, Tx buffers release, + * Rx/Tx packets processing, etc. + * They are shared among all the modes (UNET, KNET, VNET, HNET) and in both of + * user space and kernel space. + * + * The driver uses a ring of DCBs per DMA channel based on Continuous DMA mode. + * The beginning is written to register pointing to the physical address of the + * start of the ring. The ring size is maintained by the driver. A HALT DCB + * physical address is written to DMA register timely to indicate how many DCBs + * can be handled by HW. + * + * When a packet is received, an interrupt is triggered. The handler will go + * through the Rx DCB ring to process the current completed DCB and every + * subsequent DCBs until no one is left. The received packet is processed and + * passed up to the high level SW. After that, a new buffer is allocated and + * the DCB is updated for receiving a new packet. A new HALT DCB is selected + * and its physical address is written to DMA register. + * + * When a packet is transmitted, the driver starts where it left off last time + * in the Tx DCB ring, updates the DCB and writes its physical address to DMA + * register so as to start DMA. Once the transmitting is finished, the handler + * is informed to clean up the buffer based on the work mode. In KNET or HNET + * mode, an interrupt will be triggered. Polling mode is used in CNET or VNET + * mode, the buffers will be cleaned up when the number of dirty DCBs reaches + * a pre-defined threshold. + * + * In VNET and HNET modes, DCB updating between virtual ring and real ring and + * a IOCTL based notification mechanism are involved. The hypervisor in kernel + * emulates the DMA HW behaviors to update DCBs in virtual network and inform + * the handler something happened. Likewise, the hypervisor updates itself real + * DCB ring from the virtual ring to start DMA for transmitting a packet once a + * notification is received from the virtual network. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include +#include +#include + +/*! + * Configure Rx descriptor + */ +static inline void +cmicd_rx_desc_config(struct cmicd_rx_desc *rd, uint32_t addr, uint32_t len) +{ + rd->addr = addr; + rd->md.status = 0; + rd->ctrl = CMICD_DESC_CTRL_CNTLD_INTR | CMICD_DESC_CTRL_CHAIN | + CMICD_DESC_CTRL_LEN(len); +} + +/*! + * Configure Tx descriptor + */ +static inline void +cmicd_tx_desc_config(struct cmicd_tx_desc *td, uint32_t addr, uint32_t len, uint32_t flags) +{ + td->addr = addr; + td->md.status = 0; + td->ctrl = CMICD_DESC_CTRL_CNTLD_INTR | CMICD_DESC_CTRL_CHAIN | + CMICD_DESC_CTRL_FLAGS(flags) | CMICD_DESC_CTRL_LEN(len); +} + +/*! + * Configure Rx reload descriptor + */ +static inline void +cmicd_rx_rldesc_config(struct cmicd_rx_desc *rd, uint32_t addr) +{ + rd->addr = addr; + rd->md.status = 0; + rd->ctrl = CMICD_DESC_CTRL_CNTLD_INTR | CMICD_DESC_CTRL_CHAIN | + CMICD_DESC_CTRL_RELOAD; +} + +/*! + * Configure Tx reload descriptor + */ +static inline void +cmicd_tx_rldesc_config(struct cmicd_tx_desc *td, uint32_t addr) +{ + td->addr = addr; + td->md.status = 0; + td->ctrl = CMICD_DESC_CTRL_CNTLD_INTR | CMICD_DESC_CTRL_CHAIN | + CMICD_DESC_CTRL_RELOAD; +} + +/*! + * Chain Rx descriptor + */ +static inline void +cmicd_rx_desc_chain(struct cmicd_rx_desc *rd, int chain) +{ + if (chain) { + rd->ctrl |= CMICD_DESC_CTRL_CHAIN; + } else { + rd->ctrl &= ~CMICD_DESC_CTRL_CHAIN; + } +} + +/*! + * Chain Tx descriptor + */ +static inline void +cmicd_tx_desc_chain(struct cmicd_tx_desc *td, int chain) +{ + if (chain) { + td->ctrl |= CMICD_DESC_CTRL_CHAIN; + } else { + td->ctrl &= ~CMICD_DESC_CTRL_CHAIN; + } +} + +/*! + * Get unused descriptors in a Rx ring + */ +static inline int +cmicd_pdma_rx_ring_unused(struct pdma_rx_queue *rxq) +{ + /* Leave one descriptor unused so as not to halt */ + return rxq->curr > rxq->halt ? + rxq->curr - rxq->halt - 1 : + rxq->nb_desc + rxq->curr - rxq->halt - 1; +} + +/*! + * Get unused descriptors in a Tx ring + */ +static inline int +cmicd_pdma_tx_ring_unused(struct pdma_tx_queue *txq) +{ + /* Leave one descriptor unused so as not to halt */ + return txq->dirt > txq->curr ? + txq->dirt - txq->curr - 1 : + txq->nb_desc + txq->dirt - txq->curr - 1; +} + +/*! + * Initialize Rx descriptors + */ +static int +cmicd_pdma_rx_desc_init(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + struct cmicd_rx_desc *ring = (struct cmicd_rx_desc *)rxq->ring; + dma_addr_t addr; + uint32_t di; + int rv; + + for (di = 0; di < rxq->nb_desc; di++) { + if (!rxq->pbuf[di].dma) { + /* Allocate pktbuf for ring entry */ + rxq->pbuf[di].adj = CMICD_RX_META_RESV; + rv = bm->rx_buf_alloc(dev, rxq, &rxq->pbuf[di]); + if (SHR_FAILURE(rv)) { + goto cleanup; + } + } + /* Config receive descriptor ring */ + bm->rx_buf_dma(dev, rxq, &rxq->pbuf[di], &addr); + cmicd_rx_desc_config(&ring[di], addr, rxq->buf_size); + if (hw->dev->flags & PDMA_CHAIN_MODE && di == rxq->nb_desc - 1) { + cmicd_rx_desc_chain(&ring[di], 0); + } + } + /* Config the last descriptor in the ring as reload descriptor */ + cmicd_rx_rldesc_config(&ring[di], rxq->ring_addr); + + rxq->curr = 0; + rxq->halt = rxq->state & PDMA_RX_BATCH_REFILL ? 0 : rxq->nb_desc; + + rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicd_rx_desc) * di; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + hw->hdls.chan_setup(hw, rxq->chan_id, rxq->ring_addr); + + return SHR_E_NONE; + +cleanup: + for (di = 0; di < rxq->nb_desc; di++) { + if (rxq->pbuf[di].dma) { + bm->rx_buf_free(dev, rxq, &rxq->pbuf[di]); + } + cmicd_rx_desc_config(&ring[di], 0, 0); + } + + CNET_PR("RX: Failed to allocate mem\n"); + + return SHR_E_MEMORY; +} + +/*! + * Cleanup Rx descriptors + */ +static int +cmicd_pdma_rx_desc_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + struct cmicd_rx_desc *ring = (struct cmicd_rx_desc *)rxq->ring; + uint32_t di; + + /* Go through all the descriptors and free pktbuf */ + for (di = 0; di < rxq->nb_desc; di++) { + if (rxq->pbuf[di].dma) { + bm->rx_buf_free(dev, rxq, &rxq->pbuf[di]); + } + cmicd_rx_desc_config(&ring[di], 0, 0); + } + + rxq->curr = 0; + rxq->halt = 0; + + return SHR_E_NONE; +} + +/*! + * Initialize Tx descriptors + */ +static int +cmicd_pdma_tx_desc_init(struct pdma_hw *hw, struct pdma_tx_queue *txq) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + struct cmicd_tx_desc *ring = (struct cmicd_tx_desc *)txq->ring; + uint32_t di; + + for (di = 0; di < txq->nb_desc; di++) { + if (txq->pbuf[di].dma) { + bm->tx_buf_free(dev, txq, &txq->pbuf[di]); + } + /* Config transmit descriptor ring */ + cmicd_tx_desc_config(&ring[di], 0, 0, 0); + if (hw->dev->flags & PDMA_CHAIN_MODE) { + cmicd_tx_desc_chain(&ring[di], 0); + } + } + /* Config the last descriptor in the ring as reload descriptor */ + cmicd_tx_rldesc_config(&ring[di], txq->ring_addr); + + txq->curr = 0; + txq->dirt = 0; + txq->halt = 0; + + txq->halt_addr = txq->ring_addr; + hw->hdls.chan_goto(hw, txq->chan_id, txq->halt_addr); + hw->hdls.chan_setup(hw, txq->chan_id, txq->ring_addr); + + return SHR_E_NONE; +} + +/*! + * Cleanup Tx descriptors + */ +static int +cmicd_pdma_tx_desc_clean(struct pdma_hw *hw, struct pdma_tx_queue *txq) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + struct cmicd_tx_desc *ring = (struct cmicd_tx_desc *)txq->ring; + uint32_t di; + + /* Go through all the descriptors and free pktbuf */ + for (di = 0; di < txq->nb_desc; di++) { + if (txq->pbuf[di].dma) { + bm->tx_buf_free(dev, txq, &txq->pbuf[di]); + } + cmicd_tx_desc_config(&ring[di], 0, 0, 0); + } + + txq->curr = 0; + txq->dirt = 0; + txq->halt = 0; + + return SHR_E_NONE; +} + +/*! + * Process Rx vring + */ +static int +cmicd_pdma_rx_vring_process(struct pdma_hw *hw, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf) +{ + struct pdma_dev *dev = hw->dev; + struct cmicd_rx_desc *ring = (struct cmicd_rx_desc *)rxq->ring; + struct pdma_rx_queue *vrxq = NULL; + struct cmicd_rx_desc *vring = NULL; + struct pkt_hdr *pkh = &pbuf->pkb->pkh; + + vrxq = (struct pdma_rx_queue *)dev->ctrl.vnet_rxq[rxq->queue_id]; + vring = (struct cmicd_rx_desc *)vrxq->ring; + if (!vring) { + rxq->stats.dropped++; + return SHR_E_UNAVAIL; + } + + if (vring[vrxq->curr].md.status & CMICD_DESC_STAT_RTX_DONE) { + dev->xnet_wake(dev); + return SHR_E_BUSY; + } + + /* Copy descriptor and packet to vring */ + sal_memcpy(dev->sys_p2v(dev, (uint64_t)vring[vrxq->curr].addr), + &pbuf->pkb->data + pkh->meta_len, pkh->data_len); + sal_memcpy(&vring[vrxq->curr].md, &ring[rxq->curr].md, + sizeof(((struct rx_metadata *)0)->data)); + vring[vrxq->curr].md.status = ring[rxq->curr].md.status; + + MEMORY_BARRIER; + + /* Notify VNET to process if needed */ + if (!vring[(vrxq->curr + vrxq->nb_desc - 1) % vrxq->nb_desc].md.status) { + dev->xnet_wake(dev); + } + vrxq->curr = (vrxq->curr + 1) % vrxq->nb_desc; + + return SHR_E_NONE; +} + +/*! + * Refill Rx ring + */ +static int +cmicd_pdma_rx_ring_refill(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + struct cmicd_rx_desc *ring = (struct cmicd_rx_desc *)rxq->ring; + struct pdma_rx_buf *pbuf = NULL; + int unused = cmicd_pdma_rx_ring_unused(rxq); + dma_addr_t addr; + uint32_t halt; + int rv; + + for (halt = rxq->halt; halt < rxq->halt + unused; halt++) { + pbuf = &rxq->pbuf[halt % rxq->nb_desc]; + /* Allocate a new pktbuf */ + if (!bm->rx_buf_avail(dev, rxq, pbuf)) { + rv = bm->rx_buf_alloc(dev, rxq, pbuf); + if (SHR_FAILURE(rv)) { + rxq->halt = halt % rxq->nb_desc; + rxq->stats.nomems++; + goto fail; + } + } + /* Setup the new descriptor */ + bm->rx_buf_dma(dev, rxq, pbuf, &addr); + cmicd_rx_desc_config(&ring[halt % rxq->nb_desc], addr, rxq->buf_size); + if (dev->flags & PDMA_CHAIN_MODE && halt % rxq->nb_desc == rxq->nb_desc - 1) { + cmicd_rx_desc_chain(&ring[halt % rxq->nb_desc], 0); + } + } + + sal_spinlock_lock(rxq->lock); + rxq->halt = halt % rxq->nb_desc; + if (!(rxq->state & PDMA_RX_QUEUE_XOFF)) { + /* Descriptor cherry pick */ + rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicd_rx_desc) * rxq->halt; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + } + sal_spinlock_unlock(rxq->lock); + + return SHR_E_NONE; + +fail: + CNET_PR("RX: Failed to allocate mem\n"); + + return SHR_E_MEMORY; +} + +/*! + * \brief Clean Rx ring + * + * \param [in] hw HW structure point. + * \param [in] rxq Rx queue structure point. + * \param [in] budget Polling budget. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +cmicd_pdma_rx_ring_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq, int budget) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + struct cmicd_rx_desc *ring = (struct cmicd_rx_desc *)rxq->ring; + struct pdma_rx_buf *pbuf = NULL; + struct pkt_hdr *pkh = NULL; + dma_addr_t addr; + uint32_t stat, curr; + int len, done = 0; + int rv; + + curr = rxq->curr; + while (CMICD_DESC_STAT_DONE(ring[curr].md.status)) { + if (dev->mode == DEV_MODE_VNET && rxq->state & PDMA_RX_QUEUE_XOFF) { + break; + } + if (!(rxq->state & PDMA_RX_BATCH_REFILL) && + !(rxq->state & PDMA_RX_QUEUE_XOFF)) { + /* Descriptor cherry pick */ + rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicd_rx_desc) * curr; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + rxq->halt = curr; + } + if (done == budget) { + break; + } + + /* Get the current pktbuf to process */ + pbuf = &rxq->pbuf[curr]; + stat = ring[curr].md.status; + len = CMICD_DESC_STAT_LEN(stat); + pkh = bm->rx_buf_get(dev, rxq, pbuf, len); + if (!pkh) { + rxq->stats.nomems++; + goto fail; + } + + /* Setup packet header */ + pkh->data_len = len; + pkh->meta_len = pbuf->adj; + pkh->queue_id = rxq->queue_id; + pkh->attrs = CMICD_DESC_STAT_FLAGS(stat); + sal_memcpy(&pbuf->pkb->data, &ring[curr].md, sizeof(struct rx_metadata)); + + /* Send up the packet */ + rv = dev->pkt_recv(dev, rxq->queue_id, (void *)pbuf->skb); + if (SHR_FAILURE(rv)) { + if (dev->mode == DEV_MODE_HNET && pkh->attrs & PDMA_RX_TO_VNET) { + rv = cmicd_pdma_rx_vring_process(hw, rxq, pbuf); + if (SHR_FAILURE(rv) && rv == SHR_E_BUSY) { + rxq->state |= PDMA_RX_QUEUE_BUSY; + return done; + } + } else { + rxq->stats.dropped++; + } + bm->rx_buf_put(dev, rxq, pbuf, len); + } + + /* Count the packets/bytes */ + rxq->stats.packets++; + rxq->stats.bytes += len; + + /* Count the errors if any */ + if (stat & CMICD_DESC_STAT_ERR_MASK) { + rxq->stats.errors++; + if (stat & CMICD_DESC_STAT_HEAD_ERR) { + rxq->stats.head_errors++; + } + if (stat & CMICD_DESC_STAT_DATA_ERR) { + rxq->stats.data_errors++; + } + if (stat & CMICD_DESC_STAT_CELL_ERR) { + rxq->stats.cell_errors++; + } + } + + /* Setup the new descriptor */ + if (!(rxq->state & PDMA_RX_BATCH_REFILL)) { + if (!bm->rx_buf_avail(dev, rxq, pbuf)) { + rv = bm->rx_buf_alloc(dev, rxq, pbuf); + if (SHR_FAILURE(rv)) { + rxq->stats.nomems++; + goto fail; + } + } + bm->rx_buf_dma(dev, rxq, pbuf, &addr); + cmicd_rx_desc_config(&ring[curr], addr, rxq->buf_size); + if (dev->flags & PDMA_CHAIN_MODE && curr == rxq->nb_desc - 1) { + cmicd_rx_desc_chain(&ring[curr], 0); + } + } else { + cmicd_rx_desc_config(&ring[curr], 0, 0); + } + + /* Notify HNET to process if needed */ + if (dev->mode == DEV_MODE_VNET) { + MEMORY_BARRIER; + if (ring[(curr + rxq->nb_desc - 1) % rxq->nb_desc].md.status) { + dev->xnet_wake(dev); + } + } + + /* Update the indicators */ + if (!(rxq->state & PDMA_RX_BATCH_REFILL) && rxq->halt != curr) { + sal_spinlock_lock(rxq->lock); + if (!(rxq->state & PDMA_RX_QUEUE_XOFF)) { + /* Descriptor cherry pick */ + rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicd_rx_desc) * curr; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + rxq->halt = curr; + } + curr = (curr + 1) % rxq->nb_desc; + sal_spinlock_unlock(rxq->lock); + } else { + curr = (curr + 1) % rxq->nb_desc; + } + rxq->curr = curr; + done++; + + /* Restart DMA if in chain mode */ + if (dev->flags & PDMA_CHAIN_MODE) { + if (curr == 0 && !(rxq->state & PDMA_RX_QUEUE_XOFF)) { + hw->hdls.chan_stop(hw, rxq->chan_id); + hw->hdls.chan_start(hw, rxq->chan_id); + } + } + } + + /* One more poll for chain done in chain mode */ + if (dev->flags & PDMA_CHAIN_MODE) { + if (curr == rxq->nb_desc - 1 && done) { + done = budget; + } + } + + /* In batching mode, replenish all the unused descriptors */ + if (rxq->state & PDMA_RX_BATCH_REFILL && + cmicd_pdma_rx_ring_unused(rxq) >= (int)rxq->free_thresh) { + cmicd_pdma_rx_ring_refill(hw, rxq); + } + + /* Notify the other side to process */ + if (dev->mode == DEV_MODE_VNET || dev->mode == DEV_MODE_HNET) { + if (done) { + dev->xnet_wake(dev); + } + } + + return done; + +fail: + CNET_PR("RX: Failed to allocate mem\n"); + + return done; +} + +/*! + * Process Tx vring + */ +static int +cmicd_pdma_tx_vring_process(struct pdma_hw *hw, struct pdma_tx_queue *txq, + struct pdma_tx_buf *pbuf) +{ + struct pdma_dev *dev = hw->dev; + struct cmicd_tx_desc *ring = (struct cmicd_tx_desc *)txq->ring; + struct pdma_tx_queue *vtxq = NULL; + struct cmicd_tx_desc *vring = NULL; + + vtxq = (struct pdma_tx_queue *)dev->ctrl.vnet_txq[txq->queue_id]; + vring = (struct cmicd_tx_desc *)vtxq->ring; + if (!vring) { + return SHR_E_UNAVAIL; + } + + /* Update vring descriptor */ + vring[vtxq->dirt].md.status = ring[txq->dirt].md.status; + pbuf->dma = 0; + + MEMORY_BARRIER; + + /* Notify VNET to process if needed */ + if (!vring[(vtxq->dirt + vtxq->nb_desc - 1) % vtxq->nb_desc].md.status) { + dev->xnet_wake(dev); + } + vtxq->dirt = (vtxq->dirt + 1) % vtxq->nb_desc; + + return SHR_E_NONE; +} + +/*! + * \brief Clean Tx ring + * + * \param [in] hw HW structure point. + * \param [in] txq Tx queue structure point. + * \param [in] budget Polling budget. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +cmicd_pdma_tx_ring_clean(struct pdma_hw *hw, struct pdma_tx_queue *txq, int budget) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + struct cmicd_tx_desc *ring = (struct cmicd_tx_desc *)txq->ring; + uint32_t dirt, curr; + int done = 0; + + dirt = txq->dirt; + while (txq->pbuf[dirt].dma) { + if (!CMICD_DESC_STAT_DONE(ring[dirt].md.status)) { + break; + } + if (done == budget) { + break; + } + + if (dev->mode == DEV_MODE_HNET && !txq->pbuf[dirt].skb) { + cmicd_pdma_tx_vring_process(hw, txq, &txq->pbuf[dirt]); + } else { + /* Free the done pktbuf */ + bm->tx_buf_free(dev, txq, &txq->pbuf[dirt]); + } + + cmicd_tx_desc_config(&ring[dirt], 0, 0, 0); + + /* Update the indicators */ + dirt = (dirt + 1) % txq->nb_desc; + txq->dirt = dirt; + done++; + + /* Restart DMA if in chain mode */ + if (dev->flags & PDMA_CHAIN_MODE) { + sal_spinlock_lock(txq->lock); + curr = txq->curr; + if (dirt == txq->halt && dirt != curr) { + hw->hdls.chan_stop(hw, txq->chan_id); + cmicd_tx_desc_chain(&ring[(curr + txq->nb_desc - 1) % txq->nb_desc], 0); + hw->hdls.chan_setup(hw, txq->chan_id, + txq->ring_addr + sizeof(struct cmicd_tx_desc) * txq->halt); + hw->hdls.chan_start(hw, txq->chan_id); + txq->halt = curr; + } + sal_spinlock_unlock(txq->lock); + } + } + + /* One more poll for chain done in chain mode */ + if (dev->flags & PDMA_CHAIN_MODE) { + sal_spinlock_lock(txq->lock); + if (dirt != txq->halt) { + done = budget; + } + sal_spinlock_unlock(txq->lock); + } + + /* Resume Tx if any */ + sal_spinlock_lock(txq->lock); + if (cmicd_pdma_tx_ring_unused(txq) && txq->state & PDMA_TX_QUEUE_XOFF) { + txq->state &= ~PDMA_TX_QUEUE_XOFF; + sal_spinlock_unlock(txq->lock); + if (dev->tx_resume) { + dev->tx_resume(dev, txq->queue_id); + } else if (!(txq->state & PDMA_TX_QUEUE_POLL)) { + sal_sem_give(txq->sem); + } + return done; + } + sal_spinlock_unlock(txq->lock); + + return done; +} + +/*! + * Dump Rx ring + */ +static int +cmicd_pdma_rx_ring_dump(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + struct cmicd_rx_desc *ring = (struct cmicd_rx_desc *)rxq->ring; + struct cmicd_rx_desc *rd; + uint32_t di; + + CNET_PR("\nRX: queue=%d, chan=%d, curr=%d, halt=%d, halt@%p\n", + rxq->queue_id, rxq->chan_id, rxq->curr, rxq->halt, (void *)&ring[rxq->halt]); + CNET_PR("----------------------------------------------------------------\n"); + for (di = 0; di < rxq->nb_desc + 1; di++) { + rd = &ring[di]; + CNET_PR("DESC[%03d]: (%p)->%08x %08x ... %08x\n", + di, (void *)(unsigned long)(rxq->ring_addr + di * CMICD_PDMA_DCB_SIZE), + rd->addr, rd->ctrl, rd->md.status); + } + + return SHR_E_NONE; +} + +/*! + * Dump Tx ring + */ +static int +cmicd_pdma_tx_ring_dump(struct pdma_hw *hw, struct pdma_tx_queue *txq) +{ + struct cmicd_tx_desc *ring = (struct cmicd_tx_desc *)txq->ring; + struct cmicd_tx_desc *td; + uint32_t di; + + CNET_PR("\nTX: queue=%d, chan=%d, curr=%d, dirt=%d, halt@%p\n", + txq->queue_id, txq->chan_id, txq->curr, txq->dirt, (void *)&ring[txq->curr]); + CNET_PR("----------------------------------------------------------------\n"); + for (di = 0; di < txq->nb_desc + 1; di++) { + td = &ring[di]; + CNET_PR("DESC[%03d]: (%p)->%08x %08x ... %08x\n", + di, (void *)(unsigned long)(txq->ring_addr + di * CMICD_PDMA_DCB_SIZE), + td->addr, td->ctrl, td->md.status); + } + + return SHR_E_NONE; +} + +/*! + * Fetch Tx vring + */ +static int +cmicd_pdma_tx_vring_fetch(struct pdma_hw *hw, struct pdma_tx_queue *txq, + struct pdma_tx_buf *pbuf) +{ + struct pdma_dev *dev = hw->dev; + struct cmicd_tx_desc *ring = (struct cmicd_tx_desc *)txq->ring; + struct pdma_tx_queue *vtxq = NULL; + struct cmicd_tx_desc *vring = NULL; + + vtxq = (struct pdma_tx_queue *)dev->ctrl.vnet_txq[txq->queue_id]; + vring = (struct cmicd_tx_desc *)vtxq->ring; + if (!vring || !CMICD_DESC_CTRL_LEN(vring[vtxq->curr].ctrl)) { + return SHR_E_UNAVAIL; + } + + /* Fetch vring descriptor */ + sal_memcpy(&ring[txq->curr], &vring[vtxq->curr], sizeof(struct cmicd_tx_desc)); + vring[vtxq->curr].ctrl &= ~CMICD_DESC_CTRL_LEN(-1); + + MEMORY_BARRIER; + + pbuf->dma = vring[vtxq->curr].addr; + pbuf->len = CMICD_DESC_CTRL_LEN(ring[txq->curr].ctrl); + vtxq->curr = (vtxq->curr + 1) % vtxq->nb_desc; + + return SHR_E_NONE; +} + +/*! + * Check Tx ring + */ +static inline int +cmicd_pdma_tx_ring_check(struct pdma_hw *hw, struct pdma_tx_queue *txq) +{ + if (cmicd_pdma_tx_ring_unused(txq)) { + return SHR_E_NONE; + } + + sal_spinlock_lock(txq->lock); + if (!cmicd_pdma_tx_ring_unused(txq)) { + txq->state |= PDMA_TX_QUEUE_XOFF; + txq->stats.xoffs++; + sal_spinlock_unlock(txq->lock); + if (hw->dev->tx_suspend) { + hw->dev->tx_suspend(hw->dev, txq->queue_id); + } + return SHR_E_BUSY; + } + sal_spinlock_unlock(txq->lock); + + return SHR_E_NONE; +} + +/*! + * \brief Start packet transmission + * + * \param [in] hw HW structure point. + * \param [in] txq Tx queue structure point. + * \param [in] buf Tx packet buffer. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +cmicd_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + struct cmicd_tx_desc *ring = (struct cmicd_tx_desc *)txq->ring; + struct pdma_tx_buf *pbuf = NULL; + struct pkt_hdr *pkh = NULL; + dma_addr_t addr; + uint32_t curr, flags = 0; + int retry = 5000000; + int rv; + + if (!(txq->state & PDMA_TX_QUEUE_ACTIVE)) { + return SHR_E_UNAVAIL; + } + + if (dev->tx_suspend) { + sal_spinlock_lock(txq->mutex); + } else { + sal_sem_take(txq->sem, SAL_SEM_FOREVER); + } + + /* Check Tx resource */ + if (dev->tx_suspend) { + /* Suspend Tx if no resource */ + rv = cmicd_pdma_tx_ring_check(hw, txq); + if (SHR_FAILURE(rv)) { + sal_spinlock_unlock(txq->mutex); + return rv; + } + } else { + /* Abort Tx if a fatal error happened */ + if (txq->state & PDMA_TX_QUEUE_XOFF) { + sal_sem_give(txq->sem); + return SHR_E_RESOURCE; + } + } + + /* Setup the new descriptor */ + curr = txq->curr; + pbuf = &txq->pbuf[curr]; + if (dev->mode == DEV_MODE_HNET && !buf) { + rv = cmicd_pdma_tx_vring_fetch(hw, txq, pbuf); + if (SHR_FAILURE(rv)) { + sal_spinlock_unlock(txq->mutex); + return SHR_E_EMPTY; + } + } else { + pbuf->adj = 0; + pkh = bm->tx_buf_get(dev, txq, pbuf, buf); + if (!pkh) { + txq->stats.dropped++; + if (dev->tx_suspend) { + sal_spinlock_unlock(txq->mutex); + } else { + sal_sem_give(txq->sem); + } + return SHR_E_NONE; + } + bm->tx_buf_dma(dev, txq, pbuf, &addr); + flags |= pkh->attrs & PDMA_TX_HIGIG_PKT ? CMICD_DESC_TX_HIGIG_PKT : 0; + flags |= pkh->attrs & PDMA_TX_PAUSE_PKT ? CMICD_DESC_TX_PAUSE_PKT : 0; + flags |= pkh->attrs & PDMA_TX_PURGE_PKT ? CMICD_DESC_TX_PURGE_PKT : 0; + cmicd_tx_desc_config(&ring[curr], addr, pbuf->len, flags); + if (pkh->meta_len) { + sal_memcpy(&ring[curr].md, &pbuf->pkb->data, sizeof(ring->md.data)); + } + } + + /* Notify HNET to process if needed */ + if (dev->mode == DEV_MODE_VNET) { + MEMORY_BARRIER; + if (!CMICD_DESC_CTRL_LEN(ring[(curr + txq->nb_desc - 1) % txq->nb_desc].ctrl)) { + dev->xnet_wake(dev); + } + } + + /* Update the indicators */ + curr = (curr + 1) % txq->nb_desc; + txq->curr = curr; + + /* Start DMA if in chain mode */ + if (dev->flags & PDMA_CHAIN_MODE) { + if (txq->state & PDMA_TX_QUEUE_POLL) { + do { + rv = cmicd_pdma_tx_ring_clean(hw, txq, txq->nb_desc - 1); + if (rv != (int)txq->nb_desc - 1) { + break; + } + sal_usleep(1); + } while (retry--); + if (retry <= 0) { + CNET_PR("Last Tx could not be done in given time\n"); + } + } + sal_spinlock_lock(txq->lock); + if (txq->dirt == txq->halt && txq->dirt != curr) { + hw->hdls.chan_stop(hw, txq->chan_id); + cmicd_tx_desc_chain(&ring[(curr + txq->nb_desc - 1) % txq->nb_desc], 0); + hw->hdls.chan_setup(hw, txq->chan_id, + txq->ring_addr + sizeof(struct cmicd_tx_desc) * txq->halt); + hw->hdls.chan_start(hw, txq->chan_id); + txq->halt = curr; + } + sal_spinlock_unlock(txq->lock); + } + + /* Kick off DMA */ + txq->halt_addr = txq->ring_addr + sizeof(struct cmicd_tx_desc) * curr; + hw->hdls.chan_goto(hw, txq->chan_id, txq->halt_addr); + + /* Count the packets/bytes */ + txq->stats.packets++; + txq->stats.bytes += pbuf->len; + + /* Clean up ring if in polling mode */ + if (txq->state & PDMA_TX_QUEUE_POLL && + cmicd_pdma_tx_ring_unused(txq) <= (int)txq->free_thresh) { + cmicd_pdma_tx_ring_clean(hw, txq, txq->nb_desc - txq->free_thresh); + } + + /* Suspend Tx if no resource */ + rv = cmicd_pdma_tx_ring_check(hw, txq); + if (SHR_FAILURE(rv)) { + if (dev->mode == DEV_MODE_VNET) { + dev->xnet_wake(dev); + } + + if (txq->state & PDMA_TX_QUEUE_POLL) { + /* In polling mode, must wait till the ring is available */ + do { + cmicd_pdma_tx_ring_clean(hw, txq, txq->free_thresh); + if (!(txq->state & PDMA_TX_QUEUE_XOFF)) { + break; + } + sal_usleep(1); + } while (retry--); + if (retry <= 0) { + CNET_PR("Fatal error: Tx ring is full, packets have not been transmitted for 5 seconds\n"); + if (!dev->tx_suspend) { + sal_sem_give(txq->sem); + return SHR_E_RESOURCE; + } + } + } else { + /* In interrupt mode, the handle thread will wake up Tx */ + if (!dev->tx_suspend) { + return SHR_E_NONE; + } + } + } + + if (dev->tx_suspend) { + sal_spinlock_unlock(txq->mutex); + } else { + sal_sem_give(txq->sem); + } + + return SHR_E_NONE; +} + +/*! + * Suspend Rx queue + */ +static int +cmicd_pdma_rx_suspend(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + sal_spinlock_lock(rxq->lock); + rxq->state |= PDMA_RX_QUEUE_XOFF; + if (hw->dev->flags & PDMA_CHAIN_MODE) { + hw->hdls.chan_stop(hw, rxq->chan_id); + } + sal_spinlock_unlock(rxq->lock); + + return SHR_E_NONE; +} + +/*! + * Resume Rx queue + */ +static int +cmicd_pdma_rx_resume(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + sal_spinlock_lock(rxq->lock); + if (!(rxq->state & PDMA_RX_QUEUE_XOFF)) { + sal_spinlock_unlock(rxq->lock); + return SHR_E_NONE; + } + if (rxq->state & PDMA_RX_BATCH_REFILL) { + rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicd_rx_desc) * rxq->halt; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + } else if (rxq->halt == rxq->curr || (rxq->halt == rxq->nb_desc && rxq->curr == 0)) { + rxq->halt = (rxq->curr + 1) % rxq->nb_desc; + rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicd_rx_desc) * rxq->halt; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + } + if (hw->dev->flags & PDMA_CHAIN_MODE) { + rxq->curr = 0; + hw->hdls.chan_start(hw, rxq->chan_id); + } + rxq->state &= ~PDMA_RX_QUEUE_XOFF; + sal_spinlock_unlock(rxq->lock); + + return SHR_E_NONE; +} + +/*! + * Initialize function pointers + */ +int +bcmcnet_cmicd_pdma_desc_ops_init(struct pdma_hw *hw) +{ + if (!hw) { + return SHR_E_PARAM; + } + + hw->dops.rx_desc_init = cmicd_pdma_rx_desc_init; + hw->dops.rx_desc_clean = cmicd_pdma_rx_desc_clean; + hw->dops.rx_ring_clean = cmicd_pdma_rx_ring_clean; + hw->dops.rx_ring_dump = cmicd_pdma_rx_ring_dump; + hw->dops.rx_suspend = cmicd_pdma_rx_suspend; + hw->dops.rx_resume = cmicd_pdma_rx_resume; + hw->dops.tx_desc_init = cmicd_pdma_tx_desc_init; + hw->dops.tx_desc_clean = cmicd_pdma_tx_desc_clean; + hw->dops.tx_ring_clean = cmicd_pdma_tx_ring_clean; + hw->dops.tx_ring_dump = cmicd_pdma_tx_ring_dump; + hw->dops.pkt_xmit = cmicd_pdma_pkt_xmit; + + return SHR_E_NONE; +} + +/*! + * Attach device driver + */ +int +bcmcnet_cmicd_pdma_driver_attach(struct pdma_dev *dev) +{ + struct pdma_hw *hw = NULL; + + /* Allocate memory for HW data */ + hw = sal_alloc(sizeof(*hw), "bcmcnetPdmaHw"); + if (!hw) { + return SHR_E_MEMORY; + } + sal_memset(hw, 0, sizeof(*hw)); + hw->unit = dev->unit; + hw->dev = dev; + dev->ctrl.hw = hw; + + bcmcnet_cmicd_pdma_hw_hdls_init(hw); + bcmcnet_cmicd_pdma_desc_ops_init(hw); + + return SHR_E_NONE; +} + +/*! + * Detach device driver + */ +int +bcmcnet_cmicd_pdma_driver_detach(struct pdma_dev *dev) +{ + if (dev->ctrl.hw) { + sal_free(dev->ctrl.hw); + } + dev->ctrl.hw = NULL; + + return SHR_E_NONE; +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicx/bcmcnet_cmicx_pdma_hw.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicx/bcmcnet_cmicx_pdma_hw.c new file mode 100644 index 000000000000..6dc77c4b7c04 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicx/bcmcnet_cmicx_pdma_hw.c @@ -0,0 +1,604 @@ +/*! \file bcmcnet_cmicx_pdma_hw.c + * + * Utility routines for handling BCMCNET hardware (CMICx). + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include +#include + +/*! + * Read 32-bit register + */ +static inline void +cmicx_pdma_reg_read32(struct pdma_hw *hw, uint32_t addr, uint32_t *data) +{ + if (hw->dev->dev_read32) { + hw->dev->dev_read32(hw->dev, addr, data); + } else { + DEV_READ32(&hw->dev->ctrl, addr, data); + } +} + +/*! + * Write 32-bit register + */ +static inline void +cmicx_pdma_reg_write32(struct pdma_hw *hw, uint32_t addr, uint32_t data) +{ + if (hw->dev->dev_write32) { + hw->dev->dev_write32(hw->dev, addr, data); + } else { + DEV_WRITE32(&hw->dev->ctrl, addr, data); + } +} + +/*! + * Enable interrupt for a channel + */ +static inline void +cmicx_pdma_intr_enable(struct pdma_hw *hw, int cmc, int chan, uint32_t mask) +{ + uint32_t reg, irq_mask; + + hw->dev->ctrl.grp[cmc].irq_mask |= mask; + irq_mask = hw->dev->ctrl.grp[cmc].irq_mask; + if (cmc == 0) { + reg = CMICX_PDMA_IRQ_RAW_STAT0; + } else { + if (chan < 4) { + reg = CMICX_PDMA_IRQ_RAW_STAT1; + hw->dev->ctrl.grp[cmc].irq_mask <<= CMICX_IRQ_MASK_SHIFT; + } else { + reg = CMICX_PDMA_IRQ_RAW_STAT2; + hw->dev->ctrl.grp[cmc].irq_mask >>= 32 - CMICX_IRQ_MASK_SHIFT; + } + } + + hw->dev->intr_unmask(hw->dev, cmc, chan, reg & 0xfff, 0); + hw->dev->ctrl.grp[cmc].irq_mask = irq_mask; +} + +/*! + * Disable interrupt for a channel + */ +static inline void +cmicx_pdma_intr_disable(struct pdma_hw *hw, int cmc, int chan, uint32_t mask) +{ + uint32_t reg, irq_mask; + + hw->dev->ctrl.grp[cmc].irq_mask &= ~mask; + irq_mask = hw->dev->ctrl.grp[cmc].irq_mask; + if (cmc == 0) { + reg = CMICX_PDMA_IRQ_RAW_STAT0; + } else { + if (chan < 4) { + reg = CMICX_PDMA_IRQ_RAW_STAT1; + hw->dev->ctrl.grp[cmc].irq_mask <<= CMICX_IRQ_MASK_SHIFT; + } else { + reg = CMICX_PDMA_IRQ_RAW_STAT2; + hw->dev->ctrl.grp[cmc].irq_mask >>= 32 - CMICX_IRQ_MASK_SHIFT; + } + } + + hw->dev->intr_mask(hw->dev, cmc, chan, reg & 0xfff, 0); + hw->dev->ctrl.grp[cmc].irq_mask = irq_mask; +} + +/*! + * Release Packet DMA credits to EP. + */ +static int +cmicx_pdma_credits_release(struct pdma_hw *hw) +{ + int credits; + uint32_t val; + + /* + * Since only 6 bits of iproc_cmic_to_ep_credits[5:0] are being used, + * so we have to set the max credits value twice in order to release + * 64 credits to EP. + * Only do this once when HW is initialized. + */ + hw->hdls.reg_rd32(hw, CMICX_EPINTF_RELEASE_CREDITS, &val); + if (!val) { + credits = 63; + hw->hdls.reg_wr32(hw, CMICX_EPINTF_MAX_CREDITS, (0x1 << 8) | credits); + hw->hdls.reg_wr32(hw, CMICX_EPINTF_RELEASE_CREDITS, 1); + + hw->hdls.reg_wr32(hw, CMICX_EPINTF_RELEASE_CREDITS, 0); + credits = 1; + hw->hdls.reg_wr32(hw, CMICX_EPINTF_MAX_CREDITS, (0x1 << 8) | credits); + hw->hdls.reg_wr32(hw, CMICX_EPINTF_RELEASE_CREDITS, 1); + } + + return SHR_E_NONE; +} + +/*! + * Initialize HW + */ +static int +cmicx_pdma_hw_init(struct pdma_hw *hw) +{ + dev_mode_t mode = DEV_MODE_MAX; + uint32_t val; + + /* Temporarily upgrade work mode to get HW information in VNET mode. */ + if (hw->dev->mode == DEV_MODE_VNET) { + mode = DEV_MODE_VNET; + hw->dev->mode = DEV_MODE_UNET; + } + + /* Release Packet DMA credits to EP. */ + cmicx_pdma_credits_release(hw); + + hw->info.name = CMICX_DEV_NAME; + hw->info.dev_id = hw->dev->dev_id; + hw->info.num_cmcs = CMICX_PDMA_CMC_MAX; + hw->info.cmc_chans = CMICX_PDMA_CMC_CHAN; + hw->info.num_chans = CMICX_PDMA_CMC_MAX * CMICX_PDMA_CMC_CHAN; + hw->info.rx_dcb_size = CMICX_PDMA_DCB_SIZE; + hw->info.tx_dcb_size = CMICX_PDMA_DCB_SIZE; + hw->hdls.reg_rd32(hw, CMICX_EP_TO_CPU_HEADER_SIZE, &val); + hw->info.rx_ph_size = (val & 0xf) * 8; + hw->info.tx_ph_size = CMICX_TX_PKT_HDR_SIZE; + + /* Restore work mode to VNET. */ + if (mode == DEV_MODE_VNET) { + hw->dev->mode = DEV_MODE_VNET; + } + + return SHR_E_NONE; +} + +/*! + * Configure HW + */ +static int +cmicx_pdma_hw_config(struct pdma_hw *hw) +{ + struct dev_ctrl *ctrl = &hw->dev->ctrl; + struct pdma_rx_queue *rxq = NULL; + struct pdma_tx_queue *txq = NULL; + uint32_t val, que_ctrl; + int grp, que; + uint32_t qi; + int ip_if_hdr_endian = 0; + + for (qi = 0; qi < ctrl->nb_rxq; qi++) { + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[qi]; + grp = rxq->group_id; + que = rxq->chan_id % CMICX_PDMA_CMC_CHAN; + que_ctrl = ctrl->grp[grp].que_ctrl[que]; + + hw->hdls.reg_wr32(hw, CMICX_PDMA_IRQ_STAT_CLR(grp), CMICX_PDMA_IRQ_MASK(que)); + val = 0; + if (que_ctrl & PDMA_PKT_BYTE_SWAP) { + val |= CMICX_PDMA_PKT_BIG_ENDIAN; + } + if (que_ctrl & PDMA_OTH_BYTE_SWAP) { + val |= CMICX_PDMA_DESC_BIG_ENDIAN; + } + if (que_ctrl & PDMA_HDR_BYTE_SWAP) { + val |= CMICX_PDMA_HDR_BIG_ENDIAN; + } + if (!(hw->dev->flags & PDMA_CHAIN_MODE)) { + val |= CMICX_PDMA_CONTINUOUS; + } + if (hw->dev->flags & PDMA_DESC_PREFETCH) { + val |= CMICX_PDMA_CONTINUOUS_DESC; + } + val |= CMICX_PDMA_INTR_ON_DESC; + hw->hdls.reg_wr32(hw, CMICX_PDMA_CTRL(grp, que), val); + } + + for (qi = 0; qi < ctrl->nb_txq; qi++) { + txq = (struct pdma_tx_queue *)ctrl->tx_queue[qi]; + grp = txq->group_id; + que = txq->chan_id % CMICX_PDMA_CMC_CHAN; + que_ctrl = ctrl->grp[grp].que_ctrl[que]; + + hw->hdls.reg_wr32(hw, CMICX_PDMA_IRQ_STAT_CLR(grp), CMICX_PDMA_IRQ_MASK(que)); + val = 0; + if (que_ctrl & PDMA_PKT_BYTE_SWAP) { + val |= CMICX_PDMA_PKT_BIG_ENDIAN; + val |= CMICX_PDMA_HDR_BIG_ENDIAN; + ip_if_hdr_endian = 1; + } + if (que_ctrl & PDMA_OTH_BYTE_SWAP) { + val |= CMICX_PDMA_DESC_BIG_ENDIAN; + } + if (que_ctrl & PDMA_HDR_BYTE_SWAP) { + ip_if_hdr_endian = 1; + } + if (!(hw->dev->flags & PDMA_CHAIN_MODE)) { + val |= CMICX_PDMA_CONTINUOUS; + } + if (hw->dev->flags & PDMA_DESC_PREFETCH) { + val |= CMICX_PDMA_CONTINUOUS_DESC; + } + val |= CMICX_PDMA_INTR_ON_DESC | CMICX_PDMA_DIR; + hw->hdls.reg_wr32(hw, CMICX_PDMA_CTRL(grp, que), val); + } + + if (ip_if_hdr_endian == 1) { + hw->hdls.reg_rd32(hw, CMICX_TOP_CONFIG, &val); + val |= 0x80; + hw->hdls.reg_wr32(hw, CMICX_TOP_CONFIG, val); + } + + return SHR_E_NONE; +} + +/*! + * Reset HW + */ +static int +cmicx_pdma_hw_reset(struct pdma_hw *hw) +{ + int gi, qi; + + for (gi = 0; gi < hw->dev->num_groups; gi++) { + if (!hw->dev->ctrl.grp[gi].attached) { + continue; + } + for (qi = 0; qi < CMICX_PDMA_CMC_CHAN; qi++) { + if (1 << qi & hw->dev->ctrl.grp[gi].bm_rxq || + 1 << qi & hw->dev->ctrl.grp[gi].bm_txq) { + hw->hdls.reg_wr32(hw, CMICX_PDMA_CTRL(gi, qi), 0); + } + } + } + + return SHR_E_NONE; +} + +/*! + * Start a channel + */ +static int +cmicx_pdma_chan_start(struct pdma_hw *hw, int chan) +{ + uint32_t val; + int grp, que; + + grp = chan / CMICX_PDMA_CMC_CHAN; + que = chan % CMICX_PDMA_CMC_CHAN; + + hw->hdls.reg_rd32(hw, CMICX_PDMA_CTRL(grp, que), &val); + val |= CMICX_PDMA_ENABLE; + hw->hdls.reg_wr32(hw, CMICX_PDMA_CTRL(grp, que), val); + + MEMORY_BARRIER; + + return SHR_E_NONE; +} + +/*! + * Stop a channel + */ +static int +cmicx_pdma_chan_stop(struct pdma_hw *hw, int chan) +{ + uint32_t val; + int grp, que; + int retry = CMICX_HW_RETRY_TIMES; + + grp = chan / CMICX_PDMA_CMC_CHAN; + que = chan % CMICX_PDMA_CMC_CHAN; + + hw->hdls.reg_rd32(hw, CMICX_PDMA_CTRL(grp, que), &val); + val |= CMICX_PDMA_ENABLE | CMICX_PDMA_ABORT; + hw->hdls.reg_wr32(hw, CMICX_PDMA_CTRL(grp, que), val); + + MEMORY_BARRIER; + + do { + val = ~CMICX_PDMA_IS_ACTIVE; + hw->hdls.reg_rd32(hw, CMICX_PDMA_STAT(grp, que), &val); + } while ((val & CMICX_PDMA_IS_ACTIVE) && (--retry > 0)); + + hw->hdls.reg_rd32(hw, CMICX_PDMA_CTRL(grp, que), &val); + val &= ~(CMICX_PDMA_ENABLE | CMICX_PDMA_ABORT); + hw->hdls.reg_wr32(hw, CMICX_PDMA_CTRL(grp, que), val); + + hw->hdls.reg_wr32(hw, CMICX_PDMA_IRQ_STAT_CLR(grp), CMICX_PDMA_IRQ_MASK(que)); + + MEMORY_BARRIER; + + return SHR_E_NONE; +} + +/*! + * Setup a channel + */ +static int +cmicx_pdma_chan_setup(struct pdma_hw *hw, int chan, uint64_t addr) +{ + int grp, que; + + grp = chan / CMICX_PDMA_CMC_CHAN; + que = chan % CMICX_PDMA_CMC_CHAN; + + hw->hdls.reg_wr32(hw, CMICX_PDMA_DESC_LO(grp, que), addr); + hw->hdls.reg_wr32(hw, CMICX_PDMA_DESC_HI(grp, que), DMA_TO_BUS_HI(addr >> 32)); + + MEMORY_BARRIER; + + return SHR_E_NONE; +} + +/*! + * Set halt point for a channel + */ +static int +cmicx_pdma_chan_goto(struct pdma_hw *hw, int chan, uint64_t addr) +{ + int grp, que; + + grp = chan / CMICX_PDMA_CMC_CHAN; + que = chan % CMICX_PDMA_CMC_CHAN; + + hw->hdls.reg_wr32(hw, CMICX_PDMA_DESC_HALT_LO(grp, que), addr); + hw->hdls.reg_wr32(hw, CMICX_PDMA_DESC_HALT_HI(grp, que), DMA_TO_BUS_HI(addr >> 32)); + + MEMORY_BARRIER; + + return SHR_E_NONE; +} + +/*! + * Clear a channel + */ +static int +cmicx_pdma_chan_clear(struct pdma_hw *hw, int chan) +{ + int grp, que; + + grp = chan / CMICX_PDMA_CMC_CHAN; + que = chan % CMICX_PDMA_CMC_CHAN; + + hw->hdls.reg_wr32(hw, CMICX_PDMA_IRQ_STAT_CLR(grp), CMICX_PDMA_IRQ_CTRLD_INTR(que)); + + MEMORY_BARRIER; + + return SHR_E_NONE; +} + +/*! + * Get interrupt number for a channel + */ +static int +cmicx_pdma_chan_intr_num_get(struct pdma_hw *hw, int chan) +{ + int grp, que, start_num, mask_shift; + + grp = chan / CMICX_PDMA_CMC_CHAN; + que = chan % CMICX_PDMA_CMC_CHAN; + + mask_shift = 0; + if (grp > 0) { + mask_shift = CMICX_IRQ_MASK_SHIFT + grp * 32; + } + start_num = CMICX_IRQ_START_NUM + mask_shift; + + return start_num + (que * CMICX_IRQ_NUM_OFFSET); +} + +/*! + * Enable interrupt for a channel + */ +static int +cmicx_pdma_chan_intr_enable(struct pdma_hw *hw, int chan) +{ + int grp, que; + + grp = chan / CMICX_PDMA_CMC_CHAN; + que = chan % CMICX_PDMA_CMC_CHAN; + + cmicx_pdma_intr_enable(hw, grp, que, CMICX_PDMA_IRQ_CTRLD_INTR(que)); + + return SHR_E_NONE; +} + +/*! + * Disable interrupt for a channel + */ +static int +cmicx_pdma_chan_intr_disable(struct pdma_hw *hw, int chan) +{ + int grp, que; + + grp = chan / CMICX_PDMA_CMC_CHAN; + que = chan % CMICX_PDMA_CMC_CHAN; + + cmicx_pdma_intr_disable(hw, grp, que, CMICX_PDMA_IRQ_CTRLD_INTR(que)); + + return SHR_E_NONE; +} + +/*! + * Query interrupt status for a channel + * + * In group mode (interrupt processing per CMC), need to query each channel's + * interrupt status. + * + */ +static int +cmicx_pdma_chan_intr_query(struct pdma_hw *hw, int chan) +{ + uint32_t val; + int grp, que; + + grp = chan / CMICX_PDMA_CMC_CHAN; + que = chan % CMICX_PDMA_CMC_CHAN; + + hw->hdls.reg_rd32(hw, CMICX_PDMA_IRQ_STAT(grp), &val); + + return val & CMICX_PDMA_IRQ_CTRLD_INTR(que); +} + +/*! + * Check interrupt validity for a channel + * + * In group mode (interrupt processing per CMC), need to check each channel's + * interrupt validity based on its interrupt mask. + * + */ +static int +cmicx_pdma_chan_intr_check(struct pdma_hw *hw, int chan) +{ + int grp, que; + + grp = chan / CMICX_PDMA_CMC_CHAN; + que = chan % CMICX_PDMA_CMC_CHAN; + + if (!(hw->dev->ctrl.grp[grp].irq_mask & CMICX_PDMA_IRQ_CTRLD_INTR(que))) { + return 0; + } + + return cmicx_pdma_chan_intr_query(hw, chan); +} + +/*! + * Coalesce interrupt for a channel + */ +static int +cmicx_pdma_chan_intr_coalesce(struct pdma_hw *hw, int chan, int count, int timer) +{ + uint32_t val; + int grp, que; + + grp = chan / CMICX_PDMA_CMC_CHAN; + que = chan % CMICX_PDMA_CMC_CHAN; + + val = CMICX_PDMA_INTR_COAL_ENA | + CMICX_PDMA_INTR_THRESH(count) | + CMICX_PDMA_INTR_TIMER(timer); + hw->hdls.reg_wr32(hw, CMICX_PDMA_INTR_COAL(grp, que), val); + + return SHR_E_NONE; +} + +/*! + * Dump registers for a channel + */ +static int +cmicx_pdma_chan_reg_dump(struct pdma_hw *hw, int chan) +{ + uint32_t val; + int grp, que; + + grp = chan / CMICX_PDMA_CMC_CHAN; + que = chan % CMICX_PDMA_CMC_CHAN; + + hw->hdls.reg_rd32(hw, CMICX_PDMA_CTRL(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_CH%d_CTRL: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICX_PDMA_DESC_LO(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_CH%d_DESC_LO: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICX_PDMA_DESC_HI(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_CH%d_DESC_HI: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICX_PDMA_CURR_DESC_LO(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_CH%d_CURR_DESC_LO: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICX_PDMA_CURR_DESC_HI(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_CH%d_CURR_DESC_HI: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICX_PDMA_DESC_HALT_LO(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_CH%d_DESC_HALT_ADDR_LO: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICX_PDMA_DESC_HALT_HI(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_CH%d_DESC_HALT_ADDR_HI: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICX_PDMA_COS_CTRL_RX0(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_CH%d_COS_CTRL_RX_0: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICX_PDMA_COS_CTRL_RX1(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_CH%d_COS_CTRL_RX_1: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICX_PDMA_INTR_COAL(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_CH%d_INTR_COAL: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICX_PDMA_RBUF_THRE(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_CH%d_RXBUF_THRESHOLD_CONFIG: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICX_PDMA_STAT(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_CH%d_STAT: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICX_PDMA_COUNT_RX(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_CH%d_PKT_COUNT_RXPKT: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICX_PDMA_COUNT_TX(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_CH%d_PKT_COUNT_TXPKT: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICX_PDMA_COUNT_RX_DROP(grp, que), &val); + CNET_PR("CMIC_CMC%d_DMA_CH%d_PKT_COUNT_RXPKT_DROP: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICX_PDMA_IRQ_STAT(grp), &val); + CNET_PR("CMIC_CMC%d_IRQ_STAT: 0x%08x\n", grp, val); + + hw->hdls.reg_rd32(hw, CMICX_PDMA_IRQ_STAT_CLR(grp), &val); + CNET_PR("CMIC_CMC%d_IRQ_STAT_CLR: 0x%08x\n", grp, val); + + val = hw->dev->ctrl.grp[grp].irq_mask; + CNET_PR("CMIC_CMC%d_IRQ_ENAB: 0x%08x\n", grp, val); + + hw->hdls.reg_rd32(hw, CMICX_EP_TO_CPU_HEADER_SIZE, &val); + CNET_PR("CMIC_EP_TO_CPU_HEADER_SIZE: 0x%08x\n", val); + + return SHR_E_NONE; +} + +/*! + * Initialize function pointers + */ +int +bcmcnet_cmicx_pdma_hw_hdls_init(struct pdma_hw *hw) +{ + if (!hw) { + return SHR_E_PARAM; + } + + hw->hdls.reg_rd32 = cmicx_pdma_reg_read32; + hw->hdls.reg_wr32 = cmicx_pdma_reg_write32; + hw->hdls.hw_init = cmicx_pdma_hw_init; + hw->hdls.hw_config = cmicx_pdma_hw_config; + hw->hdls.hw_reset = cmicx_pdma_hw_reset; + hw->hdls.chan_start = cmicx_pdma_chan_start; + hw->hdls.chan_stop = cmicx_pdma_chan_stop; + hw->hdls.chan_setup = cmicx_pdma_chan_setup; + hw->hdls.chan_goto = cmicx_pdma_chan_goto; + hw->hdls.chan_clear = cmicx_pdma_chan_clear; + hw->hdls.chan_intr_num_get = cmicx_pdma_chan_intr_num_get; + hw->hdls.chan_intr_enable = cmicx_pdma_chan_intr_enable; + hw->hdls.chan_intr_disable = cmicx_pdma_chan_intr_disable; + hw->hdls.chan_intr_query = cmicx_pdma_chan_intr_query; + hw->hdls.chan_intr_check = cmicx_pdma_chan_intr_check; + hw->hdls.chan_intr_coalesce = cmicx_pdma_chan_intr_coalesce; + hw->hdls.chan_reg_dump = cmicx_pdma_chan_reg_dump; + + return SHR_E_NONE; +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicx/bcmcnet_cmicx_pdma_rxtx.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicx/bcmcnet_cmicx_pdma_rxtx.c new file mode 100644 index 000000000000..651728465d56 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicx/bcmcnet_cmicx_pdma_rxtx.c @@ -0,0 +1,1094 @@ +/*! \file bcmcnet_cmicx_pdma_rxtx.c + * + * Utility routines for BCMCNET hardware (CMICx) specific Rx/Tx. + * + * Here are the CMIC specific Rx/Tx routines including DCBs resource allocation + * and clean up, DCBs configuration, Rx buffers allocation, Tx buffers release, + * Rx/Tx packets processing, etc. + * They are shared among all the modes (UNET, KNET, VNET, HNET) and in both of + * user space and kernel space. + * + * The driver uses a ring of DCBs per DMA channel based on Continuous DMA mode. + * The beginning is written to register pointing to the physical address of the + * start of the ring. The ring size is maintained by the driver. A HALT DCB + * physical address is written to DMA register timely to indicate how many DCBs + * can be handled by HW. + * + * When a packet is received, an interrupt is triggered. The handler will go + * through the Rx DCB ring to process the current completed DCB and every + * subsequent DCBs until no one is left. The received packet is processed and + * passed up to the high level SW. After that, a new buffer is allocated and + * the DCB is updated for receiving a new packet. A new HALT DCB is selected + * and its physical address is written to DMA register. + * + * When a packet is transmitted, the driver starts where it left off last time + * in the Tx DCB ring, updates the DCB and writes its physical address to DMA + * register so as to start DMA. Once the transmitting is finished, the handler + * is informed to clean up the buffer based on the work mode. In KNET or HNET + * mode, an interrupt will be triggered. Polling mode is used in CNET or VNET + * mode, the buffers will be cleaned up when the number of dirty DCBs reaches + * a pre-defined threshold. + * + * In VNET and HNET modes, DCB updating between virtual ring and real ring and + * a IOCTL based notification mechanism are involved. The hypervisor in kernel + * emulates the DMA HW behaviors to update DCBs in virtual network and inform + * the handler something happened. Likewise, the hypervisor updates itself real + * DCB ring from the virtual ring to start DMA for transmitting a packet once a + * notification is received from the virtual network. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include +#include +#include + +/*! + * Configure Rx descriptor + */ +static inline void +cmicx_rx_desc_config(struct cmicx_rx_desc *rd, uint64_t addr, uint32_t len) +{ + uint32_t ctrl; + + rd->addr_lo = addr; + rd->addr_hi = DMA_TO_BUS_HI(addr >> 32); + rd->status = 0; + ctrl = rd->ctrl; + ctrl &= CMICX_DESC_CTRL_REMAIN(0xf); + ctrl |= CMICX_DESC_CTRL_CNTLD_INTR | CMICX_DESC_CTRL_CHAIN | + CMICX_DESC_CTRL_LEN(len); + rd->ctrl = ctrl; +} + +/*! + * Configure Tx descriptor + */ +static inline void +cmicx_tx_desc_config(struct cmicx_tx_desc *td, uint64_t addr, uint32_t len, uint32_t flags) +{ + uint32_t ctrl; + + td->addr_lo = addr; + td->addr_hi = DMA_TO_BUS_HI(addr >> 32); + td->status = 0; + ctrl = td->ctrl; + ctrl &= CMICX_DESC_CTRL_REMAIN(0xf); + ctrl |= CMICX_DESC_CTRL_CNTLD_INTR | CMICX_DESC_CTRL_CHAIN | + CMICX_DESC_CTRL_FLAGS(flags) | CMICX_DESC_CTRL_LEN(len); + td->ctrl = ctrl; +} + +/*! + * Configure Rx reload descriptor + */ +static inline void +cmicx_rx_rldesc_config(struct cmicx_rx_desc *rd, uint64_t addr) +{ + rd->addr_lo = addr; + rd->addr_hi = DMA_TO_BUS_HI(addr >> 32); + rd->status = 0; + rd->ctrl = CMICX_DESC_CTRL_CNTLD_INTR | CMICX_DESC_CTRL_CHAIN | + CMICX_DESC_CTRL_RELOAD; +} + +/*! + * Configure Tx reload descriptor + */ +static inline void +cmicx_tx_rldesc_config(struct cmicx_tx_desc *td, uint64_t addr) +{ + td->addr_lo = addr; + td->addr_hi = DMA_TO_BUS_HI(addr >> 32); + td->status = 0; + td->ctrl = CMICX_DESC_CTRL_CNTLD_INTR | CMICX_DESC_CTRL_CHAIN | + CMICX_DESC_CTRL_RELOAD; +} + +/*! + * Chain Rx descriptor + */ +static inline void +cmicx_rx_desc_chain(struct cmicx_rx_desc *rd, int chain) +{ + if (chain) { + rd->ctrl |= CMICX_DESC_CTRL_CHAIN; + } else { + rd->ctrl &= ~CMICX_DESC_CTRL_CHAIN; + } +} + +/*! + * Chain Tx descriptor + */ +static inline void +cmicx_tx_desc_chain(struct cmicx_tx_desc *td, int chain) +{ + if (chain) { + td->ctrl |= CMICX_DESC_CTRL_CHAIN; + } else { + td->ctrl &= ~CMICX_DESC_CTRL_CHAIN; + } +} + +/*! + * Set Rx descriptor remain + */ +static inline void +cmicx_rx_desc_remain(struct cmicx_rx_desc *rd, uint32_t rm) +{ + rd->ctrl &= ~CMICX_DESC_CTRL_REMAIN(0xf); + rd->ctrl |= CMICX_DESC_CTRL_REMAIN(rm); +} + +/*! + * Set Tx descriptor remain + */ +static inline void +cmicx_tx_desc_remain(struct cmicx_tx_desc *td, uint32_t rm) +{ + td->ctrl &= ~CMICX_DESC_CTRL_REMAIN(0xf); + td->ctrl |= CMICX_DESC_CTRL_REMAIN(rm); +} + +/*! + * Get unused descriptors in a Rx ring + */ +static inline int +cmicx_pdma_rx_ring_unused(struct pdma_rx_queue *rxq) +{ + /* Leave one descriptor unused so as not to halt */ + return rxq->curr > rxq->halt ? + rxq->curr - rxq->halt - 1 : + rxq->nb_desc + rxq->curr - rxq->halt - 1; +} + +/*! + * Get unused descriptors in a Tx ring + */ +static inline int +cmicx_pdma_tx_ring_unused(struct pdma_tx_queue *txq) +{ + /* Leave one descriptor unused so as not to halt */ + return txq->dirt > txq->curr ? + txq->dirt - txq->curr - 1 : + txq->nb_desc + txq->dirt - txq->curr - 1; +} + +/*! + * Initialize Rx descriptors + */ +static int +cmicx_pdma_rx_desc_init(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + struct cmicx_rx_desc *ring = (struct cmicx_rx_desc *)rxq->ring; + dma_addr_t addr; + uint32_t di, rm; + int rv; + + for (di = 0; di < rxq->nb_desc; di++) { + if (!rxq->pbuf[di].dma) { + /* Allocate pktbuf for ring entry */ + rv = bm->rx_buf_alloc(dev, rxq, &rxq->pbuf[di]); + if (SHR_FAILURE(rv)) { + goto cleanup; + } + } + /* Config receive descriptor ring */ + bm->rx_buf_dma(dev, rxq, &rxq->pbuf[di], &addr); + cmicx_rx_desc_config(&ring[di], addr, rxq->buf_size); + rm = (rxq->nb_desc - di) >= CMICX_DESC_REMAIN_MAX ? + CMICX_DESC_REMAIN_MAX : rxq->nb_desc - di; + cmicx_rx_desc_remain(&ring[di], rm); + if (hw->dev->flags & PDMA_CHAIN_MODE && di == rxq->nb_desc - 1) { + cmicx_rx_desc_chain(&ring[di], 0); + } + } + /* Config the last descriptor in the ring as reload descriptor */ + cmicx_rx_rldesc_config(&ring[di], rxq->ring_addr); + + rxq->curr = 0; + rxq->halt = rxq->state & PDMA_RX_BATCH_REFILL ? 0 : rxq->nb_desc; + + rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicx_rx_desc) * di; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + hw->hdls.chan_setup(hw, rxq->chan_id, rxq->ring_addr); + + return SHR_E_NONE; + +cleanup: + for (di = 0; di < rxq->nb_desc; di++) { + if (rxq->pbuf[di].dma) { + bm->rx_buf_free(dev, rxq, &rxq->pbuf[di]); + } + cmicx_rx_desc_config(&ring[di], 0, 0); + } + + CNET_PR("RX: Failed to allocate mem\n"); + + return SHR_E_MEMORY; +} + +/*! + * Cleanup Rx descriptors + */ +static int +cmicx_pdma_rx_desc_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + struct cmicx_rx_desc *ring = (struct cmicx_rx_desc *)rxq->ring; + uint32_t di; + + /* Go through all the descriptors and free pktbuf */ + for (di = 0; di < rxq->nb_desc; di++) { + if (rxq->pbuf[di].dma) { + bm->rx_buf_free(dev, rxq, &rxq->pbuf[di]); + } + cmicx_rx_desc_config(&ring[di], 0, 0); + } + + rxq->curr = 0; + rxq->halt = 0; + + return SHR_E_NONE; +} + +/*! + * Initialize Tx descriptors + */ +static int +cmicx_pdma_tx_desc_init(struct pdma_hw *hw, struct pdma_tx_queue *txq) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + struct cmicx_tx_desc *ring = (struct cmicx_tx_desc *)txq->ring; + uint32_t di, rm; + + for (di = 0; di < txq->nb_desc; di++) { + if (txq->pbuf[di].dma) { + bm->tx_buf_free(dev, txq, &txq->pbuf[di]); + } + /* Config transmit descriptor ring */ + cmicx_tx_desc_config(&ring[di], 0, 0, 0); + rm = (txq->nb_desc - di) >= CMICX_DESC_REMAIN_MAX ? + CMICX_DESC_REMAIN_MAX : txq->nb_desc - di; + cmicx_tx_desc_remain(&ring[di], rm); + if (hw->dev->flags & PDMA_CHAIN_MODE) { + cmicx_tx_desc_chain(&ring[di], 0); + } + } + /* Config the last descriptor in the ring as reload descriptor */ + cmicx_tx_rldesc_config(&ring[di], txq->ring_addr); + + txq->curr = 0; + txq->dirt = 0; + txq->halt = 0; + + txq->halt_addr = txq->ring_addr; + hw->hdls.chan_goto(hw, txq->chan_id, txq->halt_addr); + hw->hdls.chan_setup(hw, txq->chan_id, txq->ring_addr); + + return SHR_E_NONE; +} + +/*! + * Cleanup Tx descriptors + */ +static int +cmicx_pdma_tx_desc_clean(struct pdma_hw *hw, struct pdma_tx_queue *txq) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + struct cmicx_tx_desc *ring = (struct cmicx_tx_desc *)txq->ring; + uint32_t di; + + /* Go through all the descriptors and free pktbuf */ + for (di = 0; di < txq->nb_desc; di++) { + if (txq->pbuf[di].dma) { + bm->tx_buf_free(dev, txq, &txq->pbuf[di]); + } + cmicx_tx_desc_config(&ring[di], 0, 0, 0); + } + + txq->curr = 0; + txq->dirt = 0; + txq->halt = 0; + + return SHR_E_NONE; +} + +/*! + * Process Rx vring + */ +static int +cmicx_pdma_rx_vring_process(struct pdma_hw *hw, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf) +{ + struct pdma_dev *dev = hw->dev; + struct cmicx_rx_desc *ring = (struct cmicx_rx_desc *)rxq->ring; + struct pdma_rx_queue *vrxq = NULL; + struct cmicx_rx_desc *vring = NULL; + struct pkt_hdr *pkh = &pbuf->pkb->pkh; + uint64_t buf_addr; + + vrxq = (struct pdma_rx_queue *)dev->ctrl.vnet_rxq[rxq->queue_id]; + vring = (struct cmicx_rx_desc *)vrxq->ring; + if (!vring) { + rxq->stats.dropped++; + return SHR_E_UNAVAIL; + } + + if (vring[vrxq->curr].status & CMICX_DESC_STAT_RTX_DONE) { + dev->xnet_wake(dev); + return SHR_E_BUSY; + } + + /* Copy descriptor and packet to vring */ + buf_addr = BUS_TO_DMA_HI(vring[vrxq->curr].addr_hi); + buf_addr = buf_addr << 32 | vring[vrxq->curr].addr_lo; + sal_memcpy(dev->sys_p2v(dev, buf_addr), &pbuf->pkb->data, + pkh->meta_len + pkh->data_len); + vring[vrxq->curr].status = ring[rxq->curr].status; + + MEMORY_BARRIER; + + /* Notify VNET to process if needed */ + if (!vring[(vrxq->curr + vrxq->nb_desc - 1) % vrxq->nb_desc].status) { + dev->xnet_wake(dev); + } + vrxq->curr = (vrxq->curr + 1) % vrxq->nb_desc; + + return SHR_E_NONE; +} + +/*! + * Refill Rx ring + */ +static int +cmicx_pdma_rx_ring_refill(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + struct cmicx_rx_desc *ring = (struct cmicx_rx_desc *)rxq->ring; + struct pdma_rx_buf *pbuf = NULL; + int unused = cmicx_pdma_rx_ring_unused(rxq); + dma_addr_t addr; + uint32_t halt; + int rv; + + for (halt = rxq->halt; halt < rxq->halt + unused; halt++) { + pbuf = &rxq->pbuf[halt % rxq->nb_desc]; + /* Allocate a new pktbuf */ + if (!bm->rx_buf_avail(dev, rxq, pbuf)) { + rv = bm->rx_buf_alloc(dev, rxq, pbuf); + if (SHR_FAILURE(rv)) { + rxq->halt = halt % rxq->nb_desc; + rxq->stats.nomems++; + goto fail; + } + } + /* Setup the new descriptor */ + bm->rx_buf_dma(dev, rxq, pbuf, &addr); + cmicx_rx_desc_config(&ring[halt % rxq->nb_desc], addr, rxq->buf_size); + if (dev->flags & PDMA_CHAIN_MODE && halt % rxq->nb_desc == rxq->nb_desc - 1) { + cmicx_rx_desc_chain(&ring[halt % rxq->nb_desc], 0); + } + } + + sal_spinlock_lock(rxq->lock); + rxq->halt = halt % rxq->nb_desc; + if (!(rxq->state & PDMA_RX_QUEUE_XOFF)) { + /* Descriptor cherry pick */ + rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicx_rx_desc) * rxq->halt; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + } + sal_spinlock_unlock(rxq->lock); + + return SHR_E_NONE; + +fail: + CNET_PR("RX: Failed to allocate mem\n"); + + return SHR_E_MEMORY; +} + +/*! + * \brief Clean Rx ring + * + * \param [in] hw HW structure point. + * \param [in] rxq Rx queue structure point. + * \param [in] budget Polling budget. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +cmicx_pdma_rx_ring_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq, int budget) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + struct cmicx_rx_desc *ring = (struct cmicx_rx_desc *)rxq->ring; + struct pdma_rx_buf *pbuf = NULL; + struct pkt_hdr *pkh = NULL; + dma_addr_t addr; + uint32_t stat, curr; + int len, done = 0; + int rv; + + curr = rxq->curr; + while (CMICX_DESC_STAT_DONE(ring[curr].status)) { + if (dev->mode == DEV_MODE_VNET && rxq->state & PDMA_RX_QUEUE_XOFF) { + break; + } + if (!(rxq->state & PDMA_RX_BATCH_REFILL) && + !(rxq->state & PDMA_RX_QUEUE_XOFF)) { + /* Descriptor cherry pick */ + rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicx_rx_desc) * curr; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + rxq->halt = curr; + } + if (done == budget) { + break; + } + + /* Get the current pktbuf to process */ + pbuf = &rxq->pbuf[curr]; + stat = ring[curr].status; + len = CMICX_DESC_STAT_LEN(stat); + pkh = bm->rx_buf_get(dev, rxq, pbuf, len); + if (!pkh) { + rxq->stats.nomems++; + goto fail; + } + + /* Setup packet header */ + pkh->data_len = len - hw->info.rx_ph_size; + pkh->meta_len = hw->info.rx_ph_size; + pkh->queue_id = rxq->queue_id; + pkh->attrs = CMICX_DESC_STAT_FLAGS(stat); + + /* Send up the packet */ + rv = dev->pkt_recv(dev, rxq->queue_id, (void *)pbuf->skb); + if (SHR_FAILURE(rv)) { + if (dev->mode == DEV_MODE_HNET && pkh->attrs & PDMA_RX_TO_VNET) { + rv = cmicx_pdma_rx_vring_process(hw, rxq, pbuf); + if (SHR_FAILURE(rv) && rv == SHR_E_BUSY) { + rxq->state |= PDMA_RX_QUEUE_BUSY; + return done; + } + } else { + rxq->stats.dropped++; + } + bm->rx_buf_put(dev, rxq, pbuf, len); + } + + /* Count the packets/bytes */ + rxq->stats.packets++; + rxq->stats.bytes += len; + + /* Count the errors if any */ + if (stat & CMICX_DESC_STAT_ERR_MASK) { + rxq->stats.errors++; + if (stat & CMICX_DESC_STAT_DATA_ERR) { + rxq->stats.data_errors++; + } + if (stat & CMICX_DESC_STAT_CELL_ERR) { + rxq->stats.cell_errors++; + } + } + + /* Setup the new descriptor */ + if (!(rxq->state & PDMA_RX_BATCH_REFILL)) { + if (!bm->rx_buf_avail(dev, rxq, pbuf)) { + rv = bm->rx_buf_alloc(dev, rxq, pbuf); + if (SHR_FAILURE(rv)) { + rxq->stats.nomems++; + goto fail; + } + } + bm->rx_buf_dma(dev, rxq, pbuf, &addr); + cmicx_rx_desc_config(&ring[curr], addr, rxq->buf_size); + if (dev->flags & PDMA_CHAIN_MODE && curr == rxq->nb_desc - 1) { + cmicx_rx_desc_chain(&ring[curr], 0); + } + } else { + cmicx_rx_desc_config(&ring[curr], 0, 0); + } + + /* Notify HNET to process if needed */ + if (dev->mode == DEV_MODE_VNET) { + MEMORY_BARRIER; + if (ring[(curr + rxq->nb_desc - 1) % rxq->nb_desc].status) { + dev->xnet_wake(dev); + } + } + + /* Update the indicators */ + if (!(rxq->state & PDMA_RX_BATCH_REFILL) && rxq->halt != curr) { + sal_spinlock_lock(rxq->lock); + if (!(rxq->state & PDMA_RX_QUEUE_XOFF)) { + /* Descriptor cherry pick */ + rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicx_rx_desc) * curr; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + rxq->halt = curr; + } + curr = (curr + 1) % rxq->nb_desc; + sal_spinlock_unlock(rxq->lock); + } else { + curr = (curr + 1) % rxq->nb_desc; + } + rxq->curr = curr; + done++; + + /* Restart DMA if in chain mode */ + if (dev->flags & PDMA_CHAIN_MODE) { + if (curr == 0 && !(rxq->state & PDMA_RX_QUEUE_XOFF)) { + hw->hdls.chan_stop(hw, rxq->chan_id); + hw->hdls.chan_start(hw, rxq->chan_id); + } + } + } + + /* One more poll for chain done in chain mode */ + if (dev->flags & PDMA_CHAIN_MODE) { + if (curr == rxq->nb_desc - 1 && done) { + done = budget; + } + } + + /* In batching mode, replenish all the unused descriptors */ + if (rxq->state & PDMA_RX_BATCH_REFILL && + cmicx_pdma_rx_ring_unused(rxq) >= (int)rxq->free_thresh) { + cmicx_pdma_rx_ring_refill(hw, rxq); + } + + /* Notify the other side to process */ + if (dev->mode == DEV_MODE_VNET || dev->mode == DEV_MODE_HNET) { + if (done) { + dev->xnet_wake(dev); + } + } + + return done; + +fail: + CNET_PR("RX: Failed to allocate mem\n"); + + return done; +} + +/*! + * Process Tx vring + */ +static int +cmicx_pdma_tx_vring_process(struct pdma_hw *hw, struct pdma_tx_queue *txq, + struct pdma_tx_buf *pbuf) +{ + struct pdma_dev *dev = hw->dev; + struct cmicx_tx_desc *ring = (struct cmicx_tx_desc *)txq->ring; + struct pdma_tx_queue *vtxq = NULL; + struct cmicx_tx_desc *vring = NULL; + + vtxq = (struct pdma_tx_queue *)dev->ctrl.vnet_txq[txq->queue_id]; + vring = (struct cmicx_tx_desc *)vtxq->ring; + if (!vring) { + return SHR_E_UNAVAIL; + } + + /* Update vring descriptor */ + vring[vtxq->dirt].status = ring[txq->dirt].status; + pbuf->dma = 0; + + MEMORY_BARRIER; + + /* Notify VNET to process if needed */ + if (!vring[(vtxq->dirt + vtxq->nb_desc - 1) % vtxq->nb_desc].status) { + dev->xnet_wake(dev); + } + vtxq->dirt = (vtxq->dirt + 1) % vtxq->nb_desc; + + return SHR_E_NONE; +} + +/*! + * \brief Clean Tx ring + * + * \param [in] hw HW structure point. + * \param [in] txq Tx queue structure point. + * \param [in] budget Polling budget. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +cmicx_pdma_tx_ring_clean(struct pdma_hw *hw, struct pdma_tx_queue *txq, int budget) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + struct cmicx_tx_desc *ring = (struct cmicx_tx_desc *)txq->ring; + uint32_t dirt, curr; + int done = 0; + + dirt = txq->dirt; + while (txq->pbuf[dirt].dma) { + if (!CMICX_DESC_STAT_DONE(ring[dirt].status)) { + break; + } + if (done == budget) { + break; + } + + if (dev->mode == DEV_MODE_HNET && !txq->pbuf[dirt].skb) { + cmicx_pdma_tx_vring_process(hw, txq, &txq->pbuf[dirt]); + } else { + /* Free the done pktbuf */ + bm->tx_buf_free(dev, txq, &txq->pbuf[dirt]); + } + + cmicx_tx_desc_config(&ring[dirt], 0, 0, 0); + + /* Update the indicators */ + dirt = (dirt + 1) % txq->nb_desc; + txq->dirt = dirt; + done++; + + /* Restart DMA if in chain mode */ + if (dev->flags & PDMA_CHAIN_MODE) { + sal_spinlock_lock(txq->lock); + curr = txq->curr; + if (dirt == txq->halt && dirt != curr) { + hw->hdls.chan_stop(hw, txq->chan_id); + cmicx_tx_desc_chain(&ring[(curr + txq->nb_desc - 1) % txq->nb_desc], 0); + hw->hdls.chan_setup(hw, txq->chan_id, + txq->ring_addr + sizeof(struct cmicx_tx_desc) * txq->halt); + hw->hdls.chan_start(hw, txq->chan_id); + txq->halt = curr; + } + sal_spinlock_unlock(txq->lock); + } + } + + /* One more poll for chain done in chain mode */ + if (dev->flags & PDMA_CHAIN_MODE) { + sal_spinlock_lock(txq->lock); + if (dirt != txq->halt) { + done = budget; + } + sal_spinlock_unlock(txq->lock); + } + + /* Resume Tx if any */ + sal_spinlock_lock(txq->lock); + if (cmicx_pdma_tx_ring_unused(txq) && txq->state & PDMA_TX_QUEUE_XOFF) { + txq->state &= ~PDMA_TX_QUEUE_XOFF; + sal_spinlock_unlock(txq->lock); + if (dev->tx_resume) { + dev->tx_resume(dev, txq->queue_id); + } else if (!(txq->state & PDMA_TX_QUEUE_POLL)) { + sal_sem_give(txq->sem); + } + return done; + } + sal_spinlock_unlock(txq->lock); + + return done; +} + +/*! + * Dump Rx ring + */ +static int +cmicx_pdma_rx_ring_dump(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + struct cmicx_rx_desc *ring = (struct cmicx_rx_desc *)rxq->ring; + struct cmicx_rx_desc *rd; + uint32_t di; + + CNET_PR("\nRX: queue=%d, chan=%d, curr=%d, halt=%d, halt@%p\n", + rxq->queue_id, rxq->chan_id, rxq->curr, rxq->halt, (void *)&ring[rxq->halt]); + CNET_PR("----------------------------------------------------------------\n"); + for (di = 0; di < rxq->nb_desc + 1; di++) { + rd = &ring[di]; + CNET_PR("DESC[%03d]: (%p)->%08x %08x %08x %08x\n", + di, (void *)(unsigned long)(rxq->ring_addr + di * CMICX_PDMA_DCB_SIZE), + rd->addr_lo, rd->addr_hi, rd->ctrl, rd->status); + } + + return SHR_E_NONE; +} + +/*! + * Dump Tx ring + */ +static int +cmicx_pdma_tx_ring_dump(struct pdma_hw *hw, struct pdma_tx_queue *txq) +{ + struct cmicx_tx_desc *ring = (struct cmicx_tx_desc *)txq->ring; + struct cmicx_tx_desc *td; + uint32_t di; + + CNET_PR("\nTX: queue=%d, chan=%d, curr=%d, dirt=%d, halt@%p\n", + txq->queue_id, txq->chan_id, txq->curr, txq->dirt, (void *)&ring[txq->curr]); + CNET_PR("----------------------------------------------------------------\n"); + for (di = 0; di < txq->nb_desc + 1; di++) { + td = &ring[di]; + CNET_PR("DESC[%03d]: (%p)->%08x %08x %08x %08x\n", + di, (void *)(unsigned long)(txq->ring_addr + di * CMICX_PDMA_DCB_SIZE), + td->addr_lo, td->addr_hi, td->ctrl, td->status); + } + + return SHR_E_NONE; +} + +/*! + * Fetch Tx vring + */ +static int +cmicx_pdma_tx_vring_fetch(struct pdma_hw *hw, struct pdma_tx_queue *txq, + struct pdma_tx_buf *pbuf) +{ + struct pdma_dev *dev = hw->dev; + struct cmicx_tx_desc *ring = (struct cmicx_tx_desc *)txq->ring; + struct pdma_tx_queue *vtxq = NULL; + struct cmicx_tx_desc *vring = NULL; + + vtxq = (struct pdma_tx_queue *)dev->ctrl.vnet_txq[txq->queue_id]; + vring = (struct cmicx_tx_desc *)vtxq->ring; + if (!vring || !CMICX_DESC_CTRL_LEN(vring[vtxq->curr].ctrl)) { + return SHR_E_UNAVAIL; + } + + /* Fetch vring descriptor */ + sal_memcpy(&ring[txq->curr], &vring[vtxq->curr], sizeof(struct cmicx_tx_desc)); + vring[vtxq->curr].ctrl &= ~CMICX_DESC_CTRL_LEN(-1); + + MEMORY_BARRIER; + + pbuf->dma = vring[vtxq->curr].addr_lo; + pbuf->len = CMICX_DESC_CTRL_LEN(ring[txq->curr].ctrl); + vtxq->curr = (vtxq->curr + 1) % vtxq->nb_desc; + + return SHR_E_NONE; +} + +/*! + * Check Tx ring + */ +static inline int +cmicx_pdma_tx_ring_check(struct pdma_hw *hw, struct pdma_tx_queue *txq) +{ + if (cmicx_pdma_tx_ring_unused(txq)) { + return SHR_E_NONE; + } + + sal_spinlock_lock(txq->lock); + if (!cmicx_pdma_tx_ring_unused(txq)) { + txq->state |= PDMA_TX_QUEUE_XOFF; + txq->stats.xoffs++; + sal_spinlock_unlock(txq->lock); + if (hw->dev->tx_suspend) { + hw->dev->tx_suspend(hw->dev, txq->queue_id); + } + return SHR_E_BUSY; + } + sal_spinlock_unlock(txq->lock); + + return SHR_E_NONE; +} + +/*! + * \brief Start packet transmission + * + * \param [in] hw HW structure point. + * \param [in] txq Tx queue structure point. + * \param [in] buf Tx packet buffer. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +cmicx_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + struct cmicx_tx_desc *ring = (struct cmicx_tx_desc *)txq->ring; + struct pdma_tx_buf *pbuf = NULL; + struct pkt_hdr *pkh = NULL; + dma_addr_t addr; + uint32_t curr, flags = 0; + int retry = 5000000; + int rv; + + if (!(txq->state & PDMA_TX_QUEUE_ACTIVE)) { + return SHR_E_UNAVAIL; + } + + if (dev->tx_suspend) { + sal_spinlock_lock(txq->mutex); + } else { + sal_sem_take(txq->sem, SAL_SEM_FOREVER); + } + + /* Check Tx resource */ + if (dev->tx_suspend) { + /* Suspend Tx if no resource */ + rv = cmicx_pdma_tx_ring_check(hw, txq); + if (SHR_FAILURE(rv)) { + sal_spinlock_unlock(txq->mutex); + return rv; + } + } else { + /* Abort Tx if a fatal error happened */ + if (txq->state & PDMA_TX_QUEUE_XOFF) { + sal_sem_give(txq->sem); + return SHR_E_RESOURCE; + } + } + + /* Setup the new descriptor */ + curr = txq->curr; + pbuf = &txq->pbuf[curr]; + if (dev->mode == DEV_MODE_HNET && !buf) { + rv = cmicx_pdma_tx_vring_fetch(hw, txq, pbuf); + if (SHR_FAILURE(rv)) { + sal_spinlock_unlock(txq->mutex); + return SHR_E_EMPTY; + } + } else { + pbuf->adj = 1; + pkh = bm->tx_buf_get(dev, txq, pbuf, buf); + if (!pkh) { + txq->stats.dropped++; + if (dev->tx_suspend) { + sal_spinlock_unlock(txq->mutex); + } else { + sal_sem_give(txq->sem); + } + return SHR_E_NONE; + } + bm->tx_buf_dma(dev, txq, pbuf, &addr); + flags |= pkh->attrs & PDMA_TX_HIGIG_PKT ? CMICX_DESC_TX_HIGIG_PKT : 0; + flags |= pkh->attrs & PDMA_TX_PURGE_PKT ? CMICX_DESC_TX_PURGE_PKT : 0; + cmicx_tx_desc_config(&ring[curr], addr, pbuf->len, flags); + } + + /* Notify HNET to process if needed */ + if (dev->mode == DEV_MODE_VNET) { + MEMORY_BARRIER; + if (!CMICX_DESC_CTRL_LEN(ring[(curr + txq->nb_desc - 1) % txq->nb_desc].ctrl)) { + dev->xnet_wake(dev); + } + } + + /* Update the indicators */ + curr = (curr + 1) % txq->nb_desc; + txq->curr = curr; + + /* Start DMA if in chain mode */ + if (dev->flags & PDMA_CHAIN_MODE) { + if (txq->state & PDMA_TX_QUEUE_POLL) { + do { + rv = cmicx_pdma_tx_ring_clean(hw, txq, txq->nb_desc - 1); + if (rv != (int)txq->nb_desc - 1) { + break; + } + sal_usleep(1); + } while (retry--); + if (retry <= 0) { + CNET_PR("Last Tx could not be done in given time\n"); + } + } + sal_spinlock_lock(txq->lock); + if (txq->dirt == txq->halt && txq->dirt != curr) { + hw->hdls.chan_stop(hw, txq->chan_id); + cmicx_tx_desc_chain(&ring[(curr + txq->nb_desc - 1) % txq->nb_desc], 0); + hw->hdls.chan_setup(hw, txq->chan_id, + txq->ring_addr + sizeof(struct cmicx_tx_desc) * txq->halt); + hw->hdls.chan_start(hw, txq->chan_id); + txq->halt = curr; + } + sal_spinlock_unlock(txq->lock); + } + + /* Kick off DMA */ + txq->halt_addr = txq->ring_addr + sizeof(struct cmicx_tx_desc) * curr; + hw->hdls.chan_goto(hw, txq->chan_id, txq->halt_addr); + + /* Count the packets/bytes */ + txq->stats.packets++; + txq->stats.bytes += pbuf->len; + + /* Clean up ring if in polling mode */ + if (txq->state & PDMA_TX_QUEUE_POLL && + cmicx_pdma_tx_ring_unused(txq) <= (int)txq->free_thresh) { + cmicx_pdma_tx_ring_clean(hw, txq, txq->nb_desc - txq->free_thresh); + } + + /* Suspend Tx if no resource */ + rv = cmicx_pdma_tx_ring_check(hw, txq); + if (SHR_FAILURE(rv)) { + if (dev->mode == DEV_MODE_VNET) { + dev->xnet_wake(dev); + } + + if (txq->state & PDMA_TX_QUEUE_POLL) { + /* In polling mode, must wait till the ring is available */ + do { + cmicx_pdma_tx_ring_clean(hw, txq, txq->free_thresh); + if (!(txq->state & PDMA_TX_QUEUE_XOFF)) { + break; + } + sal_usleep(1); + } while (retry--); + if (retry <= 0) { + CNET_PR("Fatal error: Tx ring is full, packets have not been transmitted for 5 seconds\n"); + if (!dev->tx_suspend) { + sal_sem_give(txq->sem); + return SHR_E_RESOURCE; + } + } + } else { + /* In interrupt mode, the handle thread will wake up Tx */ + if (!dev->tx_suspend) { + return SHR_E_NONE; + } + } + } + + if (dev->tx_suspend) { + sal_spinlock_unlock(txq->mutex); + } else { + sal_sem_give(txq->sem); + } + + return SHR_E_NONE; +} + +/*! + * Suspend Rx queue + */ +static int +cmicx_pdma_rx_suspend(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + sal_spinlock_lock(rxq->lock); + rxq->state |= PDMA_RX_QUEUE_XOFF; + if (hw->dev->flags & PDMA_CHAIN_MODE) { + hw->hdls.chan_stop(hw, rxq->chan_id); + } + sal_spinlock_unlock(rxq->lock); + + return SHR_E_NONE; +} + +/*! + * Resume Rx queue + */ +static int +cmicx_pdma_rx_resume(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + sal_spinlock_lock(rxq->lock); + if (!(rxq->state & PDMA_RX_QUEUE_XOFF)) { + sal_spinlock_unlock(rxq->lock); + return SHR_E_NONE; + } + if (rxq->state & PDMA_RX_BATCH_REFILL) { + rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicx_rx_desc) * rxq->halt; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + } else if (rxq->halt == rxq->curr || (rxq->halt == rxq->nb_desc && rxq->curr == 0)) { + rxq->halt = (rxq->curr + 1) % rxq->nb_desc; + rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicx_rx_desc) * rxq->halt; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + } + if (hw->dev->flags & PDMA_CHAIN_MODE) { + rxq->curr = 0; + hw->hdls.chan_start(hw, rxq->chan_id); + } + rxq->state &= ~PDMA_RX_QUEUE_XOFF; + sal_spinlock_unlock(rxq->lock); + + return SHR_E_NONE; +} + +/*! + * Initialize function pointers + */ +int +bcmcnet_cmicx_pdma_desc_ops_init(struct pdma_hw *hw) +{ + if (!hw) { + return SHR_E_PARAM; + } + + hw->dops.rx_desc_init = cmicx_pdma_rx_desc_init; + hw->dops.rx_desc_clean = cmicx_pdma_rx_desc_clean; + hw->dops.rx_ring_clean = cmicx_pdma_rx_ring_clean; + hw->dops.rx_ring_dump = cmicx_pdma_rx_ring_dump; + hw->dops.rx_suspend = cmicx_pdma_rx_suspend; + hw->dops.rx_resume = cmicx_pdma_rx_resume; + hw->dops.tx_desc_init = cmicx_pdma_tx_desc_init; + hw->dops.tx_desc_clean = cmicx_pdma_tx_desc_clean; + hw->dops.tx_ring_clean = cmicx_pdma_tx_ring_clean; + hw->dops.tx_ring_dump = cmicx_pdma_tx_ring_dump; + hw->dops.pkt_xmit = cmicx_pdma_pkt_xmit; + + return SHR_E_NONE; +} + +/*! + * Attach device driver + */ +int +bcmcnet_cmicx_pdma_driver_attach(struct pdma_dev *dev) +{ + struct pdma_hw *hw = NULL; + + /* Allocate memory for HW data */ + hw = sal_alloc(sizeof(*hw), "bcmcnetPdmaHw"); + if (!hw) { + return SHR_E_MEMORY; + } + sal_memset(hw, 0, sizeof(*hw)); + hw->unit = dev->unit; + hw->dev = dev; + dev->ctrl.hw = hw; + + bcmcnet_cmicx_pdma_hw_hdls_init(hw); + bcmcnet_cmicx_pdma_desc_ops_init(hw); + + return SHR_E_NONE; +} + +/*! + * Detach device driver + */ +int +bcmcnet_cmicx_pdma_driver_detach(struct pdma_dev *dev) +{ + if (dev->ctrl.hw) { + sal_free(dev->ctrl.hw); + } + dev->ctrl.hw = NULL; + + return SHR_E_NONE; +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicd.h b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicd.h new file mode 100644 index 000000000000..ef9717923e70 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicd.h @@ -0,0 +1,369 @@ +/*! \file bcmcnet_cmicd.h + * + * CMICd registers and descriptors definitions. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef BCMCNET_CMICD_H +#define BCMCNET_CMICD_H + +/*! + * \name CMICD PDMA HW definitions + */ +/*! \{ */ +/*! CMICD CMC number */ +#define CMICD_PDMA_CMC_MAX 3 +/*! CMICD CMC PDMA channels */ +#define CMICD_PDMA_CMC_CHAN 4 +/*! CMICD PDMA DCB size */ +#define CMICD_PDMA_DCB_SIZE 64 +/*! \} */ + +/*! + * \name CMICD PDMA register definitions + */ +/*! \{ */ +#define CMICD_PDMA_CTRLr 0x0140 +#define CMICD_PDMA_STATr 0x0150 +#define CMICD_PDMA_STAT_HIr 0x0130 +#define CMICD_PDMA_STAT_CLRr 0x01a4 +#define CMICD_PDMA_DESCr 0x0158 +#define CMICD_PDMA_CURR_DESCr 0x01a8 +#define CMICD_PDMA_DESC_HALTr 0x0120 +#define CMICD_PDMA_COS_RX0r 0x0168 +#define CMICD_PDMA_COS_RX1r 0x016c +#define CMICD_PDMA_COS_MASK0r 0x019c +#define CMICD_PDMA_COS_MASK1r 0x01a0 +#define CMICD_PDMA_INTR_COALr 0x0188 +#define CMICD_PDMA_RBUF_THREr 0x0110 +#define CMICD_PDMA_COUNT_RXr 0x0480 +#define CMICD_PDMA_COUNT_TXr 0x0484 +#define CMICD_PDMA_COUNT_ALL_RXr 0x04a0 +#define CMICD_PDMA_COUNT_ALL_TXr 0x04a4 +#define CMICD_IRQ_STATr 0x0400 +#define CMICD_IRQ_PCI_MASKr 0x0414 +#define CMICD_IRQ_UC0_MASKr 0x0428 +/*! \} */ + +/*! + * \name CMICD PDMA register address + */ +/*! \{ */ +/*! Base address */ +#define CMICD_GRP_BASE(g) (0x00031000 + 0x1000 * g) +/*! Control register address */ +#define CMICD_PDMA_CTRL(g, q) (CMICD_GRP_BASE(g) + CMICD_PDMA_CTRLr + q * 4) +/*! Status register address */ +#define CMICD_PDMA_STAT(g) (CMICD_GRP_BASE(g) + CMICD_PDMA_STATr) +/*! Status higher register address */ +#define CMICD_PDMA_STAT_HI(g) (CMICD_GRP_BASE(g) + CMICD_PDMA_STAT_HIr) +/*! Status clear register address */ +#define CMICD_PDMA_STAT_CLR(g) (CMICD_GRP_BASE(g) + CMICD_PDMA_STAT_CLRr) +/*! Descriptor register address */ +#define CMICD_PDMA_DESC(g, q) (CMICD_GRP_BASE(g) + CMICD_PDMA_DESCr + q * 4) +/*! Current descriptor register address */ +#define CMICD_PDMA_CURR_DESC(g, q) (CMICD_GRP_BASE(g) + CMICD_PDMA_CURR_DESCr + q * 4) +/*! Descriptor halt register address */ +#define CMICD_PDMA_DESC_HALT(g, q) (CMICD_GRP_BASE(g) + CMICD_PDMA_DESC_HALTr + q * 4) +/*! COS Rx0 register address */ +#define CMICD_PDMA_COS_RX0(g, q) (CMICD_GRP_BASE(g) + CMICD_PDMA_COS_RX0r + q * 8) +/*! COS Rx1 register address */ +#define CMICD_PDMA_COS_RX1(g, q) (CMICD_GRP_BASE(g) + CMICD_PDMA_COS_RX1r + q * 8) +/*! COS Mask0 register address */ +#define CMICD_PDMA_COS_MASK0(g) (CMICD_GRP_BASE(g) + CMICD_PDMA_COS_MASK0r) +/*! COS Mask1 register address */ +#define CMICD_PDMA_COS_MASK1(g) (CMICD_GRP_BASE(g) + CMICD_PDMA_COS_MASK1r) +/*! Interrupt coalesce register address */ +#define CMICD_PDMA_INTR_COAL(g, q) (CMICD_GRP_BASE(g) + CMICD_PDMA_INTR_COALr + q * 4) +/*! Rx buffer threshhold register address */ +#define CMICD_PDMA_RBUF_THRE(g, q) (CMICD_GRP_BASE(g) + CMICD_PDMA_RBUF_THREr + q * 4) +/*! Rx counter register address */ +#define CMICD_PDMA_COUNT_RX(g, q) (CMICD_GRP_BASE(g) + CMICD_PDMA_COUNT_RXr + q * 8) +/*! Tx counter register address */ +#define CMICD_PDMA_COUNT_TX(g, q) (CMICD_GRP_BASE(g) + CMICD_PDMA_COUNT_TXr + q * 8) +/*! Rx global counter register address */ +#define CMICD_PDMA_COUNT_ALL_RX(g) (CMICD_GRP_BASE(g) + CMICD_PDMA_COUNT_ALL_RXr) +/*! Tx gloable counter register address */ +#define CMICD_PDMA_COUNT_ALL_TX(g) (CMICD_GRP_BASE(g) + CMICD_PDMA_COUNT_ALL_TXr) +/*! Interrupt status register address */ +#define CMICD_IRQ_STAT(g) (CMICD_GRP_BASE(g) + CMICD_IRQ_STATr) +/*! Interrupt PCI mask register address */ +#define CMICD_IRQ_PCI_MASK(g) (CMICD_GRP_BASE(g) + CMICD_IRQ_PCI_MASKr) +/*! Interrupt UC0 mask register address */ +#define CMICD_IRQ_UC0_MASK(g) (CMICD_GRP_BASE(g) + CMICD_IRQ_UC0_MASKr) +/*! Credits release release register address */ +#define CMICD_EPINTF_RELEASE_CREDITS 0x0001a000 +/*! Device revision register address */ +#define CMICD_DEV_REV_ID 0x00010224 +/*! CMIC revison register address */ +#define CMICD_CMICM_REV_ID 0x00010228 +/*! \} */ + +/*! + * \name Control register definitions + */ +/*! \{ */ +/*! Continuous DMA mode */ +#define CMICD_PDMA_CONTINUOUS 0x00000200 +/*! Controlled interrupt */ +#define CMICD_PDMA_CNTLD_INTR 0x00000100 +/*! Update status on reload */ +#define CMICD_PDMA_RLD_STAT_DIS 0x00000080 +/*! Dropped on chain end */ +#define CMICD_PDMA_DROP_ON_END 0x00000040 +/*! Descriptor big endianess */ +#define CMICD_PDMA_DESC_BIG_ENDIAN 0x00000020 +/*! Packet DMA big endianess */ +#define CMICD_PDMA_PKT_BIG_ENDIAN 0x00000010 +/*! Interrupt after descriptor */ +#define CMICD_PDMA_INTR_ON_DESC 0x00000008 +/*! Abort DMA */ +#define CMICD_PDMA_ABORT 0x00000004 +/*! Enable DMA */ +#define CMICD_PDMA_ENABLE 0x00000002 +/*! DMA direction */ +#define CMICD_PDMA_DIR 0x00000001 +/*! \} */ + +/*! + * \name Status register definitions + */ +/*! \{ */ +/*! Chain done */ +#define CMICD_PDMA_CHAIN_DONE(q) (0x00000001 << (q)) +/*! Descriptor done */ +#define CMICD_PDMA_DESC_DONE(q) (0x00000010 << (q)) +/*! Active */ +#define CMICD_PDMA_ACTIVE(q) (0x00000100 << (q)) +/*! \} */ + +/*! + * \name Status clear register definitions + */ +/*! \{ */ +/*! Clear completed interrupt */ +#define CMICD_PDMA_DESC_CMPLT(q) (0x00000001 << (q)) +/*! Clear controlled interrupt */ +#define CMICD_PDMA_DESC_CNTLD(q) (0x00000100 << (q)) +/*! \} */ + +/*! + * \name Interrupt_coalesce register definitions + */ +/*! \{ */ +/*! Interrupt coalesce enable */ +#define CMICD_PDMA_INTR_COAL_ENA (1 << 31) +/*! Interrupt coalesce threshhold */ +#define CMICD_PDMA_INTR_THRESH(cnt) (((cnt) & 0x7fff) << 16) +/*! Interrupt coalesce timeout */ +#define CMICD_PDMA_INTR_TIMER(tmr) ((tmr) & 0xffff) +/*! \} */ + +/*! + * \name Interrupt status&mask register definitions + */ +/*! \{ */ +/*! Interrupt mask */ +#define CMICD_PDMA_IRQ_MASK 0x78000000 +/*! Descriptor done */ +#define CMICD_IRQ_DESC_DONE(q) (0x00004000 >> (2 * (q))) +/*! Chain done */ +#define CMICD_IRQ_CHAIN_DONE(q) (0x00008000 >> (2 * (q))) +/*! Controlled interrupt */ +#define CMICD_IRQ_DESC_CNTLD(q) (0x08000000 << (q)) +/*! Interrupt start number */ +#define CMICD_IRQ_START_NUM 27 +/*! Interrupt number offset */ +#define CMICD_IRQ_NUM_OFFSET 1 +/*! Interrupt mask shift */ +#define CMICD_IRQ_MASK_SHIFT 0 +/*! Interrupt mask zeroing */ +#define CMICD_IRQ_ACT_CHAN(mask) (((mask) & CMICD_PDMA_IRQ_MASK) >> CMICD_IRQ_START_NUM) +/*! \} */ + +/*! 32-bit register read */ +#define DEV_READ32(_c, _a, _p) \ + do { \ + if ((_c)->dev->mode != DEV_MODE_VNET) { \ + *(_p) = ((volatile uint32_t *)(_c)->hw_addr)[(_a) / 4]; \ + } \ + } while (0) + +/*! 32-bit register write */ +#define DEV_WRITE32(_c, _a, _v) \ + do { \ + if ((_c)->dev->mode != DEV_MODE_VNET) { \ + ((volatile uint32_t *)(_c)->hw_addr)[(_a) / 4] = (_v); \ + } \ + } while (0) + +/*! + * \brief Rx metadata in descriptor. + */ +struct rx_metadata { + /*! Metadata */ + volatile uint32_t data[13]; + + /*! Status */ + volatile uint32_t status; +} __attribute__((packed)); + +/*! + * \brief Rx descriptor. + */ +struct cmicd_rx_desc { + /*! Packet address */ + volatile uint32_t addr; + + /*! Packet control */ + volatile uint32_t ctrl; + + /*! Metadata fields */ + struct rx_metadata md; +} __attribute__((packed)); + +/*! Reserve Rx meta data size in packet buffer */ +#define CMICD_RX_META_RESV 64 + +/*! + * \brief Tx metadata in descriptor. + */ +struct tx_metadata { + /*! Metadata */ + volatile uint32_t data[4]; + + /*! Reserved */ + volatile uint32_t rsvd[9]; + + /*! Status */ + volatile uint32_t status; +} __attribute__((packed)); + +/*! + * \brief Tx descriptor. + */ +struct cmicd_tx_desc { + /*! Packet address */ + volatile uint32_t addr; + + /*! Packet control */ + volatile uint32_t ctrl; + + /*! Metadata fields */ + struct tx_metadata md; +} __attribute__((packed)); + +/*! Reserve Tx meta data size in packet buffer */ +#define CMICD_TX_META_RESV 16 + +/*! + * Flags related to descriptors. + */ +/*! Controlled interrupt */ +#define CMICD_DESC_CTRL_CNTLD_INTR (1 << 24) +/*! Completed interrupt */ +#define CMICD_DESC_CTRL_CMPLT_INTR (1 << 23) +/*! Reload DCB */ +#define CMICD_DESC_CTRL_RELOAD (1 << 18) +/*! Scatter DCB */ +#define CMICD_DESC_CTRL_SCATTER (1 << 17) +/*! Chained DCB */ +#define CMICD_DESC_CTRL_CHAIN (1 << 16) +/*! Control flags */ +#define CMICD_DESC_CTRL_FLAGS(f) (((f) & 0xffff) << 16) +/*! Purge packet */ +#define CMICD_DESC_TX_PURGE_PKT (1 << 6) +/*! Pause packet */ +#define CMICD_DESC_TX_PAUSE_PKT (1 << 5) +/*! Higig packet */ +#define CMICD_DESC_TX_HIGIG_PKT (1 << 3) +/*! Packet length */ +#define CMICD_DESC_CTRL_LEN(len) ((len) & 0xffff) +/*! Done */ +#define CMICD_DESC_STAT_RTX_DONE (1 << 31) +/*! Head error */ +#define CMICD_DESC_STAT_HEAD_ERR (1 << 20) +/*! Data error */ +#define CMICD_DESC_STAT_DATA_ERR (1 << 19) +/*! Cell error */ +#define CMICD_DESC_STAT_CELL_ERR (1 << 18) +/*! Error mask */ +#define CMICD_DESC_STAT_ERR_MASK (CMICD_DESC_STAT_HEAD_ERR | \ + CMICD_DESC_STAT_DATA_ERR | \ + CMICD_DESC_STAT_CELL_ERR) +/*! Packet start */ +#define CMICD_DESC_STAT_PKT_START (1 << 17) +/*! Packet end */ +#define CMICD_DESC_STAT_PKT_END (1 << 16) +/*! Get done state */ +#define CMICD_DESC_STAT_DONE(stat) ((stat) & CMICD_DESC_STAT_RTX_DONE) +/*! Get flags */ +#define CMICD_DESC_STAT_FLAGS(stat) (((stat) >> 16) & ~0x8003) +/*! Get packet length */ +#define CMICD_DESC_STAT_LEN(stat) ((stat) & 0xffff) + +/*! HW access retry times */ +#define CMICD_HW_RETRY_TIMES 100000 + +/*! + * \brief Initialize HW handles. + * + * \param [in] hw HW structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_cmicd_pdma_hw_hdls_init(struct pdma_hw *hw); + +/*! + * \brief Initialize descriptor operations. + * + * \param [in] hw HW structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_cmicd_pdma_desc_ops_init(struct pdma_hw *hw); + +/*! + * \brief Attach device driver. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_cmicd_pdma_driver_attach(struct pdma_dev *dev); + +/*! + * \brief Detach device driver. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_cmicd_pdma_driver_detach(struct pdma_dev *dev); + +#endif /* BCMCNET_CMICD_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicx.h b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicx.h new file mode 100644 index 000000000000..a8657c8b46a9 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicx.h @@ -0,0 +1,379 @@ +/*! \file bcmcnet_cmicx.h + * + * CMICx registers and descriptors definitions. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef BCMCNET_CMICX_H +#define BCMCNET_CMICX_H + +/*! + * \name CMICX PDMA HW definitions + */ +/*! \{ */ +/*! CMICX CMC number */ +#define CMICX_PDMA_CMC_MAX 2 +/*! CMICX CMC PDMA channels */ +#define CMICX_PDMA_CMC_CHAN 8 +/*! CMICX PDMA DCB size */ +#define CMICX_PDMA_DCB_SIZE 16 +/*! \} */ + +/*! + * \name CMICX PCIe device address definitions + */ +/*! \{ */ +/*! CMICX PCIE offset */ +#define CMICX_PCIE_SO_OFFSET 0x10000000 +/*! Higher DMA address to bus address */ +#define DMA_TO_BUS_HI(dma) ((dma) | CMICX_PCIE_SO_OFFSET) +/*! Higher bus address to DMA address */ +#define BUS_TO_DMA_HI(bus) ((bus) & ~CMICX_PCIE_SO_OFFSET) +/*! \} */ + +/*! + * \name CMICX PDMA register definitions + */ +/*! \{ */ +#define CMICX_PDMA_CTRLr 0x2100 +#define CMICX_PDMA_STATr 0x2114 +#define CMICX_PDMA_DESC_LOr 0x2104 +#define CMICX_PDMA_DESC_HIr 0x2108 +#define CMICX_PDMA_CURR_DESC_LOr 0x2124 +#define CMICX_PDMA_CURR_DESC_HIr 0x2128 +#define CMICX_PDMA_DESC_HALT_LOr 0x210c +#define CMICX_PDMA_DESC_HALT_HIr 0x2110 +#define CMICX_PDMA_COS_CTRL_RX0r 0x2118 +#define CMICX_PDMA_COS_CTRL_RX1r 0x211c +#define CMICX_PDMA_INTR_COALr 0x2120 +#define CMICX_PDMA_RBUF_THREr 0x212c +#define CMICX_PDMA_DEBUG_CTRLr 0x2130 +#define CMICX_PDMA_DEBUG_SM_STATr 0x2134 +#define CMICX_PDMA_DEBUG_STATr 0x2138 +#define CMICX_PDMA_COUNT_RXr 0x213c +#define CMICX_PDMA_COUNT_TXr 0x2140 +#define CMICX_PDMA_COUNT_RX_DROPr 0x2144 +#define CMICX_PDMA_DESC_CNT_REQr 0x2148 +#define CMICX_PDMA_DESC_CNT_RXr 0x214c +#define CMICX_PDMA_DESC_CNT_STATr 0x2150 +#define CMICX_PDMA_IRQ_STATr 0x106c +#define CMICX_PDMA_IRQ_STAT_CLRr 0x1074 +/*! \} */ + +/*! + * \name CMICX PDMA register address + */ +/*! \{ */ +/*! Base address */ +#define CMICX_GRP_BASE(g) (0x00000000 + 0x3000 * g) +/*! Control register address */ +#define CMICX_PDMA_CTRL(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_CTRLr + q * 0x80) +/*! Status register address */ +#define CMICX_PDMA_STAT(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_STATr + q * 0x80) +/*! Descriptor Address Lower register address */ +#define CMICX_PDMA_DESC_LO(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_DESC_LOr + q * 0x80) +/*! Descriptor Address Higher register address */ +#define CMICX_PDMA_DESC_HI(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_DESC_HIr + q * 0x80) +/*! Current Descriptor Address Lower register address */ +#define CMICX_PDMA_CURR_DESC_LO(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_CURR_DESC_LOr + q * 0x80) +/*! Current Descriptor Address Higher register address */ +#define CMICX_PDMA_CURR_DESC_HI(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_CURR_DESC_HIr + q * 0x80) +/*! Descriptor Halt Address Lower register address */ +#define CMICX_PDMA_DESC_HALT_LO(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_DESC_HALT_LOr + q * 0x80) +/*! Descriptor Halt Address Higher register address */ +#define CMICX_PDMA_DESC_HALT_HI(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_DESC_HALT_HIr + q * 0x80) +/*! COS Control Rx0 register address */ +#define CMICX_PDMA_COS_CTRL_RX0(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_COS_CTRL_RX0r + q * 0x80) +/*! COS Control Rx1 register address */ +#define CMICX_PDMA_COS_CTRL_RX1(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_COS_CTRL_RX1r + q * 0x80) +/*! Interrupt Coalesce register address */ +#define CMICX_PDMA_INTR_COAL(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_INTR_COALr + q * 0x80) +/*! Rx Buffer Threshhold register address */ +#define CMICX_PDMA_RBUF_THRE(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_RBUF_THREr + q * 0x80) +/*! Debug Control register address */ +#define CMICX_PDMA_DEBUG_CTRL(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_DEBUG_CTRLr + q * 0x80) +/*! Debug Status register address */ +#define CMICX_PDMA_DEBUG_STAT(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_DEBUG_STATr + q * 0x80) +/*! Debug State Machine Status register address */ +#define CMICX_PDMA_DEBUG_SM_STAT(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_DEBUG_SM_STATr + q * 0x80) +/*! Rx Packet Count register address */ +#define CMICX_PDMA_COUNT_RX(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_COUNT_RXr + q * 0x80) +/*! Tx Packet Count register address */ +#define CMICX_PDMA_COUNT_TX(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_COUNT_TXr + q * 0x80) +/*! Dropped Rx Packet Count register address */ +#define CMICX_PDMA_COUNT_RX_DROP(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_COUNT_RX_DROPr + q * 0x80) +/*! Requested Descriptor Count register address */ +#define CMICX_PDMA_DESC_CNT_REQ(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_DESC_CNT_REQr + q * 0x80) +/*! Received Descriptor Count register address */ +#define CMICX_PDMA_DESC_CNT_RX(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_DESC_CNT_RXr + q * 0x80) +/*! Updated Descriptor Count register address */ +#define CMICX_PDMA_DESC_CNT_STAT(g, q) (CMICX_GRP_BASE(g) + CMICX_PDMA_DESC_CNT_STATr + q * 0x80) +/*! Interrupt Status register address */ +#define CMICX_PDMA_IRQ_STAT(g) (CMICX_GRP_BASE(g) + CMICX_PDMA_IRQ_STATr) +/*! Interrupt Status Clear register address */ +#define CMICX_PDMA_IRQ_STAT_CLR(g) (CMICX_GRP_BASE(g) + CMICX_PDMA_IRQ_STAT_CLRr) +/*! Interrupt Enable register address0 */ +#define CMICX_PDMA_IRQ_ENAB0 0x18013100 +/*! Interrupt Enable register address1 */ +#define CMICX_PDMA_IRQ_ENAB1 0x18013104 +/*! Interrupt Enable register address2 */ +#define CMICX_PDMA_IRQ_ENAB2 0x18013108 +/*! Interrupt raw status register address0 */ +#define CMICX_PDMA_IRQ_RAW_STAT0 0x18013150 +/*! Interrupt raw status register address1 */ +#define CMICX_PDMA_IRQ_RAW_STAT1 0x18013154 +/*! Interrupt raw status register address2 */ +#define CMICX_PDMA_IRQ_RAW_STAT2 0x18013158 +/*! EP_TO_CPU Header Size register address */ +#define CMICX_EP_TO_CPU_HEADER_SIZE 0x00000004 +/*! Top config register address */ +#define CMICX_TOP_CONFIG 0x00000008 +/*! Credits release register address */ +#define CMICX_EPINTF_RELEASE_CREDITS 0x0000006c +/*! Max credits register address */ +#define CMICX_EPINTF_MAX_CREDITS 0x00000070 +/*! \} */ + +/*! + * \name Control register definitions + */ +/*! \{ */ +/*! Disable abort on error */ +#define CMICX_PDMA_NO_ABORT_ON_ERR 0x00002000 +/*! EP_TO_CPU header big endianess */ +#define CMICX_PDMA_HDR_BIG_ENDIAN 0x00001000 +/*! Continuous descriptor mode */ +#define CMICX_PDMA_CONTINUOUS_DESC 0x00000200 +/*! Continuous DMA mode */ +#define CMICX_PDMA_CONTINUOUS 0x00000100 +/*! Interrupt after descriptor */ +#define CMICX_PDMA_INTR_ON_DESC 0x00000080 +/*! Update status on reload */ +#define CMICX_PDMA_RLD_STAT_DIS 0x00000040 +/*! Dropped on chain end */ +#define CMICX_PDMA_DROP_ON_END 0x00000020 +/*! Descriptor big endianess */ +#define CMICX_PDMA_DESC_BIG_ENDIAN 0x00000010 +/*! Packet DMA big endianess */ +#define CMICX_PDMA_PKT_BIG_ENDIAN 0x00000008 +/*! Abort DMA */ +#define CMICX_PDMA_ABORT 0x00000004 +/*! Enable DMA */ +#define CMICX_PDMA_ENABLE 0x00000002 +/*! DMA direction */ +#define CMICX_PDMA_DIR 0x00000001 +/*! EP_TO_CPU header alignment bytes */ +#define CMICX_PDMA_HDR_ALMNT(bytes) (((bytes) & 0x3) << 10) +/*! \} */ + +/*! + * \name Status register definitions + */ +/*! \{ */ +/*! Channel in halt */ +#define CMICX_PDMA_IN_HALT 0x00000040 +/*! Channel active */ +#define CMICX_PDMA_IS_ACTIVE 0x00000002 +/*! Chain done */ +#define CMICX_PDMA_CHAIN_DONE 0x00000001 +/*! \} */ + +/*! + * \name Interrupt_coalesce register definitions + */ +/*! \{ */ +/*! Interrupt coalesce enable */ +#define CMICX_PDMA_INTR_COAL_ENA (1 << 31) +/*! Interrupt coalesce threshhold */ +#define CMICX_PDMA_INTR_THRESH(cnt) (((cnt) & 0x7fff) << 16) +/*! Interrupt coalesce timeout */ +#define CMICX_PDMA_INTR_TIMER(tmr) ((tmr) & 0xffff) +/*! \} */ + +/*! + * \name Interrupt status&clear register definitions + */ +/*! \{ */ +/*! Descriptor done */ +#define CMICX_PDMA_IRQ_DESC_DONE(q) (0x00000001 << ((q) * 4)) +/*! Chain done */ +#define CMICX_PDMA_IRQ_CHAIN_DONE(q) (0x00000002 << ((q) * 4)) +/*! Coalescing interrupt */ +#define CMICX_PDMA_IRQ_COALESCE_INTR(q) (0x00000004 << ((q) * 4)) +/*! Controlled interrupt */ +#define CMICX_PDMA_IRQ_CTRLD_INTR(q) (0x00000008 << ((q) * 4)) +/*! Interrupt mask */ +#define CMICX_PDMA_IRQ_MASK(q) (0xf << ((q) * 4)) +/*! Interrupt start number */ +#define CMICX_IRQ_START_NUM (128 + 3) +/*! Interrupt number offset */ +#define CMICX_IRQ_NUM_OFFSET 4 +/*! Interrupt mask shift */ +#define CMICX_IRQ_MASK_SHIFT 16 +/*! \} */ + +/*! 32-bit register read */ +#define DEV_READ32(_c, _a, _p) \ + do { \ + if ((_c)->dev->mode != DEV_MODE_VNET) { \ + *(_p) = ((volatile uint32_t *)(_c)->hw_addr)[(_a) / 4]; \ + } \ + } while (0) + +/*! 32-bit register write */ +#define DEV_WRITE32(_c, _a, _v) \ + do { \ + if ((_c)->dev->mode != DEV_MODE_VNET) { \ + ((volatile uint32_t *)(_c)->hw_addr)[(_a) / 4] = (_v); \ + } \ + } while (0) + +/*! + * \brief Rx descriptor. + */ +struct cmicx_rx_desc { + /*! Packet address lower */ + volatile uint32_t addr_lo; + + /*! Packet address higher */ + volatile uint32_t addr_hi; + + /*! Packet control */ + volatile uint32_t ctrl; + + /*! Packet status */ + volatile uint32_t status; +} __attribute__((packed)); + +/*! + * \brief Tx descriptor. + */ +struct cmicx_tx_desc { + /*! Packet address lower */ + volatile uint32_t addr_lo; + + /*! Packet address higher */ + volatile uint32_t addr_hi; + + /*! Packet control */ + volatile uint32_t ctrl; + + /*! Packet status */ + volatile uint32_t status; +} __attribute__((packed)); + +/*! + * Flags related to descriptors. + */ +/*! Disable descriptor status write */ +#define CMICX_DESC_CTRL_STAT_WR_DIS (1 << 29) +/*! Descriptors remaining */ +#define CMICX_DESC_CTRL_REMAIN(cnt) (((cnt) & 0xf) << 25) +/*! Max remaining descriptors */ +#define CMICX_DESC_REMAIN_MAX 8 +/*! Controlled interrupt */ +#define CMICX_DESC_CTRL_CNTLD_INTR (1 << 24) +/*! Completed interrupt */ +#define CMICX_DESC_CTRL_CMPLT_INTR (1 << 23) +/*! Reload DCB */ +#define CMICX_DESC_CTRL_RELOAD (1 << 18) +/*! Scatter DCB */ +#define CMICX_DESC_CTRL_SCATTER (1 << 17) +/*! Chained DCB */ +#define CMICX_DESC_CTRL_CHAIN (1 << 16) +/*! Control flags */ +#define CMICX_DESC_CTRL_FLAGS(f) (((f) & 0xffff) << 16) +/*! Purge packet */ +#define CMICX_DESC_TX_PURGE_PKT (1 << 6) +/*! Higig packet */ +#define CMICX_DESC_TX_HIGIG_PKT (1 << 3) +/*! Packet length */ +#define CMICX_DESC_CTRL_LEN(len) ((len) & 0xffff) +/*! Done */ +#define CMICX_DESC_STAT_RTX_DONE (1 << 31) +/*! Ecc error */ +#define CMICX_DESC_STAT_DATA_ERR (1 << 19) +/*! Cell error */ +#define CMICX_DESC_STAT_CELL_ERR (1 << 18) +/*! Error mask */ +#define CMICX_DESC_STAT_ERR_MASK (CMICX_DESC_STAT_DATA_ERR | \ + CMICX_DESC_STAT_CELL_ERR) +/*! Packet start */ +#define CMICX_DESC_STAT_PKT_START (1 << 17) +/*! Packet end */ +#define CMICX_DESC_STAT_PKT_END (1 << 16) +/*! Get done state */ +#define CMICX_DESC_STAT_DONE(stat) ((stat) & CMICX_DESC_STAT_RTX_DONE) +/*! Get flags */ +#define CMICX_DESC_STAT_FLAGS(stat) (((stat) >> 16) & ~0x8003) +/*! Get packet length */ +#define CMICX_DESC_STAT_LEN(stat) ((stat) & 0xffff) + +/*! Tx packet header size */ +#define CMICX_TX_PKT_HDR_SIZE 16 + +/*! HW access retry times */ +#define CMICX_HW_RETRY_TIMES 100000 + +/*! + * \brief Initialize HW handles. + * + * \param [in] hw HW structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_cmicx_pdma_hw_hdls_init(struct pdma_hw *hw); + +/*! + * \brief Initialize descriptor operations. + * + * \param [in] hw HW structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_cmicx_pdma_desc_ops_init(struct pdma_hw *hw); + +/*! + * \brief Attach device driver. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_cmicx_pdma_driver_attach(struct pdma_dev *dev); + +/*! + * \brief Detach device driver. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_cmicx_pdma_driver_detach(struct pdma_dev *dev); + +#endif /* BCMCNET_CMICX_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_core.h b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_core.h new file mode 100644 index 000000000000..13db809dda36 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_core.h @@ -0,0 +1,1323 @@ +/*! \file bcmcnet_core.h + * + * Generic data structure definitions and APIs for BCMCNET driver. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef BCMCNET_CORE_H +#define BCMCNET_CORE_H + +#include +#include + +/*! + * \brief Packet header structure. + */ +struct pkt_hdr { + /*! Meta data or outer header */ + uint8_t meta_data[16]; + + /*! Reserved */ + uint16_t rsvd0; + + /*! Packet signature */ + uint16_t pkt_sig; + + /*! Reserved */ + uint32_t rsvd1; + + /*! Data length */ + uint16_t data_len; + + /*! Reserved */ + uint16_t rsvd2; + + /*! Meta length */ + uint8_t meta_len; + + /*! Queue index */ + uint8_t queue_id; + + /*! Attributes */ + uint16_t attrs; + /*! Tx higig packet */ +#define PDMA_TX_HIGIG_PKT (1 << 0) + /*! Tx pause packet */ +#define PDMA_TX_PAUSE_PKT (1 << 1) + /*! Tx purge packet */ +#define PDMA_TX_PURGE_PKT (1 << 2) + /*! Tx queue number */ +#define PDMA_TX_BIND_QUE (1 << 3) + /*! Tx cookded header */ +#define PDMA_TX_HDR_COOKED (1 << 4) + /*! Tx to HNET */ +#define PDMA_TX_TO_HNET (1 << 5) + /*! Rx to VNET */ +#define PDMA_RX_TO_VNET (1 << 10) + /*! Rx strip vlan tag */ +#define PDMA_RX_STRIP_TAG (1 << 11) + /*! Rx set protocol type */ +#define PDMA_RX_SET_PROTO (1 << 12) + /*! Rx IP checksum */ +#define PDMA_RX_IP_CSUM (1 << 13) + /*! Rx TCPUDP checksum */ +#define PDMA_RX_TU_CSUM (1 << 14) +}; + +/*! Packet header size */ +#define PKT_HDR_SIZE sizeof(struct pkt_hdr) + +/*! + * \brief Packet buffer structure. + */ +struct pkt_buf { + /*! Packet header */ + struct pkt_hdr pkh; + + /*! Packet data */ + uint8_t data; +}; + +/*! + * \brief Interrupt handle. + */ +struct intr_handle { + /*! Device number */ + int unit; + + /*! Group number */ + int group; + + /*! Channel number */ + int chan; + + /*! Queue number */ + int queue; + + /*! Direction */ + int dir; + + /*! Polling budget */ + int budget; + + /*! Device point */ + void *dev; + + /*! Private point */ + void *priv; + + /*! Interrupt number */ + int intr_num; + + /*! Interrupt flags */ + uint32_t intr_flags; +}; + +/*! + * \brief Queue group structure. + */ +struct queue_group { + /*! Pointer to the device control structure */ + struct dev_ctrl *ctrl; + + /*! Interrupt handles */ + struct intr_handle intr_hdl[NUM_Q_PER_GRP]; + + /*! Rx queue pointers */ + void *rx_queue[NUM_Q_PER_GRP]; + + /*! Tx queue pointers */ + void *tx_queue[NUM_Q_PER_GRP]; + + /*! Virtual Rx queue pointers */ + void *vnet_rxq[NUM_Q_PER_GRP]; + + /*! Virtual Tx queue pointers */ + void *vnet_txq[NUM_Q_PER_GRP]; + + /*! Bitmap for Rx queues at work */ + uint32_t bm_rxq; + + /*! Bitmap for Tx queues at work */ + uint32_t bm_txq; + + /*! Number of Rx queues at work */ + uint32_t nb_rxq; + + /*! Number of Tx queues at work */ + uint32_t nb_txq; + + /*! Number of descriptors */ + uint32_t nb_desc[NUM_Q_PER_GRP]; + + /*! Rx buffer size */ + uint32_t rx_size[NUM_Q_PER_GRP]; + + /*! Queue mode */ + uint32_t que_ctrl[NUM_Q_PER_GRP]; + /*! Packet_byte_swap */ +#define PDMA_PKT_BYTE_SWAP (1 << 0) + /*! Non packet_byte_swap */ +#define PDMA_OTH_BYTE_SWAP (1 << 1) + /*! Header_byte_swap */ +#define PDMA_HDR_BYTE_SWAP (1 << 2) + + /*! Group ID */ + int id; + + /*! Queues need to poll */ + uint32_t poll_queues; + + /*! Active IRQs for DMA control */ + uint32_t irq_mask; + + /*! Indicating the group is attached */ + int attached; +}; + +/*! + * \brief Device control structure. + */ +struct dev_ctrl { + /*! Pointer to the device structure */ + struct pdma_dev *dev; + + /*! Pointer to hardware-specific data */ + void *hw; + + /*! HW base address */ + volatile void *hw_addr; + + /*! Queue groups */ + struct queue_group grp[NUM_GRP_MAX]; + + /*! Pointers to Rx queues */ + void *rx_queue[NUM_QUE_MAX]; + + /*! Pointers to Tx queues */ + void *tx_queue[NUM_QUE_MAX]; + + /*! Pointers to virtual Rx queues */ + void *vnet_rxq[NUM_QUE_MAX]; + + /*! Pointers to virtual Tx queues */ + void *vnet_txq[NUM_QUE_MAX]; + + /*! Pointer to buffer manager */ + void *buf_mngr; + + /*! VNET sync data */ + vnet_sync_t vsync; + + /*! Bitmap of groups at work */ + uint32_t bm_grp; + + /*! Bitmap of Rx queues at work */ + uint32_t bm_rxq; + + /*! Bitmap of Tx queues at work */ + uint32_t bm_txq; + + /*! Number of groups at work */ + uint32_t nb_grp; + + /*! Number of Rx queues at work */ + uint32_t nb_rxq; + + /*! Number of Tx queues at work */ + uint32_t nb_txq; + + /*! Number of descriptors for a queue */ + uint32_t nb_desc; + + /*! Budget for once queue processing */ + uint32_t budget; + + /*! Common Rx buffer size for all queues */ + uint32_t rx_buf_size; + + /*! Rx descriptor size */ + uint32_t rx_desc_size; + + /*! Tx descriptor size */ + uint32_t tx_desc_size; +}; + +/*! + * Configure device. + * + * \param [in] dev Pointer to device structure. + * \param [in] bm_rxq Rx queue bitmap. + * \param [in] bm_txq Tx queue bitmap. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_dev_config_f)(struct pdma_dev *dev, uint32_t bm_rxq, uint32_t bm_txq); + +/*! + * Start device. + * + * \param [in] dev Pointer to device structure. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_dev_start_f)(struct pdma_dev *dev); + +/*! + * Stop device. + * + * \param [in] dev Pointer to device structure. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_dev_stop_f)(struct pdma_dev *dev); + +/*! + * Close device. + * + * \param [in] dev Pointer to device structure. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_dev_close_f)(struct pdma_dev *dev); + +/*! + * Suspend device. + * + * \param [in] dev Pointer to device structure. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_dev_suspend_f)(struct pdma_dev *dev); + +/*! + * Resume device. + * + * \param [in] dev Pointer to device structure. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_dev_resume_f)(struct pdma_dev *dev); + +/*! + * Get device information. + * + * \param [in] dev Pointer to device structure. + */ +typedef void (*pdma_dev_info_get_f)(struct pdma_dev *dev); + +/*! + * Get device statistics. + * + * \param [in] dev Pointer to device structure. + */ +typedef void (*pdma_dev_stats_get_f)(struct pdma_dev *dev); + +/*! + * Reset device statistics. + * + * \param [in] dev Pointer to device structure. + */ +typedef void (*pdma_dev_stats_reset_f)(struct pdma_dev *dev); + +/*! + * Convert logic queue to physical queue. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Logic queue number. + * \param [in] dir Transmit direction. + * \param [in] chan Channel number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_dev_lq2pq_f)(struct pdma_dev *dev, int queue, int dir, int *chan); + +/*! + * Convert physical queue to logic queue. + * + * \param [in] dev Pointer to device structure. + * \param [in] chan Channel number. + * \param [in] queue Logic queue number. + * \param [in] dir Transmit direction. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_dev_pq2lq_f)(struct pdma_dev *dev, int chan, int *queue, int *dir); + +/*! + * Start queue. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_queue_start_f)(struct pdma_dev *dev, int queue); + +/*! + * Stop queue. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_queue_stop_f)(struct pdma_dev *dev, int queue); + +/*! + * Set up queue. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_queue_setup_f)(struct pdma_dev *dev, int queue); + +/*! + * Release queue. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_queue_release_f)(struct pdma_dev *dev, int queue); + +/*! + * Restore queue. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_queue_restore_f)(struct pdma_dev *dev, int queue); + +/*! + * Enable queue interrupt. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_intr_enable_f)(struct pdma_dev *dev, int queue); + +/*! + * Disable queue interrupt. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_intr_disable_f)(struct pdma_dev *dev, int queue); + +/*! + * Acknowledge queue interrupt. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_intr_ack_f)(struct pdma_dev *dev, int queue); + +/*! + * Query queue interrupt. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_intr_query_f)(struct pdma_dev *dev, int queue); + +/*! + * Check queue interrupt. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_intr_check_f)(struct pdma_dev *dev, int queue); + +/*! + * Suspend Rx queue. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_rx_queue_suspend_f)(struct pdma_dev *dev, int queue); + +/*! + * Resume Rx queue. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_rx_queue_resume_f)(struct pdma_dev *dev, int queue); + +/*! + * Wake up Tx queue. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_tx_queue_wakeup_f)(struct pdma_dev *dev, int queue); + +/*! + * Poll Rx queue. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Queue number. + * \param [in] budget Max number of descriptor to poll. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_rx_queue_poll_f)(struct pdma_dev *dev, int queue, int budget); + +/*! + * Poll Tx queue. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Queue number. + * \param [in] budget Max number of descriptor to poll. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_tx_queue_poll_f)(struct pdma_dev *dev, int queue, int budget); + +/*! + * Poll queue group. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Queue number. + * \param [in] budget Max number of descriptor to poll. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pdma_group_poll_f)(struct pdma_dev *dev, int group, int budget); + +/*! + * \brief Exported functions structure. + */ +struct dev_ops { + /*! Configure device */ + pdma_dev_config_f dev_config; + + /*! Start device */ + pdma_dev_start_f dev_start; + + /*! Stop device */ + pdma_dev_stop_f dev_stop; + + /*! Close device */ + pdma_dev_close_f dev_close; + + /*! Suspend device */ + pdma_dev_suspend_f dev_suspend; + + /*! Resume device */ + pdma_dev_resume_f dev_resume; + + /*! Get device information */ + pdma_dev_info_get_f dev_info_get; + + /*! Get device statistics */ + pdma_dev_stats_get_f dev_stats_get; + + /*! Reset device statistics */ + pdma_dev_stats_reset_f dev_stats_reset; + + /*! Logic queue to physical queue */ + pdma_dev_lq2pq_f dev_lq_to_pq; + + /*! Physical queue to logic queue */ + pdma_dev_pq2lq_f dev_pq_to_lq; + + /*! Start Rx for a queue */ + pdma_queue_start_f rx_queue_start; + + /*! Stop Rx for a queue */ + pdma_queue_stop_f rx_queue_stop; + + /*! Start Tx for a queue */ + pdma_queue_start_f tx_queue_start; + + /*! Stop Tx for a queue */ + pdma_queue_stop_f tx_queue_stop; + + /*! Set up Rx queue */ + pdma_queue_setup_f rx_queue_setup; + + /*! Release Rx queue */ + pdma_queue_release_f rx_queue_release; + + /*! Restore stopped Rx queue */ + pdma_queue_restore_f rx_queue_restore; + + /*! Set up virtual Rx queue */ + pdma_queue_setup_f rx_vqueue_setup; + + /*! Release virtual Rx queue */ + pdma_queue_release_f rx_vqueue_release; + + /*! Set up Tx queue */ + pdma_queue_setup_f tx_queue_setup; + + /*! Release Tx queue */ + pdma_queue_release_f tx_queue_release; + + /*! Restore stopped Tx queue */ + pdma_queue_restore_f tx_queue_restore; + + /*! Set up virtual Tx queue */ + pdma_queue_setup_f tx_vqueue_setup; + + /*! Release virtual Tx queue */ + pdma_queue_release_f tx_vqueue_release; + + /*! Enable Rx queue interrupt */ + pdma_intr_enable_f rx_queue_intr_enable; + + /*! Disable Rx queue interrupt */ + pdma_intr_disable_f rx_queue_intr_disable; + + /*! Acknowledge interrupt for Rx queue */ + pdma_intr_ack_f rx_queue_intr_ack; + + /*! Query interrupt status for Rx queue */ + pdma_intr_query_f rx_queue_intr_query; + + /*! Check interrupt validity for Rx queue */ + pdma_intr_check_f rx_queue_intr_check; + + /*! Enable Tx queue interrupt */ + pdma_intr_enable_f tx_queue_intr_enable; + + /*! Disable Tx queue interrupt */ + pdma_intr_disable_f tx_queue_intr_disable; + + /*! Acknowledge interrupt for Tx queue */ + pdma_intr_ack_f tx_queue_intr_ack; + + /*! Query interrupt status for Tx queue */ + pdma_intr_query_f tx_queue_intr_query; + + /*! Check interrupt validity for Tx queue */ + pdma_intr_check_f tx_queue_intr_check; + + /*! Suspend a Rx queue */ + pdma_rx_queue_suspend_f rx_queue_suspend; + + /*! Resume a Rx queue */ + pdma_rx_queue_resume_f rx_queue_resume; + + /*! Wake up a Tx queue to transmit */ + pdma_tx_queue_wakeup_f tx_queue_wakeup; + + /*! Poll for a Rx queue */ + pdma_rx_queue_poll_f rx_queue_poll; + + /*! Poll for a Tx queue */ + pdma_tx_queue_poll_f tx_queue_poll; + + /*! Poll for a group */ + pdma_group_poll_f group_poll; +}; + +/*! + * Read 32-bit device register. + * + * \param [in] dev Pointer to device structure. + * \param [in] addr Register address. + * \param [in] data Pointer to read data. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*reg32_read_f)(struct pdma_dev *dev, uint32_t addr, uint32_t *data); + +/*! + * Write 32-bit device register. + * + * \param [in] dev Pointer to device structure. + * \param [in] addr Register address. + * \param [in] data Data to write. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*reg32_write_f)(struct pdma_dev *dev, uint32_t addr, uint32_t data); + +/*! + * Receive packet. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Rx queue number. + * \param [in] buf Pointer to packet buffer. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*pdma_rx_f)(struct pdma_dev *dev, int queue, void *buf); + +/*! + * Transmit packet. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Tx queue number. + * \param [in] buf Pointer to packet buffer. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*pdma_tx_f)(struct pdma_dev *dev, int queue, void *buf); + +/*! + * Suspend Tx queue. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Tx queue number. + */ +typedef void (*sys_tx_suspend_f)(struct pdma_dev *dev, int queue); + +/*! + * Resume Tx queue. + * + * \param [in] dev Pointer to device structure. + * \param [in] queue Tx queue number. + */ +typedef void (*sys_tx_resume_f)(struct pdma_dev *dev, int queue); + +/*! + * Enable interrupts. + * + * \param [in] dev Pointer to device structure. + * \param [in] group Channel group number. + * \param [in] chan Channel number. + * \param [in] reg Interrupt enable register. + * \param [in] mask Interrupt mask. + */ +typedef void (*sys_intr_unmask_f)(struct pdma_dev *dev, int group, int chan, + uint32_t reg, uint32_t mask); + +/*! + * Disable interrupts. + * + * \param [in] dev Pointer to device structure. + * \param [in] group Channel group number. + * \param [in] chan Channel number. + * \param [in] reg Interrupt enable register. + * \param [in] mask Interrupt mask. + */ +typedef void (*sys_intr_mask_f)(struct pdma_dev *dev, int group, int chan, + uint32_t reg, uint32_t mask); + +/*! + * Wait for notification from the other side. + * + * \param [in] dev Pointer to device structure. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*xnet_wait_f)(struct pdma_dev *dev); + +/*! + * Wake up the other side. + * + * \param [in] dev Pointer to device structure. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*xnet_wake_f)(struct pdma_dev *dev); + +/*! + * Convert physical address to virtual address. + * + * \param [in] dev Pointer to device structure. + * \param [in] paddr Physical address. + * + * \retval Virtual address. + */ +typedef void *(*sys_p2v_f)(struct pdma_dev *dev, uint64_t paddr); + +/*! + * Convert virtual address to physical address. + * + * \param [in] dev Pointer to device structure. + * \param [in] vaddr Virtual address. + * + * \retval Physical address. + */ +typedef uint64_t (*sys_v2p_f)(struct pdma_dev *dev, void *vaddr); + +/*! + * \brief Device structure. + */ +struct pdma_dev { + /*! Device name */ + char name[DEV_NAME_LEN_MAX]; + + /*! Device ID */ + uint32_t dev_id; + + /*! Device type */ + uint32_t dev_type; + + /*! Device Number */ + int unit; + + /*! Device control structure */ + struct dev_ctrl ctrl; + + /*! Pointer to the exported funtions structure */ + struct dev_ops *ops; + + /*! Device information */ + struct bcmcnet_dev_info info; + + /*! Device statistics data */ + struct bcmcnet_dev_stats stats; + + /*! Private data */ + void *priv; + + /*! Read 32-bit device register */ + reg32_read_f dev_read32; + + /*! Write 32-bit device register */ + reg32_write_f dev_write32; + + /*! Packet reception */ + pdma_rx_f pkt_recv; + + /*! Packet transmission */ + pdma_tx_f pkt_xmit; + + /*! Tx suspend */ + sys_tx_suspend_f tx_suspend; + + /*! Tx resume */ + sys_tx_resume_f tx_resume; + + /*! Enable a set of interrupts */ + sys_intr_unmask_f intr_unmask; + + /*! Disable a set of interrupts */ + sys_intr_mask_f intr_mask; + + /*! Virtual network wait for */ + xnet_wait_f xnet_wait; + + /*! Virtual network wake up */ + xnet_wake_f xnet_wake; + + /*! Physical address to virtual address */ + sys_p2v_f sys_p2v; + + /*! Virtual address to physical address */ + sys_v2p_f sys_v2p; + + /*! Maximum number of groups */ + int num_groups; + + /*! Maximum number of group queues */ + int grp_queues; + + /*! Maximum number of queues */ + int num_queues; + + /*! Rx packet header size */ + uint32_t rx_ph_size; + + /*! Tx packet header size */ + uint32_t tx_ph_size; + + /*! Flags */ + uint32_t flags; + /*! Interrupt processing per group */ +#define PDMA_GROUP_INTR (1 << 0) + /*! Tx polling mode */ +#define PDMA_TX_POLLING (1 << 1) + /*! Rx batch refilling */ +#define PDMA_RX_BATCHING (1 << 2) + /*! DMA chain mode */ +#define PDMA_CHAIN_MODE (1 << 3) + /*! Descriptor prefetch mode */ +#define PDMA_DESC_PREFETCH (1 << 4) + /*! VNET is docked */ +#define PDMA_VNET_DOCKED (1 << 5) + + /*! Device mode */ + dev_mode_t mode; + + /*! Device is started */ + int started; + + /*! Device is initialized and HMI driver is attached */ + int attached; +}; + +/*! + * \brief Initialize device. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_dev_init(struct pdma_dev *dev); + +/*! + * \brief Clean up device. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_dev_cleanup(struct pdma_dev *dev); + +/*! + * \brief Start device. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_dev_start(struct pdma_dev *dev); + +/*! + * \brief Stop device. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_dev_stop(struct pdma_dev *dev); + +/*! + * \brief Suspend device. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_dev_suspend(struct pdma_dev *dev); + +/*! + * \brief Resume device. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_dev_resume(struct pdma_dev *dev); + +/*! + * \brief Suspend device Rx. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_dev_rx_suspend(struct pdma_dev *dev); + +/*! + * \brief Resume device Rx. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_dev_rx_resume(struct pdma_dev *dev); + +/*! + * \brief Dock device. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_dev_dock(struct pdma_dev *dev); + +/*! + * \brief Undock device. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_dev_undock(struct pdma_dev *dev); + +/*! + * \brief Get device information. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_dev_info_get(struct pdma_dev *dev); + +/*! + * \brief Get device statistics. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_dev_stats_get(struct pdma_dev *dev); + +/*! + * \brief Reset device statistics. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_dev_stats_reset(struct pdma_dev *dev); + +/*! + * \brief Change queue number to channel number. + * + * \param [in] dev Device structure point. + * \param [in] queue Queue number. + * \param [in] dir Transmit direction. + * \param [out] chan Channel number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_dev_queue_to_chan(struct pdma_dev *dev, int queue, int dir, int *chan); + +/*! + * \brief Change channel number to queue number. + * + * \param [in] dev Device structure point. + * \param [in] chan Channel number. + * \param [out] queue Queue number. + * \param [out] dir Transmit direction. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_dev_chan_to_queue(struct pdma_dev *dev, int chan, int *queue, int *dir); + +/*! + * \brief Enable Rx queue interrupt. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_rx_queue_intr_enable(struct pdma_dev *dev, int queue); + +/*! + * \brief Disable Rx queue interrupt. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_rx_queue_intr_disable(struct pdma_dev *dev, int queue); + +/*! + * \brief Acknowledge Rx queue interrupt. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_rx_queue_intr_ack(struct pdma_dev *dev, int queue); + +/*! + * \brief Check Rx queue interrupt. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_rx_queue_intr_check(struct pdma_dev *dev, int queue); + +/*! + * \brief Enable Tx queue interrupt. + * + * \param [in] dev Device structure point. + * \param [in] queue Tx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_tx_queue_intr_enable(struct pdma_dev *dev, int queue); + +/*! + * \brief Disable Tx queue interrupt. + * + * \param [in] dev Device structure point. + * \param [in] queue Tx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_tx_queue_intr_disable(struct pdma_dev *dev, int queue); + +/*! + * \brief Acknowledge Tx queue interrupt. + * + * \param [in] dev Device structure point. + * \param [in] queue Tx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_tx_queue_intr_ack(struct pdma_dev *dev, int queue); + +/*! + * \brief Check Tx queue interrupt. + * + * \param [in] dev Device structure point. + * \param [in] queue Tx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_tx_queue_intr_check(struct pdma_dev *dev, int queue); + +/*! + * \brief Enable queue interrupt. + * + * \param [in] dev Device structure point. + * \param [in] hdl Queue interrupt handle. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_queue_intr_enable(struct pdma_dev *dev, struct intr_handle *hdl); + +/*! + * \brief Disable queue interrupt. + * + * \param [in] dev Device structure point. + * \param [in] hdl Queue interrupt handle. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_queue_intr_disable(struct pdma_dev *dev, struct intr_handle *hdl); + +/*! + * \brief Acknowledge queue interrupt. + * + * \param [in] dev Device structure point. + * \param [in] hdl Queue interrupt handle. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_queue_intr_ack(struct pdma_dev *dev, struct intr_handle *hdl); + +/*! + * \brief Check queue interrupt. + * + * \param [in] dev Device structure point. + * \param [in] hdl Queue interrupt handle. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_queue_intr_check(struct pdma_dev *dev, struct intr_handle *hdl); + +/*! + * \brief Enable group interrupt. + * + * \param [in] dev Device structure point. + * \param [in] group Group number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_group_intr_enable(struct pdma_dev *dev, int group); + +/*! + * \brief Disable group interrupt. + * + * \param [in] dev Device structure point. + * \param [in] group Group number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_group_intr_disable(struct pdma_dev *dev, int group); + +/*! + * \brief Acknowledge group interrupt. + * + * \param [in] dev Device structure point. + * \param [in] group Group number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_group_intr_ack(struct pdma_dev *dev, int group); + +/*! + * \brief Check group interrupt. + * + * \param [in] dev Device structure point. + * \param [in] group Group number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_group_intr_check(struct pdma_dev *dev, int group); + +/*! + * \brief Poll Rx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * \param [in] budget Poll budget. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_rx_queue_poll(struct pdma_dev *dev, int queue, int budget); + +/*! + * \brief Poll Tx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Tx queue number. + * \param [in] budget Poll budget. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_tx_queue_poll(struct pdma_dev *dev, int queue, int budget); + +/*! + * \brief Poll queue. + * + * \param [in] dev Device structure point. + * \param [in] hdl Queue interrupt handle. + * \param [in] budget Poll budget. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_queue_poll(struct pdma_dev *dev, struct intr_handle *hdl, int budget); + +/*! + * \brief Poll group. + * + * \param [in] dev Device structure point. + * \param [in] group Group number. + * \param [in] budget Poll budget. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_group_poll(struct pdma_dev *dev, int group, int budget); + +#endif /* BCMCNET_CORE_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_dev.h b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_dev.h new file mode 100644 index 000000000000..bc3367b34fae --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_dev.h @@ -0,0 +1,544 @@ +/*! \file bcmcnet_dev.h + * + * Generic data structure and macro definitions for BCMCNET device. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef BCMCNET_DEV_H +#define BCMCNET_DEV_H + +#include + +/*! + * \brief HW information. + */ +struct hw_info { + /*! HW name */ + char *name; + + /*! HW version */ + int ver_no; + + /*! Device ID */ + uint32_t dev_id; + + /*! Revision ID */ + uint32_t rev_id; + + /*! Number of CMCs */ + uint32_t num_cmcs; + + /*! Number of CMC channels */ + uint32_t cmc_chans; + + /*! Number of channels */ + uint32_t num_chans; + + /*! Rx DCB size */ + uint32_t rx_dcb_size; + + /*! Tx DCB size */ + uint32_t tx_dcb_size; + + /*! Rx packet header size */ + uint32_t rx_ph_size; + + /*! Tx packet header size */ + uint32_t tx_ph_size; + + /*! HW structure point */ + struct pdma_hw *hw; +}; + +/*! + * \brief Read 32-bit register. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] addr Register address. + * \param [in] data Pointer to read data. + */ +typedef void (*reg_rd32_f)(struct pdma_hw *hw, uint32_t addr, uint32_t *data); + +/*! + * \brief Write 32-bit register. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] addr Register address. + * \param [in] data Data to write. + */ +typedef void (*reg_wr32_f)(struct pdma_hw *hw, uint32_t addr, uint32_t data); + +/*! + * \brief Pre-initialize hardware. + * + * \param [in] hw Pointer to hardware structure. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*pre_init_f)(struct pdma_hw *hw); + +/*! + * \brief Initialize hardware. + * + * \param [in] hw Pointer to hardware structure. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*hw_init_f)(struct pdma_hw *hw); + +/*! + * \brief Configure hardware. + * + * \param [in] hw Pointer to hardware structure. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*hw_config_f)(struct pdma_hw *hw); + +/*! + * \brief Reset hardware. + * + * \param [in] hw Pointer to hardware structure. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*hw_reset_f)(struct pdma_hw *hw); + +/*! + * \brief Start channel. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] chan Channel number. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*chan_start_f)(struct pdma_hw *hw, int chan); + +/*! + * \brief Stop channel. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] chan Channel number. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*chan_stop_f)(struct pdma_hw *hw, int chan); + +/*! + * \brief Set up channel. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] chan Channel number. + * \param [in] addr Start DMA address of descriptors. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*chan_setup_f)(struct pdma_hw *hw, int chan, uint64_t addr); + +/*! + * \brief Go to ohter descriptor. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] chan Channel number. + * \param [in] addr Destination DMA address of descriptors. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*chan_goto_f)(struct pdma_hw *hw, int chan, uint64_t addr); + +/*! + * \brief Clear channel. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] chan Channel number. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*chan_clear_f)(struct pdma_hw *hw, int chan); + +/*! + * \brief Get interrupt number. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] chan Channel number. + * + * \retval Returned interrupt number, errors if negative value. + */ +typedef int (*chan_intr_num_get_f)(struct pdma_hw *hw, int chan); + +/*! + * \brief Enable interrupt. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] chan Channel number. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*chan_intr_enable_f)(struct pdma_hw *hw, int chan); + +/*! + * \brief Disable interrupt. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] chan Channel number. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*chan_intr_disable_f)(struct pdma_hw *hw, int chan); + +/*! + * \brief Query interrupt. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] chan Channel number. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*chan_intr_query_f)(struct pdma_hw *hw, int chan); + +/*! + * \brief Check interrupt. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] chan Channel number. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*chan_intr_check_f)(struct pdma_hw *hw, int chan); + +/*! + * \brief Coalesce interrupt. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] chan Channel number. + * \param [in] count Count value to trigger interrupt. + * \param [in] timer Timer value to triggre interrupt. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*chan_intr_coalesce_f)(struct pdma_hw *hw, int chan, int count, int timer); + +/*! + * \brief Dump registers. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] chan Channel number. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*chan_reg_dump_f)(struct pdma_hw *hw, int chan); + +/*! + * \brief HW handlers. + */ +struct hw_handlers { + /*! 32 bits register read */ + reg_rd32_f reg_rd32; + + /*! 32 bits register write */ + reg_wr32_f reg_wr32; + + /*! HW pre-initialize */ + pre_init_f pre_init; + + /*! HW initialize */ + hw_init_f hw_init; + + /*! HW configure */ + hw_config_f hw_config; + + /*! HW reset */ + hw_reset_f hw_reset; + + /*! Channel start */ + chan_start_f chan_start; + + /*! Channel stop */ + chan_stop_f chan_stop; + + /*! Channel setup */ + chan_setup_f chan_setup; + + /*! Channel goto */ + chan_goto_f chan_goto; + + /*! Channel clear */ + chan_clear_f chan_clear; + + /*! Channel interrupt number get */ + chan_intr_num_get_f chan_intr_num_get; + + /*! Channel interrupt enable */ + chan_intr_enable_f chan_intr_enable; + + /*! Channel interrupt disable */ + chan_intr_disable_f chan_intr_disable; + + /*! Channel interrupt query */ + chan_intr_query_f chan_intr_query; + + /*! Channel interrupt check */ + chan_intr_check_f chan_intr_check; + + /*! Channel interrupt coalesce */ + chan_intr_coalesce_f chan_intr_coalesce; + + /*! Channel registers dump */ + chan_reg_dump_f chan_reg_dump; +}; + +/*! + * \brief Initialize Rx descriptor. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] rxq Pointer to Rx queue struture. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_MEMORY Allocation failed. + */ +typedef int (*rx_desc_init_f)(struct pdma_hw *hw, struct pdma_rx_queue *rxq); + +/*! + * \brief Clean up Rx descriptor. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] rxq Pointer to Rx queue struture. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*rx_desc_clean_f)(struct pdma_hw *hw, struct pdma_rx_queue *rxq); + +/*! + * \brief Clean up Rx ring. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] rxq Pointer to Rx queue struture. + * \param [in] budget Budget for each operation. + * + * \retval Number of descriptors finished. + */ +typedef int (*rx_ring_clean_f)(struct pdma_hw *hw, struct pdma_rx_queue *rxq, int budget); + +/*! + * \brief Dump Rx ring. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] rxq Pointer to Rx queue struture. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*rx_ring_dump_f)(struct pdma_hw *hw, struct pdma_rx_queue *rxq); + +/*! + * \brief Suspend Rx queue. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] rxq Pointer to Rx queue struture. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*rx_suspend_f)(struct pdma_hw *hw, struct pdma_rx_queue *rxq); + +/*! + * \brief Resume Rx queue. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] rxq Pointer to Rx queue struture. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*rx_resume_f)(struct pdma_hw *hw, struct pdma_rx_queue *rxq); + +/*! + * \brief Initialize Tx descriptor. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] txq Pointer to Tx queue struture. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_MEMORY Allocation failed. + */ +typedef int (*tx_desc_init_f)(struct pdma_hw *hw, struct pdma_tx_queue *txq); + +/*! + * \brief Clean up Tx descriptor. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] txq Pointer to Tx queue struture. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*tx_desc_clean_f)(struct pdma_hw *hw, struct pdma_tx_queue *txq); + +/*! + * \brief Clean up Tx ring. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] txq Pointer to Tx queue struture. + * \param [in] budget Budget for each operation. + * + * \retval Number of descriptors finished. + */ +typedef int (*tx_ring_clean_f)(struct pdma_hw *hw, struct pdma_tx_queue *txq, int budget); + +/*! + * \brief Dump Tx ring. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] txq Pointer to Tx queue struture. + * + * \retval SHR_E_NONE No errors. + */ +typedef int (*tx_ring_dump_f)(struct pdma_hw *hw, struct pdma_tx_queue *txq); + +/*! + * \brief Transmit packet. + * + * \param [in] hw Pointer to hardware structure. + * \param [in] txq Pointer to Tx queue struture. + * \param [in] buf Pointer to packet buffer struture. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +typedef int (*pkt_xmit_f)(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf); + +/*! + * \brief Descriptor operations. + */ +struct desc_operations { + /*! Rx descriptor initialize */ + rx_desc_init_f rx_desc_init; + + /*! Rx descriptor cleanup */ + rx_desc_clean_f rx_desc_clean; + + /*! Rx ring cleanup */ + rx_ring_clean_f rx_ring_clean; + + /*! Rx ring dump */ + rx_ring_dump_f rx_ring_dump; + + /*! Rx suspend */ + rx_suspend_f rx_suspend; + + /*! Rx resume */ + rx_resume_f rx_resume; + + /*! Tx descriptor initialize */ + tx_desc_init_f tx_desc_init; + + /*! Tx descriptor cleanup */ + tx_desc_clean_f tx_desc_clean; + + /*! Tx ring cleanup */ + tx_ring_clean_f tx_ring_clean; + + /*! Tx ring dump */ + tx_ring_dump_f tx_ring_dump; + + /*! Tx transmit */ + pkt_xmit_f pkt_xmit; +}; + +/*! + * \brief HW structure. + */ +struct pdma_hw { + /*! Device number */ + int unit; + + /*! Device structure point */ + struct pdma_dev *dev; + + /*! HW information */ + struct hw_info info; + + /*! HW handlers */ + struct hw_handlers hdls; + + /*! HW operations */ + struct desc_operations dops; +}; + +/*! + * \brief Open device. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_open(struct pdma_dev *dev); + +/*! + * \brief Coalesce Rx interrupt. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * \param [in] count Interrupt threshhold. + * \param [in] timer Timer value. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_rx_queue_int_coalesce(struct pdma_dev *dev, int queue, int count, int timer); + +/*! + * \brief Coalesce Tx interrupt. + * + * \param [in] dev Device structure point. + * \param [in] queue Tx queue number. + * \param [in] count Interrupt threshhold. + * \param [in] timer Timer value. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_tx_queue_int_coalesce(struct pdma_dev *dev, int queue, int count, int timer); + +/*! + * \brief Dump Rx queue registers. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_rx_queue_reg_dump(struct pdma_dev *dev, int queue); + +/*! + * \brief Dump Tx queue registers. + * + * \param [in] dev Device structure point. + * \param [in] queue Tx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_tx_queue_reg_dump(struct pdma_dev *dev, int queue); + +#endif /* BCMCNET_DEV_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_internal.h b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_internal.h new file mode 100644 index 000000000000..e4b2051a34bc --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_internal.h @@ -0,0 +1,305 @@ +/*! \file bcmcnet_internal.h + * + * BCMCNET internal data structure and macro definitions. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef BCMCNET_INTERNAL_H +#define BCMCNET_INTERNAL_H + +#include + +/*! CMICD name */ +#define CMICD_DEV_NAME "cmicd" + +/*! CMICX name */ +#define CMICX_DEV_NAME "cmicx" + +/*! + * \brief Allocate descriptor ring buffer. + * + * \param [in] dev Pointer to Packet DMA device. + * \param [in] dma DMA address of ring buffer. + * + * \retval Pointer to DMA buffer or NULL if an error occurred. + */ +typedef void *(*ring_buf_alloc_f)(struct pdma_dev *dev, uint32_t, dma_addr_t *dma); + +/*! + * \brief Free descriptor ring buffer. + * + * \param [in] dev Pointer to Packet DMA device. + * \param [in] size Size of DMA buffer. + * \param [in] mem Pointer to DMA buffer. + * \param [in] dma DMA address of ring buffer. + */ +typedef void (*ring_buf_free_f)(struct pdma_dev *dev, uint32_t size, void *mem, + dma_addr_t dma); + +/*! + * \brief Allocate Rx packet buffer. + * + * \param [in] dev Pointer to Packet DMA device. + * \param [in] rxq Pointer to Rx queue struture. + * \param [in] pbuf Pointer to packet buffer structure. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_MEMORY Allocation failed. + */ +typedef int (*rx_buf_alloc_f)(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf); + +/*! + * \brief Get Rx packet buffer DMA address. + * + * \param [in] dev Pointer to Packet DMA device. + * \param [in] rxq Pointer to Rx queue struture. + * \param [in] pbuf Pointer to packet buffer structure. + * \param [in] dma DMA address of packet buffer. + */ +typedef void (*rx_buf_dma_f)(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf, dma_addr_t *dma); + +/*! + * \brief Check Rx packet buffer validity. + * + * \param [in] dev Pointer to Packet DMA device. + * \param [in] rxq Pointer to Rx queue struture. + * \param [in] pbuf Pointer to packet buffer structure. + * + * \retval Ture Buffer is available or FALSE. + */ +typedef int (*rx_buf_avail_f)(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf); + +/*! + * \brief Get Rx packet buffer. + * + * \param [in] dev Pointer to Packet DMA device. + * \param [in] rxq Pointer to Rx queue struture. + * \param [in] pbuf Pointer to packet buffer structure. + * \param [in] len Packet length. + * + * \retval Pointer to packet header structure or NULL if failed. + */ +typedef struct pkt_hdr *(*rx_buf_get_f)(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf, int len); + +/*! + * \brief Put Rx packet buffer. + * + * \param [in] dev Pointer to Packet DMA device. + * \param [in] rxq Pointer to Rx queue struture. + * \param [in] pbuf Pointer to packet buffer structure. + * \param [in] len Packet length. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_MEMORY Allocation failed. + */ +typedef int (*rx_buf_put_f)(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf, int len); + +/*! + * \brief Free Rx packet buffer. + * + * \param [in] dev Pointer to Packet DMA device. + * \param [in] rxq Pointer to Rx queue struture. + * \param [in] pbuf Pointer to packet buffer structure. + */ +typedef void (*rx_buf_free_f)(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf); + +/*! + * \brief Get Rx packet buffer mode. + * + * \param [in] dev Pointer to Packet DMA device. + * \param [in] rxq Pointer to Rx queue struture. + * + * \retval Buffer mode. + */ +typedef enum buf_mode (*rx_buf_mode_f)(struct pdma_dev *dev, struct pdma_rx_queue *rxq); + +/*! + * \brief Get Tx packet buffer. + * + * \param [in] dev Pointer to Packet DMA device. + * \param [in] txq Pointer to Rx queue struture. + * \param [in] pbuf Pointer to packet buffer structure. + * \param [in] buf Packet buffer. + * + * \retval Pointer to packet header structure or NULL if failed. + */ +typedef struct pkt_hdr *(*tx_buf_get_f)(struct pdma_dev *dev, struct pdma_tx_queue *txq, + struct pdma_tx_buf *pbuf, void *buf); + +/*! + * \brief Get Tx packet buffer DMA address. + * + * \param [in] dev Pointer to Packet DMA device. + * \param [in] txq Pointer to Rx queue struture. + * \param [in] pbuf Pointer to packet buffer structure. + * \param [in] dma DMA address of packet buffer. + */ +typedef void (*tx_buf_dma_f)(struct pdma_dev *dev, struct pdma_tx_queue *txq, + struct pdma_tx_buf *pbuf, dma_addr_t *dma); + +/*! + * \brief Free Tx packet buffer. + * + * \param [in] dev Pointer to Packet DMA device. + * \param [in] txq Pointer to Rx queue struture. + * \param [in] pbuf Pointer to packet buffer structure. + */ +typedef void (*tx_buf_free_f)(struct pdma_dev *dev, struct pdma_tx_queue *txq, + struct pdma_tx_buf *pbuf); + +/*! + * \brief Buffer manager. + */ +struct pdma_buf_mngr { + /*! Allocate descriptor ring buffer */ + ring_buf_alloc_f ring_buf_alloc; + + /*! Free descriptor ring buffer */ + ring_buf_free_f ring_buf_free; + + /*! Allocate Rx packet buffer */ + rx_buf_alloc_f rx_buf_alloc; + + /*! Get Rx packet buffer DMA address */ + rx_buf_dma_f rx_buf_dma; + + /*! Check Rx packet buffer validity */ + rx_buf_avail_f rx_buf_avail; + + /*! Get Rx packet buffer */ + rx_buf_get_f rx_buf_get; + + /*! Put Rx packet buffer */ + rx_buf_put_f rx_buf_put; + + /*! Free Rx packet buffer */ + rx_buf_free_f rx_buf_free; + + /*! Get Rx packet buffer mode */ + rx_buf_mode_f rx_buf_mode; + + /*! Get Tx packet buffer */ + tx_buf_get_f tx_buf_get; + + /*! Get Tx packet buffer DMA address */ + tx_buf_dma_f tx_buf_dma; + + /*! Free Tx packet buffer */ + tx_buf_free_f tx_buf_free; +}; + +/*! + * \brief Wait for the kernel networking subsystem. + * + * \param [in] unit Device number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_FAIL Operation failed. + */ +typedef int (*bcmcnet_vnet_wait_f)(int unit); + +/*! + * \brief Wake up the kernel networking subsystem. + * + * \param [in] unit Device number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_FAIL Operation failed. + */ +typedef int (*bcmcnet_hnet_wake_f)(int unit); + +/*! + * \brief Dock to the kernel networking subsystem. + * + * \param [in] unit Device number. + * \param [in] vsync Sync data. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_FAIL Operation failed. + */ +typedef int (*bcmcnet_vnet_dock_f)(int unit, vnet_sync_t *vsync); + +/*! + * \brief Undock from the kernel networking subsystem. + * + * \param [in] unit Device number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_FAIL Operation failed. + */ +typedef int (*bcmcnet_vnet_undock_f)(int unit); + +/*! + * \brief VNET operations. + */ +typedef struct bcmcnet_vnet_ops_s { + /*! + * VNET wait for HNET. + * VNET calls this to wait for any notification from HNET. + */ + bcmcnet_vnet_wait_f vnet_wait; + + /*! + * VNET wake up HNET. + * VNET calls this to notify HNET that Tx/Rx is ready. + */ + bcmcnet_hnet_wake_f hnet_wake; + + /*! + * VNET dock to HNET. + * This is called to notify HNET that VNET is ready to work and synchronize + * vrings information to HNET. + */ + bcmcnet_vnet_dock_f vnet_dock; + + /*! + * VNET undock from HNET. + * This is called to notify HNET that VNET is ready to leave. + */ + bcmcnet_vnet_undock_f vnet_undock; +} bcmcnet_vnet_ops_t; + +/*! + * \brief Initialize buffer manager. + * + * \param [in] dev Device structure pointer. + */ +extern void +bcmcnet_buf_mngr_init(struct pdma_dev *dev); + +/*! + * \brief Register VNET operations. + * + * \param [in] unit Device number. + * \param [in] vnet_ops VNET operations. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_PARAM Invalid parameters. + */ +extern int +bcmcnet_vnet_ops_register(int unit, bcmcnet_vnet_ops_t *vnet_ops); + +#endif /* BCMCNET_INTERNAL_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_rxtx.h b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_rxtx.h new file mode 100644 index 000000000000..eb5834d895b0 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_rxtx.h @@ -0,0 +1,512 @@ +/*! \file bcmcnet_rxtx.h + * + * Generic data structure and macro definitions for BCMCNET Rx/Tx. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef BCMCNET_RXTX_H +#define BCMCNET_RXTX_H + +/*! Default descriptor number in each ring */ +#define NUM_RING_DESC 64 + +/*! Maximum number of packets to be handled in one poll call */ +#define NUM_RXTX_BUDGET 64 + +/*! + * \brief Rx buffer mode definitions. + */ +enum buf_mode { + /*! Private DMA buffer in user space */ + PDMA_BUF_MODE_PRIV, + + /*! SKB in kernel */ + PDMA_BUF_MODE_SKB, + + /*! Paged buffer in kernel */ + PDMA_BUF_MODE_PAGE, + + /*! Kernel buffer mapped to user space */ + PDMA_BUF_MODE_MAPPED, + + /*! MAX mode */ + PDMA_BUF_MODE_MAX +}; + +/*! + * \brief Rx queue statistics. + */ +struct rx_stats { + /*! Number of received packets */ + uint64_t packets; + + /*! Number of received bytes */ + uint64_t bytes; + + /*! Number of dropped packets */ + uint64_t dropped; + + /*! Number of errors */ + uint64_t errors; + + /*! Number of head errors */ + uint64_t head_errors; + + /*! Number of data errors */ + uint64_t data_errors; + + /*! Number of cell errors */ + uint64_t cell_errors; + + /*! Number of failed allocation */ + uint64_t nomems; +}; + +/*! + * Rx queue structure + */ +struct pdma_rx_queue { + /*! Group index to which this queue belongs */ + uint32_t group_id; + + /*! Global channel index */ + uint32_t chan_id; + + /*! Queue index */ + uint32_t queue_id; + + /*! Pointer to the device control structure */ + struct dev_ctrl *ctrl; + + /*! Rx packet buffer pointers */ + struct pdma_rx_buf *pbuf; + + /*! Rx ring address */ + void *ring; + + /*! Rx ring DMA address */ + dma_addr_t ring_addr; + + /*! Rx ring DMA halt address */ + dma_addr_t halt_addr; + + /*! Rx buffer size */ + uint32_t buf_size; + + /*! Total number of descriptors */ + uint32_t nb_desc; + + /*! Next free ring entry */ + uint32_t curr; + + /*! Halt ring entry */ + uint32_t halt; + + /*! Max free descriptors to hold */ + uint32_t free_thresh; + + /*! Rx interrupt coalesce value */ + uint32_t ic_val; + + /*! Rx interrupt coalescing */ + int intr_coalescing; + + /*! Queue statistics */ + struct rx_stats stats; + + /*! Rx queue spin lock */ + sal_spinlock_t lock; + + /*! Queue state */ + int state; + /*! Queue is used */ +#define PDMA_RX_QUEUE_USED (1 << 0) + /*! Queue is setup */ +#define PDMA_RX_QUEUE_SETUP (1 << 1) + /*! Queue is active */ +#define PDMA_RX_QUEUE_ACTIVE (1 << 2) + /*! Queue is busy */ +#define PDMA_RX_QUEUE_BUSY (1 << 3) + /*! Queue is suspended */ +#define PDMA_RX_QUEUE_XOFF (1 << 4) + /*! Queue is batch refilled */ +#define PDMA_RX_BATCH_REFILL (1 << 5) + + /*! DMA buffer mode */ + enum buf_mode mode; +}; + +/*! + * \brief Tx queue statistics. + */ +struct tx_stats { + /*! Number of sent packets */ + uint64_t packets; + + /*! Number of sent bytes */ + uint64_t bytes; + + /*! Number of dropped packets */ + uint64_t dropped; + + /*! Number of errors */ + uint64_t errors; + + /*! Number of suspends */ + uint64_t xoffs; +}; + +/*! + * \brief Tx queue structure. + */ +struct pdma_tx_queue { + /*! Group index to which this queue belongs */ + uint32_t group_id; + + /*! Global channel index */ + uint32_t chan_id; + + /*! Queue index */ + uint32_t queue_id; + + /*! pointer to the device control structure */ + struct dev_ctrl *ctrl; + + /*! Tx packet buffer pointers */ + struct pdma_tx_buf *pbuf; + + /*! Tx ring address */ + void *ring; + + /*! Tx ring DMA address */ + dma_addr_t ring_addr; + + /*! Tx ring DMA halt address */ + dma_addr_t halt_addr; + + /*! Total number of descriptors */ + uint32_t nb_desc; + + /*! Next free ring entry */ + uint32_t curr; + + /*! First entry to be transmitted */ + uint32_t dirt; + + /*! Halt ring entry */ + uint32_t halt; + + /*! Max free descriptors to hold in non-intr mode */ + uint32_t free_thresh; + + /*! Tx interrupt coalesce value */ + uint32_t ic_val; + + /*! Tx interrupt coalescing */ + int intr_coalescing; + + /*! Queue statistics */ + struct tx_stats stats; + + /*! Tx queue spin lock */ + sal_spinlock_t lock; + + /*! Tx mutex spin lock */ + sal_spinlock_t mutex; + + /*! Tx mutex and flow control semaphore */ + sal_sem_t sem; + + /*! Queue state */ + int state; + /*! Queue is used */ +#define PDMA_TX_QUEUE_USED (1 << 0) + /*! Queue is setup */ +#define PDMA_TX_QUEUE_SETUP (1 << 1) + /*! Queue is active */ +#define PDMA_TX_QUEUE_ACTIVE (1 << 2) + /*! Queue is setup */ +#define PDMA_TX_QUEUE_BUSY (1 << 3) + /*! Queue is suspended */ +#define PDMA_TX_QUEUE_XOFF (1 << 4) + /*! Queue is poll mode */ +#define PDMA_TX_QUEUE_POLL (1 << 5) + + /*! DMA buffer mode */ + enum buf_mode mode; +}; + +/*! + * \brief Setup Rx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_rx_queue_setup(struct pdma_dev *dev, int queue); + +/*! + * \brief Release Rx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_rx_queue_release(struct pdma_dev *dev, int queue); + +/*! + * \brief Restore Rx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_rx_queue_restore(struct pdma_dev *dev, int queue); + +/*! + * \brief Setup virtual Rx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_rx_vqueue_setup(struct pdma_dev *dev, int queue); + +/*! + * \brief Release virtual Rx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_rx_vqueue_release(struct pdma_dev *dev, int queue); + +/*! + * \brief Setup Tx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Tx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_tx_queue_setup(struct pdma_dev *dev, int queue); + +/*! + * \brief Release Tx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Tx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_tx_queue_release(struct pdma_dev *dev, int queue); + +/*! + * \brief Restore Tx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Tx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_tx_queue_restore(struct pdma_dev *dev, int queue); + +/*! + * \brief Setup virtual Tx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_tx_vqueue_setup(struct pdma_dev *dev, int queue); + +/*! + * \brief Release virtual Tx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_tx_vqueue_release(struct pdma_dev *dev, int queue); + +/*! + * \brief Suspend Rx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_rx_queue_suspend(struct pdma_dev *dev, int queue); + +/*! + * \brief Resume Rx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_rx_queue_resume(struct pdma_dev *dev, int queue); + +/*! + * \brief Suspend Tx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Tx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_tx_queue_suspend(struct pdma_dev *dev, int queue); + +/*! + * \brief Resume Tx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Tx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_tx_queue_resume(struct pdma_dev *dev, int queue); + +/*! + * \brief Wakeup Tx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Tx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_tx_queue_wakeup(struct pdma_dev *dev, int queue); + +/*! + * \brief Start Tx queue transmission. + * + * \param [in] dev Device structure point. + * \param [in] queue Tx queue number. + * \param [in] buf Tx packet buffer. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_tx_queue_xmit(struct pdma_dev *dev, int queue, void *buf); + +/*! + * \brief Poll Rx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * \param [in] budget Poll budget. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_rx_queue_poll(struct pdma_dev *dev, int queue, int budget); + +/*! + * \brief Poll Tx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Tx queue number. + * \param [in] budget Poll budget. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_tx_queue_poll(struct pdma_dev *dev, int queue, int budget); + +/*! + * \brief Poll queue group. + * + * \param [in] dev Device structure point. + * \param [in] group Group number. + * \param [in] budget Poll budget. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_group_poll(struct pdma_dev *dev, int group, int budget); + +/*! + * \brief Dump Rx ring. + * + * \param [in] dev Device structure point. + * \param [in] queue Rx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_rx_ring_dump(struct pdma_dev *dev, int queue); + +/*! + * \brief Dump Tx ring. + * + * \param [in] dev Device structure point. + * \param [in] queue Tx queue number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_pdma_tx_ring_dump(struct pdma_dev *dev, int queue); + +#endif /* BCMCNET_RXTX_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_types.h b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_types.h new file mode 100644 index 000000000000..42bd9240828b --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_types.h @@ -0,0 +1,263 @@ +/*! \file bcmcnet_types.h + * + * BCMCNET public data structure and macro definitions. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef BCMCNET_TYPES_H +#define BCMCNET_TYPES_H + +#include + +/*! Maximum length of device name */ +#define DEV_NAME_LEN_MAX 16 + +/*! Maximum number of groups supported each device */ +#define NUM_GRP_MAX 4 + +/*! Maximum number of queues supported each group */ +#define NUM_Q_PER_GRP 8 + +/*! Maximum number of queues supported each device */ +#define NUM_QUE_MAX (NUM_GRP_MAX * NUM_Q_PER_GRP) + +/*! Maximum length of jumbo frame */ +#define JUMBO_FRAME_LEN_MAX 0xffff + +/*! Maximum Rx buffer size */ +#define RX_BUF_SIZE_MAX JUMBO_FRAME_LEN_MAX + +/*! Minimum Rx buffer size */ +#define RX_BUF_SIZE_MIN 68 + +/*! Default Rx buffer size */ +#define RX_BUF_SIZE_DFLT 9216 + +/*! + * \brief Transmission direction. + */ +enum pdma_dir { + PDMA_Q_RX = 0, + PDMA_Q_TX +}; + +/*! + * \brief Device information. + */ +typedef struct bcmcnet_dev_info { + /*! Device name */ + char dev_name[DEV_NAME_LEN_MAX]; + + /*! Device ID */ + uint32_t dev_id; + + /*! Device type */ + uint32_t dev_type; + + /*! Maximum number of groups */ + uint32_t max_groups; + + /*! Maximum number of queues */ + uint32_t max_queues; + + /*! Bitmap of groups at work */ + uint32_t bm_groups; + + /*! Bitmap of Rx queues at work */ + uint32_t bm_rx_queues; + + /*! Bitmap of Tx queues at work */ + uint32_t bm_tx_queues; + + /*! Number of groups at work */ + uint32_t nb_groups; + + /*! Number of Rx queues at work */ + uint32_t nb_rx_queues; + + /*! Number of Tx queues at work */ + uint32_t nb_tx_queues; + + /*! Rx descriptor size */ + uint32_t rx_desc_size; + + /*! Tx descriptor size */ + uint32_t tx_desc_size; + + /*! Rx packet header size */ + uint32_t rx_ph_size; + + /*! Tx packet header size */ + uint32_t tx_ph_size; + + /*! Rx buffer size */ + uint32_t rx_buf_dflt; + + /*! Number of descriptors for a queue */ + uint32_t nb_desc_dflt; + + /*! Rx buffer size per queue */ + uint32_t rx_buf_size[NUM_QUE_MAX]; + + /*! Number of Rx descriptors per queue */ + uint32_t nb_rx_desc[NUM_QUE_MAX]; + + /*! Number of Tx descriptors per queue */ + uint32_t nb_tx_desc[NUM_QUE_MAX]; +} bcmcnet_dev_info_t; + +/*! + * \brief Device statistics. + */ +typedef struct bcmcnet_dev_stats { + /*! Number of successfully received packets */ + uint64_t rx_packets; + + /*! Number of successfully received bytes */ + uint64_t rx_bytes; + + /*! Number of dropped packets */ + uint64_t rx_dropped; + + /*! Number of erroneous received packets */ + uint64_t rx_errors; + + /*! Number of error head packets */ + uint64_t rx_head_errors; + + /*! Number of error data packets */ + uint64_t rx_data_errors; + + /*! Number of error cell packets */ + uint64_t rx_cell_errors; + + /*! Number of RX pktbuf allocation failures */ + uint64_t rx_nomems; + + /*! Number of successfully transmitted packets */ + uint64_t tx_packets; + + /*! Number of successfully transmitted bytes */ + uint64_t tx_bytes; + + /*! Number of dropped packets */ + uint64_t tx_dropped; + + /*! Number of failed transmitted packets */ + uint64_t tx_errors; + + /*! Number of suspended transmission */ + uint64_t tx_xoffs; + + /*! Number of interrupts */ + uint64_t intrs; + + /*! Number of successfully received packets per queue */ + uint64_t rxq_packets[NUM_QUE_MAX]; + + /*! Number of successfully received bytes per queue */ + uint64_t rxq_bytes[NUM_QUE_MAX]; + + /*! Number of dropped packets per queue */ + uint64_t rxq_dropped[NUM_QUE_MAX]; + + /*! Number of erroneous received packets per queue */ + uint64_t rxq_errors[NUM_QUE_MAX]; + + /*! Number of error head packets per queue */ + uint64_t rxq_head_errors[NUM_QUE_MAX]; + + /*! Number of error data packets per queue */ + uint64_t rxq_data_errors[NUM_QUE_MAX]; + + /*! Number of error cell packets per queue */ + uint64_t rxq_cell_errors[NUM_QUE_MAX]; + + /*! Number of RX pktbuf allocation failures per queue */ + uint64_t rxq_nomems[NUM_QUE_MAX]; + + /*! Number of successfully transmitted bytes per queue */ + uint64_t txq_packets[NUM_QUE_MAX]; + + /*! Number of successfully transmitted bytes per queue */ + uint64_t txq_bytes[NUM_QUE_MAX]; + + /*! Number of dropped packets per queue */ + uint64_t txq_dropped[NUM_QUE_MAX]; + + /*! Number of failed transmitted packets per queue */ + uint64_t txq_errors[NUM_QUE_MAX]; + + /*! Number of suspended transmission per queue */ + uint64_t txq_xoffs[NUM_QUE_MAX]; +} bcmcnet_dev_stats_t; + +/*! + * \brief Device modes. + */ +typedef enum dev_mode_e { + /*! + * User network mode. + * The standalone CNET works in user space. + */ + DEV_MODE_UNET = 0, + + /*! + * Kernel network mode. + * Combined with KNET module, CNET works in kernel space. + */ + DEV_MODE_KNET, + + /*! + * Virtual network mode. + * CNET works in user space as a virtual network. + * The hypervisor must be deployed in KNET module. + */ + DEV_MODE_VNET, + + /*! + * Hyper network mode. + * Combined with KNET module, CNET works in kernel space as a hypervisor. + * The virtual network is not neccessary in this mode. + */ + DEV_MODE_HNET, + + /*! Maximum number of mode */ + DEV_MODE_MAX +} dev_mode_t; + +/*! + * \brief VNET sync data. + */ +typedef struct vnet_sync_s { + /*! Rx ring address */ + uint64_t rx_ring_addr[NUM_QUE_MAX]; + + /*! Rx ring size */ + uint32_t rx_ring_size[NUM_QUE_MAX]; + + /*! Tx ring address */ + uint64_t tx_ring_addr[NUM_QUE_MAX]; + + /*! Tx ring size */ + uint32_t tx_ring_size[NUM_QUE_MAX]; +} vnet_sync_t; + +#endif /* BCMCNET_TYPES_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_core.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_core.c new file mode 100644 index 000000000000..ef4aca7da49e --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_core.c @@ -0,0 +1,701 @@ +/*! \file bcmcnet_core.c + * + * Utility routines for BCMCNET driver. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include + +/*! + * Initialize a device + */ +int +bcmcnet_pdma_dev_init(struct pdma_dev *dev) +{ + int rv; + + /* Open the device */ + rv = bcmcnet_pdma_open(dev); + if (SHR_FAILURE(rv)) { + return rv; + } + + dev->attached = 1; + + return SHR_E_NONE; +} + +/*! + * Clean up a device + */ +int +bcmcnet_pdma_dev_cleanup(struct pdma_dev *dev) +{ + if (!dev->attached) { + return SHR_E_NONE; + } + + dev->ops->dev_close(dev); + dev->ops = NULL; + + dev->attached = 0; + + return SHR_E_NONE; +} + +/*! + * Start a device + */ +int +bcmcnet_pdma_dev_start(struct pdma_dev *dev) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + uint32_t qi; + int rv; + + if (!dev->attached) { + return SHR_E_UNAVAIL; + } + + if (dev->started) { + return SHR_E_NONE; + } + + rv = dev->ops->dev_config(dev, ctrl->bm_rxq, ctrl->bm_txq); + if (SHR_FAILURE(rv)) { + return rv; + } + + /* Start all the Rx queues */ + for (qi = 0; qi < ctrl->nb_rxq; qi++) { + rv = dev->ops->rx_queue_setup(dev, qi); + if (SHR_FAILURE(rv)) { + return rv; + } + dev->ops->rx_queue_intr_enable(dev, qi); + dev->ops->rx_queue_start(dev, qi); + } + + /* Start all the Tx queues */ + for (qi = 0; qi < ctrl->nb_txq; qi++) { + dev->ops->tx_queue_setup(dev, qi); + dev->ops->tx_queue_intr_enable(dev, qi); + dev->ops->tx_queue_start(dev, qi); + dev->ops->tx_queue_wakeup(dev, qi); + } + + bcmcnet_pdma_dev_info_get(dev); + + dev->started = 1; + + return SHR_E_NONE; +} + +/*! + * Stop a device + */ +int +bcmcnet_pdma_dev_stop(struct pdma_dev *dev) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + uint32_t qi; + + if (!dev->attached) { + return SHR_E_UNAVAIL; + } + + if (!dev->started) { + return SHR_E_NONE; + } + + /* Stop all the Rx queues */ + for (qi = 0; qi < ctrl->nb_rxq; qi++) { + dev->ops->rx_queue_intr_disable(dev, qi); + dev->ops->rx_queue_stop(dev, qi); + dev->ops->rx_queue_release(dev, qi); + } + + /* Stop all the Tx queues */ + for (qi = 0; qi < ctrl->nb_txq; qi++) { + dev->ops->tx_queue_intr_disable(dev, qi); + dev->ops->tx_queue_stop(dev, qi); + dev->ops->tx_queue_wakeup(dev, qi); + dev->ops->tx_queue_release(dev, qi); + } + + dev->started = 0; + + return SHR_E_NONE; +} + +/*! + * Suspend a device + */ +int +bcmcnet_pdma_dev_suspend(struct pdma_dev *dev) +{ + if (!dev->attached) { + return SHR_E_UNAVAIL; + } + + return dev->ops->dev_suspend(dev); +} + +/*! + * Resume a device + */ +int +bcmcnet_pdma_dev_resume(struct pdma_dev *dev) +{ + if (!dev->attached) { + return SHR_E_UNAVAIL; + } + + return dev->ops->dev_resume(dev); +} + +/*! + * Suspend Rx + */ +int +bcmcnet_pdma_dev_rx_suspend(struct pdma_dev *dev) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + uint32_t qi; + + if (!dev->attached) { + return SHR_E_UNAVAIL; + } + + /* Suspend all the Rx queues */ + for (qi = 0; qi < ctrl->nb_rxq; qi++) { + dev->ops->rx_queue_suspend(dev, qi); + } + + return SHR_E_NONE; +} + +/*! + * Resume Rx + */ +int +bcmcnet_pdma_dev_rx_resume(struct pdma_dev *dev) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + uint32_t qi; + + if (!dev->attached) { + return SHR_E_UNAVAIL; + } + + /* Resume all the Rx queues */ + for (qi = 0; qi < ctrl->nb_rxq; qi++) { + dev->ops->rx_queue_resume(dev, qi); + } + + return SHR_E_NONE; +} + +/*! + * Dock to HNET + */ +int +bcmcnet_pdma_dev_dock(struct pdma_dev *dev) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + uint32_t qi; + int rv; + + if (!dev->attached) { + return SHR_E_UNAVAIL; + } + + /* Set up all the virtual Rx queues */ + for (qi = 0; qi < ctrl->nb_rxq; qi++) { + rv = dev->ops->rx_vqueue_setup(dev, qi); + if (SHR_FAILURE(rv)) { + return rv; + } + } + + /* Set up all the virtual Tx queues */ + for (qi = 0; qi < ctrl->nb_txq; qi++) { + rv = dev->ops->tx_vqueue_setup(dev, qi); + if (SHR_FAILURE(rv)) { + return rv; + } + } + + return SHR_E_NONE; +} + +/*! + * Undock from HNET + */ +int +bcmcnet_pdma_dev_undock(struct pdma_dev *dev) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + uint32_t qi; + + if (!dev->attached) { + return SHR_E_UNAVAIL; + } + + /* Release all the virtual Rx queues */ + for (qi = 0; qi < ctrl->nb_rxq; qi++) { + dev->ops->rx_vqueue_release(dev, qi); + } + + /* Release all the virtual Tx queues */ + for (qi = 0; qi < ctrl->nb_txq; qi++) { + dev->ops->tx_vqueue_release(dev, qi); + } + + return SHR_E_NONE; +} + +/*! + * Get device information + */ +int +bcmcnet_pdma_dev_info_get(struct pdma_dev *dev) +{ + if (!dev->ops || !dev->ops->dev_info_get) { + return SHR_E_INTERNAL; + } + + dev->ops->dev_info_get(dev); + + return SHR_E_NONE; +} + +/*! + * Get device statistics + */ +int +bcmcnet_pdma_dev_stats_get(struct pdma_dev *dev) +{ + if (!dev->ops || !dev->ops->dev_stats_get) { + return SHR_E_INTERNAL; + } + + dev->ops->dev_stats_get(dev); + + return SHR_E_NONE; +} + +/*! + * Reset device statistics + */ +int +bcmcnet_pdma_dev_stats_reset(struct pdma_dev *dev) +{ + if (!dev->ops || !dev->ops->dev_stats_reset) { + return SHR_E_INTERNAL; + } + + dev->ops->dev_stats_reset(dev); + + return SHR_E_NONE; +} + +/*! + * Convert a queue index to channel index + */ +int +bcmcnet_pdma_dev_queue_to_chan(struct pdma_dev *dev, int queue, int dir, int *chan) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + + if (dir == PDMA_Q_RX) { + if ((uint32_t)queue >= ctrl->nb_rxq || chan == NULL) { + return SHR_E_PARAM; + } + } else { + if ((uint32_t)queue >= ctrl->nb_txq || chan == NULL) { + return SHR_E_PARAM; + } + } + + if (!dev->ops || !dev->ops->dev_lq_to_pq) { + return SHR_E_INTERNAL; + } + + return dev->ops->dev_lq_to_pq(dev, queue, dir, chan); +} + +/*! + * Convert a channel index to queue index + */ +int +bcmcnet_pdma_dev_chan_to_queue(struct pdma_dev *dev, int chan, int *queue, int *dir) +{ + if (chan < 0 || chan >= dev->num_queues || queue == NULL || dir == NULL) { + return SHR_E_PARAM; + } + + if (!dev->ops || !dev->ops->dev_pq_to_lq) { + return SHR_E_INTERNAL; + } + + return dev->ops->dev_pq_to_lq(dev, chan, queue, dir); +} + +/*! + * Enable interrupt for a Rx queue + */ +int +bcmcnet_rx_queue_intr_enable(struct pdma_dev *dev, int queue) +{ + if (!dev->ops || !dev->ops->rx_queue_intr_enable) { + return SHR_E_INTERNAL; + } + + return dev->ops->rx_queue_intr_enable(dev, queue); +} + +/*! + * Disable interrupt for a Rx queue + */ +int +bcmcnet_rx_queue_intr_disable(struct pdma_dev *dev, int queue) +{ + if (!dev->ops || !dev->ops->rx_queue_intr_disable) { + return SHR_E_INTERNAL; + } + + return dev->ops->rx_queue_intr_disable(dev, queue); +} + +/*! + * Acknowledge interrupt for a Rx queue + */ +int +bcmcnet_rx_queue_intr_ack(struct pdma_dev *dev, int queue) +{ + if (!dev->ops || !dev->ops->rx_queue_intr_ack) { + return SHR_E_INTERNAL; + } + + return dev->ops->rx_queue_intr_ack(dev, queue); +} + +/*! + * Check interrupt for a Rx queue + */ +int +bcmcnet_rx_queue_intr_check(struct pdma_dev *dev, int queue) +{ + if (!dev->ops || !dev->ops->rx_queue_intr_check) { + return SHR_E_INTERNAL; + } + + return dev->ops->rx_queue_intr_check(dev, queue); +} + +/*! + * Enable interrupt for a Tx queue + */ +int +bcmcnet_tx_queue_intr_enable(struct pdma_dev *dev, int queue) +{ + if (!dev->ops || !dev->ops->tx_queue_intr_enable) { + return SHR_E_INTERNAL; + } + + return dev->ops->tx_queue_intr_enable(dev, queue); +} + +/*! + * Disable interrupt for a Tx queue + */ +int +bcmcnet_tx_queue_intr_disable(struct pdma_dev *dev, int queue) +{ + if (!dev->ops || !dev->ops->tx_queue_intr_disable) { + return SHR_E_INTERNAL; + } + + return dev->ops->tx_queue_intr_disable(dev, queue); +} + +/*! + * Acknowledge interrupt for a Tx queue + */ +int +bcmcnet_tx_queue_intr_ack(struct pdma_dev *dev, int queue) +{ + if (!dev->ops || !dev->ops->tx_queue_intr_ack) { + return SHR_E_INTERNAL; + } + + return dev->ops->tx_queue_intr_ack(dev, queue); +} + +/*! + * Check interrupt for a Tx queue + */ +int +bcmcnet_tx_queue_intr_check(struct pdma_dev *dev, int queue) +{ + if (!dev->ops || !dev->ops->tx_queue_intr_check) { + return SHR_E_INTERNAL; + } + + return dev->ops->tx_queue_intr_check(dev, queue); +} + +/*! + * Enable interrupt for a queue + */ +int +bcmcnet_queue_intr_enable(struct pdma_dev *dev, struct intr_handle *hdl) +{ + if (hdl->dir == PDMA_Q_RX) { + return bcmcnet_rx_queue_intr_enable(dev, hdl->queue); + } else { + return bcmcnet_tx_queue_intr_enable(dev, hdl->queue); + } +} + +/*! + * Disable interrupt for a queue + */ +int +bcmcnet_queue_intr_disable(struct pdma_dev *dev, struct intr_handle *hdl) +{ + if (hdl->dir == PDMA_Q_RX) { + return bcmcnet_rx_queue_intr_disable(dev, hdl->queue); + } else { + return bcmcnet_tx_queue_intr_disable(dev, hdl->queue); + } +} + +/*! + * Acknowledge interrupt for a queue + */ +int +bcmcnet_queue_intr_ack(struct pdma_dev *dev, struct intr_handle *hdl) +{ + if (hdl->dir == PDMA_Q_RX) { + return bcmcnet_rx_queue_intr_ack(dev, hdl->queue); + } else { + return bcmcnet_tx_queue_intr_ack(dev, hdl->queue); + } +} + +/*! + * Check interrupt for a queue + */ +int +bcmcnet_queue_intr_check(struct pdma_dev *dev, struct intr_handle *hdl) +{ + if (hdl->dir == PDMA_Q_RX) { + return bcmcnet_rx_queue_intr_check(dev, hdl->queue); + } else { + return bcmcnet_tx_queue_intr_check(dev, hdl->queue); + } +} + +/*! + * Enable interrupt for a queue group + */ +int +bcmcnet_group_intr_enable(struct pdma_dev *dev, int group) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct queue_group *grp = &ctrl->grp[group]; + int queue, dir; + int i; + + if (!dev->ops) { + return SHR_E_INTERNAL; + } + + for (i = 0; i < dev->grp_queues; i++) { + if (1 << i & grp->bm_rxq) { + dev->ops->dev_pq_to_lq(dev, i + group * dev->grp_queues, &queue, &dir); + dev->ops->rx_queue_intr_enable(dev, queue); + } + } + + for (i = 0; i < dev->grp_queues; i++) { + if (1 << i & grp->bm_txq) { + dev->ops->dev_pq_to_lq(dev, i + group * dev->grp_queues, &queue, &dir); + dev->ops->tx_queue_intr_enable(dev, queue); + } + } + + return SHR_E_NONE; +} + +/*! + * Disable interrupt for a queue group + */ +int +bcmcnet_group_intr_disable(struct pdma_dev *dev, int group) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct queue_group *grp = &ctrl->grp[group]; + int queue, dir; + int i; + + if (!dev->ops) { + return SHR_E_INTERNAL; + } + + for (i = 0; i < dev->grp_queues; i++) { + if (1 << i & grp->bm_rxq) { + dev->ops->dev_pq_to_lq(dev, i + group * dev->grp_queues, &queue, &dir); + dev->ops->rx_queue_intr_disable(dev, queue); + } + } + + for (i = 0; i < dev->grp_queues; i++) { + if (1 << i & grp->bm_txq) { + dev->ops->dev_pq_to_lq(dev, i + group * dev->grp_queues, &queue, &dir); + dev->ops->tx_queue_intr_disable(dev, queue); + } + } + + return SHR_E_NONE; +} + +/*! + * Acknowledge interrupt for a queue group + */ +int +bcmcnet_group_intr_ack(struct pdma_dev *dev, int group) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct queue_group *grp = &ctrl->grp[group]; + int queue, dir; + int i; + + if (!dev->ops) { + return SHR_E_INTERNAL; + } + + for (i = 0; i < dev->grp_queues; i++) { + if (1 << i & grp->bm_rxq) { + dev->ops->dev_pq_to_lq(dev, i + group * dev->grp_queues, &queue, &dir); + dev->ops->rx_queue_intr_ack(dev, queue); + } + } + + for (i = 0; i < dev->grp_queues; i++) { + if (1 << i & grp->bm_txq) { + dev->ops->dev_pq_to_lq(dev, i + group * dev->grp_queues, &queue, &dir); + dev->ops->tx_queue_intr_ack(dev, queue); + } + } + + return SHR_E_NONE; +} + +/*! + * Check interrupt for a queue group + */ +int +bcmcnet_group_intr_check(struct pdma_dev *dev, int group) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct queue_group *grp = &ctrl->grp[group]; + int queue, dir; + int i; + + if (!dev->ops) { + return SHR_E_INTERNAL; + } + + for (i = 0; i < dev->grp_queues; i++) { + if (1 << i & grp->bm_rxq) { + dev->ops->dev_pq_to_lq(dev, i + group * dev->grp_queues, &queue, &dir); + if (dev->ops->rx_queue_intr_check(dev, queue)) { + return TRUE; + } + } + } + + for (i = 0; i < dev->grp_queues; i++) { + if (1 << i & grp->bm_txq) { + dev->ops->dev_pq_to_lq(dev, i + group * dev->grp_queues, &queue, &dir); + if (dev->ops->tx_queue_intr_check(dev, queue)) { + return TRUE; + } + } + } + + return FALSE; +} + +/*! + * Poll a Rx queue + */ +int +bcmcnet_rx_queue_poll(struct pdma_dev *dev, int queue, int budget) +{ + if (!dev->ops || !dev->ops->rx_queue_poll) { + return SHR_E_INTERNAL; + } + + return dev->ops->rx_queue_poll(dev, queue, budget); +} + +/*! + * Poll a Tx queue + */ +int +bcmcnet_tx_queue_poll(struct pdma_dev *dev, int queue, int budget) +{ + if (!dev->ops || !dev->ops->tx_queue_poll) { + return SHR_E_INTERNAL; + } + + return dev->ops->tx_queue_poll(dev, queue, budget); +} + +/*! + * Poll a queue + */ +int +bcmcnet_queue_poll(struct pdma_dev *dev, struct intr_handle *hdl, int budget) +{ + if (hdl->dir == PDMA_Q_RX) { + return bcmcnet_rx_queue_poll(dev, hdl->queue, budget); + } else { + return bcmcnet_tx_queue_poll(dev, hdl->queue, budget); + } +} + +/*! + * Poll a queue group + */ +int +bcmcnet_group_poll(struct pdma_dev *dev, int group, int budget) +{ + if (!dev->ops || !dev->ops->group_poll) { + return SHR_E_INTERNAL; + } + + return dev->ops->group_poll(dev, group, budget); +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_dev.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_dev.c new file mode 100644 index 000000000000..1f39515a7a62 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_dev.c @@ -0,0 +1,1059 @@ +/*! \file bcmcnet_dev.c + * + * Utility routines for BCMCNET device. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include +#include + +/*! + * Free resource for a Rx queue + */ +static void +bcn_rx_queues_free(struct pdma_dev *dev) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_rx_queue *rxq = NULL; + int gi, qi; + + for (gi = 0; gi < dev->num_groups; gi++) { + for (qi = 0; qi < dev->grp_queues; qi++) { + rxq = (struct pdma_rx_queue *)ctrl->grp[gi].rx_queue[qi]; + if (!rxq) { + continue; + } + sal_free(rxq); + ctrl->grp[gi].rx_queue[qi] = NULL; + if (dev->mode == DEV_MODE_HNET && ctrl->grp[gi].vnet_rxq[qi]) { + sal_free(ctrl->grp[gi].vnet_rxq[qi]); + ctrl->grp[gi].vnet_rxq[qi] = NULL; + } + } + } +} + +/*! + * Allocate resource for a Rx queue + */ +static int +bcn_rx_queues_alloc(struct pdma_dev *dev) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_rx_queue *rxq = NULL, *vrxq = NULL; + int gi, qi; + + for (gi = 0; gi < dev->num_groups; gi++) { + for (qi = 0; qi < dev->grp_queues; qi++) { + rxq = sal_alloc(sizeof(*rxq), "bcmcnetRxQueue"); + if (!rxq) { + goto error; + } + sal_memset(rxq, 0, sizeof(*rxq)); + rxq->group_id = gi; + rxq->chan_id = qi + gi * dev->grp_queues; + rxq->ctrl = ctrl; + ctrl->grp[gi].rx_queue[qi] = rxq; + if (dev->mode == DEV_MODE_HNET) { + vrxq = sal_alloc(sizeof(*vrxq), "bcmcnetVnetRxQueue"); + if (!vrxq) { + goto error; + } + sal_memset(vrxq, 0, sizeof(*vrxq)); + vrxq->group_id = gi; + vrxq->chan_id = qi + gi * dev->grp_queues; + vrxq->ctrl = ctrl; + ctrl->grp[gi].vnet_rxq[qi] = vrxq; + } + } + } + + return SHR_E_NONE; + +error: + bcn_rx_queues_free(dev); + + return SHR_E_MEMORY; +} + +/*! + * Free resource for a Tx queue + */ +static void +bcn_tx_queues_free(struct pdma_dev *dev) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_tx_queue *txq = NULL; + int gi, qi; + + for (gi = 0; gi < dev->num_groups; gi++) { + for (qi = 0; qi < dev->grp_queues; qi++) { + txq = (struct pdma_tx_queue *)ctrl->grp[gi].tx_queue[qi]; + if (!txq) { + continue; + } + sal_free(txq); + ctrl->grp[gi].tx_queue[qi] = NULL; + if (dev->mode == DEV_MODE_HNET && ctrl->grp[gi].vnet_txq[qi]) { + sal_free(ctrl->grp[gi].vnet_txq[qi]); + ctrl->grp[gi].vnet_txq[qi] = NULL; + } + } + } +} + +/*! + * Allocate resource for a Tx queue + */ +static int +bcn_tx_queues_alloc(struct pdma_dev *dev) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_tx_queue *txq = NULL, *vtxq = NULL; + int gi, qi; + + for (gi = 0; gi < dev->num_groups; gi++) { + for (qi = 0; qi < dev->grp_queues; qi++) { + txq = sal_alloc(sizeof(*txq), "bcmcnetTxQueue"); + if (!txq) { + goto error; + } + sal_memset(txq, 0, sizeof(*txq)); + txq->group_id = gi; + txq->chan_id = qi + gi * dev->grp_queues; + txq->ctrl = ctrl; + ctrl->grp[gi].tx_queue[qi] = txq; + if (dev->mode == DEV_MODE_HNET) { + vtxq = sal_alloc(sizeof(*vtxq), "bcmcnetVnetTxQueue"); + if (!vtxq) { + goto error; + } + sal_memset(vtxq, 0, sizeof(*vtxq)); + vtxq->group_id = gi; + vtxq->chan_id = qi + gi * dev->grp_queues; + vtxq->ctrl = ctrl; + ctrl->grp[gi].vnet_txq[qi] = vtxq; + } + } + } + + return SHR_E_NONE; + +error: + bcn_tx_queues_free(dev); + + return SHR_E_MEMORY; +} + +/*! + * \brief Parse Rx groups + * + * \param [in] dev Device structure point. + * \param [in] qbm Rx queue bitmap. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +bcn_rx_queue_group_parse(struct pdma_dev *dev, uint32_t qbm) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)ctrl->buf_mngr; + struct pdma_rx_queue *rxq = NULL; + struct intr_handle *hdl = NULL; + uint32_t mask; + int gi, qi, qn; + + ctrl->nb_rxq = 0; + sal_memset(ctrl->rx_queue, 0, sizeof(ctrl->rx_queue)); + + /* Figure out available groups and Rx queues */ + for (gi = 0; gi < dev->num_groups; gi++) { + if (!ctrl->grp[gi].attached) { + continue; + } + qn = 0; + mask = 0; + for (qi = 0; qi < dev->grp_queues; qi++) { + rxq = (struct pdma_rx_queue *)ctrl->grp[gi].rx_queue[qi]; + hdl = &ctrl->grp[gi].intr_hdl[qi]; + if (1 << (qi + gi * dev->grp_queues) & qbm) { + /* Set the number of descriptors */ + rxq->nb_desc = ctrl->grp[gi].nb_desc[qi]; + if (!rxq->nb_desc) { + rxq->nb_desc = ctrl->nb_desc; + ctrl->grp[gi].nb_desc[qi] = rxq->nb_desc; + } + /* Set Rx buffer size */ + rxq->buf_size = ctrl->grp[gi].rx_size[qi]; + if (rxq->buf_size < RX_BUF_SIZE_MIN) { + rxq->buf_size = RX_BUF_SIZE_MIN; + ctrl->grp[gi].rx_size[qi] = rxq->buf_size; + } else if (rxq->buf_size > RX_BUF_SIZE_MAX) { + rxq->buf_size = ctrl->rx_buf_size; + ctrl->grp[gi].rx_size[qi] = rxq->buf_size; + } + rxq->buf_size += dev->rx_ph_size; + /* Set mode and state for the queue */ + rxq->mode = bm->rx_buf_mode(dev, rxq); + rxq->state = PDMA_RX_QUEUE_USED; + if (dev->flags & PDMA_RX_BATCHING) { + rxq->free_thresh = rxq->nb_desc / 4; + rxq->state |= PDMA_RX_BATCH_REFILL; + } + /* Update queue index */ + rxq->queue_id = ctrl->nb_rxq; + ctrl->rx_queue[rxq->queue_id] = rxq; + ctrl->nb_rxq++; + qn++; + mask |= 1 << qi; + /* Set up handler for the queue */ + hdl->queue = rxq->queue_id; + hdl->dir = PDMA_Q_RX; + hdl->budget = ctrl->budget < rxq->nb_desc ? + ctrl->budget : rxq->nb_desc; + if (dev->mode == DEV_MODE_HNET) { + ctrl->vnet_rxq[rxq->queue_id] = ctrl->grp[gi].vnet_rxq[qi]; + } + } else { + rxq->state = 0; + } + } + + /* Set group metadata */ + if (qn) { + ctrl->grp[gi].bm_rxq = mask; + ctrl->grp[gi].nb_rxq = qn; + } else { + ctrl->grp[gi].bm_rxq = 0; + ctrl->grp[gi].nb_rxq = 0; + } + } + + return SHR_E_NONE; +} + +/*! + * \brief Parse Tx groups + * + * \param [in] dev Device structure point. + * \param [in] qbm Tx queue bitmap. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +bcn_tx_queue_group_parse(struct pdma_dev *dev, uint32_t qbm) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_tx_queue *txq = NULL; + struct intr_handle *hdl = NULL; + uint32_t mask; + int gi, qi, qn; + + ctrl->nb_txq = 0; + sal_memset(ctrl->tx_queue, 0, sizeof(ctrl->tx_queue)); + + /* Figure out available groups and Tx queues */ + for (gi = 0; gi < dev->num_groups; gi++) { + if (!ctrl->grp[gi].attached) { + continue; + } + qn = 0; + mask = 0; + for (qi = 0; qi < dev->grp_queues; qi++) { + txq = (struct pdma_tx_queue *)ctrl->grp[gi].tx_queue[qi]; + hdl = &ctrl->grp[gi].intr_hdl[qi]; + if (1 << (qi + gi * dev->grp_queues) & qbm) { + /* Set the number of descriptors */ + txq->nb_desc = ctrl->grp[gi].nb_desc[qi]; + if (!txq->nb_desc) { + txq->nb_desc = ctrl->nb_desc; + ctrl->grp[gi].nb_desc[qi] = txq->nb_desc; + } + /* Set mode and state for the queue */ + txq->state = PDMA_TX_QUEUE_USED; + if (dev->flags & PDMA_TX_POLLING) { + txq->free_thresh = txq->nb_desc / 4; + txq->state |= PDMA_TX_QUEUE_POLL; + } + /* Update queue index */ + txq->queue_id = ctrl->nb_txq; + ctrl->tx_queue[txq->queue_id] = txq; + ctrl->nb_txq++; + qn++; + mask |= 1 << qi; + /* Set up handler for the queue */ + hdl->queue = txq->queue_id; + hdl->dir = PDMA_Q_TX; + hdl->budget = ctrl->budget < txq->nb_desc ? + ctrl->budget : txq->nb_desc; + if (dev->mode == DEV_MODE_HNET) { + ctrl->vnet_txq[txq->queue_id] = ctrl->grp[gi].vnet_txq[qi]; + } + } else { + txq->state = 0; + } + } + + /* Set group metadata */ + if (qn) { + ctrl->grp[gi].bm_txq = mask; + ctrl->grp[gi].nb_txq = qn; + } else { + ctrl->grp[gi].bm_txq = 0; + ctrl->grp[gi].nb_txq = 0; + } + } + + return SHR_E_NONE; +} + +/*! + * \brief Configure device + * + * \param [in] dev Device structure point. + * \param [in] bm_rxq Rx queue bitmap. + * \param [in] bm_txq Tx queue bitmap. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +bcmcnet_pdma_config(struct pdma_dev *dev, uint32_t bm_rxq, uint32_t bm_txq) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + int gi; + + if (!bm_rxq || !bm_txq || (bm_rxq & bm_txq)) { + return SHR_E_PARAM; + } + + bcn_rx_queue_group_parse(dev, bm_rxq); + bcn_tx_queue_group_parse(dev, bm_txq); + + for (gi = 0; gi < dev->num_groups; gi++) { + if (!ctrl->grp[gi].attached) { + continue; + } + /* Update group metadata */ + if (!ctrl->grp[gi].bm_rxq && !ctrl->grp[gi].bm_txq) { + ctrl->grp[gi].attached = 0; + ctrl->bm_grp &= ~(1 << gi); + ctrl->nb_grp--; + continue; + } + ctrl->grp[gi].ctrl = ctrl; + ctrl->grp[gi].id = gi; + ctrl->grp[gi].irq_mask = 0; + } + + return hw->hdls.hw_config(hw); +} + +/*! + * Close device + */ +static int +bcmcnet_pdma_close(struct pdma_dev *dev) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)dev->ctrl.hw; + int gi; + + hw->hdls.hw_reset(hw); + + for (gi = 0; gi < dev->num_groups; gi++) { + if (!ctrl->grp[gi].attached) { + continue; + } + /* Reset group metadata */ + ctrl->bm_grp &= ~(1 << gi); + ctrl->nb_grp--; + ctrl->grp[gi].irq_mask = 0; + ctrl->grp[gi].poll_queues = 0; + ctrl->grp[gi].attached = 0; + } + + bcn_rx_queues_free(dev); + bcn_tx_queues_free(dev); + + return SHR_E_NONE; +} + +/*! + * Suspend device + */ +static int +bcmcnet_pdma_suspend(struct pdma_dev *dev) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + uint32_t qi; + + for (qi = 0; qi < ctrl->nb_rxq; qi++) { + bcmcnet_pdma_rx_queue_suspend(dev, qi); + } + + for (qi = 0; qi < ctrl->nb_txq; qi++) { + bcmcnet_pdma_tx_queue_suspend(dev, qi); + } + + return SHR_E_NONE; +} + +/*! + * Resume device + */ +static int +bcmcnet_pdma_resume(struct pdma_dev *dev) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + uint32_t qi; + + for (qi = 0; qi < ctrl->nb_rxq; qi++) { + bcmcnet_pdma_rx_queue_resume(dev, qi); + } + + for (qi = 0; qi < ctrl->nb_txq; qi++) { + bcmcnet_pdma_tx_queue_resume(dev, qi); + } + + return SHR_E_NONE; +} + +/*! + * Get device information + */ +static void +bcmcnet_pdma_info_get(struct pdma_dev *dev) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_rx_queue *rxq = NULL; + struct pdma_tx_queue *txq = NULL; + uint32_t qi; + + sal_strncpy(dev->info.dev_name, dev->name, sizeof(dev->info.dev_name) - 1); + dev->info.dev_name[sizeof(dev->info.dev_name) - 1] = 0; + dev->info.dev_id = dev->dev_id; + dev->info.dev_type = dev->dev_type; + dev->info.max_groups = hw->info.num_cmcs; + dev->info.max_queues = hw->info.num_chans; + dev->info.bm_groups = ctrl->bm_grp; + dev->info.bm_rx_queues = ctrl->bm_rxq; + dev->info.bm_tx_queues = ctrl->bm_txq; + dev->info.nb_groups = ctrl->nb_grp; + dev->info.nb_rx_queues = ctrl->nb_rxq; + dev->info.nb_tx_queues = ctrl->nb_txq; + dev->info.rx_desc_size = hw->info.rx_dcb_size; + dev->info.tx_desc_size = hw->info.tx_dcb_size; + dev->info.rx_ph_size = hw->info.rx_ph_size; + dev->info.tx_ph_size = hw->info.tx_ph_size; + dev->info.rx_buf_dflt = ctrl->rx_buf_size; + dev->info.nb_desc_dflt = ctrl->nb_desc; + + for (qi = 0; qi < ctrl->nb_rxq; qi++) { + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[qi]; + if (!rxq) { + continue; + } + dev->info.rx_buf_size[qi] = rxq->buf_size; + dev->info.nb_rx_desc[qi] = rxq->nb_desc; + } + + for (qi = 0; qi < ctrl->nb_txq; qi++) { + txq = (struct pdma_tx_queue *)ctrl->tx_queue[qi]; + if (!txq) { + continue; + } + dev->info.nb_tx_desc[qi] = txq->nb_desc; + } +} + +/*! + * Get device statistics + */ +static void +bcmcnet_pdma_stats_get(struct pdma_dev *dev) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_rx_queue *rxq = NULL; + struct pdma_tx_queue *txq = NULL; + uint32_t packets = 0, bytes = 0, dropped = 0, errors = 0, nomems = 0, xoffs = 0; + uint32_t head_errors = 0, data_errors = 0, cell_errors = 0; + uint32_t qi; + + for (qi = 0; qi < ctrl->nb_rxq; qi++) { + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[qi]; + if (!rxq) { + continue; + } + packets += rxq->stats.packets; + bytes += rxq->stats.bytes; + dropped += rxq->stats.dropped; + errors += rxq->stats.errors; + head_errors += rxq->stats.head_errors; + data_errors += rxq->stats.data_errors; + cell_errors += rxq->stats.cell_errors; + nomems += rxq->stats.nomems; + dev->stats.rxq_packets[qi] = rxq->stats.packets; + dev->stats.rxq_bytes[qi] = rxq->stats.bytes; + dev->stats.rxq_dropped[qi] = rxq->stats.dropped; + dev->stats.rxq_errors[qi] = rxq->stats.errors; + dev->stats.rxq_head_errors[qi] = rxq->stats.head_errors; + dev->stats.rxq_data_errors[qi] = rxq->stats.data_errors; + dev->stats.rxq_cell_errors[qi] = rxq->stats.cell_errors; + dev->stats.rxq_nomems[qi] = rxq->stats.nomems; + } + + dev->stats.rx_packets = packets; + dev->stats.rx_bytes = bytes; + dev->stats.rx_dropped = dropped; + dev->stats.rx_errors = errors; + dev->stats.rx_head_errors = head_errors; + dev->stats.rx_data_errors = data_errors; + dev->stats.rx_cell_errors = cell_errors; + dev->stats.rx_nomems = nomems; + + packets = bytes = dropped = errors = 0; + for (qi = 0; qi < ctrl->nb_txq; qi++) { + txq = (struct pdma_tx_queue *)ctrl->tx_queue[qi]; + if (!txq) { + continue; + } + packets += txq->stats.packets; + bytes += txq->stats.bytes; + dropped += txq->stats.dropped; + errors += txq->stats.errors; + xoffs += txq->stats.xoffs; + dev->stats.txq_packets[qi] = txq->stats.packets; + dev->stats.txq_bytes[qi] = txq->stats.bytes; + dev->stats.txq_dropped[qi] = txq->stats.dropped; + dev->stats.txq_errors[qi] = txq->stats.errors; + dev->stats.txq_xoffs[qi] = txq->stats.xoffs; + } + + dev->stats.tx_packets = packets; + dev->stats.tx_bytes = bytes; + dev->stats.tx_dropped = dropped; + dev->stats.tx_errors = errors; + dev->stats.tx_xoffs = xoffs; +} + +/*! + * Reset device statistics + */ +static void +bcmcnet_pdma_stats_reset(struct pdma_dev *dev) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_rx_queue *rxq = NULL; + struct pdma_tx_queue *txq = NULL; + uint32_t qi; + + sal_memset(&dev->stats, 0, sizeof(struct bcmcnet_dev_stats)); + + for (qi = 0; qi < ctrl->nb_rxq; qi++) { + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[qi]; + if (!rxq) { + continue; + } + rxq->stats.packets = 0; + rxq->stats.bytes = 0; + rxq->stats.dropped = 0; + rxq->stats.errors = 0; + rxq->stats.head_errors = 0; + rxq->stats.data_errors = 0; + rxq->stats.cell_errors = 0; + rxq->stats.nomems = 0; + } + + for (qi = 0; qi < ctrl->nb_txq; qi++) { + txq = (struct pdma_tx_queue *)ctrl->tx_queue[qi]; + if (!txq) { + continue; + } + txq->stats.packets = 0; + txq->stats.bytes = 0; + txq->stats.dropped = 0; + txq->stats.errors = 0; + txq->stats.xoffs = 0; + } +} + +/*! + * Convert logic queue to physical queue + */ +static int +bcmcnet_pdma_lq_to_pq(struct pdma_dev *dev, int queue, int dir, int *chan) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_rx_queue *rxq = NULL; + struct pdma_tx_queue *txq = NULL; + + if (dir == PDMA_Q_RX) { + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; + if (rxq->state & PDMA_RX_QUEUE_USED) { + *chan = rxq->chan_id; + return SHR_E_NONE; + } + } else { + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + if (txq->state & PDMA_TX_QUEUE_USED) { + *chan = txq->chan_id; + return SHR_E_NONE; + } + } + + return SHR_E_UNAVAIL; +} + +/*! + * Convert physical queue to logic queue + */ +static int +bcmcnet_pdma_pq_to_lq(struct pdma_dev *dev, int chan, int *queue, int *dir) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_rx_queue *rxq = NULL; + struct pdma_tx_queue *txq = NULL; + + rxq = ctrl->grp[chan / dev->grp_queues].rx_queue[chan % dev->grp_queues]; + if (rxq->state & PDMA_RX_QUEUE_USED) { + *queue = rxq->queue_id; + *dir = PDMA_Q_RX; + return SHR_E_NONE; + } + + txq = ctrl->grp[chan / dev->grp_queues].tx_queue[chan % dev->grp_queues]; + if (txq->state & PDMA_TX_QUEUE_USED) { + *queue = txq->queue_id; + *dir = PDMA_Q_TX; + return SHR_E_NONE; + } + + return SHR_E_UNAVAIL; +} + +/*! + * Start Rx queue + */ +static int +bcmcnet_pdma_rx_queue_start(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_rx_queue *rxq = NULL; + + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; + rxq->state |= PDMA_RX_QUEUE_ACTIVE; + + return hw->hdls.chan_start(hw, rxq->chan_id); +} + +/*! + * Stop Rx queue + */ +static int +bcmcnet_pdma_rx_queue_stop(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_rx_queue *rxq = NULL; + + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; + rxq->state &= ~PDMA_RX_QUEUE_ACTIVE; + + return hw->hdls.chan_stop(hw, rxq->chan_id); +} + +/*! + * Start Tx queue + */ +static int +bcmcnet_pdma_tx_queue_start(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_tx_queue *txq = NULL; + + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + txq->state |= PDMA_TX_QUEUE_ACTIVE; + + return dev->flags & PDMA_CHAIN_MODE ? SHR_E_NONE : + hw->hdls.chan_start(hw, txq->chan_id); +} + +/*! + * Stop Tx queue + */ +static int +bcmcnet_pdma_tx_queue_stop(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_tx_queue *txq = NULL; + + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + txq->state &= ~PDMA_TX_QUEUE_ACTIVE; + + return hw->hdls.chan_stop(hw, txq->chan_id); +} + +/*! + * Enable Rx queue interrupt + */ +static int +bcmcnet_pdma_rx_queue_intr_enable(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_rx_queue *rxq = NULL; + + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; + + return hw->hdls.chan_intr_enable(hw, rxq->chan_id); +} + +/*! + * Disable Rx queue interrupt + */ +static int +bcmcnet_pdma_rx_queue_intr_disable(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_rx_queue *rxq = NULL; + + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; + + return hw->hdls.chan_intr_disable(hw, rxq->chan_id); +} + +/*! + * Acknowledge Rx queue interrupt + */ +static int +bcmcnet_pdma_rx_queue_intr_ack(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_rx_queue *rxq = NULL; + + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; + + return hw->hdls.chan_clear(hw, rxq->chan_id); +} + +/*! + * Query Rx queue interrupt + */ +static int +bcmcnet_pdma_rx_queue_intr_query(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_rx_queue *rxq = NULL; + + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; + + return hw->hdls.chan_intr_query(hw, rxq->chan_id); +} + +/*! + * Check Rx queue interrupt + */ +static int +bcmcnet_pdma_rx_queue_intr_check(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_rx_queue *rxq = NULL; + + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; + + return hw->hdls.chan_intr_check(hw, rxq->chan_id); +} + +/*! + * Enable Tx queue interrupt + */ +static int +bcmcnet_pdma_tx_queue_intr_enable(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_tx_queue *txq = NULL; + + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + + if (txq->state & PDMA_TX_QUEUE_POLL) { + return SHR_E_NONE; + } else { + return hw->hdls.chan_intr_enable(hw, txq->chan_id); + } +} + +/*! + * Disable Tx queue interrupt + */ +static int +bcmcnet_pdma_tx_queue_intr_disable(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_tx_queue *txq = NULL; + + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + + return hw->hdls.chan_intr_disable(hw, txq->chan_id); +} + +/*! + * Acknowledge Tx queue interrupt + */ +static int +bcmcnet_pdma_tx_queue_intr_ack(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_tx_queue *txq = NULL; + + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + + return hw->hdls.chan_clear(hw, txq->chan_id); +} + +/*! + * Query Tx queue interrupt + */ +static int +bcmcnet_pdma_tx_queue_intr_query(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_tx_queue *txq = NULL; + + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + + return hw->hdls.chan_intr_query(hw, txq->chan_id); +} + +/*! + * Check Tx queue interrupt + */ +static int +bcmcnet_pdma_tx_queue_intr_check(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_tx_queue *txq = NULL; + + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + + return hw->hdls.chan_intr_check(hw, txq->chan_id); +} + +/*! + * \brief Device operation functions. + */ +static const struct dev_ops pdma_dev_ops = { + .dev_config = bcmcnet_pdma_config, + .dev_close = bcmcnet_pdma_close, + .dev_suspend = bcmcnet_pdma_suspend, + .dev_resume = bcmcnet_pdma_resume, + .dev_info_get = bcmcnet_pdma_info_get, + .dev_stats_get = bcmcnet_pdma_stats_get, + .dev_stats_reset = bcmcnet_pdma_stats_reset, + .dev_lq_to_pq = bcmcnet_pdma_lq_to_pq, + .dev_pq_to_lq = bcmcnet_pdma_pq_to_lq, + .rx_queue_start = bcmcnet_pdma_rx_queue_start, + .rx_queue_stop = bcmcnet_pdma_rx_queue_stop, + .tx_queue_start = bcmcnet_pdma_tx_queue_start, + .tx_queue_stop = bcmcnet_pdma_tx_queue_stop, + .rx_queue_setup = bcmcnet_pdma_rx_queue_setup, + .rx_queue_release = bcmcnet_pdma_rx_queue_release, + .rx_queue_restore = bcmcnet_pdma_rx_queue_restore, + .rx_vqueue_setup = bcmcnet_pdma_rx_vqueue_setup, + .rx_vqueue_release = bcmcnet_pdma_rx_vqueue_release, + .tx_queue_setup = bcmcnet_pdma_tx_queue_setup, + .tx_queue_release = bcmcnet_pdma_tx_queue_release, + .tx_queue_restore = bcmcnet_pdma_tx_queue_restore, + .tx_vqueue_setup = bcmcnet_pdma_tx_vqueue_setup, + .tx_vqueue_release = bcmcnet_pdma_tx_vqueue_release, + .rx_queue_intr_enable = bcmcnet_pdma_rx_queue_intr_enable, + .rx_queue_intr_disable = bcmcnet_pdma_rx_queue_intr_disable, + .rx_queue_intr_ack = bcmcnet_pdma_rx_queue_intr_ack, + .rx_queue_intr_query = bcmcnet_pdma_rx_queue_intr_query, + .rx_queue_intr_check = bcmcnet_pdma_rx_queue_intr_check, + .tx_queue_intr_enable = bcmcnet_pdma_tx_queue_intr_enable, + .tx_queue_intr_disable = bcmcnet_pdma_tx_queue_intr_disable, + .tx_queue_intr_ack = bcmcnet_pdma_tx_queue_intr_ack, + .tx_queue_intr_query = bcmcnet_pdma_tx_queue_intr_query, + .tx_queue_intr_check = bcmcnet_pdma_tx_queue_intr_check, + .rx_queue_suspend = bcmcnet_pdma_rx_queue_suspend, + .rx_queue_resume = bcmcnet_pdma_rx_queue_resume, + .tx_queue_wakeup = bcmcnet_pdma_tx_queue_wakeup, + .rx_queue_poll = bcmcnet_pdma_rx_queue_poll, + .tx_queue_poll = bcmcnet_pdma_tx_queue_poll, + .group_poll = bcmcnet_pdma_group_poll, +}; + +/*! + * Open a device + */ +int +bcmcnet_pdma_open(struct pdma_dev *dev) +{ + struct pdma_hw *hw = (struct pdma_hw *)dev->ctrl.hw; + struct intr_handle *hdl = NULL; + int chan, gi, qi; + + if (!hw) { + return SHR_E_INIT; + } + + /* Initialize the hardware */ + hw->hdls.hw_reset(hw); + hw->hdls.hw_init(hw); + + if ((uint32_t)dev->num_groups > hw->info.num_cmcs) { + return SHR_E_PARAM; + } + dev->grp_queues = hw->info.cmc_chans; + dev->num_queues = hw->info.num_chans; + dev->rx_ph_size = hw->info.rx_ph_size; + dev->tx_ph_size = hw->info.tx_ph_size; + dev->ctrl.nb_desc = NUM_RING_DESC; + dev->ctrl.budget = NUM_RXTX_BUDGET; + dev->ctrl.rx_desc_size = hw->info.rx_dcb_size; + dev->ctrl.tx_desc_size = hw->info.tx_dcb_size; + + /* Initialize interrupt handler */ + for (chan = 0; chan < dev->num_queues; chan++) { + gi = chan / dev->grp_queues; + qi = chan % dev->grp_queues; + hdl = &dev->ctrl.grp[gi].intr_hdl[qi]; + hdl->unit = dev->unit; + hdl->group = gi; + hdl->chan = chan; + hdl->dev = dev; + hdl->intr_num = hw->hdls.chan_intr_num_get(hw, chan); + if (hdl->intr_num < 0) { + return SHR_E_INTERNAL; + } + } + + /* Initialize buffer manager */ + bcmcnet_buf_mngr_init(dev); + + /* Allocate all the queues */ + bcn_rx_queues_alloc(dev); + bcn_tx_queues_alloc(dev); + + dev->pkt_xmit = bcmcnet_pdma_tx_queue_xmit; + + dev->ops = (struct dev_ops *)&pdma_dev_ops; + + return SHR_E_NONE; +} + +/*! + * Coalesce Rx interrupt + */ +int +bcmcnet_pdma_rx_queue_int_coalesce(struct pdma_dev *dev, int queue, int count, int timer) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_rx_queue *rxq = NULL; + + if ((uint32_t)queue >= ctrl->nb_rxq) { + return SHR_E_PARAM; + } + + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; + rxq->intr_coalescing = 1; + rxq->ic_val = (count & 0x7fff) << 16 | (timer & 0xffff); + + return hw->hdls.chan_intr_coalesce(hw, rxq->chan_id, count, timer); +} + +/*! + * Coalesce Tx interrupt + */ +int +bcmcnet_pdma_tx_queue_int_coalesce(struct pdma_dev *dev, int queue, int count, int timer) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_tx_queue *txq = NULL; + + if ((uint32_t)queue >= ctrl->nb_txq) { + return SHR_E_PARAM; + } + + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + txq->intr_coalescing = 1; + txq->ic_val = (count & 0x7fff) << 16 | (timer & 0xffff); + + return hw->hdls.chan_intr_coalesce(hw, txq->chan_id, count, timer); +} + +/*! + * Dump Rx queue registers + */ +int +bcmcnet_pdma_rx_queue_reg_dump(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_rx_queue *rxq = NULL; + + if ((uint32_t)queue >= ctrl->nb_rxq) { + return SHR_E_PARAM; + } + + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; + + return hw->hdls.chan_reg_dump(hw, rxq->chan_id); +} + +/*! + * Dump Tx queue registers + */ +int +bcmcnet_pdma_tx_queue_reg_dump(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_tx_queue *txq = NULL; + + if ((uint32_t)queue >= ctrl->nb_txq) { + return SHR_E_PARAM; + } + + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + + return hw->hdls.chan_reg_dump(hw, txq->chan_id); +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_rxtx.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_rxtx.c new file mode 100644 index 000000000000..cfabe9d95d56 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_rxtx.c @@ -0,0 +1,708 @@ +/*! \file bcmcnet_rxtx.c + * + * Utility routines for BCMCNET Rx/Tx. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include +#include + +/*! + * Free a Rx ring + */ +static void +bcn_rx_ring_free(struct pdma_rx_queue *rxq) +{ + struct dev_ctrl *ctrl = rxq->ctrl; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)ctrl->buf_mngr; + + if (rxq->lock) { + sal_spinlock_destroy(rxq->lock); + rxq->lock = NULL; + } + + if (rxq->ring) { + bm->ring_buf_free(ctrl->dev, ctrl->rx_desc_size * (rxq->nb_desc + 1), + rxq->ring, rxq->ring_addr); + rxq->ring = NULL; + } + + if (rxq->pbuf) { + sal_free(rxq->pbuf); + rxq->pbuf = NULL; + } +} + +/*! + * Allocate a Rx ring + */ +static int +bcn_rx_ring_alloc(struct pdma_rx_queue *rxq) +{ + struct dev_ctrl *ctrl = rxq->ctrl; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)ctrl->buf_mngr; + + /* Setup pktbuf ring */ + rxq->pbuf = sal_alloc(sizeof(*rxq->pbuf) * rxq->nb_desc, "bcmcnetRxBufRing"); + if (!rxq->pbuf) { + goto cleanup; + } + sal_memset(rxq->pbuf, 0, sizeof(*rxq->pbuf) * rxq->nb_desc); + + /* Allocate memory for descriptors */ + rxq->ring = bm->ring_buf_alloc(ctrl->dev, ctrl->rx_desc_size * (rxq->nb_desc + 1), + &rxq->ring_addr); + if (!rxq->ring) { + goto cleanup; + } + sal_memset(rxq->ring, 0, ctrl->rx_desc_size * (rxq->nb_desc + 1)); + + rxq->lock = sal_spinlock_create("bcmcnetRxQueueLock"); + if (!rxq->lock) { + goto cleanup; + } + + return SHR_E_NONE; + +cleanup: + bcn_rx_ring_free(rxq); + + return SHR_E_MEMORY; +} + +/*! + * Free a Tx ring + */ +static void +bcn_tx_ring_free(struct pdma_tx_queue *txq) +{ + struct dev_ctrl *ctrl = txq->ctrl; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)ctrl->buf_mngr; + + if (txq->sem) { + sal_sem_destroy(txq->sem); + txq->sem = NULL; + } + + if (txq->mutex) { + sal_spinlock_destroy(txq->mutex); + txq->mutex = NULL; + } + + if (txq->lock) { + sal_spinlock_destroy(txq->lock); + txq->lock = NULL; + } + + if (txq->ring) { + bm->ring_buf_free(ctrl->dev, ctrl->tx_desc_size * (txq->nb_desc + 1), + txq->ring, txq->ring_addr); + txq->ring = NULL; + } + + if (txq->pbuf) { + sal_free(txq->pbuf); + txq->pbuf = NULL; + } +} + +/*! + * Allocate a Tx ring + */ +static int +bcn_tx_ring_alloc(struct pdma_tx_queue *txq) +{ + struct dev_ctrl *ctrl = txq->ctrl; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)ctrl->buf_mngr; + + /* Setup pktbuf ring */ + txq->pbuf = sal_alloc(sizeof(*txq->pbuf) * txq->nb_desc, "bcmcnetTxBufRing"); + if (!txq->pbuf) { + goto cleanup; + } + sal_memset(txq->pbuf, 0, sizeof(*txq->pbuf) * txq->nb_desc); + + /* Allocate memory for descriptors */ + txq->ring = bm->ring_buf_alloc(ctrl->dev, ctrl->tx_desc_size * (txq->nb_desc + 1), + &txq->ring_addr); + if (!txq->ring) { + goto cleanup; + } + sal_memset(txq->ring, 0, ctrl->tx_desc_size * (txq->nb_desc + 1)); + + txq->lock = sal_spinlock_create("bcmcnetTxQueueLock"); + if (!txq->lock) { + goto cleanup; + } + + txq->mutex = sal_spinlock_create("bcmcnetTxMutexLock"); + if (!txq->mutex) { + goto cleanup; + } + + txq->sem = sal_sem_create("bcmcnetTxMutexSem", SAL_SEM_BINARY, 0); + if (!txq->sem) { + goto cleanup; + } + + return SHR_E_NONE; + +cleanup: + bcn_tx_ring_free(txq); + + return SHR_E_MEMORY; +} + +/*! + * Rx polling + */ +static int +bcn_rx_poll(struct pdma_rx_queue *rxq, int budget) +{ + struct dev_ctrl *ctrl = rxq->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + + return hw->dops.rx_ring_clean(hw, rxq, budget); +} + +/*! + * Tx polling + */ +static int +bcn_tx_poll(struct pdma_tx_queue *txq, int budget) +{ + struct dev_ctrl *ctrl = txq->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + + return hw->dops.tx_ring_clean(hw, txq, budget); +} + +/*! + * Setup a Rx queue + */ +int +bcmcnet_pdma_rx_queue_setup(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_rx_queue *rxq = NULL; + int rv; + + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; + if (rxq->state & PDMA_RX_QUEUE_SETUP) { + return SHR_E_NONE; + } + + rv = bcn_rx_ring_alloc(rxq); + if (SHR_FAILURE(rv)) { + return rv; + } + + rv = hw->dops.rx_desc_init(hw, rxq); + if (SHR_FAILURE(rv)) { + return rv; + } + + if (dev->mode == DEV_MODE_VNET) { + ctrl->vsync.rx_ring_addr[queue] = rxq->ring_addr; + ctrl->vsync.rx_ring_size[queue] = rxq->nb_desc; + } + + rxq->state |= PDMA_RX_QUEUE_SETUP; + + return SHR_E_NONE; +} + +/*! + * Release a Rx queue + */ +int +bcmcnet_pdma_rx_queue_release(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_rx_queue *rxq = NULL; + + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; + if (rxq->state & PDMA_RX_QUEUE_SETUP) { + hw->dops.rx_desc_clean(hw, rxq); + bcn_rx_ring_free(rxq); + rxq->state &= ~PDMA_RX_QUEUE_SETUP; + } + + return SHR_E_NONE; +} + +/*! + * Restore a Rx queue + */ +int +bcmcnet_pdma_rx_queue_restore(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_rx_queue *rxq = NULL; + + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; + if (rxq->state & PDMA_RX_QUEUE_SETUP) { + hw->dops.rx_desc_init(hw, rxq); + } + + return SHR_E_NONE; +} + +/*! + * Set up a virtual Rx queue + */ +int +bcmcnet_pdma_rx_vqueue_setup(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_rx_queue *vrxq = NULL; + + vrxq = (struct pdma_rx_queue *)ctrl->vnet_rxq[queue]; + if (vrxq->state & PDMA_RX_QUEUE_SETUP) { + return SHR_E_NONE; + } + + if (dev->ctrl.vsync.rx_ring_addr[queue]) { + vrxq->curr = 0; + vrxq->nb_desc = dev->ctrl.vsync.rx_ring_size[queue]; + vrxq->ring_addr = dev->ctrl.vsync.rx_ring_addr[queue]; + vrxq->ring = dev->sys_p2v(dev, vrxq->ring_addr); + vrxq->state |= PDMA_RX_QUEUE_SETUP; + } else { + return SHR_E_UNAVAIL; + } + + return SHR_E_NONE; +} + +/*! + * Release a virtual Rx queue + */ +int +bcmcnet_pdma_rx_vqueue_release(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_rx_queue *vrxq = NULL; + + vrxq = (struct pdma_rx_queue *)ctrl->vnet_rxq[queue]; + if (vrxq->state & PDMA_RX_QUEUE_SETUP) { + vrxq->state &= ~PDMA_RX_QUEUE_SETUP; + vrxq->ring = NULL; + } + + return SHR_E_NONE; +} + +/*! + * Setup a Tx queue + */ +int +bcmcnet_pdma_tx_queue_setup(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_tx_queue *txq = NULL; + int rv; + + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + if (txq->state & PDMA_TX_QUEUE_SETUP) { + return SHR_E_NONE; + } + + rv = bcn_tx_ring_alloc(txq); + if (SHR_FAILURE(rv)) { + return rv; + } + + rv = hw->dops.tx_desc_init(hw, txq); + if (SHR_FAILURE(rv)) { + return rv; + } + + if (dev->mode == DEV_MODE_VNET) { + ctrl->vsync.tx_ring_addr[queue] = txq->ring_addr; + ctrl->vsync.tx_ring_size[queue] = txq->nb_desc; + } + + txq->state |= PDMA_TX_QUEUE_SETUP; + + return SHR_E_NONE; +} + +/*! + * Release a Tx queue + */ +int +bcmcnet_pdma_tx_queue_release(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_tx_queue *txq = NULL; + + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + if (txq->state & PDMA_TX_QUEUE_SETUP) { + hw->dops.tx_desc_clean(hw, txq); + bcn_tx_ring_free(txq); + txq->state &= ~PDMA_TX_QUEUE_SETUP; + } + + return SHR_E_NONE; +} + +/*! + * Restore a Tx queue + */ +int +bcmcnet_pdma_tx_queue_restore(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_tx_queue *txq = NULL; + + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + if (txq->state & PDMA_TX_QUEUE_SETUP) { + hw->dops.tx_desc_init(hw, txq); + } + + return SHR_E_NONE; +} + +/*! + * Set up a virtual Tx queue + */ +int +bcmcnet_pdma_tx_vqueue_setup(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_tx_queue *vtxq = NULL; + + vtxq = (struct pdma_tx_queue *)ctrl->vnet_txq[queue]; + if (vtxq->state & PDMA_TX_QUEUE_SETUP) { + return SHR_E_NONE; + } + + if (dev->ctrl.vsync.tx_ring_addr[queue]) { + vtxq->curr = 0; + vtxq->dirt = 0; + vtxq->nb_desc = dev->ctrl.vsync.tx_ring_size[queue]; + vtxq->ring_addr = dev->ctrl.vsync.tx_ring_addr[queue]; + vtxq->ring = dev->sys_p2v(dev, vtxq->ring_addr); + vtxq->state |= PDMA_TX_QUEUE_SETUP; + } else { + return SHR_E_UNAVAIL; + } + + return SHR_E_NONE; +} + +/*! + * Release a virtual Tx queue + */ +int +bcmcnet_pdma_tx_vqueue_release(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_tx_queue *vtxq = NULL; + + vtxq = (struct pdma_tx_queue *)ctrl->vnet_txq[queue]; + if (vtxq->state & PDMA_TX_QUEUE_SETUP) { + vtxq->state &= ~PDMA_TX_QUEUE_SETUP; + vtxq->ring = NULL; + } + + return SHR_E_NONE; +} + +/*! + * Suspend a Rx queue + */ +int +bcmcnet_pdma_rx_queue_suspend(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_rx_queue *rxq = NULL; + + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; + if (!rxq || !(rxq->state & PDMA_RX_QUEUE_ACTIVE)) { + return SHR_E_UNAVAIL; + } + + return hw->dops.rx_suspend(hw, rxq); +} + +/*! + * Resume a Rx queue + */ +int +bcmcnet_pdma_rx_queue_resume(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_rx_queue *rxq = NULL; + + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; + if (!rxq || !(rxq->state & PDMA_RX_QUEUE_ACTIVE)) { + return SHR_E_UNAVAIL; + } + + return hw->dops.rx_resume(hw, rxq); +} + +/*! + * Suspend a Tx queue + */ +int +bcmcnet_pdma_tx_queue_suspend(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_tx_queue *txq = NULL; + + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + if (!txq || !(txq->state & PDMA_TX_QUEUE_ACTIVE)) { + return SHR_E_UNAVAIL; + } + + if (txq->sem) { + sal_sem_take(txq->sem, SAL_SEM_FOREVER); + } + if (dev->tx_suspend) { + dev->tx_suspend(dev, txq->queue_id); + } + + return SHR_E_NONE; +} + +/*! + * Resume a Tx queue + */ +int +bcmcnet_pdma_tx_queue_resume(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_tx_queue *txq = NULL; + + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + if (!txq || !(txq->state & PDMA_TX_QUEUE_ACTIVE)) { + return SHR_E_UNAVAIL; + } + + if (txq->sem) { + sal_sem_give(txq->sem); + } + if (dev->tx_resume) { + dev->tx_resume(dev, txq->queue_id); + } + + return SHR_E_NONE; +} + +/*! + * Wake up a Tx queue + */ +int +bcmcnet_pdma_tx_queue_wakeup(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_tx_queue *txq = NULL; + + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + if (txq->sem) { + sal_sem_give(txq->sem); + } + + return SHR_E_NONE; +} + +/*! + * Transmit a outputing packet + */ +int +bcmcnet_pdma_tx_queue_xmit(struct pdma_dev *dev, int queue, void *buf) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_tx_queue *txq = NULL; + + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + if (!txq || !(txq->state & PDMA_TX_QUEUE_ACTIVE)) { + return SHR_E_UNAVAIL; + } + + return hw->dops.pkt_xmit(hw, txq, buf); +} + +/*! + * Poll a Rx queues + */ +int +bcmcnet_pdma_rx_queue_poll(struct pdma_dev *dev, int queue, int budget) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_rx_queue *rxq = ctrl->rx_queue[queue]; + + return bcn_rx_poll(rxq, budget); +} + +/*! + * Poll a Tx queues + */ +int +bcmcnet_pdma_tx_queue_poll(struct pdma_dev *dev, int queue, int budget) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_tx_queue *txq = ctrl->tx_queue[queue]; + + return bcn_tx_poll(txq, budget); +} + +/*! + * Poll for Rx/Tx queues in a group + */ +int +bcmcnet_pdma_group_poll(struct pdma_dev *dev, int group, int budget) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = (struct pdma_hw *)ctrl->hw; + struct pdma_rx_queue *rxq = NULL; + struct pdma_tx_queue *txq = NULL; + struct queue_group *grp = &ctrl->grp[group]; + int done = 0, done_que, budget_que; + int i; + + /* Acknowledge the interrupts */ + for (i = 0; i < dev->grp_queues; i++) { + rxq = grp->rx_queue[i]; + if (rxq->state & PDMA_RX_QUEUE_ACTIVE) { + if (hw->hdls.chan_intr_query(hw, rxq->chan_id)) { + hw->hdls.chan_clear(hw, rxq->chan_id); + grp->poll_queues |= 1 << i; + } else if (rxq->state & PDMA_RX_QUEUE_BUSY) { + rxq->state &= ~PDMA_RX_QUEUE_BUSY; + grp->poll_queues |= 1 << i; + } + continue; + } + txq = grp->tx_queue[i]; + if (txq->state & PDMA_TX_QUEUE_ACTIVE) { + if (hw->hdls.chan_intr_query(hw, txq->chan_id)) { + hw->hdls.chan_clear(hw, txq->chan_id); + grp->poll_queues |= 1 << i; + } + } + } + + /* Calculate per queue budget */ + if (!grp->poll_queues) { + grp->poll_queues = grp->bm_rxq | grp->bm_txq; + budget_que = budget / grp->nb_rxq; + } else { + budget_que = 0; + for (i = 0; i < dev->grp_queues; i++) { + if (1 << i & grp->bm_rxq & grp->poll_queues) { + budget_que++; + } + } + if (budget_que) { + budget_que = budget / budget_que; + } + } + + /* Poll Rx queues */ + for (i = 0; i < dev->grp_queues; i++) { + if (1 << i & grp->bm_rxq & grp->poll_queues) { + rxq = grp->rx_queue[i]; + done_que = bcn_rx_poll(rxq, budget_que); + if (done_que < budget_que) { + grp->poll_queues &= ~(1 << i); + } + done += done_que; + } + } + + /* Poll Tx queues */ + for (i = 0; i < dev->grp_queues; i++) { + txq = grp->tx_queue[i]; + if (1 << i & grp->bm_txq & grp->poll_queues && !txq->free_thresh) { + if (bcn_tx_poll(txq, budget) < budget) { + grp->poll_queues &= ~(1 << i); + } + } + } + + return grp->poll_queues ? budget : done; +} + +/*! + * Dump a Rx ring + */ +int +bcmcnet_pdma_rx_ring_dump(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = ctrl->hw; + struct pdma_rx_queue *rxq = NULL; + + if ((uint32_t)queue >= ctrl->nb_rxq) { + return SHR_E_PARAM; + } + + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; + if (rxq->state & PDMA_RX_QUEUE_ACTIVE) { + hw->dops.rx_ring_dump(hw, rxq); + } + if (dev->mode == DEV_MODE_HNET) { + rxq = (struct pdma_rx_queue *)ctrl->vnet_rxq[queue]; + hw->dops.rx_ring_dump(hw, rxq); + } + + return SHR_E_NONE; +} + +/*! + * Dump a Tx ring + */ +int +bcmcnet_pdma_tx_ring_dump(struct pdma_dev *dev, int queue) +{ + struct dev_ctrl *ctrl = &dev->ctrl; + struct pdma_hw *hw = ctrl->hw; + struct pdma_tx_queue *txq = NULL; + + if ((uint32_t)queue >= ctrl->nb_txq) { + return SHR_E_PARAM; + } + + txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; + if (txq->state & PDMA_TX_QUEUE_ACTIVE) { + hw->dops.tx_ring_dump(hw, txq); + } + if (dev->mode == DEV_MODE_HNET) { + txq = (struct pdma_tx_queue *)ctrl->vnet_txq[queue]; + hw->dops.tx_ring_dump(hw, txq); + } + + return SHR_E_NONE; +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd/bcmdrd_devlist.h b/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd/bcmdrd_devlist.h new file mode 100644 index 000000000000..675b9426ea01 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd/bcmdrd_devlist.h @@ -0,0 +1,337 @@ +/* + * DO NOT EDIT THIS FILE! + * This file is auto-generated. + * Edits to this file will be lost when it is regenerated. + * Tool: INTERNAL/drd/instpkgs.pl + * + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +/* + * This file contains the complete list of supported devices. + * No other device lists should be used anywhere in the SDK. + */ + +#ifndef BCMDRD_DEVIDS_H +#define BCMDRD_DEVIDS_H + +#include + +/* + * All Supported Devices and Revisions + */ + +#define BROADCOM_VENDOR_ID 0x14e4 +#define BROADCOM_PHYID_MSB 0x0143 + +/* BCM56780 */ +#define BCM56780_VENDOR_ID 0x14e4 +#define BCM56780_DEVICE_ID 0xb780 +#define BCM56780_REV_A0 0x01 + +/* BCM56782 */ +#define BCM56782_VENDOR_ID 0x14e4 +#define BCM56782_DEVICE_ID 0xb782 +#define BCM56782_REV_A0 0x01 + +/* BCM56784 */ +#define BCM56784_VENDOR_ID 0x14e4 +#define BCM56784_DEVICE_ID 0xb784 +#define BCM56784_REV_A0 0x01 + +/* BCM56786 */ +#define BCM56786_VENDOR_ID 0x14e4 +#define BCM56786_DEVICE_ID 0xb786 +#define BCM56786_REV_A0 0x01 + +/* BCM56788 */ +#define BCM56788_VENDOR_ID 0x14e4 +#define BCM56788_DEVICE_ID 0xb788 +#define BCM56788_REV_A0 0x01 + +/* BCM56789 */ +#define BCM56789_VENDOR_ID 0x14e4 +#define BCM56789_DEVICE_ID 0xb789 +#define BCM56789_REV_A0 0x01 + +/* BCM56880 */ +#define BCM56880_VENDOR_ID 0x14e4 +#define BCM56880_DEVICE_ID 0xb880 +#define BCM56880_REV_A0 0x01 +#define BCM56880_REV_B0 0x11 + +/* BCM56881 */ +#define BCM56881_VENDOR_ID 0x14e4 +#define BCM56881_DEVICE_ID 0xb881 +#define BCM56881_REV_A0 0x01 +#define BCM56881_REV_B0 0x11 + +/* BCM56883 */ +#define BCM56883_VENDOR_ID 0x14e4 +#define BCM56883_DEVICE_ID 0xb883 +#define BCM56883_REV_A0 0x01 +#define BCM56883_REV_B0 0x11 + +/* BCM56889 */ +#define BCM56889_VENDOR_ID 0x14e4 +#define BCM56889_DEVICE_ID 0xb889 +#define BCM56889_REV_A0 0x01 +#define BCM56889_REV_B0 0x11 + +/* BCM56990 */ +#define BCM56990_VENDOR_ID 0x14e4 +#define BCM56990_DEVICE_ID 0xb990 +#define BCM56990_REV_A0 0x01 +#define BCM56990_REV_B0 0x11 + +/* BCM56992 */ +#define BCM56992_VENDOR_ID 0x14e4 +#define BCM56992_DEVICE_ID 0xb992 +#define BCM56992_REV_B0 0x11 + +/* BCM56996 */ +#define BCM56996_VENDOR_ID 0x14e4 +#define BCM56996_DEVICE_ID 0xb996 +#define BCM56996_REV_A0 0x01 + +/* BCM56997 */ +#define BCM56997_VENDOR_ID 0x14e4 +#define BCM56997_DEVICE_ID 0xb997 +#define BCM56997_REV_A0 0x01 + +/* + * End of Supported Devices and Revisions + */ + +#endif /* BCMDRD_DEVIDS_H */ + +#ifdef BCMDRD_DEVLIST_ENTRY +/* + * BCMDRD_DEVLIST_ENTRY macros. + * + * Before including this file, define BCMDRD_DEVLIST_ENTRY + * as a macro to operate on the following parameters: + * + * #define BCMDRD_DEVLIST_ENTRY(_nm,_vn,_dv,_rv,_md,_pi,_bd,_bc,_fn,_cn,_pf,_pd,_r0,_r1) + * + * _nm: Chip Name + * _vn: Chip Vendor ID + * _dv: Chip Device ID + * _rv: Chip Revision + * _md: Chip Model + * _pi: Probe Information + * _bd: SW Base Driver + * _bc: SW Base Configuration + * _fn: SW Full Name + * _cn: Code Name + * _pf: Product Family + * _pd: Product Description + * _r0: Reserved + * _r1: Reserved + * + * Note that this macro will be undefined at the end of this file. + */ + +#if BCMDRD_CONFIG_INCLUDE_BCM56780_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +BCMDRD_DEVLIST_ENTRY(BCM56780, BCM56780_VENDOR_ID, BCM56780_DEVICE_ID, BCM56780_REV_A0, \ + 0, 0, \ + bcm56780_a0, bcm56780_a0, bcm56780_a0, \ + "Trident4-X9", "BCM56780", \ + "8 Tb/s 160x50G-PAM4 Programmable Switch", 0, 0) +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56782_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56782, BCM56782_VENDOR_ID, BCM56782_DEVICE_ID, BCM56782_REV_A0, \ + 0, 0, \ + bcm56780_a0, bcm56782_a0, bcm56782_a0, \ + "Trident4-X9", "BCM56780", \ + "8 Tb/s 160x50G-PAM4 Programmable Switch w/MACsec", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56784_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56784, BCM56784_VENDOR_ID, BCM56784_DEVICE_ID, BCM56784_REV_A0, \ + 0, 0, \ + bcm56780_a0, bcm56784_a0, bcm56784_a0, \ + "Trident4-X9", "BCM56780", \ + "5.6 Tb/s 96x50G-PAM4/32x35G-NRZ Programmable Switch", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56786_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56786, BCM56786_VENDOR_ID, BCM56786_DEVICE_ID, BCM56786_REV_A0, \ + 0, 0, \ + bcm56780_a0, bcm56786_a0, bcm56786_a0, \ + "Trident4-X9", "BCM56780", \ + "5.6 Tb/s 96x50G-PAM4/32x35G-NRZ Programmable Switch w/MACsec", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56788_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56788, BCM56788_VENDOR_ID, BCM56788_DEVICE_ID, BCM56788_REV_A0, \ + 0, 0, \ + bcm56780_a0, bcm56788_a0, bcm56788_a0, \ + "Trident4-X9", "BCM56780", \ + "8 Tb/s 160x50G-PAM4 Programmable Switch w/MACsec w/MTop", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56789_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56789, BCM56789_VENDOR_ID, BCM56789_DEVICE_ID, BCM56789_REV_A0, \ + 0, 0, \ + bcm56780_a0, bcm56789_a0, bcm56789_a0, \ + "Trident4-X9", "BCM56780", \ + "8 Tb/s 160x50G-PAM4 Programmable Switch w/MTop", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56880_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +BCMDRD_DEVLIST_ENTRY(BCM56880, BCM56880_VENDOR_ID, BCM56880_DEVICE_ID, BCM56880_REV_A0, \ + 0, 0, \ + bcm56880_a0, bcm56880_a0, bcm56880_a0, \ + "Trident4", "BCM56880", \ + "12.8 Tb/s Switch Fabric 128x100G/64x200G/32x400G Multilayer Switch", 0, 0) +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56880_B0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56880, BCM56880_VENDOR_ID, BCM56880_DEVICE_ID, BCM56880_REV_B0, \ + 0, 0, \ + bcm56880_a0, bcm56880_a0, bcm56880_b0, \ + "Trident4", "BCM56880", \ + "12.8 Tb/s Switch Fabric 128x100G/64x200G/32x400G Multilayer Switch", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56881_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56881, BCM56881_VENDOR_ID, BCM56881_DEVICE_ID, BCM56881_REV_A0, \ + 0, 0, \ + bcm56880_a0, bcm56881_a0, bcm56881_a0, \ + "Trident4", "BCM56880", \ + "12.8 Tb/s Switch Fabric 128x100G/64x200G/32x400G Multilayer Switch", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56881_B0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56881, BCM56881_VENDOR_ID, BCM56881_DEVICE_ID, BCM56881_REV_B0, \ + 0, 0, \ + bcm56880_a0, bcm56881_a0, bcm56881_b0, \ + "Trident4", "BCM56880", \ + "12.8 Tb/s Switch Fabric 128x100G/64x200G/32x400G Multilayer Switch", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56883_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56883, BCM56883_VENDOR_ID, BCM56883_DEVICE_ID, BCM56883_REV_A0, \ + 0, 0, \ + bcm56880_a0, bcm56883_a0, bcm56883_a0, \ + "Trident4", "BCM56880", \ + "8.0 Tb/s Switch Fabric 80x100G/40x200G/20x400G Multilayer Switch", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56883_B0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56883, BCM56883_VENDOR_ID, BCM56883_DEVICE_ID, BCM56883_REV_B0, \ + 0, 0, \ + bcm56880_a0, bcm56883_a0, bcm56883_b0, \ + "Trident4", "BCM56880", \ + "8.0 Tb/s Switch Fabric 80x100G/40x200G/20x400G Multilayer Switch", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56889_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56889, BCM56889_VENDOR_ID, BCM56889_DEVICE_ID, BCM56889_REV_A0, \ + 0, 0, \ + bcm56880_a0, bcm56889_a0, bcm56889_a0, \ + "Trident4", "BCM56880", \ + "12.8 Tb/s Switch Fabric 128x100G/64x200G/32x400G Multilayer Switch", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56889_B0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56889, BCM56889_VENDOR_ID, BCM56889_DEVICE_ID, BCM56889_REV_B0, \ + 0, 0, \ + bcm56880_a0, bcm56889_a0, bcm56889_b0, \ + "Trident4", "BCM56880", \ + "12.8 Tb/s Switch Fabric 128x100G/64x200G/32x400G Multilayer Switch", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56990_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +BCMDRD_DEVLIST_ENTRY(BCM56990, BCM56990_VENDOR_ID, BCM56990_DEVICE_ID, BCM56990_REV_A0, \ + 0, 0, \ + bcm56990_a0, bcm56990_a0, bcm56990_a0, \ + "Tomahawk4", "BCM56990", \ + "25.6 Tbps Multilayer Switch", 0, 0) +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56990_B0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +BCMDRD_DEVLIST_ENTRY(BCM56990, BCM56990_VENDOR_ID, BCM56990_DEVICE_ID, BCM56990_REV_B0, \ + 0, 0, \ + bcm56990_b0, bcm56990_b0, bcm56990_b0, \ + "Tomahawk4", "BCM56990", \ + "25.6 Tbps Multilayer Switch", 0, 0) +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56992_B0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56992, BCM56992_VENDOR_ID, BCM56992_DEVICE_ID, BCM56992_REV_B0, \ + 0, 0, \ + bcm56990_b0, bcm56992_b0, bcm56992_b0, \ + "Tomahawk4", "BCM56990", \ + "25.6 Tbps Multilayer Switch", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56996_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +BCMDRD_DEVLIST_ENTRY(BCM56996, BCM56996_VENDOR_ID, BCM56996_DEVICE_ID, BCM56996_REV_A0, \ + 0, 0, \ + bcm56996_a0, bcm56996_a0, bcm56996_a0, \ + "Tomahawk4G", "BCM56996", \ + "25.6 Tbps Multilayer Switch", 0, 0) +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56997_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56997, BCM56997_VENDOR_ID, BCM56997_DEVICE_ID, BCM56997_REV_A0, \ + 0, 0, \ + bcm56996_a0, bcm56997_a0, bcm56997_a0, \ + "Tomahawk4G", "BCM56996", \ + "12.8 Tbps Multilayer Switch", 0, 0) +#endif +#endif + +/* End BCMDRD_DEVLIST_ENTRY Macros */ + +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +#undef BCMDRD_DEVLIST_INCLUDE_ALL +#endif +#ifdef BCMDRD_DEVLIST_OVERRIDE +#undef BCMDRD_DEVLIST_OVERRIDE +#endif +#undef BCMDRD_DEVLIST_ENTRY +#endif /* BCMDRD_DEVLIST_ENTRY */ diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd_config.h b/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd_config.h new file mode 100644 index 000000000000..68e5a0891098 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd_config.h @@ -0,0 +1,166 @@ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + * DO NOT EDIT THIS FILE! + * This file will be auto-generated in the near future. + * + * This config file defines all compilation-time specifications for + * the BCMDRD. + * + * Reasonable defaults are provided for all configuration options + * where appropriate. + * + * You need not edit this file directly to change your configuration, + * nor is modifying this file advised -- so doing will require + * manually merging whenever the BCMDRD is upgraded. + * + * You should provide your own configuration options or overrides + * through a combination of: + * + * 1. The compiler command line, such as -D{OPTION}={VALUE} + * + * 2. Create your own custom configuration file: + * a) Create a file called 'bcmdrd_custom_config.h' + * b) Define all custom settings, using this file as + * the reference + * c) Add -DBCMDRD_INCLUDE_CUSTOM_CONFIG to your + * compilation + * d) Make sure the compilation include path includes + * 'bcmdrd_custom_config.h' + * + */ + +#ifndef BCMDRD_CONFIG_H +#define BCMDRD_CONFIG_H + + +/* + * Include system config file if specified: + */ +#ifdef BCMDRD_INCLUDE_CUSTOM_CONFIG +#include +#endif + + +/* + * OPTIONAL configuration and feature values. + * Defaults are provided for all non-specified values. + */ + +/* Maximum number of chips supported */ +#ifndef BCMDRD_CONFIG_MAX_UNITS +#define BCMDRD_CONFIG_MAX_UNITS 8 +#endif + +/* Maximum number of ports per chip supported */ +#ifndef BCMDRD_CONFIG_MAX_PORTS +#define BCMDRD_CONFIG_MAX_PORTS 576 +#endif + +/* Maximum number of SCHAN polls */ +#ifndef BCMDRD_CONFIG_SCHAN_MAX_POLLS +#define BCMDRD_CONFIG_SCHAN_MAX_POLLS 100000 +#endif + +/* Maximum number of MIIM polls */ +#ifndef BCMDRD_CONFIG_MIIM_MAX_POLLS +#define BCMDRD_CONFIG_MIIM_MAX_POLLS 100000 +#endif + +/* Direct access to memory-mapped registers */ +#ifndef BCMDRD_CONFIG_MEMMAP_DIRECT +#define BCMDRD_CONFIG_MEMMAP_DIRECT 0 +#endif + +/* + * Include chip symbol tables for the debug shell. + * + * No symbolic debugging (register/memory names) will be available + * without this defined. + * + * You should enable at least these symbols if you can afford the + * space. + * + * This define is required to get any symbols at all. + * + * If you only wish to include symbols for a subset of chips in the + * system (probably for code space reasons), you can define the + * following for each chip whose symbols you wish to EXCLUDE: + * + * BCMDRD_CONFIG_EXCLUDE_CHIP_SYMBOLS_ + * + */ +#ifndef BCMDRD_CONFIG_INCLUDE_CHIP_SYMBOLS +#define BCMDRD_CONFIG_INCLUDE_CHIP_SYMBOLS 1 +#endif + +/* + * Include register and memory field information for the debug shell. + * + * This provides encoding, decoding, and displaying individual field + * values for each register and memory. + * + * Requires more code space than just the chip symbols alone. + * + * The per-chip exclusion define + * (BCMDRD_CONFIG_EXCLUDE_FIELD_INFO_) also applies. + */ +#ifndef BCMDRD_CONFIG_INCLUDE_FIELD_INFO +#define BCMDRD_CONFIG_INCLUDE_FIELD_INFO 1 +#endif + +/* + * Include alternative symbol names for registers and memories. + * + * Mainly for internal Broadcom use, so you can safely leave this + * option off. + */ +#ifndef BCMDRD_CONFIG_INCLUDE_ALIAS_NAMES +#define BCMDRD_CONFIG_INCLUDE_ALIAS_NAMES 1 +#endif + +#endif /* BCMDRD_CONFIG_H */ + +#ifdef CONFIG_OPTION +#ifdef BCMDRD_INCLUDE_CUSTOM_CONFIG +CONFIG_OPTION(BCMDRD_INCLUDE_CUSTOM_CONFIG) +#endif +#ifdef BCMDRD_CONFIG_MAX_UNITS +CONFIG_OPTION(BCMDRD_CONFIG_MAX_UNITS) +#endif +#ifdef BCMDRD_CONFIG_MAX_PORTS +CONFIG_OPTION(BCMDRD_CONFIG_MAX_PORTS) +#endif +#ifdef BCMDRD_CONFIG_SCHAN_MAX_POLLS +CONFIG_OPTION(BCMDRD_CONFIG_SCHAN_MAX_POLLS) +#endif +#ifdef BCMDRD_CONFIG_MIIM_MAX_POLLS +CONFIG_OPTION(BCMDRD_CONFIG_MIIM_MAX_POLLS) +#endif +#ifdef BCMDRD_CONFIG_MEMMAP_DIRECT +CONFIG_OPTION(BCMDRD_CONFIG_MEMMAP_DIRECT) +#endif +#ifdef BCMDRD_CONFIG_INCLUDE_CHIP_SYMBOLS +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_CHIP_SYMBOLS) +#endif +#ifdef BCMDRD_CONFIG_INCLUDE_FIELD_INFO +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_FIELD_INFO) +#endif +#ifdef BCMDRD_CONFIG_INCLUDE_ALIAS_NAMES +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_ALIAS_NAMES) +#endif +#endif /* CONFIG_OPTION */ +#include "bcmdrd_config_chips.h" diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd_config_chips.h b/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd_config_chips.h new file mode 100644 index 000000000000..5b45879c90e9 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd_config_chips.h @@ -0,0 +1,545 @@ +/* + * DO NOT EDIT THIS FILE! + * This file is auto-generated. + * Edits to this file will be lost when it is regenerated. + * Tool: INTERNAL/drd/instpkgs.pl + * + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +/* + * Chip inclusion and exclusion support within the BCMDRD can be + * specified as a combination of the following defines: + * + * (1) #define BCMDRD_CONFIG_INCLUDE_ [1|0] + * -- Include or exclude all revisions of the given device + * Example: #define BCMDRD_CONFIG_INCLUDE_BCM56780 1 + * + * (2) #define BCMDRD_CONFIG_INCLUDE__X [1|0] + * -- Include or exclude all versions of the given revision + * Example: #define BCMDRD_CONFIG_INCLUDE_BCM56780_Ax 0 + * #define BCMDRD_CONFIG_INCLUde_BCM56780_Bx 1 + * + * (3) #define BCMDRD_CONFIG_INCLUDE_ [1|0] + * -- Include or exclude an exact device + * Example: #define BCMDRD_CONFIG_INCLUDE_BCM56780_A0 1 + * #define BCMDRD_CONFIG_INCLUDE_BCM56780_A1 0 + * + * + * The value of BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT is used for any + * chips which are left unspecified. Set this value to 1 or 0 to + * include or exclude all chips by default. + * + */ + +#ifndef BCMDRD_CONFIG_CHIPS_H +#define BCMDRD_CONFIG_CHIPS_H + +/* This determines whether a chip is included or excluded by default */ +#ifndef BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#define BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT 1 +#endif + +/* + * Default configuration and dependencies for all chips + */ + +/* + * BCM56780 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56780 +#define BCMDRD_CONFIG_INCLUDE_BCM56780 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56780_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56780_Ax BCMDRD_CONFIG_INCLUDE_BCM56780 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56780_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56780_A0 BCMDRD_CONFIG_INCLUDE_BCM56780_Ax +#endif + + +/* + * BCM56782 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56782 +#define BCMDRD_CONFIG_INCLUDE_BCM56782 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56782_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56782_Ax BCMDRD_CONFIG_INCLUDE_BCM56782 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56782_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56782_A0 BCMDRD_CONFIG_INCLUDE_BCM56782_Ax +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56782_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56780_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56780_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56780_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56780_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56780_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56780_A0_IMPLIED 1 +#endif +#endif + + +/* + * BCM56784 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56784 +#define BCMDRD_CONFIG_INCLUDE_BCM56784 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56784_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56784_Ax BCMDRD_CONFIG_INCLUDE_BCM56784 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56784_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56784_A0 BCMDRD_CONFIG_INCLUDE_BCM56784_Ax +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56784_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56780_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56780_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56780_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56780_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56780_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56780_A0_IMPLIED 1 +#endif +#endif + + +/* + * BCM56786 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56786 +#define BCMDRD_CONFIG_INCLUDE_BCM56786 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56786_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56786_Ax BCMDRD_CONFIG_INCLUDE_BCM56786 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56786_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56786_A0 BCMDRD_CONFIG_INCLUDE_BCM56786_Ax +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56786_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56780_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56780_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56780_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56780_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56780_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56780_A0_IMPLIED 1 +#endif +#endif + + +/* + * BCM56788 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56788 +#define BCMDRD_CONFIG_INCLUDE_BCM56788 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56788_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56788_Ax BCMDRD_CONFIG_INCLUDE_BCM56788 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56788_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56788_A0 BCMDRD_CONFIG_INCLUDE_BCM56788_Ax +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56788_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56780_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56780_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56780_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56780_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56780_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56780_A0_IMPLIED 1 +#endif +#endif + + +/* + * BCM56789 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56789 +#define BCMDRD_CONFIG_INCLUDE_BCM56789 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56789_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56789_Ax BCMDRD_CONFIG_INCLUDE_BCM56789 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56789_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56789_A0 BCMDRD_CONFIG_INCLUDE_BCM56789_Ax +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56789_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56780_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56780_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56780_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56780_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56780_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56780_A0_IMPLIED 1 +#endif +#endif + + +/* + * BCM56880 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56880 +#define BCMDRD_CONFIG_INCLUDE_BCM56880 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56880_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56880_Ax BCMDRD_CONFIG_INCLUDE_BCM56880 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56880_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0 BCMDRD_CONFIG_INCLUDE_BCM56880_Ax +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56880_Bx +#define BCMDRD_CONFIG_INCLUDE_BCM56880_Bx BCMDRD_CONFIG_INCLUDE_BCM56880 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56880_B0 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_B0 BCMDRD_CONFIG_INCLUDE_BCM56880_Bx +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56880_B0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56880_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56880_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56880_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0_IMPLIED 1 +#endif +#endif + + +/* + * BCM56881 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56881 +#define BCMDRD_CONFIG_INCLUDE_BCM56881 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56881_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56881_Ax BCMDRD_CONFIG_INCLUDE_BCM56881 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56881_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56881_A0 BCMDRD_CONFIG_INCLUDE_BCM56881_Ax +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56881_Bx +#define BCMDRD_CONFIG_INCLUDE_BCM56881_Bx BCMDRD_CONFIG_INCLUDE_BCM56881 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56881_B0 +#define BCMDRD_CONFIG_INCLUDE_BCM56881_B0 BCMDRD_CONFIG_INCLUDE_BCM56881_Bx +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56881_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56880_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56880_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56880_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0_IMPLIED 1 +#endif +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56881_B0 == 1 +#if BCMDRD_CONFIG_INCLUDE_BCM56880_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56880_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0_IMPLIED 1 +#endif +#endif + + +/* + * BCM56883 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56883 +#define BCMDRD_CONFIG_INCLUDE_BCM56883 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56883_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56883_Ax BCMDRD_CONFIG_INCLUDE_BCM56883 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56883_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56883_A0 BCMDRD_CONFIG_INCLUDE_BCM56883_Ax +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56883_Bx +#define BCMDRD_CONFIG_INCLUDE_BCM56883_Bx BCMDRD_CONFIG_INCLUDE_BCM56883 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56883_B0 +#define BCMDRD_CONFIG_INCLUDE_BCM56883_B0 BCMDRD_CONFIG_INCLUDE_BCM56883_Bx +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56883_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56880_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56880_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56880_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0_IMPLIED 1 +#endif +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56883_B0 == 1 +#if BCMDRD_CONFIG_INCLUDE_BCM56880_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56880_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0_IMPLIED 1 +#endif +#endif + + +/* + * BCM56889 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56889 +#define BCMDRD_CONFIG_INCLUDE_BCM56889 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56889_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56889_Ax BCMDRD_CONFIG_INCLUDE_BCM56889 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56889_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56889_A0 BCMDRD_CONFIG_INCLUDE_BCM56889_Ax +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56889_Bx +#define BCMDRD_CONFIG_INCLUDE_BCM56889_Bx BCMDRD_CONFIG_INCLUDE_BCM56889 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56889_B0 +#define BCMDRD_CONFIG_INCLUDE_BCM56889_B0 BCMDRD_CONFIG_INCLUDE_BCM56889_Bx +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56889_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56880_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56880_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56880_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0_IMPLIED 1 +#endif +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56889_B0 == 1 +#if BCMDRD_CONFIG_INCLUDE_BCM56880_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56880_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56880_A0_IMPLIED 1 +#endif +#endif + + +/* + * BCM56990 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56990 +#define BCMDRD_CONFIG_INCLUDE_BCM56990 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56990_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56990_Ax BCMDRD_CONFIG_INCLUDE_BCM56990 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56990_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56990_A0 BCMDRD_CONFIG_INCLUDE_BCM56990_Ax +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56990_Bx +#define BCMDRD_CONFIG_INCLUDE_BCM56990_Bx BCMDRD_CONFIG_INCLUDE_BCM56990 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56990_B0 +#define BCMDRD_CONFIG_INCLUDE_BCM56990_B0 BCMDRD_CONFIG_INCLUDE_BCM56990_Bx +#endif + + +/* + * BCM56992 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56992 +#define BCMDRD_CONFIG_INCLUDE_BCM56992 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56992_Bx +#define BCMDRD_CONFIG_INCLUDE_BCM56992_Bx BCMDRD_CONFIG_INCLUDE_BCM56992 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56992_B0 +#define BCMDRD_CONFIG_INCLUDE_BCM56992_B0 BCMDRD_CONFIG_INCLUDE_BCM56992_Bx +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56992_B0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56990_B0 +#define BCMDRD_CONFIG_INCLUDE_BCM56990_B0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56990_B0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56990_B0 +#define BCMDRD_CONFIG_INCLUDE_BCM56990_B0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56990_B0_IMPLIED 1 +#endif +#endif + + +/* + * BCM56996 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56996 +#define BCMDRD_CONFIG_INCLUDE_BCM56996 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56996_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56996_Ax BCMDRD_CONFIG_INCLUDE_BCM56996 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56996_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56996_A0 BCMDRD_CONFIG_INCLUDE_BCM56996_Ax +#endif + + +/* + * BCM56997 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56997 +#define BCMDRD_CONFIG_INCLUDE_BCM56997 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56997_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56997_Ax BCMDRD_CONFIG_INCLUDE_BCM56997 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56997_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56997_A0 BCMDRD_CONFIG_INCLUDE_BCM56997_Ax +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56997_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56996_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56996_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56996_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56996_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56996_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56996_A0_IMPLIED 1 +#endif +#endif + + +#endif /* BCMDRD_CONFIG_CHIPS_H */ + +/* + * CONFIG_OPTION Macros. Can be used to determine the build configuration. + */ + +#ifdef CONFIG_OPTION +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56780) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56780_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56780_A0) +#ifdef BCMDRD_CONFIG_INCLUDE_BCM56780_A0_IMPLIED +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56780_A0_IMPLIED) +#endif +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56782) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56782_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56782_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56784) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56784_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56784_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56786) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56786_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56786_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56788) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56788_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56788_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56789) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56789_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56789_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56880) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56880_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56880_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56880_Bx) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56880_B0) +#ifdef BCMDRD_CONFIG_INCLUDE_BCM56880_A0_IMPLIED +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56880_A0_IMPLIED) +#endif +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56881) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56881_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56881_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56881_Bx) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56881_B0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56883) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56883_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56883_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56883_Bx) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56883_B0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56889) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56889_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56889_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56889_Bx) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56889_B0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56990) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56990_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56990_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56990_Bx) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56990_B0) +#ifdef BCMDRD_CONFIG_INCLUDE_BCM56990_A0_IMPLIED +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56990_A0_IMPLIED) +#endif +#ifdef BCMDRD_CONFIG_INCLUDE_BCM56990_B0_IMPLIED +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56990_B0_IMPLIED) +#endif +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56992) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56992_Bx) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56992_B0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56996) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56996_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56996_A0) +#ifdef BCMDRD_CONFIG_INCLUDE_BCM56996_A0_IMPLIED +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56996_A0_IMPLIED) +#endif +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56997) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56997_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56997_A0) +#undef CONFIG_OPTION +#endif /* #ifdef CONFIG_OPTION */ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/Kbuild b/platform/broadcom/saibcm-modules/sdklt/linux/bde/Kbuild new file mode 100644 index 000000000000..76581c02eed2 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/Kbuild @@ -0,0 +1,39 @@ +# -*- Kbuild -*- +# +# Linux kernel BDE module. +# +# $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. +# The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# A copy of the GNU General Public License version 2 (GPLv2) can +# be found in the LICENSES folder.$ +# + +obj-m := linux_ngbde.o + +ccflags-y := $(LKM_CFLAGS) \ + -I$(SDK)/linux/include \ + -I$(SDK)/linux/bde \ + -I$(SDK)/bcmdrd/include + +linux_ngbde-y := ngbde_main.o \ + ngbde_kapi.o \ + ngbde_ioctl.o \ + ngbde_procfs.o \ + ngbde_pio.o \ + ngbde_iio.o \ + ngbde_dma.o \ + ngbde_intr.o \ + ngbde_pgmem.o \ + ngbde_pci_probe.o \ + ngbde_iproc_probe.o \ + ngbde_swdev.o diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/Makefile b/platform/broadcom/saibcm-modules/sdklt/linux/bde/Makefile new file mode 100644 index 000000000000..590f4132306f --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/Makefile @@ -0,0 +1,33 @@ +# -*- Makefile -*- +# +# Linux kernel BDE module. +# +# $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. +# The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# A copy of the GNU General Public License version 2 (GPLv2) can +# be found in the LICENSES folder.$ +# + +include Kbuild + +ifeq ($(KERNELRELEASE),) + +MOD_NAME = linux_ngbde + +include $(SDK)/make/lkm.mk + +endif + +.PHONY: distclean + +distclean: diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde.h b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde.h new file mode 100644 index 000000000000..56e925f7098d --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde.h @@ -0,0 +1,836 @@ +/*! \file ngbde.h + * + * Shared definitions and APIs for NGBDE kernel module. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef NGBDE_H +#define NGBDE_H + +#include +#include + +/*! Module name. */ +#define MOD_NAME "linux_ngbde" + +/*! Major number for associated charcter device file. */ +#define MOD_MAJOR 120 + +/*! Read memory-mapped device register without byte-swap. */ +#define NGBDE_IOREAD32(_a) __raw_readl(_a) + +/*! Write memory-mapped device register without byte-swap. */ +#define NGBDE_IOWRITE32(_v, _a) __raw_writel(_v, _a) + +/*! Maximum number of I/O windows supported per device. */ +#define NGBDE_NUM_IOWIN_MAX 3 + +/*! Maximum number of DMA memory pools supported per device. */ +#define NGBDE_NUM_DMAPOOL_MAX 2 + +/*! Maximum number of IRQ status registers per interrupt source. */ +#define NGBDE_NUM_IRQ_REGS_MAX 16 + +/*! Maximum number of IRQ lines (MSI vectors) per device. */ +#define NGBDE_NUM_IRQS_MAX 1 + +/*! + * Maximum number of interrupt controller registers which may be + * written from both a user mode driver and a kernel mode driver. + * + * This feature is used when the kernel mode driver owns a subset of + * bits within a register, which is also used by the user mode driver. + * + * Both drivers must access such registers through a lock-protected + * access function. + */ +#define NGBDE_NUM_INTR_SHR_REGS_MAX 1 + +/*! I/O memory window definition. */ +struct ngbde_memwin_s { + + /*! Physical address of I/O window. */ + phys_addr_t addr; + + /*! Size of I/O window (in bytes). */ + phys_addr_t size; +}; + +/*! + * \brief Shared register value. + * + * This structure contains the current value of a register where user + * mode and kernel mode owns different bits within the same + * register. In this case access must be carefully controlled to avoid + * that one context overwrites the bits owned by the other context. + * + * The structure also contains the offset of the shared register in + * order to identify the register (in case there is more than one + * shared register). + */ +typedef struct ngbde_shr_reg_s { + + /*! Offset of the shared register. */ + uint32_t reg_offs; + + /*! Current value of the shared register. */ + uint32_t cur_val; + +} ngbde_shr_reg_t; + +/*! + * \brief Shared interrupt mask register control. + * + * This defines which bits of an interrupt mask register are owned by + * user mode context, and which are owned by kernel context. + * + * The structure contains the corresponding interrupt status register + * in order to allow identification of the interrupt mask register + * irrespective of the host CPU being used. + * + * For example, if the host CPU is connected via PCI, then we use one + * mask register, but if the host CPU is an embedded ARM CPU, then we + * use a different mask register (for the same interrupt status + * register). By using the status register to identify the shared mask + * register, the kernel mode driver does not need to know which host + * CPU it is running off. + */ +typedef struct ngbde_irq_reg_s { + + /*! Interrupt status register corresponding to the mask register. */ + uint32_t status_reg; + + /*! Shared interrupt mask register. */ + uint32_t mask_reg; + + /*! Mask identifying the register bits owned by the kernel mode driver. */ + uint32_t kmask; + +} ngbde_irq_reg_t; + +/*! + * \name Interrupt ACK register access flags. + * \anchor NGBDE_INTR_ACK_F_xxx + */ + +/*! \{ */ + +/*! ACK registers resides in PCI bridge I/O window. */ +#define NGBDE_INTR_ACK_F_PAXB (1 << 0) + +/*! \} */ + +/*! + * \brief Interrupt ACK register control. + * + * The structure contains the corresponding register offset + * and value in order to acknowledge interrupt in kernel driver. + * + * For example, if the host CPU is connected via PCI, then we use one + * ACK register, but if the host CPU is an embedded ARM CPU, then we + * use a different ACK register. + */ +typedef struct ngbde_intr_ack_reg_s { + + /*! Ack register offset. */ + uint32_t ack_reg; + + /*! Ack value. */ + uint32_t ack_val; + + /*! Flags to indicate ack_reg resides in PCI bridge window. */ + uint32_t flags; + +} ngbde_intr_ack_reg_t; + +/*! + * \brief BDE interrupt handler. + * + * The BDE will use a function of this type to register an interrupt + * handler with the Linux kernel. + * + * \param [in] data Interrupt handler context. + * + * \retval 0 Interrupt not recognized. + * \retval 1 Interrupt recognized and handled. + */ +typedef int (*ngbde_isr_f)(void *data); + +/*! + * \brief Kernel interrupt control. + * + * This structure controls the sharing of interrupt processing between + * a user mode thread and a kernel mode interrupt handler. + */ +typedef struct ngbde_intr_ctrl_s { + + /*! Handle for device I/O (for writing interrupt registers). */ + uint8_t *iomem; + + /*! Kernel device number (similar to user mode unit number). */ + int kdev; + + /*! Indicates that our interrupt handler is connected to the kernel. */ + int irq_active; + + /*! Interrupt number (IRQ# or MSI vector). */ + int irq_vect; + + /*! Number of interrupt status/mask register pairs. */ + int num_regs; + + /*! Interrupt status/mask register pairs for this device. */ + ngbde_irq_reg_t regs[NGBDE_NUM_IRQ_REGS_MAX]; + + /*! Interrupt ACK register/value for this device. */ + ngbde_intr_ack_reg_t intr_ack; + + /*! Wait queue for user mode interrupt thread. */ + wait_queue_head_t user_thread_wq; + + /*! Flag to wake up user mode interrupt thread. */ + atomic_t run_user_thread; + + /*! Primary interrupt handler. */ + ngbde_isr_f isr_func; + + /*! Context for primary interrupt handler. */ + void *isr_data; + +} ngbde_intr_ctrl_t; + +/*! Convenience macro for 1 kilobyte. */ +#define ONE_KB 1024 + +/*! Convenience macro for 1 megabyte. */ +#define ONE_MB (1024*1024) + +/*! + * \name DMA allocation types. + * \anchor NGBDE_DMA_T_xxx + */ + +/*! \{ */ + +/*! + * Do not allocate any DMA memory. + */ +#define NGBDE_DMA_T_NONE 0 + +/*! + * Try different allocation methods until DMA memory is successfully + * allocated. + */ +#define NGBDE_DMA_T_AUTO 1 + +/*! Use kernel DMA API (dma_alloc_coherent). */ +#define NGBDE_DMA_T_KAPI 2 + +/*! Use page allocator and map to physical address manually. */ +#define NGBDE_DMA_T_PGMEM 3 + +/*! \} */ + +/*! DMA memory allocation control structure. */ +typedef struct ngbde_dmactrl_s { + + /*! Requested size of DMA memory block (in bytes). */ + size_t size; + + /*! Kernel flags for memory allocation. */ + gfp_t flags; + + /*! Preferred DMA memory type (NGBDE_DMA_T_xxx). */ + int pref_type; + + /*! Kernel device for DMA memory management. */ + struct device *dev; + +} ngbde_dmactrl_t; + +/*! DMA memory descriptor. */ +typedef struct ngbde_dmamem_s { + + /*! Logical address of DMA memory block. */ + void *vaddr; + + /*! Physical address of DMA memory block. */ + dma_addr_t paddr; + + /*! Bus address of DMA memory block. */ + dma_addr_t baddr; + + /*! Actual size of DMA memory block (in bytes). */ + size_t size; + + /*! Actual DMA memory type (NGBDE_DMA_T_xxx). */ + int type; + + /*! Kernel device for DMA memory management. */ + struct device *dev; + +} ngbde_dmamem_t; + +/*! DMA memory pool. */ +typedef struct ngbde_dmapool_s { + + /*! DMA control parameters. */ + struct ngbde_dmactrl_s dmactrl; + + /*! DMA memory resources. */ + struct ngbde_dmamem_s dmamem; + +} ngbde_dmapool_t; + +/*! Switch device descriptor. */ +struct ngbde_dev_s { + + /*! Vendor ID (typically PCI vendor ID). */ + uint16_t vendor_id; + + /*! Device ID (typically PCI device ID). */ + uint16_t device_id; + + /*! Device revision (typically PCI revision). */ + uint16_t revision; + + /*! Additional device identification when primary ID is not unique. */ + uint16_t model; + + /*! Bus number (typically PCI bus number). */ + int bus_no; + + /*! Slot number (typically PCI slot number). */ + int slot_no; + + /*! Interrupt line associated with this device. */ + int irq_line; + + /*! Use MSI interrupts with this device. */ + int use_msi; + + /*! Non-zero if device was removed. */ + int inactive; + + /*! Physical I/O window for kernel driver device access. */ + struct ngbde_memwin_s pio_win; + + /*! Memory mapped I/O window for kernel driver device access. */ + uint8_t *pio_mem; + + /*! Physical I/O window for interrupt controller access. */ + struct ngbde_memwin_s iio_win; + + /*! Memory mapped I/O window for interrupt controller access. */ + uint8_t *iio_mem; + + /*! Physical I/O window for device PCI bridge access. */ + struct ngbde_memwin_s paxb_win; + + /*! Memory mapped I/O window for device PCI bridge access. */ + uint8_t *paxb_mem; + + /*! Current value of shared register (typically an IRQ mask register). */ + struct ngbde_shr_reg_s intr_shr_reg[NGBDE_NUM_INTR_SHR_REGS_MAX]; + + /*! Lock for shared register synchronization. */ + spinlock_t lock; + + /*! Interrupt control information. */ + struct ngbde_intr_ctrl_s intr_ctrl[NGBDE_NUM_IRQS_MAX]; + + /*! Linux PCI handle. */ + struct pci_dev *pci_dev; + + /*! Kernel device for DMA memory management. */ + struct device *dma_dev; + + /*! Physical device I/O. */ + struct ngbde_memwin_s iowin[NGBDE_NUM_IOWIN_MAX]; + + /*! DMA memory pools. */ + struct ngbde_dmapool_s dmapool[NGBDE_NUM_DMAPOOL_MAX]; +}; + +/*! + * \brief Linux IOCTL handler. + * + * This function handles communication between user mode and kernel + * mode. + * + * \param [in] file Device file handle. + * \param [in] cmd IOCTL command. + * \param [in] arg IOCTL command argument. + * + * \retval 0 No errors + */ +extern long +ngbde_ioctl(struct file *file, unsigned int cmd, unsigned long arg); + +/*! + * \brief Initialize procfs for BDE driver. + * + * Create procfs read interface for dumping probe information. + * + * \return 0 if no errors, otherwise -1. + */ +extern int +ngbde_procfs_init(void); + +/*! + * \brief Clean up procfs for BDE driver. + * + * Clean up resources allocated by \ref ngbde_procfs_init. + * + * \return 0 if no errors, otherwise -1. + */ +extern int +ngbde_procfs_cleanup(void); + +/*! + * \brief Allocate DMA memory pools for all probed devices. + * + * \return 0 if no errors, otherwise -1. + */ +extern int +ngbde_dma_init(void); + +/*! + * \brief Free DMA memory pools for all probed devices. + * + * \return Nothing. + */ +extern void +ngbde_dma_cleanup(void); + +/*! + * \brief Connect to hardware interrupt handler. + * + * \param [in] kdev Device number. + * \param [in] irq_num Interrupt number (MSI vector). + * + * \retval 0 No errors + * \retval -1 Something went wrong. + */ +extern int +ngbde_intr_connect(int kdev, unsigned int irq_num); + +/*! + * \brief Disconnect from hardware interrupt handler. + * + * \param [in] kdev Device number. + * \param [in] irq_num Interrupt number (MSI vector). + * + * \retval 0 No errors + * \retval -1 Something went wrong. + */ +extern int +ngbde_intr_disconnect(int kdev, unsigned int irq_num); + +/*! + * \brief Disconnect from all hardware interrupt handlers. + */ +void +ngbde_intr_cleanup(void); + +/*! + * \brief Wait for hardware interrupt. + * + * A user mode thread will call this function and sleep until a + * hardware interrupt occurs. + * + * \param [in] kdev Device number. + * \param [in] irq_num Interrupt number (MSI vector). + * + * \retval 0 No errors + * \retval -1 Something went wrong. + */ +extern int +ngbde_intr_wait(int kdev, unsigned int irq_num); + +/*! + * \brief Wake up sleeping interrupt thread. + * + * Wake up interrupt thread even if no interrupt has occurred. + * + * Intended for graceful shut-down procedure. + * + * \param [in] kdev Device number. + * \param [in] irq_num Interrupt number (MSI vector). + * + * \retval 0 No errors + * \retval -1 Something went wrong. + */ +extern int +ngbde_intr_stop(int kdev, unsigned int irq_num); + +/*! + * \brief Clear list of interrupt status/mask registers. + * + * This function is typically called before new interrupt register + * information is added. + * + * \param [in] kdev Device number. + * \param [in] irq_num Interrupt number (MSI vector). + * + * \retval 0 No errors + * \retval -1 Something went wrong. + */ +extern int +ngbde_intr_regs_clr(int kdev, unsigned int irq_num); + +/*! + * \brief Add interrupt status/mask register to monitor. + * + * This function adds a new interrupt status/mask register set to the + * list of registers monitored by the user-mode interrupt handler. + * + * The register list is used to determine whether a user-mode + * interrupt has occurred. + * + * See also \ref ngbde_intr_regs_clr. + * + * \param [in] kdev Device number. + * \param [in] irq_num Interrupt number (MSI vector). + * \param [in] ireg Interrupt status/mask register information. + * + * \retval 0 No errors + * \retval -1 Something went wrong. + */ +extern int +ngbde_intr_reg_add(int kdev, unsigned int irq_num, + struct ngbde_irq_reg_s *ireg); + +/*! + * \brief Add interrupt ack register to monitor. + * + * This function adds a interrupt register and mask value + * to acknowledge corresponding irq_num. + * + * \param [in] kdev Device number. + * \param [in] irq_num Interrupt number (MSI vector). + * \param [in] ackreg Interrupt ack register information. + * + * \retval 0 No errors + * \retval -1 Something went wrong. + */ +extern int +ngbde_intr_ack_reg_add(int kdev, unsigned int irq_num, + struct ngbde_intr_ack_reg_s *ackreg); + +/*! + * \brief Write shared interrupt mask register. + * + * This function is used by an interrupt handler when a shared + * interrupt mask register needs to be updated. + * + * Since the register is shared between multiple interrupt handlers, + * access must be protected by a lock. + * + * The register information provided via \ref ngbde_intr_reg_add is + * used to detemine which bits of the mask register belong to the user + * mode driver. + * + * Note that the mask register to access is referenced by the + * corresponding status register. This is because the mask register + * may be different depending on the host CPU interface being used + * (e.g. PCI vs. AXI). On the other hand, the status register is the + * same irrespective of the host CPU interface. + * + * \param [in] kdev Device number. + * \param [in] irq_num Interrupt number (MSI vector). + * \param [in] kapi Must be set to 1 if called from kernel API. + * \param [in] status_reg Corresponding interrupt status register offset. + * \param [in] mask_val New value to write to mask register. + * + * \retval 0 No errors + * \retval -1 Something went wrong. + */ +extern int +ngbde_intr_mask_write(int kdev, unsigned int irq_num, int kapi, + uint32_t status_reg, uint32_t mask_val); + +/*! + * \brief Probe for PCI-attached Broadcom switch devices. + * + * \return 0 if no errors, otherwise -1. + */ +extern int +ngbde_pci_probe(void); + +/*! + * \brief Clean up resources for PCI-attached Broadcom switch devices. + * + * \return 0 if no errors, otherwise -1. + */ +extern int +ngbde_pci_cleanup(void); + +/*! + * \brief Add new switch device to BDE database. + * + * Add device information for probed or fixed switch device. + * + * \param [in] nd Switch device information. + * + * \return 0 if no errors, otherwise -1. + */ +extern int +ngbde_swdev_add(struct ngbde_dev_s *nd); + +/*! + * \brief Get device information for a BDE switch device. + * + * \param [in] kdev Switch device number. + * + * \return Pointer to switch device structure or NULL on error. + */ +struct ngbde_dev_s * +ngbde_swdev_get(int kdev); + +/*! + * \brief Get list of all probed switch devices. + * + * Return a pointer to the array of registered switch devices. + * + * \param [out] nd Pointer to array of switch devices. + * \param [in] num_nd number of valid entries in switch device array. + * + * \retval 0 No errors + */ +extern int +ngbde_swdev_get_all(struct ngbde_dev_s **nd, unsigned int *num_nd); + +/*! + * \brief Allocate memory using page allocator + * + * For any sizes less than MEM_CHUNK_SIZE, we ask the page allocator + * for the entire memory block, otherwise we try to assemble a + * contiguous cmblock ourselves. + * + * Upon successful allocation, the memory block will be added to the + * global list of allocated memory blocks. + * + * \param [in] size Number of bytes to allocate. + * \param [in] flags Kernel flags (GFP_xxx) for memory allocation. + * + * \return Pointer to allocated memory or NULL if failure. + */ +void * +ngbde_pgmem_alloc(size_t size, gfp_t flags); + +/*! + * \brief Free memory block allocated by ngbde_pgmem_alloc. + * + * \param [in] ptr Pointer returned by ngbde_pgmem_alloc. + * + * \return 0 if succesfully freed, otherwise -1. + */ +extern int +ngbde_pgmem_free(void *ptr); + +/*! + * \brief Free all memory blocks allocated by ngbde_pgmem_alloc. + * + * This function will walk the global list of allocated memory blocks + * and free all associated resources. + * + * Intended for a full clean up before the module is unloaded. + * + * \return Nothing. + */ +extern void +ngbde_pgmem_free_all(void); + +/*! + * \brief Map I/O memory in kernel driver. + * + * This function is used to provide device I/O access to a kernel mode + * driver. + * + * \param [in] devh Device handle (\ref ngbde_dev_s). + * \param [in] addr Physical address to map. + * \param [in] size Size of I/O window to map. + * + * \return Pointer to mapped I/O memory, or NULL on error. + */ +extern void * +ngbde_pio_map(void *devh, phys_addr_t addr, phys_addr_t size); + +/*! + * \brief Unmap I/O memory in kernel driver. + * + * Unmap I/O memory previously mapped via \ref ngbde_pio_map. + * + * \param [in] devh Device handle (\ref ngbde_dev_s). + * + * \return Nothing. + */ +extern void +ngbde_pio_unmap(void *devh); + +/*! + * \brief Unmap all I/O windows. + */ +extern void +ngbde_pio_cleanup(void); + +/*! + * \brief Write a memory-mapped register from kernel driver. + * + * Write a 32-bit register using I/O memory previously mapped via \ref + * ngbde_pio_map. + * + * \param [in] devh Device handle (\ref ngbde_dev_s). + * \param [in] offs Register address offset. + * \param [in] val Value to write to register. + * + * \return Nothing. + */ +extern void +ngbde_pio_write32(void *devh, uint32_t offs, uint32_t val); + +/*! + * \brief Read a memory-mapped register from kernel driver. + * + * Read a 32-bit register using I/O memory previously mapped via \ref + * ngbde_pio_map. + * + * \param [in] devh Device handle (\ref ngbde_dev_s). + * \param [in] offs Register address offset. + * + * \return Value read from register. + */ +extern uint32_t +ngbde_pio_read32(void *devh, uint32_t offs); + +/*! + * \brief Map interrupt controller I/O memory. + * + * On some devices the interrupt controller is a device separate from + * the main switch device. This function is used to provide interrupt + * controller I/O access to a kernel mode driver. + * + * \param [in] devh Device handle (\ref ngbde_dev_s). + * \param [in] addr Physical address to map. + * \param [in] size Size of I/O window to map. + * + * \return Pointer to mapped I/O memory, or NULL on error. + */ +extern void * +ngbde_iio_map(void *devh, phys_addr_t addr, phys_addr_t size); + +/*! + * \brief Unmap interrupt controller I/O memory. + * + * Unmap I/O memory previously mapped via \ref ngbde_iio_map. + * + * \param [in] devh Device handle (\ref ngbde_dev_s). + * + * \return Nothing. + */ +extern void +ngbde_iio_unmap(void *devh); + +/*! + * \brief Unmap all interrupt controller I/O windows. + */ +extern void +ngbde_iio_cleanup(void); + +/*! + * \brief Write a memory-mapped interrupt controller register. + * + * Write a 32-bit register using I/O memory previously mapped via \ref + * ngbde_iio_map. + * + * \param [in] devh Device handle (\ref ngbde_dev_s). + * \param [in] offs Register address offset. + * \param [in] val Value to write to register. + * + * \return Nothing. + */ +extern void +ngbde_iio_write32(void *devh, uint32_t offs, uint32_t val); + +/*! + * \brief Read a memory-mapped interrupt controller register. + * + * Read a 32-bit register using I/O memory previously mapped via \ref + * ngbde_iio_map. + * + * \param [in] devh Device handle (\ref ngbde_dev_s). + * \param [in] offs Register address offset. + * + * \return Value read from register. + */ +extern uint32_t +ngbde_iio_read32(void *devh, uint32_t offs); + +/*! + * \brief Map PCI bridge I/O memory. + * + * On some devices the interrupt controller is a device separate from + * the main switch device. This function is used to provide interrupt + * controller I/O access to a kernel mode driver. + * + * \param [in] devh Device handle (\ref ngbde_dev_s). + * \param [in] addr Physical address to map. + * \param [in] size Size of I/O window to map. + * + * \return Pointer to mapped I/O memory, or NULL on error. + */ +extern void * +ngbde_paxb_map(void *devh, phys_addr_t addr, phys_addr_t size); + +/*! + * \brief Unmap PCI bridge I/O memory. + * + * Unmap I/O memory previously mapped via \ref ngbde_paxb_map. + * + * \param [in] devh Device handle (\ref ngbde_dev_s). + * + * \return Nothing. + */ +extern void +ngbde_paxb_unmap(void *devh); + +/*! + * \brief Unmap all PCI bridge I/O windows. + */ +extern void +ngbde_paxb_cleanup(void); + +/*! + * \brief Probe for Broadcom switch devices on IPROC internal bus. + * + * \return 0 if no errors, otherwise -1. + */ +extern int +ngbde_iproc_probe(void); + +/*! + * \brief Clean up resources for Broadcom switch devices on IPROC internal bus. + * + * \return 0 if no errors, otherwise -1. + */ +extern int +ngbde_iproc_cleanup(void); + +#endif /* NGBDE_H */ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_dma.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_dma.c new file mode 100644 index 000000000000..9cc2b191f48c --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_dma.c @@ -0,0 +1,340 @@ +/*! \file ngbde_dma.c + * + * This module handles allocation of DMA memory pools. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include + +/*! \cond */ +static int dma_debug = 0; +module_param(dma_debug, int, 0); +MODULE_PARM_DESC(dma_debug, +"DMA debug output enable (default 0)."); +/*! \endcond */ + +/*! Default size of of DMA memory pools (in MB). */ +#define DMAPOOL_SIZE_DEFAULT 16 + +/*! Default number of DMA memory pools per device. */ +#define NUM_DMAPOOL_DEFAULT 1 + +/*! \cond */ +static int dma_size = DMAPOOL_SIZE_DEFAULT; +module_param(dma_size, int, 0); +MODULE_PARM_DESC(dma_size, +"Size of of DMA memory pools in MB (default 16 MB)."); +/*! \endcond */ + +/*! \cond */ +static char *dma_alloc; +module_param(dma_alloc, charp, 0); +MODULE_PARM_DESC(dma_alloc, +"DMA allocation method auto|kapi|pgmem (default auto)"); +/*! \endcond */ + +/*! \cond */ +static int dma_pools = NUM_DMAPOOL_DEFAULT; +module_param(dma_pools, int, 0); +MODULE_PARM_DESC(dma_pools, +"Number of DMA memory pools to pre-allocate per device (default 1)."); +/*! \endcond */ + +/*! + * \brief Allocate DMA memory via kernel API. + * + * \param [in] dmactrl DMA allocation control. + * \param [out] dmamem DMA allocation result. + * + * \return Nothing. + */ +static void +ngbde_dmamem_kapi_alloc(ngbde_dmactrl_t *dmactrl, ngbde_dmamem_t *dmamem) +{ + void *vaddr; + dma_addr_t baddr; + + vaddr = dma_alloc_coherent(dmactrl->dev, dmactrl->size, &baddr, + dmactrl->flags); + if (vaddr) { + /* Store allocation information in dmamem structure */ + dmamem->vaddr = vaddr; + dmamem->paddr = virt_to_phys(vaddr); + dmamem->dev = dmactrl->dev; + dmamem->size = dmactrl->size; + dmamem->type = NGBDE_DMA_T_KAPI; + dmamem->baddr = baddr; + + /* Write small signature for debug purposes */ + strcpy((char *)vaddr, "DMA_KAPI"); + + if (dma_debug) { + printk("DMA: Allocated %d KB of KAPI memory at 0x%08lx\n", + (int)(dmamem->size / ONE_KB), + (unsigned long)dmamem->paddr); + } + } else { + if (dma_debug) { + printk("DMA: Failed to allocate KAPI memory\n"); + } + } +} + +/*! + * \brief Allocate DMA memory via page allocator. + * + * \param [in] dmactrl DMA allocation control. + * \param [out] dmamem DMA allocation result. + * + * \return Nothing. + */ +static void +ngbde_dmamem_pgmem_alloc(ngbde_dmactrl_t *dmactrl, ngbde_dmamem_t *dmamem) +{ + void *vaddr; + + vaddr = ngbde_pgmem_alloc(dmactrl->size, dmactrl->flags); + if (vaddr) { + /* Store allocation information in dmamem structure */ + dmamem->vaddr = vaddr; + dmamem->paddr = virt_to_phys(vaddr); + dmamem->dev = dmactrl->dev; + dmamem->size = dmactrl->size; + dmamem->type = NGBDE_DMA_T_PGMEM; + dmamem->baddr = dma_map_single(dmamem->dev, dmamem->vaddr, + dmamem->size, DMA_BIDIRECTIONAL); + if (dma_mapping_error(dmactrl->dev, dmamem->baddr)) { + dmamem->baddr = 0; + if (dma_debug) { + printk("DMA: Failed to map PGMEM memory\n"); + } + } + + /* Write small signature for debug purposes */ + strcpy((char *)vaddr, "DMA_PGMEM"); + + if (dma_debug) { + printk("DMA: Allocated %d KB of PGMEM memory at 0x%08lx\n", + (int)(dmamem->size / ONE_KB), + (unsigned long)dmamem->paddr); + } + } else { + if (dma_debug) { + printk("DMA: Failed to allocate PGMEM memory\n"); + } + } +} + +/*! + * \brief Allocate DMA memory. + * + * Depending on the DMA allocation control parameters, we select one + * of several DMA memory allocation methods. + * + * \param [in] dmactrl DMA allocation control. + * \param [out] dmamem DMA allocation result. + * + * \return Nothing. + */ +static int +ngbde_dmamem_alloc(ngbde_dmactrl_t *dmactrl, ngbde_dmamem_t *dmamem) +{ + int kapi = 0; + + if (dmamem->vaddr) { + /* Already allocated */ + return 0; + } + +#ifdef CONFIG_CMA + /* Always allow KAPI when CMA is available */ + kapi = 1; +#else + if (dmactrl->size <= (1 << (MAX_ORDER - 1 + PAGE_SHIFT))) { + kapi = 1; + } +#endif + + /* Allocation via kernel DMA API (if allowed) */ + if (kapi) { + switch (dmactrl->pref_type) { + case NGBDE_DMA_T_AUTO: + case NGBDE_DMA_T_KAPI: + ngbde_dmamem_kapi_alloc(dmactrl, dmamem); + break; + default: + break; + } + } + + /* Allocation via private page allocator */ + if (dmamem->vaddr == NULL) { + switch (dmactrl->pref_type) { + case NGBDE_DMA_T_AUTO: + case NGBDE_DMA_T_PGMEM: + ngbde_dmamem_pgmem_alloc(dmactrl, dmamem); + break; + default: + break; + } + } + + if (dmamem->vaddr == NULL) { + printk(KERN_WARNING "%s: Failed to allocate DMA memory\n", + MOD_NAME); + return -1; + } + + return 0; +} + +/*! + * \brief Free DMA memory. + * + * Free DMA memory allocated via \ref ngbde_dmamem_alloc. + * + * \param [in] dmamem DMA allocation result from \ref ngbde_dmamem_alloc. + * + * \return Nothing. + */ +static int +ngbde_dmamem_free(ngbde_dmamem_t *dmamem) +{ + switch (dmamem->type) { + case NGBDE_DMA_T_KAPI: + if (dma_debug) { + printk("DMA: Freeing %d KB of KAPI memory\n", + (int)(dmamem->size / ONE_KB)); + } + dma_free_coherent(dmamem->dev, dmamem->size, + dmamem->vaddr, dmamem->paddr); + memset(dmamem, 0, sizeof(*dmamem)); + break; + case NGBDE_DMA_T_PGMEM: + if (dma_debug) { + printk("DMA: Freeing %d KB of PGMEM memory\n", + (int)(dmamem->size / ONE_KB)); + } + if (dmamem->baddr) { + if (dma_debug) { + printk("DMA: Unmapping PGMEM memory at 0x%08lx\n", + (unsigned long)dmamem->baddr); + } + dma_unmap_single(dmamem->dev, dmamem->baddr, + dmamem->size, DMA_BIDIRECTIONAL); + } + ngbde_pgmem_free(dmamem->vaddr); + memset(dmamem, 0, sizeof(*dmamem)); + break; + case NGBDE_DMA_T_NONE: + /* Nothing to free */ + break; + default: + printk(KERN_WARNING "%s: Unable to free unknown DMA memory type\n", + MOD_NAME); + break; + } + return 0; +} + +/*! + * \brief Free all DMA memory pools for all devices. + * + * \return Nothing. + */ +void +ngbde_dma_cleanup(void) +{ + struct ngbde_dev_s *swdev; + unsigned int num_swdev, idx; + unsigned int pool; + + ngbde_swdev_get_all(&swdev, &num_swdev); + + for (idx = 0; idx < num_swdev; idx++) { + for (pool = 0; pool < NGBDE_NUM_DMAPOOL_MAX; pool++) { + if (swdev[idx].inactive) { + ngbde_dmamem_free(&swdev[idx].dmapool[pool].dmamem); + } + } + } +} + +/*! + * \brief Allocate DMA memory pools for all devices. + * + * \return Nothing. + */ +int +ngbde_dma_init(void) +{ + int rv; + struct ngbde_dev_s *swdev; + unsigned int num_swdev, idx; + int dma_type = NGBDE_DMA_T_AUTO; + struct ngbde_dmapool_s *dmapool; + unsigned int pool; + + /* Default DMA memory size per device */ + if (dma_size < 0) { + dma_size = DMAPOOL_SIZE_DEFAULT; + } + + /* Check for forced DMA allocation method */ + if (dma_alloc) { + if (strcmp(dma_alloc, "kapi") == 0) { + dma_type = NGBDE_DMA_T_KAPI; + } else if (strcmp(dma_alloc, "pgmem") == 0) { + dma_type = NGBDE_DMA_T_PGMEM; + } else { + printk(KERN_WARNING "%s: Unknown DMA type: %s\n", + MOD_NAME, dma_alloc); + } + } + + /* Number of DMA memory pools per device */ + if ((unsigned int)dma_pools >= NGBDE_NUM_DMAPOOL_MAX) { + dma_pools = NUM_DMAPOOL_DEFAULT; + } + + ngbde_swdev_get_all(&swdev, &num_swdev); + + for (idx = 0; idx < num_swdev; idx++) { + + /* Set DMA allocation parameters */ + for (pool = 0; pool < NGBDE_NUM_DMAPOOL_MAX; pool++) { + dmapool = &swdev[idx].dmapool[pool]; + dmapool->dmactrl.dev = swdev[idx].dma_dev; + dmapool->dmactrl.size = dma_size * ONE_MB; + dmapool->dmactrl.pref_type = dma_type; + dmapool->dmactrl.flags = GFP_KERNEL | GFP_DMA32; + } + + /* Allocate DMA pools */ + for (pool = 0; pool < dma_pools; pool++) { + dmapool = &swdev[idx].dmapool[pool]; + rv = ngbde_dmamem_alloc(&dmapool->dmactrl, &dmapool->dmamem); + if (rv < 0) { + printk(KERN_WARNING "%s: Unable to allocate DMA pool %d %d\n", + MOD_NAME, idx, pool); + } + } + } + return 0; +} diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_iio.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_iio.c new file mode 100644 index 000000000000..e97f1fcea730 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_iio.c @@ -0,0 +1,143 @@ +/*! \file ngbde_iio.c + * + * API for managing and accessing memory-mapped I/O for interrupt + * controller registers. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include + +void * +ngbde_iio_map(void *devh, phys_addr_t addr, phys_addr_t size) +{ + struct ngbde_dev_s *sd = (struct ngbde_dev_s *)devh; + + if (sd->iio_mem) { + if (addr == sd->iio_win.addr && size == sd->iio_win.size) { + /* Already mapped */ + return sd->iio_mem; + } + ngbde_iio_unmap(devh); + } + + sd->iio_mem = ioremap_nocache(addr, size); + + if (sd->iio_mem) { + /* Save mapped resources */ + sd->iio_win.addr = addr; + sd->iio_win.size = size; + } + + return sd->iio_mem; +} + +void +ngbde_iio_unmap(void *devh) +{ + struct ngbde_dev_s *sd = (struct ngbde_dev_s *)devh; + + if (sd->iio_mem) { + iounmap(sd->iio_mem); + sd->iio_mem = NULL; + } +} + +void +ngbde_iio_cleanup(void) +{ + struct ngbde_dev_s *swdev, *sd; + unsigned int num_swdev, idx; + + ngbde_swdev_get_all(&swdev, &num_swdev); + + for (idx = 0; idx < num_swdev; idx++) { + sd = ngbde_swdev_get(idx); + ngbde_iio_unmap(sd); + } +} + +void +ngbde_iio_write32(void *devh, uint32_t offs, uint32_t val) +{ + struct ngbde_dev_s *sd = (struct ngbde_dev_s *)devh; + + if (sd->iio_mem) { + NGBDE_IOWRITE32(val, sd->iio_mem + offs); + } +} + +uint32_t +ngbde_iio_read32(void *devh, uint32_t offs) +{ + struct ngbde_dev_s *sd = (struct ngbde_dev_s *)devh; + + if (sd->iio_mem) { + return NGBDE_IOREAD32(sd->iio_mem + offs); + } + return 0; +} + +void * +ngbde_paxb_map(void *devh, phys_addr_t addr, phys_addr_t size) +{ + struct ngbde_dev_s *sd = (struct ngbde_dev_s *)devh; + + if (sd->paxb_mem) { + if (addr == sd->paxb_win.addr && size == sd->paxb_win.size) { + /* Already mapped */ + return sd->paxb_mem; + } + iounmap(sd->paxb_mem); + } + + sd->paxb_mem = ioremap_nocache(addr, size); + + if (sd->paxb_mem) { + /* Save mapped resources */ + sd->paxb_win.addr = addr; + sd->paxb_win.size = size; + } + + return sd->paxb_mem; +} + +void +ngbde_paxb_unmap(void *devh) +{ + struct ngbde_dev_s *sd = (struct ngbde_dev_s *)devh; + + if (sd->paxb_mem) { + iounmap(sd->paxb_mem); + sd->paxb_mem = NULL; + } +} + +void +ngbde_paxb_cleanup(void) +{ + struct ngbde_dev_s *swdev, *sd; + unsigned int num_swdev, idx; + + ngbde_swdev_get_all(&swdev, &num_swdev); + + for (idx = 0; idx < num_swdev; idx++) { + sd = ngbde_swdev_get(idx); + ngbde_paxb_unmap(sd); + } +} diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_intr.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_intr.c new file mode 100644 index 000000000000..acec7da100f7 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_intr.c @@ -0,0 +1,550 @@ +/*! \file ngbde_intr.c + * + * API for controlling a thread-based user-mode interrupt handler. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include + +/*! \cond */ +static int intr_debug = 0; +module_param(intr_debug, int, 0); +MODULE_PARM_DESC(intr_debug, +"Interrupt debug output enable (default 0)."); +/*! \endcond */ + +static int +ngbde_intr_shared_write32(struct ngbde_dev_s *sd, struct ngbde_intr_ctrl_s *ic, + uint32_t reg_offs, uint32_t reg_val, uint32_t shr_mask) +{ + unsigned long flags; + struct ngbde_shr_reg_s *sr; + int idx; + + sr = NULL; + for (idx = 0; idx < NGBDE_NUM_INTR_SHR_REGS_MAX; idx++) { + if (sd->intr_shr_reg[idx].reg_offs == 0) { + /* If not found, then we add a new entry */ + sd->intr_shr_reg[idx].reg_offs = reg_offs; + } + if (sd->intr_shr_reg[idx].reg_offs == reg_offs) { + sr = &sd->intr_shr_reg[idx]; + break; + } + } + + if (sr == NULL) { + return -1; + } + + spin_lock_irqsave(&sd->lock, flags); + + sr->cur_val &= ~shr_mask; + sr->cur_val |= (reg_val & shr_mask); + + NGBDE_IOWRITE32(sr->cur_val, ic->iomem + reg_offs); + + spin_unlock_irqrestore(&sd->lock, flags); + + return 0; +} + +/*! + * \brief Interrupt handler for user mode thread. + * + * This function will determine whether a user-mode interrupt has + * occurred by reading the configured interrupt status and mask + * registers. + * + * If an interrupt has occurred, any waiting user-mode thread is woken + * up. + * + * \param [in] ic Interrupt control information. + * + * \retval 1 One or more user mode interrupts occurred. + * \retval 0 No user mode interrupts occurred. + */ +static int +ngbde_user_isr(ngbde_intr_ctrl_t *ic) +{ + int idx; + int active_interrupts = 0; + uint32_t stat = 0, mask = 0; + uint32_t kmask; + + /* Check if any enabled interrupts are active */ + for (idx = 0; idx < ic->num_regs; idx++) { + ngbde_irq_reg_t *ir = &ic->regs[idx]; + + /* Get mask of all kernel interrupt sources for this register address */ + kmask = ir->kmask; + + stat = NGBDE_IOREAD32(&ic->iomem[ir->status_reg]); + mask = NGBDE_IOREAD32(&ic->iomem[ir->mask_reg]); + + if (stat & mask & ~kmask) { + active_interrupts = 1; + break; + } + } + + /* No active interrupts to service */ + if (!active_interrupts) { + return 0; + } + + /* Disable (mask off) all interrupts */ + for (idx = 0; idx < ic->num_regs; idx++) { + ngbde_irq_reg_t *ir = &ic->regs[idx]; + + /* Get mask of all kernel interrupt sources for this register address */ + kmask = ir->kmask; + + if (kmask == 0xffffffff) { + /* Kernel driver owns all interrupts in this register */ + continue; + } else if (kmask) { + /* Synchronized write */ + struct ngbde_dev_s *sd = ngbde_swdev_get(ic->kdev); + if (ngbde_intr_shared_write32(sd, ic, ir->mask_reg, 0, ~kmask) < 0) { + printk(KERN_WARNING + "%s: Failed to write shared register for device %d\n", + MOD_NAME, ic->kdev); + /* Fall back to normal write to ensure interrupts are masked */ + NGBDE_IOWRITE32(0, &ic->iomem[ir->mask_reg]); + } + } else { + NGBDE_IOWRITE32(0, &ic->iomem[ir->mask_reg]); + } + } + + atomic_set(&ic->run_user_thread, 1); + wake_up_interruptible(&ic->user_thread_wq); + + return 1; +} + +/*! + * \brief Interrupt handler for kernel driver. + * + * Typically used by the KNET driver. + * + * \param [in] ic Interrupt control information. + * + * \retval 1 One or more kernel mode interrupts occurred. + * \retval 0 No kernel mode interrupts occurred. + */ +static int +ngbde_kernel_isr(ngbde_intr_ctrl_t *ic) +{ + if (ic->isr_func) { + return ic->isr_func(ic->isr_data); + } + return 0; +} + +/*! + * \brief Acknowledge interrupt + * + * \param [in] data Interrupt control information + * + * \retval 0 + */ +static int +ngbde_intr_ack(ngbde_intr_ctrl_t *ic) +{ + struct ngbde_dev_s *sd = ngbde_swdev_get(ic->kdev); + struct ngbde_intr_ack_reg_s *ar = &ic->intr_ack; + + if (sd->use_msi) { + if (ar->flags & NGBDE_INTR_ACK_F_PAXB) { + NGBDE_IOWRITE32(ar->ack_val, &sd->paxb_mem[ar->ack_reg]); + } else { + NGBDE_IOWRITE32(ar->ack_val, &sd->pio_mem[ar->ack_reg]); + } + } + + return 0; +} + +/*! + * \brief Linux ISR + * + * Will call the user-mode interrupts handler and optionally also a + * kernel mode interrupt handler (typically KNET). + * + * \param [in] irq_num Interrupt vector from kernel. + * \param [in] data Interrupt control information + * + * \retval IRQ_NONE Interrupt not recognized. + * \retval IRQ_HANDLED Interrupt recognized and handled (masked off). + */ +static irqreturn_t +ngbde_isr(int irq_num, void *data) +{ + struct ngbde_intr_ctrl_s *ic = (struct ngbde_intr_ctrl_s *)data; + irqreturn_t rv = IRQ_NONE; + + ngbde_intr_ack(ic); + + if (ngbde_user_isr(ic)) { + rv = IRQ_HANDLED; + } + if (ngbde_kernel_isr(ic)) { + rv = IRQ_HANDLED; + } + return rv; +} + +int +ngbde_intr_connect(int kdev, unsigned int irq_num) +{ + struct ngbde_dev_s *sd; + struct ngbde_intr_ctrl_s *ic; + unsigned long irq_flags; + + sd = ngbde_swdev_get(kdev); + if (!sd) { + return -1; + } + + if (irq_num >= NGBDE_NUM_IRQS_MAX) { + return -1; + } + + ic = &sd->intr_ctrl[irq_num]; + + if (ic->irq_active) { + return 0; + } + + if (sd->irq_line >= 0) { + if (sd->pio_mem == NULL) { + printk(KERN_WARNING "%s: No memory-mapped I/O for device %d\n", + MOD_NAME, kdev); + return -1; + } + ic->kdev = kdev; + ic->iomem = sd->pio_mem; + if (sd->iio_mem) { + if (intr_debug) { + printk("INTR: Using dedicated interrupt controller\n"); + } + ic->iomem = sd->iio_mem; + } + init_waitqueue_head(&ic->user_thread_wq); + atomic_set(&ic->run_user_thread, 0); + irq_flags = IRQF_SHARED; + ic->irq_vect = sd->irq_line; + + /* + * The pci_enable_msi function must be called after enabling + * BAR0_PAXB_OARR_FUNC0_MSI_PAGE, otherwise, MSI interrupts + * cannot be triggered! + */ + if (sd->use_msi) { + if (pci_enable_msi(sd->pci_dev) == 0) { + irq_flags = 0; + ic->irq_vect = sd->pci_dev->irq; + if (intr_debug) { + printk("INTR: Enabled MSI interrupts\n"); + } + } else { + printk(KERN_WARNING "%s: Failed to enable MSI for device %d\n", + MOD_NAME, kdev); + sd->use_msi = 0; + } + } + if (intr_debug) { + printk("INTR: Request IRQ %d\n", ic->irq_vect); + } + if (request_irq(ic->irq_vect, ngbde_isr, irq_flags, MOD_NAME, ic) < 0) { + printk(KERN_WARNING "%s: Could not get IRQ %d for device %d\n", + MOD_NAME, ic->irq_vect, kdev); + return -1; + } + ic->irq_active = 1; + } + + return 0; +} + +int +ngbde_intr_disconnect(int kdev, unsigned int irq_num) +{ + struct ngbde_dev_s *sd; + struct ngbde_intr_ctrl_s *ic; + + sd = ngbde_swdev_get(kdev); + if (!sd) { + return -1; + } + + if (irq_num >= NGBDE_NUM_IRQS_MAX) { + return -1; + } + + ic = &sd->intr_ctrl[irq_num]; + + if (!ic->irq_active) { + return 0; + } + + if (ic->isr_func) { + printk(KERN_WARNING "%s: Disconnecting IRQ %d blocked by kernel ISR\n", + MOD_NAME, irq_num); + return 0; + } + + if (ic->irq_vect >= 0) { + free_irq(ic->irq_vect, ic); + if (sd->use_msi) { + pci_disable_msi(sd->pci_dev); + } + ic->irq_active = 0; + } + + return 0; +} + +void +ngbde_intr_cleanup(void) +{ + struct ngbde_dev_s *swdev; + unsigned int num_swdev, idx, irq_num; + + ngbde_swdev_get_all(&swdev, &num_swdev); + + for (idx = 0; idx < num_swdev; idx++) { + for (irq_num = 0; irq_num < NGBDE_NUM_IRQS_MAX; irq_num++) { + ngbde_intr_disconnect(idx, irq_num); + } + } +} + +int +ngbde_intr_wait(int kdev, unsigned int irq_num) +{ + struct ngbde_dev_s *sd; + struct ngbde_intr_ctrl_s *ic; + + sd = ngbde_swdev_get(kdev); + if (!sd) { + return -1; + } + + if (irq_num >= NGBDE_NUM_IRQS_MAX) { + return -1; + } + + ic = &sd->intr_ctrl[irq_num]; + + if (!ic->irq_active) { + return 0; + } + + wait_event_interruptible(ic->user_thread_wq, + atomic_read(&ic->run_user_thread) != 0); + atomic_set(&ic->run_user_thread, 0); + + return 0; +} + +int +ngbde_intr_stop(int kdev, unsigned int irq_num) +{ + struct ngbde_dev_s *sd; + struct ngbde_intr_ctrl_s *ic; + + sd = ngbde_swdev_get(kdev); + if (!sd) { + return -1; + } + + if (irq_num >= NGBDE_NUM_IRQS_MAX) { + return -1; + } + + ic = &sd->intr_ctrl[irq_num]; + + if (!ic->irq_active) { + return 0; + } + + /* Wake up user thread */ + atomic_set(&ic->run_user_thread, 1); + wake_up_interruptible(&ic->user_thread_wq); + + return 0; +} + +int +ngbde_intr_regs_clr(int kdev, unsigned int irq_num) +{ + struct ngbde_dev_s *sd; + struct ngbde_intr_ctrl_s *ic; + + sd = ngbde_swdev_get(kdev); + if (!sd) { + return -1; + } + + if (irq_num >= NGBDE_NUM_IRQS_MAX) { + return -1; + } + + ic = &sd->intr_ctrl[irq_num]; + + if (ic->irq_active) { + /* Do not clear configuration with interrupt connected */ + return 0; + } + + ic->num_regs = 0; + memset(ic->regs, 0, sizeof(ic->regs)); + + return 0; +} + +int +ngbde_intr_reg_add(int kdev, unsigned int irq_num, + struct ngbde_irq_reg_s *ireg) +{ + struct ngbde_dev_s *sd; + struct ngbde_intr_ctrl_s *ic; + struct ngbde_irq_reg_s *ir; + unsigned int idx; + + sd = ngbde_swdev_get(kdev); + if (!sd) { + return -1; + } + + if (irq_num >= NGBDE_NUM_IRQS_MAX) { + return -1; + } + + ic = &sd->intr_ctrl[irq_num]; + + if (ic->irq_active) { + /* + * If the interrupt is connected, then we only update the + * kernel mask for existing entries. + */ + for (idx = 0; idx < ic->num_regs; idx++) { + ir = &ic->regs[idx]; + if (ir->status_reg == ireg->status_reg && + ir->mask_reg == ireg->mask_reg) { + ir->kmask = ireg->kmask; + if (intr_debug) { + printk("INTR: Updating interrupt register " + "0x%08x/0x%08x (0x%08x)\n", + ir->status_reg, ir->mask_reg, ir->kmask); + } + return 0; + } + } + return -1; + } + + if (ic->num_regs >= NGBDE_NUM_IRQ_REGS_MAX) { + return -1; + } + + ir = &ic->regs[ic->num_regs++]; + + memcpy(ir, ireg, sizeof (*ir)); + + if (intr_debug) { + printk("INTR: Adding interrupt register 0x%08x/0x%08x (0x%08x)\n", + ir->status_reg, ir->mask_reg, ir->kmask); + } + + return ic->num_regs; +} + +int +ngbde_intr_ack_reg_add(int kdev, unsigned int irq_num, + struct ngbde_intr_ack_reg_s *ackreg) +{ + struct ngbde_dev_s *sd; + struct ngbde_intr_ctrl_s *ic; + struct ngbde_intr_ack_reg_s *ar; + + sd = ngbde_swdev_get(kdev); + if (!sd) { + return -1; + } + + if (irq_num >= NGBDE_NUM_IRQS_MAX) { + return -1; + } + + ic = &sd->intr_ctrl[irq_num]; + + if (ic->irq_active) { + /* Ignore request if interrupt is connected */ + return 0; + } + + ar = &ic->intr_ack; + + memcpy(ar, ackreg, sizeof (*ar)); + + if (intr_debug) { + printk("INTR: Adding interrupt ACK register 0x%08x/0x%08x (0x%08x)\n", + ar->ack_reg, ar->ack_val, ar->flags); + } + + return 0; +} + +int +ngbde_intr_mask_write(int kdev, unsigned int irq_num, int kapi, + uint32_t status_reg, uint32_t mask_val) +{ + struct ngbde_dev_s *sd; + struct ngbde_intr_ctrl_s *ic; + struct ngbde_irq_reg_s *ir; + unsigned int idx; + uint32_t bmask; + + sd = ngbde_swdev_get(kdev); + if (!sd) { + return -1; + } + + if (irq_num >= NGBDE_NUM_IRQS_MAX) { + return -1; + } + + ic = &sd->intr_ctrl[irq_num]; + + ir = ic->regs; + for (idx = 0; idx < ic->num_regs; idx++) { + if (ir->status_reg == status_reg) { + bmask = kapi ? ir->kmask : ~ir->kmask; + ngbde_intr_shared_write32(sd, ic, ir->mask_reg, mask_val, bmask); + return 0; + } + ir++; + } + + return -1; +} diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_ioctl.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_ioctl.c new file mode 100644 index 000000000000..ccd0b7ee01d0 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_ioctl.c @@ -0,0 +1,237 @@ +/*! \file ngbde_ioctl.c + * + * NGBDE IOCTL interface. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include + +#include + +long +ngbde_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct ngbde_ioc_cmd_s ioc; + struct ngbde_dev_s *swdev; + struct ngbde_irq_reg_s ireg; + struct ngbde_intr_ack_reg_s ackreg; + phys_addr_t addr, size; + unsigned int num_swdev; + unsigned int rsrc_type, rsrc_idx; + unsigned int irq_num, intr_cmd; + uint32_t mreg, mval; + + if (copy_from_user(&ioc, (void *)arg, sizeof(ioc))) { + return -EFAULT; + } + + ioc.rc = NGBDE_IOC_SUCCESS; + + switch (cmd) { + case NGBDE_IOC_MOD_INFO: + ioc.op.mod_info.version = NGBDE_IOC_VERSION; + break; + case NGBDE_IOC_PROBE_INFO: + ngbde_swdev_get_all(NULL, &num_swdev); + ioc.op.probe_info.num_swdev = num_swdev; + break; + case NGBDE_IOC_DEV_INFO: + swdev = ngbde_swdev_get(ioc.devid); + if (!swdev) { + ioc.rc = NGBDE_IOC_FAIL; + break; + } + ioc.op.dev_info.vendor_id = swdev->vendor_id; + ioc.op.dev_info.device_id = swdev->device_id; + ioc.op.dev_info.revision = swdev->revision; + ioc.op.dev_info.model = swdev->model; + if (swdev->use_msi) { + ioc.op.dev_info.flags |= NGBDE_DEV_F_MSI; + } + break; + case NGBDE_IOC_PHYS_ADDR: + swdev = ngbde_swdev_get(ioc.devid); + if (!swdev) { + ioc.rc = NGBDE_IOC_FAIL; + break; + } + rsrc_type = ioc.op.rsrc_id.type; + rsrc_idx = ioc.op.rsrc_id.inst; + switch (rsrc_type) { + case NGBDE_IO_RSRC_DEV_IO: + if (rsrc_idx >= NGBDE_NUM_IOWIN_MAX) { + printk(KERN_WARNING + "ngbde: invalid resource index (%d)\n", + rsrc_idx); + ioc.rc = NGBDE_IOC_FAIL; + break; + } + ioc.op.phys_addr.addr = swdev->iowin[rsrc_idx].addr; + ioc.op.phys_addr.size = swdev->iowin[rsrc_idx].size; + break; + case NGBDE_IO_RSRC_DMA_MEM: + if (rsrc_idx >= NGBDE_NUM_DMAPOOL_MAX) { + printk(KERN_WARNING + "ngbde: invalid resource index (%d)\n", + rsrc_idx); + ioc.rc = NGBDE_IOC_FAIL; + break; + } + ioc.op.phys_addr.addr = swdev->dmapool[rsrc_idx].dmamem.paddr; + ioc.op.phys_addr.size = swdev->dmapool[rsrc_idx].dmactrl.size; + break; + case NGBDE_IO_RSRC_DMA_BUS: + if (rsrc_idx >= NGBDE_NUM_DMAPOOL_MAX) { + printk(KERN_WARNING + "ngbde: invalid resource index (%d)\n", + rsrc_idx); + ioc.rc = NGBDE_IOC_FAIL; + break; + } + ioc.op.phys_addr.addr = swdev->dmapool[rsrc_idx].dmamem.baddr; + ioc.op.phys_addr.size = swdev->dmapool[rsrc_idx].dmactrl.size; + break; + default: + printk(KERN_WARNING + "ngbde: unknown resource type (%d)\n", + rsrc_type); + ioc.rc = NGBDE_IOC_FAIL; + break; + } + break; + case NGBDE_IOC_INTR_CTRL: + irq_num = ioc.op.intr_ctrl.irq_num; + intr_cmd = ioc.op.intr_ctrl.cmd; + switch (intr_cmd) { + case NGBDE_ICTL_INTR_CONN: + if (ngbde_intr_connect(ioc.devid, irq_num) < 0) { + ioc.rc = NGBDE_IOC_FAIL; + } + break; + case NGBDE_ICTL_INTR_DISC: + if (ngbde_intr_disconnect(ioc.devid, irq_num) < 0) { + ioc.rc = NGBDE_IOC_FAIL; + } + break; + case NGBDE_ICTL_INTR_WAIT: + if (ngbde_intr_wait(ioc.devid, irq_num) < 0) { + ioc.rc = NGBDE_IOC_FAIL; + } + break; + case NGBDE_ICTL_INTR_STOP: + if (ngbde_intr_stop(ioc.devid, irq_num) < 0) { + ioc.rc = NGBDE_IOC_FAIL; + } + break; + case NGBDE_ICTL_REGS_CLR: + if (ngbde_intr_regs_clr(ioc.devid, irq_num) < 0) { + ioc.rc = NGBDE_IOC_FAIL; + } + break; + default: + printk(KERN_WARNING + "%s: unknown interrupt control command (%d)\n", + MOD_NAME, intr_cmd); + ioc.rc = NGBDE_IOC_FAIL; + break; + } + break; + case NGBDE_IOC_IRQ_REG_ADD: + irq_num = ioc.op.irq_reg_add.irq_num; + ireg.status_reg = ioc.op.irq_reg_add.status_reg; + ireg.mask_reg = ioc.op.irq_reg_add.mask_reg; + ireg.kmask = ioc.op.irq_reg_add.kmask; + if (ngbde_intr_reg_add(ioc.devid, irq_num, &ireg) < 0) { + printk(KERN_WARNING + "%s: Unable to add interrupt register\n", + MOD_NAME); + ioc.rc = NGBDE_IOC_FAIL; + } + break; + case NGBDE_IOC_INTR_ACK_REG_ADD: + irq_num = ioc.op.intr_ack_reg_add.irq_num; + ackreg.ack_reg = ioc.op.intr_ack_reg_add.ack_reg; + ackreg.ack_val = ioc.op.intr_ack_reg_add.ack_val; + ackreg.flags = ioc.op.intr_ack_reg_add.flags; + if (ngbde_intr_ack_reg_add(ioc.devid, irq_num, &ackreg) < 0) { + printk(KERN_WARNING + "%s: Unable to add interrupt ack register\n", + MOD_NAME); + ioc.rc = NGBDE_IOC_FAIL; + } + break; + case NGBDE_IOC_IRQ_MASK_WR: + irq_num = ioc.op.irq_mask_wr.irq_num; + mreg = ioc.op.irq_mask_wr.offs; + mval = ioc.op.irq_mask_wr.val; + if (ngbde_intr_mask_write(ioc.devid, irq_num, 0, mreg, mval) < 0) { + printk(KERN_WARNING + "%s: Unable to write shared register\n", + MOD_NAME); + ioc.rc = NGBDE_IOC_FAIL; + } + break; + case NGBDE_IOC_PIO_WIN_MAP: + swdev = ngbde_swdev_get(ioc.devid); + if (!swdev) { + ioc.rc = NGBDE_IOC_FAIL; + break; + } + addr = ioc.op.pio_win.addr; + size = ioc.op.pio_win.size; + if (ngbde_pio_map(swdev, addr, size) == NULL) { + ioc.rc = NGBDE_IOC_FAIL; + } + break; + case NGBDE_IOC_IIO_WIN_MAP: + swdev = ngbde_swdev_get(ioc.devid); + if (!swdev) { + ioc.rc = NGBDE_IOC_FAIL; + break; + } + addr = ioc.op.pio_win.addr; + size = ioc.op.pio_win.size; + if (ngbde_iio_map(swdev, addr, size) == NULL) { + ioc.rc = NGBDE_IOC_FAIL; + } + break; + case NGBDE_IOC_PAXB_WIN_MAP: + swdev = ngbde_swdev_get(ioc.devid); + if (!swdev) { + ioc.rc = NGBDE_IOC_FAIL; + break; + } + addr = ioc.op.pio_win.addr; + size = ioc.op.pio_win.size; + if (ngbde_paxb_map(swdev, addr, size) == NULL) { + ioc.rc = NGBDE_IOC_FAIL; + } + break; + default: + printk(KERN_ERR "ngbde: invalid ioctl (%08x)\n", cmd); + ioc.rc = NGBDE_IOC_FAIL; + break; + } + + if (copy_to_user((void *)arg, &ioc, sizeof(ioc))) { + return -EFAULT; + } + + return 0; +} diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_iproc_probe.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_iproc_probe.c new file mode 100644 index 000000000000..63b02a4075a3 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_iproc_probe.c @@ -0,0 +1,164 @@ +/*! \file ngbde_iproc_probe.c + * + * BDE probe for IPROC internal bus devices. + * + * Validate CMICD existence on the platform. If Linux device tree matched, + * probe function of platform driver is called and the switch device read from + * CMICD register is added to the device list. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include + +/*! \cond */ +static int iproc_debug = 0; +module_param(iproc_debug, int, 0); +MODULE_PARM_DESC(iproc_debug, +"IPROC debug output enable (default 0)."); +/*! \endcond */ + +/*! + * \brief Probe devices on the IPROC internal bus. + * + * \param [in] pldev Platform device. + * + * \retval 0 No errors + * \retval -1 Something went wrong. + */ +static int +iproc_cmicd_probe(struct platform_device *pldev) +{ + int rv; + uint32_t size; + void *base_address; + uint32_t dev_rev_id; + struct ngbde_dev_s ngbde_dev, *nd = &ngbde_dev; + struct resource *memres, *irqres; + + memres = platform_get_resource(pldev, IORESOURCE_MEM, 0); + if (memres == NULL) { + printk("Unable to retrieve iProc CMIC memory resource."); + return -1; + } + size = memres->end - memres->start + 1; + + if (iproc_debug) { + printk("CMIC info : Memory start=%p, end=%p\n", + (void *)memres->start, (void *)memres->end); + } + + base_address = ioremap_nocache(memres->start, size); + if (!base_address) { + printk(KERN_WARNING "Error mapping iProc CMIC registers"); + return -1; + } + + memset(nd, 0, sizeof(*nd)); + nd->pci_dev = NULL; /* No PCI bus */ + nd->dma_dev = &pldev->dev; + + /* Read switch device ID from CMIC */ + dev_rev_id = *((uint32_t*)(base_address + 0x10224)); + nd->vendor_id = 0x14e4; + nd->device_id = dev_rev_id & 0xffff; + nd->revision = (dev_rev_id >> 16) & 0xff; + + irqres = platform_get_resource(pldev, IORESOURCE_IRQ, 0); + if (irqres == NULL) { + printk(KERN_WARNING "Unable to retrieve iProc CMIC IRQ resource."); + return -1; + } + nd->irq_line = irqres->start; + if (iproc_debug) { + printk("CMIC info : IRQ line=%p\n", (void *)irqres->start); + } + + nd->iowin[0].addr = memres->start; + nd->iowin[0].size = size; + + if (base_address) { + iounmap(base_address); + } + rv = ngbde_swdev_add(nd); + + return rv; +} + +/*! + * \brief Remove the platform device. + * + * \param [in] pldev Platform device. + * + * \retval 0 No errors + */ +static int +iproc_cmicd_remove(struct platform_device *pldev) +{ + return 0; +} + +/*! Matching compatible property with device tree. */ +static const struct of_device_id iproc_cmicd_of_match[] = { + { .compatible = "brcm,iproc-cmicd" }, + {}, +}; +MODULE_DEVICE_TABLE(of, iproc_cmicd_of_match); + +static char iproc_cmicd_string[] = "bcmiproc-cmicd"; + +/*! Platform driver definition. */ +static struct platform_driver iproc_cmicd_driver = +{ + .probe = iproc_cmicd_probe, + .remove = iproc_cmicd_remove, + .driver = + { + .name = iproc_cmicd_string, + .owner = THIS_MODULE, + .of_match_table = iproc_cmicd_of_match, + }, +}; + +/*! + * \brief Probe for Broadcom switch devices on IPROC internal bus. + * + * \return 0 if no errors, otherwise -1. + */ +int +ngbde_iproc_probe(void) +{ + platform_driver_register(&iproc_cmicd_driver); + + return 0; +} + +/*! + * \brief Clean up resources for Broadcom switch devices on IPROC internal bus. + * + * \return 0 if no errors, otherwise -1. + */ +int +ngbde_iproc_cleanup(void) +{ + platform_driver_unregister(&iproc_cmicd_driver); + + return 0; +} diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_kapi.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_kapi.c new file mode 100644 index 000000000000..340e7b057d44 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_kapi.c @@ -0,0 +1,216 @@ +/*! \file ngbde_kapi.c + * + * Public BDE kernel API for use with other kernel modules. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include + +#include + +struct pci_dev * +ngbde_kapi_pci_dev_get(int kdev) +{ + struct ngbde_dev_s *sd; + + sd = ngbde_swdev_get(kdev); + if (!sd) { + return NULL; + } + + return sd->pci_dev; +} +/*! \cond */ +EXPORT_SYMBOL(ngbde_kapi_pci_dev_get); +/*! \endcond */ + +struct device * +ngbde_kapi_dma_dev_get(int kdev) +{ + struct ngbde_dev_s *sd; + + sd = ngbde_swdev_get(kdev); + if (!sd) { + return NULL; + } + + return sd->dma_dev; +} +/*! \cond */ +EXPORT_SYMBOL(ngbde_kapi_dma_dev_get); +/*! \endcond */ + +void * +ngbde_kapi_dma_bus_to_virt(int kdev, dma_addr_t baddr) +{ + struct ngbde_dev_s *sd; + struct ngbde_dmamem_s *dmamem; + size_t dma_offset; + int idx; + + sd = ngbde_swdev_get(kdev); + if (!sd) { + return NULL; + } + + for (idx = 0; idx < NGBDE_NUM_DMAPOOL_MAX; idx++) { + dmamem = &sd->dmapool[idx].dmamem; + dma_offset = baddr - dmamem->baddr; + if (dma_offset < dmamem->size) { + return (uint8_t *)dmamem->vaddr + dma_offset; + } + } + return NULL; +} +/*! \cond */ +EXPORT_SYMBOL(ngbde_kapi_dma_bus_to_virt); +/*! \endcond */ + +dma_addr_t +ngbde_kapi_dma_virt_to_bus(int kdev, void *vaddr) +{ + struct ngbde_dev_s *sd; + struct ngbde_dmamem_s *dmamem; + size_t dma_offset; + int idx; + + sd = ngbde_swdev_get(kdev); + if (!sd) { + return 0UL; + } + + for (idx = 0; idx < NGBDE_NUM_DMAPOOL_MAX; idx++) { + dmamem = &sd->dmapool[idx].dmamem; + dma_offset = (uintptr_t)vaddr - (uintptr_t)dmamem->vaddr; + if (dma_offset < dmamem->size) { + return dmamem->baddr + dma_offset; + } + } + return 0UL; +} +/*! \cond */ +EXPORT_SYMBOL(ngbde_kapi_dma_virt_to_bus); +/*! \endcond */ + +void +ngbde_kapi_pio_write32(int kdev, uint32_t offs, uint32_t val) +{ + struct ngbde_dev_s *sd; + + sd = ngbde_swdev_get(kdev); + if (sd) { + return ngbde_pio_write32(sd, offs, val); + } +} +/*! \cond */ +EXPORT_SYMBOL(ngbde_kapi_pio_write32); +/*! \endcond */ + +uint32_t +ngbde_kapi_pio_read32(int kdev, uint32_t offs) +{ + struct ngbde_dev_s *sd; + + sd = ngbde_swdev_get(kdev); + if (sd) { + return ngbde_pio_read32(sd, offs); + } + + return (uint32_t)-1; +} +/*! \cond */ +EXPORT_SYMBOL(ngbde_kapi_pio_read32); +/*! \endcond */ + +void * +ngbde_kapi_pio_membase(int kdev) +{ + struct ngbde_dev_s *sd; + + sd = ngbde_swdev_get(kdev); + if (!sd) { + return NULL; + } + + return sd->pio_mem; +} +/*! \cond */ +EXPORT_SYMBOL(ngbde_kapi_pio_membase); +/*! \endcond */ + +int +ngbde_kapi_intr_connect(int kdev, unsigned int irq_num, + int (*isr_func)(void *), void *isr_data) +{ + struct ngbde_dev_s *sd; + struct ngbde_intr_ctrl_s *ic; + + sd = ngbde_swdev_get(kdev); + if (!sd) { + return -1; + } + + if (irq_num >= NGBDE_NUM_IRQS_MAX) { + return -1; + } + + ic = &sd->intr_ctrl[irq_num]; + ic->isr_func = isr_func; + ic->isr_data = isr_data; + + return 0; +} +/*! \cond */ +EXPORT_SYMBOL(ngbde_kapi_intr_connect); +/*! \endcond */ + +int +ngbde_kapi_intr_disconnect(int kdev, unsigned int irq_num) +{ + struct ngbde_dev_s *sd; + struct ngbde_intr_ctrl_s *ic; + + sd = ngbde_swdev_get(kdev); + if (!sd) { + return -1; + } + + if (irq_num >= NGBDE_NUM_IRQS_MAX) { + return -1; + } + + ic = &sd->intr_ctrl[irq_num]; + ic->isr_func = NULL; + ic->isr_data = NULL; + + return 0; +} +/*! \cond */ +EXPORT_SYMBOL(ngbde_kapi_intr_disconnect); +/*! \endcond */ + +int +ngbde_kapi_intr_mask_write(int kdev, unsigned int irq_num, + uint32_t status_reg, uint32_t mask_val) +{ + return ngbde_intr_mask_write(kdev, irq_num, 1, status_reg, mask_val); +} +/*! \cond */ +EXPORT_SYMBOL(ngbde_kapi_intr_mask_write); +/*! \endcond */ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_main.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_main.c new file mode 100644 index 000000000000..5ce48ebc5134 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_main.c @@ -0,0 +1,297 @@ +/*! \file ngbde_main.c + * + * NGBDE module entry. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include + +/*! \cond */ +MODULE_AUTHOR("Broadcom Corporation"); +MODULE_DESCRIPTION("NG BDE Module"); +MODULE_LICENSE("GPL"); +/*! \endcond */ + +/*! \cond */ +static int mmap_debug = 0; +module_param(mmap_debug, int, 0); +MODULE_PARM_DESC(mmap_debug, +"MMAP debug output enable (default 0)."); +/*! \endcond */ + +/*! + * \brief Remap user space DMA memory to non-cached area. + * + * Since we cannot flush and invalidate DMA memory from user space, + * the DMA memory pools need to be cache-coherent, even if this means + * that we need to remap the DMA memory as non-cached. + * + * If undefined, we set this value according to kernel configuration. + */ +#ifndef REMAP_DMA_NONCACHED +# ifdef CONFIG_DMA_NONCOHERENT +# define REMAP_DMA_NONCACHED 1 +# else +# define REMAP_DMA_NONCACHED 0 +# endif +#endif + +static int +ngbde_open(struct inode *inode, struct file *filp) +{ + return 0; +} + +static int +ngbde_release(struct inode *inode, struct file *filp) +{ + return 0; +} + +/*! + * \brief Check if memory range is within existing DMA memory pools. + * + * \param [in] paddr Physical start address of memory range. + * \param [in] size Size of memory range. + * + * \retval true Range is valid. + * \retval false Range is not valid. + */ +static bool +ngbde_dma_range_valid(unsigned long paddr, unsigned long size) +{ + struct ngbde_dev_s *swdev; + unsigned int num_swdev, idx; + struct ngbde_dmamem_s *dmamem; + unsigned int pool; + + ngbde_swdev_get_all(&swdev, &num_swdev); + + for (idx = 0; idx < num_swdev; idx++) { + for (pool = 0; pool < NGBDE_NUM_DMAPOOL_MAX; pool++) { + dmamem = &swdev[idx].dmapool[pool].dmamem; + if (paddr >= dmamem->paddr && + (paddr + size) <= (dmamem->paddr + dmamem->size)) { + return true; + } + } + } + return false; +} + +/*! + * \brief Check if memory range is within device I/O ranges. + * + * \param [in] paddr Physical start address of I/O memory range. + * \param [in] size Size of memory range. + * + * \retval true Range is valid. + * \retval false Range is not valid. + */ +static bool +ngbde_pio_range_valid(unsigned long paddr, unsigned long size) +{ + struct ngbde_dev_s *swdev; + unsigned int num_swdev, idx; + struct ngbde_memwin_s *iowin; + unsigned long iowin_size; + unsigned int wdx; + + ngbde_swdev_get_all(&swdev, &num_swdev); + + for (idx = 0; idx < num_swdev; idx++) { + for (wdx = 0; wdx < NGBDE_NUM_IOWIN_MAX; wdx++) { + iowin = &swdev[idx].iowin[wdx]; + iowin_size = iowin->size; + if (iowin_size < PAGE_SIZE) { + iowin_size = PAGE_SIZE; + } + if (mmap_debug) { + printk("MMAP: Check 0x%08lx/0x%08lx against " + "0x%08lx/0x%08lx(0x%08lx)\n", + paddr, size, + (unsigned long)iowin->addr, + (unsigned long)iowin->size, iowin_size); + } + if (paddr >= iowin->addr && + (paddr + size) <= (iowin->addr + iowin_size)) { + return true; + } + } + } + return false; +} + +/*! + * \brief Match incomplete address with device base addresses. + * + * Use for physical addresses larger than 44 bits. + * + * \param [in] paddr Physical address from user space. + * + * \return Matched device base addess or 0 if no match. + */ +static unsigned long +ngbde_pio_base_match(unsigned long paddr) +{ + struct ngbde_dev_s *swdev; + unsigned int num_swdev, idx; + struct ngbde_memwin_s *iowin; + unsigned int wdx; + + ngbde_swdev_get_all(&swdev, &num_swdev); + + for (idx = 0; idx < num_swdev; idx++) { + for (wdx = 0; wdx < NGBDE_NUM_IOWIN_MAX; wdx++) { + iowin = &swdev[idx].iowin[wdx]; + if (((paddr ^ iowin->addr) & 0xfffffffffffULL) == 0) { + if (mmap_debug) { + printk("MMAP: Matched 0x%08lx to 0x%08lx\n", + (unsigned long)paddr, + (unsigned long)iowin->addr); + } + return iowin->addr; + } + } + } + return 0; +} + +/* + * Some kernels are configured to prevent mapping of kernel RAM memory + * into user space via the /dev/mem device. + * + * The function below provides a backdoor to mapping the DMA pool to + * user space via the BDE device file. + */ +static int +ngbde_mmap(struct file *filp, struct vm_area_struct *vma) +{ + unsigned long paddr = vma->vm_pgoff << PAGE_SHIFT; + unsigned long size = vma->vm_end - vma->vm_start; + int map_noncached = REMAP_DMA_NONCACHED; + int range_valid = 0; + + if (mmap_debug) { + printk("MMAP: Mapping %lu Kbytes at 0x%08lx (0x%lx)\n", + size / 1024, paddr, vma->vm_pgoff); + } + + if (ngbde_dma_range_valid(paddr, size)) { + range_valid = 1; + } else { + map_noncached = 1; + if (ngbde_pio_range_valid(paddr, size)) { + range_valid = 1; + } else { + paddr = ngbde_pio_base_match(paddr); + if (ngbde_pio_range_valid(paddr, size)) { + range_valid = 1; + } + } + } + + if (!range_valid) { + printk("BDE: Invalid mmap range 0x%08lx/0x%lx\n", paddr, size); + return -EINVAL; + } + + if (map_noncached) { + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + } + + if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, + size, vma->vm_page_prot)) { + printk("BDE: Failed to mmap phys range 0x%lx-0x%lx to 0x%lx-0x%lx\n", + paddr, paddr + size, vma->vm_start, vma->vm_end); + return -EAGAIN; + } + + return 0; +} + +static struct file_operations fops = { + .open = ngbde_open, + .release = ngbde_release, + .unlocked_ioctl = ngbde_ioctl, + .compat_ioctl = ngbde_ioctl, + .mmap = ngbde_mmap, +}; + +/*! + * \brief Standard module cleanup. + * + * \return Nothing. + */ +void __exit +cleanup_module(void) +{ + ngbde_intr_cleanup(); + ngbde_iio_cleanup(); + ngbde_paxb_cleanup(); + ngbde_pio_cleanup(); + ngbde_dma_cleanup(); + ngbde_procfs_cleanup(); + unregister_chrdev(MOD_MAJOR, MOD_NAME); + ngbde_pci_cleanup(); + ngbde_iproc_cleanup(); + printk(KERN_INFO "Broadcom NGBDE unloaded successfully\n"); +} + +/*! + * \brief Standard module initialization. + * + * \return Nothing. + */ +int __init +init_module(void) +{ + int rv; + + rv = register_chrdev(MOD_MAJOR, MOD_NAME, &fops); + if (rv < 0) { + printk(KERN_WARNING "%s: can't get major %d\n", + MOD_NAME, MOD_MAJOR); + return rv; + } + + rv = ngbde_iproc_probe(); + if (rv < 0) { + printk(KERN_WARNING "%s: Error probing for AXI bus devices.\n", + MOD_NAME); + return rv; + } + + rv = ngbde_pci_probe(); + if (rv < 0) { + printk(KERN_WARNING "%s: Error probing for PCI bus devices.\n", + MOD_NAME); + return rv; + } + + rv = ngbde_procfs_init(); + if (rv < 0) { + printk(KERN_WARNING "%s: Unable to initialize proc files\n", + MOD_NAME); + return rv; + } + + printk(KERN_INFO "Broadcom NGBDE loaded successfully\n"); + return 0; +} diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pci_probe.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pci_probe.c new file mode 100644 index 000000000000..37da39cd38a7 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pci_probe.c @@ -0,0 +1,211 @@ +/*! \file ngbde_pci_probe.c + * + * NG BDE probe for PCI devices. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include + +/*! \cond */ +static int use_msi = 1; +module_param(use_msi, int, 0); +MODULE_PARM_DESC(use_msi, +"Use MSI interrupts if supported by the kernel (default 1)."); +/*! \endcond */ + +/*! \cond */ +static int pci_debug = 0; +module_param(pci_debug, int, 0); +MODULE_PARM_DESC(pci_debug, +"PCI debug output enable (default 0)."); +/*! \endcond */ + +/*! + * Use BCMDRD_DEVLIST_ENTRY macro to generate a device list based on + * supported/installed devices. + */ +#define BCMDRD_DEVLIST_ENTRY(_nm,_vn,_dv,_rv,_md,_pi,_bd,_bc,_fn,_cn,_pf,_pd,_r0,_r1) \ + { _vn, _dv, PCI_ANY_ID, PCI_ANY_ID }, + +/*! Include all chip variants in the list of supported devices. */ +#define BCMDRD_DEVLIST_INCLUDE_ALL + +static struct pci_device_id pci_id_table[] = { +#include + { BROADCOM_VENDOR_ID, 0xb524, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, 0xb684, PCI_ANY_ID, PCI_ANY_ID }, + { 0, 0, 0, 0 } +}; + +static int +pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *ent) +{ + int rv; + int bdx; + int cmic_bar = 0; + uint8_t rev; + struct ngbde_dev_s ngbde_dev, *nd = &ngbde_dev; + int bus_no = pci_dev->bus ? pci_dev->bus->number : 0; + int slot_no = PCI_SLOT(pci_dev->devfn); + + if (PCI_FUNC(pci_dev->devfn) > 0) { + return 0; + } + + if (pci_debug) { + printk("PCI: pci_probe: bus %d slot %d: %04x:%04x\n", + bus_no, slot_no, + pci_dev->vendor, pci_dev->device); + } + + memset(nd, 0, sizeof(*nd)); + nd->pci_dev = pci_dev; + nd->dma_dev = &pci_dev->dev; + nd->vendor_id = pci_dev->vendor; + nd->device_id = pci_dev->device; + nd->bus_no = bus_no; + nd->slot_no = slot_no; + + /* PCI revision must extracted "manually */ + pci_read_config_byte(pci_dev, PCI_REVISION_ID, &rev); + nd->revision = rev; + + if (pci_enable_device(pci_dev)) { + printk(KERN_WARNING "%s: Cannot enable PCI device: " + "vendor_id = %x, device_id = %x\n", + MOD_NAME, pci_dev->vendor, pci_dev->device); + } + pci_set_master(pci_dev); + + /* IRQ number is only valid if PCI device is enabled */ + nd->irq_line = pci_dev->irq; + + /* Check for iProc */ + if (pci_resource_len(pci_dev, 2)) { + nd->iowin[1].addr = pci_resource_start(pci_dev, 0); + nd->iowin[1].size = pci_resource_len(pci_dev, 0); + cmic_bar = 2; + } + nd->iowin[0].addr = pci_resource_start(pci_dev, cmic_bar); + nd->iowin[0].size = pci_resource_len(pci_dev, cmic_bar); + + /* Verify basic I/O access by reading first word of each BAR window */ + for (bdx = 0; bdx < 2; bdx++) { + if (nd->iowin[bdx].size == 0) { + continue; + } + if (ngbde_pio_map(nd, nd->iowin[bdx].addr, nd->iowin[bdx].size)) { + if (pci_debug) { + printk("PCI: BAR %d adddress 0 = 0x%x\n", + bdx, (unsigned int)ngbde_pio_read32(nd, 0)); + } + ngbde_pio_unmap(nd); + } else { + printk(KERN_WARNING "%s: Cannot map PCI BAR %d: " + "start = %08lx, len = %lx\n", + MOD_NAME, bdx, + (unsigned long)nd->iowin[bdx].addr, + (unsigned long)nd->iowin[bdx].size); + } + } + + spin_lock_init(&nd->lock); + + /* Determine MSI configuration by enabling MSI on the device */ + nd->use_msi = use_msi; + if (nd->use_msi) { + if (pci_enable_msi(nd->pci_dev) == 0) { + pci_disable_msi(nd->pci_dev); + } else { + nd->use_msi = 0; + } + } + + rv = ngbde_swdev_add(nd); + + if (rv == 0) { + /* Update DMA pools for all devices */ + rv = ngbde_dma_init(); + if (rv < 0) { + printk(KERN_WARNING "%s: Error initializing DMA memory\n", + MOD_NAME); + /* Mark device as inactive */ + nd->inactive = 1; + } + } + + return rv; +} + +static void +pci_remove(struct pci_dev* pci_dev) +{ + struct ngbde_dev_s *swdev; + unsigned int num_swdev, idx; + int bus_no = pci_dev->bus ? pci_dev->bus->number : 0; + int slot_no = PCI_SLOT(pci_dev->devfn); + + if (pci_debug) { + printk("PCI: pci_remove: bus %d slot %d: %04x:%04x\n", + bus_no, slot_no, + pci_dev->vendor, pci_dev->device); + } + + ngbde_swdev_get_all(&swdev, &num_swdev); + for (idx = 0; idx < num_swdev; idx++) { + if (swdev[idx].bus_no == bus_no && + swdev[idx].slot_no == slot_no) { + if (swdev[idx].inactive) { + printk(KERN_WARNING "%s: Device already removed\n", + MOD_NAME); + } + /* Active device in this slot already? */ + swdev[idx].inactive = 1; + } + } + + /* Update DMA pools for all devices */ + ngbde_dma_cleanup(); +} + +static struct pci_driver pci_driver = { + .name = MOD_NAME, + .probe = pci_probe, + .remove = pci_remove, + .id_table = pci_id_table, + /* The rest are dynamic */ +}; + +int +ngbde_pci_probe(void) +{ + if (pci_register_driver(&pci_driver) < 0) { + return -ENODEV; + } + + return 0; +} + +int +ngbde_pci_cleanup(void) +{ + pci_unregister_driver(&pci_driver); + + return 0; +} diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pgmem.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pgmem.c new file mode 100644 index 000000000000..e473f0c545cb --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pgmem.c @@ -0,0 +1,472 @@ +/*! \file ngbde_pgmem.c + * + * \brief PGMEM allocator. + * + * This module is used to allocate large physically contiguous memory + * blocks using the Linux kernel page allocator. + * + * The Linux page allocator can allocate contiguous memory up until a + * certain size, which depends on the kernel version and the CPU + * architecture. + * + * If a larger contiguous memory block is requested, then we need to + * allocate multiple blocks from the Linux page allocator and then + * check if which ones are contiguous. + * + * The smaller memory blocks from which the larger block is assembled + * are referred to as "chunks". + * + * The PGMEM allocator will continue to allocate chunks from the Linux + * page allocator, until a contiguous memory block of the requested + * size has been assembled, or until a predefined maximum number of + * chunks have been allocated. Obviously the process is also stopped + * if the Linux page allocator returns an error. + * + * A physically contiguous memory block assembled from smaller memory + * chunks are referred to as "cmblocks". + * + * The chance of success depends on the requested memory block size as + * well as the fragmentation level of the system memory, i.e. the + * sooner after system boot these memory block are requested, the more + * likely these requests are to succeed. + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include + + +/******************************************************************************* + * Local definitions + ******************************************************************************/ + +/*! Maximum size the kernel can allocate in a single allocation. */ +#define MEM_CHUNK_SIZE_MAX (1 << (MAX_ORDER - 1 + PAGE_SHIFT)) + +/*! Default block size we wil request from the kernel. */ +#define MEM_CHUNK_SIZE_DEFAULT (512 * ONE_KB) + +/*! \cond */ +static int pgmem_chunk_size = 0; +module_param(pgmem_chunk_size, int, 0); +MODULE_PARM_DESC(pgmem_chunk_size, +"Memory chunk size in KB used by page allocator (default auto)."); +/*! \endcond */ + +/*! \cond */ +static int pgmem_debug = 0; +module_param(pgmem_debug, int, 0); +MODULE_PARM_DESC(pgmem_debug, +"Enable page memory allocator debug output (default 0)."); +/*! \endcond */ + +/*! Helper macro for debug trace output. */ +#define PGMEM_TRACE(_s) \ + do { \ + if (pgmem_debug) { \ + printk(_s); \ + } \ + } while (0) + +/*! + * Chunk memory block descriptor. + */ +typedef struct cmblock_desc_s { + + /*! Linked-list handle. */ + struct list_head list; + + /*! Requested cmblock size. */ + unsigned long req_size; + + /*! Memory chunk size. */ + unsigned long chunk_size; + + /*! Memory chunk size in alternate format (2^x). */ + unsigned long chunk_order; + + /*! Current cmblock size. */ + unsigned long cmblk_size; + + /*! Logical address of cmblock. */ + unsigned long cmblk_begin; + + /*! Logical end address of cmblock. */ + unsigned long cmblk_end; + + /*! Array of logical chunk addresses. */ + unsigned long *chunk_ptr; + + /*! Maximum number of chunks to allocate. */ + int chunk_cnt_max; + + /*! Current number of chunks allocated. */ + int chunk_cnt; + +} cmblock_desc_t; + +static LIST_HEAD(cmblocks_list); + + +/*! + * \name Chunk tag mask. + * \anchor CT_xxx + * + * The lower two bits of the chunk address is used to tag the chunk + * with its current state. + */ +#define CT_MASK 0x3 + +/*! Chunk is untagged. */ +#define CT_UNTAGGED 0 + +/*! Chunk was discarded. */ +#define CT_DISCARDED 1 + +/*! Chunk is part of largest cmblock. */ +#define CT_LARGEST 2 + +/*! Chunk is part of current cmblock. */ +#define CT_CURRENT 3 + +/*! Set block as untagged. */ +#define CTAG_SET(_a, _t) \ + do { \ + (_a) &= ~CT_MASK; \ + (_a) |= _t; \ + } while (0) + +/*! Set block as untagged. */ +#define CTAG_GET(_a) \ + ((_a) & CT_MASK) + + +/******************************************************************************* + * Private Functions + ******************************************************************************/ + +/*! + * \brief Find largest contiguous memory block. + * + * Find largest contiguous memory block from a pool of memory chunks. + * + * Assembly stops if a cmblock of the requested cmblock size has been + * obtained. + * + * The lower two address bits of the memory chunks are encoded as a + * tag according to \ref CT_xxx. + * + * \param [in] cmbd cmblock descriptor. + * + * \return Always 0. + */ +static int +find_largest_cmblock(cmblock_desc_t *cmbd) +{ + int i, j, chunks, found; + unsigned long b, e, a; + unsigned long *cptr; + + /* Convenience variable */ + chunks = cmbd->chunk_cnt; + cptr = cmbd->chunk_ptr; + + /* Clear all chunk tags */ + for (i = 0; i < chunks; i++) { + CTAG_SET(cptr[i], CT_UNTAGGED); + } + for (i = 0; i < chunks && cmbd->cmblk_size < cmbd->req_size; i++) { + /* First chunk must be an untagged chunk */ + if (CTAG_GET(cptr[i]) == CT_UNTAGGED) { + /* Initial cmblock size is the chunk size */ + b = cptr[i]; + e = b + cmbd->chunk_size; + CTAG_SET(cptr[i], CT_CURRENT); + /* Loop looking for adjacent chunks */ + do { + found = 0; + for (j = i + 1; j < chunks && (e - b) < cmbd->req_size; j++) { + a = cptr[j]; + /* Check untagged chunks only */ + if (CTAG_GET(a) == CT_UNTAGGED) { + if (a == (b - cmbd->chunk_size)) { + /* Found adjacent chunk below current cmblock */ + CTAG_SET(cptr[j], CT_CURRENT); + b = a; + found = 1; + } else if (a == e) { + /* Found adjacent chunk above current cmblock */ + CTAG_SET(cptr[j], CT_CURRENT); + e += cmbd->chunk_size; + found = 1; + } + } + } + } while (found); + /* Now check the size of the assembled memory block */ + if ((e - b) > cmbd->cmblk_size) { + /* The current block is largest so far */ + cmbd->cmblk_begin = b; + cmbd->cmblk_end = e; + cmbd->cmblk_size = e - b; + /* Re-tag current and previous largest cmblock */ + for (j = 0; j < chunks; j++) { + if (CTAG_GET(cptr[j]) == CT_CURRENT) { + /* Tag current cmblock as the largest */ + CTAG_SET(cptr[j], CT_LARGEST); + } else if (CTAG_GET(cptr[j]) == CT_LARGEST) { + /* Discard previous largest cmblock */ + CTAG_SET(cptr[j], CT_DISCARDED); + } + } + } else { + /* Discard all chunks in current cmblock */ + for (j = 0; j < chunks; j++) { + if (CTAG_GET(cptr[j]) == CT_CURRENT) { + CTAG_SET(cptr[j], CT_DISCARDED); + } + } + } + } + } + return 0; +} + +/*! + * \brief Allocate memory chunks and add them to the pool. + * + * Memory chunks are allocated using the kernel page allocator. + * + * \param [in] cmbd - cmblock descriptor. + * \param [in] chunks - Number of memory chunks to allocate. + * + * \return 0 if no errors, otherwise -1. + */ +static int +alloc_mem_chunks(cmblock_desc_t *cmbd, int chunks) +{ + int i, start; + unsigned long addr; + + if (cmbd->chunk_cnt + chunks > cmbd->chunk_cnt_max) { + printk("PGMEM: No more memory chunks\n"); + return -1; + } + start = cmbd->chunk_cnt; + cmbd->chunk_cnt += chunks; + for (i = start; i < cmbd->chunk_cnt; i++) { + /* Get chunk from kernel allocator */ + addr = __get_free_pages(GFP_KERNEL | GFP_DMA32, cmbd->chunk_order); + PGMEM_TRACE("."); + if (addr) { + cmbd->chunk_ptr[i] = addr; + } else { + printk("PGMEM: Page memory allocation failed\n"); + return -1; + } + } + return 0; +} + +/*! + * \brief Allocate large physically contiguous memory block. + * + * If we cannot allocate a sufficiently large block of contiguous + * memory from the kernel, then we simply keep allocating smaller + * chunks until we can assemble a contiguous block of the desired + * size. + * + * When maximum amount of system memory has been allocated without the + * successful assembly of a contiguous memory block, the allocation + * function will return the largest contiguous block found so far. It + * is then up to the calling function to decide whether this amount is + * sufficient to proceed. + * + * \param [in] size Requested memory block size. + * \param [in] chunk_size Assemble cmblock from chunks of this size. + * + * \return Pointer to cmblock descriptor, or NULL if error. + */ +static cmblock_desc_t * +cmblock_alloc(size_t size, size_t chunk_size) +{ + cmblock_desc_t *cmbd; + int i, chunk_ptr_size; + unsigned long page_addr; + struct sysinfo si; + + /* Sanity check */ + if (size == 0 || chunk_size == 0) { + return NULL; + } + + /* Allocate an initialize memory cmblock descriptor */ + if ((cmbd = kmalloc(sizeof(cmblock_desc_t), GFP_KERNEL)) == NULL) { + return NULL; + } + memset(cmbd, 0, sizeof(*cmbd)); + cmbd->req_size = size; + cmbd->chunk_size = PAGE_ALIGN(chunk_size); + while ((PAGE_SIZE << cmbd->chunk_order) < cmbd->chunk_size) { + cmbd->chunk_order++; + } + + /* Determine the maximum possible number of memory chunks */ + si_meminfo(&si); + cmbd->chunk_cnt_max = (si.totalram << PAGE_SHIFT) / cmbd->chunk_size; + chunk_ptr_size = cmbd->chunk_cnt_max * sizeof(unsigned long); + + /* Allocate an initialize memory chunk pool */ + cmbd->chunk_ptr = kmalloc(chunk_ptr_size, GFP_KERNEL); + if (cmbd->chunk_ptr == NULL) { + kfree(cmbd); + return NULL; + } + memset(cmbd->chunk_ptr, 0, chunk_ptr_size); + + /* Allocate minimum number of memory chunks */ + (void)alloc_mem_chunks(cmbd, cmbd->req_size / cmbd->chunk_size); + + /* Allocate more chunks until we have a complete cmblock */ + do { + find_largest_cmblock(cmbd); + PGMEM_TRACE("o"); + if (cmbd->cmblk_size >= cmbd->req_size) { + break; + } + } while (alloc_mem_chunks(cmbd, 8) == 0); + + /* Reserve all pages in the cmblock and free unused chunks */ + for (i = 0; i < cmbd->chunk_cnt; i++) { + if (CTAG_GET(cmbd->chunk_ptr[i]) == CT_LARGEST) { + CTAG_SET(cmbd->chunk_ptr[i], CT_UNTAGGED); + for (page_addr = cmbd->chunk_ptr[i]; + page_addr < cmbd->chunk_ptr[i] + cmbd->chunk_size; + page_addr += PAGE_SIZE) { + SetPageReserved(virt_to_page((void *)page_addr)); + } + } else if (cmbd->chunk_ptr[i]) { + CTAG_SET(cmbd->chunk_ptr[i], CT_UNTAGGED); + free_pages(cmbd->chunk_ptr[i], cmbd->chunk_order); + PGMEM_TRACE("x"); + cmbd->chunk_ptr[i] = 0; + } + } + PGMEM_TRACE("O\n"); + return cmbd; +} + +/*! + * \brief Free cmblock and associated resources. + * + * Free all memory chunks and other associated resources associated + * with a contiguous memory block. + * + * See alse \ref cmblock_alloc. + * + * \param [in] cmbd Command block descriptor to free. + * + * \return Nothing. + */ +static void +cmblock_free(cmblock_desc_t *cmbd) +{ + int i; + unsigned long page_addr; + + if (cmbd->chunk_ptr) { + for (i = 0; i < cmbd->chunk_cnt; i++) { + if (cmbd->chunk_ptr[i]) { + for (page_addr = cmbd->chunk_ptr[i]; + page_addr < cmbd->chunk_ptr[i] + cmbd->chunk_size; + page_addr += PAGE_SIZE) { + ClearPageReserved(virt_to_page((void *)page_addr)); + } + free_pages(cmbd->chunk_ptr[i], cmbd->chunk_order); + PGMEM_TRACE("X"); + } + } + kfree(cmbd->chunk_ptr); + kfree(cmbd); + } +} + + +/******************************************************************************* + * Public Functions + ******************************************************************************/ + +void * +ngbde_pgmem_alloc(size_t size, gfp_t flags) +{ + cmblock_desc_t *cmbd; + size_t chunk_size; + + chunk_size = size; + + if (pgmem_chunk_size > 0) { + chunk_size = pgmem_chunk_size * ONE_KB; + } + + if (chunk_size > MEM_CHUNK_SIZE_MAX) { + chunk_size = MEM_CHUNK_SIZE_DEFAULT; + } + + if (pgmem_debug) { + printk("PGMEM: Allocate %d MB in %d KB chunks\n", + (int)(size / ONE_MB), (int)(chunk_size / ONE_KB)); + } + + if ((cmbd = cmblock_alloc(size, chunk_size)) == NULL) { + return NULL; + } + if (cmbd->cmblk_size < size) { + /* If we didn't get the full size then forget it */ + cmblock_free(cmbd); + return NULL; + } + list_add(&cmbd->list, &cmblocks_list); + return (void *)cmbd->cmblk_begin; +} + +int +ngbde_pgmem_free(void *ptr) +{ + struct list_head *pos; + + list_for_each(pos, &cmblocks_list) { + cmblock_desc_t *cmbd = list_entry(pos, cmblock_desc_t, list); + if (ptr == (void *)cmbd->cmblk_begin) { + list_del(&cmbd->list); + cmblock_free(cmbd); + return 0; + } + } + return -1; +} + +void +ngbde_pgmem_free_all(void) +{ + struct list_head *pos, *tmp; + + list_for_each_safe(pos, tmp, &cmblocks_list) { + cmblock_desc_t *cmbd = list_entry(pos, cmblock_desc_t, list); + list_del(&cmbd->list); + cmblock_free(cmbd); + } +} diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pio.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pio.c new file mode 100644 index 000000000000..cab094a2feca --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pio.c @@ -0,0 +1,97 @@ +/*! \file ngbde_pio.c + * + * API for managing and accessing memory-mapped I/O for switch + * registers. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include + +void * +ngbde_pio_map(void *devh, phys_addr_t addr, phys_addr_t size) +{ + struct ngbde_dev_s *sd = (struct ngbde_dev_s *)devh; + + if (sd->pio_mem) { + if (addr == sd->pio_win.addr && size == sd->pio_win.size) { + /* Already mapped */ + return sd->pio_mem; + } + ngbde_pio_unmap(devh); + } + + sd->pio_mem = ioremap_nocache(addr, size); + + if (sd->pio_mem) { + /* Save mapped resources */ + sd->pio_win.addr = addr; + sd->pio_win.size = size; + } else { + printk(KERN_WARNING "%s: Unable to map address 0x%08lu\n", + MOD_NAME, (unsigned long)addr); + } + + return sd->pio_mem; +} + +void +ngbde_pio_unmap(void *devh) +{ + struct ngbde_dev_s *sd = (struct ngbde_dev_s *)devh; + + if (sd->pio_mem) { + iounmap(sd->pio_mem); + sd->pio_mem = NULL; + } +} + +void +ngbde_pio_cleanup(void) +{ + struct ngbde_dev_s *swdev, *sd; + unsigned int num_swdev, idx; + + ngbde_swdev_get_all(&swdev, &num_swdev); + + for (idx = 0; idx < num_swdev; idx++) { + sd = ngbde_swdev_get(idx); + ngbde_pio_unmap(sd); + } +} + +void +ngbde_pio_write32(void *devh, uint32_t offs, uint32_t val) +{ + struct ngbde_dev_s *sd = (struct ngbde_dev_s *)devh; + + if (sd->pio_mem) { + NGBDE_IOWRITE32(val, sd->pio_mem + offs); + } +} + +uint32_t +ngbde_pio_read32(void *devh, uint32_t offs) +{ + struct ngbde_dev_s *sd = (struct ngbde_dev_s *)devh; + + if (sd->pio_mem) { + return NGBDE_IOREAD32(sd->pio_mem + offs); + } + return 0; +} diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_procfs.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_procfs.c new file mode 100644 index 000000000000..f99339a5b0dc --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_procfs.c @@ -0,0 +1,120 @@ +/*! \file ngbde_procfs.c + * + * + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include + +static int +proc_show(struct seq_file *m, void *v) +{ + struct ngbde_dev_s *swdev; + unsigned int num_swdev, idx; + struct ngbde_dmamem_s *dmamem; + unsigned int pool; + unsigned int dma_pools; + char *dma_str; + + ngbde_swdev_get_all(&swdev, &num_swdev); + + seq_printf(m, "Broadcom Device Enumerator (%s)\n", MOD_NAME); + + seq_printf(m, "Found %d switch device(s):\n", num_swdev); + for (idx = 0; idx < num_swdev; idx++) { + if (swdev->inactive) { + seq_printf(m, "%d:removed\n", idx); + continue; + } + seq_printf(m, "%d:%04x:%04x:%02x,%s(%d)\n", idx, + swdev->vendor_id, swdev->device_id, swdev->revision, + swdev->use_msi ? "MSI" : "IRQ", swdev->irq_line); + } + + seq_printf(m, "DMA pools:\n"); + for (idx = 0; idx < num_swdev; idx++) { + seq_printf(m, "%d", idx); + dma_pools = 0; + for (pool = 0; pool < NGBDE_NUM_DMAPOOL_MAX; pool++) { + dmamem = &swdev[idx].dmapool[pool].dmamem; + dma_str = "unknown"; + if (dmamem->type == NGBDE_DMA_T_NONE) { + /* Skip empty DMA pools */ + continue; + } else if (dmamem->type == NGBDE_DMA_T_KAPI) { + dma_str = "kapi"; + } else if (dmamem->type == NGBDE_DMA_T_PGMEM) { + dma_str = "pgmem"; + } + seq_printf(m, ":%dMB@0x%08lx(%s)", + (int)(dmamem->size / ONE_MB), + (unsigned long)dmamem->baddr, dma_str); + dma_pools++; + } + if (dma_pools == 0) { + seq_printf(m, ":none"); + } + seq_printf(m, "\n"); + } + + return 0; +} + +static int +proc_open(struct inode *inode, struct file *file) +{ + return single_open(file, proc_show, NULL); +} + +static int +proc_release(struct inode *inode, struct file *file) +{ + return single_release(inode, file); +} + +static struct file_operations proc_fops = { + owner: THIS_MODULE, + open: proc_open, + read: seq_read, + llseek: seq_lseek, + release: proc_release, +}; + +int +ngbde_procfs_init(void) +{ + struct proc_dir_entry *entry; + + PROC_CREATE(entry, MOD_NAME, 0666, NULL, &proc_fops); + + if (entry == NULL) { + printk(KERN_ERR "ngbde: proc_create failed\n"); + return -1; + } + + return 0; +} + +int +ngbde_procfs_cleanup(void) +{ + remove_proc_entry(MOD_NAME, NULL); + + return 0; +} diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_swdev.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_swdev.c new file mode 100644 index 000000000000..60d328ad2526 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_swdev.c @@ -0,0 +1,79 @@ +/*! \file ngbde_swdev.c + * + * + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include + +/* Switch devices */ +static struct ngbde_dev_s swdevs[NGBDE_NUM_SWDEV_MAX]; + +/* Number of probed switch devices */ +static unsigned int num_swdev; + +int +ngbde_swdev_add(struct ngbde_dev_s *nd) +{ + unsigned int idx; + + /* Look for existing slot */ + for (idx = 0; idx < num_swdev; idx++) { + if (swdevs[idx].bus_no == nd->bus_no && + swdevs[idx].slot_no == nd->slot_no) { + if (swdevs[idx].inactive) { + memcpy(&swdevs[idx], nd, sizeof(swdevs[0])); + return 0; + } + /* Active device in this slot already? */ + printk(KERN_WARNING "%s: Device exists\n", + MOD_NAME); + return -EBUSY; + } + } + + /* Add new device */ + if (num_swdev >= NGBDE_NUM_SWDEV_MAX) { + return -ENOMEM; + } + memcpy(&swdevs[num_swdev], nd, sizeof(swdevs[0])); + ++num_swdev; + return 0; +} + +struct ngbde_dev_s * +ngbde_swdev_get(int kdev) +{ + if ((unsigned int)kdev < num_swdev) { + return &swdevs[kdev]; + } + return NULL; +} + +int +ngbde_swdev_get_all(struct ngbde_dev_s **nd, unsigned int *num_nd) +{ + if (nd) { + *nd = swdevs; + } + if (num_nd) { + *num_nd = num_swdev; + } + return 0; +} diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/lkm.h b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/lkm.h new file mode 100644 index 000000000000..c0ba0a319767 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/lkm.h @@ -0,0 +1,126 @@ +/*! \file lkm.h + * + * + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef LKM_H +#define LKM_H + +#include +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) +#error Kernel too old +#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0) +#include +#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) +#include +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39) +#include +#endif +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#ifdef CONFIG_DEVFS_FS +#include +#endif + +/* Compatibility Macros */ + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) +#define PROC_CREATE(_entry, _name, _acc, _path, _fops) \ + do { \ + _entry = proc_create(_name, _acc, _path, _fops); \ + } while (0) + +#define PROC_CREATE_DATA(_entry, _name, _acc, _path, _fops, _data) \ + do { \ + _entry = proc_create_data(_name, _acc, _path, _fops, _data); \ + } while (0) + +#define PROC_PDE_DATA(_node) PDE_DATA(_node) +#else +#define PROC_CREATE(_entry, _name, _acc, _path, _fops) \ + do { \ + _entry = create_proc_entry(_name, _acc, _path); \ + if (_entry) { \ + _entry->proc_fops = _fops; \ + } \ + } while (0) + +#define PROC_CREATE_DATA(_entry, _name, _acc, _path, _fops, _data) \ + do { \ + _entry = create_proc_entry(_name, _acc, _path); \ + if (_entry) { \ + _entry->proc_fops = _fops; \ + _entry->data=_data; \ + } \ + } while (0) + +#define PROC_PDE_DATA(_node) PROC_I(_node)->pde->data +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0) +#define timer_arg(var, context, timer_fieldname) \ + (typeof(var))(context) +#define timer_context_t unsigned long +#else +#define timer_context_t struct timer_list * +#define timer_arg(var, context, timer_fieldname) \ + from_timer(var, context, timer_fieldname) +#endif + +#ifndef setup_timer +#define setup_timer(timer, fn, data) \ + timer_setup(timer, fn, 0) +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,6,0) +static inline void page_ref_inc(struct page *page) +{ + atomic_inc(&page->_count); +} + +static inline void page_ref_dec(struct page *page) +{ + atomic_dec(&page->_count); +} +#endif + +#endif /* LKM_H */ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngbde_ioctl.h b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngbde_ioctl.h new file mode 100644 index 000000000000..b90486ce06f2 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngbde_ioctl.h @@ -0,0 +1,345 @@ +/*! \file ngbde_ioctl.h + * + * NGBDE device I/O control definitions. + * + * This file is intended for use in both kernel mode and user mode. + * + * IMPORTANT! + * All shared structures must be properly 64-bit aligned. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef NGBDE_IOCTL_H +#define NGBDE_IOCTL_H + +#include +#include + +/*! Must be updated if backward compatibility is broken. */ +#define NGBDE_IOC_VERSION 2 + +/*! LUBDE IOCTL command magic. */ +#define NGBDE_IOC_MAGIC 'L' + +/*! + * \name IOCTL commands for the NGBDE kernel module. + * \anchor NGBDE_IOC_xxx + * + * Note that we use __u64 for the IOCTL parameter size because + * sizeof(void *) is different between 32-bit and 64-bit code, and we + * need a 32-bit user mode application to generate the same IOCTL + * command codes as a 64-bit kernel when using the _IOW macro. + */ + +/*! \{ */ + +/*! Get kernel module information. */ +#define NGBDE_IOC_MOD_INFO _IOW(NGBDE_IOC_MAGIC, 0, __u64) + +/*! Get information about registered devices. */ +#define NGBDE_IOC_PROBE_INFO _IOW(NGBDE_IOC_MAGIC, 1, __u64) + +/*! Get detailed switch device information. */ +#define NGBDE_IOC_DEV_INFO _IOW(NGBDE_IOC_MAGIC, 2, __u64) + +/*! Get a physical memory address associated with a switch device. */ +#define NGBDE_IOC_PHYS_ADDR _IOW(NGBDE_IOC_MAGIC, 3, __u64) + +/*! Interrupt control command (see \ref NGBDE_ICTL_xxx). */ +#define NGBDE_IOC_INTR_CTRL _IOW(NGBDE_IOC_MAGIC, 4, __u64) + +/*! Add interrupt status/mask register for kernel to control. */ +#define NGBDE_IOC_IRQ_REG_ADD _IOW(NGBDE_IOC_MAGIC, 5, __u64) + +/*! Write to a shared interrupt mask register. */ +#define NGBDE_IOC_IRQ_MASK_WR _IOW(NGBDE_IOC_MAGIC, 6, __u64) + +/*! Map device registers in kernel space. */ +#define NGBDE_IOC_PIO_WIN_MAP _IOW(NGBDE_IOC_MAGIC, 7, __u64) + +/*! Map interrupt controller registers in kernel space. */ +#define NGBDE_IOC_IIO_WIN_MAP _IOW(NGBDE_IOC_MAGIC, 8, __u64) + +/*! Map PCI bridge registers in kernel space. */ +#define NGBDE_IOC_PAXB_WIN_MAP _IOW(NGBDE_IOC_MAGIC, 9, __u64) + +/*! Add interrupt ACK register for kernel to control. */ +#define NGBDE_IOC_INTR_ACK_REG_ADD _IOW(NGBDE_IOC_MAGIC, 10, __u64) + +/*! \} */ + +/*! IOCTL command return code for success. */ +#define NGBDE_IOC_SUCCESS 0 + +/*! IOCTL command return code for failure. */ +#define NGBDE_IOC_FAIL ((__u32)-1) + +/*! + * \name Device flags. + * \anchor NGBDE_DEV_F_xxx + */ + +/*! \{ */ + +/*! Message-signaled interrupts, PCI interrupts are operating in MSI mode. */ +#define NGBDE_DEV_F_MSI (1 << 0) + +/*! \} */ + +/*! + * \name Interrupt control commands. + * \anchor NGBDE_ICTL_xxx + */ + +/*! \{ */ + +/*! Connect interrupt handler. */ +#define NGBDE_ICTL_INTR_CONN 0 + +/*! Disconnect interrupt handler. */ +#define NGBDE_ICTL_INTR_DISC 1 + +/*! Wait for interrupt. */ +#define NGBDE_ICTL_INTR_WAIT 2 + +/*! Force waiting thread to return. */ +#define NGBDE_ICTL_INTR_STOP 3 + +/*! Clear list of interrupt status/mask registers. */ +#define NGBDE_ICTL_REGS_CLR 4 + +/*! \} */ + +/*! Kernel module information. */ +struct ngbde_ioc_mod_info_s { + + /*! IOCTL version used by kernel module. */ + __u16 version; +}; + +/*! Probing results. */ +struct ngbde_ioc_probe_info_s { + + /*! Number of switch devices. */ + __u16 num_swdev; +}; + +/*! Device information. */ +struct ngbde_ioc_dev_info_s { + + /*! Device type. */ + __u16 type; + + /*! Device flags (\ref NGBDE_DEV_F_xxx). */ + __u16 flags; + + /*! Vendor ID (typically the PCI vendor ID). */ + __u16 vendor_id; + + /*! Device ID (typically the PCI vendor ID). */ + __u16 device_id; + + /*! Device revision (typically the PCI device revision). */ + __u16 revision; + + /*! Device model (device-identification beyond PCI generic ID). */ + __u16 model; +}; + +/*! + * \name I/O resource types. + * \anchor NGBDE_IO_RSRC_xxx + */ + +/*! \{ */ + +/*! Memory-mapped I/O. */ +#define NGBDE_IO_RSRC_DEV_IO 0 + +/*! DMA memory pool. */ +#define NGBDE_IO_RSRC_DMA_MEM 1 + +/*! DMA memory pool as mapped by IOMMU. */ +#define NGBDE_IO_RSRC_DMA_BUS 2 + +/*! \} */ + +/*! + * \brief Resource ID (IOCTL input). + * + * This structure is used to query a physical address resource in the + * kernel module. The caller must provide a resource type (device I/O, + * DMA memory, etc.) and a resource instance number (e.g. a PCI BAR + * address will have multiple instances). + * + * Also see \ref ngbde_ioc_phys_addr_s. + */ +struct ngbde_ioc_rsrc_id_s { + + /*! Resource type (\ref NGBDE_IO_RSRC_xxx). */ + __u32 type; + + /*! Resource instance number. */ + __u32 inst; +}; + +/*! + * \brief Physical device address. + * + * This structure is returned in response to the \ref + * NGBDE_IOC_PHYS_ADDR command. The caller must identify the requested + * physical address using the \ref ngbde_ioc_rsrc_id_s structure. + */ +struct ngbde_ioc_phys_addr_s { + + /*! Physical address. */ + __u64 addr; + + /*! Resource size (in bytes). */ + __u32 size; +}; + +/*! Interrupt control operation */ +struct ngbde_ioc_intr_ctrl_s { + + /*! Interrupt instance for this device. */ + __u32 irq_num; + + /*! Interrupt control command. */ + __u32 cmd; +}; + +/*! Add interrupt register information. */ +struct ngbde_ioc_irq_reg_add_s { + + /*! Interrupt instance for this device. */ + __u32 irq_num; + + /*! Interrupt status register address offset. */ + __u32 status_reg; + + /*! Interrupt mask register address offset. */ + __u32 mask_reg; + + /*! Interrupt mask for interrupts handled by the kernel. */ + __u32 kmask; + + /*! Reserved for future use. */ + __u32 flags; +}; + +/*! + * \name Interrupt ACK register access flags. + * \anchor NGBDE_DEV_INTR_ACK_F_xxx + */ + +/*! \{ */ + +/*! ACK registers resides in PCI bridge I/O window. */ +#define NGBDE_DEV_INTR_ACK_F_PAXB (1 << 0) + +/*! \} */ + +/*! Add interrupt ACK register information. */ +struct ngbde_ioc_intr_ack_reg_add_s { + + /*! Interrupt instance for this device. */ + __u32 irq_num; + + /*! Interrupt ACK register address offset. */ + __u32 ack_reg; + + /*! Interrupt ACK value. */ + __u32 ack_val; + + /*! Flags to indicate ack_reg resides in PCI bridge window. */ + __u32 flags; +}; + +/*! Memory-mapped I/O window */ +struct ngbde_ioc_pio_win_s { + + /*! Physical address */ + __u64 addr; + + /*! Resource size */ + __u32 size; +}; + +/*! Interrupt mask register write */ +struct ngbde_ioc_irq_mask_wr_s { + + /*! Interrupt instance for this device. */ + __u32 irq_num; + + /*! Register offset. */ + __u32 offs; + + /*! Value to write. */ + __u32 val; +}; + +/*! IOCTL operation data. */ +union ngbde_ioc_op_s { + + /*! Get kernel module information. */ + struct ngbde_ioc_mod_info_s mod_info; + + /*! Get information about registered devices. */ + struct ngbde_ioc_probe_info_s probe_info; + + /*! Get detailed switch device information. */ + struct ngbde_ioc_dev_info_s dev_info; + + /*! Resource ID (input). */ + struct ngbde_ioc_rsrc_id_s rsrc_id; + + /*! Get a physical memory address associated with a switch device. */ + struct ngbde_ioc_phys_addr_s phys_addr; + + /*! Interrupt control command (see \ref NGBDE_ICTL_xxx). */ + struct ngbde_ioc_intr_ctrl_s intr_ctrl; + + /*! Add interrupt status/mask register for kernel to control. */ + struct ngbde_ioc_irq_reg_add_s irq_reg_add; + + /*! Add interrupt ACK register for kernel to control. */ + struct ngbde_ioc_intr_ack_reg_add_s intr_ack_reg_add; + + /*! Write to a shared interrupt mask register. */ + struct ngbde_ioc_irq_mask_wr_s irq_mask_wr; + + /*! Map device registers in kernel space. */ + struct ngbde_ioc_pio_win_s pio_win; +}; + +/*! IOCTL command message. */ +typedef struct ngbde_ioc_cmd_s { + + /*! Device handle. */ + __u32 devid; + + /*! Return code (0 means success). */ + __u32 rc; + + /*! IOCTL operation. */ + union ngbde_ioc_op_s op; +} ngbde_ioc_cmd_t; + +#endif /* NGBDE_IOCTL_H */ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngbde_kapi.h b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngbde_kapi.h new file mode 100644 index 000000000000..142aa63b572c --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngbde_kapi.h @@ -0,0 +1,169 @@ +/*! \file ngbde_kapi.h + * + * NGBDE kernel API. + * + * This file is intended for use by other kernel modules relying on the BDE. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef NGBDE_KAPI_H +#define NGBDE_KAPI_H + +#include + +/*! Maximum number of switch devices supported. */ +#ifndef NGBDE_NUM_SWDEV_MAX +#define NGBDE_NUM_SWDEV_MAX 16 +#endif + +/*! + * \brief Get Linux PCI device handle for a switch device. + * + * \param [in] kdev Device number. + * + * \return Linux PCI device handle or NULL if unavailable. + */ +extern struct pci_dev * +ngbde_kapi_pci_dev_get(int kdev); + +/*! + * \brief Get Linux kernel device handle for a switch device. + * + * \param [in] kdev Device number. + * + * \return Linux kernel device handle or NULL if unavailable. + */ +extern struct device * +ngbde_kapi_dma_dev_get(int kdev); + +/*! + * \brief Convert DMA bus address to virtual address. + * + * This API will convert a physical DMA bus address to a kernel + * virtual address for a memory location that belongs to one of the + * DMA memory pools allocated by the BDE module. + * + * \param [in] kdev Device number. + * \param [in] baddr Physical DMA bus address for this device. + * + * \return Virtual kernel address or NULL on error. + */ +void * +ngbde_kapi_dma_bus_to_virt(int kdev, dma_addr_t baddr); + +/*! + * \brief Convert virtual address to DMA bus address. + * + * This API will convert a kernel virtual address to a physical DMA + * bus address for a memory location that belongs to one of the DMA + * memory pools allocated by the BDE module. + * + * \param [in] kdev Device number. + * \param [in] vaddr Virtual kernel address. + * + * \return Physical DMA bus address for this device or 0 on error. + */ +dma_addr_t +ngbde_kapi_dma_virt_to_bus(int kdev, void *vaddr); + +/*! + * \brief Write a memory-mapped register from kernel driver. + * + * \param [in] kdev Device number. + * \param [in] offs Register address offset. + * \param [in] val Value to write to register. + * + * \return Nothing. + */ +extern void +ngbde_kapi_pio_write32(int kdev, uint32_t offs, uint32_t val); + +/*! + * \brief Read a memory-mapped register from kernel driver. + * + * \param [in] kdev Device number. + * \param [in] offs Register address offset. + * + * \return Value read from register. + */ +extern uint32_t +ngbde_kapi_pio_read32(int kdev, uint32_t offs); + +/*! + * \brief Get base address fo memory-mapped I/O memory. + * + * The lgical base address returned can be used with ioread32, etc. + * + * \param [in] kdev Device number. + * + * \return Logical base address or NULL if unavailable. + */ +extern void * +ngbde_kapi_pio_membase(int kdev); + +/*! + * \brief Install kernel mode interrupt handler. + * + * \param [in] kdev Device number. + * \param [in] irq_num MSI interrupt number. + * \param [in] isr_func Interrupt handler function. + * \param [in] isr_data Interrupt handler context. + * + * \retval 0 No errors + */ +extern int +ngbde_kapi_intr_connect(int kdev, unsigned int irq_num, + int (*isr_func)(void *), void *isr_data); + +/*! + * \brief Uninstall kernel mode interrupt handler. + * + * \param [in] kdev Device number. + * \param [in] irq_num MSI interrupt number. + * + * \retval 0 No errors + */ +extern int +ngbde_kapi_intr_disconnect(int kdev, unsigned int irq_num); + +/*! + * \brief Write shared interrupt mask register. + * + * This function is used by an interrupt handler when a shared + * interrupt mask register needs to be updated. + * + * Note that the mask register to access is referenced by the + * corrsponding status register. This is because the mask register may + * be different depending on the host CPU interface being used + * (e.g. PCI vs. AXI). On the other hand, the status register is the + * same irrespective of the host CPU interface. + * + * \param [in] kdev Device number. + * \param [in] irq_num Interrupt number (MSI vector). + * \param [in] status_reg Corresponding interrupt status register offset. + * \param [in] mask_val New value to write to mask register. + * + * \retval 0 No errors + * \retval -1 Something went wrong. + */ +extern int +ngbde_kapi_intr_mask_write(int kdev, unsigned int irq_num, + uint32_t status_reg, uint32_t mask_val); + +#endif /* NGBDE_KAPI_H */ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_dev.h b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_dev.h new file mode 100644 index 000000000000..74d3d5b350b0 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_dev.h @@ -0,0 +1,408 @@ +/*! \file ngknet_dev.h + * + * NGKNET device definitions. + * + * This file is intended for use in both kernel mode and user mode. + * + * IMPORTANT! + * All shared structures must be properly 64-bit aligned. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef NGKNET_DEV_H +#define NGKNET_DEV_H + +#include + +/*! Device name length */ +#define NGKNET_DEV_NAME_MAX 16 + +/*! Maximum number of virtual network devices */ +#ifndef NGKNET_NETIF_MAX +#define NUM_VDEV_MAX 128 +#else +#define NUM_VDEV_MAX NGKNET_NETIF_MAX +#endif + +/*! Maximum number of filters */ +#ifndef NGKNET_FILTER_MAX +#define NUM_FILTER_MAX 128 +#else +#define NUM_FILTER_MAX NGKNET_FILTER_MAX +#endif + +/*! + * \brief System network interface + * + * Network interface types: + * + * NGKNET_NETIF_T_VLAN + * Transmits to this interface will go to ingress PIPE of switch + * CPU port using specified VLAN ID. Packet will be switched. + * + * NGKNET_NETIF_T_PORT + * Transmits to this interface will go to unmodified to specified + * physical switch port. All switching logic is bypassed. Meta data + * should be provided when this interface is created. + * + * NGKNET_NETIF_T_META + * Transmits to this interface will be done using raw meta data + * as DMA descriptors. + * + * Network interface flags: + * + * NGKNET_NETIF_F_RCPU_ENCAP + * Use RCPU encapsulation for packets that enter and exit this + * interface. + * + * NGKNET_NETIF_F_ADD_TAG + * Add VLAN tag to packets sent directly to physical port. + * + * NGKNET_NETIF_F_BIND_CHAN + * Bind this interface to a Rx channel. + */ +/*! Max network interface name length */ +#define NGKNET_NETIF_NAME_MAX 16 +/*! Max network interface meta bytes */ +#define NGKNET_NETIF_META_MAX 16 +/*! Max netif user data in bytes */ +#define NGKNET_NETIF_USER_DATA 64 + +/*! Send packets to switch */ +#define NGKNET_NETIF_T_VLAN 0 +/*! Send packets to port */ +#define NGKNET_NETIF_T_PORT 1 +/*! Send packets with matadata attached */ +#define NGKNET_NETIF_T_META 2 + +/*! Send packets with RCPU encapsulation */ +#define NGKNET_NETIF_F_RCPU_ENCAP (1U << 0) +/*! Send packets with vlan tag */ +#define NGKNET_NETIF_F_ADD_TAG (1U << 1) +/*! Bind network interface to Rx channel */ +#define NGKNET_NETIF_F_BIND_CHAN (1U << 2) + +/*! + * \brief Network interface description. + */ +typedef struct ngknet_netif_s { + /*! This network interface ID */ + uint16_t id; + + /*! Next network interface ID */ + uint16_t next; + + /*! Network interface type */ + uint16_t type; + + /*! Network interface flags */ + uint16_t flags; + + /*! Network interface VLAN ID */ + uint16_t vlan; + + /*! Network interface MAC address */ + uint8_t macaddr[6]; + + /*! Network interface MTU */ + uint32_t mtu; + + /*! Network interface bound to channel */ + uint32_t chan; + + /*! Network interface name */ + char name[NGKNET_NETIF_NAME_MAX]; + + /*! Metadata offset from Ethernet header */ + uint16_t meta_off; + + /*! Metadata length */ + uint16_t meta_len; + + /*! Metadata used to send packets to physical port */ + uint8_t meta_data[NGKNET_NETIF_META_MAX]; + + /*! User data gotten back through callbacks */ + uint8_t user_data[NGKNET_NETIF_USER_DATA]; +} ngknet_netif_t; + +/*! + * \brief Packet filters + * + * Filters work like software TCAMs where a mask is applied to the + * source data, and the result is then compared to the filter data. + * + * Filters are checked in priority order with the lowest priority + * values being checked first (i.e. 0 is the highest priority). + * + * Filter types: + * + * NGKNET_FILTER_T_RX_PKT + * Filter data and mask are applied to the Rx DMA control block + * as well as to the Rx packet contents. + * + * Destination types: + * + * NGKNET_FILTER_DEST_T_NULL + * Packet is dropped. + * + * NGKNET_FILTER_DEST_T_NETIF + * Packet is sent to network interface with ID . + * + * NGKNET_FILTER_DEST_T_VNET + * Packet is sent to VNET in user space. + * + * Filter flags: + * + * NGKNET_FILTER_F_ANY_DATA + * When this flags is set the filter will match any packet on + * the associated unit. + * + * NGKNET_FILTER_F_STRIP_TAG + * Strip VLAN tag before packet is sent to destination. + */ +/*! Roundup to word */ +#define NGKNET_BYTES2WORDS(bytes) ((bytes + 3) / 4) + +/*! Max filter description length */ +#define NGKNET_FILTER_DESC_MAX 32 +/*! Max filter bytes size */ +#define NGKNET_FILTER_BYTES_MAX 256 +/*! Max filter words size */ +#define NGKNET_FILTER_WORDS_MAX NGKNET_BYTES2WORDS(NGKNET_FILTER_BYTES_MAX) +/*! Max filter user data in bytes */ +#define NGKNET_FILTER_USER_DATA 64 + +/*! Filter to Rx */ +#define NGKNET_FILTER_T_RX_PKT 1 + +/*! Drop packet */ +#define NGKNET_FILTER_DEST_T_NULL 0 +/*! Send packet to netif */ +#define NGKNET_FILTER_DEST_T_NETIF 1 +/*! Send packet to VNET */ +#define NGKNET_FILTER_DEST_T_VNET 2 +/*! Send packet to kernel callback function (BCMPKT_DEST_T_CALLBACK) */ +#define NGKNET_FILTER_DEST_T_CB 3 + +/*! Match any data */ +#define NGKNET_FILTER_F_ANY_DATA (1U << 0) +/*! Strip vlan tag */ +#define NGKNET_FILTER_F_STRIP_TAG (1U << 1) +/*! Match Rx channel */ +#define NGKNET_FILTER_F_MATCH_CHAN (1U << 2) +/*! Filter created with raw metadata */ +#define NGKNET_FILTER_F_RAW_PMD (1U << 15) + +/*! + * \brief Filter description. + */ +typedef struct ngknet_filter_s { + /*! This filter ID */ + uint16_t id; + + /*! Next filter ID */ + uint16_t next; + + /*! Filter type. Refer to \ref NGKNET_FILTER_T_XXX. */ + uint16_t type; + + /*! Filter flags. Refer to \ref NGKNET_FILTER_F_XXX. */ + uint16_t flags; + + /*! Filter priority */ + uint32_t priority; + + /*! Filter belong to */ + uint32_t chan; + + /*! Filter description */ + char desc[NGKNET_FILTER_DESC_MAX]; + + /*! Destination type. Refer to \ref NGKNET_FILTER_DEST_T_XXX. */ + uint16_t dest_type; + + /*! Destination network interface ID */ + uint16_t dest_id; + + /*! Destination network interface protocol type */ + uint16_t dest_proto; + + /*! Mirror type */ + uint16_t mirror_type; + + /*! Mirror network interface ID */ + uint16_t mirror_id; + + /*! Mirror network interface protocol type */ + uint16_t mirror_proto; + + /*! Out band data offset */ + uint16_t oob_data_offset; + + /*! Out band data size */ + uint16_t oob_data_size; + + /*! Packet data offset */ + uint16_t pkt_data_offset; + + /*! Packet data size */ + uint16_t pkt_data_size; + + /*! Filtering data */ + union { + uint8_t b[NGKNET_FILTER_BYTES_MAX]; + uint32_t w[NGKNET_FILTER_WORDS_MAX]; + } data; + + /*! Filtering mask */ + union { + uint8_t b[NGKNET_FILTER_BYTES_MAX]; + uint32_t w[NGKNET_FILTER_WORDS_MAX]; + } mask; + + /*! User data gotten back through callbacks */ + uint8_t user_data[NGKNET_FILTER_USER_DATA]; +} ngknet_filter_t; + +/*! + * \brief Device configure structure. + */ +typedef struct ngknet_dev_cfg_s { + /*! Device name */ + char name[NGKNET_DEV_NAME_MAX]; + + /*! Device type string */ + char type_str[NGKNET_DEV_NAME_MAX]; + + /*! Device ID */ + uint32_t dev_id; + + /*! Device mode */ + dev_mode_t mode; + + /*! Number of groups */ + uint32_t nb_grp; + + /*! Bitmap of groups */ + uint32_t bm_grp; + + /*! Rx packet header size */ + uint32_t rx_ph_size; + + /*! Tx packet header size */ + uint32_t tx_ph_size; + + /*! Base network interface */ + ngknet_netif_t base_netif; +} ngknet_dev_cfg_t; + +/*! + * \brief Channel configure structure. + */ +typedef struct ngknet_chan_cfg_s { + /*! Channel number */ + int chan; + + /*! Number of descriptors */ + uint32_t nb_desc; + + /*! Rx buffer size */ + uint32_t rx_buf_size; + + /*! Channel control */ + uint32_t chan_ctrl; + /*! Packet_byte_swap */ +#define NGKNET_PKT_BYTE_SWAP (1 << 0) + /*! Non packet_byte_swap */ +#define NGKNET_OTH_BYTE_SWAP (1 << 1) + /*! Header_byte_swap */ +#define NGKNET_HDR_BYTE_SWAP (1 << 2) + + /*! Rx or Tx */ + int dir; + /*! Rx channel */ +#define NGKNET_RX_CHAN 0 + /*! Tx channel */ +#define NGKNET_TX_CHAN 1 +} ngknet_chan_cfg_t; + +/*! + * \brief RCPU header structure. + */ +struct ngknet_rcpu_hdr { + /*! Destination MAC address */ + uint8_t dst_mac[6]; + + /*! Source MAC address */ + uint8_t src_mac[6]; + + /*! VLAN TPID */ + uint16_t vlan_tpid; + + /*! VLAN TCI */ + uint16_t vlan_tci; + + /*! Ethernet type */ + uint16_t eth_type; + + /*! Packet signature */ + uint16_t pkt_sig; + + /*! Operation code */ + uint8_t op_code; + + /*! Flags */ + uint8_t flags; + + /*! Transaction number */ + uint16_t trans_id; + + /*! Packet data length */ + uint16_t data_len; + + /*! Reserved must be 0 */ + uint16_t rsvd0; + + /*! packet meta data length */ + uint8_t meta_len; + + /*! Transmission queue number */ + uint8_t queue_id; + + /*! Reserved must be 0 */ + uint16_t rsvd1; +}; + +/*! RCPU Rx operation */ +#define RCPU_OPCODE_RX 0x10 +/*! RCPU Tx operation */ +#define RCPU_OPCODE_TX 0x20 + +/*! RCPU purge flag */ +#define RCPU_FLAG_PURGE (1 << 0) +/*! RCPU pause flag */ +#define RCPU_FLAG_PAUSE (1 << 1) +/*! RCPU modhdr flag */ +#define RCPU_FLAG_MODHDR (1 << 2) +/*! RCPU bind queue flag */ +#define RCPU_FLAG_BIND_QUE (1 << 3) + +#endif /* NGKNET_DEV_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_ioctl.h b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_ioctl.h new file mode 100644 index 000000000000..6da52c778191 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_ioctl.h @@ -0,0 +1,112 @@ +/*! \file ngknet_ioctl.h + * + * NGKNET I/O control definitions. + * + * This file is intended for use in both kernel mode and user mode. + * + * IMPORTANT! + * All shared structures must be properly 64-bit aligned. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef NGKNET_IOCTL_H +#define NGKNET_IOCTL_H + +/*! Module information */ +#define NGKNET_MODULE_NAME "linux_ngknet" +#define NGKNET_MODULE_MAJOR 121 + +/*! Must be updated if backward compatibility is broken */ +#define NGKNET_IOC_VERSION 2 + +/*! Max number of input arguments */ +#define NGKNET_IOC_IARG_MAX 2 + +#define NGKNET_IOC_MAGIC 'K' + +#define NGKNET_VERSION_GET _IOR(NGKNET_IOC_MAGIC, 0xa0, unsigned int) +#define NGKNET_RX_RATE_LIMIT _IOWR(NGKNET_IOC_MAGIC, 0xa1, unsigned int) +#define NGKNET_DEV_INIT _IOWR(NGKNET_IOC_MAGIC, 0xb0, unsigned int) +#define NGKNET_DEV_DEINIT _IOWR(NGKNET_IOC_MAGIC, 0xb1, unsigned int) +#define NGKNET_DEV_SUSPEND _IOWR(NGKNET_IOC_MAGIC, 0xb2, unsigned int) +#define NGKNET_DEV_RESUME _IOWR(NGKNET_IOC_MAGIC, 0xb3, unsigned int) +#define NGKNET_DEV_VNET_WAIT _IOWR(NGKNET_IOC_MAGIC, 0xb4, unsigned int) +#define NGKNET_DEV_HNET_WAKE _IOWR(NGKNET_IOC_MAGIC, 0xb5, unsigned int) +#define NGKNET_DEV_VNET_DOCK _IOWR(NGKNET_IOC_MAGIC, 0xb6, unsigned int) +#define NGKNET_DEV_VNET_UNDOCK _IOWR(NGKNET_IOC_MAGIC, 0xb7, unsigned int) +#define NGKNET_QUEUE_CONFIG _IOWR(NGKNET_IOC_MAGIC, 0xc0, unsigned int) +#define NGKNET_QUEUE_QUERY _IOR(NGKNET_IOC_MAGIC, 0xc1, unsigned int) +#define NGKNET_RCPU_CONFIG _IOWR(NGKNET_IOC_MAGIC, 0xc2, unsigned int) +#define NGKNET_RCPU_GET _IOR(NGKNET_IOC_MAGIC, 0xc3, unsigned int) +#define NGKNET_NETIF_CREATE _IOWR(NGKNET_IOC_MAGIC, 0xd0, unsigned int) +#define NGKNET_NETIF_DESTROY _IOWR(NGKNET_IOC_MAGIC, 0xd1, unsigned int) +#define NGKNET_NETIF_GET _IOR(NGKNET_IOC_MAGIC, 0xd2, unsigned int) +#define NGKNET_NETIF_NEXT _IOR(NGKNET_IOC_MAGIC, 0xd3, unsigned int) +#define NGKNET_NETIF_LINK_SET _IOW(NGKNET_IOC_MAGIC, 0xd4, unsigned int) +#define NGKNET_FILT_CREATE _IOWR(NGKNET_IOC_MAGIC, 0xe0, unsigned int) +#define NGKNET_FILT_DESTROY _IOWR(NGKNET_IOC_MAGIC, 0xe1, unsigned int) +#define NGKNET_FILT_GET _IOR(NGKNET_IOC_MAGIC, 0xe2, unsigned int) +#define NGKNET_FILT_NEXT _IOR(NGKNET_IOC_MAGIC, 0xe3, unsigned int) +#define NGKNET_INFO_GET _IOR(NGKNET_IOC_MAGIC, 0xf0, unsigned int) +#define NGKNET_STATS_GET _IOR(NGKNET_IOC_MAGIC, 0xf1, unsigned int) +#define NGKNET_STATS_RESET _IOWR(NGKNET_IOC_MAGIC, 0xf2, unsigned int) +#define NGKNET_PTP_DEV_CTRL _IOWR(NGKNET_IOC_MAGIC, 0x90, unsigned int) + +/*! Kernel module information. */ +struct ngknet_ioc_mod_info { + /*! IOCTL version used by kernel module */ + uint32_t version; +}; + +/*! Data transmission */ +struct ngknet_ioc_data_xmit { + /*! Data buffer address */ + uint64_t buf; + + /*! Data buffer length */ + uint32_t len; +}; + +/*! IOCTL operations */ +union ngknet_ioc_op { + /*! Get module info */ + struct ngknet_ioc_mod_info info; + /*! Transmit data */ + struct ngknet_ioc_data_xmit data; +}; + +/*! + * \brief NGKNET IOCTL command message. + */ +struct ngknet_ioctl { + /*! Device number */ + uint32_t unit; + + /*! Return code (0 means success) */ + uint32_t rc; + + /*! Input arguments */ + int iarg[NGKNET_IOC_IARG_MAX]; + + /*! IOCTL operation */ + union ngknet_ioc_op op; +}; + +#endif /* NGKNET_IOCTL_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/include/net/psample.h b/platform/broadcom/saibcm-modules/sdklt/linux/include/net/psample.h new file mode 100644 index 000000000000..64188c95daeb --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/include/net/psample.h @@ -0,0 +1,24 @@ +#ifndef __NET_PSAMPLE_H +#define __NET_PSAMPLE_H + +#include +#include +#include +#include + +struct psample_group { + struct list_head list; + struct net *net; + u32 group_num; + u32 refcount; + u32 seq; +}; + +extern struct psample_group *psample_group_get(struct net *net, u32 group_num); +extern void psample_group_put(struct psample_group *group); + +extern void psample_sample_packet(struct psample_group *group, struct sk_buff *skb, + u32 trunc_size, int in_ifindex, int out_ifindex, + u32 sample_rate); + +#endif /* __NET_PSAMPLE_H */ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/include/uapi/linux/psample.h b/platform/broadcom/saibcm-modules/sdklt/linux/include/uapi/linux/psample.h new file mode 100644 index 000000000000..ed48996ec0e8 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/include/uapi/linux/psample.h @@ -0,0 +1,35 @@ +#ifndef __UAPI_PSAMPLE_H +#define __UAPI_PSAMPLE_H + +enum { + /* sampled packet metadata */ + PSAMPLE_ATTR_IIFINDEX, + PSAMPLE_ATTR_OIFINDEX, + PSAMPLE_ATTR_ORIGSIZE, + PSAMPLE_ATTR_SAMPLE_GROUP, + PSAMPLE_ATTR_GROUP_SEQ, + PSAMPLE_ATTR_SAMPLE_RATE, + PSAMPLE_ATTR_DATA, + + /* commands attributes */ + PSAMPLE_ATTR_GROUP_REFCOUNT, + + __PSAMPLE_ATTR_MAX +}; + +enum psample_command { + PSAMPLE_CMD_SAMPLE, + PSAMPLE_CMD_GET_GROUP, + PSAMPLE_CMD_NEW_GROUP, + PSAMPLE_CMD_DEL_GROUP, +}; + +/* Can be overridden at runtime by module option */ +#define PSAMPLE_ATTR_MAX (__PSAMPLE_ATTR_MAX - 1) + +#define PSAMPLE_NL_MCGRP_CONFIG_NAME "config" +#define PSAMPLE_NL_MCGRP_SAMPLE_NAME "packets" +#define PSAMPLE_GENL_NAME "psample" +#define PSAMPLE_GENL_VERSION 1 + +#endif diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/Kbuild b/platform/broadcom/saibcm-modules/sdklt/linux/knet/Kbuild new file mode 100644 index 000000000000..fe5d5c5bfefc --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/Kbuild @@ -0,0 +1,44 @@ +# -*- Kbuild -*- +# +# Linux KNET module. +# +# $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. +# The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# A copy of the GNU General Public License version 2 (GPLv2) can +# be found in the LICENSES folder.$ +# + +obj-m := linux_ngknet.o + +ccflags-y := $(KNET_CPPFLAGS) $(LKM_CFLAGS) \ + -I$(SDK)/shr/include \ + -I$(SDK)/bcmdrd/include \ + -I$(SDK)/linux/include \ + -I$(SDK)/linux/knet/include \ + -I$(SDK)/linux/knet + +linux_ngknet-y := $(CHIP_OBJS) \ + bcmcnet_cmicd_pdma_hw.o \ + bcmcnet_cmicd_pdma_rxtx.o \ + bcmcnet_cmicx_pdma_hw.o \ + bcmcnet_cmicx_pdma_rxtx.o \ + bcmcnet_core.o \ + bcmcnet_dev.o \ + bcmcnet_rxtx.o \ + ngknet_buff.o \ + ngknet_callback.o \ + ngknet_extra.o \ + ngknet_linux.o \ + ngknet_main.o \ + ngknet_procfs.o \ + ngknet_ptp.o diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/Makefile b/platform/broadcom/saibcm-modules/sdklt/linux/knet/Makefile new file mode 100644 index 000000000000..785b81fadb17 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/Makefile @@ -0,0 +1,105 @@ +# -*- Makefile -*- +# +# Linux KNET module. +# +# $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. +# The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# A copy of the GNU General Public License version 2 (GPLv2) can +# be found in the LICENSES folder.$ +# + +CNETDIR = $(SDK)/bcmcnet +KNETDIR = $(SDK)/linux/knet +SRCIDIR = $(CNETDIR)/include/bcmcnet +DSTIDIR = $(KNETDIR)/include/bcmcnet + +# Change comma-separated list to space-separated list +comma = , +empty = +space = $(empty) $(empty) +spc_sep = $(subst $(comma),$(space),$1) + +# Convert chip name to uppercase +chip_uc = $(subst a,A,$(subst b,B,$(subst c,C,$(subst m,M,$1)))) + +# Convert chip name to lowercase +chip_lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst M,m,$1)))) + +# +# If SDK_CHIPS is defined, then exclude any chip directory which is +# not part of this list. +# +KNET_CHIPS := $(subst $(CNETDIR)/chip/,,$(wildcard $(CNETDIR)/chip/bcm*)) +ifdef SDK_CHIPS +# Create space-separated lowercase version of chip list +SDK_CHIPS_SPC := $(call spc_sep,$(SDK_CHIPS)) +SDK_CHIPS_LC := $(call chip_lc,$(SDK_CHIPS_SPC)) +# Configure build flags according to chip list +KNET_CHIPS := $(filter $(SDK_CHIPS_LC),$(KNET_CHIPS)) +KNET_CPPFLAGS := CHIP_DEFAULT=0 $(addsuffix =1,$(call chip_uc,$(KNET_CHIPS))) +KNET_CPPFLAGS := $(addprefix -DBCMDRD_CONFIG_INCLUDE_,$(KNET_CPPFLAGS)) +export KNET_CPPFLAGS +endif + +.PHONY: mklinks rmlinks + +knet: mklinks + $(MAKE) all + +# +# Suppress symlink error messages. +# +# Note that we do not use "ln -f" as this may cause failures if +# multiple builds are done in parallel on the same source tree. +# +R = 2>/dev/null + +mklinks: + mkdir -p $(DSTIDIR) + -ln -s $(KNETDIR)/ngknet_dep.h $(DSTIDIR)/bcmcnet_dep.h $(R) + -ln -s $(KNETDIR)/ngknet_buff.h $(DSTIDIR)/bcmcnet_buff.h $(R) + -ln -s $(SRCIDIR)/bcmcnet_types.h $(DSTIDIR) $(R) + -ln -s $(SRCIDIR)/bcmcnet_internal.h $(DSTIDIR) $(R) + -ln -s $(SRCIDIR)/bcmcnet_core.h $(DSTIDIR) $(R) + -ln -s $(SRCIDIR)/bcmcnet_dev.h $(DSTIDIR) $(R) + -ln -s $(SRCIDIR)/bcmcnet_rxtx.h $(DSTIDIR) $(R) + -ln -s $(SRCIDIR)/bcmcnet_cmicd.h $(DSTIDIR) $(R) + -ln -s $(SRCIDIR)/bcmcnet_cmicx.h $(DSTIDIR) $(R) + -ln -s $(CNETDIR)/chip/*/*attach.c $(KNETDIR) $(R) + -ln -s $(CNETDIR)/hmi/cmicd/*.c $(KNETDIR) $(R) + -ln -s $(CNETDIR)/hmi/cmicx/*.c $(KNETDIR) $(R) + -ln -s $(CNETDIR)/main/bcmcnet_core.c $(KNETDIR) $(R) + -ln -s $(CNETDIR)/main/bcmcnet_dev.c $(KNETDIR) $(R) + -ln -s $(CNETDIR)/main/bcmcnet_rxtx.c $(KNETDIR) $(R) + +rmlinks: + -rm -f bcm* + -rm -rf include + +CHIP_SRCS := $(addsuffix _pdma_attach.c,$(KNET_CHIPS)) +CHIP_OBJS ?= $(patsubst %.c, %.o, $(CHIP_SRCS)) +export CHIP_OBJS + +include Kbuild + +ifeq ($(KERNELRELEASE),) + +MOD_NAME = linux_ngknet + +include $(SDK)/make/lkm.mk + +endif + +.PHONY: distclean + +distclean: rmlinks diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.c b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.c new file mode 100644 index 000000000000..750fff69caf3 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.c @@ -0,0 +1,326 @@ +/*! \file ngknet_buff.c + * + * Utility routines for NGKNET packet buffer management in Linux kernel mode. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include +#include "ngknet_main.h" +#include "ngknet_buff.h" + +/*! + * Allocate coherent memory + */ +static void * +bcmcnet_ring_buf_alloc(struct pdma_dev *dev, uint32_t size, dma_addr_t *dma) +{ + struct ngknet_dev *kdev = (struct ngknet_dev *)dev->priv; + + return dma_alloc_coherent(kdev->dev, size, dma, GFP_KERNEL); +} + +/*! + * Free coherent memory + */ +static void +bcmcnet_ring_buf_free(struct pdma_dev *dev, uint32_t size, void *addr, dma_addr_t dma) +{ + struct ngknet_dev *kdev = (struct ngknet_dev *)dev->priv; + + dma_free_coherent(kdev->dev, size, addr, dma); +} + +/*! + * Allocate Rx buffer + */ +static int +bcmcnet_rx_buf_alloc(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf) +{ + struct ngknet_dev *kdev = (struct ngknet_dev *)dev->priv; + dma_addr_t dma; + struct page *page; + struct sk_buff *skb; + + if (rxq->mode == PDMA_BUF_MODE_PAGE) { + page = kal_dev_alloc_page(); + if (unlikely(!page)) { + return SHR_E_MEMORY; + } + dma = dma_map_page(kdev->dev, page, 0, PAGE_SIZE, DMA_FROM_DEVICE); + if (unlikely(dma_mapping_error(kdev->dev, dma))) { + __free_page(page); + return SHR_E_MEMORY; + } + pbuf->dma = dma; + pbuf->page = page; + pbuf->page_offset = 0; + } else { + skb = netdev_alloc_skb(kdev->net_dev, PDMA_RXB_RESV + pbuf->adj + rxq->buf_size); + if (unlikely(!skb)) { + return SHR_E_MEMORY; + } + skb_reserve(skb, PDMA_RXB_ALIGN - (((unsigned long)skb->data) & (PDMA_RXB_ALIGN - 1))); + pbuf->skb = skb; + pbuf->pkb = (struct pkt_buf *)skb->data; + dma = dma_map_single(kdev->dev, &pbuf->pkb->data + pbuf->adj, rxq->buf_size, DMA_FROM_DEVICE); + if (unlikely(dma_mapping_error(kdev->dev, dma))) { + dev_kfree_skb_any(skb); + return SHR_E_MEMORY; + } + pbuf->dma = dma; + } + + return SHR_E_NONE; +} + +/*! + * Get Rx buffer DMA address + */ +static void +bcmcnet_rx_buf_dma(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf, dma_addr_t *addr) +{ + if (rxq->mode == PDMA_BUF_MODE_PAGE) { + *addr = pbuf->dma + pbuf->page_offset + PDMA_RXB_RESV + pbuf->adj; + } else { + *addr = pbuf->dma; + } +} + +/*! + * Check Rx buffer + */ +static int +bcmcnet_rx_buf_avail(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf) +{ + if (rxq->mode == PDMA_BUF_MODE_PAGE) { + pbuf->skb = NULL; + } + + return pbuf->dma != 0; +} + +/*! + * Get Rx buffer + */ +static struct pkt_hdr * +bcmcnet_rx_buf_get(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf, int len) +{ + struct ngknet_dev *kdev = (struct ngknet_dev *)dev->priv; + struct sk_buff *skb; + + if (rxq->mode == PDMA_BUF_MODE_PAGE) { + if (pbuf->skb) { + return &pbuf->pkb->pkh; + } + skb = kal_build_skb(page_address(pbuf->page) + pbuf->page_offset, + PDMA_SKB_RESV + pbuf->adj + rxq->buf_size); + if (unlikely(!skb)) { + return NULL; + } + skb_reserve(skb, PDMA_RXB_ALIGN); + dma_sync_single_range_for_cpu(kdev->dev, pbuf->dma, pbuf->page_offset, + PDMA_PAGE_BUF_MAX, DMA_FROM_DEVICE); + pbuf->skb = skb; + pbuf->pkb = (struct pkt_buf *)skb->data; + + /* Try to reuse this page */ + if (unlikely(page_count(pbuf->page) != 1)) { + dma_unmap_page(kdev->dev, pbuf->dma, PAGE_SIZE, DMA_FROM_DEVICE); + pbuf->dma = 0; + } else { + pbuf->page_offset ^= PDMA_PAGE_BUF_MAX; + page_ref_inc(pbuf->page); + dma_sync_single_range_for_device(kdev->dev, pbuf->dma, pbuf->page_offset, + PDMA_PAGE_BUF_MAX, DMA_FROM_DEVICE); + } + } else { + if (!pbuf->dma) { + return &pbuf->pkb->pkh; + } + skb = pbuf->skb; + dma_unmap_single(kdev->dev, pbuf->dma, rxq->buf_size, DMA_FROM_DEVICE); + pbuf->dma = 0; + } + + skb_put(skb, PKT_HDR_SIZE + pbuf->adj + len); + + return &pbuf->pkb->pkh; +} + +/*! + * Put Rx buffer + */ +static int +bcmcnet_rx_buf_put(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf, int len) +{ + struct ngknet_dev *kdev = (struct ngknet_dev *)dev->priv; + dma_addr_t dma; + struct sk_buff *skb; + + if (rxq->mode == PDMA_BUF_MODE_PAGE) { + dev_kfree_skb_any(pbuf->skb); + } else { + skb = pbuf->skb; + dma = dma_map_single(kdev->dev, &pbuf->pkb->data + pbuf->adj, + rxq->buf_size, DMA_FROM_DEVICE); + if (unlikely(dma_mapping_error(kdev->dev, dma))) { + dev_kfree_skb_any(skb); + pbuf->dma = 0; + return SHR_E_MEMORY; + } + pbuf->dma = dma; + skb_trim(skb, skb->len - (PKT_HDR_SIZE + pbuf->adj + len)); + } + + return SHR_E_NONE; +} + +/*! + * Free Rx buffer + */ +static void +bcmcnet_rx_buf_free(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf) +{ + struct ngknet_dev *kdev = (struct ngknet_dev *)dev->priv; + + if (rxq->mode == PDMA_BUF_MODE_PAGE) { + dma_unmap_single(kdev->dev, pbuf->dma, PAGE_SIZE, DMA_FROM_DEVICE); + __free_page(pbuf->page); + } else { + dma_unmap_single(kdev->dev, pbuf->dma, rxq->buf_size, DMA_FROM_DEVICE); + dev_kfree_skb_any(pbuf->skb); + } + + pbuf->dma = 0; + pbuf->page = NULL; + pbuf->page_offset = 0; + pbuf->skb = NULL; + pbuf->pkb = NULL; + pbuf->adj = 0; +} + +/*! + * Get Rx buffer mode + */ +static enum buf_mode +bcmcnet_rx_buf_mode(struct pdma_dev *dev, struct pdma_rx_queue *rxq) +{ + uint32_t len; + + len = dev->rx_ph_size ? rxq->buf_size : rxq->buf_size + PDMA_RXB_META; + if (PDMA_RXB_SIZE(len) <= PDMA_PAGE_BUF_MAX && PAGE_SIZE < 8192 && + kal_support_paged_skb()) { + return PDMA_BUF_MODE_PAGE; + } + + return PDMA_BUF_MODE_SKB; +} + +/*! + * Get Tx buffer + */ +static struct pkt_hdr * +bcmcnet_tx_buf_get(struct pdma_dev *dev, struct pdma_tx_queue *txq, + struct pdma_tx_buf *pbuf, void *buf) +{ + struct ngknet_dev *kdev = (struct ngknet_dev *)dev->priv; + struct sk_buff *skb = (struct sk_buff *)buf; + struct pkt_buf *pkb = (struct pkt_buf *)skb->data; + dma_addr_t dma; + + pbuf->len = pkb->pkh.data_len + (pbuf->adj ? pkb->pkh.meta_len : 0); + dma = dma_map_single(kdev->dev, &pkb->data + (pbuf->adj ? 0 : pkb->pkh.meta_len), + pbuf->len, DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(kdev->dev, dma))) { + dev_kfree_skb_any(skb); + return NULL; + } + pbuf->dma = dma; + pbuf->skb = skb; + pbuf->pkb = pkb; + + return &pkb->pkh; +} + +/*! + * Get Tx buffer DMA address + */ +static void +bcmcnet_tx_buf_dma(struct pdma_dev *dev, struct pdma_tx_queue *txq, + struct pdma_tx_buf *pbuf, dma_addr_t *addr) +{ + *addr = pbuf->dma; +} + +/*! + * Free Tx buffer + */ +static void +bcmcnet_tx_buf_free(struct pdma_dev *dev, struct pdma_tx_queue *txq, + struct pdma_tx_buf *pbuf) +{ + struct ngknet_dev *kdev = (struct ngknet_dev *)dev->priv; + + dma_unmap_single(kdev->dev, pbuf->dma, pbuf->len, DMA_TO_DEVICE); + if (skb_shinfo(pbuf->skb)->tx_flags & SKBTX_IN_PROGRESS) { + skb_queue_tail(&kdev->ptp_tx_queue, pbuf->skb); + schedule_work(&kdev->ptp_tx_work); + } else { + dev_kfree_skb_any(pbuf->skb); + } + + pbuf->dma = 0; + pbuf->len = 0; + pbuf->skb = NULL; + pbuf->pkb = NULL; + pbuf->adj = 0; +} + +static const struct pdma_buf_mngr buf_mngr = { + .ring_buf_alloc = bcmcnet_ring_buf_alloc, + .ring_buf_free = bcmcnet_ring_buf_free, + .rx_buf_alloc = bcmcnet_rx_buf_alloc, + .rx_buf_dma = bcmcnet_rx_buf_dma, + .rx_buf_avail = bcmcnet_rx_buf_avail, + .rx_buf_get = bcmcnet_rx_buf_get, + .rx_buf_put = bcmcnet_rx_buf_put, + .rx_buf_free = bcmcnet_rx_buf_free, + .rx_buf_mode = bcmcnet_rx_buf_mode, + .tx_buf_get = bcmcnet_tx_buf_get, + .tx_buf_dma = bcmcnet_tx_buf_dma, + .tx_buf_free = bcmcnet_tx_buf_free, +}; + +/*! + * Open a device + */ +void +bcmcnet_buf_mngr_init(struct pdma_dev *dev) +{ + dev->ctrl.buf_mngr = (struct pdma_buf_mngr *)&buf_mngr; +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.h new file mode 100644 index 000000000000..54768e826917 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.h @@ -0,0 +1,83 @@ +/*! \file ngknet_buff.h + * + * Generic data structure definitions for NGKNET packet buffer management. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef NGKNET_BUFF_H +#define NGKNET_BUFF_H + +/*! Rx buffer align size */ +#define PDMA_RXB_ALIGN 32 +/*! Rx buffer reserved size */ +#define PDMA_RXB_RESV (PDMA_RXB_ALIGN + PKT_HDR_SIZE) +/*! Rx SKB reserved size */ +#define PDMA_SKB_RESV (PDMA_RXB_RESV + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) +/*! Rx buffer size */ +#define PDMA_RXB_SIZE(len) (SKB_DATA_ALIGN(len + NET_SKB_PAD) + PDMA_SKB_RESV) +/*! Rx reserved meta size */ +#define PDMA_RXB_META 64 +/*! Max page buffer size */ +#define PDMA_PAGE_BUF_MAX 2048 + +/*! + * \brief Rx buffer. + */ +struct pdma_rx_buf { + /*! DMA address */ + dma_addr_t dma; + + /*! Buffer page */ + struct page *page; + + /*! Buffer page offset */ + unsigned int page_offset; + + /*! Rx SKB */ + struct sk_buff *skb; + + /*! Packet buffer point */ + struct pkt_buf *pkb; + + /*! Packet buffer adjustment */ + uint32_t adj; +}; + +/*! + * \brief Tx buffer. + */ +struct pdma_tx_buf { + /*! DMA address */ + dma_addr_t dma; + + /*! Tx buffer length */ + uint32_t len; + + /*! Tx SKB */ + struct sk_buff *skb; + + /*! Packet buffer point */ + struct pkt_buf *pkb; + + /*! Packet buffer adjustment */ + uint32_t adj; +}; + +#endif /* NGKNET_BUFF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_callback.c b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_callback.c new file mode 100644 index 000000000000..21512a51fbd2 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_callback.c @@ -0,0 +1,315 @@ +/*! \file ngknet_callback.c + * + * Utility routines for NGKNET callbacks. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include "ngknet_callback.h" + +static struct ngknet_callback_ctrl callback_ctrl; + +int +ngknet_callback_control_get(struct ngknet_callback_ctrl **cbc) +{ + *cbc = &callback_ctrl; + + return 0; +} + +/*! + * Call-back interfaces for other Linux kernel drivers. + * + * The Rx call-back allows an external module to modify packet contents + * before it is handed off to the Linux network stack. + * + * The Tx call-back allows an external module to modify packet contents + * before it is injected into the switch. + */ + +int +ngknet_rx_cb_register(ngknet_rx_cb_f rx_cb) +{ + if (callback_ctrl.rx_cb != NULL) { + return -1; + } + callback_ctrl.rx_cb = rx_cb; + + return 0; +} + +int +ngknet_rx_cb_unregister(ngknet_rx_cb_f rx_cb) +{ + if (rx_cb == NULL || callback_ctrl.rx_cb != rx_cb) { + return -1; + } + callback_ctrl.rx_cb = NULL; + + return 0; +} + +int +ngknet_tx_cb_register(ngknet_tx_cb_f tx_cb) +{ + if (callback_ctrl.tx_cb != NULL) { + return -1; + } + callback_ctrl.tx_cb = tx_cb; + + return 0; +} + +int +ngknet_tx_cb_unregister(ngknet_tx_cb_f tx_cb) +{ + if (tx_cb == NULL || callback_ctrl.tx_cb != tx_cb) { + return -1; + } + callback_ctrl.tx_cb = NULL; + + return 0; +} + +int +ngknet_ptp_rx_config_set_cb_register(ngknet_ptp_config_set_cb_f ptp_rx_config_set_cb) +{ + if (callback_ctrl.ptp_rx_config_set_cb != NULL) { + return -1; + } + callback_ctrl.ptp_rx_config_set_cb = ptp_rx_config_set_cb; + + return 0; +} + +int +ngknet_ptp_rx_config_set_cb_unregister(ngknet_ptp_config_set_cb_f ptp_rx_config_set_cb) +{ + if (ptp_rx_config_set_cb == NULL || + callback_ctrl.ptp_rx_config_set_cb != ptp_rx_config_set_cb) { + return -1; + } + callback_ctrl.ptp_rx_config_set_cb = NULL; + + return 0; +} + +int +ngknet_ptp_tx_config_set_cb_register(ngknet_ptp_config_set_cb_f ptp_tx_config_set_cb) +{ + if (callback_ctrl.ptp_tx_config_set_cb != NULL) { + return -1; + } + callback_ctrl.ptp_tx_config_set_cb = ptp_tx_config_set_cb; + + return 0; +} + +int +ngknet_ptp_tx_config_set_cb_unregister(ngknet_ptp_config_set_cb_f ptp_tx_config_set_cb) +{ + if (ptp_tx_config_set_cb == NULL || + callback_ctrl.ptp_tx_config_set_cb != ptp_tx_config_set_cb) { + return -1; + } + callback_ctrl.ptp_tx_config_set_cb = NULL; + + return 0; +} + +int +ngknet_ptp_rx_hwts_get_cb_register(ngknet_ptp_hwts_get_cb_f ptp_rx_hwts_get_cb) +{ + if (callback_ctrl.ptp_rx_hwts_get_cb != NULL) { + return -1; + } + callback_ctrl.ptp_rx_hwts_get_cb = ptp_rx_hwts_get_cb; + + return 0; +} + +int +ngknet_ptp_rx_hwts_get_cb_unregister(ngknet_ptp_hwts_get_cb_f ptp_rx_hwts_get_cb) +{ + if (ptp_rx_hwts_get_cb == NULL || + callback_ctrl.ptp_rx_hwts_get_cb != ptp_rx_hwts_get_cb) { + return -1; + } + callback_ctrl.ptp_rx_hwts_get_cb = NULL; + + return 0; +} + +int +ngknet_ptp_tx_hwts_get_cb_register(ngknet_ptp_hwts_get_cb_f ptp_tx_hwts_get_cb) +{ + if (callback_ctrl.ptp_tx_hwts_get_cb != NULL) { + return -1; + } + callback_ctrl.ptp_tx_hwts_get_cb = ptp_tx_hwts_get_cb; + + return 0; +} + +int +ngknet_ptp_tx_hwts_get_cb_unregister(ngknet_ptp_hwts_get_cb_f ptp_tx_hwts_get_cb) +{ + if (ptp_tx_hwts_get_cb == NULL || + callback_ctrl.ptp_tx_hwts_get_cb != ptp_tx_hwts_get_cb) { + return -1; + } + callback_ctrl.ptp_tx_hwts_get_cb = NULL; + + return 0; +} + +int +ngknet_ptp_tx_meta_set_cb_register(ngknet_ptp_meta_set_cb_f ptp_tx_meta_set_cb) +{ + if (callback_ctrl.ptp_tx_meta_set_cb != NULL) { + return -1; + } + callback_ctrl.ptp_tx_meta_set_cb = ptp_tx_meta_set_cb; + + return 0; +} + +int +ngknet_ptp_tx_meta_set_cb_unregister(ngknet_ptp_meta_set_cb_f ptp_tx_meta_set_cb) +{ + if (ptp_tx_meta_set_cb == NULL || + callback_ctrl.ptp_tx_meta_set_cb != ptp_tx_meta_set_cb) { + return -1; + } + callback_ctrl.ptp_tx_meta_set_cb = NULL; + + return 0; +} + +int +ngknet_ptp_phc_index_get_cb_register(ngknet_ptp_phc_index_get_cb_f ptp_phc_index_get_cb) +{ + if (callback_ctrl.ptp_phc_index_get_cb != NULL) { + return -1; + } + callback_ctrl.ptp_phc_index_get_cb = ptp_phc_index_get_cb; + + return 0; +} + +int +ngknet_ptp_phc_index_get_cb_unregister(ngknet_ptp_phc_index_get_cb_f ptp_phc_index_get_cb) +{ + if (ptp_phc_index_get_cb == NULL || + callback_ctrl.ptp_phc_index_get_cb != ptp_phc_index_get_cb) { + return -1; + } + callback_ctrl.ptp_phc_index_get_cb = NULL; + + return 0; +} + +int +ngknet_ptp_dev_ctrl_cb_register(ngknet_ptp_dev_ctrl_cb_f ptp_dev_ctrl_cb) +{ + if (callback_ctrl.ptp_dev_ctrl_cb != NULL) { + return -1; + } + callback_ctrl.ptp_dev_ctrl_cb = ptp_dev_ctrl_cb; + + return 0; +} + +int +ngknet_ptp_dev_ctrl_cb_unregister(ngknet_ptp_dev_ctrl_cb_f ptp_dev_ctrl_cb) +{ + if (ptp_dev_ctrl_cb == NULL || + callback_ctrl.ptp_dev_ctrl_cb != ptp_dev_ctrl_cb) { + return -1; + } + callback_ctrl.ptp_dev_ctrl_cb = NULL; + + return 0; +} + +int +ngknet_netif_create_cb_register(ngknet_netif_cb_f netif_cb) +{ + if (callback_ctrl.netif_create_cb != NULL) { + return -1; + } + callback_ctrl.netif_create_cb = netif_cb; + + return 0; +} + +int +ngknet_netif_create_cb_unregister(ngknet_netif_cb_f netif_cb) +{ + if (netif_cb == NULL || callback_ctrl.netif_create_cb != netif_cb) { + return -1; + } + callback_ctrl.netif_create_cb = NULL; + + return 0; +} + +int +ngknet_netif_destroy_cb_register(ngknet_netif_cb_f netif_cb) +{ + if (callback_ctrl.netif_destroy_cb != NULL) { + return -1; + } + callback_ctrl.netif_destroy_cb = netif_cb; + + return 0; +} + +int +ngknet_netif_destroy_cb_unregister(ngknet_netif_cb_f netif_cb) +{ + if (netif_cb == NULL || callback_ctrl.netif_destroy_cb != netif_cb) { + return -1; + } + callback_ctrl.netif_destroy_cb = NULL; + + return 0; +} + +EXPORT_SYMBOL(ngknet_rx_cb_register); +EXPORT_SYMBOL(ngknet_rx_cb_unregister); +EXPORT_SYMBOL(ngknet_tx_cb_register); +EXPORT_SYMBOL(ngknet_tx_cb_unregister); +EXPORT_SYMBOL(ngknet_ptp_rx_config_set_cb_register); +EXPORT_SYMBOL(ngknet_ptp_rx_config_set_cb_unregister); +EXPORT_SYMBOL(ngknet_ptp_tx_config_set_cb_register); +EXPORT_SYMBOL(ngknet_ptp_tx_config_set_cb_unregister); +EXPORT_SYMBOL(ngknet_ptp_rx_hwts_get_cb_register); +EXPORT_SYMBOL(ngknet_ptp_rx_hwts_get_cb_unregister); +EXPORT_SYMBOL(ngknet_ptp_tx_hwts_get_cb_register); +EXPORT_SYMBOL(ngknet_ptp_tx_hwts_get_cb_unregister); +EXPORT_SYMBOL(ngknet_ptp_tx_meta_set_cb_register); +EXPORT_SYMBOL(ngknet_ptp_tx_meta_set_cb_unregister); +EXPORT_SYMBOL(ngknet_ptp_phc_index_get_cb_register); +EXPORT_SYMBOL(ngknet_ptp_phc_index_get_cb_unregister); +EXPORT_SYMBOL(ngknet_ptp_dev_ctrl_cb_register); +EXPORT_SYMBOL(ngknet_ptp_dev_ctrl_cb_unregister); +EXPORT_SYMBOL(ngknet_netif_create_cb_register); +EXPORT_SYMBOL(ngknet_netif_create_cb_unregister); +EXPORT_SYMBOL(ngknet_netif_destroy_cb_register); +EXPORT_SYMBOL(ngknet_netif_destroy_cb_unregister); diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_callback.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_callback.h new file mode 100644 index 000000000000..54583adffa36 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_callback.h @@ -0,0 +1,364 @@ +/*! \file ngknet_callback.h + * + * Data structure definitions for NGKNET callbacks. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef NGKNET_CALLBACK_H +#define NGKNET_CALLBACK_H + +#include +#include "ngknet_main.h" + +/*! + * \brief NGKNET callback description. + */ +struct ngknet_callback_desc { + /*! Device number */ + int dev_no; + + /*! Device ID */ + uint32_t dev_id; + + /*! Device type string */ + const char *type_str; + + /*! Network interface private data */ + struct ngknet_private *priv; + + /*! Matched filter */ + struct ngknet_filter_s *filt; + + /*! Packet meta data */ + uint8_t *pmd; + + /*! Packet meta data length */ + int pmd_len; + + /*! Packet data length */ + int pkt_len; + + /*! Matched callback filter */ + struct ngknet_filter_s *filt_cb; +}; + +#define NGKNET_SKB_CB(_skb) ((struct ngknet_callback_desc *)_skb->cb) + +/*! Handle Rx packet */ +typedef struct sk_buff * +(*ngknet_rx_cb_f)(struct sk_buff *skb); + +/*! Handle Tx packet */ +typedef struct sk_buff * +(*ngknet_tx_cb_f)(struct sk_buff *skb); + +/*! PTP Rx/Tx config set */ +typedef int +(*ngknet_ptp_config_set_cb_f)(struct ngknet_private *priv, int *value); + +/*! PTP Rx/Tx HW timestamp get */ +typedef int +(*ngknet_ptp_hwts_get_cb_f)(struct sk_buff *skb, uint64_t *ts); + +/*! PTP Tx meta set */ +typedef int +(*ngknet_ptp_meta_set_cb_f)(struct sk_buff *skb); + +/*! PTP PHC index get */ +typedef int +(*ngknet_ptp_phc_index_get_cb_f)(struct ngknet_private *priv, int *index); + +/*! PTP device control */ +typedef int +(*ngknet_ptp_dev_ctrl_cb_f)(struct ngknet_dev *dev, int cmd, char *data, int len); + +/*! Netif callback */ +typedef int +(*ngknet_netif_cb_f)(struct net_device *dev); + +/*! + * \brief NGKNET callback control. + */ +struct ngknet_callback_ctrl { + /*! Handle Rx packet */ + ngknet_rx_cb_f rx_cb; + + /*! Handle Tx packet */ + ngknet_tx_cb_f tx_cb; + + /*! PTP Rx config set */ + ngknet_ptp_config_set_cb_f ptp_rx_config_set_cb; + + /*! PTP Tx config set */ + ngknet_ptp_config_set_cb_f ptp_tx_config_set_cb; + + /*! PTP Rx HW timestamp get */ + ngknet_ptp_hwts_get_cb_f ptp_rx_hwts_get_cb; + + /*! PTP Tx HW timestamp get */ + ngknet_ptp_hwts_get_cb_f ptp_tx_hwts_get_cb; + + /*! PTP Tx meta set */ + ngknet_ptp_meta_set_cb_f ptp_tx_meta_set_cb; + + /*! PTP PHC index get */ + ngknet_ptp_phc_index_get_cb_f ptp_phc_index_get_cb; + + /*! PTP device control */ + ngknet_ptp_dev_ctrl_cb_f ptp_dev_ctrl_cb; + + /*! Handle Netif create */ + ngknet_netif_cb_f netif_create_cb; + + /*! Handle Netif destroy */ + ngknet_netif_cb_f netif_destroy_cb; +}; + +/*! + * \brief Get callback control. + * + * \param [in] cbc Pointer to callback control. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_callback_control_get(struct ngknet_callback_ctrl **cbc); + +/*! + * \brief Register Rx callback. + * + * \param [in] rx_cb Rx callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_rx_cb_register(ngknet_rx_cb_f rx_cb); + +/*! + * \brief Unregister Rx callback. + * + * \param [in] rx_cb Rx callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_rx_cb_unregister(ngknet_rx_cb_f rx_cb); + +/*! + * \brief Register Tx callback. + * + * \param [in] tx_cb Tx callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_tx_cb_register(ngknet_tx_cb_f tx_cb); + +/*! + * \brief Unregister Tx callback. + * + * \param [in] tx_cb Tx callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_tx_cb_unregister(ngknet_tx_cb_f tx_cb); + +/*! + * \brief Register PTP Rx config set callback. + * + * \param [in] ptp_rx_config_set_cb Rx config set callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_rx_config_set_cb_register(ngknet_ptp_config_set_cb_f ptp_rx_config_set_cb); + +/*! + * \brief Unregister PTP Rx config set callback. + * + * \param [in] ptp_rx_config_set_cb Rx config set callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_rx_config_set_cb_unregister(ngknet_ptp_config_set_cb_f ptp_rx_config_set_cb); + +/*! + * \brief Register PTP Tx config set callback. + * + * \param [in] ptp_tx_config_set_cb Tx config set callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_tx_config_set_cb_register(ngknet_ptp_config_set_cb_f ptp_tx_config_set_cb); + +/*! + * \brief Unregister PTP Tx config set callback. + * + * \param [in] ptp_tx_config_set_cb Tx config set callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_tx_config_set_cb_unregister(ngknet_ptp_config_set_cb_f ptp_tx_config_set_cb); + +/*! + * \brief Register PTP Rx HW timestamp get callback. + * + * \param [in] ptp_rx_hwts_get_cb Rx HW timestamp get callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_rx_hwts_get_cb_register(ngknet_ptp_hwts_get_cb_f ptp_rx_hwts_get_cb); + +/*! + * \brief Unregister PTP Rx HW timestamp get callback. + * + * \param [in] ptp_rx_hwts_get_cb Rx HW timestamp get callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_rx_hwts_get_cb_unregister(ngknet_ptp_hwts_get_cb_f ptp_rx_hwts_get_cb); + +/*! + * \brief Register PTP Tx HW timestamp get callback. + * + * \param [in] ptp_tx_hwts_get_cb Tx HW timestamp get callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_tx_hwts_get_cb_register(ngknet_ptp_hwts_get_cb_f ptp_tx_hwts_get_cb); + +/*! + * \brief Unregister PTP Tx HW timestamp get callback. + * + * \param [in] ptp_tx_hwts_get_cb Tx HW timestamp get callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_tx_hwts_get_cb_unregister(ngknet_ptp_hwts_get_cb_f ptp_tx_hwts_get_cb); + +/*! + * \brief Register PTP Tx meta set callback. + * + * \param [in] ptp_tx_meta_set_cb Tx meta set callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_tx_meta_set_cb_register(ngknet_ptp_meta_set_cb_f ptp_tx_meta_set_cb); + +/*! + * \brief Unregister PTP Tx meta set callback. + * + * \param [in] ptp_tx_meta_set_cb Tx meta set callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_tx_meta_set_cb_unregister(ngknet_ptp_meta_set_cb_f ptp_tx_meta_set_cb); + +/*! + * \brief Register PTP PHC index get callback. + * + * \param [in] ptp_phc_index_get_cb PHC index get callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_phc_index_get_cb_register(ngknet_ptp_phc_index_get_cb_f ptp_phc_index_get_cb); + +/*! + * \brief Unregister PTP PHC index get callback. + * + * \param [in] ptp_phc_index_get_cb PHC index get callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_phc_index_get_cb_unregister(ngknet_ptp_phc_index_get_cb_f ptp_phc_index_get_cb); + +/*! + * \brief Register PTP device control callback. + * + * \param [in] ptp_dev_ctrl_cb Device control callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_dev_ctrl_cb_register(ngknet_ptp_dev_ctrl_cb_f ptp_dev_ctrl_cb); + +/*! + * \brief Unregister PTP device control callback. + * + * \param [in] ptp_dev_ctrl_cb Device control callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_dev_ctrl_cb_unregister(ngknet_ptp_dev_ctrl_cb_f ptp_dev_ctrl_cb); + +/*! + * \brief Register Netif Create callback. + * + * \param [netif_cb] netif_cb create callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_netif_create_cb_register(ngknet_netif_cb_f netif_cb); + +/*! + * \brief Unregister Netif Create callback. + * + * \param [netif_cb] netif_cb destroy callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_netif_create_cb_unregister(ngknet_netif_cb_f netif_cb); + +/*! + * \brief Register Netif Destroy callback. + * + * \param [netif_cb] netif_cb destroy callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_netif_destroy_cb_register(ngknet_netif_cb_f netif_cb); + +/*! + * \brief Unregister Netif Destroy callback. + * + * \param [netif_cb] netif_cb destroy callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_netif_destroy_cb_unregister(ngknet_netif_cb_f netif_cb); + +#endif /* NGKNET_CALLBACK_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_dep.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_dep.h new file mode 100644 index 000000000000..919dd6450340 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_dep.h @@ -0,0 +1,61 @@ +/*! \file ngknet_dep.h + * + * Macro definitions for NGKNET dependence. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef NGKNET_DEP_H +#define NGKNET_DEP_H + +#include +#include + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +/*! Memorry barrier */ +#define MEMORY_BARRIER smp_mb() + +/*! CNET print uitility */ +#define CNET_PR(fmt, args...) printk(fmt, ##args) + +struct pdma_dev; + +/*! Externs for the required functions. */ +#define BCMDRD_DEVLIST_ENTRY(_nm,_vn,_dv,_rv,_md,_pi,_bd,_bc,_fn,_cn,_pf,_pd,_r0,_r1) \ +extern int _bd##_cnet_pdma_attach(struct pdma_dev *dev); \ +extern int _bd##_cnet_pdma_detach(struct pdma_dev *dev); +#include + +/*! Create enumeration values from list of supported devices. */ +#define BCMDRD_DEVLIST_ENTRY(_nm,_vn,_dv,_rv,_md,_pi,_bd,_bc,_fn,_cn,_pf,_pd,_r0,_r1) \ + NGKNET_DEV_T_##_bd, +/*! Enumeration for all base device types. */ +typedef enum { + NGKNET_DEV_T_NONE = 0, +#include + NGKNET_DEV_T_COUNT +} ngknet_dev_type_t; + +#endif /* NGKNET_DEP_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_extra.c b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_extra.c new file mode 100644 index 000000000000..00fdb3da8849 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_extra.c @@ -0,0 +1,505 @@ +/*! \file ngknet_extra.c + * + * Utility routines for NGKNET enhancement. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "ngknet_main.h" +#include "ngknet_extra.h" +#include "ngknet_callback.h" + +static struct ngknet_rl_ctrl rl_ctrl; + +int +ngknet_filter_create(struct ngknet_dev *dev, ngknet_filter_t *filter) +{ + struct filt_ctrl *fc = NULL; + struct list_head *list = NULL; + ngknet_filter_t *filt = NULL; + unsigned long flags; + int num, id, done = 0; + + switch (filter->type) { + case NGKNET_FILTER_T_RX_PKT: + break; + default: + return SHR_E_UNAVAIL; + } + + switch (filter->dest_type) { + case NGKNET_FILTER_DEST_T_NULL: + case NGKNET_FILTER_DEST_T_NETIF: + case NGKNET_FILTER_DEST_T_VNET: + case NGKNET_FILTER_DEST_T_CB: /* SDKLT-26907: support NGKNET_FILTER_DEST_T_CB */ + break; + default: + return SHR_E_UNAVAIL; + } + + spin_lock_irqsave(&dev->lock, flags); + + num = (long)dev->fc[0]; + for (id = 1; id < num + 1; id++) { + if (!dev->fc[id]) { + break; + } + } + if (id > NUM_FILTER_MAX) { + spin_unlock_irqrestore(&dev->lock, flags); + return SHR_E_RESOURCE; + } + + fc = kzalloc(sizeof(*fc), GFP_KERNEL); + if (!fc) { + spin_unlock_irqrestore(&dev->lock, flags); + return SHR_E_MEMORY; + } + + dev->fc[id] = fc; + num += id == (num + 1) ? 1 : 0; + dev->fc[0] = (void *)(long)num; + + memcpy(&fc->filt, filter, sizeof(fc->filt)); + fc->filt.id = id; + + list_for_each(list, &dev->filt_list) { + filt = &((struct filt_ctrl *)list)->filt; + if (filt->flags & NGKNET_FILTER_F_MATCH_CHAN) { + if (!(fc->filt.flags & NGKNET_FILTER_F_MATCH_CHAN) || + fc->filt.chan > filt->chan) { + continue; + } + if (fc->filt.chan < filt->chan || + fc->filt.priority < filt->priority) { + list_add_tail(&fc->list, list); + done = 1; + break; + } + } else { + if (fc->filt.flags & NGKNET_FILTER_F_MATCH_CHAN || + fc->filt.priority < filt->priority) { + list_add_tail(&fc->list, list); + done = 1; + break; + } + } + } + if (!done) { + list_add_tail(&fc->list, &dev->filt_list); + } + + filter->id = fc->filt.id; + + spin_unlock_irqrestore(&dev->lock, flags); + + return SHR_E_NONE; +} + +int +ngknet_filter_destroy(struct ngknet_dev *dev, int id) +{ + struct filt_ctrl *fc = NULL; + unsigned long flags; + int num; + + if (id <= 0 || id > NUM_FILTER_MAX) { + return SHR_E_PARAM; + } + + spin_lock_irqsave(&dev->lock, flags); + + fc = (struct filt_ctrl *)dev->fc[id]; + if (!fc) { + spin_unlock_irqrestore(&dev->lock, flags); + return SHR_E_NOT_FOUND; + } + + list_del(&fc->list); + kfree(fc); + + dev->fc[id] = NULL; + num = (long)dev->fc[0]; + while (num-- == id--) { + if (dev->fc[id]) { + dev->fc[0] = (void *)(long)num; + break; + } + } + + spin_unlock_irqrestore(&dev->lock, flags); + + return SHR_E_NONE; +} + +int +ngknet_filter_destroy_all(struct ngknet_dev *dev) +{ + int id; + int rv; + + for (id = 1; id <= NUM_FILTER_MAX; id++) { + rv = ngknet_filter_destroy(dev, id); + if (SHR_FAILURE(rv)) { + return rv; + } + } + + return SHR_E_NONE; +} + +int +ngknet_filter_get(struct ngknet_dev *dev, int id, ngknet_filter_t *filter) +{ + struct filt_ctrl *fc = NULL; + unsigned long flags; + int num; + + if (id <= 0 || id > NUM_FILTER_MAX) { + return SHR_E_PARAM; + } + + spin_lock_irqsave(&dev->lock, flags); + + fc = (struct filt_ctrl *)dev->fc[id]; + if (!fc) { + spin_unlock_irqrestore(&dev->lock, flags); + return SHR_E_NOT_FOUND; + } + + memcpy(filter, &fc->filt, sizeof(*filter)); + + num = (long)dev->fc[0]; + for (id++; id < num + 1; id++) { + if (dev->fc[id]) { + break; + } + } + filter->next = id == (num + 1) ? 0 : id; + + spin_unlock_irqrestore(&dev->lock, flags); + + return SHR_E_NONE; +} + +int +ngknet_filter_get_next(struct ngknet_dev *dev, ngknet_filter_t *filter) +{ + int id; + int rv; + + if (!filter->next) { + for (id = 1; id <= NUM_FILTER_MAX; id++) { + rv = ngknet_filter_get(dev, id, filter); + if (SHR_SUCCESS(rv)) { + return rv; + } + } + if (id > NUM_FILTER_MAX) { + return SHR_E_NOT_FOUND; + } + } + + return ngknet_filter_get(dev, filter->next, filter); +} + +int +ngknet_rx_pkt_filter(struct ngknet_dev *dev, struct sk_buff *skb, struct net_device **ndev, + struct net_device **mndev, struct sk_buff **mskb) +{ + struct pkt_buf *pkb = (struct pkt_buf *)skb->data; + struct net_device *dest_ndev = NULL, *mirror_ndev = NULL; + struct sk_buff *mirror_skb = NULL; + struct ngknet_private *priv = NULL; + struct filt_ctrl *fc = NULL; + struct list_head *list = NULL; + ngknet_filter_t scratch, *filt = NULL, *filt_cb = NULL; + uint8_t *oob = &pkb->data, *data = NULL; + uint16_t tpid; + unsigned long flags; + int wsize; + int chan_id; + int idx, match = 0, match_cb = 0; + + bcmcnet_pdma_dev_queue_to_chan(&dev->pdma_dev, pkb->pkh.queue_id, + PDMA_Q_RX, &chan_id); + + spin_lock_irqsave(&dev->lock, flags); + + dest_ndev = dev->bdev[chan_id]; + if (dest_ndev) { + skb->dev = dest_ndev; + priv = netdev_priv(dest_ndev); + priv->users++; + *ndev = dest_ndev; + spin_unlock_irqrestore(&dev->lock, flags); + return SHR_E_NONE; + } + + if (list_empty(&dev->filt_list)) { + spin_unlock_irqrestore(&dev->lock, flags); + return SHR_E_NONE; + } + + list_for_each(list, &dev->filt_list) { + fc = (struct filt_ctrl *)list; + filt = &fc->filt; + if (filt->flags & NGKNET_FILTER_F_ANY_DATA) { + match = 1; + break; + } + if (filt->flags & NGKNET_FILTER_F_MATCH_CHAN && filt->chan != chan_id) { + continue; + } + memcpy(&scratch.data.b[0], + &oob[filt->oob_data_offset], filt->oob_data_size); + memcpy(&scratch.data.b[filt->oob_data_size], + &pkb->data + pkb->pkh.meta_len + filt->pkt_data_offset, + filt->pkt_data_size); + wsize = NGKNET_BYTES2WORDS(filt->oob_data_size + filt->pkt_data_size); + for (idx = 0; idx < wsize; idx++) { + scratch.data.w[idx] &= filt->mask.w[idx]; + if (scratch.data.w[idx] != filt->data.w[idx]) { + break; + } + } + if (idx == wsize) { + if (NGKNET_FILTER_DEST_T_CB == filt->dest_type) { + match_cb = 1; + filt_cb = filt; + continue; + } + match = 1; + break; + } + } + + if (match) { + fc->hits++; + switch (filt->dest_type) { + case NGKNET_FILTER_DEST_T_NETIF: + if (filt->dest_id == 0) { + dest_ndev = dev->net_dev; + } else { + dest_ndev = dev->vdev[filt->dest_id]; + } + if (dest_ndev) { + skb->dev = dest_ndev; + if (filt->dest_proto) { + pkb->pkh.attrs |= PDMA_RX_SET_PROTO; + skb->protocol = filt->dest_proto; + } + priv = netdev_priv(dest_ndev); + priv->users++; + } + break; + case NGKNET_FILTER_DEST_T_VNET: + pkb->pkh.attrs |= PDMA_RX_TO_VNET; + spin_unlock_irqrestore(&dev->lock, flags); + return SHR_E_NO_HANDLER; + case NGKNET_FILTER_DEST_T_NULL: + default: + spin_unlock_irqrestore(&dev->lock, flags); + return SHR_E_UNAVAIL; + } + } + + spin_unlock_irqrestore(&dev->lock, flags); + + if (!dest_ndev) { + return SHR_E_NONE; + } else { + *ndev = dest_ndev; + } + + if (filt->flags & NGKNET_FILTER_F_STRIP_TAG) { + pkb->pkh.attrs |= PDMA_RX_STRIP_TAG; + data = skb->data + PKT_HDR_SIZE + pkb->pkh.meta_len; + tpid = data[12] << 8 | data[13]; + if (tpid == ETH_P_8021Q || tpid == ETH_P_8021AD) { + pkb->pkh.data_len -= VLAN_HLEN; + memmove(skb->data + VLAN_HLEN, skb->data, + PKT_HDR_SIZE + pkb->pkh.meta_len + 2 * ETH_ALEN); + skb_pull(skb, VLAN_HLEN); + } + } + + if (dev->cbc->rx_cb) { + NGKNET_SKB_CB(skb)->filt = filt; + + /* Add callback filter if matched */ + if (match_cb) { + NGKNET_SKB_CB(skb)->filt_cb = filt_cb; + } + } + + if (filt->mirror_type == NGKNET_FILTER_DEST_T_NETIF) { + spin_lock_irqsave(&dev->lock, flags); + if (filt->mirror_id == 0) { + mirror_ndev = dev->net_dev; + } else { + mirror_ndev = dev->vdev[filt->mirror_id]; + } + if (mirror_ndev) { + mirror_skb = pskb_copy(skb, GFP_ATOMIC); + if (mirror_skb) { + mirror_skb->dev = mirror_ndev; + if (filt->mirror_proto) { + pkb->pkh.attrs |= PDMA_RX_SET_PROTO; + mirror_skb->protocol = filt->mirror_proto; + } + if (dev->cbc->rx_cb) { + NGKNET_SKB_CB(mirror_skb)->filt = filt; + } + priv = netdev_priv(mirror_ndev); + priv->users++; + *mndev = mirror_ndev; + *mskb = mirror_skb; + } + } + spin_unlock_irqrestore(&dev->lock, flags); + } + + return SHR_E_NONE; +} + +static void +ngknet_rl_process(timer_context_t data) +{ + struct ngknet_rl_ctrl *rc = timer_arg(rc, data, timer); + struct ngknet_dev *dev; + unsigned long flags; + int idx; + + spin_lock_irqsave(&rc->lock, flags); + rc->rx_pkts = 0; + for (idx = 0; idx < NUM_PDMA_DEV_MAX; idx++) { + dev = &rc->devs[idx]; + if (rc->dev_active[idx] && rc->dev_paused[idx]) { + bcmcnet_pdma_dev_rx_resume(&dev->pdma_dev); + rl_ctrl.dev_paused[dev->dev_no] = 0; + } + } + spin_unlock_irqrestore(&rc->lock, flags); + + rc->timer.expires = jiffies + HZ / rc->rx_ticks; + add_timer(&rc->timer); +} + +void +ngknet_rx_rate_limit_init(struct ngknet_dev *devs) +{ + sal_memset(&rl_ctrl, 0, sizeof(rl_ctrl)); + rl_ctrl.rx_ticks = 10; + setup_timer(&rl_ctrl.timer, ngknet_rl_process, (timer_context_t)&rl_ctrl); + spin_lock_init(&rl_ctrl.lock); + rl_ctrl.devs = devs; +} + +void +ngknet_rx_rate_limit_cleanup(void) +{ + del_timer_sync(&rl_ctrl.timer); +} + +int +ngknet_rx_rate_limit_started(void) +{ + return rl_ctrl.started; +} + +void +ngknet_rx_rate_limit_start(struct ngknet_dev *dev) +{ + unsigned long flags; + + spin_lock_irqsave(&rl_ctrl.lock, flags); + rl_ctrl.dev_active[dev->dev_no] = 1; + spin_unlock_irqrestore(&rl_ctrl.lock, flags); + + if (!rl_ctrl.started) { + rl_ctrl.started = 1; + rl_ctrl.timer.expires = jiffies + HZ / rl_ctrl.rx_ticks; + add_timer(&rl_ctrl.timer); + } +} + +void +ngknet_rx_rate_limit_stop(struct ngknet_dev *dev) +{ + unsigned long flags; + + spin_lock_irqsave(&rl_ctrl.lock, flags); + rl_ctrl.dev_active[dev->dev_no] = 0; + spin_unlock_irqrestore(&rl_ctrl.lock, flags); +} + +void +ngknet_rx_rate_limit(struct ngknet_dev *dev, int limit) +{ + unsigned long flags; + + spin_lock_irqsave(&rl_ctrl.lock, flags); + if ((++rl_ctrl.rx_pkts + rl_ctrl.rx_overruns > limit / rl_ctrl.rx_ticks) && + !rl_ctrl.dev_paused[dev->dev_no] && rl_ctrl.dev_active[dev->dev_no]) { + rl_ctrl.dev_paused[dev->dev_no] = 1; + rl_ctrl.rx_overruns = 0; + bcmcnet_pdma_dev_rx_suspend(&dev->pdma_dev); + } + if (rl_ctrl.dev_paused[dev->dev_no]) { + rl_ctrl.rx_overruns++; + } + spin_unlock_irqrestore(&rl_ctrl.lock, flags); +} + +void +ngknet_tx_queue_schedule(struct ngknet_dev *dev, struct sk_buff *skb, int *queue) +{ + struct pkt_buf *pkb = (struct pkt_buf *)skb->data; + + if (pkb->pkh.attrs & PDMA_TX_BIND_QUE) { + *queue = pkb->pkh.queue_id; + } +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_extra.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_extra.h new file mode 100644 index 000000000000..27dea9e368e7 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_extra.h @@ -0,0 +1,218 @@ +/*! \file ngknet_extra.h + * + * Generic data structure definitions for NGKNET enhancement. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef NGKNET_EXTRA_H +#define NGKNET_EXTRA_H + +/*! + * \brief Filter control. + */ +struct filt_ctrl { + /*! List head */ + struct list_head list; + + /*! Device number */ + int dev_no; + + /*! Number of hits */ + uint64_t hits; + + /*! Filter description */ + ngknet_filter_t filt; +}; + +/*! + * \brief Create filter. + * + * \param [in] dev Device structure point. + * \param [in] filter Filter structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +ngknet_filter_create(struct ngknet_dev *dev, ngknet_filter_t *filter); + +/*! + * \brief Destroy filter. + * + * \param [in] dev Device structure point. + * \param [in] id Filter ID. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +ngknet_filter_destroy(struct ngknet_dev *dev, int id); + +/*! + * \brief Destroy all the filters. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +ngknet_filter_destroy_all(struct ngknet_dev *dev); + +/*! + * \brief Get filter. + * + * \param [in] dev Device structure point. + * \param [in] id Filter ID. + * \param [out] filter Filter structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +ngknet_filter_get(struct ngknet_dev *dev, int id, ngknet_filter_t *filter); + +/*! + * \brief Get the next filter. + * + * \param [in] dev Device structure point. + * \param [out] filter Filter structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +ngknet_filter_get_next(struct ngknet_dev *dev, ngknet_filter_t *filter); + +/*! + * \brief Filter packet. + * + * \param [in] dev Device structure point. + * \param [in] skb Rx packet SKB. + * \param [out] mndev Mirror network interface. + * \param [out] mskb Mirror Rx packet SKB. + * + * \retval Matched network interface. + * \retval NULL No matched network interface. + */ +extern int +ngknet_rx_pkt_filter(struct ngknet_dev *dev, struct sk_buff *skb, struct net_device **ndev, + struct net_device **mndev, struct sk_buff **mskb); + +/*! + * \brief Rx rate limit control. + * + * This contains all the control information for Rx rate limit such as + * the number of Rx packets, status related to Rx rate limit, etc. + * + * The rate limit is kernel-oriented, i.e. all the Rx packets from any + * device/channel will be accounted for. Once the received packets reach + * the limit value in an 1-Sec interval, the driver API XXXX_rx_suspend() + * will be called to suspend Rx. The 1-Sec basis timer will call the driver + * API XXXX_rx_resume() to resume Rx and reset rate-related status/counters + * at the begin of the next 1-Sec interval. + * + * The NGKNET module parameter 'rx_rate_limit' is used to decide the maximum + * Rx rate. Disable Rx rate limit if set 0. It can be set when inserting + * NGKNET module or modified using its SYSFS attributions. + */ +struct ngknet_rl_ctrl { + /*! Rx packets */ + int rx_pkts; + + /*! Rx overruns */ + int rx_overruns; + + /*! Rx ticks */ + int rx_ticks; + + /*! Active devices under rate control */ + int dev_active[NUM_PDMA_DEV_MAX]; + + /*! Paused devices due to no Rx credit */ + int dev_paused[NUM_PDMA_DEV_MAX]; + + /*! Rate limit timer */ + struct timer_list timer; + + /*! Rate limit lock */ + spinlock_t lock; + + /*! Devices */ + struct ngknet_dev *devs; + + /*! Rate limit status indicator */ + int started; +}; + +/*! + * \brief Initialize Rx rate limit. + * + * \param [in] devs Devices array. + */ +extern void +ngknet_rx_rate_limit_init(struct ngknet_dev *devs); + +/*! + * \brief Cleanup Rx rate limit. + */ +extern void +ngknet_rx_rate_limit_cleanup(void); + +/*! + * \brief Get Rx rate limit state. + */ +extern int +ngknet_rx_rate_limit_started(void); + +/*! + * \brief Start Rx rate limit. + * + * \param [in] dev Device structure point. + */ +extern void +ngknet_rx_rate_limit_start(struct ngknet_dev *dev); + +/*! + * \brief Stop Rx rate limit. + * + * \param [in] dev Device structure point. + */ +extern void +ngknet_rx_rate_limit_stop(struct ngknet_dev *dev); + +/*! + * \brief Limit Rx rate. + * + * \param [in] dev Device structure point. + */ +extern void +ngknet_rx_rate_limit(struct ngknet_dev *dev, int limit); + +/*! + * \brief Schedule Tx queue. + * + * \param [in] dev Device structure point. + * \param [in] queue Tx queue number. + */ +extern void +ngknet_tx_queue_schedule(struct ngknet_dev *dev, struct sk_buff *skb, int *queue); + +#endif /* NGKNET_EXTRA_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_linux.c b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_linux.c new file mode 100644 index 000000000000..0162ae5b96c1 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_linux.c @@ -0,0 +1,173 @@ +/*! \file ngknet_linux.c + * + * Utility routines for Linux kernel APIs abstraction. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ngknet_linux.h" + +/*! + * Time + */ + +unsigned long +sal_time_usecs(void) +{ + struct timeval tv; + + kal_time_val_get(&tv); + + return tv.tv_sec * 1000000 + tv.tv_usec; +} + +void +sal_usleep(unsigned long usec) +{ + unsigned long then, now, hz; + + hz = usec * HZ / 1000000; + if (hz) { + schedule_timeout(hz); + } + usec = usec * HZ % 1000000 / HZ; + if (usec) { + then = sal_time_usecs(); + do { + schedule(); + now = sal_time_usecs(); + } while (now > then && (now - then) < usec); + } +} + +/*! + * Synchronization + */ + +typedef struct { + struct semaphore sem; + char *desc; + int binary; +} sem_ctrl_t; + +sal_sem_t +sal_sem_create(char *desc, int binary, int count) +{ + sem_ctrl_t *sc = kmalloc(sizeof(*sc), GFP_KERNEL); + + if (sc != NULL) { + sema_init(&sc->sem, count); + sc->desc = desc; + sc->binary = binary; + } + + return (sal_sem_t)sc; +} + +void +sal_sem_destroy(sal_sem_t sem) +{ + sem_ctrl_t *sc = (sem_ctrl_t *)sem; + + kfree(sc); +} + +int +sal_sem_take(sal_sem_t sem, int usec) +{ + sem_ctrl_t *sc = (sem_ctrl_t *)sem; + int rv; + + if (usec == SAL_SEM_FOREVER) { + do { + rv = down_interruptible(&sc->sem); + } while (rv == -EINTR); + return rv ? -1 : 0; + } + + return -1; +} + +int +sal_sem_give(sal_sem_t sem) +{ + sem_ctrl_t *sc = (sem_ctrl_t *)sem; + + up(&sc->sem); + + return 0; +} + +typedef struct spinlock_ctrl_s { + spinlock_t spinlock; + unsigned long flags; + char *desc; +} *spinlock_ctrl_t; + +sal_spinlock_t +sal_spinlock_create(char *desc) +{ + spinlock_ctrl_t sl = kmalloc(sizeof(*sl), GFP_KERNEL); + + if (sl != NULL) { + spin_lock_init(&sl->spinlock); + sl->flags = 0; + sl->desc = desc; + } + + return (sal_spinlock_t)sl; +} + +void +sal_spinlock_destroy(sal_spinlock_t lock) +{ + spinlock_ctrl_t sl = (spinlock_ctrl_t)lock; + + kfree(sl); +} + +int +sal_spinlock_lock(sal_spinlock_t lock) +{ + spinlock_ctrl_t sl = (spinlock_ctrl_t)lock; + + spin_lock_irqsave(&sl->spinlock, sl->flags); + + return 0; +} + +int +sal_spinlock_unlock(sal_spinlock_t lock) +{ + spinlock_ctrl_t sl = (spinlock_ctrl_t)lock; + + spin_unlock_irqrestore(&sl->spinlock, sl->flags); + + return 0; +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_linux.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_linux.h new file mode 100644 index 000000000000..686aac8f5571 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_linux.h @@ -0,0 +1,240 @@ +/*! \file ngknet_linux.h + * + * Data structure and macro definitions for Linux kernel APIs abstraction. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef NGKNET_LINUX_H +#define NGKNET_LINUX_H + +#include +#include +#include +#include + +/*! + * Kernel abstraction + */ + +#define MODULE_PARAM(n, t, p) module_param(n, t, p) + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) +#define kal_vlan_hwaccel_put_tag(skb, proto, tci) \ + __vlan_hwaccel_put_tag(skb, tci) +#define NETIF_F_HW_VLAN_CTAG_RX NETIF_F_HW_VLAN_RX +#define NETIF_F_HW_VLAN_CTAG_TX NETIF_F_HW_VLAN_TX +#else +#define kal_vlan_hwaccel_put_tag(skb, proto, tci) \ + __vlan_hwaccel_put_tag(skb, htons(proto), tci) +#endif /* KERNEL_VERSION(3,10,0) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0) +static inline int +kal_support_paged_skb(void) +{ + return false; +} +#else +static inline int +kal_support_paged_skb(void) +{ + return true; +} +#endif /* KERNEL_VERSION(3,6,0) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0) +static inline struct page * +kal_dev_alloc_page(void) +{ + return NULL; +} +#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0) +static inline struct page * +kal_dev_alloc_page(void) +{ + return alloc_pages(GFP_ATOMIC | __GFP_ZERO | __GFP_COLD | + __GFP_COMP | __GFP_MEMALLOC, 0); +} +#else +static inline struct page * +kal_dev_alloc_page(void) +{ + return dev_alloc_page(); +} +#endif /* KERNEL_VERSION(3,6,0) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0) +static inline struct sk_buff * +kal_build_skb(void *data, unsigned int frag_size) +{ + return NULL; +} +#else +static inline struct sk_buff * +kal_build_skb(void *data, unsigned int frag_size) +{ + return build_skb(data, frag_size); +} +#endif /* KERNEL_VERSION(3,6,0) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0) +static inline void +kal_netif_trans_update(struct net_device *dev) +{ + dev->trans_start = jiffies; +} +#else +static inline void +kal_netif_trans_update(struct net_device *dev) +{ + netif_trans_update(dev); +} +#endif /* KERNEL_VERSION(4,7,0) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0) +static inline void +kal_time_val_get(struct timeval *tv) +{ + do_gettimeofday(tv); +} +#else +static inline void +kal_time_val_get(struct timeval *tv) +{ + struct timespec64 ts; + ktime_get_real_ts64(&ts); + tv->tv_sec = ts.tv_sec; + tv->tv_usec = ts.tv_nsec / 1000; +} +#endif /* KERNEL_VERSION(3,17,0) */ + +static inline unsigned long +kal_copy_from_user(void *to, const void __user *from, + unsigned int dl, unsigned int sl) +{ + unsigned int len = dl; + + if (unlikely(len != sl)) { + printk(KERN_WARNING "Unmatched linux_ngknet.ko, please use the latest.\n"); + len = min(dl, sl); + } + + return copy_from_user(to, from, len); +} + +static inline unsigned long +kal_copy_to_user(void __user *to, const void *from, + unsigned int dl, unsigned int sl) +{ + unsigned int len = dl; + + if (unlikely(len != sl)) { + printk(KERN_WARNING "Unmatched linux_ngknet.ko, please use the latest.\n"); + len = min(dl, sl); + } + + return copy_to_user(to, from, len); +} + +/*! + * System abstraction + */ + +static inline void * +sal_alloc(unsigned int sz, char *s) +{ + return kmalloc(sz, GFP_KERNEL); +} + +static inline void +sal_free(void *addr) +{ + kfree(addr); +} + +static inline void * +sal_memset(void *dest, int c, size_t cnt) +{ + return memset(dest, c, cnt); +} + +static inline void * +sal_memcpy(void *dest, const void *src, size_t cnt) +{ + return memcpy(dest, src, cnt); +} + +static inline char * +sal_strncpy(char *dest, const char *src, size_t cnt) +{ + return strncpy(dest, src, cnt); +} + +/*! + * Time + */ + +extern unsigned long +sal_time_usecs(void); + +extern void +sal_usleep(unsigned long usec); + +/*! + * Synchronization + */ + +typedef struct sal_sem_s { + char semaphore_opaque_type; +} *sal_sem_t; + +typedef struct sal_spinlock_s { + char spinlock_opaque_type; +} *sal_spinlock_t; + +#define SAL_SEM_FOREVER -1 +#define SAL_SEM_BINARY 1 +#define SAL_SEM_COUNTING 0 + +extern sal_sem_t +sal_sem_create(char *desc, int binary, int count); + +extern void +sal_sem_destroy(sal_sem_t sem); + +extern int +sal_sem_take(sal_sem_t sem, int usec); + +extern int +sal_sem_give(sal_sem_t sem); + +extern sal_spinlock_t +sal_spinlock_create(char *desc); + +extern void +sal_spinlock_destroy(sal_spinlock_t lock); + +extern int +sal_spinlock_lock(sal_spinlock_t lock); + +extern int +sal_spinlock_unlock(sal_spinlock_t lock); + +#endif /* NGKNET_LINUX_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_main.c b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_main.c new file mode 100644 index 000000000000..b8af31d85ff2 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_main.c @@ -0,0 +1,2689 @@ +/*! \file ngknet_main.c + * + * NGKNET module entry. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +/* + * This module implements a Linux network driver for Broadcom + * XGS switch devices. The driver simultaneously serves a + * number of virtual Linux network devices. + * + * Packets received from the switch device are sent to a virtual + * Linux network device based on a set of packet filters. + * + * Packets from the virtual Linux network devices are multiplexed + * with fifo mode if only one Tx queue enabled. + * + * A command-based IOCTL interface is used for managing the devices, + * packet filters and virtual Linux network interfaces. + * + * A virtual network interface can be configured to work in RCPU + * mode, which means that packets from the switch device will + * be encapsulated with a RCPU header and a block of meta data + * that basically contains the core DCB information. Likewise, + * packets received from the Linux network stack are assumed to + * be RCPU encapsulated when going out on an interface in RCPU + * mode. If a virtual network interface does not work in RCPU + * mode and transmits to this interface will unmodified go to + * specified physical switch port, DCB information should be + * provided when the interface is created. + * + * The module implements basic Rx DMA rate control. The rate is + * specified in packets per second, and different Rx DMA channels + * can be configured to use different maximum packet rates. + * The packet rate can be configure as a module parameter, and + * it can also be changed dynamically through the proc file + * system (syntax is described in function header comment). + * + * For a list of supported module parameters, please see below. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include "ngknet_main.h" +#include "ngknet_extra.h" +#include "ngknet_procfs.h" +#include "ngknet_callback.h" +#include "ngknet_ptp.h" + +/*! \cond */ +MODULE_AUTHOR("Broadcom Corporation"); +MODULE_DESCRIPTION("Network Device Driver Module"); +MODULE_LICENSE("GPL"); +/*! \endcond */ + +/*! \cond */ +static int debug = 0; +MODULE_PARAM(debug, int, 0); +MODULE_PARM_DESC(debug, +"Debug level (default 0)"); +/*! \endcond */ + +/*! \cond */ +static char *base_dev_name = "bcm"; +MODULE_PARAM(base_dev_name, charp, 0); +MODULE_PARM_DESC(base_dev_name, +"Base device name (default bcm0, bcm1, etc.)"); +/*! \endcond */ + +/*! \cond */ +static char *mac_addr = NULL; +MODULE_PARAM(mac_addr, charp, 0); +MODULE_PARM_DESC(mac_addr, +"Ethernet MAC address (default 02:10:18:xx:xx:xx)"); +/*! \endcond */ + +/*! \cond */ +static int default_mtu = 1500; +MODULE_PARAM(default_mtu, int, 0); +MODULE_PARM_DESC(default_mtu, +"Default MTU for NGKNET network interfaces (default 1500)"); +/*! \endcond */ + +/*! \cond */ +static int rx_buffer_size = RX_BUF_SIZE_DFLT; +MODULE_PARAM(rx_buffer_size, int, 0); +MODULE_PARM_DESC(rx_buffer_size, +"Default size of RX packet buffers (default 9216)"); +/*! \endcond */ + +/*! \cond */ +static int rx_rate_limit = -1; +MODULE_PARAM(rx_rate_limit, int, 0); +MODULE_PARM_DESC(rx_rate_limit, +"Rx rate limit (pps, default -1 no limit)"); +/*! \endcond */ + +/*! \cond */ +static int tx_polling = 0; +MODULE_PARAM(tx_polling, int, 0); +MODULE_PARM_DESC(tx_polling, +"Tx polling mode (default 0 in interrupt mode)"); +/*! \endcond */ + +/*! \cond */ +static int rx_batching = 0; +MODULE_PARAM(rx_batching, int, 0); +MODULE_PARM_DESC(rx_batching, +"Rx batching mode (default 0 in single fill mode)"); +/*! \endcond */ + +typedef int (*drv_ops_attach)(struct pdma_dev *dev); + +struct bcmcnet_drv_ops { + const char *drv_desc; + drv_ops_attach drv_attach; + drv_ops_attach drv_detach; +}; + +#define BCMDRD_DEVLIST_ENTRY(_nm,_vn,_dv,_rv,_md,_pi,_bd,_bc,_fn,_cn,_pf,_pd,_r0,_r1) \ + static struct bcmcnet_drv_ops _bd##_cnet_drv_ops = { \ + #_bd, \ + _bd##_cnet_pdma_attach, \ + _bd##_cnet_pdma_detach, \ + }; +#include + +#define BCMDRD_DEVLIST_ENTRY(_nm,_vn,_dv,_rv,_md,_pi,_bd,_bc,_fn,_cn,_pf,_pd,_r0,_r1) \ + &_bd##_cnet_drv_ops, +static struct bcmcnet_drv_ops *drv_ops[] = { + NULL, +#include + NULL +}; +static int drv_num = sizeof(drv_ops) / sizeof(drv_ops[0]); + +struct ngknet_dev ngknet_devices[NUM_PDMA_DEV_MAX]; + +/* Default random MAC address has Broadcom OUI with local admin bit set */ +static uint8_t ngknet_dev_mac[6] = {0x02, 0x10, 0x18, 0x00, 0x00, 0x00}; + +/* Interrupt handles */ +struct ngknet_intr_handle { + struct napi_struct napi; + struct intr_handle *hdl; + int napi_resched; + int napi_pending; +}; + +static struct ngknet_intr_handle priv_hdl[NUM_PDMA_DEV_MAX][NUM_QUE_MAX]; + +/*! + * Dump packet content for debug + */ +static void +ngknet_pkt_dump(uint8_t *data, int len) +{ + char str[128]; + int i; + + len = len > 256 ? 256 : len; + + for (i = 0; i < len; i++) { + if ((i & 0x1f) == 0) { + sprintf(str, "%04x: ", i); + } + sprintf(&str[strlen(str)], "%02x", data[i]); + if ((i & 0x1f) == 0x1f) { + sprintf(&str[strlen(str)], "\n"); + printk(str); + continue; + } + if ((i & 0x3) == 0x3) { + sprintf(&str[strlen(str)], " "); + } + } + if ((i & 0x1f) != 0) { + sprintf(&str[strlen(str)], "\n"); + printk(str); + } + printk("\n"); +} + +/*! + * Rx packets rate test for debug + */ +static void +ngknet_pkt_stats(struct pdma_dev *pdev, int dir) +{ + static struct timeval tv0[2], tv1[2]; + static uint32_t pkts[2] = {0}, prts[2] = {0}; + static uint64_t intrs = 0; + + if (pkts[dir] == 0) { + kal_time_val_get(&tv0[dir]); + intrs = pdev->stats.intrs; + } + if (++pkts[dir] >= 100000) { + uint32_t iv_time; + uint32_t pps; + kal_time_val_get(&tv1[dir]); + iv_time = (tv1[dir].tv_sec - tv0[dir].tv_sec) * 1000000 + + (tv1[dir].tv_usec - tv0[dir].tv_usec); + pps = 100000 * 1000 / (iv_time / 1000); + prts[dir]++; + if (pps <= 100000 || prts[dir] * 100000 >= pps) { + printk(KERN_CRIT "%s -- limit: %d pps, 100K pkts time: %d usec, rate: %d pps, intrs: %llu\n", + dir == PDMA_Q_RX ? "Rx" : "Tx", + dir == PDMA_Q_RX ? rx_rate_limit : -1, + iv_time, pps, pdev->stats.intrs - intrs); + prts[dir] = 0; + } + pkts[dir] = 0; + } +} + +/*! + * Read 32-bit register callback + */ +static int +ngknet_dev_read32(struct pdma_dev *dev, uint32_t addr, uint32_t *data) +{ + *data = ngbde_kapi_pio_read32(dev->unit, addr); + + return 0; +} + +/*! + * Write 32-bit register callback + */ +static int +ngknet_dev_write32(struct pdma_dev *dev, uint32_t addr, uint32_t data) +{ + ngbde_kapi_pio_write32(dev->unit, addr, data); + + return 0; +} + +/*! + * Set Rx HW timestamping. + */ +static int +ngknet_ptp_rx_hwts_set(struct net_device *ndev, struct sk_buff *skb) +{ + struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb); + uint64_t ts = 0; + int rv; + + rv = ngknet_ptp_rx_hwts_get(ndev, skb, &ts); + if (SHR_FAILURE(rv) || !ts) { + return SHR_E_FAIL; + } + + memset(shhwtstamps, 0, sizeof(*shhwtstamps)); + shhwtstamps->hwtstamp = ns_to_ktime(ts); + + return SHR_E_NONE; +} + +/*! + * \brief Process Rx packet. + * + * Add RCPU encapsulation or strip matadata if needed + * + * \param [in] ndev Network device structure point. + * \param [in] oskb Rx packet SKB. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +ngknet_rx_frame_process(struct net_device *ndev, struct sk_buff **oskb) +{ + struct ngknet_private *priv = netdev_priv(ndev); + struct ngknet_dev *dev = priv->bkn_dev; + struct sk_buff *skb = *oskb; + struct ngknet_rcpu_hdr *rch = (struct ngknet_rcpu_hdr *)skb->data; + struct pkt_hdr *pkh = (struct pkt_hdr *)skb->data; + uint8_t meta_len = pkh->meta_len; + + /* Do Rx timestamping */ + if (priv->hwts_rx_filter) { + ngknet_ptp_rx_hwts_set(ndev, skb); + } + + /* Remove FCS from packet length */ + skb_trim(skb, skb->len - ETH_FCS_LEN); + pkh->data_len -= ETH_FCS_LEN; + + if (priv->flags & NGKNET_NETIF_F_RCPU_ENCAP) { + /* Set up RCPU header */ + memcpy(skb->data, skb->data + PKT_HDR_SIZE + meta_len, 2 * ETH_ALEN); + if (*(uint32_t *)&dev->rcpu_ctrl.dst_mac[0] != 0 || + *(uint16_t *)&dev->rcpu_ctrl.dst_mac[4] != 0) { + memcpy(rch->dst_mac, dev->rcpu_ctrl.dst_mac, ETH_ALEN); + } + if (*(uint32_t *)&dev->rcpu_ctrl.src_mac[0] != 0 || + *(uint16_t *)&dev->rcpu_ctrl.src_mac[4] != 0) { + memcpy(rch->src_mac, dev->rcpu_ctrl.src_mac, ETH_ALEN); + } + rch->vlan_tpid = htons(dev->rcpu_ctrl.vlan_tpid); + rch->vlan_tci = htons(dev->rcpu_ctrl.vlan_tci); + rch->eth_type = htons(dev->rcpu_ctrl.eth_type); + rch->pkt_sig = htons(dev->rcpu_ctrl.pkt_sig); + rch->op_code = RCPU_OPCODE_RX; + rch->flags = RCPU_FLAG_MODHDR; + rch->trans_id = htons(dev->rcpu_ctrl.trans_id); + rch->data_len = htons(pkh->data_len); + } else { + /* Remove packet header and meta data */ + skb_pull(skb, PKT_HDR_SIZE + meta_len); + } + + /* Optional callback handle */ + if (dev->cbc->rx_cb) { + struct ngknet_callback_desc *cbd = NGKNET_SKB_CB(skb); + cbd->dev_no = dev->dev_no; + cbd->dev_id = dev->pdma_dev.dev_id; + cbd->type_str = drv_ops[dev->pdma_dev.dev_type]->drv_desc; + cbd->priv = priv; + if (priv->flags & NGKNET_NETIF_F_RCPU_ENCAP) { + cbd->pmd = skb->data + PKT_HDR_SIZE; + cbd->pkt_len = ntohs(rch->data_len); + } else { + cbd->pmd = skb->data - meta_len; + cbd->pkt_len = pkh->data_len; + } + cbd->pmd_len = meta_len; + skb = dev->cbc->rx_cb(skb); + if (!skb) { + *oskb = NULL; + return SHR_E_UNAVAIL; + } + if (priv->flags & NGKNET_NETIF_F_RCPU_ENCAP) { + rch = (struct ngknet_rcpu_hdr *)skb->data; + rch->data_len = htons(skb->len - PKT_HDR_SIZE - meta_len); + } + } + + /* Update SKB pointer */ + *oskb = skb; + + return SHR_E_NONE; +} + +/*! + * \brief Network interface Rx function. + * + * After processing the packet, send it up to network stack. + * + * \param [in] ndev Network device structure point. + * \param [in] skb Rx packet SKB. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +ngknet_netif_recv(struct net_device *ndev, struct sk_buff *skb) +{ + struct ngknet_private *priv = netdev_priv(ndev); + struct ngknet_dev *dev = priv->bkn_dev; + struct pdma_dev *pdev = &dev->pdma_dev; + struct pkt_hdr *pkh = (struct pkt_hdr *)skb->data; + struct napi_struct *napi = NULL; + uint16_t proto; + int chan, gi, qi; + int rv; + + /* Handle one incoming packet */ + rv = ngknet_rx_frame_process(ndev, &skb); + if (SHR_FAILURE(rv)) { + if (!skb) { + return SHR_E_NONE; + } + } + + DBG_VERB(("Rx packet sent up to ndev%d (%d bytes).\n", priv->id, skb->len)); + if (debug & DBG_LVL_PDMP) { + ngknet_pkt_dump(skb->data, skb->len); + } + + if (ndev->features & NETIF_F_RXCSUM) { + if ((pkh->attrs & (PDMA_RX_TU_CSUM | PDMA_RX_IP_CSUM)) == + (PDMA_RX_TU_CSUM | PDMA_RX_IP_CSUM)) { + skb->ip_summed = CHECKSUM_UNNECESSARY; + } else { + skb_checksum_none_assert(skb); + } + } + + if (!(priv->flags & NGKNET_NETIF_F_RCPU_ENCAP) && + ndev->features & NETIF_F_HW_VLAN_CTAG_RX && + pkh->attrs & PDMA_RX_STRIP_TAG) { + kal_vlan_hwaccel_put_tag(skb, ETH_P_8021Q, priv->vlan); + } + + proto = eth_type_trans(skb, ndev); + if (priv->flags & NGKNET_NETIF_F_RCPU_ENCAP) { + skb->protocol = htons(dev->rcpu_ctrl.eth_type); + } else if (!(pkh->attrs & PDMA_RX_SET_PROTO) || !skb->protocol) { + skb->protocol = proto; + } + + skb_record_rx_queue(skb, pkh->queue_id); + + bcmcnet_pdma_dev_queue_to_chan(pdev, pkh->queue_id, PDMA_Q_RX, &chan); + gi = chan / pdev->grp_queues; + if (pdev->flags & PDMA_GROUP_INTR) { + napi = (struct napi_struct *)pdev->ctrl.grp[gi].intr_hdl[0].priv; + } else { + qi = pkh->queue_id; + napi = (struct napi_struct *)pdev->ctrl.grp[gi].intr_hdl[qi].priv; + } + napi_gro_receive(napi, skb); + + /* Update accounting */ + priv->stats.rx_packets++; + priv->stats.rx_bytes += skb->len; + + /* Rate limit */ + if (rx_rate_limit >= 0) { + if (!ngknet_rx_rate_limit_started()) { + ngknet_rx_rate_limit_start(dev); + } + ngknet_rx_rate_limit(dev, rx_rate_limit); + } + + return SHR_E_NONE; +} + +/*! + * \brief Driver Rx callback. + * + * After processing the packet, send it up to network stack. + * + * \param [in] pdev Packet DMA device structure point. + * \param [in] buf Raw Rx buffer. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +ngknet_frame_recv(struct pdma_dev *pdev, int queue, void *buf) +{ + struct ngknet_dev *dev = (struct ngknet_dev *)pdev->priv; + struct sk_buff *skb = (struct sk_buff *)buf, *mskb = NULL; + struct net_device *ndev = NULL, *mndev = NULL; + struct ngknet_private *priv = NULL; + unsigned long flags; + int rv; + + DBG_VERB(("Rx packet (%d bytes).\n", skb->len)); + if (debug & DBG_LVL_PDMP) { + ngknet_pkt_dump(skb->data, skb->len); + } + + /* Go through the filters */ + rv = ngknet_rx_pkt_filter(dev, skb, &ndev, &mndev, &mskb); + if (SHR_FAILURE(rv) || !ndev) { + return SHR_E_FAIL; + } + + /* Populate header, checksum status, VLAN, and protocol */ + priv = netdev_priv(ndev); + if (netif_carrier_ok(ndev)) { + ngknet_netif_recv(ndev, skb); + } else { + priv->stats.rx_dropped++; + rv = SHR_E_UNAVAIL; + } + + spin_lock_irqsave(&dev->lock, flags); + priv->users--; + if (!priv->users && priv->wait) { + wake_up(&dev->wq); + } + spin_unlock_irqrestore(&dev->lock, flags); + + /* Handle mirrored packet */ + if (mndev && mskb) { + priv = netdev_priv(mndev); + if (netif_carrier_ok(mndev)) { + ngknet_netif_recv(mndev, mskb); + } else { + priv->stats.rx_dropped++; + dev_kfree_skb_any(mskb); + } + spin_lock_irqsave(&dev->lock, flags); + priv->users--; + if (!priv->users && priv->wait) { + wake_up(&dev->wq); + } + spin_unlock_irqrestore(&dev->lock, flags); + } + + /* Measure speed */ + if (debug & DBG_LVL_RATE) { + ngknet_pkt_stats(pdev, PDMA_Q_RX); + } + + return rv; +} + +/*! + * Set Tx HW timestamping. + */ +static int +ngknet_ptp_tx_hwts_set(struct net_device *ndev, struct sk_buff *skb) +{ + struct skb_shared_hwtstamps shhwtstamps; + uint64_t ts = 0; + int rv; + + rv = ngknet_ptp_tx_hwts_get(ndev, skb, &ts); + if (SHR_FAILURE(rv) || !ts) { + return SHR_E_FAIL; + } + + memset(&shhwtstamps, 0, sizeof(shhwtstamps)); + shhwtstamps.hwtstamp = ns_to_ktime(ts); + skb_tstamp_tx(skb, &shhwtstamps); + + return SHR_E_NONE; +} + +/*! + * PTP Tx worker. + */ +static void +ngknet_ptp_tx_work(struct work_struct *work) +{ + struct ngknet_dev *dev = container_of(work, struct ngknet_dev, ptp_tx_work); + struct sk_buff *skb; + int rv; + + while (skb_queue_len(&dev->ptp_tx_queue)) { + skb = skb_dequeue(&dev->ptp_tx_queue); + rv = ngknet_ptp_tx_hwts_set(dev->net_dev, skb); + if (SHR_FAILURE(rv)) { + printk("Timestamp value has not been set for current skb.\n"); + } + dev_kfree_skb_any(skb); + } +} + +/*! + * Config Tx metadata for HW timestamping. + */ +static int +ngknet_ptp_tx_config(struct net_device *ndev, struct sk_buff *skb) +{ + struct ngknet_private *priv = netdev_priv(ndev); + struct ngknet_dev *dev = priv->bkn_dev; + int rv; + + if (priv->type == NGKNET_NETIF_T_PORT) { + rv = ngknet_ptp_tx_meta_set(ndev, skb); + if (SHR_FAILURE(rv)) { + return rv; + } + } else if (priv->hwts_tx_type != HWTSTAMP_TX_ONESTEP_SYNC) { + return SHR_E_UNAVAIL; + } + + skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; + + if (priv->hwts_tx_type == HWTSTAMP_TX_ONESTEP_SYNC) { + skb_queue_tail(&dev->ptp_tx_queue, skb_get(skb)); + schedule_work(&dev->ptp_tx_work); + } + + return SHR_E_NONE; +} + +/*! + * \brief Process Tx packet. + * + * Strip RCPU encapsulation, setup CNET packet buffer, add vlan tag + * or pad the packet. + * + * \param [in] ndev Network device structure point. + * \param [in] oskb Tx packet SKB. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +ngknet_tx_frame_process(struct net_device *ndev, struct sk_buff **oskb) +{ + struct ngknet_private *priv = netdev_priv(ndev); + struct ngknet_dev *dev = priv->bkn_dev; + struct sk_buff *skb = *oskb; + struct ngknet_rcpu_hdr *rch = (struct ngknet_rcpu_hdr *)skb->data; + struct pkt_hdr *pkh = (struct pkt_hdr *)skb->data; + struct sk_buff *nskb = NULL; + char *data = NULL; + uint32_t copy_len, meta_len, data_len, pkt_len, tag_len; + uint16_t tpid; + + /* Set up packet header */ + if (priv->flags & NGKNET_NETIF_F_RCPU_ENCAP) { + /* RCPU encapsulation packet */ + data_len = pkh->attrs & PDMA_TX_HDR_COOKED ? + pkh->data_len - ETH_FCS_LEN : ntohs(rch->data_len); + pkt_len = PKT_HDR_SIZE + rch->meta_len + data_len; + if (skb->len != pkt_len || skb->len < (PKT_HDR_SIZE + 14)) { + DBG_WARN(("Tx drop: Invalid RCPU encapsulation\n")); + return SHR_E_FAIL; + } + if (dev->rcpu_ctrl.pkt_sig && dev->rcpu_ctrl.pkt_sig != ntohs(rch->pkt_sig)) { + DBG_WARN(("Tx drop: Invalid RCPU signature\n")); + return SHR_E_FAIL; + } + if (pkh->attrs & PDMA_TX_HDR_COOKED) { + /* Resumed packet */ + return SHR_E_NONE; + } + pkh->data_len = data_len + ETH_FCS_LEN; + pkh->meta_len = rch->meta_len; + pkh->attrs = 0; + if (rch->flags & RCPU_FLAG_MODHDR) { + pkh->attrs |= PDMA_TX_HIGIG_PKT; + } + if (rch->flags & RCPU_FLAG_PAUSE) { + pkh->attrs |= PDMA_TX_PAUSE_PKT; + } + if (rch->flags & RCPU_FLAG_PURGE) { + pkh->attrs |= PDMA_TX_PURGE_PKT; + } + if (rch->flags & RCPU_FLAG_BIND_QUE) { + pkh->attrs |= PDMA_TX_BIND_QUE; + } + } else { + /* Non-RCPU encapsulation packet */ + data_len = pkh->data_len - ETH_FCS_LEN; + pkt_len = PKT_HDR_SIZE + pkh->meta_len + data_len; + if (skb->len == pkt_len && pkh->attrs & PDMA_TX_HDR_COOKED && + pkh->pkt_sig == dev->rcpu_ctrl.pkt_sig) { + /* Resumed packet */ + return SHR_E_NONE; + } + meta_len = 0; + if (priv->type == NGKNET_NETIF_T_PORT) { + meta_len = priv->meta_len; + if (!meta_len) { + printk("Tx abort: no metadata\n"); + return SHR_E_UNAVAIL; + } + } + if (skb_header_cloned(skb) || + skb_headroom(skb) < (PKT_HDR_SIZE + meta_len + VLAN_HLEN) || + skb_tailroom(skb) < ETH_FCS_LEN) { + nskb = skb_copy_expand(skb, PKT_HDR_SIZE + meta_len + VLAN_HLEN, + ETH_FCS_LEN, GFP_ATOMIC); + if (!nskb) { + return SHR_E_MEMORY; + } + skb_shinfo(nskb)->tx_flags = skb_shinfo(skb)->tx_flags; + skb = nskb; + } + skb_push(skb, PKT_HDR_SIZE + meta_len); + memset(skb->data, 0, PKT_HDR_SIZE + meta_len); + pkh = (struct pkt_hdr *)skb->data; + pkh->data_len = skb->len - PKT_HDR_SIZE - meta_len + ETH_FCS_LEN; + pkh->meta_len = meta_len; + pkh->attrs = 0; + if (priv->type == NGKNET_NETIF_T_PORT) { + /* Send to physical port using netif metadata */ + if (priv->meta_off) { + memmove(skb->data + PKT_HDR_SIZE, skb->data + PKT_HDR_SIZE + meta_len, priv->meta_off); + } + memcpy(skb->data + PKT_HDR_SIZE + priv->meta_off, priv->meta_data, priv->meta_len); + pkh->attrs |= PDMA_TX_HIGIG_PKT; + } + pkh->pkt_sig = dev->rcpu_ctrl.pkt_sig; + } + + /* Packet header done here */ + pkh->attrs |= PDMA_TX_HDR_COOKED; + + data = skb->data + PKT_HDR_SIZE + pkh->meta_len; + tpid = data[12] << 8 | data[13]; + tag_len = (tpid == ETH_P_8021Q || tpid == ETH_P_8021AD) ? VLAN_HLEN : 0; + + /* Need to add VLAN tag if packet is untagged */ + if (!tag_len && (!(pkh->attrs & PDMA_TX_HIGIG_PKT) || priv->flags & NGKNET_NETIF_F_ADD_TAG)) { + copy_len = PKT_HDR_SIZE + pkh->meta_len + 2 * ETH_ALEN; + if (skb_header_cloned(skb) || skb_headroom(skb) < VLAN_HLEN) { + nskb = skb_copy_expand(skb, VLAN_HLEN, 0, GFP_ATOMIC); + if (!nskb) { + return SHR_E_MEMORY; + } + skb_shinfo(nskb)->tx_flags = skb_shinfo(skb)->tx_flags; + skb = nskb; + } + skb_push(skb, VLAN_HLEN); + memmove(skb->data, skb->data + VLAN_HLEN, copy_len); + pkh = (struct pkt_hdr *)skb->data; + data = skb->data + PKT_HDR_SIZE + pkh->meta_len; + data[12] = 0x81; + data[13] = 0x00; + data[14] = priv->vlan >> 8 & 0xf; + data[15] = priv->vlan & 0xff; + pkh->data_len += VLAN_HLEN; + tag_len = VLAN_HLEN; + } + + /* Optional callback handle */ + if (dev->cbc->tx_cb) { + struct ngknet_callback_desc *cbd = NGKNET_SKB_CB(skb); + cbd->dev_no = dev->dev_no; + cbd->dev_id = dev->pdma_dev.dev_id; + cbd->type_str = drv_ops[dev->pdma_dev.dev_type]->drv_desc; + cbd->priv = priv; + cbd->pmd = skb->data + PKT_HDR_SIZE; + cbd->pmd_len = pkh->meta_len; + cbd->pkt_len = skb->len - PKT_HDR_SIZE - pkh->meta_len; + skb = dev->cbc->tx_cb(skb); + if (!skb) { + if (!nskb) { + *oskb = NULL; + } + return SHR_E_UNAVAIL; + } + pkh = (struct pkt_hdr *)skb->data; + pkh->data_len = skb->len - PKT_HDR_SIZE - pkh->meta_len + ETH_FCS_LEN; + } + + /* Pad packet if needed */ + if (pkh->data_len < (64 + tag_len)) { + pkh->data_len = 64 + tag_len; + if (skb_padto(skb, PKT_HDR_SIZE + pkh->meta_len + pkh->data_len - ETH_FCS_LEN)) { + if (!nskb) { + *oskb = NULL; + } + return SHR_E_MEMORY; + } + } + + /* Update SKB pointer */ + *oskb = skb; + + return SHR_E_NONE; +} + +/*! + * Suspend Tx queue callback + */ +static void +ngknet_tx_suspend(struct pdma_dev *pdev, int queue) +{ + struct ngknet_dev *dev = (struct ngknet_dev *)pdev->priv; + unsigned long flags; + int vdi; + + netif_stop_subqueue(dev->net_dev, queue); + + spin_lock_irqsave(&dev->lock, flags); + for (vdi = 1; vdi <= NUM_VDEV_MAX; vdi++) { + if (!dev->vdev[vdi]) { + continue; + } + netif_stop_subqueue(dev->vdev[vdi], queue); + } + spin_unlock_irqrestore(&dev->lock, flags); +} + +/*! + * Resume Tx queue callback + */ +static void +ngknet_tx_resume(struct pdma_dev *pdev, int queue) +{ + struct ngknet_dev *dev = (struct ngknet_dev *)pdev->priv; + unsigned long flags; + int vdi; + + if (__netif_subqueue_stopped(dev->net_dev, queue)) { + netif_wake_subqueue(dev->net_dev, queue); + } + + spin_lock_irqsave(&dev->lock, flags); + for (vdi = 1; vdi <= NUM_VDEV_MAX; vdi++) { + if (!dev->vdev[vdi]) { + continue; + } + if (__netif_subqueue_stopped(dev->vdev[vdi], queue)) { + netif_wake_subqueue(dev->vdev[vdi], queue); + } + } + spin_unlock_irqrestore(&dev->lock, flags); + + if (pdev->mode == DEV_MODE_HNET) { + atomic_set(&dev->hnet_active, 1); + wake_up_interruptible(&dev->hnet_wq); + } +} + +/*! + * Enable interrupt callback + */ +static void +ngknet_intr_enable(struct pdma_dev *pdev, int cmc, int chan, + uint32_t reg, uint32_t mask) +{ + pdev->ctrl.grp[cmc].irq_mask |= mask; + ngbde_kapi_intr_mask_write(pdev->unit, 0, reg, pdev->ctrl.grp[cmc].irq_mask); +} + +/*! + * Disable interrupt callback + */ +static void +ngknet_intr_disable(struct pdma_dev *pdev, int cmc, int chan, + uint32_t reg, uint32_t mask) +{ + pdev->ctrl.grp[cmc].irq_mask &= ~mask; + ngbde_kapi_intr_mask_write(pdev->unit, 0, reg, pdev->ctrl.grp[cmc].irq_mask); +} + +/*! + * NAPI polling function + */ +static int +ngknet_poll(struct napi_struct *napi, int budget) +{ + struct ngknet_intr_handle *kih = (struct ngknet_intr_handle *)napi; + struct intr_handle *hdl = kih->hdl; + struct pdma_dev *pdev = (struct pdma_dev *)hdl->dev; + struct ngknet_dev *dev = (struct ngknet_dev *)pdev->priv; + unsigned long flags; + int work_done; + + DBG_NAPI(("Scheduled NAPI on queue %d.\n", hdl->queue)); + + kih->napi_resched = 0; + kih->napi_pending = 0; + + if (pdev->flags & PDMA_GROUP_INTR) { + work_done = bcmcnet_group_poll(pdev, hdl->group, budget); + } else { + work_done = bcmcnet_queue_poll(pdev, hdl, budget); + } + + if (work_done < budget) { + napi_complete(napi); + if (kih->napi_pending && napi_schedule_prep(napi)) { + __napi_schedule(napi); + return work_done; + } + spin_lock_irqsave(&dev->lock, flags); + if (!kih->napi_resched) { + if (pdev->flags & PDMA_GROUP_INTR) { + bcmcnet_group_intr_enable(pdev, hdl->group); + } else { + bcmcnet_queue_intr_enable(pdev, hdl); + } + } + spin_unlock_irqrestore(&dev->lock, flags); + } + + return work_done; +} + +/*! + * NGKNET ISR + */ +static int +ngknet_isr(void *isr_data) +{ + struct ngknet_dev *dev = isr_data; + struct pdma_dev *pdev = &dev->pdma_dev; + struct intr_handle *hdl = NULL; + struct napi_struct *napi = NULL; + unsigned long flags; + int gi, qi; + int iv = 0; + + for (gi = 0; gi < pdev->num_groups; gi++) { + if (!pdev->ctrl.grp[gi].attached) { + continue; + } + for (qi = 0; qi < pdev->grp_queues; qi++) { + hdl = &pdev->ctrl.grp[gi].intr_hdl[qi]; + if (pdev->flags & PDMA_GROUP_INTR) { + if (!bcmcnet_group_intr_check(pdev, gi)) { + break; + } + } else { + if (!bcmcnet_queue_intr_check(pdev, hdl)) { + continue; + } + } + spin_lock_irqsave(&dev->lock, flags); + if (pdev->flags & PDMA_GROUP_INTR) { + bcmcnet_group_intr_disable(pdev, gi); + } else { + bcmcnet_queue_intr_disable(pdev, hdl); + } + spin_unlock_irqrestore(&dev->lock, flags); + napi = (struct napi_struct *)hdl->priv; + if (likely(napi_schedule_prep(napi))) { + __napi_schedule(napi); + } + iv++; + if (pdev->flags & PDMA_GROUP_INTR) { + break; + } + } + } + + if (iv) { + DBG_IRQ(("Got interrupt on device %d.\n", dev->dev_no)); + pdev->stats.intrs++; + return IRQ_HANDLED; + } else { + return IRQ_NONE; + } +} + +/*! + * Hypervisor network work handler + */ +static void +ngknet_dev_hnet_work(struct pdma_dev *pdev) +{ + struct ngknet_dev *dev = (struct ngknet_dev *)pdev->priv; + struct intr_handle *hdl = NULL; + struct napi_struct *napi = NULL; + struct ngknet_intr_handle *kih = NULL; + unsigned long flags; + int gi, qi; + + for (gi = 0; gi < pdev->num_groups; gi++) { + if (!pdev->ctrl.grp[gi].attached) { + continue; + } + for (qi = 0; qi < pdev->grp_queues; qi++) { + hdl = &pdev->ctrl.grp[gi].intr_hdl[qi]; + napi = (struct napi_struct *)hdl->priv; + kih = (struct ngknet_intr_handle *)napi; + kih->napi_pending = 1; + if (napi_schedule_prep(napi)) { + spin_lock_irqsave(&dev->lock, flags); + kih->napi_resched = 1; + spin_unlock_irqrestore(&dev->lock, flags); + local_bh_disable(); + __napi_schedule(napi); + local_bh_enable(); + } + if (pdev->flags & PDMA_GROUP_INTR) { + break; + } + } + } +} + +/*! + * Hypervisor network wait handler + */ +static int +ngknet_dev_hnet_wait(struct pdma_dev *pdev) +{ + struct ngknet_dev *dev = (struct ngknet_dev *)pdev->priv; + int qi; + int rv; + + while (!kthread_should_stop()) { + wait_event_interruptible(dev->hnet_wq, + atomic_read(&dev->hnet_active) != 0); + if (!(dev->flags & NGKNET_DEV_ACTIVE)) { + schedule_timeout(HZ); + continue; + } + atomic_set(&dev->hnet_active, 0); + for (qi = 0; qi < pdev->ctrl.nb_txq; qi++) { + do { + rv = pdev->pkt_xmit(pdev, qi, 0); + } while (rv == SHR_E_NONE); + } + schedule_work(&dev->hnet_work); + } + + return 0; +} + +/*! + * Hypervisor network wake handler + */ +static int +ngknet_dev_vnet_wake(struct pdma_dev *pdev) +{ + struct ngknet_dev *dev = (struct ngknet_dev *)pdev->priv; + + atomic_set(&dev->vnet_active, 1); + wake_up_interruptible(&dev->vnet_wq); + + return SHR_E_NONE; +} + +/*! + * Hypervisor network process + */ +static int +ngknet_dev_hnet_process(void *data) +{ + return ngknet_dev_hnet_wait((struct pdma_dev *)data); +} + +/*! + * Hypervisor network schedule + */ +static void +ngknet_dev_hnet_schedule(struct work_struct *work) +{ + struct ngknet_dev *dev = container_of(work, struct ngknet_dev, hnet_work); + + ngknet_dev_hnet_work(&dev->pdma_dev); +} + +/*! + * Convert physical address to virtual address + */ +static void * +ngknet_sys_p2v(struct pdma_dev *pdev, uint64_t paddr) +{ + return ngbde_kapi_dma_bus_to_virt(pdev->unit, (dma_addr_t)paddr); +} + +/*! + * Convert virtual address to physical address + */ +static uint64_t +ngknet_sys_v2p(struct pdma_dev *pdev, void *vaddr) +{ + return (uint64_t)ngbde_kapi_dma_virt_to_bus(pdev->unit, vaddr); +} + +/*! + * Open network device + */ +static int +ngknet_enet_open(struct net_device *ndev) +{ + struct ngknet_private *priv = netdev_priv(ndev); + struct ngknet_dev *dev = priv->bkn_dev; + struct pdma_dev *pdev = &dev->pdma_dev; + struct napi_struct *napi = NULL; + unsigned long bm_queue; + int gi, qi; + int rv; + + if (!pdev->ctrl.bm_rxq || !pdev->ctrl.bm_txq) { + printk("Not config Rx or Tx queue yet!\n"); + return -EPERM; + } + + if (priv->id <= 0) { + /* Register interrupt handler */ + ngbde_kapi_intr_connect(dev->dev_no, 0, ngknet_isr, dev); + + /* Start PDMA device */ + rv = bcmcnet_pdma_dev_start(pdev); + if (SHR_FAILURE(rv)) { + ngbde_kapi_intr_disconnect(dev->dev_no, 0); + return -EPERM; + } + + /* Start rate limit */ + if (rx_rate_limit >= 0) { + ngknet_rx_rate_limit_start(dev); + } + + /* Notify the stack of the actual queue counts. */ + rv = netif_set_real_num_rx_queues(dev->net_dev, pdev->ctrl.nb_rxq); + if (rv < 0) { + ngbde_kapi_intr_disconnect(dev->dev_no, 0); + return rv; + } + rv = netif_set_real_num_tx_queues(dev->net_dev, pdev->ctrl.nb_txq); + if (rv < 0) { + ngbde_kapi_intr_disconnect(dev->dev_no, 0); + return rv; + } + + for (gi = 0; gi < pdev->num_groups; gi++) { + if (!pdev->ctrl.grp[gi].attached) { + continue; + } + bm_queue = pdev->ctrl.grp[gi].bm_rxq | pdev->ctrl.grp[gi].bm_txq; + for (qi = 0; qi < pdev->grp_queues; qi++) { + napi = (struct napi_struct *)pdev->ctrl.grp[gi].intr_hdl[qi].priv; + if (pdev->flags & PDMA_GROUP_INTR) { + napi_enable(napi); + break; + } + if (1 << qi & bm_queue) { + napi_enable(napi); + } + } + } + } else { + /* Notify the stack of the actual queue counts. */ + rv = netif_set_real_num_rx_queues(ndev, pdev->ctrl.nb_rxq); + if (rv < 0) { + return rv; + } + rv = netif_set_real_num_tx_queues(ndev, pdev->ctrl.nb_txq); + if (rv < 0) { + return rv; + } + } + + /* Prevent tx timeout */ + kal_netif_trans_update(ndev); + + netif_tx_wake_all_queues(ndev); + + return 0; +} + +/*! + * Stop network device + */ +static int +ngknet_enet_stop(struct net_device *ndev) +{ + struct ngknet_private *priv = netdev_priv(ndev); + struct ngknet_dev *dev = priv->bkn_dev; + struct pdma_dev *pdev = &dev->pdma_dev; + struct napi_struct *napi = NULL; + unsigned long bm_queue; + int gi, qi; + + netif_tx_stop_all_queues(ndev); + + if (priv->id <= 0) { + /* Stop rate limit */ + if (rx_rate_limit >= 0) { + ngknet_rx_rate_limit_stop(dev); + } + + /* Suspend PDMA device */ + bcmcnet_pdma_dev_suspend(pdev); + + for (gi = 0; gi < pdev->num_groups; gi++) { + if (!pdev->ctrl.grp[gi].attached) { + continue; + } + bm_queue = pdev->ctrl.grp[gi].bm_rxq | pdev->ctrl.grp[gi].bm_txq; + for (qi = 0; qi < pdev->grp_queues; qi++) { + napi = (struct napi_struct *)pdev->ctrl.grp[gi].intr_hdl[qi].priv; + if (pdev->flags & PDMA_GROUP_INTR) { + napi_disable(napi); + break; + } + if (1 << qi & bm_queue) { + napi_disable(napi); + } + } + } + + /* Stop PDMA device */ + bcmcnet_pdma_dev_stop(pdev); + + /* Unregister interrupt handler */ + ngbde_kapi_intr_disconnect(dev->dev_no, 0); + } + + return 0; +} + +/*! + * Start transmission + */ +static int +ngknet_start_xmit(struct sk_buff *skb, struct net_device *ndev) +{ + struct ngknet_private *priv = netdev_priv(ndev); + struct ngknet_dev *dev = priv->bkn_dev; + struct pdma_dev *pdev = &dev->pdma_dev; + struct sk_buff *bskb = skb; + uint32_t len = skb->len; + int queue; + int rv; + + DBG_VERB(("Tx packet from ndev%d (%d bytes).\n", priv->id, skb->len)); + if (debug & DBG_LVL_PDMP) { + ngknet_pkt_dump(skb->data, skb->len); + } + + /* Do not transmit on base device */ + if (priv->id <= 0) { + priv->stats.tx_dropped++; + dev_kfree_skb_any(skb); + return NETDEV_TX_OK; + } + + /* Measure speed */ + if (debug & DBG_LVL_RATE) { + ngknet_pkt_stats(pdev, PDMA_Q_TX); + } + + queue = skb->queue_mapping; + + /* Handle one outgoing packet */ + rv = ngknet_tx_frame_process(ndev, &skb); + if (SHR_FAILURE(rv)) { + priv->stats.tx_dropped++; + if (skb) { + dev_kfree_skb_any(skb); + } + return NETDEV_TX_OK; + } + + /* Schedule Tx queue */ + ngknet_tx_queue_schedule(dev, skb, &queue); + skb->queue_mapping = queue; + + DBG_VERB(("Tx packet (%d bytes).\n", skb->len)); + if (debug & DBG_LVL_PDMP) { + ngknet_pkt_dump(skb->data, skb->len); + } + + /* Do Tx timestamping */ + if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) { + ngknet_ptp_tx_config(ndev, skb); + } + + skb_tx_timestamp(skb); + + rv = pdev->pkt_xmit(pdev, queue, skb); + + if (rv == SHR_E_UNAVAIL) { + DBG_WARN(("Tx drop: DMA device not ready\n")); + priv->stats.tx_dropped++; + if (skb != bskb) { + dev_kfree_skb_any(skb); + } + dev_kfree_skb_any(bskb); + return NETDEV_TX_OK; + } + + if (rv == SHR_E_BUSY) { + DBG_WARN(("Tx suspend: No DMA resources\n")); + priv->stats.tx_fifo_errors++; + if (skb != bskb) { + dev_kfree_skb_any(skb); + } + return NETDEV_TX_BUSY; + } else { + if (skb != bskb) { + dev_kfree_skb_any(bskb); + } + } + + /* Update accounting */ + priv->stats.tx_packets++; + priv->stats.tx_bytes += len; + + return NETDEV_TX_OK; +} + +/*! + * Get network device stats + */ +static struct net_device_stats * +ngknet_get_stats(struct net_device *ndev) +{ + struct ngknet_private *priv = netdev_priv(ndev); + + return &priv->stats; +} + +/*! + * Set network device MC list + */ +static void +ngknet_set_multicast_list(struct net_device *ndev) +{ + return; +} + +/*! + * Set network device MAC address + */ +static int +ngknet_set_mac_address(struct net_device *ndev, void *addr) +{ + if (!is_valid_ether_addr(((struct sockaddr *)addr)->sa_data)) { + return -EINVAL; + } + + netdev_info(ndev, "Setting new MAC address\n"); + memcpy(ndev->dev_addr, ((struct sockaddr *)addr)->sa_data, ndev->addr_len); + + return 0; +} + +/*! + * Change network device MTU + */ +static int +ngknet_change_mtu(struct net_device *ndev, int new_mtu) +{ + int frame_size = new_mtu + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN; + + if (frame_size < 68 || frame_size > rx_buffer_size) { + return -EINVAL; + } + + netdev_info(ndev, "Changing MTU from %d to %d\n", ndev->mtu, new_mtu); + ndev->mtu = new_mtu; + + return 0; +} + +/*! + * Do I/O control + */ +static int +ngknet_do_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd) +{ + struct ngknet_private *priv = netdev_priv(ndev); + struct hwtstamp_config config; + int rv; + + if (cmd == SIOCSHWTSTAMP) { + if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) { + return -EFAULT; + } + + if (priv->type != NGKNET_NETIF_T_PORT) { + return -ENOSYS; + } + + switch (config.tx_type) { + case HWTSTAMP_TX_OFF: + priv->hwts_tx_type = HWTSTAMP_TX_OFF; + rv = ngknet_ptp_tx_config_set(ndev, priv->hwts_tx_type); + if (SHR_FAILURE(rv)) { + return -ENOSYS; + } + break; + case HWTSTAMP_TX_ON: + priv->hwts_tx_type = HWTSTAMP_TX_ON; + rv = ngknet_ptp_tx_config_set(ndev, priv->hwts_tx_type); + if (SHR_FAILURE(rv)) { + return -ENOSYS; + } + break; + case HWTSTAMP_TX_ONESTEP_SYNC: + priv->hwts_tx_type = HWTSTAMP_TX_ONESTEP_SYNC; + rv = ngknet_ptp_tx_config_set(ndev, priv->hwts_tx_type); + if (SHR_FAILURE(rv)) { + return -ENOSYS; + } + break; + default: + return -ERANGE; + } + + switch (config.rx_filter) { + case HWTSTAMP_FILTER_NONE: + rv = ngknet_ptp_rx_config_set(ndev, &config.rx_filter); + if (SHR_FAILURE(rv)) { + return -ENOSYS; + } + priv->hwts_rx_filter = HWTSTAMP_FILTER_NONE; + break; + default: + rv = ngknet_ptp_rx_config_set(ndev, &config.rx_filter); + if (SHR_FAILURE(rv)) { + return -ENOSYS; + } + priv->hwts_rx_filter = config.rx_filter; + break; + } + + return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? -EFAULT : 0; + } + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)) + if (cmd == SIOCGHWTSTAMP) { + config.flags = 0; + config.tx_type = priv->hwts_tx_type; + config.rx_filter = priv->hwts_rx_filter; + + return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? -EFAULT : 0; + } +#endif + + return -EINVAL; +} + +#ifdef CONFIG_NET_POLL_CONTROLLER +/*! + * Poll network device + */ +static void +ngknet_poll_controller(struct net_device *ndev) +{ + struct ngknet_private *priv = netdev_priv(ndev); + + disable_irq(ndev->irq); + ngknet_isr(priv->bkn_dev); + enable_irq(ndev->irq); +} +#endif + +static const struct net_device_ops ngknet_netdev_ops = { + .ndo_open = ngknet_enet_open, + .ndo_stop = ngknet_enet_stop, + .ndo_start_xmit = ngknet_start_xmit, + .ndo_get_stats = ngknet_get_stats, + .ndo_validate_addr = eth_validate_addr, + .ndo_set_rx_mode = ngknet_set_multicast_list, + .ndo_set_mac_address = ngknet_set_mac_address, + .ndo_change_mtu = ngknet_change_mtu, + .ndo_set_features = NULL, + .ndo_do_ioctl = ngknet_do_ioctl, + .ndo_tx_timeout = NULL, +#ifdef CONFIG_NET_POLL_CONTROLLER + .ndo_poll_controller = ngknet_poll_controller, +#endif +}; + +static void +ngknet_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) +{ + strlcpy(drvinfo->driver, "linux_ngknet", sizeof(drvinfo->driver)); + snprintf(drvinfo->version, sizeof(drvinfo->version), "%d", NGKNET_IOC_VERSION); + strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); + strlcpy(drvinfo->bus_info, "N/A", sizeof(drvinfo->bus_info)); +} + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)) +static int +ngknet_get_ts_info(struct net_device *ndev, struct ethtool_ts_info *info) +{ + int rv; + + info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | + SOF_TIMESTAMPING_TX_SOFTWARE | + SOF_TIMESTAMPING_RX_HARDWARE | + SOF_TIMESTAMPING_RX_SOFTWARE | + SOF_TIMESTAMPING_SOFTWARE | + SOF_TIMESTAMPING_RAW_HARDWARE; + info->tx_types = 1 << HWTSTAMP_TX_OFF | 1 << HWTSTAMP_TX_ON | 1 << HWTSTAMP_TX_ONESTEP_SYNC; + info->rx_filters = 1 << HWTSTAMP_FILTER_NONE | 1 << HWTSTAMP_FILTER_ALL; + rv = ngknet_ptp_phc_index_get(ndev, &info->phc_index); + if (SHR_FAILURE(rv)) { + info->phc_index = -1; + } + + return 0; +} +#endif + +static const struct ethtool_ops ngknet_ethtool_ops = { + .get_drvinfo = ngknet_get_drvinfo, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)) + .get_ts_info = ngknet_get_ts_info, +#endif +}; + +/*! + * \brief Initialize network device. + * + * \param [in] name Network device name. + * \param [in] mac Network device MAC address. + * \param [out] nd New registered network device. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +ngknet_ndev_init(ngknet_netif_t *netif, struct net_device **nd) +{ + struct net_device *ndev = NULL; + uint8_t *ma; + int rv; + + if (!netif) { + DBG_WARN(("Network interface is NULL.\n")); + return SHR_E_PARAM; + } + if (!nd) { + DBG_WARN(("Network device is NULL.\n")); + return SHR_E_PARAM; + } + + ndev = alloc_etherdev_mq(sizeof(struct ngknet_private), NUM_QUE_MAX); + if (!ndev) { + DBG_WARN(("Error allocating network device.\n")); + return SHR_E_MEMORY; + } + if (!ndev->dev_addr) { + DBG_WARN(("ndev->dev_addr is NULL\n")); + free_netdev(ndev); + return SHR_E_INTERNAL; + } + + /* Device information -- not available right now */ + ndev->irq = 0; + ndev->base_addr = 0; + + /* Fill in the dev structure */ + ndev->watchdog_timeo = 5 * HZ; + + /* Default MTU should not exceed MTU of switch front-panel ports */ + ndev->mtu = netif->mtu; + if (!ndev->mtu) { + ndev->mtu = default_mtu ? default_mtu : rx_buffer_size; + } + + ndev->netdev_ops = &ngknet_netdev_ops; + ndev->ethtool_ops = &ngknet_ethtool_ops; + + /* Network device name */ + if (netif->name && *netif->name) { + strncpy(ndev->name, netif->name, IFNAMSIZ - 1); + } + + /* Set the device MAC address */ + ma = netif->macaddr; + if ((ma[0] | ma[1] | ma[2] | ma[3] | ma[4] | ma[5]) == 0) { + ngknet_dev_mac[5]++; + ma = ngknet_dev_mac; + } + memcpy(ndev->dev_addr, ma, ETH_ALEN); + + /* Initialize the device features */ + ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | + NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_TX; + ndev->features |= NETIF_F_HIGHDMA | NETIF_F_HW_VLAN_CTAG_RX; + + /* Register the kernel network device */ + rv = register_netdev(ndev); + if (rv < 0) { + DBG_WARN(("Error registering network device %s.\n", ndev->name)); + free_netdev(ndev); + return SHR_E_FAIL; + } + + *nd = ndev; + + DBG_VERB(("Created network device %s.\n", ndev->name)); + + return SHR_E_NONE; +} + +/*! + * \brief Initialize Packet DMA device. + * + * \param [in] dev NGKNET device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +ngknet_pdev_init(struct ngknet_dev *dev) +{ + struct pdma_dev *pdev = &dev->pdma_dev; + int rv; + + /* Initialize PDMA control structure */ + pdev->unit = dev->dev_no; + pdev->priv = dev; + pdev->ctrl.dev = pdev; + pdev->ctrl.hw_addr = dev->base_addr; + pdev->ctrl.rx_buf_size = rx_buffer_size; + + /* Hook callbacks */ + pdev->dev_read32 = ngknet_dev_read32; + pdev->dev_write32 = ngknet_dev_write32; + pdev->pkt_recv = ngknet_frame_recv; + pdev->tx_suspend = ngknet_tx_suspend; + pdev->tx_resume = ngknet_tx_resume; + pdev->intr_unmask = ngknet_intr_enable; + pdev->intr_mask = ngknet_intr_disable; + pdev->xnet_wait = ngknet_dev_hnet_wait; + pdev->xnet_wake = ngknet_dev_vnet_wake; + pdev->sys_p2v = ngknet_sys_p2v; + pdev->sys_v2p = ngknet_sys_v2p; + + pdev->flags |= PDMA_GROUP_INTR; + if (tx_polling) { + pdev->flags |= PDMA_TX_POLLING; + } + if (rx_batching || pdev->mode == DEV_MODE_HNET) { + pdev->flags |= PDMA_RX_BATCHING; + } + + /* Attach PDMA driver */ + rv = drv_ops[pdev->dev_type]->drv_attach(pdev); + if (SHR_FAILURE(rv)) { + DBG_WARN(("Attach DMA driver failed.\n")); + return rv; + } + + /* Initialize PDMA device */ + rv = bcmcnet_pdma_dev_init(pdev); + if (SHR_FAILURE(rv)) { + DBG_WARN(("Init DMA device.failed.\n")); + return rv; + } + + DBG_VERB(("Attached DMA device %s.\n", pdev->name)); + + return SHR_E_NONE; +} + +/*! + * \brief Get device information from BDE. + * + * \param [in] dn Device number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +ngknet_dev_info_get(int dn) +{ + struct ngknet_dev *dev = &ngknet_devices[dn]; + + dev->base_addr = ngbde_kapi_pio_membase(dn); + dev->dev = ngbde_kapi_dma_dev_get(dn); + + if (!dev->base_addr || !dev->dev) { + return SHR_E_ACCESS; + } + + dev->dev_no = dn; + + return SHR_E_NONE; +} + +/*! + * \brief Probe device. + * + * Get the information from BDE, initialize Packet DMA device, + * initialize base network device and allocate other resources. + * + * \param [in] dn Device number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +ngknet_dev_probe(int dn, ngknet_netif_t *netif) +{ + struct ngknet_dev *dev = &ngknet_devices[dn]; + struct pdma_dev *pdev = &dev->pdma_dev; + struct net_device *ndev = NULL; + struct ngknet_private *priv = NULL; + struct intr_handle *hdl = NULL; + struct cpumask mask; + int gi, qi; + int rv; + + DBG_VERB(("%s: dev %d\n",__FUNCTION__, dn)); + + /* Get device information */ + rv = ngknet_dev_info_get(dn); + if (SHR_FAILURE(rv)) { + return rv; + } + + /* Initialize PDMA device */ + rv = ngknet_pdev_init(dev); + if (SHR_FAILURE(rv)) { + return rv; + } + + /* Get base network device name */ + if (netif->name[0] == '\0') { + /* Reserve 6 vacancies for base&vitual device number, i.e. nameAB_XYZ */ + if (strlen(base_dev_name) < IFNAMSIZ - 6) { + snprintf(netif->name, IFNAMSIZ, "%s%d", base_dev_name, dn); + } else { + DBG_WARN(("Too long network device name: %s.\n", base_dev_name)); + return SHR_E_PARAM; + } + } + + rv = ngknet_ndev_init(netif, &ndev); + if (SHR_FAILURE(rv)) { + bcmcnet_pdma_dev_cleanup(pdev); + return rv; + } + dev->net_dev = ndev; + + /* Initialize private information for base network device */ + priv = netdev_priv(ndev); + priv->net_dev = ndev; + priv->bkn_dev = dev; + priv->id = 0; + priv->type = netif->type; + if (priv->type == NGKNET_NETIF_T_PORT) { + priv->meta_off = netif->meta_off; + priv->meta_len = netif->meta_len; + memcpy(priv->meta_data, netif->meta_data, priv->meta_len); + } + priv->flags = netif->flags; + priv->vlan = netif->vlan; + priv->chan = netif->chan; + memcpy(priv->user_data, netif->user_data, sizeof(priv->user_data)); + + netif->id = priv->id; + memcpy(netif->macaddr, ndev->dev_addr, ETH_ALEN); + netif->mtu = ndev->mtu; + memcpy(netif->name, ndev->name, sizeof(netif->name) - 1); + + if (priv->flags & NGKNET_NETIF_F_BIND_CHAN) { + dev->bdev[priv->chan] = ndev; + } + + /* Register for napi */ + for (gi = 0; gi < pdev->num_groups; gi++) { + if (!pdev->ctrl.grp[gi].attached) { + continue; + } + for (qi = 0; qi < pdev->grp_queues; qi++) { + hdl = &pdev->ctrl.grp[gi].intr_hdl[qi]; + priv_hdl[hdl->unit][hdl->chan].hdl = hdl; + hdl->priv = &priv_hdl[hdl->unit][hdl->chan]; + netif_napi_add(ndev, (struct napi_struct *)hdl->priv, + ngknet_poll, pdev->ctrl.budget); + if (pdev->flags & PDMA_GROUP_INTR) { + break; + } + } + } + + /* Get callback control */ + ngknet_callback_control_get(&dev->cbc); + + INIT_LIST_HEAD(&dev->filt_list); + spin_lock_init(&dev->lock); + init_waitqueue_head(&dev->wq); + if (pdev->mode == DEV_MODE_HNET) { + init_waitqueue_head(&dev->vnet_wq); + atomic_set(&dev->vnet_active, 0); + init_waitqueue_head(&dev->hnet_wq); + atomic_set(&dev->hnet_active, 0); + dev->hnet_task = kthread_run(ngknet_dev_hnet_process, pdev, pdev->name); + if (IS_ERR(dev->hnet_task)) { + dev->hnet_task = NULL; + return SHR_E_INTERNAL; + } + cpumask_clear(&mask); + cpumask_set_cpu(1, &mask); + set_cpus_allowed_ptr(dev->hnet_task, &mask); + INIT_WORK(&dev->hnet_work, ngknet_dev_hnet_schedule); + } + + skb_queue_head_init(&dev->ptp_tx_queue); + INIT_WORK(&dev->ptp_tx_work, ngknet_ptp_tx_work); + + dev->flags |= NGKNET_DEV_ACTIVE; + + DBG_NDEV(("Broadcom NGKNET Attached\n")); + DBG_NDEV(("MAC: %pM\n", ndev->dev_addr)); + DBG_NDEV(("Running with NAPI enabled\n")); + + return SHR_E_NONE; +} + +/*! + * \brief Remove device. + * + * Suspend device firstly, destroy all virtual network devices + * and filters, clean up Packet DMA device. + * + * \param [in] dn Device number. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +ngknet_dev_remove(int dn) +{ + struct ngknet_dev *dev = &ngknet_devices[dn]; + struct pdma_dev *pdev = &dev->pdma_dev; + struct net_device *ndev = NULL; + struct intr_handle *hdl = NULL; + int di, gi, qi; + int rv; + + if (!(dev->flags & NGKNET_DEV_ACTIVE)) { + return SHR_E_NONE; + } + + DBG_VERB(("%s: dev %d\n",__FUNCTION__, dn)); + + dev->flags &= ~NGKNET_DEV_ACTIVE; + + skb_queue_purge(&dev->ptp_tx_queue); + + if (pdev->mode == DEV_MODE_HNET && dev->hnet_task) { + atomic_set(&dev->hnet_active, 1); + wake_up_interruptible(&dev->hnet_wq); + kthread_stop(dev->hnet_task); + dev->hnet_task = NULL; + } + + /* Destroy all the filters */ + ngknet_filter_destroy_all(dev); + + /* Destroy all the virtual devices */ + for (di = 1; di <= NUM_VDEV_MAX; di++) { + ndev = dev->vdev[di]; + if (ndev) { + netif_carrier_off(ndev); + unregister_netdev(ndev); + free_netdev(ndev); + dev->vdev[di] = NULL; + } + } + dev->vdev[0] = NULL; + + DBG_VERB(("Removing base network device %s.\n", dev->net_dev->name)); + + /* Destroy the base network device */ + ndev = dev->net_dev; + unregister_netdev(ndev); + free_netdev(ndev); + + for (qi = 0; qi < NUM_QUE_MAX; qi++) { + dev->bdev[qi] = NULL; + } + + for (gi = 0; gi < pdev->num_groups; gi++) { + if (!pdev->ctrl.grp[gi].attached) { + continue; + } + for (qi = 0; qi < pdev->grp_queues; qi++) { + hdl = &pdev->ctrl.grp[gi].intr_hdl[qi]; + netif_napi_del((struct napi_struct *)hdl->priv); + priv_hdl[hdl->unit][hdl->chan].hdl = NULL; + if (pdev->flags & PDMA_GROUP_INTR) { + break; + } + } + } + + /* Clean up PDMA device */ + bcmcnet_pdma_dev_cleanup(pdev); + + /* Detach PDMA driver */ + rv = drv_ops[pdev->dev_type]->drv_detach(pdev); + if (SHR_FAILURE(rv)) { + DBG_WARN(("Detach DMA driver failed.\n")); + } + + return rv; +} + +/*! + * Network interface functions + */ + +int +ngknet_netif_create(struct ngknet_dev *dev, ngknet_netif_t *netif) +{ + struct net_device *ndev = NULL; + struct ngknet_private *priv = NULL; + unsigned long flags; + int num, id; + int rv; + + switch (netif->type) { + case NGKNET_NETIF_T_VLAN: + case NGKNET_NETIF_T_PORT: + case NGKNET_NETIF_T_META: + break; + default: + return SHR_E_UNAVAIL; + } + + /* Get vitual network device name */ + if (netif->name[0] == '\0') { + /* Reserve 6 vacancies for base&vitual device number, i.e. nameAB_XYZ */ + if (strlen(base_dev_name) < IFNAMSIZ - 6) { + snprintf(netif->name, IFNAMSIZ, "%s%d%s", base_dev_name, dev->dev_no, "_"); + strncat(netif->name, "%d", 3); + } else { + DBG_WARN(("Too long network device name: %s.\n", base_dev_name)); + return SHR_E_PARAM; + } + } + + rv = ngknet_ndev_init(netif, &ndev); + if (SHR_FAILURE(rv)) { + return rv; + } + + spin_lock_irqsave(&dev->lock, flags); + + num = (long)dev->vdev[0]; + for (id = 1; id < num + 1; id++) { + if (!dev->vdev[id]) { + break; + } + } + if (id > NUM_VDEV_MAX) { + spin_unlock_irqrestore(&dev->lock, flags); + unregister_netdev(ndev); + free_netdev(ndev); + return SHR_E_RESOURCE; + } + + dev->vdev[id] = ndev; + num += id == (num + 1) ? 1 : 0; + dev->vdev[0] = (struct net_device *)(long)num; + + spin_unlock_irqrestore(&dev->lock, flags); + + priv = netdev_priv(ndev); + priv->net_dev = ndev; + priv->bkn_dev = dev; + priv->id = id; + priv->type = netif->type; + if (priv->type == NGKNET_NETIF_T_PORT) { + priv->meta_off = netif->meta_off; + priv->meta_len = netif->meta_len; + memcpy(priv->meta_data, netif->meta_data, priv->meta_len); + } + priv->flags = netif->flags; + priv->vlan = netif->vlan; + priv->chan = netif->chan; + memcpy(priv->user_data, netif->user_data, sizeof(priv->user_data)); + + netif->id = priv->id; + memcpy(netif->macaddr, ndev->dev_addr, ETH_ALEN); + netif->mtu = ndev->mtu; + memcpy(netif->name, ndev->name, sizeof(netif->name) - 1); + + if (priv->flags & NGKNET_NETIF_F_BIND_CHAN) { + dev->bdev[priv->chan] = ndev; + } + + /* Optional netif create callback handle */ + if (dev->cbc->netif_create_cb) { + rv = dev->cbc->netif_create_cb(ndev); + if (rv) { + DBG_WARN(("Netif create callback failed with rv %d for '%s'\n", rv, ndev->name)); + } + } + + DBG_VERB(("Created virtual network device %s (%d).\n", ndev->name, priv->id)); + + return SHR_E_NONE; +} + +int +ngknet_netif_destroy(struct ngknet_dev *dev, int id) +{ + struct net_device *ndev = NULL; + struct ngknet_private *priv = NULL; + unsigned long flags; + int num; + DECLARE_WAITQUEUE(wait, current); + + if (id <= 0 || id > NUM_VDEV_MAX) { + return SHR_E_PARAM; + } + + spin_lock_irqsave(&dev->lock, flags); + + ndev = dev->vdev[id]; + if (!ndev) { + spin_unlock_irqrestore(&dev->lock, flags); + return SHR_E_NOT_FOUND; + } + priv = netdev_priv(ndev); + + add_wait_queue(&dev->wq, &wait); + + while (priv->users) { + priv->wait = 1; + set_current_state(TASK_INTERRUPTIBLE); + spin_unlock_irqrestore(&dev->lock, flags); + schedule(); + spin_lock_irqsave(&dev->lock, flags); + priv->wait = 0; + set_current_state(TASK_RUNNING); + } + + if (priv->flags & NGKNET_NETIF_F_BIND_CHAN) { + dev->bdev[priv->chan] = NULL; + } + + dev->vdev[id] = NULL; + num = (long)dev->vdev[0]; + while (num-- == id--) { + if (dev->vdev[id]) { + dev->vdev[0] = (struct net_device *)(long)num; + break; + } + } + + spin_unlock_irqrestore(&dev->lock, flags); + + remove_wait_queue(&dev->wq, &wait); + + /* Optional netif destroy callback handle */ + if (dev->cbc->netif_destroy_cb) { + int rv = dev->cbc->netif_destroy_cb(ndev); + if (rv) { + DBG_WARN(("Netif destroy callback failed with rv %d for '%s'\n", rv, ndev->name)); + } + } + DBG_VERB(("Removing virtual network device %s (%d).\n", ndev->name, priv->id)); + + netif_carrier_off(ndev); + unregister_netdev(ndev); + free_netdev(ndev); + + return SHR_E_NONE; +} + +int +ngknet_netif_get(struct ngknet_dev *dev, int id, ngknet_netif_t *netif) +{ + struct net_device *ndev = NULL; + struct ngknet_private *priv = NULL; + unsigned long flags; + int num; + + if (id < 0 || id > NUM_VDEV_MAX) { + return SHR_E_PARAM; + } + + spin_lock_irqsave(&dev->lock, flags); + + ndev = id == 0 ? dev->net_dev : dev->vdev[id]; + if (!ndev) { + spin_unlock_irqrestore(&dev->lock, flags); + return SHR_E_NOT_FOUND; + } + + priv = netdev_priv(ndev); + netif->id = priv->id; + netif->type = priv->type; + netif->flags = priv->flags; + netif->vlan = priv->vlan; + memcpy(netif->macaddr, priv->net_dev->dev_addr, ETH_ALEN); + netif->mtu = priv->net_dev->mtu; + netif->chan = priv->chan; + memcpy(netif->name, priv->net_dev->name, sizeof(netif->name) - 1); + netif->meta_off = priv->meta_off; + netif->meta_len = priv->meta_len; + memcpy(netif->meta_data, priv->meta_data, netif->meta_len); + memcpy(netif->user_data, priv->user_data, sizeof(netif->user_data)); + + num = (long)dev->vdev[0]; + for (id++; id < num + 1; id++) { + if (dev->vdev[id]) { + break; + } + } + netif->next = id == (num + 1) ? 0 : id; + + spin_unlock_irqrestore(&dev->lock, flags); + + DBG_VERB(("Got virtual network device %s (%d).\n", ndev->name, priv->id)); + + return SHR_E_NONE; +} + +int +ngknet_netif_get_next(struct ngknet_dev *dev, ngknet_netif_t *netif) +{ + return ngknet_netif_get(dev, netif->next, netif); +} + +/*! + * System control interfaces + */ + +int +ngknet_debug_level_get(void) +{ + return debug; +} + +void +ngknet_debug_level_set(int debug_level) +{ + debug = debug_level; +} + +int +ngknet_rx_rate_limit_get(void) +{ + return rx_rate_limit; +} + +void +ngknet_rx_rate_limit_set(int rate_limit) +{ + rx_rate_limit = rate_limit; +} + +/*! + * Generic module functions + */ + +static int +ngknet_open(struct inode *inode, struct file *filp) +{ + return 0; +} + +static int +ngknet_release(struct inode *inode, struct file *filp) +{ + return 0; +} + +static long +ngknet_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct ngknet_ioctl ioc; + struct ngknet_dev *dev = NULL; + struct net_device *ndev = NULL; + struct pdma_dev *pdev = NULL; + union { + ngknet_dev_cfg_t dev_cfg; + ngknet_chan_cfg_t chan_cfg; + ngknet_netif_t netif; + ngknet_filter_t filter; + } iod; + ngknet_dev_cfg_t *dev_cfg = &iod.dev_cfg; + ngknet_chan_cfg_t *chan_cfg = &iod.chan_cfg; + ngknet_netif_t *netif = &iod.netif; + ngknet_filter_t *filter = &iod.filter; + char *data = NULL; + int dt, gi, qi; + + if (_IOC_TYPE(cmd) != NGKNET_IOC_MAGIC) { + DBG_WARN(("Unsupported command (cmd=%d)\n", cmd)); + return -EINVAL; + } + + if (copy_from_user(&ioc, (void *)arg, sizeof(ioc))) { + return -EFAULT; + } + + ioc.rc = SHR_E_NONE; + + dev = &ngknet_devices[ioc.unit]; + pdev = &dev->pdma_dev; + + if (cmd != NGKNET_VERSION_GET && + cmd != NGKNET_RX_RATE_LIMIT && + cmd != NGKNET_DEV_INIT && + !(dev->flags & NGKNET_DEV_ACTIVE)) { + ioc.rc = SHR_E_UNAVAIL; + if (copy_to_user((void *)arg, &ioc, sizeof(ioc))) { + return -EFAULT; + } + return 0; + } + + switch (cmd) { + case NGKNET_VERSION_GET: + DBG_CMD(("NGKNET_VERSION_GET\n")); + ioc.op.info.version = NGKNET_IOC_VERSION; + break; + case NGKNET_RX_RATE_LIMIT: + DBG_CMD(("NGKNET_RX_RATE_LIMIT\n")); + if (ioc.iarg[0]) { + ngknet_rx_rate_limit_set(ioc.iarg[1]); + } else { + ioc.iarg[1] = ngknet_rx_rate_limit_get(); + } + break; + case NGKNET_DEV_INIT: + DBG_CMD(("NGKNET_DEV_INIT\n")); + if (dev->flags & NGKNET_DEV_ACTIVE) { + DBG_CMD(("NGKNET_DEV_INIT, retrieve device configurations.\n")); + strlcpy(dev_cfg->name, pdev->name, sizeof(dev_cfg->name)); + dev_cfg->dev_id = pdev->dev_id; + dev_cfg->nb_grp = pdev->ctrl.nb_grp; + dev_cfg->bm_grp = pdev->ctrl.bm_grp; + ioc.rc = ngknet_netif_get(dev, 0, &dev_cfg->base_netif); + if (SHR_FAILURE((int)ioc.rc)) { + break; + } + if (kal_copy_to_user((void *)(unsigned long)ioc.op.data.buf, dev_cfg, + ioc.op.data.len, sizeof(*dev_cfg))) { + return -EFAULT; + } + break; + } + if (kal_copy_from_user(dev_cfg, (void *)(unsigned long)ioc.op.data.buf, + sizeof(*dev_cfg), ioc.op.data.len)) { + return -EFAULT; + } + if (!dev_cfg->name[0] || !dev_cfg->bm_grp || + dev_cfg->bm_grp >= (1 << NUM_GRP_MAX)) { + DBG_WARN(("Invalid parameter: name=%s, bm_grp=0x%x\n", + dev_cfg->name, dev_cfg->bm_grp)); + ioc.rc = SHR_E_PARAM; + break; + } + memset(pdev, 0, sizeof(*pdev)); + strlcpy(pdev->name, dev_cfg->name, sizeof(pdev->name)); + pdev->dev_id = dev_cfg->dev_id; + for (dt = 0; dt < drv_num; dt++) { + if (!drv_ops[dt]) { + continue; + } + if (!strcasecmp(dev_cfg->type_str, drv_ops[dt]->drv_desc)) { + pdev->dev_type = dt; + break; + } + } + if (pdev->dev_type <= NGKNET_DEV_T_NONE || + pdev->dev_type >= NGKNET_DEV_T_COUNT) { + ioc.rc = SHR_E_PARAM; + break; + } + pdev->ctrl.bm_grp = dev_cfg->bm_grp; + for (gi = 0; gi < NUM_GRP_MAX; gi++) { + if (1 << gi & dev_cfg->bm_grp) { + pdev->ctrl.nb_grp++; + pdev->ctrl.grp[gi].attached = 1; + pdev->num_groups = gi + 1; + } + } + pdev->rx_ph_size = dev_cfg->rx_ph_size; + pdev->tx_ph_size = dev_cfg->tx_ph_size; + pdev->mode = dev_cfg->mode; + if (pdev->mode != DEV_MODE_KNET && pdev->mode != DEV_MODE_HNET) { + pdev->mode = DEV_MODE_KNET; + } + ioc.rc = ngknet_dev_probe(ioc.unit, &dev_cfg->base_netif); + if (SHR_FAILURE((int)ioc.rc)) { + break; + } + if (kal_copy_to_user((void *)(unsigned long)ioc.op.data.buf, dev_cfg, + ioc.op.data.len, sizeof(*dev_cfg))) { + return -EFAULT; + } + break; + case NGKNET_DEV_DEINIT: + DBG_CMD(("NGKNET_DEV_DEINIT\n")); + if (dev->flags & NGKNET_DEV_ACTIVE) { + ioc.rc = ngknet_dev_remove(ioc.unit); + } + break; + case NGKNET_QUEUE_CONFIG: + DBG_CMD(("NGKNET_QUEUE_CONFIG\n")); + if (kal_copy_from_user(chan_cfg, (void *)(unsigned long)ioc.op.data.buf, + sizeof(*chan_cfg), ioc.op.data.len)) { + return -EFAULT; + } + gi = chan_cfg->chan / pdev->grp_queues; + if (!(1 << gi & pdev->ctrl.bm_grp)) { + DBG_WARN(("Invalid parameter: chan=%d (bm_grp=0x%x)\n", + chan_cfg->chan, pdev->ctrl.bm_grp)); + ioc.rc = SHR_E_PARAM; + break; + } + if (chan_cfg->dir == PDMA_Q_RX) { + if (1 << chan_cfg->chan & pdev->ctrl.bm_txq) { + pdev->ctrl.bm_txq &= ~(1 << chan_cfg->chan); + pdev->ctrl.nb_txq--; + } + if (!(1 << chan_cfg->chan & pdev->ctrl.bm_rxq)) { + pdev->ctrl.bm_rxq |= 1 << chan_cfg->chan; + pdev->ctrl.nb_rxq++; + } + } else { + if (1 << chan_cfg->chan & pdev->ctrl.bm_rxq) { + pdev->ctrl.bm_rxq &= ~(1 << chan_cfg->chan); + pdev->ctrl.nb_rxq--; + } + if (!(1 << chan_cfg->chan & pdev->ctrl.bm_txq)) { + pdev->ctrl.bm_txq |= 1 << chan_cfg->chan; + pdev->ctrl.nb_txq++; + } + } + qi = chan_cfg->chan % pdev->grp_queues; + pdev->ctrl.grp[gi].nb_desc[qi] = chan_cfg->nb_desc; + pdev->ctrl.grp[gi].rx_size[qi] = chan_cfg->rx_buf_size; + pdev->ctrl.grp[gi].que_ctrl[qi] &= ~(PDMA_PKT_BYTE_SWAP | + PDMA_OTH_BYTE_SWAP | + PDMA_HDR_BYTE_SWAP); + if (chan_cfg->chan_ctrl & NGKNET_PKT_BYTE_SWAP) { + pdev->ctrl.grp[gi].que_ctrl[qi] |= PDMA_PKT_BYTE_SWAP; + } + if (chan_cfg->chan_ctrl & NGKNET_OTH_BYTE_SWAP) { + pdev->ctrl.grp[gi].que_ctrl[qi] |= PDMA_OTH_BYTE_SWAP; + } + if (chan_cfg->chan_ctrl & NGKNET_HDR_BYTE_SWAP) { + pdev->ctrl.grp[gi].que_ctrl[qi] |= PDMA_HDR_BYTE_SWAP; + } + break; + case NGKNET_QUEUE_QUERY: + DBG_CMD(("NGKNET_QUEUE_QUERY\n")); + if (kal_copy_from_user(chan_cfg, (void *)(unsigned long)ioc.op.data.buf, + sizeof(*chan_cfg), ioc.op.data.len)) { + return -EFAULT; + } + if (1 << chan_cfg->chan & pdev->ctrl.bm_rxq) { + chan_cfg->dir = PDMA_Q_RX; + } else if (1 << chan_cfg->chan & pdev->ctrl.bm_txq) { + chan_cfg->dir = PDMA_Q_TX; + } else { + ioc.rc = SHR_E_UNAVAIL; + break; + } + gi = chan_cfg->chan / pdev->grp_queues; + qi = chan_cfg->chan % pdev->grp_queues; + chan_cfg->nb_desc = pdev->ctrl.grp[gi].nb_desc[qi]; + chan_cfg->chan_ctrl = pdev->ctrl.grp[gi].que_ctrl[qi]; + if (chan_cfg->dir == PDMA_Q_RX) { + chan_cfg->rx_buf_size = pdev->ctrl.grp[gi].rx_size[qi]; + } else { + chan_cfg->rx_buf_size = 0; + } + if (kal_copy_to_user((void *)(unsigned long)ioc.op.data.buf, chan_cfg, + ioc.op.data.len, sizeof(*chan_cfg))) { + return -EFAULT; + } + break; + case NGKNET_DEV_SUSPEND: + DBG_CMD(("NGKNET_DEV_SUSPEND\n")); + if (rx_rate_limit >= 0) { + ngknet_rx_rate_limit_stop(dev); + } + ioc.rc = bcmcnet_pdma_dev_suspend(pdev); + break; + case NGKNET_DEV_RESUME: + DBG_CMD(("NGKNET_DEV_RESUME\n")); + ioc.rc = bcmcnet_pdma_dev_resume(pdev); + if (rx_rate_limit >= 0) { + ngknet_rx_rate_limit_start(dev); + } + break; + case NGKNET_DEV_VNET_WAIT: + DBG_CMD(("NGKNET_DEV_VNET_WAIT\n")); + if (pdev->mode != DEV_MODE_HNET) { + ioc.rc = SHR_E_UNAVAIL; + break; + } + wait_event_interruptible(dev->vnet_wq, + atomic_read(&dev->vnet_active) != 0); + atomic_set(&dev->vnet_active, 0); + break; + case NGKNET_DEV_HNET_WAKE: + DBG_CMD(("NGKNET_DEV_HNET_WAKE\n")); + if (pdev->mode != DEV_MODE_HNET) { + ioc.rc = SHR_E_UNAVAIL; + break; + } + atomic_set(&dev->hnet_active, 1); + wake_up_interruptible(&dev->hnet_wq); + break; + case NGKNET_DEV_VNET_DOCK: + DBG_CMD(("NGKNET_DEV_VNET_DOCK\n")); + if (pdev->mode != DEV_MODE_HNET) { + ioc.rc = SHR_E_UNAVAIL; + break; + } + if (kal_copy_from_user(&pdev->ctrl.vsync, (void *)(unsigned long)ioc.op.data.buf, + sizeof(pdev->ctrl.vsync), ioc.op.data.len)) { + return -EFAULT; + } + ioc.rc = bcmcnet_pdma_dev_dock(pdev); + break; + case NGKNET_DEV_VNET_UNDOCK: + DBG_CMD(("NGKNET_DEV_VNET_UNDOCK\n")); + if (pdev->mode != DEV_MODE_HNET) { + ioc.rc = SHR_E_UNAVAIL; + break; + } + ngknet_dev_vnet_wake(pdev); + ioc.rc = bcmcnet_pdma_dev_undock(pdev); + break; + case NGKNET_RCPU_CONFIG: + DBG_CMD(("NGKNET_RCPU_CONFIG\n")); + if (kal_copy_from_user(&dev->rcpu_ctrl, (void *)(unsigned long)ioc.op.data.buf, + sizeof(dev->rcpu_ctrl), ioc.op.data.len)) { + return -EFAULT; + } + break; + case NGKNET_RCPU_GET: + DBG_CMD(("NGKNET_RCPU_GET\n")); + if (kal_copy_to_user((void *)(unsigned long)ioc.op.data.buf, &dev->rcpu_ctrl, + ioc.op.data.len, sizeof(dev->rcpu_ctrl))) { + return -EFAULT; + } + break; + case NGKNET_INFO_GET: + DBG_CMD(("NGKNET_INFO_GET\n")); + bcmcnet_pdma_dev_info_get(pdev); + if (kal_copy_to_user((void *)(unsigned long)ioc.op.data.buf, &pdev->info, + ioc.op.data.len, sizeof(pdev->info))) { + return -EFAULT; + } + break; + case NGKNET_STATS_GET: + DBG_CMD(("NGKNET_STATS_GET\n")); + bcmcnet_pdma_dev_stats_get(pdev); + if (kal_copy_to_user((void *)(unsigned long)ioc.op.data.buf, &pdev->stats, + ioc.op.data.len, sizeof(pdev->stats))) { + return -EFAULT; + } + break; + case NGKNET_STATS_RESET: + DBG_CMD(("NGKNET_STATS_RESET\n")); + bcmcnet_pdma_dev_stats_reset(pdev); + break; + case NGKNET_NETIF_CREATE: + DBG_CMD(("NGKNET_NETIF_CREATE\n")); + if (kal_copy_from_user(netif, (void *)(unsigned long)ioc.op.data.buf, + sizeof(*netif), ioc.op.data.len)) { + return -EFAULT; + } + ioc.rc = ngknet_netif_create(dev, netif); + if (SHR_FAILURE((int)ioc.rc)) { + break; + } + if (kal_copy_to_user((void *)(unsigned long)ioc.op.data.buf, netif, + ioc.op.data.len, sizeof(*netif))) { + return -EFAULT; + } + break; + case NGKNET_NETIF_DESTROY: + DBG_CMD(("NGKNET_NETIF_DESTROY\n")); + ioc.rc = ngknet_netif_destroy(dev, ioc.iarg[0]); + break; + case NGKNET_NETIF_GET: + DBG_CMD(("NGKNET_NETIF_GET\n")); + ioc.rc = ngknet_netif_get(dev, ioc.iarg[0], netif); + if (SHR_FAILURE((int)ioc.rc)) { + break; + } + if (kal_copy_to_user((void *)(unsigned long)ioc.op.data.buf, netif, + ioc.op.data.len, sizeof(*netif))) { + return -EFAULT; + } + break; + case NGKNET_NETIF_NEXT: + DBG_CMD(("NGKNET_NETIF_NEXT\n")); + if (kal_copy_from_user(netif, (void *)(unsigned long)ioc.op.data.buf, + sizeof(*netif), ioc.op.data.len)) { + return -EFAULT; + } + ioc.rc = ngknet_netif_get_next(dev, netif); + if (SHR_FAILURE((int)ioc.rc)) { + break; + } + if (kal_copy_to_user((void *)(unsigned long)ioc.op.data.buf, netif, + ioc.op.data.len, sizeof(*netif))) { + return -EFAULT; + } + break; + case NGKNET_NETIF_LINK_SET: + DBG_CMD(("NGKNET_NETIF_LINK_SET\n")); + ioc.rc = ngknet_netif_get(dev, ioc.iarg[0], netif); + if (SHR_FAILURE((int)ioc.rc)) { + break; + } + ndev = dev->vdev[netif->id]; + if (ioc.iarg[1]) { + if (!netif_carrier_ok(ndev)) { + netif_carrier_on(ndev); + netif_tx_wake_all_queues(ndev); + DBG_LINK(("%s: link up\n", netif->name)); + } + } else { + if (netif_carrier_ok(ndev)) { + netif_carrier_off(ndev); + netif_tx_stop_all_queues(ndev); + DBG_LINK(("%s: link down\n", netif->name)); + } + } + break; + case NGKNET_FILT_CREATE: + DBG_CMD(("NGKNET_FILT_CREATE\n")); + if (kal_copy_from_user(filter, (void *)(unsigned long)ioc.op.data.buf, + sizeof(*filter), ioc.op.data.len)) { + return -EFAULT; + } + ioc.rc = ngknet_filter_create(dev, filter); + if (SHR_FAILURE((int)ioc.rc)) { + break; + } + if (kal_copy_to_user((void *)(unsigned long)ioc.op.data.buf, filter, + ioc.op.data.len, sizeof(*filter))) { + return -EFAULT; + } + break; + case NGKNET_FILT_DESTROY: + DBG_CMD(("NGKNET_FILT_DESTROY\n")); + ioc.rc = ngknet_filter_destroy(dev, ioc.iarg[0]); + break; + case NGKNET_FILT_GET: + DBG_CMD(("NGKNET_FILT_GET\n")); + ioc.rc = ngknet_filter_get(dev, ioc.iarg[0], filter); + if (SHR_FAILURE((int)ioc.rc)) { + break; + } + if (kal_copy_to_user((void *)(unsigned long)ioc.op.data.buf, filter, + ioc.op.data.len, sizeof(*filter))) { + return -EFAULT; + } + break; + case NGKNET_FILT_NEXT: + DBG_CMD(("NGKNET_FILT_NEXT\n")); + if (kal_copy_from_user(filter, (void *)(unsigned long)ioc.op.data.buf, + sizeof(*filter), ioc.op.data.len)) { + return -EFAULT; + } + ioc.rc = ngknet_filter_get_next(dev, filter); + if (SHR_FAILURE((int)ioc.rc)) { + break; + } + if (kal_copy_to_user((void *)(unsigned long)ioc.op.data.buf, filter, + ioc.op.data.len, sizeof(*filter))) { + return -EFAULT; + } + break; + case NGKNET_PTP_DEV_CTRL: + DBG_CMD(("NGKNET_PTP_DEV_CTRL\n")); + if (ioc.op.data.len) { + data = kmalloc(ioc.op.data.len, GFP_ATOMIC); + if (data == NULL) { + printk("Fatal error: no memory for PTP device ioctl\n"); + return -EFAULT; + } + if (copy_from_user(data, (void *)(unsigned long)ioc.op.data.buf, + ioc.op.data.len)) { + kfree(data); + return -EFAULT; + } + } + ioc.rc = ngknet_ptp_dev_ctrl(dev, ioc.iarg[0], data, ioc.op.data.len); + if (SHR_FAILURE((int)ioc.rc)) { + if (data) { + kfree(data); + } + break; + } + if (ioc.op.data.len) { + if (copy_to_user((void *)(unsigned long)ioc.op.data.buf, data, + ioc.op.data.len)) { + kfree(data); + return -EFAULT; + } + kfree(data); + } + break; + default: + ioc.rc = SHR_E_UNAVAIL; + printk("Invalid IOCTL"); + break; + } + + if (copy_to_user((void *)arg, &ioc, sizeof(ioc))) { + return -EFAULT; + } + + return 0; +} + +static int +ngknet_mmap(struct file *filp, struct vm_area_struct *vma) +{ + return 0; +} + +static struct file_operations ngknet_fops = { + .open = ngknet_open, + .release = ngknet_release, + .unlocked_ioctl = ngknet_ioctl, + .compat_ioctl = ngknet_ioctl, + .mmap = ngknet_mmap, +}; + +static int __init +ngknet_init_module(void) +{ + int idx; + int rv; + + rv = register_chrdev(NGKNET_MODULE_MAJOR, NGKNET_MODULE_NAME, &ngknet_fops); + if (rv < 0) { + printk(KERN_WARNING "%s: can't get major %d\n", + NGKNET_MODULE_NAME, NGKNET_MODULE_MAJOR); + return rv; + } + + /* Randomize lower 3 bytes of the MAC address (TESTING ONLY) */ + get_random_bytes(&ngknet_dev_mac[3], 3); + + /* Check for user-supplied MAC address (recommended) */ + if (mac_addr != NULL && strlen(mac_addr) == 17) { + for (idx = 0; idx < 6; idx++) { + ngknet_dev_mac[idx] = simple_strtoul(&mac_addr[idx * 3], NULL, 16); + } + /* Do not allow multicast address */ + ngknet_dev_mac[0] &= ~0x01; + } + + /* Initialize procfs */ + ngknet_procfs_init(); + + /* Initialize Rx rate limit */ + ngknet_rx_rate_limit_init(ngknet_devices); + + return 0; +} + +static void __exit +ngknet_exit_module(void) +{ + int idx; + + /* Cleanup Rx rate limit */ + ngknet_rx_rate_limit_cleanup(); + + /* Cleanup procfs */ + ngknet_procfs_cleanup(); + + /* Remove all the devices */ + for (idx = 0; idx < NUM_PDMA_DEV_MAX; idx++) { + ngknet_dev_remove(idx); + } + + unregister_chrdev(NGKNET_MODULE_MAJOR, NGKNET_MODULE_NAME); +} + +module_init(ngknet_init_module); +module_exit(ngknet_exit_module); + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_main.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_main.h new file mode 100644 index 000000000000..fb38f1b9abc3 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_main.h @@ -0,0 +1,278 @@ +/*! \file ngknet_main.h + * + * Data structure and macro definitions for NGKNET kernel module. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef NGKNET_MAIN_H +#define NGKNET_MAIN_H + +#include +#include +#include +#include + +/*! Maximum number of PDMA devices supported */ +#ifdef NGBDE_NUM_SWDEV_MAX +#define NUM_PDMA_DEV_MAX NGBDE_NUM_SWDEV_MAX +#else +#define NUM_PDMA_DEV_MAX 16 +#endif + +/*! + * Debug levels + */ +#define DBG_LVL_VERB 0x0001 +#define DBG_LVL_PKT 0x0002 +#define DBG_LVL_CMD 0x0004 +#define DBG_LVL_IRQ 0x0008 +#define DBG_LVL_NAPI 0x0010 +#define DBG_LVL_NDEV 0x0020 +#define DBG_LVL_FILT 0x0040 +#define DBG_LVL_RCPU 0x0080 +#define DBG_LVL_WARN 0x0100 +#define DBG_LVL_PDMP 0x0200 +#define DBG_LVL_RATE 0x0400 +#define DBG_LVL_LINK 0x0800 + +#define DBG_VERB(_s) do { if (debug & DBG_LVL_VERB) printk _s; } while (0) +#define DBG_PKT(_s) do { if (debug & DBG_LVL_PKT) printk _s; } while (0) +#define DBG_CMD(_s) do { if (debug & DBG_LVL_CMD) printk _s; } while (0) +#define DBG_IRQ(_s) do { if (debug & DBG_LVL_IRQ) printk _s; } while (0) +#define DBG_NAPI(_s) do { if (debug & DBG_LVL_NAPI) printk _s; } while (0) +#define DBG_NDEV(_s) do { if (debug & DBG_LVL_NDEV) printk _s; } while (0) +#define DBG_FILT(_s) do { if (debug & DBG_LVL_FILT) printk _s; } while (0) +#define DBG_RCPU(_s) do { if (debug & DBG_LVL_RCPU) printk _s; } while (0) +#define DBG_WARN(_s) do { if (debug & DBG_LVL_WARN) printk _s; } while (0) +#define DBG_PDMP(_s) do { if (debug & DBG_LVL_PDMP) printk _s; } while (0) +#define DBG_RATE(_s) do { if (debug & DBG_LVL_RATE) printk _s; } while (0) +#define DBG_LINK(_s) do { if (debug & DBG_LVL_LINK) printk _s; } while (0) + +/*! + * Device description + */ +struct ngknet_dev { + /*! Base address for PCI register access */ + volatile void *base_addr; + + /*! Required for DMA memory control */ + struct device *dev; + + /*! Required for PCI memory control */ + struct pci_dev *pci_dev; + + /*! Base network device */ + struct net_device *net_dev; + + /*! PDMA device */ + struct pdma_dev pdma_dev; + + /*! Device number (from BDE) */ + int dev_no; + + /*! Vitual network devices, 0 is reserved */ + struct net_device *vdev[NUM_VDEV_MAX + 1]; + + /*! Vitual network devices bound to queue */ + struct net_device *bdev[NUM_QUE_MAX]; + + /*! Filter list */ + struct list_head filt_list; + + /*! Filter control, 0 is reserved */ + void *fc[NUM_FILTER_MAX + 1]; + + /*! Callback control */ + struct ngknet_callback_ctrl *cbc; + + /*! RCPU control */ + struct ngknet_rcpu_hdr rcpu_ctrl; + + /*! NGKNET lock */ + spinlock_t lock; + + /*! NGKNET wait queue */ + wait_queue_head_t wq; + + /*! VNET wait queue */ + wait_queue_head_t vnet_wq; + + /*! VNET is active */ + atomic_t vnet_active; + + /*! HNET wait queue */ + wait_queue_head_t hnet_wq; + + /*! HNET is active */ + atomic_t hnet_active; + + /*! HNET deamon */ + struct task_struct *hnet_task; + + /*! HNET work */ + struct work_struct hnet_work; + + /*! PTP Tx queue */ + struct sk_buff_head ptp_tx_queue; + + /*! PTP Tx work */ + struct work_struct ptp_tx_work; + + /*! Flags */ + int flags; + /*! NGKNET device is active */ +#define NGKNET_DEV_ACTIVE (1 << 0) +}; + +/*! + * Network interface specific private data + */ +struct ngknet_private { + /*! Network device */ + struct net_device *net_dev; + + /*! Network stats */ + struct net_device_stats stats; + + /*! NGKNET device */ + struct ngknet_dev *bkn_dev; + + /*! Network interface ID */ + int id; + + /*! Network interface type */ + int type; + + /*! Network interface flags */ + uint32_t flags; + + /*! Network interface vlan */ + uint32_t vlan; + + /*! Network interface bound to */ + uint32_t chan; + + /*! Metadata offset from Ethernet header */ + uint32_t meta_off; + + /*! Metadata length */ + uint32_t meta_len; + + /*! Metadata used to send packets to physical port */ + uint8_t meta_data[NGKNET_NETIF_META_MAX]; + + /*! User data gotten back through callbacks */ + uint8_t user_data[NGKNET_NETIF_USER_DATA]; + + /*! Users of this network interface */ + int users; + + /*! Wait for this network interface free */ + int wait; + + /*! HW timestamp Rx filter */ + int hwts_rx_filter; + + /*! HW timestamp Tx type */ + int hwts_tx_type; +}; + +/*! + * \brief Create network interface. + * + * \param [in] dev NGKNET device structure point. + * \param [in] netif Network interface structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +ngknet_netif_create(struct ngknet_dev *dev, ngknet_netif_t *netif); + +/*! + * \brief Destroy network interface. + * + * \param [in] dev NGKNET device structure point. + * \param [in] id Network interface ID. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +ngknet_netif_destroy(struct ngknet_dev *dev, int id); + +/*! + * \brief Get network interface. + * + * \param [in] dev NGKNET device structure point. + * \param [in] id Network interface ID. + * \param [out] netif Network interface structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +ngknet_netif_get(struct ngknet_dev *dev, int id, ngknet_netif_t *netif); + +/*! + * \brief Get the next network interface. + * + * \param [in] dev NGKNET device structure point. + * \param [out] netif Network interface structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +ngknet_netif_get_next(struct ngknet_dev *dev, ngknet_netif_t *netif); + +/*! + * \brief Get debug level. + * + * \retval Current debug level. + */ +extern int +ngknet_debug_level_get(void); + +/*! + * \brief Set debug level. + * + * \param [in] debug_level Debug level to be set. + */ +extern void +ngknet_debug_level_set(int debug_level); + +/*! + * \brief Get Rx rate limit. + * + * \retval Current Rx rate limit. + */ +extern int +ngknet_rx_rate_limit_get(void); + +/*! + * \brief Set Rx rate limit. + * + * \param [in] rate_limit Rx rate limit to be set. + */ +extern void +ngknet_rx_rate_limit_set(int rate_limit); + +#endif /* NGKNET_MAIN_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_procfs.c b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_procfs.c new file mode 100644 index 000000000000..85edaa26abb9 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_procfs.c @@ -0,0 +1,655 @@ +/*! \file ngknet_procfs.c + * + * + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include "ngknet_main.h" +#include "ngknet_extra.h" + +extern struct ngknet_dev ngknet_devices[]; + +static struct proc_dir_entry *proc_root = NULL; + +static void +proc_data_show(struct seq_file *m, const unsigned char *buf, size_t len) +{ + uint32_t i; + + if (!buf || !len) { + seq_printf(m, "\n"); + return; + } + + for (i = 0; i < len; i++) { + seq_printf(m, "%02x ", buf[i]); + if ((i + 1) % 32 == 0 || (i + 1) == len) { + seq_printf(m, "\n"); + if ((i + 1) < len) { + seq_printf(m, " "); + } + } + } +} + +static int +proc_debug_level_show(struct seq_file *m, void *v) +{ + seq_printf(m, "Debug level: 0x%x\n", ngknet_debug_level_get()); + + return 0; +} + +static int +proc_debug_level_open(struct inode *inode, struct file *file) +{ + return single_open(file, proc_debug_level_show, NULL); +} + +static ssize_t +proc_debug_level_write(struct file *file, const char *buf, + size_t count, loff_t *loff) +{ + char level_str[11] = {0}; + int debug_level; + + if (copy_from_user(level_str, buf, sizeof(level_str) - 1)) { + return -EFAULT; + } + debug_level = simple_strtol(level_str, NULL, 16); + + ngknet_debug_level_set(debug_level); + printk("Debug level set to: 0x%x\n", debug_level); + + return count; +} + +static int +proc_debug_level_release(struct inode *inode, struct file *file) +{ + return single_release(inode, file); +} + +static struct file_operations proc_debug_level_fops = { + owner: THIS_MODULE, + open: proc_debug_level_open, + read: seq_read, + write: proc_debug_level_write, + llseek: seq_lseek, + release: proc_debug_level_release, +}; + +static int +proc_device_info_show(struct seq_file *m, void *v) +{ + struct ngknet_dev *dev; + struct bcmcnet_dev_info *info; + int di, qi, ai = 0; + int rv; + + for (di = 0; di < NUM_PDMA_DEV_MAX; di++) { + dev = &ngknet_devices[di]; + if (!(dev->flags & NGKNET_DEV_ACTIVE)) { + continue; + } + ai++; + + rv = bcmcnet_pdma_dev_info_get(&dev->pdma_dev); + if (SHR_FAILURE(rv)) { + printk("ngknet: get device%d info failed\n", di); + break; + } + + info = &dev->pdma_dev.info; + seq_printf(m, "dev_no: %d\n", di); + seq_printf(m, "dev_name: %s\n", info->dev_name); + seq_printf(m, "dev_id: 0x%x\n", info->dev_id); + seq_printf(m, "dev_type: %d\n", info->dev_type); + seq_printf(m, "max_groups: %d\n", info->max_groups); + seq_printf(m, "max_queues: %d\n", info->max_queues); + seq_printf(m, "bm_groups: 0x%x\n", info->bm_groups); + seq_printf(m, "bm_rx_queues: 0x%x\n", info->bm_rx_queues); + seq_printf(m, "bm_tx_queues: 0x%x\n", info->bm_tx_queues); + seq_printf(m, "nb_groups: %d\n", info->nb_groups); + seq_printf(m, "nb_rx_queues: %d\n", info->nb_rx_queues); + seq_printf(m, "nb_tx_queues: %d\n", info->nb_tx_queues); + seq_printf(m, "rx_desc_size: %d\n", info->rx_desc_size); + seq_printf(m, "tx_desc_size: %d\n", info->tx_desc_size); + seq_printf(m, "rx_ph_size: %d\n", info->rx_ph_size); + seq_printf(m, "tx_ph_size: %d\n", info->tx_ph_size); + for (qi = 0; qi < info->nb_rx_queues; qi++) { + seq_printf(m, "rx_buf_sz[%d]: %d\n", qi, info->rx_buf_size[qi]); + } + for (qi = 0; qi < info->nb_rx_queues; qi++) { + seq_printf(m, "nb_rx_desc[%d]: %d\n", qi, info->nb_rx_desc[qi]); + } + for (qi = 0; qi < info->nb_tx_queues; qi++) { + seq_printf(m, "nb_tx_desc[%d]: %d\n", qi, info->nb_tx_desc[qi]); + } + } + + if (!ai) { + seq_printf(m, "%s\n", "No active device"); + } else { + seq_printf(m, "------------------------\n"); + seq_printf(m, "Total %d devices\n", ai); + } + + return 0; +} + +static int +proc_device_info_open(struct inode *inode, struct file *file) +{ + return single_open(file, proc_device_info_show, NULL); +} + +static int +proc_device_info_release(struct inode *inode, struct file *file) +{ + return single_release(inode, file); +} + +static struct file_operations proc_device_info_fops = { + owner: THIS_MODULE, + open: proc_device_info_open, + read: seq_read, + llseek: seq_lseek, + release: proc_device_info_release, +}; + +static int +proc_filter_info_show(struct seq_file *m, void *v) +{ + struct ngknet_dev *dev; + ngknet_filter_t filt = {0}; + int di, dn = 0, fn = 0; + int rv; + + for (di = 0; di < NUM_PDMA_DEV_MAX; di++) { + dev = &ngknet_devices[di]; + if (!(dev->flags & NGKNET_DEV_ACTIVE)) { + continue; + } + dn++; + + do { + rv = ngknet_filter_get_next(dev, &filt); + if (SHR_FAILURE(rv)) { + printk("ngknet: get device%d filter failed\n", di); + break; + } + fn++; + + seq_printf(m, "\n"); + seq_printf(m, "dev_no: %d\n", di); + seq_printf(m, "id: %d\n", filt.id); + seq_printf(m, "next: %d\n", filt.next); + seq_printf(m, "type: %d\n", filt.type); + seq_printf(m, "flags: 0x%x\n", filt.flags); + seq_printf(m, "prio: %d\n", filt.priority); + seq_printf(m, "chan: %d\n", filt.chan); + seq_printf(m, "desc: %s\n", filt.desc); + seq_printf(m, "dest_type: %d\n", filt.dest_type); + seq_printf(m, "dest_id: %d\n", filt.dest_id); + seq_printf(m, "dest_proto: 0x%x\n", filt.dest_proto); + seq_printf(m, "mirror_type: %d\n", filt.mirror_type); + seq_printf(m, "mirror_id: %d\n", filt.mirror_id); + seq_printf(m, "mirror_proto: 0x%x\n", filt.mirror_proto); + seq_printf(m, "oob_offset: %d\n", filt.oob_data_offset); + seq_printf(m, "oob_size: %d\n", filt.oob_data_size); + seq_printf(m, "pkt_offset: %d\n", filt.pkt_data_offset); + seq_printf(m, "pkt_size: %d\n", filt.pkt_data_size); + seq_printf(m, "filt_data: "); + proc_data_show(m, filt.data.b, filt.oob_data_size + filt.pkt_data_size); + seq_printf(m, "filt_mask: "); + proc_data_show(m, filt.mask.b, filt.oob_data_size + filt.pkt_data_size); + seq_printf(m, "user_data: "); + proc_data_show(m, filt.user_data, NGKNET_FILTER_USER_DATA); + seq_printf(m, "hits: %llu\n", ((struct filt_ctrl *)dev->fc[filt.id])->hits); + } while (filt.next); + } + + if (!dn) { + seq_printf(m, "%s\n", "No active device"); + } else { + seq_printf(m, "--------------------------------\n"); + seq_printf(m, "Total %d devices, %d filters\n", dn, fn); + } + + return 0; +} + +static int +proc_filter_info_open(struct inode *inode, struct file *file) +{ + return single_open(file, proc_filter_info_show, NULL); +} + +static int +proc_filter_info_release(struct inode *inode, struct file *file) +{ + return single_release(inode, file); +} + +static struct file_operations proc_filter_info_fops = { + owner: THIS_MODULE, + open: proc_filter_info_open, + read: seq_read, + llseek: seq_lseek, + release: proc_filter_info_release, +}; + +static int +proc_netif_info_show(struct seq_file *m, void *v) +{ + struct ngknet_dev *dev; + struct net_device *ndev; + struct ngknet_private *priv; + ngknet_netif_t netif = {0}; + int di, ma, dn = 0, nn = 0; + int rv; + + for (di = 0; di < NUM_PDMA_DEV_MAX; di++) { + dev = &ngknet_devices[di]; + if (!(dev->flags & NGKNET_DEV_ACTIVE)) { + continue; + } + dn++; + + do { + rv = ngknet_netif_get_next(dev, &netif); + if (SHR_FAILURE(rv)) { + printk("ngknet: get device%d netif failed\n", di); + break; + } + nn++; + ndev = netif.id == 0 ? dev->net_dev : dev->vdev[netif.id]; + priv = netdev_priv(ndev); + + seq_printf(m, "\n"); + seq_printf(m, "dev_no: %d\n", di); + seq_printf(m, "id: %d\n", netif.id); + seq_printf(m, "next: %d\n", netif.next); + seq_printf(m, "type: %d\n", netif.type); + seq_printf(m, "flags: 0x%x\n", netif.flags); + seq_printf(m, "vlan: %d\n", netif.vlan); + seq_printf(m, "mac: "); + for (ma = 0; ma < 6; ma++) { + if (ma == 5) { + seq_printf(m, "%02x\n", netif.macaddr[ma]); + } else { + seq_printf(m, "%02x:", netif.macaddr[ma]); + } + } + seq_printf(m, "mtu: %d\n", netif.mtu); + seq_printf(m, "chan: %d\n", netif.chan); + seq_printf(m, "name: %s\n", netif.name); + seq_printf(m, "meta_off: %d\n", netif.meta_off); + seq_printf(m, "meta_len: %d\n", netif.meta_len); + seq_printf(m, "meta_data: "); + proc_data_show(m, netif.meta_data, netif.meta_len); + seq_printf(m, "user_data: "); + proc_data_show(m, netif.user_data, NGKNET_NETIF_USER_DATA); + seq_printf(m, "rx_packets: %lu\n", priv->stats.rx_packets); + seq_printf(m, "rx_bytes: %lu\n", priv->stats.rx_bytes); + seq_printf(m, "rx_dropped: %lu\n", priv->stats.rx_dropped); + seq_printf(m, "rx_errors: %lu\n", priv->stats.rx_errors); + seq_printf(m, "tx_packets: %lu\n", priv->stats.tx_packets); + seq_printf(m, "tx_bytes: %lu\n", priv->stats.tx_bytes); + seq_printf(m, "tx_dropped: %lu\n", priv->stats.tx_dropped); + seq_printf(m, "tx_errors: %lu\n", priv->stats.tx_errors); + } while (netif.next); + } + + if (!dn) { + seq_printf(m, "%s\n", "No active device"); + } else { + seq_printf(m, "--------------------------------\n"); + seq_printf(m, "Total %d devices, %d netifs\n", dn, nn); + } + + return 0; +} + +static int +proc_netif_info_open(struct inode *inode, struct file *file) +{ + return single_open(file, proc_netif_info_show, NULL); +} + +static int +proc_netif_info_release(struct inode *inode, struct file *file) +{ + return single_release(inode, file); +} + +static struct file_operations proc_netif_info_fops = { + owner: THIS_MODULE, + open: proc_netif_info_open, + read: seq_read, + llseek: seq_lseek, + release: proc_netif_info_release, +}; + +static int +proc_pkt_stats_show(struct seq_file *m, void *v) +{ + struct ngknet_dev *dev; + struct bcmcnet_dev_stats *stats; + int di, qi, ai = 0; + int rv; + + for (di = 0; di < NUM_PDMA_DEV_MAX; di++) { + dev = &ngknet_devices[di]; + if (!(dev->flags & NGKNET_DEV_ACTIVE)) { + continue; + } + ai++; + + rv = bcmcnet_pdma_dev_stats_get(&dev->pdma_dev); + if (SHR_FAILURE(rv)) { + printk("ngknet: get device%d stats failed\n", di); + break; + } + + stats = &dev->pdma_dev.stats; + seq_printf(m, "rx_packets: %llu\n", (unsigned long long)stats->rx_packets); + seq_printf(m, "rx_bytes: %llu\n", (unsigned long long)stats->rx_bytes); + for (qi = 0; qi < dev->pdma_dev.ctrl.nb_rxq; qi++) { + seq_printf(m, "rx_packets[%d]: %llu\n", qi, (unsigned long long)stats->rxq_packets[qi]); + seq_printf(m, "rx_bytes[%d]: %llu\n", qi, (unsigned long long)stats->rxq_bytes[qi]); + } + seq_printf(m, "rx_dropped: %llu\n", (unsigned long long)stats->rx_dropped); + seq_printf(m, "rx_errors: %llu\n", (unsigned long long)stats->rx_errors); + seq_printf(m, "rx_nomems: %llu\n", (unsigned long long)stats->rx_nomems); + seq_printf(m, "tx_packets: %llu\n", (unsigned long long)stats->tx_packets); + seq_printf(m, "tx_bytes: %llu\n", (unsigned long long)stats->tx_bytes); + for (qi = 0; qi < dev->pdma_dev.ctrl.nb_txq; qi++) { + seq_printf(m, "tx_packets[%d]: %llu\n", qi, (unsigned long long)stats->txq_packets[qi]); + seq_printf(m, "tx_bytes[%d]: %llu\n", qi, (unsigned long long)stats->txq_bytes[qi]); + } + seq_printf(m, "tx_dropped: %llu\n", (unsigned long long)stats->tx_dropped); + seq_printf(m, "tx_errors: %llu\n", (unsigned long long)stats->tx_errors); + seq_printf(m, "tx_xoffs: %llu\n", (unsigned long long)stats->tx_xoffs); + seq_printf(m, "interrupts: %llu\n", (unsigned long long)stats->intrs); + } + + if (!ai) { + seq_printf(m, "%s\n", "No active device"); + } else { + seq_printf(m, "------------------------\n"); + seq_printf(m, "Total %d devices\n", ai); + } + + return 0; +} + +static int +proc_pkt_stats_open(struct inode *inode, struct file *file) +{ + return single_open(file, proc_pkt_stats_show, NULL); +} + +static int +proc_pkt_stats_release(struct inode *inode, struct file *file) +{ + return single_release(inode, file); +} + +static struct file_operations proc_pkt_stats_fops = { + owner: THIS_MODULE, + open: proc_pkt_stats_open, + read: seq_read, + llseek: seq_lseek, + release: proc_pkt_stats_release, +}; + +static int +proc_rate_limit_show(struct seq_file *m, void *v) +{ + seq_printf(m, "Rx rate limit: %d pps\n", ngknet_rx_rate_limit_get()); + + return 0; +} + +static int +proc_rate_limit_open(struct inode *inode, struct file *file) +{ + return single_open(file, proc_rate_limit_show, NULL); +} + +static ssize_t +proc_rate_limit_write(struct file *file, const char *buf, + size_t count, loff_t *loff) +{ + char limit_str[9] = {0}; + int rate_limit; + + if (copy_from_user(limit_str, buf, sizeof(limit_str) - 1)) { + return -EFAULT; + } + rate_limit = simple_strtol(limit_str, NULL, 10); + + ngknet_rx_rate_limit_set(rate_limit); + printk("Rx rate limit set to: %d pps\n", rate_limit); + + return count; +} + +static int +proc_rate_limit_release(struct inode *inode, struct file *file) +{ + return single_release(inode, file); +} + +static struct file_operations proc_rate_limit_fops = { + owner: THIS_MODULE, + open: proc_rate_limit_open, + read: seq_read, + write: proc_rate_limit_write, + llseek: seq_lseek, + release: proc_rate_limit_release, +}; + +static int +proc_reg_status_show(struct seq_file *m, void *v) +{ + struct ngknet_dev *dev; + int di, qi, ai = 0; + + for (di = 0; di < NUM_PDMA_DEV_MAX; di++) { + dev = &ngknet_devices[di]; + if (!(dev->flags & NGKNET_DEV_ACTIVE)) { + continue; + } + ai++; + for (qi = 0; qi < dev->pdma_dev.ctrl.nb_rxq; qi++) { + bcmcnet_pdma_rx_queue_reg_dump(&dev->pdma_dev, qi); + } + for (qi = 0; qi < dev->pdma_dev.ctrl.nb_txq; qi++) { + bcmcnet_pdma_tx_queue_reg_dump(&dev->pdma_dev, qi); + } + } + + if (!ai) { + seq_printf(m, "%s\n", "No active device"); + } else { + seq_printf(m, "------------------------\n"); + seq_printf(m, "Total %d devices\n", ai); + } + + return 0; +} + +static int +proc_reg_status_open(struct inode *inode, struct file *file) +{ + return single_open(file, proc_reg_status_show, NULL); +} + +static int +proc_reg_status_release(struct inode *inode, struct file *file) +{ + return single_release(inode, file); +} + +static struct file_operations proc_reg_status_fops = { + owner: THIS_MODULE, + open: proc_reg_status_open, + read: seq_read, + llseek: seq_lseek, + release: proc_reg_status_release, +}; + +static int +proc_ring_status_show(struct seq_file *m, void *v) +{ + struct ngknet_dev *dev; + int di, qi, ai = 0; + + for (di = 0; di < NUM_PDMA_DEV_MAX; di++) { + dev = &ngknet_devices[di]; + if (!(dev->flags & NGKNET_DEV_ACTIVE)) { + continue; + } + ai++; + seq_printf(m, "%s-%d, ", "Unit", di); + for (qi = 0; qi < dev->pdma_dev.ctrl.nb_rxq; qi++) { + bcmcnet_pdma_rx_ring_dump(&dev->pdma_dev, qi); + } + seq_printf(m, "%s%d, ", "Rx queues: ", qi); + for (qi = 0; qi < dev->pdma_dev.ctrl.nb_txq; qi++) { + bcmcnet_pdma_tx_ring_dump(&dev->pdma_dev, qi); + } + seq_printf(m, "%s%d. ", "Tx queues: ", qi); + seq_printf(m, "\n"); + } + + if (!ai) { + seq_printf(m, "%s\n", "No active device"); + } else { + seq_printf(m, "------------------------\n"); + seq_printf(m, "Total %d devices\n", ai); + } + + return 0; +} + +static int +proc_ring_status_open(struct inode *inode, struct file *file) +{ + return single_open(file, proc_ring_status_show, NULL); +} + +static int +proc_ring_status_release(struct inode *inode, struct file *file) +{ + return single_release(inode, file); +} + +static struct file_operations proc_ring_status_fops = { + owner: THIS_MODULE, + open: proc_ring_status_open, + read: seq_read, + llseek: seq_lseek, + release: proc_ring_status_release, +}; + +int +ngknet_procfs_init(void) +{ + struct proc_dir_entry *entry = NULL; + + proc_root = proc_mkdir(NGKNET_MODULE_NAME, NULL); + if (proc_root == NULL) { + printk(KERN_ERR "ngknet: proc_mkdir failed\n"); + return -1; + } + + PROC_CREATE(entry, "debug_level", 0666, proc_root, &proc_debug_level_fops); + if (entry == NULL) { + printk(KERN_ERR "ngknet: proc_create failed\n"); + return -1; + } + + PROC_CREATE(entry, "device_info", 0444, proc_root, &proc_device_info_fops); + if (entry == NULL) { + printk(KERN_ERR "ngknet: proc_create failed\n"); + return -1; + } + + PROC_CREATE(entry, "filter_info", 0444, proc_root, &proc_filter_info_fops); + if (entry == NULL) { + printk(KERN_ERR "ngknet: proc_create failed\n"); + return -1; + } + + PROC_CREATE(entry, "netif_info", 0444, proc_root, &proc_netif_info_fops); + if (entry == NULL) { + printk(KERN_ERR "ngknet: proc_create failed\n"); + return -1; + } + + PROC_CREATE(entry, "pkt_stats", 0444, proc_root, &proc_pkt_stats_fops); + if (entry == NULL) { + printk(KERN_ERR "ngknet: proc_create failed\n"); + return -1; + } + + PROC_CREATE(entry, "rate_limit", 0666, proc_root, &proc_rate_limit_fops); + if (entry == NULL) { + printk(KERN_ERR "ngknet: proc_create failed\n"); + return -1; + } + + PROC_CREATE(entry, "reg_status", 0444, proc_root, &proc_reg_status_fops); + if (entry == NULL) { + printk(KERN_ERR "ngknet: proc_create failed\n"); + return -1; + } + + PROC_CREATE(entry, "ring_status", 0444, proc_root, &proc_ring_status_fops); + if (entry == NULL) { + printk(KERN_ERR "ngknet: proc_create failed\n"); + return -1; + } + + return 0; +} + +int +ngknet_procfs_cleanup(void) +{ + remove_proc_entry("debug_level", proc_root); + remove_proc_entry("device_info", proc_root); + remove_proc_entry("filter_info", proc_root); + remove_proc_entry("netif_info", proc_root); + remove_proc_entry("pkt_stats", proc_root); + remove_proc_entry("rate_limit", proc_root); + remove_proc_entry("reg_status", proc_root); + remove_proc_entry("ring_status", proc_root); + + remove_proc_entry(NGKNET_MODULE_NAME, NULL); + + return 0; +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_procfs.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_procfs.h new file mode 100644 index 000000000000..3c1938121ebb --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_procfs.h @@ -0,0 +1,47 @@ +/*! \file ngknet_procfs.h + * + * Procfs-related definitions and APIs for NGKNET module. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef NGKNET_PROCFS_H +#define NGKNET_PROCFS_H + +/*! + * \brief Initialize procfs for KNET driver. + * + * Create procfs read/write interfaces. + * + * \return 0 if no errors, otherwise -1. + */ +extern int +ngknet_procfs_init(void); + +/*! + * \brief Clean up procfs for KNET driver. + * + * Clean up resources allocated by \ref ngknet_procfs_init. + * + * \return 0 if no errors, otherwise -1. + */ +extern int +ngknet_procfs_cleanup(void); + +#endif /* NGKNET_PROCFS_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_ptp.c b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_ptp.c new file mode 100644 index 000000000000..13579208eab0 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_ptp.c @@ -0,0 +1,194 @@ +/*! \file ngknet_ptp.c + * + * Utility routines for PTP. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include "ngknet_callback.h" +#include "ngknet_ptp.h" + +int +ngknet_ptp_rx_config_set(struct net_device *ndev, int *filter) +{ + struct ngknet_private *priv = netdev_priv(ndev); + struct ngknet_dev *dev = priv->bkn_dev; + + if (!dev->cbc->ptp_rx_config_set_cb) { + return SHR_E_UNAVAIL; + } + + /* + * The expected Rx filter value is passed to the callback. The callback + * should pass back the actual filter value by the paramter . + * The callback can use priv->user_data to get other private parameters + * such as phys_port, dev_type, etc, which should be introduced when the + * netif is created. + */ + return dev->cbc->ptp_rx_config_set_cb(priv, filter); +} + +int +ngknet_ptp_tx_config_set(struct net_device *ndev, int type) +{ + struct ngknet_private *priv = netdev_priv(ndev); + struct ngknet_dev *dev = priv->bkn_dev; + + if (!dev->cbc->ptp_tx_config_set_cb) { + return SHR_E_UNAVAIL; + } + + /* + * The Tx type value is passed to the callback by the parameter . + * The callback should do the configuration according to the type. + * The callback can use priv->user_data to get other private parameters + * such as phys_port, dev_type, etc, which should be introduced when the + * netif is created. + */ + return dev->cbc->ptp_tx_config_set_cb(priv, &type); +} + +int +ngknet_ptp_rx_hwts_get(struct net_device *ndev, struct sk_buff *skb, uint64_t *ts) +{ + struct ngknet_private *priv = netdev_priv(ndev); + struct ngknet_dev *dev = priv->bkn_dev; + struct ngknet_callback_desc *cbd = NGKNET_SKB_CB(skb); + struct pkt_hdr *pkh = (struct pkt_hdr *)skb->data; + + if (!dev->cbc->ptp_rx_hwts_get_cb) { + return SHR_E_UNAVAIL; + } + + cbd->dev_no = dev->dev_no; + cbd->dev_id = dev->pdma_dev.dev_id; + cbd->priv = priv; + cbd->pmd = skb->data + PKT_HDR_SIZE; + cbd->pmd_len = pkh->meta_len; + cbd->pkt_len = pkh->data_len; + + /* + * The callback should get timestamp value for a Rx packet and return + * by the parameter . + * Some parameters have been consolidated to SKB as above. They can be + * achieved by NGKNET_SKB_CB(skb). Specially more private paramters are + * in NGKNET_SKB_CB(skb)->priv->user_data[]. + */ + return dev->cbc->ptp_rx_hwts_get_cb(skb, ts); +} + +int +ngknet_ptp_tx_hwts_get(struct net_device *ndev, struct sk_buff *skb, uint64_t *ts) +{ + struct ngknet_private *priv = netdev_priv(ndev); + struct ngknet_dev *dev = priv->bkn_dev; + struct ngknet_callback_desc *cbd = NGKNET_SKB_CB(skb); + struct pkt_hdr *pkh = (struct pkt_hdr *)skb->data; + + if (!dev->cbc->ptp_tx_hwts_get_cb) { + return SHR_E_UNAVAIL; + } + + cbd->dev_no = dev->dev_no; + cbd->dev_id = dev->pdma_dev.dev_id; + cbd->priv = priv; + cbd->pmd = skb->data + PKT_HDR_SIZE; + cbd->pmd_len = pkh->meta_len; + cbd->pkt_len = pkh->data_len; + + /* + * The callback should get timestamp value for a Tx packet and return + * by the parameter . + * For HWTSTAMP_TX_ONESTEP_SYNC type, the time value can be achieved and + * returned immediately. Otherwise, for HWTSTAMP_TX_ON type, the callback + * should wait till the time value can be available, i.e. the packet has + * been tranmitted out from port. + * Some parameters have been consolidated to SKB as above. They can be + * achieved by NGKNET_SKB_CB(skb). Specially more private paramters are + * in NGKNET_SKB_CB(skb)->priv->user_data[] such as phys_port, dev_type, + * and so on. + */ + return dev->cbc->ptp_tx_hwts_get_cb(skb, ts); +} + +int +ngknet_ptp_tx_meta_set(struct net_device *ndev, struct sk_buff *skb) +{ + struct ngknet_private *priv = netdev_priv(ndev); + struct ngknet_dev *dev = priv->bkn_dev; + struct ngknet_callback_desc *cbd = NGKNET_SKB_CB(skb); + struct pkt_hdr *pkh = (struct pkt_hdr *)skb->data; + + if (!dev->cbc->ptp_tx_meta_set_cb) { + return SHR_E_UNAVAIL; + } + + cbd->dev_no = dev->dev_no; + cbd->dev_id = dev->pdma_dev.dev_id; + cbd->priv = priv; + cbd->pmd = skb->data + PKT_HDR_SIZE; + cbd->pmd_len = pkh->meta_len; + cbd->pkt_len = pkh->data_len; + + /* + * The callback should configure the metadata pmd> + * for HW timestamping according to the corresponding switch device. + * Some parameters have been consolidated to SKB as above. They can be + * achieved by NGKNET_SKB_CB(skb). Specially more private paramters are + * in NGKNET_SKB_CB(skb)->priv->user_data[] such as phys_port, dev_type, + * and so on. + */ + return dev->cbc->ptp_tx_meta_set_cb(skb); +} + +int +ngknet_ptp_phc_index_get(struct net_device *ndev, int *index) +{ + struct ngknet_private *priv = netdev_priv(ndev); + struct ngknet_dev *dev = priv->bkn_dev; + + if (!dev->cbc->ptp_phc_index_get_cb) { + return SHR_E_UNAVAIL; + } + + /* + * The callback should return the HPC index by the parameter . + * priv->user_data[] can be used to get other private parameters such as + * phys_port, dev_type, etc, which should be introduced when the netif is + * created. + */ + return dev->cbc->ptp_phc_index_get_cb(priv, index); +} + +int +ngknet_ptp_dev_ctrl(struct ngknet_dev *dev, int cmd, char *data, int len) +{ + if (!dev->cbc->ptp_dev_ctrl_cb) { + return SHR_E_UNAVAIL; + } + + /* + * The callback is IOCTL dispatcher for PTP driver/module. + * The parameter is the command defined by the user. The parameter + * and are used for interactions between the user application + * and the driver for PTP device start/stop, enable/disable, set/get, and + * so on. + */ + return dev->cbc->ptp_dev_ctrl_cb(dev, cmd, data, len); +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_ptp.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_ptp.h new file mode 100644 index 000000000000..86dcb6c4904a --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_ptp.h @@ -0,0 +1,111 @@ +/*! \file ngknet_ptp.h + * + * Definitions and APIs declaration for PTP. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef NGKNET_PTP_H +#define NGKNET_PTP_H + +#include +#include "ngknet_main.h" + +/*! + * \brief PTP Rx config set. + * + * \param [in] ndev Network device structure point. + * \param [in] filter Rx filter. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_rx_config_set(struct net_device *ndev, int *filter); + +/*! + * \brief PTP Tx config set. + * + * \param [in] ndev Network device structure point. + * \param [in] type Tx type. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_tx_config_set(struct net_device *ndev, int type); + +/*! + * \brief PTP Rx HW timestamping get. + * + * \param [in] ndev Network device structure point. + * \param [in] skb Rx packet SKB. + * \param [out] ts Timestamp value. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_rx_hwts_get(struct net_device *ndev, struct sk_buff *skb, uint64_t *ts); + +/*! + * \brief PTP Tx HW timestamping get. + * + * \param [in] ndev Network device structure point. + * \param [in] skb Tx packet SKB. + * \param [out] ts Timestamp value. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_tx_hwts_get(struct net_device *ndev, struct sk_buff *skb, uint64_t *ts); + +/*! + * \brief PTP Tx meta set. + * + * \param [in] ndev Network device structure point. + * \param [in] skb Tx packet SKB. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_tx_meta_set(struct net_device *ndev, struct sk_buff *skb); + +/*! + * \brief PTP PHC index get. + * + * \param [in] ndev Network device structure point. + * \param [out] index PHC index. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_phc_index_get(struct net_device *ndev, int *index); + +/*! + * \brief PTP device control. + * + * \param [in] dev NGKNET device structure point. + * \param [in] cmd Command. + * \param [in] data Data buffer. + * \param [in] len Data length. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_dev_ctrl(struct ngknet_dev *dev, int cmd, char *data, int len); + +#endif /* NGKNET_PTP_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Kbuild b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Kbuild new file mode 100644 index 000000000000..2ce66edb3c63 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Kbuild @@ -0,0 +1,36 @@ +# -*- Kbuild -*- +# +# Linux KNET Callback module. +# +# $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. +# The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# A copy of the GNU General Public License version 2 (GPLv2) can +# be found in the LICENSES folder.$ +# +ifeq ($(BUILD_PSAMPLE),1) +PSAMPLE_CFLAGS=-DPSAMPLE_SUPPORT +PSAMPLE_CB_OBJS=psample-cb.o +endif + +obj-m := linux_ngknetcb.o + +ccflags-y := $(LKM_CFLAGS) \ + -I$(SDK)/shr/include \ + -I$(SDK)/bcmdrd/include \ + -I$(SDK)/linux/include \ + -I$(SDK)/linux/knet/include \ + -I$(SDK)/linux/knet \ + $(PSAMPLE_CFLAGS) + +linux_ngknetcb-y := ngknetcb_main.o \ + $(PSAMPLE_CB_OBJS) diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Makefile b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Makefile new file mode 100644 index 000000000000..e2acfed49d6c --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Makefile @@ -0,0 +1,33 @@ +# -*- Makefile -*- +# +# Linux KNET Callback module. +# +# $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. +# The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# A copy of the GNU General Public License version 2 (GPLv2) can +# be found in the LICENSES folder.$ +# + +include Kbuild + +ifeq ($(KERNELRELEASE),) + +MOD_NAME = linux_ngknetcb + +include $(SDK)/make/lkm.mk + +endif + +.PHONY: distclean + +distclean: diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/ngknetcb_main.c b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/ngknetcb_main.c new file mode 100644 index 000000000000..aa248dafce52 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/ngknetcb_main.c @@ -0,0 +1,444 @@ +/*! \file ngknetcb_main.c + * + * NGKNET Callback module entry. + */ +/* + * $Copyright: (c) 2019 Broadcom. + * Broadcom Proprietary and Confidential. All rights reserved.$ + */ + +#include +#include +#include "psample-cb.h" + +/*! \cond */ +MODULE_AUTHOR("Broadcom Corporation"); +MODULE_DESCRIPTION("NGKNET Callback Module"); +MODULE_LICENSE("GPL"); +/*! \endcond */ + +/*! \cond */ +int debug = 0; +MODULE_PARAM(debug, int, 0); +MODULE_PARM_DESC(debug, +"Debug level (default 0)"); +/*! \endcond */ + +/*! Module information */ +#define NGKNETCB_MODULE_NAME "linux_ngknetcb" +#define NGKNETCB_MODULE_MAJOR 122 + +/* set KNET_CB_DEBUG for debug info */ +#define KNET_CB_DEBUG + +/* These below need to match incoming enum values */ +#define FILTER_TAG_STRIP 0 +#define FILTER_TAG_KEEP 1 +#define FILTER_TAG_ORIGINAL 2 + +/* Maintain tag strip statistics */ +struct strip_stats_s { + unsigned long stripped; /* Number of packets that have been stripped */ + unsigned long checked; + unsigned long skipped; +}; + +static struct strip_stats_s strip_stats; +static unsigned int rx_count = 0; + +/* Local function prototypes */ +static void strip_vlan_tag(struct sk_buff *skb); + +/* Remove VLAN tag for select TPIDs */ +static void +strip_vlan_tag(struct sk_buff *skb) +{ + uint16_t vlan_proto; + uint8_t *pkt = skb->data; + + vlan_proto = (uint16_t) ((pkt[12] << 8) | pkt[13]); + if ((vlan_proto == 0x8100) || (vlan_proto == 0x88a8) || (vlan_proto == 0x9100)) { + /* Move first 12 bytes of packet back by 4 */ + memmove(&skb->data[4], skb->data, 12); + skb_pull(skb, 4); /* Remove 4 bytes from start of buffer */ + } +} + +/* + * The function get_tag_status() returns the tag status. + * 0 = Untagged + * 1 = Single inner-tag + * 2 = Single outer-tag + * 3 = Double tagged. + * -1 = Unsupported type + */ +static int +get_tag_status(uint32_t dev_type, void *meta) +{ + uint32_t *valptr; + uint32_t fd_index; + uint32_t outer_l2_hdr; + int tag_status = -1; + + if ((dev_type == 0xb880) || (dev_type == 0xb780)) + { + /* Field BCM_PKTIO_RXPMD_MATCH_ID_LO has tag status in RX PMD */ + fd_index = 2; + valptr = (uint32_t *)meta; + outer_l2_hdr = (valptr[fd_index] >> ((dev_type == 0xb780) ? 2 : 1) & 0xFF); + + if (outer_l2_hdr & 0x1) { +#ifdef KNET_CB_DEBUG + if (debug & 0x1) { + printk(" L2 Header Present\n"); + } +#endif + tag_status = 0; + if (outer_l2_hdr & 0x4) { +#ifdef KNET_CB_DEBUG + if (debug & 0x1) { + printk(" SNAP/LLC\n"); + } +#endif + tag_status = 0; + } + if (outer_l2_hdr & 0x10) { +#ifdef KNET_CB_DEBUG + if (debug & 0x1) { + printk(" Outer Tagged\n"); + } +#endif + tag_status = 2; + if (outer_l2_hdr & 0x20) { +#ifdef KNET_CB_DEBUG + if (debug & 0x1) { + printk(" Double Tagged\n"); + } +#endif + tag_status = 3; + } + } + else if (outer_l2_hdr & 0x20) { +#ifdef KNET_CB_DEBUG + if (debug & 0x1) { + printk(" Inner Tagged\n"); + } +#endif + tag_status = 1; + } + } + } + else if ((dev_type == 0xb990)|| (dev_type == 0xb996)) + { + fd_index = 9; + valptr = (uint32_t *)meta; + /* On TH4, outer_l2_header means INCOMING_TAG_STATUS. + * TH4 only supports single tagging, so if TAG_STATUS + * says there's a tag, then we don't want to strip. + * Otherwise, we do. + */ + outer_l2_hdr = (valptr[fd_index] >> 13) & 3; + + if (outer_l2_hdr) + { + tag_status = 2; +#ifdef KNET_CB_DEBUG + if (debug & 0x1) + { + printk(" Incoming frame tagged\n"); + } +#endif + } + else + { + tag_status = 0; +#ifdef KNET_CB_DEBUG + if (debug & 0x1) + { + printk(" Incoming frame untagged\n"); + } +#endif + } + } +#ifdef KNET_CB_DEBUG + if (debug & 0x1) { + printk("%s; Device Type: %d; tag status: %d\n", __func__, dev_type, tag_status); + } +#endif + return tag_status; +} + +#ifdef KNET_CB_DEBUG +static void +dump_buffer(uint8_t * data, int size) +{ + const char *const to_hex = "0123456789ABCDEF"; + int i; + char buffer[128]; + char *buffer_ptr; + int addr = 0; + + buffer_ptr = buffer; + for (i = 0; i < size; i++) { + *buffer_ptr++ = ' '; + *buffer_ptr++ = to_hex[(data[i] >> 4) & 0xF]; + *buffer_ptr++ = to_hex[data[i] & 0xF]; + if (((i % 16) == 15) || (i == size - 1)) { + *buffer_ptr = '\0'; + buffer_ptr = buffer; + printk(KERN_INFO "%04X %s\n", addr, buffer); + addr = i + 1; + } + } +} + +static void +show_pmd(uint8_t *pmd, int len) +{ + if (debug & 0x1) { + printk("PMD (%d bytes):\n", len); + dump_buffer(pmd, len); + } +} + +static void +show_mac(uint8_t *pkt) +{ + if (debug & 0x1) { + printk("DMAC=%02X:%02X:%02X:%02X:%02X:%02X\n", + pkt[0], pkt[1], pkt[2], pkt[3], pkt[4], pkt[5]); + } +} +#endif + +static struct sk_buff * +strip_tag_rx_cb(struct sk_buff *skb) +{ + const struct ngknet_callback_desc *cbd = NGKNET_SKB_CB(skb); + const struct ngknet_private *priv = cbd->priv; + int rcpu_mode = 0; + int tag_status; + + rcpu_mode = (priv->flags & NGKNET_NETIF_F_RCPU_ENCAP)? 1 : 0; +#ifdef KNET_CB_DEBUG + if (debug & 0x1) + { + printk(KERN_INFO + "\n%4u --------------------------------------------------------------------------------\n", + rx_count); + printk(KERN_INFO + "RX KNET callback: dev_no=%1d; dev_id=0x%04X; type_str=%4s; RCPU: %3s \n", + cbd->dev_no, cbd->dev_id, cbd->type_str, rcpu_mode ? "yes" : "no"); + printk(KERN_INFO " pkt_len=%4d; pmd_len=%2d; SKB len: %4d\n", + cbd->pkt_len, cbd->pmd_len, skb->len); + if (cbd->filt) { + printk(KERN_INFO "Filter user data: 0x%08x\n", + *(uint32_t *) cbd->filt->user_data); + } + printk(KERN_INFO "Before SKB (%d bytes):\n", skb->len); + dump_buffer(skb->data, skb->len); + printk("rx_cb for dev %d: id 0x%x, %s\n", cbd->dev_no, cbd->dev_id, cbd->type_str); + printk("netif user data: 0x%08x\n", *(uint32_t *)cbd->priv->user_data); + show_pmd(cbd->pmd, cbd->pmd_len); + if (rcpu_mode) { + const int RCPU_header_len = PKT_HDR_SIZE + cbd->pmd_len; + const int payload_len = skb->len - RCPU_header_len; + unsigned char *payload_start = skb->data + payload_len; + + printk(KERN_INFO "Packet Payload (%d bytes):\n", payload_len); + dump_buffer(payload_start, payload_len); + } else { + printk(KERN_INFO "Packet (%d bytes):\n", cbd->pkt_len); + dump_buffer(skb->data, cbd->pkt_len); + } + } +#endif + + if ((!rcpu_mode) && (cbd->filt)) { + if (FILTER_TAG_ORIGINAL == cbd->filt->user_data[0]) { + tag_status = get_tag_status(cbd->dev_id, (void *)cbd->pmd); + if (tag_status < 0) { + strip_stats.skipped++; + goto _strip_tag_rx_cb_exit; + } + strip_stats.checked++; + if (tag_status < 2) { + strip_stats.stripped++; + strip_vlan_tag(skb); + } + } + } +_strip_tag_rx_cb_exit: +#ifdef KNET_CB_DEBUG + if (debug & 0x1) { + printk(KERN_INFO "After SKB (%d bytes):\n", skb->len); + dump_buffer(skb->data, skb->len); + printk(KERN_INFO + "\n%4u --------------------------------------------------------------------------------\n", + rx_count++); + } +#endif + return skb; +} + +static struct sk_buff * +strip_tag_tx_cb(struct sk_buff *skb) +{ +#ifdef KNET_CB_DEBUG + struct ngknet_callback_desc *cbd = NGKNET_SKB_CB(skb); + + if (debug & 0x1) { + printk("tx_cb for dev %d: %s\n", cbd->dev_no, cbd->type_str); + } + show_pmd(cbd->pmd, cbd->pmd_len); + show_mac(cbd->pmd + cbd->pmd_len); +#endif + return skb; +} + +static struct sk_buff * +ngknet_rx_cb(struct sk_buff *skb) +{ + skb = strip_tag_rx_cb(skb); +#ifdef PSAMPLE_SUPPORT + skb = psample_rx_cb(skb); +#endif + return skb; +} + +static struct sk_buff * +ngknet_tx_cb(struct sk_buff *skb) +{ + skb = strip_tag_tx_cb(skb); + return skb; +} + +static int +ngknet_netif_create_cb(struct net_device *dev) +{ + int retv = 0; +#ifdef PSAMPLE_SUPPORT + retv = psample_netif_create_cb(dev); +#endif + return retv; +} + +static int +ngknet_netif_destroy_cb(struct net_device *dev) +{ + int retv = 0; +#ifdef PSAMPLE_SUPPORT + retv = psample_netif_destroy_cb(dev); +#endif + return retv; +} + +/*! + * Generic module functions + */ +static int +ngknetcb_show(struct seq_file *m, void *v) +{ + seq_printf(m, "Broadcom Linux NGKNET Callback: Untagged VLAN Stripper\n"); + seq_printf(m, " %lu stripped packets\n", strip_stats.stripped); + seq_printf(m, " %lu packets checked\n", strip_stats.checked); + seq_printf(m, " %lu packets skipped\n", strip_stats.skipped); + return 0; +} + +static int +ngknetcb_open(struct inode *inode, struct file *filp) +{ + return single_open(filp, ngknetcb_show, NULL); +} + +static int +ngknetcb_release(struct inode *inode, struct file *filp) +{ + return 0; +} + +static ssize_t +ngknetcb_write(struct file *file, const char *buf, + size_t count, loff_t *loff) +{ + memset(&strip_stats, 0, sizeof(strip_stats)); + printk("Cleared NGKNET callback stats\n"); + return count; +} + +static long +ngknetcb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + return 0; +} + +static int +ngknetcb_mmap(struct file *filp, struct vm_area_struct *vma) +{ + return 0; +} + +static struct file_operations ngknetcb_fops = { + .owner = THIS_MODULE, + .open = ngknetcb_open, + .read = seq_read, + .write = ngknetcb_write, + .llseek = seq_lseek, + .release = ngknetcb_release, + .unlocked_ioctl = ngknetcb_ioctl, + .compat_ioctl = ngknetcb_ioctl, + .mmap = ngknetcb_mmap, +}; + +static int __init +ngknetcb_init_module(void) +{ + int rv; + struct proc_dir_entry *entry = NULL; + + rv = register_chrdev(NGKNETCB_MODULE_MAJOR, NGKNETCB_MODULE_NAME, &ngknetcb_fops); + if (rv < 0) { + printk(KERN_WARNING "%s: can't get major %d\n", + NGKNETCB_MODULE_NAME, NGKNETCB_MODULE_MAJOR); + return rv; + } + + PROC_CREATE(entry, NGKNETCB_MODULE_NAME, 0666, NULL, &ngknetcb_fops); + if (entry == NULL) { + printk(KERN_ERR "%s: proc_mkdir failed\n", + NGKNETCB_MODULE_NAME); + } + + ngknet_rx_cb_register(ngknet_rx_cb); + ngknet_tx_cb_register(ngknet_tx_cb); + +#ifdef PSAMPLE_SUPPORT + psample_init(); +#endif + + ngknet_netif_create_cb_register(ngknet_netif_create_cb); + ngknet_netif_destroy_cb_register(ngknet_netif_destroy_cb); + return 0; +} + +static void __exit +ngknetcb_exit_module(void) +{ + ngknet_netif_create_cb_unregister(ngknet_netif_create_cb); + ngknet_netif_destroy_cb_unregister(ngknet_netif_destroy_cb); + +#ifdef PSAMPLE_SUPPORT + psample_cleanup(); +#endif + + ngknet_rx_cb_unregister(ngknet_rx_cb); + ngknet_tx_cb_unregister(ngknet_tx_cb); + + remove_proc_entry(NGKNETCB_MODULE_NAME, NULL); + + unregister_chrdev(NGKNETCB_MODULE_MAJOR, NGKNETCB_MODULE_NAME); +} + +module_init(ngknetcb_init_module); +module_exit(ngknetcb_exit_module); diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.c b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.c new file mode 100644 index 000000000000..be34430218d3 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.c @@ -0,0 +1,995 @@ +/* + * Copyright 2017-2019 Broadcom + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation (the "GPL"). + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. + */ +/* + * $Id: psample_cb.c $ + * $Copyright: (c) 2019 Broadcom Corp. + * All Rights Reserved.$ + */ + +/* + * Driver for call-back functions for Linux KNET driver. + * + * This code is used to integrate packet sampling KNET callback to + * the psample infra for sending sampled pkts to userspace sflow + * applications such as Host Sflow (https://github.com/sflow/host-sflow) + * using genetlink interfaces. + * + * The module can be built from the standard Linux user mode target + * directories using the following command (assuming bash), e.g. + * + * cd $SDK/systems/linux/user/ + * make BUILD_KNET_CB=1 + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "psample-cb.h" + +#define PSAMPLE_CB_DBG +#ifdef PSAMPLE_CB_DBG +extern int debug; +#define PSAMPLE_CB_DBG_LVL_VERB (0x1) +#define PSAMPLE_CB_DBG_LVL_PMD (0x2) +#define PSAMPLE_CB_DBG_PRINT(...) if (debug & PSAMPLE_CB_DBG_LVL_VERB) { printk(__VA_ARGS__); } +#define PSAMPLE_CB_PMD_PRINT(...) if (debug & PSAMPLE_CB_DBG_LVL_PMD) { printk(__VA_ARGS__); } +#else +#define PSAMPLE_CB_DBG_PRINT(...) +#define PSAMPLE_CB_PMD_PRINT(...) +#endif + +#define FCS_SZ 4 +#define PSAMPLE_NLA_PADDING 4 +#define PSAMPLE_PKT_HANDLED (1) + +#define PSAMPLE_RATE_DFLT 1 +#define PSAMPLE_SIZE_DFLT 128 +static int psample_size = PSAMPLE_SIZE_DFLT; +MODULE_PARAM(psample_size, int, 0); +MODULE_PARM_DESC(psample_size, +"psample pkt size (default 128 bytes)"); + +#define PSAMPLE_QLEN_DFLT 1024 +static int psample_qlen = PSAMPLE_QLEN_DFLT; +MODULE_PARAM(psample_qlen, int, 0); +MODULE_PARM_DESC(psample_qlen, +"psample queue length (default 1024 buffers)"); + +/* driver proc entry root */ +static struct proc_dir_entry *psample_proc_root = NULL; +static struct proc_dir_entry *knet_cb_proc_root = NULL; + +/* psample general info */ +typedef struct { + struct list_head netif_list; + int netif_count; + struct net *netns; + spinlock_t lock; + int dcb_type; +} psample_info_t; +static psample_info_t g_psample_info = {0}; + +/* Maintain sampled pkt statistics */ +typedef struct psample_stats_s { + unsigned long pkts_f_psample_cb; + unsigned long pkts_f_psample_mod; + unsigned long pkts_f_handled; + unsigned long pkts_f_pass_through; + unsigned long pkts_f_dst_mc; + unsigned long pkts_c_qlen_cur; + unsigned long pkts_c_qlen_hi; + unsigned long pkts_d_qlen_max; + unsigned long pkts_d_no_mem; + unsigned long pkts_d_no_group; + unsigned long pkts_d_sampling_disabled; + unsigned long pkts_d_not_ready; + unsigned long pkts_d_metadata; + unsigned long pkts_d_skb; + unsigned long pkts_d_skb_cbd; + unsigned long pkts_d_meta_srcport; + unsigned long pkts_d_meta_dstport; + unsigned long pkts_d_invalid_size; +} psample_stats_t; +static psample_stats_t g_psample_stats = {0}; + +typedef struct psample_meta_s { + int trunc_size; + int src_ifindex; + int dst_ifindex; + int sample_rate; +} psample_meta_t; + +typedef struct psample_pkt_s { + struct list_head list; + struct psample_group *group; + psample_meta_t meta; + struct sk_buff *skb; +} psample_pkt_t; + +typedef struct psample_work_s { + struct list_head pkt_list; + struct work_struct wq; + spinlock_t lock; +} psample_work_t; +static psample_work_t g_psample_work = {0}; + +static psample_netif_t* +psample_netif_lookup_by_ifindex(int ifindex) +{ + struct list_head *list; + psample_netif_t *psample_netif = NULL; + unsigned long flags; + + /* look for port from list of available net_devices */ + spin_lock_irqsave(&g_psample_info.lock, flags); + list_for_each(list, &g_psample_info.netif_list) { + psample_netif = (psample_netif_t*)list; + if (psample_netif->dev->ifindex == ifindex) { + spin_unlock_irqrestore(&g_psample_info.lock, flags); + return psample_netif; + } + } + spin_unlock_irqrestore(&g_psample_info.lock, flags); + return (NULL); +} + +static psample_netif_t* +psample_netif_lookup_by_port(int port) +{ + struct list_head *list; + psample_netif_t *psample_netif = NULL; + unsigned long flags; + + /* look for port from list of available net_devices */ + spin_lock_irqsave(&g_psample_info.lock, flags); + list_for_each(list, &g_psample_info.netif_list) { + psample_netif = (psample_netif_t*)list; + if (psample_netif->port == port) { + spin_unlock_irqrestore(&g_psample_info.lock, flags); + return psample_netif; + } + } + spin_unlock_irqrestore(&g_psample_info.lock, flags); + return (NULL); +} + +static int +psample_meta_sample_reason(uint8_t *pkt, void *pkt_meta) +{ + uint32_t *metadata = (uint32_t*)pkt_meta; + uint32_t reason = 0; + uint32_t reason_hi = 0; + uint32_t sample_rx_reason_mask = 0; + + if (metadata) { + /* Sample Pkt reason code (bcmRxReasonSampleSource) */ + switch(g_psample_info.dcb_type) { + case 36: /* TD3 */ + case 38: /* TH3 */ + reason_hi = *(metadata + 4); + reason = *(metadata + 5); + sample_rx_reason_mask = (1 << 3); + break; + case 32: /* TH1/TH2 */ + case 26: /* TD2 */ + case 23: /* HX4 */ + reason_hi = *(metadata + 2); + reason = *(metadata + 3); + sample_rx_reason_mask = (1 << 5); + break; + default: + break; + } + } + PSAMPLE_CB_DBG_PRINT("%s: DCB%d sample_rx_reason_mask: 0x%08x, reason: 0x%08x, reason_hi: 0x%08x\n", + __func__, g_psample_info.dcb_type, sample_rx_reason_mask, reason, reason_hi); + + /* Check if only sample reason code is set. + * If only sample reason code, then consume pkt. + * If other reason codes exist, then pkt should be + * passed through to Linux network stack. + */ + if ((reason & ~sample_rx_reason_mask) || reason_hi) { + return 0; /* multiple reasons set, pass through */ + } + + /* only sample rx reason set, consume pkt */ + return (PSAMPLE_PKT_HANDLED); +} + +static int +psample_meta_get(struct sk_buff *skb, psample_meta_t *sflow_meta) +{ + int src_ifindex = 0; + int sample_rate = 1; + int sample_size = PSAMPLE_SIZE_DFLT; + psample_netif_t *psample_netif = NULL; + const struct ngknet_callback_desc *cbd = NGKNET_SKB_CB(skb); + const struct ngknet_private *netif = cbd->priv; + memset(sflow_meta, 0, sizeof(psample_meta_t)); + + /* find src port */ + if ((psample_netif = psample_netif_lookup_by_ifindex(netif->net_dev->ifindex))) { + src_ifindex = psample_netif->dev->ifindex; + sample_rate = psample_netif->sample_rate; + sample_size = psample_netif->sample_size; + } else { + g_psample_stats.pkts_d_meta_srcport++; + PSAMPLE_CB_DBG_PRINT("%s: could not find psample netif for src dev %s (ifidx %d)\n", + __func__, netif->net_dev->name, netif->net_dev->ifindex); + } + + sflow_meta->src_ifindex = src_ifindex; + sflow_meta->trunc_size = sample_size; + sflow_meta->sample_rate = sample_rate; + return (0); +} + +static void +psample_task(struct work_struct *work) +{ + psample_work_t *psample_work = container_of(work, psample_work_t, wq); + unsigned long flags; + struct list_head *list_ptr, *list_next; + psample_pkt_t *pkt; + + spin_lock_irqsave(&psample_work->lock, flags); + list_for_each_safe(list_ptr, list_next, &psample_work->pkt_list) { + /* dequeue pkt from list */ + pkt = list_entry(list_ptr, psample_pkt_t, list); + list_del(list_ptr); + g_psample_stats.pkts_c_qlen_cur--; + spin_unlock_irqrestore(&psample_work->lock, flags); + + /* send to psample */ + if (pkt) { + PSAMPLE_CB_DBG_PRINT("%s: group 0x%x, trunc_size %d, src_ifdx 0x%x, dst_ifdx 0x%x, sample_rate %d\n", + __func__, pkt->group->group_num, + pkt->meta.trunc_size, pkt->meta.src_ifindex, + pkt->meta.dst_ifindex, pkt->meta.sample_rate); + + psample_sample_packet(pkt->group, + pkt->skb, + pkt->meta.trunc_size, + pkt->meta.src_ifindex, + pkt->meta.dst_ifindex, + pkt->meta.sample_rate); + g_psample_stats.pkts_f_psample_mod++; + + dev_kfree_skb_any(pkt->skb); + kfree(pkt); + } + spin_lock_irqsave(&psample_work->lock, flags); + } + spin_unlock_irqrestore(&psample_work->lock, flags); +} + +struct sk_buff* +psample_rx_cb(struct sk_buff *skb) +{ + struct psample_group *group; + psample_meta_t meta; + int rv = 0, size; + const struct ngknet_callback_desc *cbd = NULL; + const struct ngknet_private *netif = NULL; + const struct ngknet_filter_s *filt = NULL; + const struct ngknet_filter_s *filt_src = NULL; + + if (!skb) { + printk("%s: skb is NULL\n", __func__); + g_psample_stats.pkts_d_skb++; + return (NULL); + } + cbd = NGKNET_SKB_CB(skb); + netif = cbd->priv; + filt_src = cbd->filt; + filt = cbd->filt_cb; + + if (!cbd || !netif || !filt_src) { + printk("%s: cbd(0x%p) or priv(0x%p) or filter src(0x%p) is NULL\n", + __func__, cbd, netif, filt_src); + g_psample_stats.pkts_d_skb_cbd++; + return (skb); + } + + /* Enable PMD output in dmesg: "echo "debug=0x2" > /proc/bcm/knet-cb/psample/debug" + * Use bshell cmd "pmddecode rxpmd ..." to decode pkt metadata + */ + if (debug & PSAMPLE_CB_DBG_LVL_PMD) { + char str[128]; + int i, len = cbd->pmd_len > 128? 128 : cbd->pmd_len; + PSAMPLE_CB_PMD_PRINT("PMD (%d bytes): %s\n", + cbd->pmd_len, skb->dev->name); + for (i=0; ipmd+i))); + if ((i & 0x1c) == 0x1c) { + sprintf(&str[strlen(str)], "\n"); + printk(str); + continue; + } + } + if ((i & 0x1f) != 0) { + sprintf(&str[strlen(str)], "\n"); + PSAMPLE_CB_PMD_PRINT(str); + } + } + + /* check if this packet is sampled packet (from sample filter) */ + if (!filt || + (NGKNET_FILTER_DEST_T_CB != filt->dest_type) || + (strncmp(filt->desc, PSAMPLE_CB_NAME, NGKNET_FILTER_DESC_MAX) != 0)) { + return (skb); + } + + PSAMPLE_CB_DBG_PRINT("%s: src dev %s, pkt size %d, filt->dest_id %d\n", + __func__, skb->dev->name, cbd->pkt_len, filt->dest_id); + g_psample_stats.pkts_f_psample_cb++; + + /* get psample group info. psample genetlink group ID passed in filt->dest_id */ + group = psample_group_get(g_psample_info.netns, filt->dest_id); + if (!group) { + printk("%s: Could not find psample genetlink group %d\n", __func__, filt->dest_id); + g_psample_stats.pkts_d_no_group++; + goto PSAMPLE_FILTER_CB_PKT_HANDLED; + } + + /* get psample metadata */ + rv = psample_meta_get(skb, &meta); + if (rv < 0) { + printk("%s: Could not parse pkt metadata\n", __func__); + g_psample_stats.pkts_d_metadata++; + goto PSAMPLE_FILTER_CB_PKT_HANDLED; + } + + /* Adjust original pkt size to remove 4B FCS */ + size = cbd->pkt_len; + if (size < FCS_SZ) { + g_psample_stats.pkts_d_invalid_size++; + goto PSAMPLE_FILTER_CB_PKT_HANDLED; + } else { + size -= FCS_SZ; + } + + /* Account for padding in libnl used by psample */ + if (meta.trunc_size >= size) { + meta.trunc_size = size - PSAMPLE_NLA_PADDING; + } + + PSAMPLE_CB_DBG_PRINT("%s: group 0x%x, trunc_size %d, src_ifdx 0x%x, dst_ifdx 0x%x, sample_rate %d\n", + __func__, group->group_num, meta.trunc_size, meta.src_ifindex, meta.dst_ifindex, meta.sample_rate); + + /* drop if configured sample rate is 0 */ + if (meta.sample_rate > 0) { + unsigned long flags; + psample_pkt_t *psample_pkt; + struct sk_buff *skb_psample; + + if (g_psample_stats.pkts_c_qlen_cur >= psample_qlen) { + printk("%s: tail drop due to max qlen %d reached\n", __func__, psample_qlen); + g_psample_stats.pkts_d_qlen_max++; + goto PSAMPLE_FILTER_CB_PKT_HANDLED; + } + + if ((psample_pkt = kmalloc(sizeof(psample_pkt_t), GFP_ATOMIC)) == NULL) { + printk("%s: failed to alloc psample mem for pkt\n", __func__); + g_psample_stats.pkts_d_no_mem++; + goto PSAMPLE_FILTER_CB_PKT_HANDLED; + } + memcpy(&psample_pkt->meta, &meta, sizeof(psample_meta_t)); + psample_pkt->group = group; + + if ((skb_psample = dev_alloc_skb(meta.trunc_size)) == NULL) { + printk("%s: failed to alloc psample mem for pkt skb\n", __func__); + g_psample_stats.pkts_d_no_mem++; + goto PSAMPLE_FILTER_CB_PKT_HANDLED; + } + + /* setup skb to point to pkt */ + memcpy(skb_psample->data, skb->data, meta.trunc_size); + skb_put(skb_psample, meta.trunc_size); + skb_psample->len = meta.trunc_size; + psample_pkt->skb = skb_psample; + + spin_lock_irqsave(&g_psample_work.lock, flags); + list_add_tail(&psample_pkt->list, &g_psample_work.pkt_list); + + g_psample_stats.pkts_c_qlen_cur++; + if (g_psample_stats.pkts_c_qlen_cur > g_psample_stats.pkts_c_qlen_hi) { + g_psample_stats.pkts_c_qlen_hi = g_psample_stats.pkts_c_qlen_cur; + } + + schedule_work(&g_psample_work.wq); + spin_unlock_irqrestore(&g_psample_work.lock, flags); + } else { + g_psample_stats.pkts_d_sampling_disabled++; + } + +PSAMPLE_FILTER_CB_PKT_HANDLED: + /* if sample reason only, consume pkt. else pass through */ + rv = psample_meta_sample_reason(skb->data, cbd->pmd); + if (rv) { + g_psample_stats.pkts_f_handled++; + return NULL; + } + g_psample_stats.pkts_f_pass_through++; + return skb; +} + +int +psample_netif_create_cb(struct net_device *dev) +{ + int found; + struct list_head *list; + psample_netif_t *psample_netif, *lpsample_netif; + unsigned long flags; + struct ngknet_private *netif = NULL; + + if (!dev) { + printk("%s: net_device is NULL\n", __func__); + return (-1); + } + netif = netdev_priv(dev); + + if ((psample_netif = kmalloc(sizeof(psample_netif_t), GFP_ATOMIC)) == NULL) { + printk("%s: failed to alloc psample mem for netif '%s'\n", + __func__, dev->name); + return (-1); + } + + spin_lock_irqsave(&g_psample_info.lock, flags); + + psample_netif->dev = dev; + psample_netif->id = netif->id; + /* FIXME: port is not saved in ngknet_private, need to get from metadata?? */ + //psample_netif->port = netif->port; + psample_netif->vlan = netif->vlan; + psample_netif->sample_rate = PSAMPLE_RATE_DFLT; + psample_netif->sample_size = PSAMPLE_SIZE_DFLT; + + /* insert netif sorted by ID similar to bkn_knet_netif_create() */ + found = 0; + list_for_each(list, &g_psample_info.netif_list) { + lpsample_netif = (psample_netif_t*)list; + if (netif->id < lpsample_netif->id) { + found = 1; + g_psample_info.netif_count++; + break; + } + } + + if (found) { + /* Replace previously removed interface */ + list_add_tail(&psample_netif->list, &lpsample_netif->list); + } else { + /* No holes - add to end of list */ + list_add_tail(&psample_netif->list, &g_psample_info.netif_list); + } + + spin_unlock_irqrestore(&g_psample_info.lock, flags); + + PSAMPLE_CB_DBG_PRINT("%s: added psample netif '%s'\n", __func__, dev->name); + return (0); +} + +int +psample_netif_destroy_cb(struct net_device *dev) +{ + int found; + struct list_head *list; + psample_netif_t *psample_netif; + unsigned long flags; + struct ngknet_private *netif = NULL; + + if (!dev) { + printk("%s: net_device is NULL\n", __func__); + return (-1); + } + netif = netdev_priv(dev); + + spin_lock_irqsave(&g_psample_info.lock, flags); + + list_for_each(list, &g_psample_info.netif_list) { + psample_netif = (psample_netif_t*)list; + if (netif->id == psample_netif->id) { + found = 1; + list_del(&psample_netif->list); + PSAMPLE_CB_DBG_PRINT("%s: removing psample netif '%s'\n", __func__, dev->name); + kfree(psample_netif); + g_psample_info.netif_count--; + break; + } + } + + spin_unlock_irqrestore(&g_psample_info.lock, flags); + + if (!found) { + printk("%s: netif ID %d not found!\n", __func__, netif->id); + return (-1); + } + return (0); +} + +/* + * psample rate Proc Read Entry + */ +static int +psample_proc_rate_show(struct seq_file *m, void *v) +{ + struct list_head *list; + psample_netif_t *psample_netif; + unsigned long flags; + + spin_lock_irqsave(&g_psample_info.lock, flags); + + list_for_each(list, &g_psample_info.netif_list) { + psample_netif = (psample_netif_t*)list; + seq_printf(m, " %-14s %d\n", psample_netif->dev->name, psample_netif->sample_rate); + } + + spin_unlock_irqrestore(&g_psample_info.lock, flags); + + return 0; +} + +static int +psample_proc_rate_open(struct inode * inode, struct file * file) +{ + return single_open(file, psample_proc_rate_show, NULL); +} + +/* + * psample rate Proc Write Entry + * + * Syntax: + * = + * + * Where is a virtual network interface name. + * + * Examples: + * eth4=1000 + */ +static ssize_t +psample_proc_rate_write(struct file *file, const char *buf, + size_t count, loff_t *loff) +{ + int found; + struct list_head *list; + psample_netif_t *psample_netif; + char sample_str[40], *ptr, *newline; + unsigned long flags; + + + if (count > sizeof(sample_str)) { + count = sizeof(sample_str) - 1; + sample_str[count] = '\0'; + } + if (copy_from_user(sample_str, buf, count)) { + return -EFAULT; + } + sample_str[count] = 0; + newline = strchr(sample_str, '\n'); + if (newline) { + /* Chop off the trailing newline */ + *newline = '\0'; + } + + if ((ptr = strchr(sample_str, '=')) == NULL && + (ptr = strchr(sample_str, ':')) == NULL) { + printk("Error: Pkt sample rate syntax not recognized: '%s'\n", sample_str); + return count; + } + *ptr++ = 0; + + spin_lock_irqsave(&g_psample_info.lock, flags); + + found = 0; + list_for_each(list, &g_psample_info.netif_list) { + psample_netif = (psample_netif_t*)list; + if (strcmp(psample_netif->dev->name, sample_str) == 0) { + psample_netif->sample_rate = simple_strtol(ptr, NULL, 10); + // TODO MLI@BRCM - check valid sample rate + found = 1; + break; + } + } + + spin_unlock_irqrestore(&g_psample_info.lock, flags); + + if (!found) { + printk("Warning: Failed setting psample rate on unknown network interface: '%s'\n", sample_str); + } + return count; +} + +struct file_operations psample_proc_rate_file_ops = { + owner: THIS_MODULE, + open: psample_proc_rate_open, + read: seq_read, + llseek: seq_lseek, + write: psample_proc_rate_write, + release: single_release, +}; + +/* + * psample size Proc Read Entry + */ +static int +psample_proc_size_show(struct seq_file *m, void *v) +{ + struct list_head *list; + psample_netif_t *psample_netif; + unsigned long flags; + + spin_lock_irqsave(&g_psample_info.lock, flags); + + list_for_each(list, &g_psample_info.netif_list) { + psample_netif = (psample_netif_t*)list; + seq_printf(m, " %-14s %d\n", psample_netif->dev->name, psample_netif->sample_size); + } + + spin_unlock_irqrestore(&g_psample_info.lock, flags); + return 0; +} + +static int +psample_proc_size_open(struct inode * inode, struct file * file) +{ + return single_open(file, psample_proc_size_show, NULL); +} + +/* + * psample size Proc Write Entry + * + * Syntax: + * = + * + * Where is a virtual network interface name. + * + * Examples: + * eth4=128 + */ +static ssize_t +psample_proc_size_write(struct file *file, const char *buf, + size_t count, loff_t *loff) +{ + int found; + struct list_head *list; + psample_netif_t *psample_netif; + char sample_str[40], *ptr, *newline; + unsigned long flags; + + if (count > sizeof(sample_str)) { + count = sizeof(sample_str) - 1; + sample_str[count] = '\0'; + } + if (copy_from_user(sample_str, buf, count)) { + return -EFAULT; + } + sample_str[count] = 0; + newline = strchr(sample_str, '\n'); + if (newline) { + /* Chop off the trailing newline */ + *newline = '\0'; + } + + if ((ptr = strchr(sample_str, '=')) == NULL && + (ptr = strchr(sample_str, ':')) == NULL) { + printk("Error: Pkt sample size syntax not recognized: '%s'\n", sample_str); + return count; + } + *ptr++ = 0; + + spin_lock_irqsave(&g_psample_info.lock, flags); + + found = 0; + list_for_each(list, &g_psample_info.netif_list) { + psample_netif = (psample_netif_t*)list; + if (strcmp(psample_netif->dev->name, sample_str) == 0) { + psample_netif->sample_size = simple_strtol(ptr, NULL, 10); + // TODO MLI@BRCM - check valid sample size + found = 1; + break; + } + } + + spin_unlock_irqrestore(&g_psample_info.lock, flags); + + if (!found) { + printk("Warning: Failed setting psample size on unknown network interface: '%s'\n", sample_str); + } + return count; +} + +struct file_operations psample_proc_size_file_ops = { + owner: THIS_MODULE, + open: psample_proc_size_open, + read: seq_read, + llseek: seq_lseek, + write: psample_proc_size_write, + release: single_release, +}; + +/* + * psample map Proc Read Entry + */ +static int +psample_proc_map_show(struct seq_file *m, void *v) +{ + struct list_head *list; + psample_netif_t *psample_netif; + unsigned long flags; + + seq_printf(m, " Interface logical port ifindex\n"); + seq_printf(m, "------------- ------------ -------\n"); + spin_lock_irqsave(&g_psample_info.lock, flags); + + list_for_each(list, &g_psample_info.netif_list) { + psample_netif = (psample_netif_t*)list; + seq_printf(m, " %-14s %-14d %d\n", + psample_netif->dev->name, + psample_netif->port, + psample_netif->dev->ifindex); + } + + spin_unlock_irqrestore(&g_psample_info.lock, flags); + return 0; +} + +static int +psample_proc_map_open(struct inode * inode, struct file * file) +{ + return single_open(file, psample_proc_map_show, NULL); +} + +struct file_operations psample_proc_map_file_ops = { + owner: THIS_MODULE, + open: psample_proc_map_open, + read: seq_read, + llseek: seq_lseek, + write: NULL, + release: single_release, +}; + +/* + * psample debug Proc Read Entry + */ +static int +psample_proc_debug_show(struct seq_file *m, void *v) +{ + seq_printf(m, "BCM KNET %s Callback Config\n", PSAMPLE_CB_NAME); + seq_printf(m, " debug: 0x%x\n", debug); + seq_printf(m, " dcb_type: %d\n", g_psample_info.dcb_type); + seq_printf(m, " netif_count: %d\n", g_psample_info.netif_count); + seq_printf(m, " queue length: %d\n", psample_qlen); + + return 0; +} + +static int +psample_proc_debug_open(struct inode * inode, struct file * file) +{ + return single_open(file, psample_proc_debug_show, NULL); +} + +/* + * psample debug Proc Write Entry + * + * Syntax: + * debug= + * + * Where corresponds to the debug module parameter. + * + * Examples: + * debug=0x1 + */ +static ssize_t +psample_proc_debug_write(struct file *file, const char *buf, + size_t count, loff_t *loff) +{ + char debug_str[40]; + char *ptr; + + if (count > sizeof(debug_str)) { + count = sizeof(debug_str) - 1; + debug_str[count] = '\0'; + } + if (copy_from_user(debug_str, buf, count)) { + return -EFAULT; + } + + if ((ptr = strstr(debug_str, "debug=")) != NULL) { + ptr += 6; + debug = simple_strtol(ptr, NULL, 0); + } else { + printk("Warning: unknown configuration setting\n"); + } + + return count; +} + +struct file_operations psample_proc_debug_file_ops = { + owner: THIS_MODULE, + open: psample_proc_debug_open, + read: seq_read, + llseek: seq_lseek, + write: psample_proc_debug_write, + release: single_release, +}; + +static int +psample_proc_stats_show(struct seq_file *m, void *v) +{ + seq_printf(m, "BCM KNET %s Callback Stats\n", PSAMPLE_CB_NAME); + seq_printf(m, " DCB type %d\n", g_psample_info.dcb_type); + seq_printf(m, " pkts filter psample cb %10lu\n", g_psample_stats.pkts_f_psample_cb); + seq_printf(m, " pkts sent to psample module %10lu\n", g_psample_stats.pkts_f_psample_mod); + seq_printf(m, " pkts handled by psample %10lu\n", g_psample_stats.pkts_f_handled); + seq_printf(m, " pkts pass through %10lu\n", g_psample_stats.pkts_f_pass_through); + seq_printf(m, " pkts with mc destination %10lu\n", g_psample_stats.pkts_f_dst_mc); + seq_printf(m, " pkts current queue length %10lu\n", g_psample_stats.pkts_c_qlen_cur); + seq_printf(m, " pkts high queue length %10lu\n", g_psample_stats.pkts_c_qlen_hi); + seq_printf(m, " pkts drop max queue length %10lu\n", g_psample_stats.pkts_d_qlen_max); + seq_printf(m, " pkts drop no memory %10lu\n", g_psample_stats.pkts_d_no_mem); + seq_printf(m, " pkts drop no psample group %10lu\n", g_psample_stats.pkts_d_no_group); + seq_printf(m, " pkts drop sampling disabled %10lu\n", g_psample_stats.pkts_d_sampling_disabled); + seq_printf(m, " pkts drop psample not ready %10lu\n", g_psample_stats.pkts_d_not_ready); + seq_printf(m, " pkts drop metadata parse error %10lu\n", g_psample_stats.pkts_d_metadata); + seq_printf(m, " pkts drop skb error %10lu\n", g_psample_stats.pkts_d_skb); + seq_printf(m, " pkts drop skb cbd error %10lu\n", g_psample_stats.pkts_d_skb_cbd); + seq_printf(m, " pkts with invalid src port %10lu\n", g_psample_stats.pkts_d_meta_srcport); + seq_printf(m, " pkts with invalid dst port %10lu\n", g_psample_stats.pkts_d_meta_dstport); + seq_printf(m, " pkts with invalid orig pkt sz %10lu\n", g_psample_stats.pkts_d_invalid_size); + return 0; +} + +static int +psample_proc_stats_open(struct inode * inode, struct file * file) +{ + return single_open(file, psample_proc_stats_show, NULL); +} + +/* + * psample stats Proc Write Entry + * + * Syntax: + * write any value to clear stats + */ +static ssize_t +psample_proc_stats_write(struct file *file, const char *buf, + size_t count, loff_t *loff) +{ + int qlen_cur = 0; + unsigned long flags; + + spin_lock_irqsave(&g_psample_work.lock, flags); + qlen_cur = g_psample_stats.pkts_c_qlen_cur; + memset(&g_psample_stats, 0, sizeof(psample_stats_t)); + g_psample_stats.pkts_c_qlen_cur = qlen_cur; + spin_unlock_irqrestore(&g_psample_work.lock, flags); + + return count; +} +struct file_operations psample_proc_stats_file_ops = { + owner: THIS_MODULE, + open: psample_proc_stats_open, + read: seq_read, + llseek: seq_lseek, + write: psample_proc_stats_write, + release: single_release, +}; + +int psample_cleanup(void) +{ + cancel_work_sync(&g_psample_work.wq); + remove_proc_entry("stats", psample_proc_root); + remove_proc_entry("rate", psample_proc_root); + remove_proc_entry("size", psample_proc_root); + remove_proc_entry("debug", psample_proc_root); + remove_proc_entry("map" , psample_proc_root); + remove_proc_entry("psample", knet_cb_proc_root); + remove_proc_entry("bcm/knet-cb", NULL); + remove_proc_entry("bcm", NULL); + return 0; +} + +int psample_init(void) +{ + #define PROCFS_MAX_PATH 1024 + char psample_procfs_path[PROCFS_MAX_PATH]; + struct proc_dir_entry *entry; + + /* initialize proc files (for ngknet) */ + proc_mkdir("bcm", NULL); + + /* create procfs for psample */ + snprintf(psample_procfs_path, PROCFS_MAX_PATH, "bcm/knet-cb"); + knet_cb_proc_root = proc_mkdir(psample_procfs_path, NULL); + snprintf(psample_procfs_path, PROCFS_MAX_PATH, "%s/%s", psample_procfs_path, PSAMPLE_CB_NAME); + psample_proc_root = proc_mkdir(psample_procfs_path, NULL); + + /* create procfs for psample stats */ + PROC_CREATE(entry, "stats", 0666, psample_proc_root, &psample_proc_stats_file_ops); + if (entry == NULL) { + printk("%s: Unable to create procfs entry '/procfs/%s/stats'\n", __func__, psample_procfs_path); + return -1; + } + + /* create procfs for setting sample rates */ + PROC_CREATE(entry, "rate", 0666, psample_proc_root, &psample_proc_rate_file_ops); + if (entry == NULL) { + printk("%s: Unable to create procfs entry '/procfs/%s/rate'\n", __func__, psample_procfs_path); + return -1; + } + + /* create procfs for setting sample size */ + PROC_CREATE(entry, "size", 0666, psample_proc_root, &psample_proc_size_file_ops); + if (entry == NULL) { + printk("%s: Unable to create procfs entry '/procfs/%s/size'\n", __func__, psample_procfs_path); + return -1; + } + + /* create procfs for getting netdev mapping */ + PROC_CREATE(entry, "map", 0666, psample_proc_root, &psample_proc_map_file_ops); + if (entry == NULL) { + printk("%s: Unable to create procfs entry '/procfs/%s/map'\n", __func__, psample_procfs_path); + return -1; + } + + /* create procfs for debug log */ + PROC_CREATE(entry, "debug", 0666, psample_proc_root, &psample_proc_debug_file_ops); + if (entry == NULL) { + printk("%s: Unable to create procfs entry '/procfs/%s/debug'\n", __func__, psample_procfs_path); + return -1; + } + + /* clear data structs */ + memset(&g_psample_stats, 0, sizeof(psample_stats_t)); + memset(&g_psample_info, 0, sizeof(psample_info_t)); + memset(&g_psample_work, 0, sizeof(psample_work_t)); + + /* FIXME: How to get DCB type from NGKNET? */ + //g_psample_info.dcb_type + + /* setup psample_info struct */ + INIT_LIST_HEAD(&g_psample_info.netif_list); + spin_lock_init(&g_psample_info.lock); + + /* setup psample work queue */ + spin_lock_init(&g_psample_work.lock); + INIT_LIST_HEAD(&g_psample_work.pkt_list); + INIT_WORK(&g_psample_work.wq, psample_task); + + /* get net namespace */ + g_psample_info.netns = get_net_ns_by_pid(current->pid); + if (!g_psample_info.netns) { + printk("%s: Could not get network namespace for pid %d\n", __func__, current->pid); + return (-1); + } + PSAMPLE_CB_DBG_PRINT("%s: current->pid %d, netns 0x%p, sample_size %d\n", __func__, + current->pid, g_psample_info.netns, psample_size); + + + return 0; +} diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.h b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.h new file mode 100644 index 000000000000..2e3342ead5c3 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.h @@ -0,0 +1,57 @@ +/* + * Copyright 2017 Broadcom + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation (the "GPL"). + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. + */ +/* + * $Id: psample_cb.h $ + * $Copyright: (c) 2019 Broadcom Corp. + * All Rights Reserved.$ + */ +#ifndef __PSAMPLE_CB_H__ +#define __PSAMPLE_CB_H__ + +#include +#include + +//#define PSAMPLE_SUPPORT 1 // TODO: MLI@BRCM - Add this as part of conditional in Makefile +#define PSAMPLE_CB_NAME "psample" + +extern int +psample_init(void); + +extern int +psample_cleanup(void); + +extern struct sk_buff* +psample_rx_cb(struct sk_buff *skb); + +/* psample data per interface */ +typedef struct { + struct list_head list; + struct net_device *dev; + uint16_t id; + uint8_t port; + uint16_t vlan; + uint16_t qnum; + uint32_t sample_rate; + uint32_t sample_size; +} psample_netif_t; + +extern int +psample_netif_create_cb(struct net_device *dev); + +extern int +psample_netif_destroy_cb(struct net_device *dev); + +#endif /* __PSAMPLE_CB_H__ */ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/psample/Kbuild b/platform/broadcom/saibcm-modules/sdklt/linux/psample/Kbuild new file mode 100644 index 000000000000..0049e399076b --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/psample/Kbuild @@ -0,0 +1,18 @@ +# -*- Kbuild -*- +# +# Linux psample module. +# +# $Copyright: (c) 2020 Broadcom. +# Broadcom Proprietary and Confidential. All rights reserved.$ +# + +obj-m := linux_psample.o + +ccflags-y := $(LKM_CFLAGS) \ + -I$(SDK)/shr/include \ + -I$(SDK)/bcmdrd/include \ + -I$(SDK)/linux/include \ + -I$(SDK)/linux/knet/include \ + -I$(SDK)/linux/knet + +linux_psample-y := psample.o diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/psample/Makefile b/platform/broadcom/saibcm-modules/sdklt/linux/psample/Makefile new file mode 100644 index 000000000000..b37b8ebb1c29 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/psample/Makefile @@ -0,0 +1,21 @@ +# -*- Makefile -*- +# +# Linux psample module. +# +# $Copyright: (c) 2020 Broadcom. +# Broadcom Proprietary and Confidential. All rights reserved.$ +# + +include Kbuild + +ifeq ($(KERNELRELEASE),) + +MOD_NAME = linux_psample + +include $(SDK)/make/lkm.mk + +endif + +.PHONY: distclean + +distclean: diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/psample/psample.c b/platform/broadcom/saibcm-modules/sdklt/linux/psample/psample.c new file mode 100644 index 000000000000..f0c9beab5784 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/psample/psample.c @@ -0,0 +1,302 @@ +/* + * net/psample/psample.c - Netlink channel for packet sampling + * Copyright (c) 2017 Yotam Gigi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PSAMPLE_MAX_PACKET_SIZE 0xffff + +static LIST_HEAD(psample_groups_list); +static DEFINE_SPINLOCK(psample_groups_lock); + +/* multicast groups */ +enum psample_nl_multicast_groups { + PSAMPLE_NL_MCGRP_CONFIG, + PSAMPLE_NL_MCGRP_SAMPLE, +}; + +static const struct genl_multicast_group psample_nl_mcgrps[] = { + [PSAMPLE_NL_MCGRP_CONFIG] = { .name = PSAMPLE_NL_MCGRP_CONFIG_NAME }, + [PSAMPLE_NL_MCGRP_SAMPLE] = { .name = PSAMPLE_NL_MCGRP_SAMPLE_NAME }, +}; + +static struct genl_family psample_nl_family; + +static int psample_group_nl_fill(struct sk_buff *msg, + struct psample_group *group, + enum psample_command cmd, u32 portid, u32 seq, + int flags) +{ + void *hdr; + int ret; + + hdr = genlmsg_put(msg, portid, seq, &psample_nl_family, flags, cmd); + if (!hdr) + return -EMSGSIZE; + + ret = nla_put_u32(msg, PSAMPLE_ATTR_SAMPLE_GROUP, group->group_num); + if (ret < 0) + goto error; + + ret = nla_put_u32(msg, PSAMPLE_ATTR_GROUP_REFCOUNT, group->refcount); + if (ret < 0) + goto error; + + ret = nla_put_u32(msg, PSAMPLE_ATTR_GROUP_SEQ, group->seq); + if (ret < 0) + goto error; + + genlmsg_end(msg, hdr); + return 0; + +error: + genlmsg_cancel(msg, hdr); + return -EMSGSIZE; +} + +static int psample_nl_cmd_get_group_dumpit(struct sk_buff *msg, + struct netlink_callback *cb) +{ + struct psample_group *group; + int start = cb->args[0]; + int idx = 0; + int err; + + spin_lock(&psample_groups_lock); + list_for_each_entry(group, &psample_groups_list, list) { + if (!net_eq(group->net, sock_net(msg->sk))) + continue; + if (idx < start) { + idx++; + continue; + } + err = psample_group_nl_fill(msg, group, PSAMPLE_CMD_NEW_GROUP, + NETLINK_CB(cb->skb).portid, + cb->nlh->nlmsg_seq, NLM_F_MULTI); + if (err) + break; + idx++; + } + + spin_unlock(&psample_groups_lock); + cb->args[0] = idx; + return msg->len; +} + +static const struct genl_ops psample_nl_ops[] = { + { + .cmd = PSAMPLE_CMD_GET_GROUP, + .dumpit = psample_nl_cmd_get_group_dumpit, + /* can be retrieved by unprivileged users */ + } +}; + +static struct genl_family psample_nl_family = { + .name = PSAMPLE_GENL_NAME, + .version = PSAMPLE_GENL_VERSION, + .maxattr = PSAMPLE_ATTR_MAX, + .netnsok = true, + .module = THIS_MODULE, + .mcgrps = psample_nl_mcgrps, + .ops = psample_nl_ops, + .n_ops = ARRAY_SIZE(psample_nl_ops), + .n_mcgrps = ARRAY_SIZE(psample_nl_mcgrps), +}; + +static void psample_group_notify(struct psample_group *group, + enum psample_command cmd) +{ + struct sk_buff *msg; + int err; + + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC); + if (!msg) + return; + + err = psample_group_nl_fill(msg, group, cmd, 0, 0, NLM_F_MULTI); + if (!err) + genlmsg_multicast_netns(&psample_nl_family, group->net, msg, 0, + PSAMPLE_NL_MCGRP_CONFIG, GFP_ATOMIC); + else + nlmsg_free(msg); +} + +static struct psample_group *psample_group_create(struct net *net, + u32 group_num) +{ + struct psample_group *group; + + group = kzalloc(sizeof(*group), GFP_ATOMIC); + if (!group) + return NULL; + + group->net = net; + group->group_num = group_num; + list_add_tail(&group->list, &psample_groups_list); + + psample_group_notify(group, PSAMPLE_CMD_NEW_GROUP); + return group; +} + +static void psample_group_destroy(struct psample_group *group) +{ + psample_group_notify(group, PSAMPLE_CMD_DEL_GROUP); + list_del(&group->list); + kfree(group); +} + +static struct psample_group * +psample_group_lookup(struct net *net, u32 group_num) +{ + struct psample_group *group; + + list_for_each_entry(group, &psample_groups_list, list) + if ((group->group_num == group_num) && (group->net == net)) + return group; + return NULL; +} + +struct psample_group *psample_group_get(struct net *net, u32 group_num) +{ + struct psample_group *group; + + spin_lock(&psample_groups_lock); + + group = psample_group_lookup(net, group_num); + if (!group) { + group = psample_group_create(net, group_num); + if (!group) + goto out; + } + group->refcount++; + +out: + spin_unlock(&psample_groups_lock); + return group; +} +EXPORT_SYMBOL_GPL(psample_group_get); + +void psample_group_put(struct psample_group *group) +{ + spin_lock(&psample_groups_lock); + + if (--group->refcount == 0) + psample_group_destroy(group); + + spin_unlock(&psample_groups_lock); +} +EXPORT_SYMBOL_GPL(psample_group_put); + +void psample_sample_packet(struct psample_group *group, struct sk_buff *skb, + u32 trunc_size, int in_ifindex, int out_ifindex, + u32 sample_rate) +{ + struct sk_buff *nl_skb; + int data_len; + int meta_len; + void *data; + int ret; + + meta_len = (in_ifindex ? nla_total_size(sizeof(u16)) : 0) + + (out_ifindex ? nla_total_size(sizeof(u16)) : 0) + + nla_total_size(sizeof(u32)) + /* sample_rate */ + nla_total_size(sizeof(u32)) + /* orig_size */ + nla_total_size(sizeof(u32)) + /* group_num */ + nla_total_size(sizeof(u32)); /* seq */ + + data_len = min(skb->len, trunc_size); + if (meta_len + nla_total_size(data_len) > PSAMPLE_MAX_PACKET_SIZE) + data_len = PSAMPLE_MAX_PACKET_SIZE - meta_len - NLA_HDRLEN + - NLA_ALIGNTO; + + nl_skb = genlmsg_new(meta_len + nla_total_size(data_len), GFP_ATOMIC); + if (unlikely(!nl_skb)) + return; + + data = genlmsg_put(nl_skb, 0, 0, &psample_nl_family, 0, + PSAMPLE_CMD_SAMPLE); + if (unlikely(!data)) + goto error; + + if (in_ifindex) { + ret = nla_put_u16(nl_skb, PSAMPLE_ATTR_IIFINDEX, in_ifindex); + if (unlikely(ret < 0)) + goto error; + } + + if (out_ifindex) { + ret = nla_put_u16(nl_skb, PSAMPLE_ATTR_OIFINDEX, out_ifindex); + if (unlikely(ret < 0)) + goto error; + } + + ret = nla_put_u32(nl_skb, PSAMPLE_ATTR_SAMPLE_RATE, sample_rate); + if (unlikely(ret < 0)) + goto error; + + ret = nla_put_u32(nl_skb, PSAMPLE_ATTR_ORIGSIZE, skb->len); + if (unlikely(ret < 0)) + goto error; + + ret = nla_put_u32(nl_skb, PSAMPLE_ATTR_SAMPLE_GROUP, group->group_num); + if (unlikely(ret < 0)) + goto error; + + ret = nla_put_u32(nl_skb, PSAMPLE_ATTR_GROUP_SEQ, group->seq++); + if (unlikely(ret < 0)) + goto error; + + if (data_len) { + int nla_len = nla_total_size(data_len); + struct nlattr *nla; + + nla = (struct nlattr *)skb_put(nl_skb, nla_len); + nla->nla_type = PSAMPLE_ATTR_DATA; + nla->nla_len = nla_attr_size(data_len); + + if (skb_copy_bits(skb, 0, nla_data(nla), data_len)) + goto error; + } + + genlmsg_end(nl_skb, data); + genlmsg_multicast_netns(&psample_nl_family, group->net, nl_skb, 0, + PSAMPLE_NL_MCGRP_SAMPLE, GFP_ATOMIC); + + return; +error: + pr_err_ratelimited("Could not create psample log message\n"); + nlmsg_free(nl_skb); +} +EXPORT_SYMBOL_GPL(psample_sample_packet); + +static int __init psample_module_init(void) +{ + return genl_register_family(&psample_nl_family); +} + +static void __exit psample_module_exit(void) +{ + genl_unregister_family(&psample_nl_family); +} + +module_init(psample_module_init); +module_exit(psample_module_exit); + +MODULE_AUTHOR("Yotam Gigi "); +MODULE_DESCRIPTION("netlink channel for packet sampling"); +MODULE_LICENSE("GPL v2"); diff --git a/platform/broadcom/saibcm-modules/sdklt/make/lkm.mk b/platform/broadcom/saibcm-modules/sdklt/make/lkm.mk new file mode 100644 index 000000000000..c3d2a4d40b50 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/make/lkm.mk @@ -0,0 +1,76 @@ +# +# $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. +# The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# A copy of the GNU General Public License version 2 (GPLv2) can +# be found in the LICENSES folder.$ +# +# Shared makefile include for building Linux kernel modules. +# + +# KDIR must point to the Linux kernel sources +ifndef KDIR +nokdir:; @echo 'The $$KDIR variable is not set'; exit 1 +endif + +# Required for older kernels +export EXTRA_CFLAGS = $(ccflags-y) + +PWD := $(shell pwd) + +ifneq ($(LKM_BLDDIR),) +# +# If a build directory has been specified, then we symlink all sources +# to this directory and redirect the module build path. +# +# Note that the KBUILD_OUTPUT variable cannot be used to redirect the +# output as we want it. +# +MDIR = $(LKM_BLDDIR) +MSRCS = $(patsubst %.o,%.c,$($(MOD_NAME)-y)) +MSRCS += Makefile Kbuild +BSRCS = $(addprefix $(PWD)/,$(MSRCS)) +else +# +# Build in current directory by default. +# +MDIR = $(PWD) +endif + +all: + $(Q)echo Building kernel module $(MOD_NAME) +ifneq ($(LKM_BLDDIR),) +ifneq ($(LKM_BLDDIR),$(PWD)) + $(Q)mkdir -p $(MDIR) + (cd $(MDIR); \ + rm -rf *.c Makefile Kbuild; \ + for f in $(BSRCS); do \ + ln -s $$f; \ + done) +endif +endif + $(MAKE) -C $(KDIR) M=$(MDIR) + +clean:: + $(Q)echo Cleaning kernel module $(MOD_NAME) + $(MAKE) -C $(KDIR) M=$(MDIR) clean +ifneq ($(LKM_BLDDIR),) +ifneq ($(LKM_BLDDIR),$(PWD)) +# Remove all files except for Makefile (needed by 'make clean') + rm -f $(LKM_BLDDIR)/*[cdors] +endif +endif + +.PHONY: all clean + +# Standard documentation targets +-include $(SDK)/make/doc.mk diff --git a/platform/broadcom/saibcm-modules/sdklt/shr/include/shr/shr_error.h b/platform/broadcom/saibcm-modules/sdklt/shr/include/shr/shr_error.h new file mode 100644 index 000000000000..1924d600de53 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/shr/include/shr/shr_error.h @@ -0,0 +1,195 @@ +/*! \file shr_error.h + * + * Shared error codes. + * + */ +/* + * $Copyright: Copyright 2018-2020 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef SHR_ERROR_H +#define SHR_ERROR_H + +/*! + * \brief Standard SDK error codes. + * + * IMPORTANT: These error codes must match the corresponding text + * messages in shr_error.c. + */ +typedef enum { + + /*! + * The operation completed successfully. + */ + SHR_E_NONE = 0, + + /*! + * This usually indicates that software encountered an internal + * data inconsistency or an unanticipated hardware state. + */ + SHR_E_INTERNAL = -1, + + /*! + * An operation failed due to insufficient dynamically allocated + * memory. + */ + SHR_E_MEMORY = -2, + + /*! + * The first argument of many API routines is a unit number. This + * error occurs if that number refers to a non-existent unit. + */ + SHR_E_UNIT = -3, + + /*! + * A parameter to an API routine was invalid. A null pointer value + * may have been passed to the routine, or an integer parameter + * may be outside of its allowed range. + */ + SHR_E_PARAM = -4, + + /*! + * The operation encountered a pooled resource (e.g. a table or a + * list) with no valid elements. + */ + SHR_E_EMPTY = -5, + + /*! + * The operation encountered a pooled resource (e.g. a table or a + * list) with no room for new elements. + */ + SHR_E_FULL = -6, + + /*! + * The specified entry in a pooled resource (e.g. a table or a + * list) could not be found. + */ + SHR_E_NOT_FOUND = -7, + + /*! + * The specified entry of a pooled resource (e.g. a table or a + * list) already exists. + */ + SHR_E_EXISTS = -8, + + /*! + * The operation did not complete within the maximum allowed time frame. + */ + SHR_E_TIMEOUT = -9, + + /*! + * An operation was attempted before the previous operation had + * completed. + */ + SHR_E_BUSY = -10, + + /*! + * An operation could not be completed. This may be due to a + * hardware or configuration problem. + */ + SHR_E_FAIL = -11, + + /*! + * The operation could not be completed because a required feature + * was disabled. + */ + SHR_E_DISABLED = -12, + + /*! + * The specified identifier was not valid. Note that this error + * code will normally take precedence over \ref SHR_E_PARAM. + */ + SHR_E_BADID = -13, + + /*! + * The operation could not be completed due to lack of hardware + * resources. + */ + SHR_E_RESOURCE = -14, + + /*! + * The operation could not be completed due to incomplete or + * incorrect configuration. + */ + SHR_E_CONFIG = -15, + + /*! + * The hardware does not support the requested operation. + */ + SHR_E_UNAVAIL = -16, + + /*! + * An operation was attempted before initialization was complete. + */ + SHR_E_INIT = -17, + + /*! + * The specified port value was not valid. Note that this error + * code will normally take precedence over \ref SHR_E_PARAM. + */ + SHR_E_PORT = -18, + + /*! + * A low-level register or memory access failed. + */ + SHR_E_IO = -19, + + /*! + * Access method not permitted. Typically returned if attempting + * to write to a read-only object. + */ + SHR_E_ACCESS = -20, + + /*! + * No handler exists to perform the hardware access associated + * with a an operation on a software object. + */ + SHR_E_NO_HANDLER = -21, + + /*! + * The operation was only partially completed, and this could + * potentially leave the system in an unexpected state. + */ + SHR_E_PARTIAL = -22, + + /*! + * The operation failed because of a hash collision. + */ + SHR_E_COLL = -23, + + SHR_E_LIMIT = -24 /* Must come last */ + +} shr_error_t; + +/*! Check for successful return value. */ +#define SHR_SUCCESS(_expr) ((_expr) >= 0) + +/*! Check for error return value. */ +#define SHR_FAILURE(_expr) ((_expr) < 0) + +/*! + * \brief Get standard error message + * + * Returns a text message corresponding to the error code passed in. + * + * \param [in] rv Error code + * + * \return Pointer to error message + */ +extern const char * +shr_errmsg(int rv); + +#endif /* SHR_ERROR_H */ diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/include/linux-bde.h b/platform/broadcom/saibcm-modules/systems/bde/linux/include/linux-bde.h index bdf7a56dcabb..c4d31579bfdf 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/include/linux-bde.h +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/include/linux-bde.h @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /*********************************************************************** * @@ -58,7 +69,6 @@ #define __LINUX_BDE_H__ #include - #include @@ -104,12 +114,17 @@ /* Max devices */ /* 16 switch chips + 2 out-of-band Ethernet + 2 CPUs */ +#ifndef LINUX_BDE_MAX_SWITCH_DEVICES #define LINUX_BDE_MAX_SWITCH_DEVICES 16 +#endif #define LINUX_BDE_MAX_ETHER_DEVICES 2 #define LINUX_BDE_MAX_CPU_DEVICES 2 #define LINUX_BDE_MAX_DEVICES (LINUX_BDE_MAX_SWITCH_DEVICES + \ LINUX_BDE_MAX_ETHER_DEVICES + \ - LINUX_BDE_MAX_CPU_DEVICES) + LINUX_BDE_MAX_CPU_DEVICES) +#define LINUX_BDE_NOF_DEVICE_BITMAP_WORDS ((LINUX_BDE_MAX_DEVICES+31)/32) +#define LINUX_BDE_MAX_IPROC_UC_CORES 12 /* Maximum number of R5 cores per device */ +typedef uint32 linux_bde_device_bitmap_t[LINUX_BDE_NOF_DEVICE_BITMAP_WORDS]; /* * PCI devices will be initialized by the Linux Kernel, @@ -148,14 +163,24 @@ typedef struct linux_bde_bus_s { */ #define BDE_DEV_STATE_CHANGED (2) +/* + * BDE_DEV_INST_ID_INVALID : The invalid instance identifier. + */ +#define BDE_DEV_INST_ID_INVALID ((uint32)-1) + extern int linux_bde_create(linux_bde_bus_t* bus, ibde_t** bde); extern int linux_bde_destroy(ibde_t* bde); #ifdef BCM_INSTANCE_SUPPORT extern int linux_bde_instance_attach(unsigned int dev_mask,unsigned int dma_size); +extern int linux_bde_instance_config(linux_bde_device_bitmap_t dev_mask,unsigned int dma_size); #endif #ifdef __KERNEL__ +#ifdef INCLUDE_EDK +#define BDE_EDK_SUPPORT +#endif + /* * Backdoors provided by the kernel bde * @@ -171,6 +196,10 @@ extern int linux_bde_instance_attach(unsigned int dev_mask,unsigned int dma_size extern int lkbde_get_dma_info(phys_addr_t *cpu_pbase, phys_addr_t *dma_pbase, ssize_t *size); extern uint32 lkbde_get_dev_phys(int d); extern uint32 lkbde_get_dev_phys_hi(int d); +#ifdef BDE_EDK_SUPPORT +extern int lkbde_edk_get_dma_info(int dev_id, phys_addr_t* cpu_pbase, + phys_addr_t* dma_pbase, ssize_t* size); +#endif /* * Virtual device address needed by kernel space @@ -183,8 +212,8 @@ extern void *lkbde_get_dev_virt(int d); * the userland code to mmap. The following functions * supports multiple resources for a single device. */ -extern int lkbde_get_dev_resource(int d, int rsrc, uint32 *flags, - uint32 *phys_lo, uint32 *phys_hi); +extern int lkbde_get_dev_resource(int d, int rsrc, uint32_t *phys_lo, + uint32_t *phys_hi, uint32_t *size); /* * Backdoor to retrieve OS device structure to be used for @@ -215,6 +244,19 @@ extern int lkbde_dev_state_set(int d, uint32 state); extern int lkbde_dev_instid_get(int d, uint32 *instid); extern int lkbde_dev_instid_set(int d, uint32 instid); + +/* + * Return none-zero if the SDK instance with the given instance ID + * manages the given device. + */ +extern int lkbde_is_dev_managed_by_instance(uint32 dev, uint32 inst_id); + +/* + * Return a pointer to the bitmap of the SDK instance managed devices. + */ +extern linux_bde_device_bitmap_t* lkbde_get_inst_devs(uint32 inst_id); + + /* * Functions that allow an interrupt handler in user mode to * coexist with interrupt handler in kernel module. @@ -256,13 +298,6 @@ extern int lkbde_cpu_pci_register(int d); #endif #endif -/* Don't use _SIMPLE_MEMORY_ALLOCATION_ method for newer kernel than 3.10.0 */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) -#ifndef _SIMPLE_MEMORY_ALLOCATION_ -#define _SIMPLE_MEMORY_ALLOCATION_ 0 -#endif -#endif - /* Allocation via dma_alloc_coherent is turned off by default */ #ifndef _SIMPLE_MEMORY_ALLOCATION_ #define _SIMPLE_MEMORY_ALLOCATION_ 9 /* compile in the allocation method, but do not use it by default */ 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 3bf7488abce9..23eb3fa33e9e 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 @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /*********************************************************************** * @@ -60,7 +71,7 @@ extern void _dma_init(int dev_index); extern int _dma_cleanup(void); -extern void _dma_pprint(void); +extern void _dma_pprint(struct seq_file *m); extern uint32_t *_salloc(int d, int size, const char *name); extern void _sfree(int d, void *ptr); extern int _sinval(int d, void *ptr, int length); diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/include/mpool.h b/platform/broadcom/saibcm-modules/systems/bde/linux/include/mpool.h index be4d436f8da9..15d496ff623d 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/include/mpool.h +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/include/mpool.h @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: mpool.h,v 1.2 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/Makefile b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/Makefile index cfd72d3a9216..2aa3bec11d73 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/Makefile +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/Makefile @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # -*- Makefile -*- # $Id: Makefile,v 1.18 Broadcom SDK $ 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 3a60ac4dd54e..9029b3b51477 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 @@ -339,10 +339,19 @@ typedef struct bde_ctrl_s { uint32 dev_state; /* inst_id */ - uint32 inst_id; + uint32 inst_id; /* The instance ID of the instance controlling the device */ } bde_ctrl_t; static bde_ctrl_t _devices[LINUX_BDE_MAX_DEVICES]; + +/* information stored per SDK instance, curently the devices it manages */ +typedef struct { + linux_bde_device_bitmap_t devices; /* The devices controlled by this instance */ +} lkbde_inst_info_t; + +/* Information for each SDK instance (array index), the device that it manages */ +static lkbde_inst_info_t _instance_info[LINUX_BDE_MAX_DEVICES] = {{ .devices = {0}}}; + static int _ndevices = 0; static int _switch_ndevices = 0; static int _ether_ndevices = 0; @@ -810,6 +819,25 @@ iproc_cmicd_probe(struct platform_device *pldev) static int iproc_cmicd_remove(struct platform_device *pldev) { + int i; + uint32 mask = BDE_SWITCH_DEV_TYPE | BDE_AXI_DEV_TYPE; + bde_ctrl_t *ctrl; + + for (i = 0; i < _ndevices; i++) { + ctrl = _devices + i; + if ((ctrl->dev_type & mask) == mask) { + if (ctrl->bde_dev.base_address1) { + iounmap((void *)ctrl->bde_dev.base_address1); + ctrl->bde_dev.base_address1 = 0; + } + + if (ctrl->bde_dev.base_address) { + iounmap((void *)ctrl->bde_dev.base_address); + ctrl->bde_dev.base_address = 0; + } + } + } + return 0; } #ifdef CONFIG_OF @@ -1429,6 +1457,7 @@ static const struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM53575_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56070_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56071_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM56072_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9656, PCI_ANY_ID, PCI_ANY_ID }, { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9056, PCI_ANY_ID, PCI_ANY_ID }, { BCM53000_VENDOR_ID, BCM53000PCIE_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1474,9 +1503,11 @@ static const struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM88270_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88271_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88272_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88273_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88274_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88276_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88278_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88279_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1496,7 +1527,6 @@ static const struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM88687_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88380_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88381_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, - { BROADCOM_VENDOR_ID, BCM88202_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88360_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88361_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88363_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1527,18 +1557,37 @@ static const struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM8869E_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM8869F_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88800_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, - { BROADCOM_VENDOR_ID, BCM88821_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, - { BROADCOM_VENDOR_ID, BCM88826_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88801_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88802_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88803_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88804_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88805_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88806_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88807_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88808_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88809_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8880A_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8880B_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8880C_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8880D_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8880E_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8880F_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88820_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88821_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88822_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88823_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88824_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88825_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88826_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88827_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88828_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88829_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8882A_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8882B_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8882C_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8882D_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8882E_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8882F_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88480_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88481_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88482_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1555,12 +1604,40 @@ static const struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM8848D_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM8848E_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM8848F_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88280_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88281_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88282_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88283_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88284_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88285_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88286_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88287_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88288_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88289_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8828A_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8828B_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8828C_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8828D_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8828E_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8828F_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88850_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88851_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88852_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88853_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88854_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88855_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88856_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88857_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88858_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88859_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8885A_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8885B_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8885C_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8885D_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8885E_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8885F_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, #endif /* BCM_DNX_SUPPORT */ #ifdef BCM_DFE_SUPPORT - { BROADCOM_VENDOR_ID, BCM88750_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, - { BROADCOM_VENDOR_ID, BCM88753_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, - { BROADCOM_VENDOR_ID, BCM88755_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88770_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88773_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88774_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1574,7 +1651,6 @@ static const struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM88954_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88955_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88956_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, - { BROADCOM_VENDOR_ID, BCM88752_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88772_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88952_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, #endif @@ -1613,6 +1689,10 @@ static const struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM56276_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56277_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56278_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM56279_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM56575_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM56175_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM56176_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56370_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56371_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56372_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1638,6 +1718,7 @@ static const struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM56470_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56471_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56472_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM56475_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { 0, 0, 0, 0 } };; @@ -2540,9 +2621,6 @@ _pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) #if defined(BCM_DFE_SUPPORT) switch (dev->device) { - case BCM88750_DEVICE_ID: - case BCM88753_DEVICE_ID: - case BCM88755_DEVICE_ID: case BCM88770_DEVICE_ID: case BCM88773_DEVICE_ID: case BCM88774_DEVICE_ID: @@ -2554,7 +2632,6 @@ _pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) case BCM88954_DEVICE_ID: case BCM88955_DEVICE_ID: case BCM88956_DEVICE_ID: - case BCM88752_DEVICE_ID: case BCM88772_DEVICE_ID: case BCM88952_DEVICE_ID: @@ -2801,9 +2878,10 @@ _pci_remove(struct pci_dev* dev) } static struct pci_driver _device_driver = { - probe: _pci_probe, - remove: _pci_remove, - id_table: _id_table, + .name = LINUX_KERNEL_BDE_NAME, + .probe = _pci_probe, + .remove = _pci_remove, + .id_table = _id_table, /* The rest are dynamic */ }; @@ -2978,7 +3056,13 @@ probe_plx_local_bus(void) static int _init(void) { + unsigned i; #ifdef IPROC_CMICD + /* + * Adjust the PCI driver name to prevent our device file from + * getting removed when the module is unloaded. + */ + _device_driver.name = LINUX_KERNEL_BDE_NAME ".iproc"; #ifdef CONFIG_OF if (of_find_compatible_node(NULL, NULL, IPROC_CMICX_COMPATIBLE)) { iproc_platform_driver_register(&iproc_cmicd_driver); @@ -3000,9 +3084,6 @@ _init(void) #ifdef BCM_ICS _ics_bde_create(); #else /* PCI */ - /* Register our goodies */ - _device_driver.name = LINUX_KERNEL_BDE_NAME; - /* Configure MSI interrupt support */ use_msi = usemsi; @@ -3078,6 +3159,10 @@ _init(void) } } + for (i = 0; i < LINUX_BDE_MAX_DEVICES; ++i) { + _devices[i].inst_id = BDE_DEV_INST_ID_INVALID; + } + return 0; } @@ -3150,45 +3235,45 @@ _cleanup(void) * Always 0 */ static int -_pprint(void) +_pprint(struct seq_file *m) { int i = 0; - pprintf("Broadcom Device Enumerator (%s)\n", LINUX_KERNEL_BDE_NAME); + pprintf(m, "Broadcom Device Enumerator (%s)\n", LINUX_KERNEL_BDE_NAME); - pprintf("Module parameters:\n"); - pprintf("\tmaxpayload=%d\n", maxpayload); - pprintf("\tusemsi=%d\n", usemsi); + pprintf(m, "Module parameters:\n"); + pprintf(m, "\tmaxpayload=%d\n", maxpayload); + pprintf(m, "\tusemsi=%d\n", usemsi); - _dma_pprint(); + _dma_pprint(m); if (_ndevices == 0) { - pprintf("No devices found\n"); + pprintf(m, "No devices found\n"); } else { - pprintf("Devices:\n"); + pprintf(m, "Devices:\n"); } for (i = 0; i < _ndevices; i++) { bde_ctrl_t *ctrl = _devices + i; if (ctrl->dev_type & BDE_SWITCH_DEV_TYPE) { - pprintf("\t%d (swi) : ", i); + pprintf(m, "\t%d (swi) : ", i); } else if (ctrl->dev_type & BDE_ETHER_DEV_TYPE) { - pprintf("\t%d (eth) : ", i); + pprintf(m, "\t%d (eth) : ", i); } else if (ctrl->dev_type & BDE_CPU_DEV_TYPE) { - pprintf("\t%d (cpu) : ", i); + pprintf(m, "\t%d (cpu) : ", i); } else { - pprintf("\t%d (?) : ", i); + pprintf(m, "\t%d (?) : ", i); } if (ctrl->dev_state == BDE_DEV_STATE_REMOVED) { - pprintf("PCI device 0x%x:0x%x:%d REMOVED\n", + pprintf(m, "PCI device 0x%x:0x%x:%d REMOVED\n", ctrl->pci_device->vendor, ctrl->pci_device->device, ctrl->bde_dev.rev); continue; } if (ctrl->dev_type & BDE_PCI_DEV_TYPE) { - pprintf("PCI device %02x:%02x.%x 0x%x:0x%x:%d:0x%.8lx:0x%.8lx:%d%s\n", + pprintf(m, "PCI device %02x:%02x.%x 0x%x:0x%x:%d:0x%.8lx:0x%.8lx:%d%s\n", (unsigned int)ctrl->pci_device->bus->number, PCI_SLOT(ctrl->pci_device->devfn), PCI_FUNC(ctrl->pci_device->devfn), @@ -3200,7 +3285,7 @@ _pprint(void) ctrl->pci_device->irq, ctrl->use_msi ? " (MSI)" : ""); } else if (ctrl->dev_type & BDE_SPI_DEV_TYPE) { - pprintf("SPI Device %d:%x:%x:0x%x:0x%x:%d\n", + pprintf(m, "SPI Device %d:%x:%x:0x%x:0x%x:%d\n", ctrl->spi_device->cid, ctrl->spi_device->part, ctrl->spi_device->rev, @@ -3208,26 +3293,35 @@ _pprint(void) ctrl->spi_device->phyid_low, ctrl->bde_dev.rev); } else if (ctrl->dev_type & BDE_ICS_DEV_TYPE) { - pprintf("ICS Device 0x%x:0x%x\n", + pprintf(m, "ICS Device 0x%x:0x%x\n", ctrl->bde_dev.device, ctrl->bde_dev.rev); } else if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { - pprintf("AXI Device 0x%x:0x%x:0x%.8lx:%d\n", + pprintf(m, "AXI Device 0x%x:0x%x:0x%.8lx:%d\n", ctrl->bde_dev.device, ctrl->bde_dev.rev, (unsigned long)ctrl->iowin[0].addr, ctrl->iLine); } else if (ctrl->dev_type & BDE_EB_DEV_TYPE) { - pprintf("EB Bus Device 0x%x:0x%x\n", + pprintf(m, "EB Bus Device 0x%x:0x%x\n", ctrl->bde_dev.device, ctrl->bde_dev.rev); } if (debug >= 1) { - pprintf("\t\timask:imask2:fmask 0x%x:0x%x:0x%x\n", + pprintf(m, "\t\timask:imask2:fmask 0x%x:0x%x:0x%x\n", ctrl->imask, ctrl->imask2, ctrl->fmask); } + if (debug >= 1) { + if (ctrl->inst_id == BDE_DEV_INST_ID_INVALID) { + pprintf(m, "\t\tinst_id INVALID\n"); + } else { + pprintf(m, "\t\tinst_id %u%s\n", + ctrl->inst_id, + ctrl->inst_id < LINUX_BDE_MAX_DEVICES ? "":"(Illegal)"); + } + } } return 0; } @@ -3952,9 +4046,6 @@ lkbde_cpu_pci_register(int d) pci_write_config_byte(ctrl->pci_device, 0x88, 0x2f); pci_write_config_byte(ctrl->pci_device, 0x89, 0x10); break; - case BCM88750_DEVICE_ID: - case BCM88753_DEVICE_ID: - case BCM88755_DEVICE_ID: case BCM88770_DEVICE_ID: case BCM88773_DEVICE_ID: case BCM88774_DEVICE_ID: @@ -3966,7 +4057,6 @@ lkbde_cpu_pci_register(int d) case BCM88954_DEVICE_ID: case BCM88955_DEVICE_ID: case BCM88956_DEVICE_ID: - case BCM88752_DEVICE_ID: case BCM88772_DEVICE_ID: case BCM88952_DEVICE_ID: case ACP_PCI_DEVICE_ID: @@ -4013,9 +4103,11 @@ lkbde_cpu_pci_register(int d) case BCM88476_DEVICE_ID: case BCM88477_DEVICE_ID: case BCM88270_DEVICE_ID: + case BCM88271_DEVICE_ID: case BCM88272_DEVICE_ID: case BCM88273_DEVICE_ID: case BCM88274_DEVICE_ID: + case BCM88276_DEVICE_ID: case BCM88278_DEVICE_ID: case BCM8206_DEVICE_ID: case BCM88350_DEVICE_ID: @@ -4061,6 +4153,7 @@ lkbde_cpu_pci_register(int d) case J2C_DEVICE_ID: case J2C_2ND_DEVICE_ID: case Q2A_DEVICE_ID: + case Q2U_DEVICE_ID: case J2P_DEVICE_ID: #endif #ifdef BCM_DNXF_SUPPORT @@ -4277,14 +4370,14 @@ lkbde_get_dev_virt(int d) } int -lkbde_get_dev_resource(int d, int rsrc, uint32_t *flags, - uint32_t *phys_lo, uint32_t *phys_hi) +lkbde_get_dev_resource(int d, int rsrc, uint32_t *phys_lo, + uint32_t *phys_hi, uint32_t *size) { if (!VALID_DEVICE(d)) { return -1; } - *flags = 0; + *size = 0; *phys_lo = 0; *phys_hi = 0; @@ -4300,12 +4393,14 @@ lkbde_get_dev_resource(int d, int rsrc, uint32_t *flags, #ifdef PHYS_ADDR_IS_64BIT *phys_hi = (uint32_t)(_devices[d].iowin[0].addr >> 32); #endif + *size = _devices[d].iowin[0].size; break; case 1: *phys_lo = (uint32_t)(_devices[d].iowin[1].addr); #ifdef PHYS_ADDR_IS_64BIT *phys_hi = (uint32_t)(_devices[d].iowin[1].addr >> 32); #endif + *size = _devices[d].iowin[1].size; break; default: break; @@ -4431,7 +4526,7 @@ lkbde_irq_mask_set(int d, uint32_t addr, uint32_t mask, uint32_t fmask) if (iproc_reg) { _iproc_write(d, addr, ctrl->imask | ctrl->imask2); } else { - _write(d, addr, ctrl->imask | ctrl->imask2); + _write(d, addr, ctrl->imask | ctrl->imask2); } spin_unlock_irqrestore(&ctrl->lock, flags); @@ -4481,6 +4576,29 @@ lkbde_get_num_devices(int type) return _num_devices(type); } +/* + * Return none-zero if the SDK instance with the given instance ID + * manages the given device. + */ +int lkbde_is_dev_managed_by_instance(uint32 dev, uint32 inst_id) +{ + if (inst_id >= LINUX_BDE_MAX_DEVICES || dev >= _ndevices) { + return 0; + } + return _instance_info[inst_id].devices[dev / 32] & (1 << (dev % 32)) ? 1 : 0; +} + +/* + * Return a pointer to the bitmap of the SDK instance managed devices. + */ +linux_bde_device_bitmap_t* lkbde_get_inst_devs(uint32 inst_id) +{ + if (inst_id >= LINUX_BDE_MAX_DEVICES) { + return NULL; + } + return &_instance_info[inst_id].devices; +} + /* * Export functions */ @@ -4503,3 +4621,5 @@ LKM_EXPORT_SYM(lkbde_cpu_write); LKM_EXPORT_SYM(lkbde_cpu_read); LKM_EXPORT_SYM(lkbde_cpu_pci_register); #endif +LKM_EXPORT_SYM(lkbde_is_dev_managed_by_instance); +LKM_EXPORT_SYM(lkbde_get_inst_devs); 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 4f9518e9f4a9..52711964a533 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 @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: linux_dma.c,v 1.414 Broadcom SDK $ @@ -78,9 +89,10 @@ /* allocation types/methods for the DMA memory pool */ #define ALLOC_TYPE_CHUNK 0 /* use small allocations and join them */ #define ALLOC_TYPE_API 1 /* use one allocation */ + #if _SIMPLE_MEMORY_ALLOCATION_ #include -#if defined(IPROC_CMICD) && defined(CONFIG_CMA) && defined(CONFIG_CMA_SIZE_MBYTES) +#if defined(CONFIG_CMA) && defined(CONFIG_CMA_SIZE_MBYTES) #define DMA_MAX_ALLOC_SIZE (CONFIG_CMA_SIZE_MBYTES * 1024 * 1024) #else #define DMA_MAX_ALLOC_SIZE (1 << (MAX_ORDER - 1 + PAGE_SHIFT)) /* Maximum size the kernel can allocate in one allocation */ @@ -88,6 +100,7 @@ #endif /* _SIMPLE_MEMORY_ALLOCATION_ */ #if _SIMPLE_MEMORY_ALLOCATION_ == 1 +/* Use Linux DMA API to allocate contiguous memory */ #define ALLOC_METHOD_DEFAULT ALLOC_TYPE_API #if defined(__arm__) #define USE_DMA_MMAP_COHERENT @@ -196,6 +209,17 @@ MODULE_PARM_DESC(himemaddr, #define DMA_MEM_DEFAULT (8 * ONE_MB) #endif +#ifdef BDE_EDK_SUPPORT +typedef struct { + phys_addr_t cpu_pbase; /* CPU physical base address of the DMA pool */ + phys_addr_t dma_pbase; /* Bus base address of the DMA pool */ + void __iomem *dma_vbase; + uint32 size; /* Total size of the pool */ +}_edk_dma_pool_t; +static _edk_dma_pool_t _edk_dma_pool[LINUX_BDE_MAX_DEVICES]; +static int _edk_use_dma_mapping = 0; +#endif + /* We try to assemble a contiguous segment from chunks of this size */ #define DMA_BLOCK_SIZE (512 * ONE_KB) @@ -552,18 +576,145 @@ _pgfree(void *ptr) return -1; } +#ifdef BDE_EDK_SUPPORT +/* + * Function: _edk_mpool_free + * + * Purpose: + * Free all memory allocated by _adk_mpool_alloc + * Parameters: + * None + * Returns: + * Nothing. + */ +static void +_edk_mpool_free(void) +{ + int i, ndevices; + + ndevices = BDE_NUM_DEVICES(BDE_SWITCH_DEVICES); + for (i = 0; i < ndevices && DMA_DEV(i); i ++) { + if (_edk_dma_pool[i].dma_vbase) { + if (_edk_use_dma_mapping) { + dma_unmap_single(DMA_DEV(i), (dma_addr_t)_edk_dma_pool[i].dma_pbase, + _edk_dma_pool[i].size, DMA_BIDIRECTIONAL); + } + _pgfree(_edk_dma_pool[i].dma_vbase); + _edk_dma_pool[i].dma_vbase = NULL; + } + } + _edk_use_dma_mapping = 0; +} + +/* + * Function: edk_mpool_alloc + * + * Purpose: + * Allocate DMA memory pool for EDK + * Parameters: + * size - size of DMA memory pool + * Returns: + * Nothing. + */ +static void +_edk_mpool_alloc(int dev_id, size_t size) +{ + static void __iomem *dma_vbase = NULL; + static phys_addr_t cpu_pbase = 0; + static phys_addr_t dma_pbase = 0; + + struct device *dev = DMA_DEV(DMA_DEV_INDEX); + unsigned long pbase = 0; + + dma_vbase = _pgalloc(size); + if (!dma_vbase) { + gprintk("Failed to allocate memory pool of size 0x%lx for EDK\n", + (unsigned long)size); + return; + } + cpu_pbase = virt_to_bus(dma_vbase); + + /* Use dma_map_single to obtain DMA bus address or IOVA if IOMMU is present. */ + if (dev) { + pbase = dma_map_single(dev, dma_vbase, size, DMA_BIDIRECTIONAL); + if (BDE_DMA_MAPPING_ERROR(dev, pbase)) { + gprintk("Failed to map memory at %p for EDK\n", dma_vbase); + _pgfree(dma_vbase); + dma_vbase = NULL; + return; + } + _edk_use_dma_mapping = 1; + } else { + pbase = cpu_pbase; + } + + dma_pbase = pbase; + +#ifdef REMAP_DMA_NONCACHED + _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; + _edk_dma_pool[dev_id].dma_vbase = dma_vbase; + _edk_dma_pool[dev_id].size = size; +} + +int +lkbde_edk_get_dma_info(int dev_id, phys_addr_t* cpu_pbase, phys_addr_t* dma_pbase, ssize_t* size) +{ + if (_edk_dma_pool[dev_id].dma_vbase == NULL) { + _edk_mpool_alloc(dev_id, *size * ONE_MB); + } + + if (cpu_pbase) { + *cpu_pbase = _edk_dma_pool[dev_id].cpu_pbase; + } + + if (dma_pbase) { + *dma_pbase = _edk_dma_pool[dev_id].dma_pbase; + } + + *size = (_edk_dma_pool[dev_id].dma_vbase) ? _edk_dma_pool[dev_id].size : 0; + return 0; +} + /* - * Function: _pgcleanup + * The below function validates the memory to the EDK allocated DMA pool, + * required to user space via the BDE device file. + */ +static int +_edk_vm_is_valid(struct file *filp, struct vm_area_struct *vma) +{ + unsigned long phys_addr = vma->vm_pgoff << PAGE_SHIFT; + unsigned long size = vma->vm_end - vma->vm_start; + int i, ndevices; + + ndevices = BDE_NUM_DEVICES(BDE_SWITCH_DEVICES); + for (i = 0; i < ndevices; i++) { + if (phys_addr < (unsigned long )_edk_dma_pool[i].cpu_pbase || + (phys_addr + size) > ((unsigned long )_edk_dma_pool[i].cpu_pbase + + _edk_dma_pool[i].size)) { + continue; + } + return 1; + } + + return 0; +} +#endif + +/* + * Function: _mpool_free * * Purpose: - * Free all memory allocated by _pgalloc + * Free all memory allocated by _mpool_alloc * Parameters: * None * Returns: * Nothing. */ static void -_pgcleanup(void) +_mpool_free(void) { switch (dmaalloc) { #if _SIMPLE_MEMORY_ALLOCATION_ @@ -599,7 +750,7 @@ _pgcleanup(void) } /* - * Function: _alloc_mpool + * Function: _mpool_alloc * * Purpose: * Allocate DMA memory pool @@ -613,7 +764,7 @@ _pgcleanup(void) * It is assumed there is only one pool. */ static void -_alloc_mpool(size_t size) +_mpool_alloc(size_t size) { unsigned long pbase = 0; struct device *dev = DMA_DEV(DMA_DEV_INDEX); @@ -643,7 +794,22 @@ _alloc_mpool(size_t size) gprintk("DMA in high memory at 0x%lx size 0x%lx is beyond the 4GB limit and not supported.\n", pbase, (unsigned long)size); return; } - _cpu_pbase = _dma_pbase = pbase; + _cpu_pbase = pbase; + if (dev) { + /* Use dma_map_single to obtain DMA bus address or I/O virtual address, if + IOMMU is present. */ + pbase = dma_map_single(dev, bus_to_virt(_cpu_pbase), size, DMA_BIDIRECTIONAL); + if (BDE_DMA_MAPPING_ERROR(dev, pbase)) { + gprintk("Error !! Failed to map memory at phys base 0x%lx\n", + (unsigned long)_cpu_pbase); + _cpu_pbase = 0; + return; + } + _use_dma_mapping = 1; + } else { + pbase = _cpu_pbase; + } + _dma_pbase = pbase; _dma_vbase = IOREMAP(_dma_pbase, size); } else { /* Get DMA memory from kernel */ @@ -684,14 +850,13 @@ _alloc_mpool(size_t size) return; } _cpu_pbase = virt_to_bus(_dma_vbase); - /* Use dma_map_single to obtain DMA bus address or IOVA if iommu is present. */ + /* Use dma_map_single to obtain DMA bus address or IOVA if IOMMU is present. */ if (dev) { pbase = dma_map_single(dev, _dma_vbase, size, DMA_BIDIRECTIONAL); if (BDE_DMA_MAPPING_ERROR(dev, pbase)) { gprintk("Failed to map memory at %p\n", _dma_vbase); - _pgcleanup(); + _mpool_free(); _dma_vbase = NULL; - _cpu_pbase = 0; return; } _use_dma_mapping = 1; @@ -709,7 +874,7 @@ _alloc_mpool(size_t size) if (!dma64_support && ((pbase + (size - 1)) >> 16) > DMA_BIT_MASK(16)) { gprintk("DMA memory allocated at 0x%lx size 0x%lx is beyond the 4GB limit and not supported.\n", pbase, (unsigned long)size); - _pgcleanup(); + _mpool_free(); _dma_vbase = NULL; _dma_pbase = 0; return; @@ -739,15 +904,27 @@ _alloc_mpool(size_t size) int _dma_cleanup(void) { +#ifdef BDE_EDK_SUPPORT + _edk_mpool_free(); +#endif if (_dma_vbase) { mpool_destroy(_dma_pool); if (_use_himem) { + int i, ndevices; iounmap(_dma_vbase); + if (_use_dma_mapping) { + ndevices = BDE_NUM_DEVICES(BDE_SWITCH_DEVICES); + for (i = 0; i < ndevices && DMA_DEV(i); i ++) { + dma_unmap_single(DMA_DEV(i), (dma_addr_t)_dma_pbase, _dma_mem_size, + DMA_BIDIRECTIONAL); + } + _use_dma_mapping = 0; + } } else { #ifdef REMAP_DMA_NONCACHED iounmap(_dma_vbase); #endif - _pgcleanup(); + _mpool_free(); } _dma_vbase = NULL; _dma_pbase = 0; @@ -811,7 +988,7 @@ void _dma_init(int dev_index) } if (_dma_mem_size) { - _alloc_mpool(_dma_mem_size); + _mpool_alloc(_dma_mem_size); if (_dma_vbase == NULL) { gprintk("no DMA memory available\n"); } else { @@ -835,10 +1012,17 @@ int _dma_mmap(struct file *filp, struct vm_area_struct *vma) if (phys_addr < (unsigned long )_cpu_pbase || (phys_addr + size) > ((unsigned long )_cpu_pbase + _dma_mem_size)) { +#ifdef BDE_EDK_SUPPORT + if(!_edk_vm_is_valid(filp, vma)) { + gprintk("range 0x%lx-0x%lx outside DMA pool\n", phys_addr, phys_addr + size); + return -EINVAL; + } +#else gprintk("range 0x%lx-0x%lx outside DMA pool 0x%lx-0x%lx\n", phys_addr, phys_addr + size, (unsigned long )_cpu_pbase, (unsigned long )_cpu_pbase + _dma_mem_size); return -EINVAL; +#endif } #ifdef USE_DMA_MMAP_COHERENT @@ -995,7 +1179,7 @@ lkbde_get_dma_info(phys_addr_t* cpu_pbase, phys_addr_t* dma_pbase, ssize_t* size if (_dma_mem_size == 0) { _dma_mem_size = DMA_MEM_DEFAULT; } - _alloc_mpool(_dma_mem_size); + _mpool_alloc(_dma_mem_size); } *cpu_pbase = _cpu_pbase; *dma_pbase = _dma_pbase; @@ -1004,12 +1188,12 @@ lkbde_get_dma_info(phys_addr_t* cpu_pbase, phys_addr_t* dma_pbase, ssize_t* size } void -_dma_pprint(void) +_dma_pprint(struct seq_file *m) { - pprintf("\tdmasize=%s\n", dmasize); - pprintf("\thimem=%s\n", himem); - pprintf("\thimemaddr=%s\n", himemaddr); - pprintf("DMA Memory (%s): %d bytes, %d used, %d free%s\n", + pprintf(m, "\tdmasize=%s\n", dmasize); + pprintf(m, "\thimem=%s\n", himem); + pprintf(m, "\thimemaddr=%s\n", himemaddr); + pprintf(m, "DMA Memory (%s): %d bytes, %d used, %d free%s\n", (_use_himem) ? "high" : "kernel", (_dma_vbase) ? _dma_mem_size : 0, (_dma_vbase) ? mpool_usage(_dma_pool) : 0, @@ -1020,6 +1204,10 @@ _dma_pprint(void) /* * Export functions */ + +#ifdef BDE_EDK_SUPPORT +LKM_EXPORT_SYM(lkbde_edk_get_dma_info); +#endif LKM_EXPORT_SYM(kmalloc_giant); LKM_EXPORT_SYM(kfree_giant); LKM_EXPORT_SYM(lkbde_get_dma_info); diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_shbde.c b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_shbde.c index a2d58858a5a5..dd003e1f9297 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_shbde.c +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_shbde.c @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_shbde.h b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_shbde.h index 5e8a70119e85..ef4b49dc2124 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_shbde.h +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_shbde.h @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/shared/mpool.c b/platform/broadcom/saibcm-modules/systems/bde/linux/shared/mpool.c index 13206596ee26..4c2db5e4de6c 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/shared/mpool.c +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/shared/mpool.c @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: mpool.c,v 1.18 Broadcom SDK $ @@ -71,7 +82,7 @@ static sal_sem_t _mpool_lock; #endif #define MPOOL_BUF_SIZE 1024 -#define MPOOL_BUF_ALLOC_COUNT_MAX 16 +#define MPOOL_BUF_ALLOC_COUNT_MAX 128 typedef struct mpool_mem_s { unsigned char *address; @@ -80,20 +91,42 @@ typedef struct mpool_mem_s { struct mpool_mem_s *next; } mpool_mem_t; +static int _mpool_count; static int _buf_alloc_count; static mpool_mem_t *mpool_buf[MPOOL_BUF_ALLOC_COUNT_MAX]; static mpool_mem_t *free_list; -#define ALLOC_INIT_MPOOL_BUF(ptr) \ - ptr = MALLOC((sizeof(mpool_mem_t) * MPOOL_BUF_SIZE)); \ - if (ptr) { \ - int i; \ - for (i = 0; i < MPOOL_BUF_SIZE - 1; i++) { \ - ptr[i].next = &ptr[i+1]; \ - } \ - ptr[MPOOL_BUF_SIZE - 1].next = NULL; \ - free_list = &ptr[0]; \ - } +static mpool_mem_t * +_mpool_buf_create(void) +{ + int i; + mpool_mem_t *ptr; + + if (_buf_alloc_count == MPOOL_BUF_ALLOC_COUNT_MAX) { + return NULL; + } + + mpool_buf[_buf_alloc_count] = MALLOC((sizeof(mpool_mem_t) * MPOOL_BUF_SIZE)); + if (!mpool_buf[_buf_alloc_count]) { + return NULL; + } + + ptr = mpool_buf[_buf_alloc_count]; + for (i = 0; i < MPOOL_BUF_SIZE - 1; i++) { + ptr[i].next = &ptr[i+1]; + } + + ptr[MPOOL_BUF_SIZE - 1].next = NULL; + + if (free_list) { + free_list->next = &ptr[0]; + } else { + free_list = &ptr[0]; + } + + _buf_alloc_count++; + return ptr; +} /* * Function: mpool_init @@ -108,7 +141,15 @@ static mpool_mem_t *free_list; int mpool_init(void) { + int i; + MPOOL_LOCK_INIT(); + _buf_alloc_count = 0; + _mpool_count = 0; + for (i = 0; i < MPOOL_BUF_ALLOC_COUNT_MAX; i++) { + mpool_buf[i] = NULL; + } + free_list = NULL; return 0; } @@ -140,7 +181,7 @@ mpool_alloc(mpool_handle_t pool, int size) } mod = size & (BCM_CACHE_LINE_BYTES - 1); - if (mod != 0 ) { + if (mod != 0) { size += (BCM_CACHE_LINE_BYTES - mod); } while (ptr && ptr->next) { @@ -155,20 +196,9 @@ mpool_alloc(mpool_handle_t pool, int size) return NULL; } - if (!free_list) { - if (_buf_alloc_count == MPOOL_BUF_ALLOC_COUNT_MAX) { - MPOOL_UNLOCK(); - return NULL; - } - - ALLOC_INIT_MPOOL_BUF(mpool_buf[_buf_alloc_count]); - - if (mpool_buf[_buf_alloc_count] == NULL) { - MPOOL_UNLOCK(); - return NULL; - } - - _buf_alloc_count++; + if (!free_list && !_mpool_buf_create()) { + MPOOL_UNLOCK(); + return NULL; } newptr = free_list; @@ -251,25 +281,16 @@ mpool_create(void *base_ptr, int size) { mpool_mem_t *head, *tail; int mod = (int)(((unsigned long)base_ptr) & (BCM_CACHE_LINE_BYTES - 1)); - int i; MPOOL_LOCK(); - for (i = 0; i < MPOOL_BUF_ALLOC_COUNT_MAX; i++) { - mpool_buf[i] = NULL; - } - - _buf_alloc_count = 0; - - ALLOC_INIT_MPOOL_BUF(mpool_buf[_buf_alloc_count]); - - if (mpool_buf[_buf_alloc_count] == NULL) { - MPOOL_UNLOCK(); - return NULL; + if (!free_list || !(free_list->next)) { + if (!_mpool_buf_create()) { + MPOOL_UNLOCK(); + return NULL; + } } - _buf_alloc_count++; - if (mod) { base_ptr = (char*)base_ptr + (BCM_CACHE_LINE_BYTES - mod); size -= (BCM_CACHE_LINE_BYTES - mod); @@ -288,6 +309,7 @@ mpool_create(void *base_ptr, int size) head->next = tail; tail->prev = head; tail->next = NULL; + _mpool_count++; MPOOL_UNLOCK(); return head; @@ -307,19 +329,27 @@ int mpool_destroy(mpool_handle_t pool) { int i; + mpool_mem_t *head = pool; MPOOL_LOCK(); - if ((mpool_mem_t *)pool != mpool_buf[0]) { + if (!(head && head->prev)) { MPOOL_UNLOCK(); return 0; } - for (i = 0; i < MPOOL_BUF_ALLOC_COUNT_MAX; i++) { - if (mpool_buf[i]) { - FREE(mpool_buf[i]); - mpool_buf[i] = NULL; + head->prev->next = free_list; + free_list = head; + _mpool_count--; + + if (_mpool_count == 0) { + for (i = 0; i < MPOOL_BUF_ALLOC_COUNT_MAX; i++) { + if (mpool_buf[i]) { + FREE(mpool_buf[i]); + mpool_buf[i] = NULL; + } } + free_list = NULL; } MPOOL_UNLOCK(); diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/Makefile b/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/Makefile index 424f2fe24bee..2cc96df02d0a 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/Makefile +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/Makefile @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # -*- Makefile -*- # $Id: Makefile,v 1.1 Broadcom SDK $ 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 46f60c8a3ae9..4e6186e2d80d 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 @@ -24,14 +24,13 @@ #include #include #include - +#include #include "linux-user-bde.h" #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0) #include #endif - MODULE_AUTHOR("Broadcom Corporation"); MODULE_DESCRIPTION("User BDE Helper Module"); MODULE_LICENSE("GPL"); @@ -71,7 +70,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, @@ -80,15 +79,27 @@ be made. */ #define PAXB_0_PAXB_IC_INTRCLR_0 (0x180123a0) #define PAXB_0_PAXB_IC_INTRCLR_1 (0x180123a4) - #define PAXB_0_PAXB_IC_INTRCLR_MODE_0 (0x180123a8) #define PAXB_0_PAXB_IC_INTRCLR_MODE_1 (0x180123ac) +#define PAXB_0_PAXB_INTR_STATUS (0x18012f38) +#define PAXB_0_PAXB_IC_INTR_PACING_CTRL (0x18012398) +#define PAXB_0_PAXB_INTRCLR_DELAY_UNIT (0x1801239c) +#define PAXB_0_PAXB_IC_INTRCLR_DELAY_REG0 (0x180123b0) +#define PAXB_0_PCIE_ERROR_STATUS (0x18012024) #define HX5_PAXB_0_PAXB_IC_INTRCLR_0 (0x102303a0) #define HX5_PAXB_0_PAXB_IC_INTRCLR_1 (0x102303a4) #define HX5_PAXB_0_PAXB_IC_INTRCLR_MODE_0 (0x102303a8) #define HX5_PAXB_0_PAXB_IC_INTRCLR_MODE_1 (0x102303ac) +#define HX5_PAXB_0_PAXB_INTR_STATUS (0x10230f38) +#define HX5_PAXB_0_PAXB_IC_INTR_PACING_CTRL (0x10230398) +#define HX5_PAXB_0_PAXB_INTRCLR_DELAY_UNIT (0x1023039c) +#define HX5_PAXB_0_PAXB_IC_INTRCLR_DELAY_REG0 (0x102303b0) +#define HX5_PAXB_0_PCIE_ERROR_STATUS (0x10230024) + +#define PAXB_0_PAXB_IC_INTRCLR_DELAY_BASE (PAXB_0_PAXB_IC_INTRCLR_DELAY_REG0) +#define HX5_PAXB_0_PAXB_IC_INTRCLR_DELAY_BASE (HX5_PAXB_0_PAXB_IC_INTRCLR_DELAY_REG0) #define INTC_INTR_ENABLE_REG0 (0x180130f0) #define INTC_INTR_STATUS_REG0 (0x18013190) @@ -129,9 +140,9 @@ be made. #define INTC_LOW_PRIORITY_INTR_REG_IND IRQ_MASK_INDEX(HX5_CHIP_INTR_LOW_PRIORITY) #define INTC_PDMA_INTR_REG_IND 4 -#define READ_INTC_INTR(d, reg, v) \ +#define IPROC_READ(d, reg, v) \ (v = user_bde->iproc_read(d, reg)) -#define WRITE_INTC_INTR(d, reg, v) \ +#define IPROC_WRITE(d, reg, v) \ (user_bde->iproc_write(d, reg, v)) #define IHOST_READ_INTR(d, reg, v) \ @@ -155,6 +166,22 @@ be made. static uint32 *ihost_intr_status_base = NULL; static uint32 *ihost_intr_enable_base = NULL; +/* Module parameter for Interruptible timeout */ +static int intr_timeout = 0; +LKM_MOD_PARAM(intr_timeout, "i", int, (S_IRUGO | S_IWUSR)); +MODULE_PARM_DESC(intr_timeout, +"Interruptible wait timeout in milliseconds for Interrupt to be triggered."); + +static ulong intr_count = 0; +LKM_MOD_PARAM(intr_count, "intr_count", ulong, (S_IRUGO | S_IWUSR)); +MODULE_PARM_DESC(intr_count, +"Interrupt count provides information about the number of times the ISR is called."); + +static ulong intr_timeout_count = 0; +LKM_MOD_PARAM(intr_timeout_count, "intr_timeout_count", ulong, (S_IRUGO | S_IWUSR)); +MODULE_PARM_DESC(intr_timeout_count, +"Interrupt timeout count provides information about the number of times the interrupt wait is timeed out."); + /* Debug output */ static int debug; LKM_MOD_PARAM(debug, "i", int, (S_IRUGO | S_IWUSR)); @@ -168,10 +195,16 @@ typedef void (*isr_f)(void *); typedef struct _intr_regs_s { uint32 intc_intr_status_base; uint32 intc_intr_enable_base; + uint32 intc_intr_raw_status_base; uint32 intc_intr_clear_0; uint32 intc_intr_clear_1; uint32 intc_intr_clear_mode_0; uint32 intc_intr_clear_mode_1; + uint32 intc_intr_status; + uint32 intc_intr_pacing_ctrl; + uint32 intc_intr_clear_delay_unit; + uint32 intc_intr_clear_delay_base; + uint32 intc_intr_pcie_err_status; } _intr_regs_t; typedef struct bde_ctrl_s { @@ -181,7 +214,8 @@ typedef struct bde_ctrl_s { int devid; isr_f isr; uint32 *ba; - int inst; /* associate to _bde_inst_resource[] */ + uint32 inst; /* the resource/instance index in _bde_inst_resource[] */ + int edk_irq_enabled; _intr_regs_t intr_regs; } bde_ctrl_t; @@ -199,20 +233,37 @@ static atomic_t _ether_interrupt_has_taken_place = ATOMIC_INIT(0); */ static int _bde_multi_inst = 0; +#define MAX_UC_CORES LINUX_BDE_MAX_IPROC_UC_CORES + +/* Structure to hold info about interrupts handled by EDK */ typedef struct { - unsigned int inst_id; - unsigned int dma_offset; - unsigned int dma_size; + uint32_t timer_intrc_offset; /* Timer interrupts INTC offset */ + uint32_t timer_intrc_mask; /* Timer interrupts mask */ + uint32_t sw_intr_intrc_offset; /* SW Programmable Interrupt's offset */ + uint32_t sw_intr_intrc_mask; /* SW interrupt's mask */ + uint32_t sw_intr_src_bitmap; /* SW interrupt's bitmask to navigate ICFG registers */ + uint32_t sw_intr_icfg_reg[MAX_UC_CORES]; /* ICFG registers for each core */ +} bde_edk_intr_t; + +typedef struct { + int is_active; /* Is the instance active */ + unsigned int dma_offset; /* offset of the instance's DMA memory in the DMA buffer pool */ + unsigned int dma_size; /* size of the instance's DMA memory (in the DMA buffer pool) */ wait_queue_head_t intr_wq; + wait_queue_head_t edk_intr_wq; atomic_t intr; + atomic_t edk_intr; + bde_edk_intr_t edk_irqs; } bde_inst_resource_t; +/* This array contains information for SDK instance, the index in the array is the instance ID */ static bde_inst_resource_t _bde_inst_resource[LINUX_BDE_MAX_DEVICES]; /* * Lock used to protect changes to _bde_inst_resource */ static spinlock_t bde_resource_lock; + typedef struct { phys_addr_t cpu_pbase; /* CPU physical base address of the DMA pool */ phys_addr_t dma_pbase; /* Bus base address of the DMA pool */ @@ -291,23 +342,98 @@ _cmic_interrupt(bde_ctrl_t *ctrl) #endif } -static void -_cmicx_interrupt(bde_ctrl_t *ctrl) +void +dump_interrupt_regs(bde_ctrl_t *ctrl , int dev) +{ + int ind; + uint32_t val; + + 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++) { + 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); + gprintk("INTC_INTR_RAW_STATUS_REG_%d = 0x%x\n", ind, val); + IPROC_READ(dev, ctrl->intr_regs.intc_intr_enable_base + 4 * ind, val); + gprintk("INTC_INTR_ENABLE_REG_%d = 0x%x\n", ind, val); + } + /* Dump PAXB Register */ + IPROC_READ(dev, ctrl->intr_regs.intc_intr_status, val); + gprintk("PAXB_0_PAXB_INTR_STATUS = 0x%x\n", val); + IPROC_READ(dev, ctrl->intr_regs.intc_intr_pacing_ctrl, val); + gprintk("PAXB_0_PAXB_IC_INTR_PACING_CTRL = 0x%x\n", val); + IPROC_READ(dev, ctrl->intr_regs.intc_intr_clear_delay_unit, val); + gprintk("PAXB_0_PAXB_INTRCLR_DELAY_UNIT = 0x%x\n", val); + IPROC_READ(dev, ctrl->intr_regs.intc_intr_pcie_err_status, val); + gprintk("PAXB_0_PCIE_ERROR_STATUS = 0x%x\n", val); + + for (ind = 0; ind < PAXB_INTRCLR_DELAY_REG_NUM; ind++) { + IPROC_READ(dev, ctrl->intr_regs.intc_intr_clear_delay_base + 4 * ind, val); + gprintk("PAXB_0_PAXB_IC_INTRCLR_DELAY_REG_%d = 0x%x\n", ind, val); + } + } + /* Clear interrupt enable registers */ + for (ind = 0; ind < INTC_INTR_REG_NUM; ind++) { + IPROC_WRITE(dev, ctrl->intr_regs.intc_intr_enable_base + 4 * ind, 0); + } +} + +#ifdef BDE_EDK_SUPPORT +static int +_cmicx_edk_interrupt_check(bde_ctrl_t *ctrl, int d) { - int d, ind; - uint32 stat, iena, mask, fmask; bde_inst_resource_t *res; + uint32 stat, mask = 0, bitmap = 0; + int idx; + + res = &_bde_inst_resource[ctrl->inst]; + bitmap = res->edk_irqs.sw_intr_src_bitmap; + + /* Explicitly reading raw_status so as to not clear the status on read */ + IPROC_READ(d, ctrl->intr_regs.intc_intr_raw_status_base + + (res->edk_irqs.sw_intr_intrc_offset * 4), stat); + /* Check whether Software Programmable Interrupt is set */ + if (stat & res->edk_irqs.sw_intr_intrc_mask) { + for (idx = 0; (bitmap && (idx < MAX_UC_CORES)); idx++) { + if (bitmap & 1) { + IPROC_READ(d, res->edk_irqs.sw_intr_icfg_reg[idx], stat); + mask |= (stat & 1) << idx; + } + bitmap = (bitmap >> 1); + } + if (mask) + return 1; + } + + /* EDK uses timer interrupt as watchdog to indicate the the firmware has crashed */ + IPROC_READ(d, ctrl->intr_regs.intc_intr_raw_status_base + + (res->edk_irqs.timer_intrc_offset * 4), stat); + if (stat & res->edk_irqs.timer_intrc_mask) { + return 1; + } + return 0; +} +#endif + +static int +_cmicx_interrupt_prepare(bde_ctrl_t *ctrl) +{ + int d, ind, ret = 0; + uint32 stat, iena, mask, fmask; d = (((uint8 *)ctrl - (uint8 *)_devices) / sizeof (bde_ctrl_t)); if (ctrl->dev_type & BDE_PCI_DEV_TYPE) { + IPROC_READ(d, ctrl->intr_regs.intc_intr_clear_mode_0, stat); /* Clear MSI interrupts immediately to prevent spurious interrupts */ - WRITE_INTC_INTR(d, ctrl->intr_regs.intc_intr_clear_0, 0xFFFFFFFF); - WRITE_INTC_INTR(d, ctrl->intr_regs.intc_intr_clear_1, 0xFFFFFFFF); + 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); + } } - res = &_bde_inst_resource[ctrl->inst]; - lkbde_irq_mask_get(d, &mask, &fmask); if (fmask) { @@ -315,15 +441,15 @@ _cmicx_interrupt(bde_ctrl_t *ctrl) IHOST_READ_INTR(d, ihost_intr_status_base + INTC_PDMA_INTR_REG_IND, stat); IHOST_READ_INTR(d, ihost_intr_enable_base + INTC_PDMA_INTR_REG_IND, iena); } else { - READ_INTC_INTR(d, ctrl->intr_regs.intc_intr_status_base + 4 * INTC_PDMA_INTR_REG_IND, stat); - READ_INTC_INTR(d, ctrl->intr_regs.intc_intr_enable_base + 4 * INTC_PDMA_INTR_REG_IND, iena); + IPROC_READ(d, ctrl->intr_regs.intc_intr_status_base + 4 * INTC_PDMA_INTR_REG_IND, stat); + IPROC_READ(d, ctrl->intr_regs.intc_intr_enable_base + 4 * INTC_PDMA_INTR_REG_IND, iena); } if (stat & iena) { if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { IHOST_WRITE_INTR(d, ihost_intr_enable_base + INTC_PDMA_INTR_REG_IND + HX5_IHOST_IRQ_MASK_OFFSET, ~0); } else { - WRITE_INTC_INTR(d, ctrl->intr_regs.intc_intr_enable_base + 4 * INTC_PDMA_INTR_REG_IND, 0); + IPROC_WRITE(d, ctrl->intr_regs.intc_intr_enable_base + 4 * INTC_PDMA_INTR_REG_IND, 0); } for (ind = 0; ind < INTC_INTR_REG_NUM; ind++) { @@ -344,16 +470,16 @@ _cmicx_interrupt(bde_ctrl_t *ctrl) } } } else { - READ_INTC_INTR(d, ctrl->intr_regs.intc_intr_status_base + 4 * ind, stat); - READ_INTC_INTR(d, ctrl->intr_regs.intc_intr_enable_base + 4 * ind, iena); + IPROC_READ(d, ctrl->intr_regs.intc_intr_status_base + 4 * ind, stat); + IPROC_READ(d, ctrl->intr_regs.intc_intr_enable_base + 4 * ind, iena); } if (stat & iena) { break; } } - + /* No pending interrupts */ if (ind >= INTC_INTR_REG_NUM) { - return; + return -1; } } } @@ -362,6 +488,11 @@ _cmicx_interrupt(bde_ctrl_t *ctrl) * So as to avoid getting new interrupts until the user level driver * enumerates the interrupts to be serviced */ +#ifdef BDE_EDK_SUPPORT + if (ctrl->edk_irq_enabled) + ret = _cmicx_edk_interrupt_check(ctrl, d); +#endif + for (ind = 0; ind < INTC_INTR_REG_NUM; ind++) { if (fmask && ind == INTC_PDMA_INTR_REG_IND) { continue; @@ -381,17 +512,42 @@ _cmicx_interrupt(bde_ctrl_t *ctrl) HX5_IHOST_IRQ_MASK_OFFSET, ~0); } } else { - WRITE_INTC_INTR(d, ctrl->intr_regs.intc_intr_enable_base + 4*ind, 0); + IPROC_WRITE(d, ctrl->intr_regs.intc_intr_enable_base + (4 * ind), 0); } } - /* Notify */ - atomic_set(&res->intr, 1); + return ret; +} + +static void +_cmicx_interrupt(bde_ctrl_t *ctrl) +{ + bde_inst_resource_t *res; + int ret; + + intr_count++; + + res = &_bde_inst_resource[ctrl->inst]; + ret = _cmicx_interrupt_prepare(ctrl); + if (ret < 0) { + return; + } else if (ret > 0) { + /* Notify */ + atomic_set(&res->edk_intr, 1); #ifdef BDE_LINUX_NON_INTERRUPTIBLE - wake_up(&res->intr_wq); + wake_up(&res->edk_intr_wq); #else - wake_up_interruptible(&res->intr_wq); + wake_up_interruptible(&res->edk_intr_wq); #endif + } else { + /* Notify */ + atomic_set(&res->intr, 1); +#ifdef BDE_LINUX_NON_INTERRUPTIBLE + wake_up(&res->intr_wq); +#else + wake_up_interruptible(&res->intr_wq); +#endif + } } static void @@ -695,25 +851,6 @@ _cmicd_interrupt(bde_ctrl_t *ctrl) #endif } -static void -_bcm88750_interrupt(bde_ctrl_t *ctrl) -{ - int d; - bde_inst_resource_t *res; - - d = (((uint8 *)ctrl - (uint8 *)_devices) / sizeof (bde_ctrl_t)); - res = &_bde_inst_resource[ctrl->inst]; - lkbde_irq_mask_set(d, CMIC_IRQ_MASK, 0, 0); - - lkbde_irq_mask_set(d, CMIC_IRQ_MASK_1, 0, 0); - lkbde_irq_mask_set(d, CMIC_IRQ_MASK_2, 0, 0); - atomic_set(&res->intr, 1); -#ifdef BDE_LINUX_NON_INTERRUPTIBLE - wake_up(&res->intr_wq); -#else - wake_up_interruptible(&res->intr_wq); -#endif -} /* The actual interrupt handler of ethernet devices */ static void @@ -738,7 +875,6 @@ static struct _intr_mode_s { { (isr_f)_cmicm_interrupt, "CMICm" }, { (isr_f)_cmicd_interrupt, "CMICd" }, { (isr_f)_cmicd_cmc0_interrupt, "CMICd CMC0" }, - { (isr_f)_bcm88750_interrupt, "BCM88750" }, { (isr_f)_cmicx_interrupt, "CMICx" }, { NULL, NULL } }; @@ -764,17 +900,31 @@ _intr_regs_init(bde_ctrl_t *ctrl, int hx5_intr) if (hx5_intr) { 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; ctrl->intr_regs.intc_intr_clear_0 = HX5_PAXB_0_PAXB_IC_INTRCLR_0; ctrl->intr_regs.intc_intr_clear_1 = HX5_PAXB_0_PAXB_IC_INTRCLR_1; ctrl->intr_regs.intc_intr_clear_mode_0 = HX5_PAXB_0_PAXB_IC_INTRCLR_MODE_0; ctrl->intr_regs.intc_intr_clear_mode_1 = HX5_PAXB_0_PAXB_IC_INTRCLR_MODE_1; + ctrl->intr_regs.intc_intr_status = HX5_PAXB_0_PAXB_INTR_STATUS; + ctrl->intr_regs.intc_intr_pacing_ctrl = HX5_PAXB_0_PAXB_IC_INTR_PACING_CTRL; + 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; + } 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; ctrl->intr_regs.intc_intr_enable_base = INTC_INTR_ENABLE_BASE; ctrl->intr_regs.intc_intr_clear_0 = PAXB_0_PAXB_IC_INTRCLR_0; ctrl->intr_regs.intc_intr_clear_1 = PAXB_0_PAXB_IC_INTRCLR_1; ctrl->intr_regs.intc_intr_clear_mode_0 = PAXB_0_PAXB_IC_INTRCLR_MODE_0; ctrl->intr_regs.intc_intr_clear_mode_1 = PAXB_0_PAXB_IC_INTRCLR_MODE_1; + ctrl->intr_regs.intc_intr_status = PAXB_0_PAXB_INTR_STATUS; + ctrl->intr_regs.intc_intr_pacing_ctrl = PAXB_0_PAXB_IC_INTR_PACING_CTRL; + 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; + } } @@ -804,13 +954,6 @@ _devices_init(int d) } if (ctrl->dev_type & BDE_SWITCH_DEV_TYPE) { switch (user_bde->get_dev(d)->device) { - case BCM88750_DEVICE_ID: - case BCM88753_DEVICE_ID: - case BCM88754_DEVICE_ID: - case BCM88755_DEVICE_ID: - case BCM88752_DEVICE_ID: - ctrl->isr = (isr_f)_bcm88750_interrupt; - break; case BCM53540_DEVICE_ID: case BCM53547_DEVICE_ID: case BCM53548_DEVICE_ID: @@ -894,6 +1037,10 @@ _devices_init(int d) case BCM56276_DEVICE_ID: case BCM56277_DEVICE_ID: case BCM56278_DEVICE_ID: + case BCM56279_DEVICE_ID: + case BCM56575_DEVICE_ID: + case BCM56175_DEVICE_ID: + case BCM56176_DEVICE_ID: ctrl->isr = (isr_f)_cmicx_interrupt; if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { if (!ihost_intr_enable_base) { @@ -944,6 +1091,7 @@ _devices_init(int d) case J2C_DEVICE_ID: case J2C_2ND_DEVICE_ID: case Q2A_DEVICE_ID: + case Q2U_DEVICE_ID: case J2P_DEVICE_ID: #endif #ifdef BCM_DNXF_SUPPORT @@ -974,10 +1122,11 @@ _devices_init(int d) static int _init(void) { - int i; + int i, nof_devices; phys_addr_t cpu_pbase, dma_pbase; ssize_t dmasize; bde_inst_resource_t *res; + uint32 *bitmap_ptr; /* Connect to the kernel bde */ if ((linux_bde_create(NULL, &user_bde) < 0) || user_bde == NULL) { @@ -1002,16 +1151,30 @@ _init(void) res->dma_offset = 0; res->dma_size = _dma_pool.total_size; init_waitqueue_head(&res->intr_wq); + init_waitqueue_head(&res->edk_intr_wq); atomic_set(&res->intr, 0); + atomic_set(&res->edk_intr, 0); ihost_intr_enable_base = NULL; ihost_intr_status_base = NULL; - for (i = 0; i < user_bde->num_devices(BDE_ALL_DEVICES); i++) { - res->inst_id |= (1 << i); + nof_devices = user_bde->num_devices(BDE_ALL_DEVICES); + /* for no BDE instances, mark the single SDK as controlling all devices */ + bitmap_ptr = *lkbde_get_inst_devs(0); + for (i = nof_devices; i >=32; i -= 32) { + *(bitmap_ptr++) = 0xffffffff; + } + *bitmap_ptr = (((uint32)1) << i) - 1; + res->is_active = 1; + + for (i = 0; i < nof_devices; i++) { /* init all devices */ _devices_init(i); } + if (intr_timeout > 0) { + gprintk("Interruptible wait timeout = %d msecs\n", intr_timeout); + } + return 0; } @@ -1036,7 +1199,7 @@ _cleanup(void) BDE_DEV_MEM_MAPPED(_devices[i].dev_type)) { user_bde->interrupt_disconnect(i); } - lkbde_dev_instid_set(i, 0); + lkbde_dev_instid_set(i, BDE_DEV_INST_ID_INVALID); } linux_bde_destroy(user_bde); user_bde = NULL; @@ -1065,48 +1228,53 @@ _cleanup(void) * Always 0 */ static int -_pprint(void) +_pprint(struct seq_file *m) { int idx; const char *name; bde_inst_resource_t *res; uint32 state, instid; - pprintf("Broadcom Device Enumerator (%s)\n", LINUX_USER_BDE_NAME); + pprintf(m, "Broadcom Device Enumerator (%s)\n", LINUX_USER_BDE_NAME); for (idx = 0; idx < user_bde->num_devices(BDE_ALL_DEVICES); idx++) { name = _intr_mode_str(_devices[idx].isr); if (name == NULL) { name = "unknown"; } - pprintf("\t%d: Interrupt mode %s ",idx, name); + pprintf(m, "\t%d: Interrupt mode %s ",idx, name); (void)lkbde_dev_state_get(idx, &state); if (state == BDE_DEV_STATE_REMOVED) { - pprintf(" Device REMOVED ! \n"); + pprintf(m, " Device REMOVED ! \n"); } else { (void)lkbde_dev_instid_get(idx, &instid); - if (instid) { - pprintf("Inst id 0x%x\n",instid); + if (instid != BDE_DEV_INST_ID_INVALID) { + pprintf(m, "Inst id 0x%x\n",instid); } else { - pprintf("\n"); + pprintf(m, "\n"); } } } - pprintf("Instance resource \n"); + pprintf(m, "Instance resource \n"); for (idx = 0; idx < user_bde->num_devices(BDE_ALL_DEVICES); idx++) { res = &_bde_inst_resource[idx]; - if (res->inst_id) { - pprintf("\tDev mask 0x%x : " - "DMA offset %d size %d MB\n", - res->inst_id, + if (res->is_active) { + linux_bde_device_bitmap_t* bitmap_p = lkbde_get_inst_devs(idx); + pprintf(m, "\t%d: DMA offset %d size %d MB Dev mask 0x", + idx, res->dma_offset, res->dma_size); + for (state = 0; state * 32 < user_bde->num_devices(BDE_ALL_DEVICES); ++state) { + pprintf(m,"%.8x ", (*bitmap_p)[state]); + } + pprintf(m,"\n"); } } return 0; } +#ifdef BCM_INSTANCE_SUPPORT /* * Allocate the DMA resource from DMA pool * Parameter : @@ -1127,22 +1295,21 @@ _dma_resource_alloc(unsigned int dma_size, unsigned int *dma_offset) _dma_pool.offset += dma_size; return 0; } +#endif static int -_dma_resource_get(int inst_id, phys_addr_t *cpu_pbase, phys_addr_t *dma_pbase, ssize_t* size) +_dma_resource_get(unsigned inst_id, phys_addr_t *cpu_pbase, phys_addr_t *dma_pbase, ssize_t* size) { - int i; unsigned int dma_size = 0, dma_offset = 0; bde_inst_resource_t *res; - for (i = 0; i < user_bde->num_devices(BDE_ALL_DEVICES); i++) { - res = &_bde_inst_resource[i]; - if (res->inst_id == inst_id) { - dma_size = res->dma_size; - dma_offset = res->dma_offset; - break; - } + if (inst_id >= user_bde->num_devices(BDE_ALL_DEVICES)) { + gprintk("ERROR: requested DMA resources for an instance number out of range: %u\n", inst_id); + return -1; } + res = &_bde_inst_resource[inst_id]; + dma_size = res->dma_size; + dma_offset = res->dma_offset; *cpu_pbase = _dma_pool.cpu_pbase + dma_offset * ONE_MB; *dma_pbase = _dma_pool.dma_pbase + dma_offset * ONE_MB; @@ -1151,28 +1318,49 @@ _dma_resource_get(int inst_id, phys_addr_t *cpu_pbase, phys_addr_t *dma_pbase, s return 0; } +#ifdef BCM_INSTANCE_SUPPORT +/* + * Checks if we have the instance in _bde_inst_resource. If not, return LUBDE_SUCCESS==0 (considered a new instance). + * If it exists with the same dmasize, return 1 (It is considered already in use) + * Otherwise if the device with the same index of the resource, has resource/instance index 0, return LUBDE_SUCCESS==0. (bug) + * Otherwise return LUBDE_FAIL==-1 (It is considered to exist with a different dmasize). + */ static int -_instance_validate(unsigned int inst_id, unsigned int dmasize) +_instance_validate(unsigned int inst_id, unsigned int dmasize, linux_bde_device_bitmap_t inst_devices) { - int i; - bde_inst_resource_t *res; + unsigned i; + uint32 bits; + bde_inst_resource_t *res = _bde_inst_resource + inst_id; + linux_bde_device_bitmap_t* bitmap_p; - for (i = 0; i < user_bde->num_devices(BDE_ALL_DEVICES); i++) { - res = &_bde_inst_resource[i]; - if (res->inst_id == inst_id) { - if (res->dma_size != dmasize) { - if(_devices[i].inst == 0){ - /* Skip _instance_validate (not init yet) */ - return LUBDE_SUCCESS; - } - gprintk("ERROR: dma_size mismatch\n"); - return LUBDE_FAIL; - } - return (1); + if (inst_id >= user_bde->num_devices(BDE_ALL_DEVICES)) { + gprintk("ERROR: instance number out of range: %u\n", inst_id); + return LUBDE_FAIL; + } + + if (res->is_active == 0) { + /* FIXME SDK-225233 check that the devices are not used by another active instance */ + return LUBDE_SUCCESS; + } + + bitmap_p = lkbde_get_inst_devs(inst_id); + for (i = 0; i < LINUX_BDE_NOF_DEVICE_BITMAP_WORDS; ++i) { + bits = inst_devices[i] ^ (*bitmap_p)[i]; + if (bits != 0) { + for (i *= 32; (bits & 1) == 0; bits >>= 1, ++i); + gprintk("ERROR: existing instance number %u does not control the same devices, see device %u\n", inst_id, i); + return LUBDE_FAIL; } } - return LUBDE_SUCCESS; + + if (res->dma_size == dmasize) { + return 1; /* For an existing same instance with the same DMA size, do nothing */ + } + /* with a different DMS size */ + gprintk("ERROR: dma_size mismatch\n"); + return LUBDE_FAIL; } +#endif static int _device_reprobe(void) @@ -1187,33 +1375,49 @@ _device_reprobe(void) return 0; } +#ifdef BCM_INSTANCE_SUPPORT +/* + * Attach an SDK instance: + * _device_reprobe(); + * Check If an instance with the same bitmap exists, if yes with the same dmasize, return, if yes a different dmasize return an error, if no: + * Allocate DMA for the instance. + * This loop finds the first free resource in _bde_inst_resource[] and configure it for the instance. + * Store the resource/instance index in _bde_inst_resource for every device in the instance. + */ static int -_instance_attach(unsigned int inst_id, unsigned int dma_size) +_instance_attach(unsigned int inst_id, unsigned int dma_size, linux_bde_device_bitmap_t inst_devices) { unsigned int dma_offset; int i, exist; bde_inst_resource_t *res; - int inst_idx = -1; - uint32 instid; + uint32 previous_inst_id; /* Reprobe the system for hot-plugged device */ _device_reprobe(); if (debug >= 2) { - gprintk("INFO: Request to attach to instance_id %d with dma size %d!\n", inst_id, dma_size); + gprintk("INFO: Request to attach to instance_id %u with dma size %d!\n", inst_id, dma_size); } spin_lock(&bde_resource_lock); - /* Validate the resource with inst_id */ - exist = _instance_validate(inst_id, dma_size); - if (exist < 0) { + /* If not in multi instance mode, move to the mode and fix the first instance that represented all devices */ + if (_bde_multi_inst == 0) { + _bde_multi_inst = 1; + _bde_inst_resource->is_active = 0; + /*_bde_inst_resource->dev will not be used when _bde_inst_resource->is_active == 0 */ + } + + /* Validate the resource with inst_devices */ + exist = _instance_validate(inst_id, dma_size, inst_devices); + + if (exist == LUBDE_FAIL) { spin_unlock(&bde_resource_lock); return LUBDE_FAIL; } if (exist > 0) { if (debug >= 2) { - gprintk("INFO: Already attached to instance_id %d with dma size %d!\n", inst_id, dma_size); + gprintk("INFO: Already attached to instance_id %u with dma size %d!\n", inst_id, dma_size); } spin_unlock(&bde_resource_lock); return LUBDE_SUCCESS; @@ -1222,38 +1426,59 @@ _instance_attach(unsigned int inst_id, unsigned int dma_size) spin_unlock(&bde_resource_lock); return LUBDE_FAIL; } - for (i = 0; i < user_bde->num_devices(BDE_ALL_DEVICES); i++) { - res = &_bde_inst_resource[i]; - if ((_bde_multi_inst == 0) || (res->inst_id == 0)) { - res->inst_id = inst_id; - res->dma_offset = dma_offset; - res->dma_size = dma_size; - _bde_multi_inst++; - inst_idx = i; - init_waitqueue_head(&res->intr_wq); - atomic_set(&res->intr, 0); - break; - } + + /* configure the instance ID resources */ + res = _bde_inst_resource + inst_id; + res->is_active = 1; + res->dma_offset = dma_offset; + res->dma_size = dma_size; +#ifdef SAI_FIXUP /* SDK-240875 */ + /* skip instance 0, WQ for instance 0 has been initialized in user_bde init, see _init() */ + if (inst_id != 0) { + init_waitqueue_head(&res->intr_wq); + init_waitqueue_head(&res->edk_intr_wq); + atomic_set(&res->intr, 0); + atomic_set(&res->edk_intr, 0); } +#endif + memcpy(*lkbde_get_inst_devs(inst_id), inst_devices, sizeof(linux_bde_device_bitmap_t)); /* SDK-225233 */ + /* store the resource/instance index in _bde_inst_resource for every device in the instance */ for (i = 0; i < user_bde->num_devices(BDE_ALL_DEVICES); i++) { - if (inst_id & (1 << i)) { - _devices[i].inst = inst_idx; - /* Pass the instid to the kernel BDE */ - if (lkbde_dev_instid_get(i, &instid) == 0) { - if (!instid) { + if (inst_devices[i / 32] & (1 << (i % 32))) { + _devices[i].inst = inst_id; + /* Pass the inst_id to the kernel BDE */ + if (lkbde_dev_instid_get(i, &previous_inst_id) == 0) { /* If the linux-kernel-bde inst_id is not set for the device, set it to the instance ID */ + if (previous_inst_id == BDE_DEV_INST_ID_INVALID) { lkbde_dev_instid_set(i, inst_id); } - } + } /* TODO handle the case where the device is marked belonging to a different instance */ } } spin_unlock(&bde_resource_lock); if (debug >= 2) { - gprintk("INFO: Attached to instance_id %d with dma size %d! SUCCESS\n", inst_id, dma_size); + gprintk("INFO: Attached to instance_id %lu with dma size %d! SUCCESS\n", (unsigned long)inst_devices, dma_size); } return LUBDE_SUCCESS; } +#endif /* BCM_INSTANCE_SUPPORT */ + +#ifdef BDE_EDK_SUPPORT +static int +_edk_instance_attach(unsigned int inst_id, unsigned int dma_size) +{ + ssize_t size = (ssize_t)dma_size; + if (size) { + lkbde_edk_get_dma_info(inst_id, NULL, NULL, &size); + if (!size) { + gprintk("Error: EDK Attached to instance_id %lu failed\n", (unsigned long)inst_id); + return LUBDE_FAIL; + } + } + return LUBDE_SUCCESS; +} +#endif /* * Function: _ioctl @@ -1273,7 +1498,7 @@ _ioctl(unsigned int cmd, unsigned long arg) phys_addr_t cpu_pbase, dma_pbase; ssize_t size; const ibde_dev_t *bde_dev; - int inst_id; + int inst_id, idx; bde_inst_resource_t *res; uint32_t *mapaddr; @@ -1341,10 +1566,19 @@ _ioctl(unsigned int cmd, unsigned long arg) case LUBDE_GET_DMA_INFO: inst_id = io.dev; if (_bde_multi_inst){ - _dma_resource_get(inst_id, &cpu_pbase, &dma_pbase, &size); + if (_dma_resource_get(inst_id, &cpu_pbase, &dma_pbase, &size)) { + io.rc = LUBDE_FAIL; + } } else { lkbde_get_dma_info(&cpu_pbase, &dma_pbase, &size); } +#ifdef BDE_EDK_SUPPORT + case LUBDE_GET_EDK_DMA_INFO: + if (cmd == LUBDE_GET_EDK_DMA_INFO) { + inst_id = io.dev; + lkbde_edk_get_dma_info(inst_id, &cpu_pbase, &dma_pbase, &size); + } +#endif io.d0 = dma_pbase; io.d1 = size; /* Optionally enable DMA mmap via /dev/linux-kernel-bde */ @@ -1365,14 +1599,6 @@ _ioctl(unsigned int cmd, unsigned long arg) } if (_devices[io.dev].dev_type & BDE_SWITCH_DEV_TYPE) { if (_devices[io.dev].isr && !_devices[io.dev].enabled) { - bde_ctrl_t *ctrl; - ctrl = &_devices[io.dev]; - if ((ctrl->isr == (isr_f)_cmicx_interrupt) && - (ctrl->dev_type & BDE_PCI_DEV_TYPE)) { - /* Set MSI mode to SW clear vs auto clear */ - WRITE_INTC_INTR(io.dev, ctrl->intr_regs.intc_intr_clear_mode_0, 0x0); - WRITE_INTC_INTR(io.dev, ctrl->intr_regs.intc_intr_clear_mode_1, 0x0); - } user_bde->interrupt_connect(io.dev, _devices[io.dev].isr, _devices+io.dev); @@ -1398,6 +1624,32 @@ _ioctl(unsigned int cmd, unsigned long arg) _devices[io.dev].enabled = 0; } break; + case LUBDE_SET_EDK_INTERRUPTS: + if (!VALID_DEVICE(io.dev)) { + return -EINVAL; + } + res = &_bde_inst_resource[_devices[io.dev].inst]; + res->edk_irqs.timer_intrc_offset = io.d0; + res->edk_irqs.timer_intrc_mask = io.d1; + res->edk_irqs.sw_intr_intrc_offset = io.d2; + res->edk_irqs.sw_intr_intrc_mask = io.d3; + res->edk_irqs.sw_intr_src_bitmap = io.dx.dw[0]; + for (idx = 0; idx < MAX_UC_CORES; idx++) { + res->edk_irqs.sw_intr_icfg_reg[idx] = io.dx.dw[idx + 1]; + } + break; + case LUBDE_ENABLE_EDK_INTERRUPTS: + if (!VALID_DEVICE(io.dev)) { + return -EINVAL; + } + _devices[io.dev].edk_irq_enabled = 1; + break; + case LUBDE_DISABLE_EDK_INTERRUPTS: + if (!VALID_DEVICE(io.dev)) { + return -EINVAL; + } + _devices[io.dev].edk_irq_enabled = 0; + break; case LUBDE_WAIT_FOR_INTERRUPT: if (!VALID_DEVICE(io.dev)) { return -EINVAL; @@ -1409,8 +1661,34 @@ _ioctl(unsigned int cmd, unsigned long arg) atomic_read(&res->intr) != 0, 100); #else - wait_event_interruptible(res->intr_wq, - atomic_read(&res->intr) != 0); + /* CMICX Devices */ + if ((_devices[io.dev].dev_type & BDE_PCI_DEV_TYPE) && + (_devices[io.dev].isr == (isr_f)_cmicx_interrupt) && + (intr_timeout > 0)) { + unsigned long t_jiffies; + int err=0; + t_jiffies = msecs_to_jiffies(intr_timeout); + err = wait_event_interruptible_timeout(res->intr_wq, + atomic_read(&res->intr) != 0, + t_jiffies); + /* Timeout happend and condition not set */ + if (err == 0) { + bde_ctrl_t *ctrl; + ctrl = &_devices[io.dev]; + intr_timeout_count++; + if (debug >= 1) { + gprintk("Timeout happend and condition not set\n"); + } + dump_interrupt_regs(ctrl, io.dev); + } else if (err == -ERESTARTSYS) { + if (debug >= 1) { + gprintk("Interrupted by Signal\n"); + } + } + } else { + wait_event_interruptible(res->intr_wq, + atomic_read(&res->intr) != 0); + } #endif /* * Even if we get multiple interrupts, we @@ -1424,14 +1702,56 @@ _ioctl(unsigned int cmd, unsigned long arg) #else wait_event_interruptible(_ether_interrupt_wq, atomic_read(&_ether_interrupt_has_taken_place) != 0); + #endif /* - * Even if we get multiple interrupts, we + * Even if we get multiple interrupts, we * only run the interrupt handler once. */ atomic_set(&_ether_interrupt_has_taken_place, 0); } break; + case LUBDE_WAIT_FOR_EDK_INTERRUPT: + if (!VALID_DEVICE(io.dev)) { + return -EINVAL; + } + res = &_bde_inst_resource[_devices[io.dev].inst]; +#ifdef BDE_LINUX_NON_INTERRUPTIBLE + wait_event_timeout(res->edk_intr_wq, + atomic_read(&res->edk_intr) != 0, 100); + +#else + /* CMICX Devices */ + if ((_devices[io.dev].dev_type & BDE_PCI_DEV_TYPE) && + (_devices[io.dev].isr == (isr_f)_cmicx_interrupt) && + (intr_timeout > 0)) { + unsigned long t_jiffies; + int err = 0; + t_jiffies = msecs_to_jiffies(intr_timeout); + err = wait_event_interruptible_timeout(res->edk_intr_wq, + atomic_read(&res->edk_intr) != 0, t_jiffies); + /* Timeout happend and condition not set */ + if (err == 0) { + bde_ctrl_t *ctrl; + ctrl = &_devices[io.dev]; + intr_timeout_count++; + if (debug >= 1) { + gprintk("EDK Interrrupt: Timeout happened\n"); + } + dump_interrupt_regs(ctrl, io.dev); + } else if (err == -ERESTARTSYS) { + if (debug >= 1) { + gprintk("EDK Interrrupt: Interrupted by Signal\n"); + } + } + } else { + wait_event_interruptible(res->edk_intr_wq, atomic_read(&res->edk_intr) != 0); + } +#endif + /* Even if we get multiple interrupts, we + * only run the interrupt handler once. */ + atomic_set(&res->edk_intr, 0); + break; case LUBDE_USLEEP: case LUBDE_UDELAY: case LUBDE_SEM_OP: @@ -1487,7 +1807,7 @@ _ioctl(unsigned int cmd, unsigned long arg) if (BDE_DEV_MEM_MAPPED(_devices[io.dev].dev_type)) { /* Get physical address to map */ io.rc = lkbde_get_dev_resource(io.dev, io.d0, - &io.d1, &io.d2, &io.d3); + &io.d2, &io.d3, &io.d1); } } else { io.rc = LUBDE_FAIL; @@ -1517,9 +1837,16 @@ _ioctl(unsigned int cmd, unsigned long arg) io.rc = LUBDE_FAIL; } break; +#ifdef BDE_EDK_SUPPORT + case LUBDE_ATTACH_EDK_INSTANCE: + io.rc = _edk_instance_attach(io.d0, io.d1); + break; +#endif +#ifdef BCM_INSTANCE_SUPPORT case LUBDE_ATTACH_INSTANCE: - io.rc = _instance_attach(io.d0, io.d1); + io.rc = _instance_attach(io.d0, io.d1, io.dx.dw); break; +#endif case LUBDE_GET_DEVICE_STATE: io.rc = lkbde_dev_state_get(io.dev, &io.d0); break; diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/linux-user-bde.h b/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/linux-user-bde.h index 535ccac9fad9..4bd4b746c521 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/linux-user-bde.h +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/linux-user-bde.h @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: linux-user-bde.h,v 1.23 Broadcom SDK $ @@ -45,7 +56,7 @@ typedef struct { unsigned int d3; bde_kernel_addr_t p0; union { - unsigned int dw[2]; + uint32_t dw[16]; unsigned char buf[64]; } dx; } lubde_ioctl_t; @@ -54,34 +65,41 @@ typedef struct { /* LUBDE ioctls */ #define LUBDE_MAGIC 'L' -#define LUBDE_VERSION _IO(LUBDE_MAGIC, 0) -#define LUBDE_GET_NUM_DEVICES _IO(LUBDE_MAGIC, 1) -#define LUBDE_GET_DEVICE _IO(LUBDE_MAGIC, 2) -#define LUBDE_PCI_CONFIG_PUT32 _IO(LUBDE_MAGIC, 3) -#define LUBDE_PCI_CONFIG_GET32 _IO(LUBDE_MAGIC, 4) -#define LUBDE_GET_DMA_INFO _IO(LUBDE_MAGIC, 5) -#define LUBDE_ENABLE_INTERRUPTS _IO(LUBDE_MAGIC, 6) -#define LUBDE_DISABLE_INTERRUPTS _IO(LUBDE_MAGIC, 7) -#define LUBDE_USLEEP _IO(LUBDE_MAGIC, 8) -#define LUBDE_WAIT_FOR_INTERRUPT _IO(LUBDE_MAGIC, 9) -#define LUBDE_SEM_OP _IO(LUBDE_MAGIC, 10) -#define LUBDE_UDELAY _IO(LUBDE_MAGIC, 11) -#define LUBDE_GET_DEVICE_TYPE _IO(LUBDE_MAGIC, 12) -#define LUBDE_SPI_READ_REG _IO(LUBDE_MAGIC, 13) -#define LUBDE_SPI_WRITE_REG _IO(LUBDE_MAGIC, 14) -#define LUBDE_READ_REG_16BIT_BUS _IO(LUBDE_MAGIC, 19) -#define LUBDE_WRITE_REG_16BIT_BUS _IO(LUBDE_MAGIC, 20) -#define LUBDE_GET_BUS_FEATURES _IO(LUBDE_MAGIC, 21) -#define LUBDE_WRITE_IRQ_MASK _IO(LUBDE_MAGIC, 22) -#define LUBDE_CPU_WRITE_REG _IO(LUBDE_MAGIC, 23) -#define LUBDE_CPU_READ_REG _IO(LUBDE_MAGIC, 24) -#define LUBDE_CPU_PCI_REGISTER _IO(LUBDE_MAGIC, 25) -#define LUBDE_DEV_RESOURCE _IO(LUBDE_MAGIC, 26) -#define LUBDE_IPROC_READ_REG _IO(LUBDE_MAGIC, 27) -#define LUBDE_IPROC_WRITE_REG _IO(LUBDE_MAGIC, 28) -#define LUBDE_ATTACH_INSTANCE _IO(LUBDE_MAGIC, 29) -#define LUBDE_GET_DEVICE_STATE _IO(LUBDE_MAGIC, 30) -#define LUBDE_REPROBE _IO(LUBDE_MAGIC, 31) +#define LUBDE_VERSION _IO(LUBDE_MAGIC, 0) +#define LUBDE_GET_NUM_DEVICES _IO(LUBDE_MAGIC, 1) +#define LUBDE_GET_DEVICE _IO(LUBDE_MAGIC, 2) +#define LUBDE_PCI_CONFIG_PUT32 _IO(LUBDE_MAGIC, 3) +#define LUBDE_PCI_CONFIG_GET32 _IO(LUBDE_MAGIC, 4) +#define LUBDE_GET_DMA_INFO _IO(LUBDE_MAGIC, 5) +#define LUBDE_ENABLE_INTERRUPTS _IO(LUBDE_MAGIC, 6) +#define LUBDE_DISABLE_INTERRUPTS _IO(LUBDE_MAGIC, 7) +#define LUBDE_USLEEP _IO(LUBDE_MAGIC, 8) +#define LUBDE_WAIT_FOR_INTERRUPT _IO(LUBDE_MAGIC, 9) +#define LUBDE_SEM_OP _IO(LUBDE_MAGIC, 10) +#define LUBDE_UDELAY _IO(LUBDE_MAGIC, 11) +#define LUBDE_GET_DEVICE_TYPE _IO(LUBDE_MAGIC, 12) +#define LUBDE_SPI_READ_REG _IO(LUBDE_MAGIC, 13) +#define LUBDE_SPI_WRITE_REG _IO(LUBDE_MAGIC, 14) +#define LUBDE_READ_REG_16BIT_BUS _IO(LUBDE_MAGIC, 19) +#define LUBDE_WRITE_REG_16BIT_BUS _IO(LUBDE_MAGIC, 20) +#define LUBDE_GET_BUS_FEATURES _IO(LUBDE_MAGIC, 21) +#define LUBDE_WRITE_IRQ_MASK _IO(LUBDE_MAGIC, 22) +#define LUBDE_CPU_WRITE_REG _IO(LUBDE_MAGIC, 23) +#define LUBDE_CPU_READ_REG _IO(LUBDE_MAGIC, 24) +#define LUBDE_CPU_PCI_REGISTER _IO(LUBDE_MAGIC, 25) +#define LUBDE_DEV_RESOURCE _IO(LUBDE_MAGIC, 26) +#define LUBDE_IPROC_READ_REG _IO(LUBDE_MAGIC, 27) +#define LUBDE_IPROC_WRITE_REG _IO(LUBDE_MAGIC, 28) +#define LUBDE_ATTACH_INSTANCE _IO(LUBDE_MAGIC, 29) +#define LUBDE_GET_DEVICE_STATE _IO(LUBDE_MAGIC, 30) +#define LUBDE_REPROBE _IO(LUBDE_MAGIC, 31) +#define LUBDE_SET_EDK_INTERRUPTS _IO(LUBDE_MAGIC, 32) +#define LUBDE_ENABLE_EDK_INTERRUPTS _IO(LUBDE_MAGIC, 33) +#define LUBDE_DISABLE_EDK_INTERRUPTS _IO(LUBDE_MAGIC, 34) +#define LUBDE_WAIT_FOR_EDK_INTERRUPT _IO(LUBDE_MAGIC, 35) +#define LUBDE_ATTACH_EDK_INSTANCE _IO(LUBDE_MAGIC, 36) +#define LUBDE_GET_EDK_DMA_INFO _IO(LUBDE_MAGIC, 37) + #define LUBDE_SEM_OP_CREATE 1 #define LUBDE_SEM_OP_DESTROY 2 diff --git a/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde.h b/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde.h index 53003a40ce53..2d0651191fbb 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde.h +++ b/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde.h @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_iproc.h b/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_iproc.h index 4b614ba53139..4b71b8f16ee3 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_iproc.h +++ b/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_iproc.h @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_mdio.h b/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_mdio.h index 5f8fa63533f4..a51dd2ac6f5f 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_mdio.h +++ b/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_mdio.h @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_pci.h b/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_pci.h index 1f045d7b02c8..a0b88494823f 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_pci.h +++ b/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_pci.h @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_iproc.c b/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_iproc.c index 087720a20a8b..ca8024c78a32 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_iproc.c +++ b/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_iproc.c @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: $ @@ -292,12 +303,19 @@ shbde_iproc_paxb_init(shbde_hal_t *shbde, void *iproc_regs, /* Configure MSIX interrupt page, need for iproc ver 0x10 and 0x12 */ if ((icfg->use_msi == 2) && - ((icfg->iproc_ver == 0x10) || (icfg->iproc_ver == 0x12))){ + ((icfg->iproc_ver == 0x10) + || (icfg->iproc_ver == 0x12) + || (icfg->iproc_ver == 0x11))){ unsigned int mask = (0x1 << PAXB_0_FUNC0_IMAP1_3_ADDR_SHIFT) - 1; reg = ROFFS(iproc_regs, PAXB_0_FUNC0_IMAP1_3); data = iproc32_read(shbde, reg); data &= mask; - data |= 0x410 << PAXB_0_FUNC0_IMAP1_3_ADDR_SHIFT; + if (icfg->iproc_ver == 0x11) { + data |= 0x400 << PAXB_0_FUNC0_IMAP1_3_ADDR_SHIFT; + } else { + data |= 0x410 << PAXB_0_FUNC0_IMAP1_3_ADDR_SHIFT; + } + iproc32_write(shbde, reg, data); } diff --git a/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_mdio.c b/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_mdio.c index ef4a72071b33..1e38eb024adc 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_mdio.c +++ b/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_mdio.c @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_pci.c b/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_pci.c index 5cc46d0d463d..8e64b475a41f 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_pci.c +++ b/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_pci.c @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/Makefile b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/Makefile index 448b4b9a9310..b599580ae861 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/Makefile @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # -*- Makefile -*- # $Id: Makefile,v 1.10 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-knet/Makefile b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-knet/Makefile index a3f430a6a903..9879be69b0b6 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-knet/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-knet/Makefile @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # -*- Makefile -*- # $Id: Makefile,v 1.3 Broadcom SDK $ 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 a9eda27ad4d5..a3f92b17584b 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 @@ -60,10 +60,6 @@ #include #include -#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,16,0) -#include -#endif - #include #include #include @@ -222,6 +218,7 @@ MODULE_PARM_DESC(ft_vid, #define DBG_LVL_DCB_RX 0x20000 #define DBG_LVL_PDMP_TX 0x40000 #define DBG_LVL_PDMP_RX 0x80000 +#define DBG_LVL_PTP 0x100000 #define DBG_VERB(_s) do { if (debug & DBG_LVL_VERB) gprintk _s; } while (0) #define DBG_PKT(_s) do { if (debug & DBG_LVL_PKT) gprintk _s; } while (0) @@ -245,6 +242,7 @@ MODULE_PARM_DESC(ft_vid, #define DBG_DCB(_s) do { if (debug & (DBG_LVL_DCB|DBG_LVL_DCB_TX| \ DBG_LVL_DCB_RX)) \ gprintk _s; } while (0) +#define DBG_PTP(_s) do { if (debug & DBG_LVL_PTP) gprintk _s; } while (0) /* This flag is used to indicate if debugging packet function is open or closed */ @@ -499,6 +497,12 @@ static inline void bkn_skb_tx_timestamp(struct sk_buff *skb) #define BKN_DMA_MAPPING_ERROR(d,a) bkn_pci_dma_mapping_error(d,a) #endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) +#define BKN_NETDEV_TX_BUSY NETDEV_TX_BUSY +#else +#define BKN_NETDEV_TX_BUSY 1 +#endif + /* * Get a 16-bit value from packet offset * _data Pointer to packet @@ -672,6 +676,8 @@ typedef struct bkn_switch_info_s { } rx[NUM_RX_CHAN]; } bkn_switch_info_t; +#define INVALID_INSTANCE_ID BDE_DEV_INST_ID_INVALID + /* 0x1 - Jericho 2 mode */ #define BKN_DNX_JR2_MODE 1 /* PTCH_2 */ @@ -936,13 +942,6 @@ typedef struct bkn_filter_s { kcom_filter_t kf; } bkn_filter_t; -#ifdef SAI_FIXUP /* SDK-224448 */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) -#define BKN_NETDEV_TX_BUSY NETDEV_TX_BUSY -#else -#define BKN_NETDEV_TX_BUSY 1 -#endif -#endif /* SDK-224448 */ /* * Multiple instance support in KNET @@ -1071,6 +1070,7 @@ bkn_sleep(int clicks) #define DEV_IS_CMICX(_sinfo) ((_sinfo)->cmic_type == 'x') #define DEV_IS_CMICM(_sinfo) ((_sinfo)->cmic_type == 'm') +#define DEV_IS_CMIC(_sinfo) ((_sinfo)->cmic_type != 0) #define CDMA_CH(_d, _ch) ((_d)->cdma_channels & (1 << (_ch))) /* @@ -2125,12 +2125,13 @@ bkn_api_rx_chain_done(bkn_switch_info_t *sinfo, int chan) static int bkn_api_rx_copy_from_skb(bkn_switch_info_t *sinfo, - int chan, bkn_desc_info_t *desc) + int chan, bkn_desc_info_t *desc, int rx_hwts) { bkn_dcb_chain_t *dcb_chain; uint32_t *dcb; uint32_t dcb_stat; uint8_t *pkt; + uint8_t *skb_pkt; uint64_t pkt_dma; int pktlen; int i; @@ -2168,8 +2169,18 @@ bkn_api_rx_copy_from_skb(bkn_switch_info_t *sinfo, return -1; } + skb_pkt = desc->skb->data; + + /* Strip custom header from KNETSync packets. */ + if ((rx_hwts) && + ((skb_pkt[0] == 'B') && (skb_pkt[1] == 'C') && + (skb_pkt[2] == 'M') && (skb_pkt[3] == 'C'))) { + + skb_pkt = skb_pkt + skb_pkt[4]; + } + /* Copy packet data */ - memcpy(pkt, desc->skb->data, pktlen); + memcpy(pkt, skb_pkt, pktlen); /* Copy packet metadata and mark as done */ if (sinfo->cmic_type != 'x') { @@ -2235,11 +2246,11 @@ bkn_rx_refill(bkn_switch_info_t *sinfo, int chan) while (sinfo->rx[chan].free < MAX_RX_DCBS) { desc = &sinfo->rx[chan].desc[sinfo->rx[chan].cur]; if (desc->skb == NULL) { - skb = dev_alloc_skb(rx_buffer_size + RCPU_RX_ENCAP_SIZE); + skb = dev_alloc_skb(rx_buffer_size + SKB_DATA_ALIGN(resv_size)); if (skb == NULL) { break; } - skb_reserve(skb, resv_size); + skb_reserve(skb, SKB_DATA_ALIGN(resv_size)); desc->skb = skb; } else { DBG_DCB_RX(("Refill Rx%d SKB in DCB %d recycled.\n", @@ -3832,6 +3843,11 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) while (dcbs_done < budget) { char str[32]; + + if (!sinfo->rx[chan].running) { + /* DCBs might be cleaned up when bkn_knet_hw_reset is triggered. */ + return 0; + } sprintf(str, "Rx DCB (%d)", sinfo->rx[chan].dirty); desc = &sinfo->rx[chan].desc[sinfo->rx[chan].dirty]; dcb = desc->dcb_mem; @@ -3850,6 +3866,12 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) sinfo->rx[chan].pkts++; skb = desc->skb; + DBG_DCB_RX(("Rx%d SKB DMA done (%d).\n", chan, sinfo->rx[chan].dirty)); + BKN_DMA_UNMAP_SINGLE(sinfo->dma_dev, + desc->skb_dma, desc->dma_size, + BKN_DMA_FROMDEV); + desc->skb_dma = 0; + if (device_is_sand(sinfo)) { err_woff = BKN_SAND_SCRATCH_DATA_SIZE - 1; sand_scratch_data[err_woff] = dcb[sinfo->dcb_wsize-1]; @@ -3868,11 +3890,6 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) pktlen = dcb[sinfo->dcb_wsize-1] & 0xffff; priv = netdev_priv(sinfo->dev); - DBG_DCB_RX(("Rx%d SKB DMA done (%d).\n", chan, sinfo->rx[chan].dirty)); - BKN_DMA_UNMAP_SINGLE(sinfo->dma_dev, - desc->skb_dma, desc->dma_size, - BKN_DMA_FROMDEV); - desc->skb_dma = 0; bkn_dump_pkt(skb->data, pktlen, XGS_DMA_RX_CHAN); if (device_is_sand(sinfo)) { @@ -3945,7 +3962,7 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) case KCOM_DEST_T_API: DBG_FLTR(("Send to Rx API\n")); sinfo->rx[chan].pkts_f_api++; - bkn_api_rx_copy_from_skb(sinfo, chan, desc); + bkn_api_rx_copy_from_skb(sinfo, chan, desc, 0); break; case KCOM_DEST_T_NETIF: priv = bkn_netif_lookup(sinfo, filter->kf.dest_id); @@ -3961,7 +3978,7 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) if ((filter->kf.mirror_type == KCOM_DEST_T_API) || dbg_pkt_enable) { sinfo->rx[chan].pkts_m_api++; - bkn_api_rx_copy_from_skb(sinfo, chan, desc); + bkn_api_rx_copy_from_skb(sinfo, chan, desc, priv->rx_hwts); } if (device_is_sand(sinfo)) { @@ -4095,6 +4112,9 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) } } + /* Ensure that we reallocate SKB for this DCB */ + desc->skb = NULL; + /* Unlock while calling up network stack */ spin_unlock(&sinfo->lock); if (use_napi) { @@ -4104,8 +4124,6 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) } spin_lock(&sinfo->lock); - /* Ensure that we reallocate SKB for this DCB */ - desc->skb = NULL; } else { DBG_FLTR(("Unknown netif %d\n", filter->kf.dest_id)); @@ -4299,11 +4317,28 @@ bkn_hw_tstamp_tx_work(struct work_struct *work) { bkn_switch_info_t *sinfo = container_of(work, bkn_switch_info_t, tx_ptp_work); struct sk_buff *skb; + int ret; while (skb_queue_len(&sinfo->tx_ptp_queue)) { skb = skb_dequeue(&sinfo->tx_ptp_queue); - if (bkn_hw_tstamp_tx_set(sinfo, skb) < 0) { - gprintk("Timestamp has not been taken for the current skb.\n"); + ret = bkn_hw_tstamp_tx_set(sinfo, skb); + if (ret < 0) { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) + ktime_t now; + now = ktime_get(); + DBG_PTP(("2Step TX Timestamp has not been taken for the current skb (%lld us)\n", + ktime_us_delta(now, skb->tstamp))); + } else { + ktime_t now; + now = ktime_get(); + /* Timeout 20 should be same as configured by PTP4L */ + if (ktime_us_delta(now, skb->tstamp) >= 20000) { + DBG_PTP(("2Step TX Timestamp fetch took long time %lld us\n", + ktime_us_delta(now, skb->tstamp))); + } +#else + DBG_PTP(("2Step TX Timestamp has not been taken for the current skb\n")); +#endif } dev_kfree_skb_any(skb); } @@ -4346,6 +4381,9 @@ bkn_do_tx(bkn_switch_info_t *sinfo) } if (bkn_skb_tx_flags(desc->skb) & SKBTX_IN_PROGRESS) { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) + desc->skb->tstamp = ktime_get(); +#endif skb_queue_tail(&sinfo->tx_ptp_queue, desc->skb); schedule_work(&sinfo->tx_ptp_work); } else { @@ -5310,6 +5348,7 @@ bkn_hw_tstamp_tx_config(bkn_switch_info_t *sinfo, case 26: case 32: case 33: + case 35: meta[2] |= md[0]; meta[3] |= md[1]; meta[4] |= md[2]; @@ -5342,6 +5381,7 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) uint32_t *metadata; unsigned long flags; uint32_t cpu_channel = 0; + int headroom, tailroom; DBG_VERB(("Netif Tx: Len=%d priv->id=%d\n", skb->len, priv->id)); @@ -5449,7 +5489,16 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) if (skb_header_cloned(skb)) { /* Current SKB cannot be modified */ DBG_SKB(("Realloc Tx SKB\n")); - new_skb = dev_alloc_skb(pktlen + TAG_SZ + FCS_SZ); + /* + * New SKB needs extra TAG_SZ for VLAN tag + * and extra FCS_SZ for Ethernet FCS. + */ + headroom = TAG_SZ; + tailroom = FCS_SZ; + new_skb = skb_copy_expand(skb, + headroom + skb_headroom(skb), + tailroom + skb_tailroom(skb), + GFP_ATOMIC); if (new_skb == NULL) { DBG_WARN(("Tx drop: No SKB memory\n")); priv->stats.tx_dropped++; @@ -5458,9 +5507,12 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) spin_unlock_irqrestore(&sinfo->lock, flags); return 0; } + /* Remove rcpulen from buffer. */ + skb_pull(new_skb, rcpulen); + /* Extended by TAG_SZ at the start of buffer. */ + skb_push(new_skb, TAG_SZ); + /* Restore the data before the tag. */ memcpy(new_skb->data, pktdata, 12); - memcpy(&new_skb->data[16], &pktdata[12], pktlen - 12); - skb_put(new_skb, pktlen + TAG_SZ); bkn_skb_tstamp_copy(new_skb, skb); dev_kfree_skb_any(skb); skb = new_skb; @@ -5489,7 +5541,16 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) if (skb_header_cloned(skb) || skb_headroom(skb) < hdrlen + 4) { /* Current SKB cannot be modified */ DBG_SKB(("Realloc Tx SKB\n")); - new_skb = dev_alloc_skb(pktlen + hdrlen + 4 + FCS_SZ); + if (device_is_sand(sinfo)) { + headroom = hdrlen; + } else { + headroom = hdrlen + 4; + } + tailroom = FCS_SZ; + new_skb = skb_copy_expand(skb, + headroom + skb_headroom(skb), + tailroom + skb_tailroom(skb), + GFP_ATOMIC); if (new_skb == NULL) { DBG_WARN(("Tx drop: No SKB memory\n")); priv->stats.tx_dropped++; @@ -5498,12 +5559,7 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) spin_unlock_irqrestore(&sinfo->lock, flags); return 0; } - if (!device_is_sand(sinfo)) - { - skb_reserve(new_skb, 4); - } - memcpy(new_skb->data + hdrlen, skb->data, pktlen); - skb_put(new_skb, pktlen + hdrlen); + skb_push(new_skb, hdrlen); bkn_skb_tstamp_copy(new_skb, skb); dev_kfree_skb_any(skb); skb = new_skb; @@ -5526,7 +5582,12 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) if (skb_header_cloned(skb) || skb_headroom(skb) < 4) { /* Current SKB cannot be modified */ DBG_SKB(("Realloc Tx SKB\n")); - new_skb = dev_alloc_skb(pktlen + TAG_SZ + FCS_SZ); + headroom = TAG_SZ; + tailroom = FCS_SZ; + new_skb = skb_copy_expand(skb, + headroom + skb_headroom(skb), + tailroom + skb_tailroom(skb), + GFP_ATOMIC); if (new_skb == NULL) { DBG_WARN(("Tx drop: No SKB memory\n")); priv->stats.tx_dropped++; @@ -5535,10 +5596,8 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) spin_unlock_irqrestore(&sinfo->lock, flags); return 0; } - memcpy(new_skb->data, skb->data, hdrlen + 12); - memcpy(&new_skb->data[hdrlen + 16], &skb->data[hdrlen + 12], - pktlen - hdrlen - 12); - skb_put(new_skb, pktlen + TAG_SZ); + skb_push(new_skb, TAG_SZ); + memcpy(new_skb->data, pktdata, hdrlen + 12); bkn_skb_tstamp_copy(new_skb, skb); dev_kfree_skb_any(skb); skb = new_skb; @@ -5868,24 +5927,11 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) priv->stats.tx_bytes += pktlen; sinfo->tx.pkts++; } else { -#ifdef SAI_FIXUP /* SDK-224448 */ DBG_VERB(("Tx busy: No DMA resources\n")); sinfo->tx.pkts_d_dma_resrc++; -#else - DBG_WARN(("Tx drop: No DMA resources\n")); - priv->stats.tx_dropped++; - sinfo->tx.pkts_d_dma_resrc++; - dev_kfree_skb_any(skb); - } - - /* Check our Tx resources */ - if (sinfo->tx.free <= 1) { -#endif /* SDK-224448 */ bkn_suspend_tx(sinfo); -#ifdef SAI_FIXUP /* SDK-224448 */ spin_unlock_irqrestore(&sinfo->lock, flags); return BKN_NETDEV_TX_BUSY; -#endif /* SDK-224448 */ } NETDEV_UPDATE_TRANS_START_TIME(dev); @@ -6105,6 +6151,7 @@ bkn_create_sinfo(int dev_no) sinfo->dma_dev = lkbde_get_dma_dev(dev_no); sinfo->pdev = lkbde_get_hw_dev(dev_no); sinfo->dev_no = dev_no; + sinfo->inst_id = INVALID_INSTANCE_ID; sinfo->evt_idx = -1; spin_lock_init(&sinfo->lock); @@ -6196,6 +6243,7 @@ bkn_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info) case 26: case 32: case 33: + case 35: case 36: case 38: case 40: @@ -6292,10 +6340,6 @@ bkn_init_ndev(u8 *mac, char *name) if (dev->mtu == 0) { 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 /* Device vectors */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) @@ -7296,9 +7340,9 @@ bkn_proc_cleanup(void) */ static int -_pprint(void) +_pprint(struct seq_file *m) { - pprintf("Broadcom BCM KNET Linux Network Driver\n"); + pprintf(m, "Broadcom BCM KNET Linux Network Driver\n"); return 0; } @@ -7460,7 +7504,7 @@ bkn_create_inst(uint32 inst_id) DBG_INST(("%s evt_idx %d inst_id 0x%x\n",__FUNCTION__, i, inst_id)); break; } - if ((_bkn_multi_inst == 0) || (evt->inst_id == 0)) { + if ((_bkn_multi_inst == 0) || (evt->inst_id == INVALID_INSTANCE_ID)) { _bkn_multi_inst ++; evt_idx = i; init_waitqueue_head(&evt->evt_wq); @@ -7475,7 +7519,7 @@ bkn_create_inst(uint32 inst_id) return -1; } for (i = 0; i < kernel_bde->num_devices(BDE_ALL_DEVICES); i++) { - if (inst_id & (1 << i)) { + if (lkbde_is_dev_managed_by_instance(i, inst_id)) { sinfo = bkn_sinfo_from_unit(i); spin_lock_irqsave(&sinfo->lock, flags); sinfo->evt_idx = evt_idx; @@ -7519,23 +7563,28 @@ bkn_knet_dev_inst_set(kcom_msg_reprobe_t *kmsg) { bkn_switch_info_t *sinfo; int d = kmsg->hdr.unit; - uint32 inst = 0; + uint32 inst = INVALID_INSTANCE_ID; unsigned long flags; struct list_head *list; sinfo = bkn_sinfo_from_unit(d); +#ifdef BCM_INSTANCE_SUPPORT lkbde_dev_instid_get(d, &inst); +#else + inst = INVALID_INSTANCE_ID; +#endif + DBG_INST(("%s sinfo->inst_id %d d %d inst %d\n",__FUNCTION__,sinfo->inst_id, d, inst)); spin_lock_irqsave(&sinfo->lock, flags); if (sinfo->inst_id != inst) { /* Instance database changed, reinit the inst_id */ - sinfo->inst_id = 0; + sinfo->inst_id = INVALID_INSTANCE_ID; sinfo->evt_idx = -1; } spin_unlock_irqrestore(&sinfo->lock, flags); - if (inst) { - if (sinfo->inst_id == 0) { + if (inst != INVALID_INSTANCE_ID) { + if (sinfo->inst_id == INVALID_INSTANCE_ID) { if (bkn_create_inst(inst) != 0) { return -1; } @@ -7549,7 +7598,7 @@ bkn_knet_dev_inst_set(kcom_msg_reprobe_t *kmsg) sinfo = (bkn_switch_info_t *)list; spin_lock_irqsave(&sinfo->lock, flags); sinfo->evt_idx = 0; - sinfo->inst_id = 0; + sinfo->inst_id = INVALID_INSTANCE_ID; spin_unlock_irqrestore(&sinfo->lock, flags); } } @@ -7880,16 +7929,16 @@ bkn_knet_netif_create(kcom_msg_netif_create_t *kmsg, int len) } } + DBG_VERB(("Assigned ID %d to Ethernet device %s\n", priv->id, dev->name)); kmsg->netif.id = priv->id; memcpy(kmsg->netif.macaddr, dev->dev_addr, 6); memcpy(kmsg->netif.name, dev->name, KCOM_NETIF_NAME_MAX - 1); - if (knet_netif_create_cb != NULL) { int retv = knet_netif_create_cb(kmsg->hdr.unit, &(kmsg->netif), dev); - if (retv) { + if (retv) { gprintk("Warning: knet_netif_create_cb() returned %d for netif '%s'\n", retv, dev->name); } } @@ -7947,6 +7996,7 @@ bkn_knet_netif_destroy(kcom_msg_netif_destroy_t *kmsg, int len) netif.id = priv->id; knet_netif_destroy_cb(kmsg->hdr.unit, &netif, priv->dev); } + list_del(&priv->list); if (priv->id < sinfo->ndev_max) { @@ -8473,8 +8523,8 @@ bkn_get_next_dma_event(kcom_msg_dma_info_t *kmsg) sinfo = bkn_sinfo_from_unit(dev_no); } - if (sinfo && (sinfo->inst_id != 0) && - ((sinfo->inst_id & (1 << dev_evt)) == 0)) { + if (sinfo && (sinfo->inst_id != INVALID_INSTANCE_ID) && + (!lkbde_is_dev_managed_by_instance(dev_evt, sinfo->inst_id))) { DBG_INST((" %s skip dev(%d)\n",__FUNCTION__,dev_no)); continue; } @@ -8540,8 +8590,10 @@ _cleanup(void) del_timer_sync(&sinfo->rxtick); spin_lock_irqsave(&sinfo->lock, flags); - bkn_dma_abort(sinfo); - dev_irq_mask_set(sinfo, 0); + if (DEV_IS_CMIC(sinfo)) { + bkn_dma_abort(sinfo); + dev_irq_mask_set(sinfo, 0); + } spin_unlock_irqrestore(&sinfo->lock, flags); DBG_IRQ(("Unregister ISR.\n")); @@ -8759,6 +8811,7 @@ _init(void) /* Initialize event queue */ for (idx = 0; idx < LINUX_BDE_MAX_DEVICES; idx++) { memset(&_bkn_evt[idx], 0, sizeof(bkn_evt_resource_t)); + _bkn_evt[idx].inst_id = INVALID_INSTANCE_ID; } evt = &_bkn_evt[0]; init_waitqueue_head(&evt->evt_wq); diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-ptp-clock/Makefile b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-ptp-clock/Makefile index 1c9a3209e133..9aa3be686851 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-ptp-clock/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-ptp-clock/Makefile @@ -14,9 +14,9 @@ # version 2 (GPLv2) along with this source code. # # -*- Makefile -*- -# $Id: Makefile,v 1.3 Broadcom SDK $ -# $Copyright: (c) 2020 Broadcom. -# Broadcom Proprietary and Confidential. All rights reserved.$ +# $Id: Makefile,v 1.3 2012/07/17 07:39:51 mlarsen Exp $ +# $Copyright: (c) 2005 Broadcom Corp. +# All Rights Reserved.$ # LOCALDIR = systems/linux/kernel/modules/bcm-ptp-clock diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-ptp-clock/bcm-ptp-clock.c b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-ptp-clock/bcm-ptp-clock.c index 5b0a6bde738d..edc4a38c741c 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-ptp-clock/bcm-ptp-clock.c +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-ptp-clock/bcm-ptp-clock.c @@ -76,9 +76,13 @@ MODULE_PARM_DESC(fw_core, /* Debug levels */ #define DBG_LVL_VERB 0x1 #define DBG_LVL_WARN 0x2 +#define DBG_LVL_TXTS 0x4 +#define DBG_LVL_CMDS 0x8 #define DBG_VERB(_s) do { if (debug & DBG_LVL_VERB) gprintk _s; } while (0) #define DBG_WARN(_s) do { if (debug & DBG_LVL_WARN) gprintk _s; } while (0) +#define DBG_TXTS(_s) do { if (debug & DBG_LVL_TXTS) gprintk _s; } while (0) +#define DBG_CMDS(_s) do { if (debug & DBG_LVL_CMDS) gprintk _s; } while (0) #define DBG_ERR(_s) do { if (1) gprintk _s; } while (0) @@ -98,41 +102,37 @@ MODULE_PARM_DESC(fw_core, #define BKSYNC_PACKLEN_U24 3 #define BKSYNC_PACKLEN_U32 4 -#define BKSYNC_UNPACK_U8(_buf, _var) \ +#define BKSYNC_UNPACK_U8(_buf, _var) \ _var = *_buf++ -#define BKSYNC_UNPACK_U16(_buf, _var) \ +#define BKSYNC_UNPACK_U16(_buf, _var) \ do { \ (_var) = (((_buf)[0] << 8) | \ (_buf)[1]); \ - (_buf) += BKSYNC_PACKLEN_U16; \ + (_buf) += BKSYNC_PACKLEN_U16; \ } while (0) -#define BKSYNC_UNPACK_U24(_buf, _var) \ +#define BKSYNC_UNPACK_U24(_buf, _var) \ do { \ (_var) = (((_buf)[0] << 16) | \ ((_buf)[1] << 8) | \ (_buf)[2]); \ - (_buf) += BKSYNC_PACKLEN_U24; \ + (_buf) += BKSYNC_PACKLEN_U24; \ } while (0) -#define BKSYNC_UNPACK_U32(_buf, _var) \ +#define BKSYNC_UNPACK_U32(_buf, _var) \ do { \ (_var) = (((_buf)[0] << 24) | \ ((_buf)[1] << 16) | \ ((_buf)[2] << 8) | \ (_buf)[3]); \ - (_buf) += BKSYNC_PACKLEN_U32; \ + (_buf) += BKSYNC_PACKLEN_U32; \ } while (0) #define CMICX_DEV_TYPE ((ptp_priv->dcb_type == 38) || \ (ptp_priv->dcb_type == 36)) -#define HOSTCMD_USE_REGS ((ptp_priv->dcb_type == 38) || \ - (ptp_priv->dcb_type == 36) || \ - (ptp_priv->dcb_type == 32)) - /* CMIC MCS-0 SCHAN Messaging registers */ /* Core0:CMC1 Core1:CMC2 */ #define CMIC_CMC_BASE \ @@ -154,30 +154,58 @@ MODULE_PARM_DESC(fw_core, u32 hostcmd_regs[5] = { 0 }; -/* TX Timestamp FIFO Access */ -#define BCM_NUM_PORTS 128 +#define BCMKSYNC_NUM_PORTS 128 /* NUM_PORTS where 2-step is supported. */ +#define BCMKSYNC_MAX_NUM_PORTS 256 /* Max ever NUM_PORTS in the system */ +#define BCMKSYNC_MAX_MTP_IDX 8 /* Max number of mtps in the system */ -/* Service request commands to R5 */ +/* Service request commands to Firmware. */ enum { - BCM_KSYNC_DONE = 0x0, - BCM_KSYNC_INIT = 0x1, - BCM_KSYNC_DEINIT = 0x2, - BCM_KSYNC_GETTIME = 0x3, - BCM_KSYNC_SETTIME = 0x4, - BCM_KSYNC_FREQCOR = 0x5, - BCM_KSYNC_PBM_UPDATE = 0x6, - BCM_KSYNC_ADJTIME = 0x7, - BCM_KSYNC_GET_TSTIME = 0x8, + BKSYNC_DONE = (0x0), + BKSYNC_INIT = (0x1), + BKSYNC_DEINIT = (0x2), + BKSYNC_GETTIME = (0x3), + BKSYNC_SETTIME = (0x4), + BKSYNC_FREQCOR = (0x5), + BKSYNC_PBM_UPDATE = (0x6), + BKSYNC_ADJTIME = (0x7), + BKSYNC_GET_TSTIME = (0x8), + BKSYNC_MTP_TS_UPDATE_ENABLE = (0x9), + BKSYNC_MTP_TS_UPDATE_DISABLE = (0xa), + BKSYNC_ACK_TSTIME = (0xb), +}; + + +/* 1588 message types. */ +enum +{ + IEEE1588_MSGTYPE_SYNC = (0x0), + IEEE1588_MSGTYPE_DELREQ = (0x1), + IEEE1588_MSGTYPE_PDELREQ = (0x2), + IEEE1588_MSGTYPE_PDELRESP = (0x3), + /* reserved (0x4) */ + /* reserved (0x5) */ + /* reserved (0x6) */ + /* reserved (0x7) */ + IEEE1588_MSGTYPE_GENERALMASK = (0x8), /* all non-event messages have this bit set */ + IEEE1588_MSGTYPE_FLWUP = (0x8), + IEEE1588_MSGTYPE_DELRESP = (0x9), + IEEE1588_MSGTYPE_PDELRES_FLWUP = (0xA), + IEEE1588_MSGTYPE_ANNOUNCE = (0xB), + IEEE1588_MSGTYPE_SGNLNG = (0xC), + IEEE1588_MSGTYPE_MNGMNT = (0xD) + /* reserved (0xE) */ + /* reserved (0xF) */ }; /* Usage macros */ #define ONE_BILLION (1000000000) #define SKB_U16_GET(_skb, _pkt_offset) \ - ((_skb->data[_pkt_offset] << 8) | _skb->data[_pkt_offset + 1]) + ((_skb->data[_pkt_offset] << 8) | _skb->data[_pkt_offset + 1]) #define BKSYNC_PTP_EVENT_MSG(_ptp_msg_type) \ - ((_ptp_msg_type == DELAY_REQ) || (_ptp_msg_type == SYNC)) + ((_ptp_msg_type == IEEE1588_MSGTYPE_DELREQ) || \ + (_ptp_msg_type == IEEE1588_MSGTYPE_SYNC)) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) @@ -187,10 +215,6 @@ enum { #endif -/* Values for the messageType field */ -#define SYNC 0x0 -#define DELAY_REQ 0x1 - /* * Hardware specific information. * 4 words of information used from this data set. @@ -225,6 +249,19 @@ uint32_t sobmhudpipv6_dcb32[24] = {0x00000000, 0x00013E00, 0x00000000, 0x0000000 0x00000000, 0x000C3E00, 0x00000000, 0x00000000, 0x00000000, 0x000C4200, 0x00000000, 0x00000000, 0x00000000, 0x000C3E00, 0x00000000, 0x00000000, 0x00000000, 0x000C4200, 0x00000000, 0x00000000}; +uint32_t sobmhrawpkts_dcb35[24] = {0x00000000, 0x0020E000, 0x00000000, 0x00000000, 0x00000000, 0x00212000, 0x00000000, 0x00000000, + 0x00000000, 0x0100E000, 0x00000000, 0x00000000, 0x00000000, 0x01012000, 0x00000000, 0x00000000, + 0x00000000, 0x0140E000, 0x00000000, 0x00000000, 0x00000000, 0x01412000, 0x00000000, 0x00000000}; + +uint32_t sobmhudpipv4_dcb35[24] = {0x00000000, 0x0022A000, 0x00000000, 0x00000000, 0x00000000, 0x0022E000, 0x00000000, 0x00000000, + 0x00000000, 0x0102A000, 0x00000000, 0x00000000, 0x00000000, 0x0102E000, 0x00000000, 0x00000000, + 0x00000000, 0x0142A000, 0x00000000, 0x00000000, 0x00000000, 0x0142E000, 0x00000000, 0x00000000}; + +uint32_t sobmhudpipv6_dcb35[24] = {0x00000000, 0x0023E000, 0x00000000, 0x00000000, 0x00000000, 0x00242000, 0x00000000, 0x00000000, + 0x00000000, 0x0103E000, 0x00000000, 0x00000000, 0x00000000, 0x01042000, 0x00000000, 0x00000000, + 0x00000000, 0x0143E000, 0x00000000, 0x00000000, 0x00000000, 0x01442000, 0x00000000, 0x00000000}; + + uint32_t sobmhrawpkts_dcb36[24] = {0x00000000, 0x00010E00, 0x00000000, 0x00000000, 0x00000000, 0x00011200, 0x00000000, 0x00000000, 0x00000000, 0x00080E00, 0x00000000, 0x00000000, 0x00000000, 0x00081200, 0x00000000, 0x00000000, 0x00000000, 0x00080E00, 0x00000000, 0x00000000, 0x00000000, 0x00081200, 0x00000000, 0x00000000}; @@ -267,21 +304,26 @@ typedef struct _bksync_uc_linux_ipc_s u32 ksyncinit; u32 dev_id; s64 freqcorr; - u64 portmap[BCM_NUM_PORTS/64]; + u64 portmap[BCMKSYNC_NUM_PORTS/64]; /* Two-step enabled ports */ u64 ptptime; u64 reftime; s64 phase_offset; - bksync_tx_ts_data_t port_ts_data[BCM_NUM_PORTS]; + bksync_tx_ts_data_t port_ts_data[BCMKSYNC_NUM_PORTS]; } bksync_uc_linux_ipc_t; typedef struct bksync_port_stats_s { u32 pkt_rxctr; /* All ingress packets */ u32 pkt_txctr; /* All egress packets */ + u32 pkt_txonestep; /* 1-step Tx packet counter */ u32 tsts_match; /* 2-Step tstamp req match */ u32 tsts_timeout; /* 2-Step tstamp req timeouts */ u32 tsts_discard; /* 2-Step tstamp req discards */ u32 osts_event_pkts; /* 1-step event packet counter */ u32 osts_tstamp_reqs; /* 1-step events with tstamp request */ + u32 fifo_rxctr; /* 2-Step tstamp req match */ + u64 tsts_best_fetch_time; /* 1-step events with tstamp request */ + u64 tsts_worst_fetch_time; /* 1-step events with tstamp request */ + u32 tsts_avg_fetch_time; /* 1-step events with tstamp request */ } bksync_port_stats_t; /* Clock Private Data */ @@ -296,14 +338,10 @@ struct bksync_ptp_priv { volatile bksync_uc_linux_ipc_t *shared_addr; /* address for shared memory access */ uint64_t dma_mem; int dma_mem_size; - int num_pports; struct DMA_DEV *dma_dev; /* Required for DMA memory control */ - u32 pkt_rxctr[BCM_NUM_PORTS]; - u32 pkt_txctr[BCM_NUM_PORTS]; - u32 ts_match[BCM_NUM_PORTS]; - u32 ts_timeout[BCM_NUM_PORTS]; - u32 ts_discard[BCM_NUM_PORTS]; + int num_pports; int timekeep_status; + u32 mirror_encap_bmp; struct delayed_work time_keep; bksync_port_stats_t *port_stats; }; @@ -311,7 +349,7 @@ struct bksync_ptp_priv { static struct bksync_ptp_priv *ptp_priv; volatile bksync_uc_linux_ipc_t *linuxPTPMemory = (bksync_uc_linux_ipc_t*)(0); static volatile int module_initialized; -static int retry_count = 10; /* Default retry for 10 jiffies */ +static int num_retries = 10; /* Retry count */ static void bksync_ptp_time_keep_init(void); static void bksync_ptp_time_keep_deinit(void); @@ -366,64 +404,6 @@ ptp_sleep(int jiffies) } -static int bksync_cmd_cmicm_go(u32 cmd, void *data0, void *data1) -{ - int ret = -1; - int retry_cnt = retry_count; - u32 cmd_status; - - mutex_lock(&ptp_priv->ptp_lock); - ptp_priv->shared_addr->ksyncinit = cmd; - switch (cmd) { - case BCM_KSYNC_INIT: - ptp_priv->shared_addr->phase_offset = 0; - ret = 0; - break; - case BCM_KSYNC_FREQCOR: - ptp_priv->shared_addr->freqcorr = *((s32 *)data0); - break; - case BCM_KSYNC_ADJTIME: - ptp_priv->shared_addr->phase_offset = *((s64 *)data0); - break; - case BCM_KSYNC_GETTIME: - break; - case BCM_KSYNC_SETTIME: - ptp_priv->shared_addr->ptptime = *((s64 *)data0); - ptp_priv->shared_addr->phase_offset = 0; - break; - default: - break; - } - - do { - cmd_status = ptp_priv->shared_addr->ksyncinit; - if (cmd_status == BCM_KSYNC_DONE) { - switch (cmd) { - case BCM_KSYNC_GETTIME: - *((s64 *)data0) = ptp_priv->shared_addr->ptptime; - *((s64 *)data1) = ptp_priv->shared_addr->reftime; /* ptp counter */ - break; - default: - break; - } - ret = 0; - break; - } - ptp_sleep(1); - retry_cnt--; - } while (retry_cnt); - mutex_unlock(&ptp_priv->ptp_lock); - - if (retry_cnt == 0) { - DBG_ERR(("Timeout on response from R5\n")); - } - - - return ret; -} - - - static void bksync_hostcmd_data_op(int setget, u64 *d1, u64 *d2) { u32 w0, w1; @@ -455,14 +435,28 @@ static void bksync_hostcmd_data_op(int setget, u64 *d1, u64 *d2) } -static int bksync_cmd_cmicx_go(u32 cmd, void *data0, void *data1) +static int bksync_cmd_go(u32 cmd, void *data0, void *data1) { int ret = -1; - int retry_cnt = (retry_count * 100); + int retry_cnt = (1000); /* 1ms default timeout for hostcmd response */ u32 cmd_status; char cmd_str[20]; + int port; + uint32_t seq_id; + ktime_t start, now; + + if (ptp_priv == NULL || ptp_priv->shared_addr == NULL) { + return ret; + } mutex_lock(&ptp_priv->ptp_lock); + + if (cmd == BKSYNC_GET_TSTIME || cmd == BKSYNC_ACK_TSTIME) { + port = *((uint64_t *)data0) & 0xFFF; + seq_id = *((uint64_t*)data0) >> 16; + } + start = ktime_get(); + ptp_priv->shared_addr->ksyncinit = cmd; /* init data */ @@ -472,36 +466,53 @@ static int bksync_cmd_cmicx_go(u32 cmd, void *data0, void *data1) DEV_WRITE32(ptp_priv, hostcmd_regs[4], 0x0); switch (cmd) { - case BCM_KSYNC_INIT: + case BKSYNC_INIT: sprintf(cmd_str, "KSYNC_INIT"); ptp_priv->shared_addr->phase_offset = 0; bksync_hostcmd_data_op(1, (u64 *)&(ptp_priv->shared_addr->phase_offset), 0); break; - case BCM_KSYNC_FREQCOR: + case BKSYNC_FREQCOR: sprintf(cmd_str, "KSYNC_FREQCORR"); ptp_priv->shared_addr->freqcorr = *((s32 *)data0); bksync_hostcmd_data_op(1, (u64 *)&(ptp_priv->shared_addr->freqcorr), 0); break; - case BCM_KSYNC_ADJTIME: + case BKSYNC_ADJTIME: sprintf(cmd_str, "KSYNC_ADJTIME"); ptp_priv->shared_addr->phase_offset = *((s64 *)data0); bksync_hostcmd_data_op(1, (u64 *)&(ptp_priv->shared_addr->phase_offset), 0); break; - case BCM_KSYNC_GETTIME: + case BKSYNC_GETTIME: + retry_cnt = (retry_cnt * 2); sprintf(cmd_str, "KSYNC_GETTIME"); break; - case BCM_KSYNC_GET_TSTIME: + case BKSYNC_GET_TSTIME: retry_cnt = (retry_cnt * 2); sprintf(cmd_str, "KSYNC_GET_TSTIME"); bksync_hostcmd_data_op(1, data0, data1); break; - case BCM_KSYNC_SETTIME: + case BKSYNC_ACK_TSTIME: + retry_cnt = (retry_cnt * 2); + sprintf(cmd_str, "KSYNC_ACK_TSTIME"); + bksync_hostcmd_data_op(1, data0, data1); + break; + case BKSYNC_SETTIME: sprintf(cmd_str, "KSYNC_SETTIME"); ptp_priv->shared_addr->ptptime = *((s64 *)data0); ptp_priv->shared_addr->phase_offset = 0; bksync_hostcmd_data_op(1, (u64 *)&(ptp_priv->shared_addr->ptptime), (u64 *)&(ptp_priv->shared_addr->phase_offset)); break; - case BCM_KSYNC_DEINIT: + case BKSYNC_MTP_TS_UPDATE_ENABLE: + retry_cnt = (retry_cnt * 6); + sprintf(cmd_str, "KSYNC_MTP_TS_UPDATE_ENABLE"); + bksync_hostcmd_data_op(1, (u64 *)data0, 0); + break; + case BKSYNC_MTP_TS_UPDATE_DISABLE: + retry_cnt = (retry_cnt * 6); + sprintf(cmd_str, "KSYNC_MTP_TS_UPDATE_DISABLE"); + bksync_hostcmd_data_op(1, (u64 *)data0, 0); + break; + case BKSYNC_DEINIT: + retry_cnt = (retry_cnt * 4); sprintf(cmd_str, "KSYNC_DEINIT"); break; default: @@ -514,11 +525,11 @@ static int bksync_cmd_cmicx_go(u32 cmd, void *data0, void *data1) DEV_READ32(ptp_priv, hostcmd_regs[0], &cmd_status); ptp_priv->shared_addr->ksyncinit = cmd_status; - if (cmd_status == BCM_KSYNC_DONE) { + if (cmd_status == BKSYNC_DONE) { ret = 0; switch (cmd) { - case BCM_KSYNC_GET_TSTIME: - case BCM_KSYNC_GETTIME: + case BKSYNC_GET_TSTIME: + case BKSYNC_GETTIME: bksync_hostcmd_data_op(0, (u64 *)data0, (u64 *)data1); break; default: @@ -530,37 +541,20 @@ static int bksync_cmd_cmicx_go(u32 cmd, void *data0, void *data1) retry_cnt--; } while (retry_cnt); + now = ktime_get(); mutex_unlock(&ptp_priv->ptp_lock); if (retry_cnt == 0) { - DBG_ERR(("Timeout on response from R5 to cmd %s\n", cmd_str)); + DBG_ERR(("Timeout on response from R5 to cmd %s time taken %lld us\n", cmd_str, ktime_us_delta(now, start))); + if (cmd == BKSYNC_GET_TSTIME) { + DBG_TXTS(("Timeout Port %d SeqId %d\n", port, seq_id)); + } } - - - return ret; -} - - -static int bksync_cmd_go(u32 cmd, void *data0, void *data1) -{ - int ret = -1; - - if (ptp_priv == NULL || ptp_priv->shared_addr == NULL) { - return ret; + if (debug & DBG_LVL_CMDS) { + if (ktime_us_delta(now, start) > 5000) + DBG_CMDS(("R5 Command %s exceeded time expected (%lld us)\n", cmd_str, ktime_us_delta(now, start))); } - switch (ptp_priv->dcb_type) { - case 26: - ret = bksync_cmd_cmicm_go(cmd, data0, data1); - break; - case 32: - case 36: - case 38: - ret = bksync_cmd_cmicx_go(cmd, data0, data1); - break; - default: - break; - } return ret; } @@ -577,7 +571,7 @@ static int bksync_cmd_go(u32 cmd, void *data0, void *data1) static int bksync_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb) { int ret = -1; - u32 cmd_status = BCM_KSYNC_FREQCOR; + u32 cmd_status = BKSYNC_FREQCOR; ret = bksync_cmd_go(cmd_status, &ppb, NULL); DBG_VERB(("applying freq correction: %x\n", ppb)); @@ -595,7 +589,7 @@ static int bksync_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb) */ static int bksync_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) { - u32 cmd_status = BCM_KSYNC_ADJTIME; + u32 cmd_status = BKSYNC_ADJTIME; int ret = -1; ret = bksync_cmd_go(cmd_status, (void *)&delta, NULL); @@ -616,18 +610,20 @@ static int bksync_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) static int bksync_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts) { int ret = -1; - u32 cmd_status = BCM_KSYNC_GETTIME; + u32 cmd_status = BKSYNC_GETTIME; s64 reftime = 0; s64 refctr = 0; ret = bksync_cmd_go(cmd_status, (void *)&reftime, (void *)&refctr); - DBG_VERB(("ptp gettime: 0x%llx refctr:0x%llx\n", reftime, refctr)); - mutex_lock(&ptp_priv->ptp_pair_lock); - ptp_priv->shared_addr->ptptime = reftime; - ptp_priv->shared_addr->reftime = refctr; - mutex_unlock(&ptp_priv->ptp_pair_lock); - - *ts = ns_to_timespec64(reftime); + if (ret == 0) { + DBG_VERB(("ptp gettime: 0x%llx refctr:0x%llx\n", reftime, refctr)); + mutex_lock(&ptp_priv->ptp_pair_lock); + ptp_priv->shared_addr->ptptime = reftime; + ptp_priv->shared_addr->reftime = refctr; + mutex_unlock(&ptp_priv->ptp_pair_lock); + + *ts = ns_to_timespec64(reftime); + } return ret; } @@ -646,7 +642,7 @@ static int bksync_ptp_settime(struct ptp_clock_info *ptp, { s64 reftime, phaseadj; int ret = -1; - u32 cmd_status = BCM_KSYNC_SETTIME; + u32 cmd_status = BKSYNC_SETTIME; phaseadj = 0; reftime = timespec64_to_ns(ts); @@ -663,6 +659,38 @@ static int bksync_ptp_enable(struct ptp_clock_info *ptp, return 0; } + +static int bksync_ptp_mirror_encap_update(struct ptp_clock_info *ptp, + int mtp_idx, int start) +{ + int ret = -1; + u64 mirror_encap_idx; + u32 cmd_status; + + if (mtp_idx > BCMKSYNC_MAX_MTP_IDX) { + return ret; + } + + mirror_encap_idx = mtp_idx; + if (start) { + cmd_status = BKSYNC_MTP_TS_UPDATE_ENABLE; + ptp_priv->mirror_encap_bmp |= (1 << mtp_idx); + } else { + if (!(ptp_priv->mirror_encap_bmp & mtp_idx)) { + /* Not running */ + return ret; + } + cmd_status = BKSYNC_MTP_TS_UPDATE_DISABLE; + ptp_priv->mirror_encap_bmp &= ~mtp_idx; + } + + ret = bksync_cmd_go(cmd_status, &mirror_encap_idx, NULL); + DBG_VERB(("ptp mmirror_encap_update: %d, mpt_index: %d, ret:%d \n", start, mtp_idx, ret)); + + return ret; + +} + /* structure describing a PTP hardware clock */ static struct ptp_clock_info bksync_ptp_caps = { .owner = THIS_MODULE, @@ -721,7 +749,7 @@ int bksync_ptp_hw_tstamp_enable(int dev_no, int port, int tx_type) portmap |= (uint64_t)0x1 << port; ptp_priv->shared_addr->portmap[map] = portmap; /* Command to R5 for the update */ - ptp_priv->shared_addr->ksyncinit=BCM_KSYNC_PBM_UPDATE; + ptp_priv->shared_addr->ksyncinit=BKSYNC_PBM_UPDATE; } exit: @@ -769,7 +797,7 @@ int bksync_ptp_hw_tstamp_disable(int dev_no, int port, int tx_type) ptp_priv->shared_addr->portmap[map]= portmap; /* Command to R5 for the update */ - ptp_priv->shared_addr->ksyncinit = BCM_KSYNC_PBM_UPDATE; + ptp_priv->shared_addr->ksyncinit = BKSYNC_PBM_UPDATE; } exit: return ret; @@ -818,23 +846,26 @@ bksync_txpkt_tsts_tsamp_get(int port, uint32_t pkt_seq_id, uint32_t *ts_valid, u { int ret = 0; uint64_t tmp; + u32 fifo_rxctr = 0; tmp = (port & 0xFFFF) | (pkt_seq_id << 16); - if (HOSTCMD_USE_REGS) { - ret = bksync_cmd_go(BCM_KSYNC_GET_TSTIME, &tmp, timestamp); - - if (ret >= 0) { - *seq_id = ((tmp >> 16) & 0xFFFF); - *ts_valid = (tmp & 0x1); + ret = bksync_cmd_go(BKSYNC_GET_TSTIME, &tmp, timestamp); + + if (ret >= 0) { + fifo_rxctr = (tmp >> 32) & 0xFFFF; + *seq_id = ((tmp >> 16) & 0xFFFF); + *ts_valid = (tmp & 0x1); + if (*ts_valid) { + tmp = (port & 0xFFFF) | (pkt_seq_id << 16); + bksync_cmd_go(BKSYNC_ACK_TSTIME, &tmp, 0); + if (fifo_rxctr != 0) { + if (fifo_rxctr != ptp_priv->port_stats[port].fifo_rxctr + 1) { + DBG_ERR(("FW Reset or Lost Timestamp RxSeq:(Prev %d : Current %d)\n", ptp_priv->port_stats[port].fifo_rxctr, fifo_rxctr)); + } + ptp_priv->port_stats[port].fifo_rxctr = fifo_rxctr; + } } -#if 0 - if (tmp & 0x1) gprintk("in_port: %d in_seq_id: %d out_port: %lld ts_valid: %lld seq_id: %lld ts: %llx\n", port, pkt_seq_id, ((tmp & 0xFFFF) >> 1), (tmp & 0x1), (tmp >> 16), *timestamp); -#endif - } else { - *ts_valid = ptp_priv->shared_addr->port_ts_data[port].ts_valid; - *seq_id = ptp_priv->shared_addr->port_ts_data[port].ts_seq_id; - *timestamp = ptp_priv->shared_addr->port_ts_data[port].timestamp; } @@ -861,9 +892,12 @@ int bksync_ptp_hw_tstamp_tx_time_get(int dev_no, int port, uint8_t *pkt, uint64_ uint32_t pktseq_id = 0; uint64_t timestamp = 0; uint16_t tpid = 0; - int retry_cnt = retry_count; + ktime_t start; + u64 delta; + int retry_cnt = num_retries; int seq_id_offset, tpid_offset; int transport = network_transport; + start = ktime_get(); if (!ptp_priv || !pkt || !ts || port < 1 || port > 255 || ptp_priv->shared_addr == NULL) { return -1; @@ -918,25 +952,26 @@ int bksync_ptp_hw_tstamp_tx_time_get(int dev_no, int port, uint8_t *pkt, uint64_ if (seq_id == pktseq_id) { *ts = timestamp; - if (HOSTCMD_USE_REGS) { - ptp_priv->port_stats[port].tsts_match += 1; - } else { - ptp_priv->ts_match[port] += 1; - } + ptp_priv->port_stats[port].tsts_match += 1; - DBG_VERB(("Port: %d Skb_SeqID %d FW_SeqId %d and TS:%llx\n", - port, pktseq_id, seq_id, timestamp)); + delta = ktime_us_delta(ktime_get(), start); + DBG_VERB(("Port: %d Skb_SeqID %d FW_SeqId %d and TS:%llx FetchTime %lld\n", + port, pktseq_id, seq_id, timestamp, delta)); + if (delta < ptp_priv->port_stats[port].tsts_best_fetch_time || ptp_priv->port_stats[port].tsts_best_fetch_time == 0) { + ptp_priv->port_stats[port].tsts_best_fetch_time = delta; + } + if (delta > ptp_priv->port_stats[port].tsts_worst_fetch_time || ptp_priv->port_stats[port].tsts_worst_fetch_time == 0) { + ptp_priv->port_stats[port].tsts_worst_fetch_time = delta; + } + /* Calculate Moving Average*/ + ptp_priv->port_stats[port].tsts_avg_fetch_time = ((u32)delta + ((ptp_priv->port_stats[port].tsts_match - 1) * ptp_priv->port_stats[port].tsts_avg_fetch_time)) / ptp_priv->port_stats[port].tsts_match; break; } else { - DBG_ERR(("discard timestamp on port %d Skb_SeqID %d FW_SeqId %d\n", - port, pktseq_id, seq_id)); + DBG_TXTS(("Discard timestamp on port %d Skb_SeqID %d FW_SeqId %d RetryCnt %d TimeLapsed (%lld us)\n", + port, pktseq_id, seq_id, (num_retries - retry_cnt), ktime_us_delta(ktime_get(),start))); - if (HOSTCMD_USE_REGS) { - ptp_priv->port_stats[port].tsts_discard += 1; - } else { - ptp_priv->ts_discard[port] += 1; - } + ptp_priv->port_stats[port].tsts_discard += 1; continue; } } @@ -945,19 +980,12 @@ int bksync_ptp_hw_tstamp_tx_time_get(int dev_no, int port, uint8_t *pkt, uint64_ } while(retry_cnt); - if (HOSTCMD_USE_REGS) { - ptp_priv->port_stats[port].pkt_txctr += 1; - } else { - ptp_priv->pkt_txctr[port] += 1; - } + ptp_priv->port_stats[port].pkt_txctr += 1; if (retry_cnt == 0) { - if (HOSTCMD_USE_REGS) { - ptp_priv->port_stats[port].tsts_timeout += 1; - } else { - ptp_priv->ts_timeout[port] += 1; - } - DBG_ERR(("FW Response timeout: Tx TS on phy port:%d Skb_SeqID: %d\n", port, seq_id)); + ptp_priv->port_stats[port].tsts_timeout += 1; + DBG_ERR(("FW Response timeout: Tx TS on phy port:%d Skb_SeqID: %d TimeLapsed (%lld us)\n", + port, pktseq_id, ktime_us_delta(ktime_get(), start))); } @@ -1113,6 +1141,7 @@ int bksync_ptp_hw_tstamp_rx_time_upscale(int dev_no, int port, struct sk_buff *s switch (KNET_SKB_CB(skb)->dcb_type) { case 26: case 32: + case 35: if (pci_cos != (meta[4] & 0x3F)) { return -1; } @@ -1142,12 +1171,8 @@ int bksync_ptp_hw_tstamp_rx_time_upscale(int dev_no, int port, struct sk_buff *s } if (port > 0){ - port -= 1; - if (HOSTCMD_USE_REGS) { + port -= 1; ptp_priv->port_stats[port].pkt_rxctr += 1; - } else { - ptp_priv->pkt_rxctr[port] += 1; - } } return ret; @@ -1240,6 +1265,8 @@ int bksync_ptp_hw_tstamp_tx_meta_get(int dev_no, if (md) *md = &sobmhrawpkts_dcb32[md_offset]; } else if(KNET_SKB_CB(skb)->dcb_type == 26) { if (md) *md = &sobmhrawpkts_dcb26[md_offset]; + } else if(KNET_SKB_CB(skb)->dcb_type == 35) { + if (md) *md = &sobmhrawpkts_dcb35[md_offset]; } else if(KNET_SKB_CB(skb)->dcb_type == 36) { if (md) *md = &sobmhrawpkts_dcb36[md_offset]; } else if(KNET_SKB_CB(skb)->dcb_type == 38) { @@ -1252,6 +1279,8 @@ int bksync_ptp_hw_tstamp_tx_meta_get(int dev_no, if (md) *md = &sobmhudpipv4_dcb32[md_offset]; } else if(KNET_SKB_CB(skb)->dcb_type == 26) { if (md) *md = &sobmhudpipv4_dcb26[md_offset]; + } else if(KNET_SKB_CB(skb)->dcb_type == 35) { + if (md) *md = &sobmhudpipv4_dcb35[md_offset]; } else if(KNET_SKB_CB(skb)->dcb_type == 36) { if (md) *md = &sobmhudpipv4_dcb36[md_offset]; } else if(KNET_SKB_CB(skb)->dcb_type == 38) { @@ -1264,6 +1293,8 @@ int bksync_ptp_hw_tstamp_tx_meta_get(int dev_no, if (md) *md = &sobmhudpipv6_dcb32[md_offset]; } else if(KNET_SKB_CB(skb)->dcb_type == 26) { if (md) *md = &sobmhudpipv6_dcb26[md_offset]; + } else if(KNET_SKB_CB(skb)->dcb_type == 35) { + if (md) *md = &sobmhudpipv6_dcb35[md_offset]; } else if(KNET_SKB_CB(skb)->dcb_type == 36) { if (md) *md = &sobmhudpipv6_dcb36[md_offset]; } else if(KNET_SKB_CB(skb)->dcb_type == 38) { @@ -1276,6 +1307,8 @@ int bksync_ptp_hw_tstamp_tx_meta_get(int dev_no, if (md) *md = &sobmhudpipv4_dcb32[md_offset]; } else if(KNET_SKB_CB(skb)->dcb_type == 26) { if (md) *md = &sobmhudpipv4_dcb26[md_offset]; + } else if(KNET_SKB_CB(skb)->dcb_type == 35) { + if (md) *md = &sobmhudpipv4_dcb35[md_offset]; } else if(KNET_SKB_CB(skb)->dcb_type == 36) { if (md) *md = &sobmhudpipv4_dcb36[md_offset]; } else if(KNET_SKB_CB(skb)->dcb_type == 38) { @@ -1285,7 +1318,7 @@ int bksync_ptp_hw_tstamp_tx_meta_get(int dev_no, } - if ((hwts == HWTSTAMP_TX_ONESTEP_SYNC) && + if ((hwts == HWTSTAMP_TX_ONESTEP_SYNC) && BKSYNC_PTP_EVENT_MSG(skb->data[ptp_hdr_offset])) { /* One Step Timestamp Field updation */ int corr_offset = ptp_hdr_offset + 8; @@ -1295,6 +1328,7 @@ int bksync_ptp_hw_tstamp_tx_meta_get(int dev_no, int udp_csum_regen; u32 udp_csum20; u16 udp_csum; + int port; udp_csum = SKB_U16_GET(skb, (ptp_hdr_offset - 2)); @@ -1360,12 +1394,15 @@ int bksync_ptp_hw_tstamp_tx_meta_get(int dev_no, skb->data[ptp_hdr_offset - 1] = ((udp_csum ) & 0xFF); } - if (skb->data[ptp_hdr_offset] == DELAY_REQ) { + if (skb->data[ptp_hdr_offset] == IEEE1588_MSGTYPE_DELREQ) { *tstamp = ptptime; DBG_VERB(("ptp delay req packet tstamp : 0x%llx corrField: 0x%llx\n", ptptime, corrField)); } + port = KNET_SKB_CB(skb)->port; + port -= 1; + ptp_priv->port_stats[port].pkt_txonestep += 1; } return 0; @@ -1425,14 +1462,14 @@ static void bksync_ptp_time_keep_deinit(void) static int bksync_ptp_init(struct ptp_clock_info *ptp) { - return bksync_cmd_go(BCM_KSYNC_INIT, NULL, NULL); + return bksync_cmd_go(BKSYNC_INIT, NULL, NULL); } static int bksync_ptp_deinit(struct ptp_clock_info *ptp) { bksync_ptp_time_keep_deinit(); - return bksync_cmd_go(BCM_KSYNC_DEINIT, NULL, NULL); + return bksync_cmd_go(BKSYNC_DEINIT, NULL, NULL); } /* @@ -1450,14 +1487,15 @@ static void *bksync_proc_seq_start(struct seq_file *s, loff_t *pos) /* beginning a new sequence ? */ if ( (int)*pos == 0 && ptp_priv->shared_addr != NULL) { - seq_printf(s, "Port Bitmap : %08llx%08llx\n", + seq_printf(s, "TwoStep Port Bitmap : %08llx%08llx\n", (uint64_t)(ptp_priv->shared_addr->portmap[1]), (uint64_t)(ptp_priv->shared_addr->portmap[0])); - seq_printf(s,"%4s| %9s| %9s| %9s| %9s| %9s| %9s|\n", - "Port", "RxCounter", "TxCounter", "TSTimeout", "TSRead", "TSMatch", "TSDiscard"); + seq_printf(s,"%4s| %9s| %9s| %9s| %9s| %9s| %9s| %9s| %9s| %9s| %9s| %9s\n", + "Port", "RxCounter", "TxCounter", "TxOneStep", "TSTimeout", "TSRead", "TSMatch", "TSDiscard", + "TimeHi" , "TimeLo", "TimeAvg", "FIFORx"); } - if (ptp_priv->shared_addr != NULL && (int)*pos < (ptp_priv->num_pports)) + if ((int)*pos < (ptp_priv->num_pports)) return (void *)(unsigned long)(*pos + 1); /* End of the sequence, return NULL */ return NULL; @@ -1490,33 +1528,24 @@ static int bksync_proc_seq_show(struct seq_file *s, void *v) { unsigned long port = (unsigned long)v; port = port - 1; - if (HOSTCMD_USE_REGS) { - if (ptp_priv->port_stats[port].pkt_rxctr || ptp_priv->port_stats[port].pkt_txctr || - ptp_priv->port_stats[port].tsts_discard || ptp_priv->port_stats[port].tsts_timeout || - ptp_priv->shared_addr->port_ts_data[port].ts_cnt || ptp_priv->port_stats[port].tsts_match) { - seq_printf(s, "%4lu | %9d| %9d| %9d| %9d| %9d| %9d| %s\n", (port + 1), - ptp_priv->port_stats[port].pkt_rxctr, - ptp_priv->port_stats[port].pkt_txctr, - ptp_priv->port_stats[port].tsts_timeout, - ptp_priv->shared_addr->port_ts_data[port].ts_cnt, - ptp_priv->port_stats[port].tsts_match, - ptp_priv->port_stats[port].tsts_discard, - ptp_priv->port_stats[port].pkt_txctr != ptp_priv->port_stats[port].tsts_match ? "***":""); - } - } else { - if (ptp_priv->pkt_rxctr[port] || ptp_priv->pkt_txctr[port] || - ptp_priv->ts_discard[port] || ptp_priv->ts_timeout[port] || - ptp_priv->shared_addr->port_ts_data[port].ts_cnt || ptp_priv->ts_match[port]) { - seq_printf(s, "%4lu | %9d| %9d| %9d| %9d| %9d| %9d| %s\n", (port + 1), - ptp_priv->pkt_rxctr[port], - ptp_priv->pkt_txctr[port], - ptp_priv->ts_timeout[port], + if (ptp_priv->port_stats[port].pkt_rxctr || ptp_priv->port_stats[port].pkt_txctr || + ptp_priv->port_stats[port].pkt_txonestep|| + ptp_priv->port_stats[port].tsts_discard || ptp_priv->port_stats[port].tsts_timeout || + ptp_priv->shared_addr->port_ts_data[port].ts_cnt || ptp_priv->port_stats[port].tsts_match) { + seq_printf(s, "%4lu | %9d| %9d| %9d| %9d| %9d| %9d| %9d| %9lld| %9lld | %9d|%9d | %s\n", (port + 1), + ptp_priv->port_stats[port].pkt_rxctr, + ptp_priv->port_stats[port].pkt_txctr, + ptp_priv->port_stats[port].pkt_txonestep, + ptp_priv->port_stats[port].tsts_timeout, ptp_priv->shared_addr->port_ts_data[port].ts_cnt, - ptp_priv->ts_match[port], - ptp_priv->ts_discard[port], - ptp_priv->pkt_txctr[port] != ptp_priv->ts_match[port] ? "***":""); + ptp_priv->port_stats[port].tsts_match, + ptp_priv->port_stats[port].tsts_discard, + ptp_priv->port_stats[port].tsts_worst_fetch_time, + ptp_priv->port_stats[port].tsts_best_fetch_time, + ptp_priv->port_stats[port].tsts_avg_fetch_time, + ptp_priv->port_stats[port].fifo_rxctr, + ptp_priv->port_stats[port].pkt_txctr != ptp_priv->port_stats[port].tsts_match ? "***":""); } - } return 0; } @@ -1549,19 +1578,12 @@ bksync_proc_txts_write(struct file *file, const char *buf, if ((ptr = strstr(debug_str, "clear")) != NULL) { for (port = 0; port < ptp_priv->num_pports; port++) { - if (HOSTCMD_USE_REGS) { - ptp_priv->port_stats[port].pkt_rxctr = 0; - ptp_priv->port_stats[port].pkt_txctr = 0; - ptp_priv->port_stats[port].tsts_discard = 0; - ptp_priv->port_stats[port].tsts_timeout = 0; - ptp_priv->port_stats[port].tsts_match = 0; - } else { - ptp_priv->pkt_rxctr[port] = 0; - ptp_priv->pkt_txctr[port] = 0; - ptp_priv->ts_discard[port] = 0; - ptp_priv->ts_timeout[port] = 0; - ptp_priv->ts_match[port] = 0; - } + ptp_priv->port_stats[port].pkt_rxctr = 0; + ptp_priv->port_stats[port].pkt_txctr = 0; + ptp_priv->port_stats[port].pkt_txonestep = 0; + ptp_priv->port_stats[port].tsts_timeout = 0; + ptp_priv->port_stats[port].tsts_match = 0; + ptp_priv->port_stats[port].tsts_discard = 0; if (ptp_priv->shared_addr) ptp_priv->shared_addr->port_ts_data[port].ts_cnt = 0; } @@ -1581,91 +1603,90 @@ struct file_operations bksync_proc_txts_file_ops = { release: seq_release, }; +/* + * Driver Debug Proc Entry + */ static int -bksync_proc_init(void) +bksync_proc_debug_show(struct seq_file *m, void *v) { - struct proc_dir_entry *entry; - - PROC_CREATE(entry, "stats", 0666, bksync_proc_root, &bksync_proc_txts_file_ops); - if (entry == NULL) { - return -1; - } + seq_printf(m, "Configuration:\n"); + seq_printf(m, " debug: 0x%x\n", debug); return 0; } -static int -bksync_proc_cleanup(void) +static ssize_t +bksync_proc_debug_write(struct file *file, const char *buf, + size_t count, loff_t *loff) { - remove_proc_entry("stats", bksync_proc_root); - return 0; -} + char debug_str[40]; + char *ptr; -static void bksync_ptp_cmicm_dma_init(int dcb_type) -{ - int endianess; - int num_pports = 128; - dma_addr_t dma_mem = 0; + if (copy_from_user(debug_str, buf, count)) { + return -EFAULT; + } - /* Initialize the Base address for CMIC and shared Memory access */ - ptp_priv->base_addr = lkbde_get_dev_virt(0); - ptp_priv->dma_dev = lkbde_get_dma_dev(0); + if ((ptr = strstr(debug_str, "debug=")) != NULL) { + ptr += 6; + debug = simple_strtol(ptr, NULL, 0); + } else { + gprintk("Warning: unknown configuration\n"); + } - ptp_priv->dma_mem_size = 16384;/*sizeof(bksync_uc_linux_ipc_t);*/ + return count; +} - if (ptp_priv->shared_addr == NULL) { - DBG_ERR(("Allocate shared memory with R5\n")); - ptp_priv->shared_addr = DMA_ALLOC_COHERENT(ptp_priv->dma_dev, - ptp_priv->dma_mem_size, - &dma_mem); - ptp_priv->dma_mem = (uint64_t)dma_mem; - ptp_priv->num_pports = num_pports; - ptp_priv->port_stats = kzalloc((sizeof(bksync_port_stats_t) * num_pports), GFP_KERNEL); - } +static int bksync_proc_debug_open(struct inode * inode, struct file * file) +{ + return single_open(file, bksync_proc_debug_show, NULL); +} - if (ptp_priv->shared_addr != NULL) { - /* Reset memory */ - memset((void *)ptp_priv->shared_addr, 0, ptp_priv->dma_mem_size); - DBG_ERR(("Shared memory allocation (%d bytes) successful at 0x%016lx.\n", - ptp_priv->dma_mem_size, (long unsigned int)ptp_priv->dma_mem)); -#ifdef __LITTLE_ENDIAN - endianess = 0; -#else - endianess = 1; -#endif - DEV_WRITE32(ptp_priv, CMIC_CMC_SCHAN_MESSAGE_12r(CMIC_CMC_BASE), ((pci_cos << 16) | endianess)); +struct file_operations bksync_proc_debug_file_ops = { + owner: THIS_MODULE, + open: bksync_proc_debug_open, + read: seq_read, + llseek: seq_lseek, + write: bksync_proc_debug_write, + release: single_release, +}; - DEV_WRITE32(ptp_priv, CMIC_CMC_SCHAN_MESSAGE_10r(CMIC_CMC_BASE), - (ptp_priv->dma_mem & 0xffffffff)); - DEV_WRITE32(ptp_priv, CMIC_CMC_SCHAN_MESSAGE_11r(CMIC_CMC_BASE), - (ptp_priv->dma_mem >> 32) & 0xffffffff); - ptp_priv->dcb_type = dcb_type; - } +static int +bksync_proc_init(void) +{ + struct proc_dir_entry *entry; - if (debug & DBG_LVL_VERB) { - printk(KERN_EMERG"%s %p:%p\n",__FUNCTION__, - ptp_priv->base_addr,(void *)ptp_priv->shared_addr); + PROC_CREATE(entry, "stats", 0666, bksync_proc_root, &bksync_proc_txts_file_ops); + if (entry == NULL) { + return -1; + } + PROC_CREATE(entry, "debug", 0666, bksync_proc_root, &bksync_proc_debug_file_ops); + if (entry == NULL) { + return -1; } + return 0; +} - return; +static int +bksync_proc_cleanup(void) +{ + remove_proc_entry("stats", bksync_proc_root); + remove_proc_entry("debug", bksync_proc_root); + return 0; } -static void bksync_ptp_cmicx_dma_init(int dcb_type) +static void bksync_ptp_dma_init(int dcb_type) { int endianess; int num_pports = 256; - /* Initialize the Base address for CMIC and shared Memory access */ - ptp_priv->base_addr = lkbde_get_dev_virt(0); - ptp_priv->dma_dev = lkbde_get_dma_dev(0); + ptp_priv->num_pports = num_pports; ptp_priv->dcb_type = dcb_type; ptp_priv->dma_mem_size = 16384;/*sizeof(bksync_uc_linux_ipc_t);*/ if (ptp_priv->shared_addr == NULL) { ptp_priv->shared_addr = kzalloc(16384, GFP_KERNEL); - ptp_priv->num_pports = num_pports; ptp_priv->port_stats = kzalloc((sizeof(bksync_port_stats_t) * num_pports), GFP_KERNEL); } @@ -1678,10 +1699,10 @@ static void bksync_ptp_cmicx_dma_init(int dcb_type) #else endianess = 1; #endif - DEV_WRITE32(ptp_priv, CMIC_CMC_SCHAN_MESSAGE_12r(CMIC_CMC_BASE), ((pci_cos << 16) | endianess)); + DEV_WRITE32(ptp_priv, CMIC_CMC_SCHAN_MESSAGE_14r(CMIC_CMC_BASE), ((pci_cos << 16) | endianess)); - DEV_WRITE32(ptp_priv, CMIC_CMC_SCHAN_MESSAGE_10r(CMIC_CMC_BASE), 1); - DEV_WRITE32(ptp_priv, CMIC_CMC_SCHAN_MESSAGE_11r(CMIC_CMC_BASE), 1); + DEV_WRITE32(ptp_priv, CMIC_CMC_SCHAN_MESSAGE_15r(CMIC_CMC_BASE), 1); + DEV_WRITE32(ptp_priv, CMIC_CMC_SCHAN_MESSAGE_16r(CMIC_CMC_BASE), 1); } @@ -1690,6 +1711,7 @@ static void bksync_ptp_cmicx_dma_init(int dcb_type) ptp_priv->base_addr,(void *)ptp_priv->shared_addr); } + ptp_priv->mirror_encap_bmp = 0x0; hostcmd_regs[0] = CMIC_CMC_SCHAN_MESSAGE_21r(CMIC_CMC_BASE); hostcmd_regs[1] = CMIC_CMC_SCHAN_MESSAGE_20r(CMIC_CMC_BASE); @@ -1701,28 +1723,6 @@ static void bksync_ptp_cmicx_dma_init(int dcb_type) } -static void bksync_ptp_dma_init(int dcb_type) -{ - switch (dcb_type) { - case 26: - bksync_ptp_cmicm_dma_init(dcb_type); - ptp_priv->dcb_type = dcb_type; - break; - case 32: - case 36: - case 38: - bksync_ptp_cmicx_dma_init(dcb_type); - ptp_priv->dcb_type = dcb_type; - break; - default: - break; - } - - return; -} - - - /** * bksync_ioctl_cmd_handler * @kmsg: kcom message - ptp clock ioctl command. @@ -1732,6 +1732,7 @@ static void bksync_ptp_dma_init(int dcb_type) static int bksync_ioctl_cmd_handler(kcom_msg_clock_cmd_t *kmsg, int len, int dcb_type) { + u32 fw_status; kmsg->hdr.type = KCOM_MSG_TYPE_RSP; if (!module_initialized && kmsg->clock_info.cmd != KSYNC_M_HW_INIT) { @@ -1744,6 +1745,20 @@ bksync_ioctl_cmd_handler(kcom_msg_clock_cmd_t *kmsg, int len, int dcb_type) pci_cos = kmsg->clock_info.data[0]; if (kmsg->clock_info.data[1] == 0 || kmsg->clock_info.data[1] == 1) { fw_core = kmsg->clock_info.data[1]; + DEV_READ32(ptp_priv, CMIC_CMC_SCHAN_MESSAGE_21r(CMIC_CMC_BASE), &fw_status); + + /* Return success if the app is already initialized. */ + if (module_initialized) { + kmsg->hdr.status = KCOM_E_NONE; + return sizeof(kcom_msg_hdr_t); + } + + /* Return error if the app is not ready yet. */ + if (fw_status != 0xBADC0DE1) { + kmsg->hdr.status = KCOM_E_RESOURCE; + return sizeof(kcom_msg_hdr_t); + } + bksync_ptp_dma_init(dcb_type); if (bksync_ptp_init(&(ptp_priv->ptp_caps)) >= 0) { module_initialized = 1; @@ -1757,6 +1772,12 @@ bksync_ioctl_cmd_handler(kcom_msg_clock_cmd_t *kmsg, int len, int dcb_type) case KSYNC_M_HW_TS_DISABLE: bksync_ptp_hw_tstamp_disable(0, kmsg->clock_info.data[0], 0); break; + case KSYNC_M_MTP_TS_UPDATE_ENABLE: + bksync_ptp_mirror_encap_update(0, kmsg->clock_info.data[0], TRUE); + break; + case KSYNC_M_MTP_TS_UPDATE_DISABLE: + bksync_ptp_mirror_encap_update(0, kmsg->clock_info.data[0], FALSE); + break; case KSYNC_M_VERSION: break; default: @@ -1813,6 +1834,10 @@ static int bksync_ptp_register(void) /* Register ptp clock driver with bksync_ptp_caps */ ptp_priv->ptp_clock = ptp_clock_register(&ptp_priv->ptp_caps, NULL); + /* Initialize the Base address for CMIC and shared Memory access */ + ptp_priv->base_addr = lkbde_get_dev_virt(0); + ptp_priv->dma_dev = lkbde_get_dma_dev(0); + if (IS_ERR(ptp_priv->ptp_clock)) { ptp_priv->ptp_clock = NULL; } else if (ptp_priv->ptp_clock) { @@ -1858,8 +1883,8 @@ static int bksync_ptp_remove(void) bkn_hw_tstamp_ioctl_cmd_cb_unregister(bksync_ioctl_cmd_handler); if (module_initialized) { - DEV_WRITE32(ptp_priv, CMIC_CMC_SCHAN_MESSAGE_10r(CMIC_CMC_BASE), 0); - DEV_WRITE32(ptp_priv, CMIC_CMC_SCHAN_MESSAGE_11r(CMIC_CMC_BASE), 0); + DEV_WRITE32(ptp_priv, CMIC_CMC_SCHAN_MESSAGE_15r(CMIC_CMC_BASE), 0); + DEV_WRITE32(ptp_priv, CMIC_CMC_SCHAN_MESSAGE_16r(CMIC_CMC_BASE), 0); } /* Deinitialize the PTP */ bksync_ptp_deinit(&(ptp_priv->ptp_caps)); @@ -1870,12 +1895,7 @@ static int bksync_ptp_remove(void) ptp_priv->port_stats = NULL; } if (ptp_priv->shared_addr != NULL) { - if (HOSTCMD_USE_REGS) { - kfree((void *)ptp_priv->shared_addr); - } else { - DMA_FREE_COHERENT(ptp_priv->dma_dev, ptp_priv->dma_mem_size, - (void *)ptp_priv->shared_addr, (dma_addr_t)ptp_priv->dma_mem); - } + kfree((void *)ptp_priv->shared_addr); ptp_priv->shared_addr = NULL; DBG_ERR(("Free R5 memory\n")); } @@ -1906,13 +1926,13 @@ static int bksync_ptp_remove(void) * Always 0 */ static int -_pprint(void) +_pprint(struct seq_file *m) { #if LINUX_VERSION_CODE > KERNEL_VERSION(3,17,0) /* put some goodies here */ - pprintf("Broadcom BCM PTP Hardware Clock Module\n"); + pprintf(m, "Broadcom BCM PTP Hardware Clock Module\n"); #else - pprintf("Broadcom BCM PTP Hardware Clock Module not supported\n"); + pprintf(m, "Broadcom BCM PTP Hardware Clock Module not supported\n"); #endif return 0; } diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/bcm-knet.h b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/bcm-knet.h index df8874fb1f70..8d710869824f 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/bcm-knet.h +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/bcm-knet.h @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: bcm-knet.h,v 1.4 Broadcom SDK $ @@ -137,7 +148,6 @@ bkn_hw_tstamp_ioctl_cmd_cb_register(knet_hw_tstamp_ioctl_cmd_cb_f hw_tstamp_ioct extern int bkn_hw_tstamp_ioctl_cmd_cb_unregister(knet_hw_tstamp_ioctl_cmd_cb_f hw_tstamp_ioctl_cmd_cb); - typedef struct { uint8 cmic_type; uint8 dcb_type; diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/gmodule.h b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/gmodule.h index 22cef82a8ddc..a9db097f3062 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/gmodule.h +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/gmodule.h @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: gmodule.h,v 1.9 Broadcom SDK $ @@ -23,6 +34,7 @@ #define __COMMON_LINUX_KRN_GMODULE_H__ #include +#include typedef struct gmodule_s { @@ -32,9 +44,7 @@ typedef struct gmodule_s { int (*init)(void); int (*cleanup)(void); - - int (*pprint)(void); - + int (*pprint)(struct seq_file *m); int (*open)(void); int (*ioctl)(unsigned int cmd, unsigned long arg); int (*close)(void); @@ -48,8 +58,8 @@ extern gmodule_t* gmodule_get(void); /* Proc Filesystem information */ -extern int pprintf(const char* fmt, ...) - __attribute__ ((format (printf, 1, 2))); +extern int pprintf(struct seq_file *m, const char* fmt, ...) + __attribute__ ((format (printf, 2, 3))); extern int gmodule_vpprintf(char** page, const char* fmt, va_list args) __attribute__ ((format (printf, 2, 0))); extern int gmodule_pprintf(char** page, const char* fmt, ...) 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 56d641c9c87c..9ea8fc5896d8 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 @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: lkm.h,v 1.22 Broadcom SDK $ @@ -34,7 +45,8 @@ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #include #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) +/* The version kconfig.h became available in. */ #include #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) 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 3de3e07080c4..b8697731dd4e 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 @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # -*- Makefile -*- # $Id: Makefile,v 1.3 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/knet-cb.c b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/knet-cb.c index 1626d33c1c5d..650a4ced1d7a 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/knet-cb.c +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/knet-cb.c @@ -107,7 +107,7 @@ static struct sk_buff *strip_tag_rx_cb(struct sk_buff *skb, int dev_no, void *me static struct sk_buff *strip_tag_tx_cb(struct sk_buff *skb, int dev_no, void *meta); static int strip_tag_filter_cb(uint8_t * pkt, int size, int dev_no, void *meta, int chan, kcom_filter_t * kf); -static int _pprint(void); +static int _pprint(struct seq_file *m); static int _cleanup(void); static int _init(void); @@ -333,11 +333,11 @@ knet_filter_cb(uint8_t * pkt, int size, int dev_no, void *meta, int chan, kcom_filter_t *kf) { /* check for filter callback handler */ -#ifdef PSAMPLE_SUPPORT + #ifdef PSAMPLE_SUPPORT if (strncmp(kf->desc, PSAMPLE_CB_NAME, KCOM_FILTER_DESC_MAX) == 0) { return psample_filter_cb (pkt, size, dev_no, meta, chan, kf); } -#endif + #endif return strip_tag_filter_cb (pkt, size, dev_no, meta, chan, kf); } @@ -366,12 +366,12 @@ knet_netif_destroy_cb(int unit, kcom_netif_t *netif, struct net_device *dev) * % cat /proc/linux-knet-cb */ static int -_pprint(void) +_pprint(struct seq_file *m) { - pprintf("Broadcom Linux KNET Call-Back: Untagged VLAN Stripper\n"); - pprintf(" %lu stripped packets\n", strip_stats.stripped); - pprintf(" %lu packets checked\n", strip_stats.checked); - pprintf(" %lu packets skipped\n", strip_stats.skipped); + pprintf(m, "Broadcom Linux KNET Call-Back: Untagged VLAN Stripper\n"); + pprintf(m, " %lu stripped packets\n", strip_stats.stripped); + pprintf(m ," %lu packets checked\n", strip_stats.checked); + pprintf(m, " %lu packets skipped\n", strip_stats.skipped); return 0; } @@ -395,6 +395,7 @@ _cleanup(void) #ifdef PSAMPLE_SUPPORT psample_cleanup(); #endif + return 0; } @@ -410,9 +411,10 @@ _init(void) bkn_tx_skb_cb_register(strip_tag_tx_cb); } -#ifdef PSAMPLE_SUPPORT + #ifdef PSAMPLE_SUPPORT psample_init(); -#endif + #endif + bkn_filter_cb_register(knet_filter_cb); bkn_netif_create_cb_register(knet_netif_create_cb); 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 e1a6086a52ae..755955b20fdd 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 @@ -967,7 +967,7 @@ psample_proc_stats_open(struct inode * inode, struct file * file) * psample stats Proc Write Entry * * Syntax: - * write any value to clear stats + * write any value to clear stats */ static ssize_t psample_proc_stats_write(struct file *file, const char *buf, @@ -1009,13 +1009,13 @@ int psample_cleanup(void) int psample_init(void) { #define PROCFS_MAX_PATH 1024 + #define PSAMPLE_PROCFS_PATH "bcm/knet-cb" char psample_procfs_path[PROCFS_MAX_PATH]; struct proc_dir_entry *entry; /* create procfs for psample */ - snprintf(psample_procfs_path, PROCFS_MAX_PATH, "bcm/knet-cb"); - knet_cb_proc_root = proc_mkdir(psample_procfs_path, NULL); - snprintf(psample_procfs_path, PROCFS_MAX_PATH, "%s/%s", psample_procfs_path, PSAMPLE_CB_NAME); + proc_mkdir(PSAMPLE_PROCFS_PATH, NULL); + snprintf(psample_procfs_path, sizeof(psample_procfs_path), "%s/%s", PSAMPLE_PROCFS_PATH, PSAMPLE_CB_NAME); psample_proc_root = proc_mkdir(psample_procfs_path, NULL); /* create procfs for psample stats */ @@ -1031,7 +1031,7 @@ int psample_init(void) gprintk("%s: Unable to create procfs entry '/procfs/%s/rate'\n", __func__, psample_procfs_path); return -1; } - + /* create procfs for setting sample size */ PROC_CREATE(entry, "size", 0666, psample_proc_root, &psample_proc_size_file_ops); if (entry == NULL) { @@ -1059,23 +1059,23 @@ int psample_init(void) memset(&g_psample_work, 0, sizeof(psample_work_t)); /* setup psample_info struct */ - INIT_LIST_HEAD(&g_psample_info.netif_list); + INIT_LIST_HEAD(&g_psample_info.netif_list); spin_lock_init(&g_psample_info.lock); /* setup psample work queue */ - spin_lock_init(&g_psample_work.lock); - INIT_LIST_HEAD(&g_psample_work.pkt_list); + spin_lock_init(&g_psample_work.lock); + INIT_LIST_HEAD(&g_psample_work.pkt_list); INIT_WORK(&g_psample_work.wq, psample_task); - /* get net namespace */ + /* get net namespace */ g_psample_info.netns = get_net_ns_by_pid(current->pid); if (!g_psample_info.netns) { gprintk("%s: Could not get network namespace for pid %d\n", __func__, current->pid); return (-1); } - PSAMPLE_CB_DBG_PRINT("%s: current->pid %d, netns 0x%p, sample_size %d\n", __func__, + PSAMPLE_CB_DBG_PRINT("%s: current->pid %d, netns 0x%p, sample_size %d\n", __func__, current->pid, g_psample_info.netns, psample_size); - + return 0; } diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/psample/psample.c b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/psample/psample.c index 1deccacc5edd..99317cbf30cc 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/psample/psample.c +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/psample/psample.c @@ -224,7 +224,7 @@ void psample_sample_packet(struct psample_group *group, struct sk_buff *skb, data_len = PSAMPLE_MAX_PACKET_SIZE - meta_len - NLA_HDRLEN - NLA_ALIGNTO; - nl_skb = genlmsg_new(meta_len + data_len, GFP_ATOMIC); + nl_skb = genlmsg_new(meta_len + nla_total_size(data_len), GFP_ATOMIC); if (unlikely(!nl_skb)) return; diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/Makefile b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/Makefile index 5e97a3a32123..966f639f6983 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/Makefile @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # -*- Makefile -*- # $Id: Makefile,v 1.2 Broadcom SDK $ 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 cdfaf089674a..3ef000961837 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 @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: gmodule.c,v 1.20 Broadcom SDK $ @@ -26,8 +37,6 @@ #include #include #include -#include - /* Module Vector Table */ static gmodule_t* _gmodule = NULL; @@ -94,21 +103,18 @@ gdbg(const char* fmt, ...) * Proc FS Utilities */ #if PROC_INTERFACE_KERN_VER_3_10 -static struct seq_file* _proc_buf = NULL; - int -pprintf(const char* fmt, ...) +pprintf(struct seq_file *m, const char* fmt, ...) { va_list args; va_start(args, fmt); - seq_vprintf(_proc_buf, fmt, args); + seq_vprintf(m, fmt, args); va_end(args); return 0; } static int _gmodule_proc_show(struct seq_file *m, void *v){ - _proc_buf = m; - _gmodule->pprint(); + _gmodule->pprint(m); return 0; } @@ -174,7 +180,7 @@ gmodule_pprintf(char** page_ptr, const char* fmt, ...) static char* _proc_buf = NULL; int -pprintf(const char* fmt, ...) +pprintf(struct seq_file *m, const char* fmt, ...) { int rv; @@ -193,7 +199,7 @@ static int _gmodule_pprint(char* buf) { PSTART(buf); - _gmodule->pprint(); + _gmodule->pprint(NULL); return PEND(buf); } 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 d1caf871f0e2..7f90c59c3a39 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 @@ -1,5 +1,10 @@ /* - * Copyright 2017 Broadcom + * Copyright 2007-2020 Broadcom Inc. All rights reserved. + * + * Permission is granted to use, copy, modify and/or distribute this + * software under either one of the licenses below. + * + * License Option 1: GPL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ * * You should have received a copy of the GNU General Public License * version 2 (GPLv2) along with this source code. + * + * + * License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license + * + * This software is governed by the Broadcom Open Network Switch APIs license: + * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* * $Id: ksal.c,v 1.1 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/common/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/common/Makefile index f95593a383ce..8f59a763e314 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/common/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/common/Makefile @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # -*- Makefile -*- # $Id: Makefile,v 1.4 Broadcom SDK $ @@ -113,6 +124,7 @@ endif ifndef BUILD_KNET BUILD_KNET = 1 endif + # Remove this when LinuxPTP support becomes optional. ifndef BUILD_LPTP BUILD_LPTP = 1 @@ -141,7 +153,6 @@ ifdef BUILD_PSAMPLE all_targets += $(PSAMPLE) ADD_TO_CFLAGS += -DPSAMPLE_SUPPORT - # KnetSync support ifdef BUILD_KNETSYNC @@ -151,17 +162,17 @@ LOCAL_KERNEL_TARGETS += $(patsubst %,$(realpath ..)/$(platform)/%,$(BCM_PTP_CLOC endif # BUILD_KNETSYNC ifeq ($(NO_LOCAL_TARGETS),) -LOCAL_TARGETS +=$(patsubst %,../$(platform)/%,$(PSAMPLE_LOCAL)) -all_targets +=$(LOCAL_TARGETS) + LOCAL_TARGETS +=$(patsubst %,../$(platform)/%,$(PSAMPLE_LOCAL)) + all_targets +=$(LOCAL_TARGETS) endif endif ifdef BUILD_LPTP -all_targets += $(BCM_LPTP) + all_targets += $(BCM_LPTP) ifeq ($(NO_LOCAL_TARGETS),) -LOCAL_TARGETS +=$(patsubst %,../$(platform)/%,$(BCM_LPTP_LOCAL)) -all_targets +=$(LOCAL_TARGETS) + LOCAL_TARGETS +=$(patsubst %,../$(platform)/%,$(BCM_LPTP_LOCAL)) + all_targets +=$(LOCAL_TARGETS) endif endif @@ -191,7 +202,7 @@ CFLAGS:=$(filter-out -fPIC, $(CFLAGS)) # KnetSync Support ifdef BUILD_KNETSYNC -knetsync_subdirs = bcm-ptp-clock + knetsync_subdirs = bcm-ptp-clock endif # BUILD_KNETSYNC kernel_modules: @@ -200,7 +211,7 @@ kernel_modules: ifeq ($(BUILD_KNET),1) $(MAKE) -C $(SDK)/systems/linux/kernel/modules kernel_version=$(kernel_version) \ subdirs="shared bcm-knet" override-target=linux-$(platform) CFLAGS="$(CFLAGS)" -ifdef BUILD_PSAMPLE +ifdef BUILD_PSAMPLE $(MAKE) -C $(SDK)/systems/linux/kernel/modules kernel_version=$(kernel_version) \ subdirs="psample" override-target=linux-$(platform) CFLAGS="$(CFLAGS)" endif diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/gts/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/gts/Makefile index 466faf02a515..5acaeab271cc 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/gts/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/gts/Makefile @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # -*- Makefile -*- # $Id: Makefile,v 0.1 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/iproc-3_14/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/iproc-3_14/Makefile index c9f538802f6d..b874340ddec2 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/iproc-3_14/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/iproc-3_14/Makefile @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # -*- Makefile -*- # $Id: Makefile,v 1.7 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/iproc-4_4/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/iproc-4_4/Makefile index e8405f5c2a0c..2b724be3202f 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/iproc-4_4/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/iproc-4_4/Makefile @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # -*- Makefile -*- # $Id: Makefile,v 1.7 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/iproc/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/iproc/Makefile index 03300ff8a046..f10c5c37a082 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/iproc/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/iproc/Makefile @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # -*- Makefile -*- # $Id: Makefile,v 1.7 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/iproc_64/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/iproc_64/Makefile index 778c85a03bed..983b3abbced7 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/iproc_64/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/iproc_64/Makefile @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # -*- Makefile -*- # $Id: Makefile,v 1.7 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/slk/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/slk/Makefile index 99d49d285145..6ef360156572 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/slk/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/slk/Makefile @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # -*- Makefile -*- # $Id: Makefile,v 0.1 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/x86-smp_generic_64-2_6/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/x86-smp_generic_64-2_6/Makefile index 29717b3af42a..78c2c0cb1702 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/x86-smp_generic_64-2_6/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/x86-smp_generic_64-2_6/Makefile @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # -*- Makefile -*- # $Id: Makefile,v 1.2 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/xlr/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/xlr/Makefile index 13246d09e78f..e19eeff4aef2 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/xlr/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/xlr/Makefile @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # -*- Makefile -*- # $Id: Makefile,v 0.1 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/tools/mktool.pl b/platform/broadcom/saibcm-modules/tools/mktool.pl index 8800c00613d8..518ab25535c3 100644 --- a/platform/broadcom/saibcm-modules/tools/mktool.pl +++ b/platform/broadcom/saibcm-modules/tools/mktool.pl @@ -1,5 +1,10 @@ # -# Copyright 2017 Broadcom +# Copyright 2007-2020 Broadcom Inc. All rights reserved. +# +# Permission is granted to use, copy, modify and/or distribute this +# software under either one of the licenses below. +# +# License Option 1: GPL # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as @@ -12,6 +17,12 @@ # # You should have received a copy of the GNU General Public License # version 2 (GPLv2) along with this source code. +# +# +# License Option 2: Broadcom Open Network Switch APIs (OpenNSA) license +# +# This software is governed by the Broadcom Open Network Switch APIs license: +# https://www.broadcom.com/products/ethernet-connectivity/software/opennsa # # # mktool.pl From 6f17c924e60ab1ed5f764b3dd15d921e747b0344 Mon Sep 17 00:00:00 2001 From: Tamer Ahmed Date: Fri, 29 Jan 2021 14:15:48 -0800 Subject: [PATCH 0146/1674] [sonic-device-data]: Update BRCM Tunnel/ECMP Parameter For 7050cx3 SKUs (#6415) Update Tunnel and ECMP parameters for brcm 7050cx3 48x50G+8x100G and 32x100G SKUs. signed-off-by: Tamer Ahmed --- .../td3-a7050cx3-32s-32x100G.config.bcm | 10 ++++++++++ .../td3-a7050cx3-32s-48x50G+8x100G.config.bcm | 10 ++++++++++ src/sonic-device-data/tests/permitted_list | 11 +++++++++++ 3 files changed, 31 insertions(+) diff --git a/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/td3-a7050cx3-32s-32x100G.config.bcm b/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/td3-a7050cx3-32s-32x100G.config.bcm index 09354d6fd8e7..10a5b822afce 100644 --- a/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/td3-a7050cx3-32s-32x100G.config.bcm +++ b/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/td3-a7050cx3-32s-32x100G.config.bcm @@ -1,3 +1,13 @@ +host_as_route_disable=1 +use_all_splithorizon_groups=1 +riot_enable=1 +sai_tunnel_support=1 +riot_overlay_l3_intf_mem_size=4096 +riot_overlay_l3_egress_mem_size=32768 +l3_ecmp_levels=3 +riot_overlay_ecmp_resilient_hash_size=16384 +flow_init_mode=1 +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ arl_clean_timeout_usec=15000000 asf_mem_profile=2 bcm_num_cos=10 diff --git a/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-D48C8/td3-a7050cx3-32s-48x50G+8x100G.config.bcm b/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-D48C8/td3-a7050cx3-32s-48x50G+8x100G.config.bcm index 2b7da96358d5..d71f01529b02 100644 --- a/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-D48C8/td3-a7050cx3-32s-48x50G+8x100G.config.bcm +++ b/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-D48C8/td3-a7050cx3-32s-48x50G+8x100G.config.bcm @@ -1,3 +1,13 @@ +host_as_route_disable=1 +use_all_splithorizon_groups=1 +riot_enable=1 +sai_tunnel_support=1 +riot_overlay_l3_intf_mem_size=4096 +riot_overlay_l3_egress_mem_size=32768 +l3_ecmp_levels=3 +riot_overlay_ecmp_resilient_hash_size=16384 +flow_init_mode=1 +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ arl_clean_timeout_usec=15000000 asf_mem_profile=2 bcm_num_cos=8 diff --git a/src/sonic-device-data/tests/permitted_list b/src/sonic-device-data/tests/permitted_list index 8feb791875ef..997250cbf6b8 100644 --- a/src/sonic-device-data/tests/permitted_list +++ b/src/sonic-device-data/tests/permitted_list @@ -1,3 +1,13 @@ +sai_trap_group_priority +use_all_splithorizon_groups +riot_enable +sai_tunnel_support +riot_overlay_l3_intf_mem_size +riot_overlay_l3_egress_mem_size +l3_ecmp_levels +riot_overlay_ecmp_resilient_hash_size +flow_init_mode +sai_load_hw_config arl_clean_timeout_usec asf_mem_profile bcm_linkscan_interval @@ -219,3 +229,4 @@ serdes_fec_enable pbmp_gport_stack reglist_enable scache_filename +host_as_route_disable From 7199cb87d260a4503a02a042cbfecb3bc65bbcf9 Mon Sep 17 00:00:00 2001 From: Mahesh Maddikayala <10645050+smaheshm@users.noreply.github.com> Date: Sat, 30 Jan 2021 14:41:17 -0800 Subject: [PATCH 0147/1674] [broadcom]: Add BCM config variable that contains premier cancun firmware path (#6611) BRCM SDK 6.5.21 includes firmware updates (premier cancun) for TD3 platforms. The firmware update is required on TD3 platforms, which is packaged with BCMSAI 4.3.0.10. **- How I did it** Updated BCM config with a new variable that specifies the firmware package path. SDK uses this path to locate firmware packages and load during cold boot. **- How to verify it** bsv BRCM SAI ver: [4.3.0.10], OCP SAI ver: [1.7.1], SDK ver: [sdk-6.5.21] CANCUN ver: [5.3.3] drivshell> admin@str2-7050cx3-acs-02:~$ bcmsh Press Enter to show prompt. Press Ctrl+C to exit. NOTICE: Only one bcmsh or bcmcmd can connect to the shell at same time. drivshell>cancun stat cancun stat UNIT0 CANCUN: CIH: LOADED Ver: 06.06.01 CMH: LOADED Ver: 06.06.01 SDK Ver: 06.05.21 CCH: LOADED Ver: 06.06.01 SDK Ver: 06.05.21 CEH: LOADED Ver: 06.06.01 SDK Ver: 06.05.21 drivshell> --- .../Accton-AS7326-56X/td3-as7326-48x25G+8x100G.config.bcm | 1 + .../Accton-AS7726-32X/td3-as7726-32x100G.config.bcm | 1 + .../Seastone_2/td3-seastone_2-32x100G.config.bcm | 1 + .../DellEMC-S5232f-C32/td3-s5232f-32x100G.config.bcm | 1 + .../DellEMC-S5232f-C8D48/td3-s5232f-8x100G+48x50G.config.bcm | 1 + .../DellEMC-S5232f-P-100G/td3-s5232f-32x100G.config.bcm | 1 + .../DellEMC-S5232f-P-10G/td3-s5232f-96x10G+8x100G.config.bcm | 1 + .../DellEMC-S5232f-P-25G/td3-s5232f-96x25G+8x100G.config.bcm | 1 + .../DellEMC-S5248f-P-10G/td3-s5248f-10g.config.bcm | 1 + .../DellEMC-S5248f-P-25G/td3-s5248f-25g.config.bcm | 1 + .../DellEMC-S5296f-P-10G/td3-s5296f-10g.config.bcm | 1 + .../DellEMC-S5296f-P-25G/td3-s5296f-25g.config.bcm | 1 + .../Delta-ag9032v2a/td3-ag9032v2a-32x100G+1x10G.config.bcm | 1 + .../INVENTEC-D6332/td3-d6332-32x100G-SR4.config.bcm | 1 + .../INVENTEC-D6356/td3-d6356-48x25G-8x100G.config.bcm | 1 + .../Quanta-IX7-32X/td3-ix7-32x100G.config.bcm | 1 + .../Quanta-IX8-56X/td3-ix8-48x25G+8x100G.config.bcm | 1 + .../Quanta-IX8C-56X/td3-ix8c-48x25G+8x100G.config.bcm | 1 + 18 files changed, 18 insertions(+) diff --git a/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/td3-as7326-48x25G+8x100G.config.bcm b/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/td3-as7326-48x25G+8x100G.config.bcm index 83f614bf093d..fd76d1f93171 100755 --- a/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/td3-as7326-48x25G+8x100G.config.bcm +++ b/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/td3-as7326-48x25G+8x100G.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ #polarity/lanemap is using TH2 style. core_clock_frequency=1525 dpp_clock_ratio=2:3 diff --git a/device/accton/x86_64-accton_as7726_32x-r0/Accton-AS7726-32X/td3-as7726-32x100G.config.bcm b/device/accton/x86_64-accton_as7726_32x-r0/Accton-AS7726-32X/td3-as7726-32x100G.config.bcm index 8042955fcae7..e64fd49c6ec7 100755 --- a/device/accton/x86_64-accton_as7726_32x-r0/Accton-AS7726-32X/td3-as7726-32x100G.config.bcm +++ b/device/accton/x86_64-accton_as7726_32x-r0/Accton-AS7726-32X/td3-as7726-32x100G.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ #polarity/lanemap is using TH2 style. core_clock_frequency=1525 dpp_clock_ratio=2:3 diff --git a/device/celestica/x86_64-cel_seastone_2-r0/Seastone_2/td3-seastone_2-32x100G.config.bcm b/device/celestica/x86_64-cel_seastone_2-r0/Seastone_2/td3-seastone_2-32x100G.config.bcm index 2c23d0da2f22..c146e4621023 100644 --- a/device/celestica/x86_64-cel_seastone_2-r0/Seastone_2/td3-seastone_2-32x100G.config.bcm +++ b/device/celestica/x86_64-cel_seastone_2-r0/Seastone_2/td3-seastone_2-32x100G.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ help_cli_enable=1 ifp_inports_support_enable=1 ipv6_lpm_128b_enable=0x1 diff --git a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-C32/td3-s5232f-32x100G.config.bcm b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-C32/td3-s5232f-32x100G.config.bcm index 3f50f39db8e5..49eb1dc29289 100644 --- a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-C32/td3-s5232f-32x100G.config.bcm +++ b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-C32/td3-s5232f-32x100G.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ os=unix core_clock_frequency=1525 diff --git a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-C8D48/td3-s5232f-8x100G+48x50G.config.bcm b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-C8D48/td3-s5232f-8x100G+48x50G.config.bcm index 4f3121387dea..2fa422fd1f5b 100644 --- a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-C8D48/td3-s5232f-8x100G+48x50G.config.bcm +++ b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-C8D48/td3-s5232f-8x100G+48x50G.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ os=unix core_clock_frequency=1525 diff --git a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-100G/td3-s5232f-32x100G.config.bcm b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-100G/td3-s5232f-32x100G.config.bcm index 099d1270443e..28743920ce93 100644 --- a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-100G/td3-s5232f-32x100G.config.bcm +++ b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-100G/td3-s5232f-32x100G.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ os=unix core_clock_frequency=1525 diff --git a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-10G/td3-s5232f-96x10G+8x100G.config.bcm b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-10G/td3-s5232f-96x10G+8x100G.config.bcm index caf255d892e8..1bda551a5b9a 100644 --- a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-10G/td3-s5232f-96x10G+8x100G.config.bcm +++ b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-10G/td3-s5232f-96x10G+8x100G.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ os=unix core_clock_frequency=1525 diff --git a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-25G/td3-s5232f-96x25G+8x100G.config.bcm b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-25G/td3-s5232f-96x25G+8x100G.config.bcm index 84bd873acc4b..cced29e6e494 100644 --- a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-25G/td3-s5232f-96x25G+8x100G.config.bcm +++ b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-25G/td3-s5232f-96x25G+8x100G.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ os=unix core_clock_frequency=1525 diff --git a/device/dell/x86_64-dellemc_s5248f_c3538-r0/DellEMC-S5248f-P-10G/td3-s5248f-10g.config.bcm b/device/dell/x86_64-dellemc_s5248f_c3538-r0/DellEMC-S5248f-P-10G/td3-s5248f-10g.config.bcm index 2369f4590795..c6f7d4bb5044 100644 --- a/device/dell/x86_64-dellemc_s5248f_c3538-r0/DellEMC-S5248f-P-10G/td3-s5248f-10g.config.bcm +++ b/device/dell/x86_64-dellemc_s5248f_c3538-r0/DellEMC-S5248f-P-10G/td3-s5248f-10g.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ os=unix dpp_clock_ratio=2:3 oversubscribe_mode=1 diff --git a/device/dell/x86_64-dellemc_s5248f_c3538-r0/DellEMC-S5248f-P-25G/td3-s5248f-25g.config.bcm b/device/dell/x86_64-dellemc_s5248f_c3538-r0/DellEMC-S5248f-P-25G/td3-s5248f-25g.config.bcm index 4095c2d0a4f4..31d03149e721 100644 --- a/device/dell/x86_64-dellemc_s5248f_c3538-r0/DellEMC-S5248f-P-25G/td3-s5248f-25g.config.bcm +++ b/device/dell/x86_64-dellemc_s5248f_c3538-r0/DellEMC-S5248f-P-25G/td3-s5248f-25g.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ os=unix dpp_clock_ratio=2:3 diff --git a/device/dell/x86_64-dellemc_s5296f_c3538-r0/DellEMC-S5296f-P-10G/td3-s5296f-10g.config.bcm b/device/dell/x86_64-dellemc_s5296f_c3538-r0/DellEMC-S5296f-P-10G/td3-s5296f-10g.config.bcm index 7351e6908e78..930c80978312 100644 --- a/device/dell/x86_64-dellemc_s5296f_c3538-r0/DellEMC-S5296f-P-10G/td3-s5296f-10g.config.bcm +++ b/device/dell/x86_64-dellemc_s5296f_c3538-r0/DellEMC-S5296f-P-10G/td3-s5296f-10g.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ os=unix portmap_5.0=5:10 portmap_6.0=6:10 diff --git a/device/dell/x86_64-dellemc_s5296f_c3538-r0/DellEMC-S5296f-P-25G/td3-s5296f-25g.config.bcm b/device/dell/x86_64-dellemc_s5296f_c3538-r0/DellEMC-S5296f-P-25G/td3-s5296f-25g.config.bcm index 81a42406e75f..496fc443539e 100644 --- a/device/dell/x86_64-dellemc_s5296f_c3538-r0/DellEMC-S5296f-P-25G/td3-s5296f-25g.config.bcm +++ b/device/dell/x86_64-dellemc_s5296f_c3538-r0/DellEMC-S5296f-P-25G/td3-s5296f-25g.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ os=unix portmap_5.0=5:25 portmap_6.0=6:25 diff --git a/device/delta/x86_64-delta_ag9032v2a-r0/Delta-ag9032v2a/td3-ag9032v2a-32x100G+1x10G.config.bcm b/device/delta/x86_64-delta_ag9032v2a-r0/Delta-ag9032v2a/td3-ag9032v2a-32x100G+1x10G.config.bcm index 2cef2f4261a3..634a0bb3876a 100755 --- a/device/delta/x86_64-delta_ag9032v2a-r0/Delta-ag9032v2a/td3-ag9032v2a-32x100G+1x10G.config.bcm +++ b/device/delta/x86_64-delta_ag9032v2a-r0/Delta-ag9032v2a/td3-ag9032v2a-32x100G+1x10G.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ pbmp_oversubscribe=0x00003fc000000ff0000003fc000001fe pbmp_xport_xe=0xffffffffffffffffffffffffffffffffffff core_clock_frequency=1525 diff --git a/device/inventec/x86_64-inventec_d6332-r0/INVENTEC-D6332/td3-d6332-32x100G-SR4.config.bcm b/device/inventec/x86_64-inventec_d6332-r0/INVENTEC-D6332/td3-d6332-32x100G-SR4.config.bcm index 27670075cf99..40ec86f0be9f 100644 --- a/device/inventec/x86_64-inventec_d6332-r0/INVENTEC-D6332/td3-d6332-32x100G-SR4.config.bcm +++ b/device/inventec/x86_64-inventec_d6332-r0/INVENTEC-D6332/td3-d6332-32x100G-SR4.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ ### fix for sonic ptp_ts_pll_fref=50000000 ptp_bs_fref_0=50000000 diff --git a/device/inventec/x86_64-inventec_d6356-r0/INVENTEC-D6356/td3-d6356-48x25G-8x100G.config.bcm b/device/inventec/x86_64-inventec_d6356-r0/INVENTEC-D6356/td3-d6356-48x25G-8x100G.config.bcm index 57fd5cd57164..bd61d3610633 100644 --- a/device/inventec/x86_64-inventec_d6356-r0/INVENTEC-D6356/td3-d6356-48x25G-8x100G.config.bcm +++ b/device/inventec/x86_64-inventec_d6356-r0/INVENTEC-D6356/td3-d6356-48x25G-8x100G.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ ### fix for sonic ptp_ts_pll_fref=50000000 ptp_bs_fref_0=50000000 diff --git a/device/quanta/x86_64-quanta_ix7_rglbmc-r0/Quanta-IX7-32X/td3-ix7-32x100G.config.bcm b/device/quanta/x86_64-quanta_ix7_rglbmc-r0/Quanta-IX7-32X/td3-ix7-32x100G.config.bcm index aaea0380e50b..14cf4a16bfbe 100644 --- a/device/quanta/x86_64-quanta_ix7_rglbmc-r0/Quanta-IX7-32X/td3-ix7-32x100G.config.bcm +++ b/device/quanta/x86_64-quanta_ix7_rglbmc-r0/Quanta-IX7-32X/td3-ix7-32x100G.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ bcm_tunnel_term_compatible_mode=1 core_clock_frequency=1525 dpp_clock_ratio=2:3 diff --git a/device/quanta/x86_64-quanta_ix8_rglbmc-r0/Quanta-IX8-56X/td3-ix8-48x25G+8x100G.config.bcm b/device/quanta/x86_64-quanta_ix8_rglbmc-r0/Quanta-IX8-56X/td3-ix8-48x25G+8x100G.config.bcm index 407105d0ca0a..4b146ad897ec 100644 --- a/device/quanta/x86_64-quanta_ix8_rglbmc-r0/Quanta-IX8-56X/td3-ix8-48x25G+8x100G.config.bcm +++ b/device/quanta/x86_64-quanta_ix8_rglbmc-r0/Quanta-IX8-56X/td3-ix8-48x25G+8x100G.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ bcm_tunnel_term_compatible_mode=1 core_clock_frequency=1525 dpp_clock_ratio=2:3 diff --git a/device/quanta/x86_64-quanta_ix8c_bwde-r0/Quanta-IX8C-56X/td3-ix8c-48x25G+8x100G.config.bcm b/device/quanta/x86_64-quanta_ix8c_bwde-r0/Quanta-IX8C-56X/td3-ix8c-48x25G+8x100G.config.bcm index 407105d0ca0a..4b146ad897ec 100644 --- a/device/quanta/x86_64-quanta_ix8c_bwde-r0/Quanta-IX8C-56X/td3-ix8c-48x25G+8x100G.config.bcm +++ b/device/quanta/x86_64-quanta_ix8c_bwde-r0/Quanta-IX8C-56X/td3-ix8c-48x25G+8x100G.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ bcm_tunnel_term_compatible_mode=1 core_clock_frequency=1525 dpp_clock_ratio=2:3 From fadf10529ac3a47d8420269e88564f4c6fcb04ef Mon Sep 17 00:00:00 2001 From: gechiang <62408185+gechiang@users.noreply.github.com> Date: Tue, 2 Feb 2021 21:48:26 -0800 Subject: [PATCH 0148/1674] [BCM Config] Update TD3 bcm.config files to use ISSU capable premium CANCUN 6.4.1 (#6651) --- .../Accton-AS7326-56X/td3-as7326-48x25G+8x100G.config.bcm | 2 +- .../Accton-AS7726-32X/td3-as7726-32x100G.config.bcm | 2 +- .../Arista-7050CX3-32S-C32/td3-a7050cx3-32s-32x100G.config.bcm | 2 +- .../td3-a7050cx3-32s-48x50G+8x100G.config.bcm | 2 +- .../Seastone_2/td3-seastone_2-32x100G.config.bcm | 2 +- .../DellEMC-S5232f-C32/td3-s5232f-32x100G.config.bcm | 2 +- .../DellEMC-S5232f-C8D48/td3-s5232f-8x100G+48x50G.config.bcm | 2 +- .../DellEMC-S5232f-P-100G/td3-s5232f-32x100G.config.bcm | 2 +- .../DellEMC-S5232f-P-10G/td3-s5232f-96x10G+8x100G.config.bcm | 2 +- .../DellEMC-S5232f-P-25G/td3-s5232f-96x25G+8x100G.config.bcm | 2 +- .../DellEMC-S5248f-P-10G/td3-s5248f-10g.config.bcm | 2 +- .../DellEMC-S5248f-P-25G/td3-s5248f-25g.config.bcm | 2 +- .../DellEMC-S5296f-P-10G/td3-s5296f-10g.config.bcm | 2 +- .../DellEMC-S5296f-P-25G/td3-s5296f-25g.config.bcm | 2 +- .../Delta-ag9032v2a/td3-ag9032v2a-32x100G+1x10G.config.bcm | 2 +- .../INVENTEC-D6332/td3-d6332-32x100G-SR4.config.bcm | 2 +- .../INVENTEC-D6356/td3-d6356-48x25G-8x100G.config.bcm | 2 +- .../Quanta-IX7-32X/td3-ix7-32x100G.config.bcm | 2 +- .../Quanta-IX8-56X/td3-ix8-48x25G+8x100G.config.bcm | 2 +- .../Quanta-IX8C-56X/td3-ix8c-48x25G+8x100G.config.bcm | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/td3-as7326-48x25G+8x100G.config.bcm b/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/td3-as7326-48x25G+8x100G.config.bcm index fd76d1f93171..5da8cd015da1 100755 --- a/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/td3-as7326-48x25G+8x100G.config.bcm +++ b/device/accton/x86_64-accton_as7326_56x-r0/Accton-AS7326-56X/td3-as7326-48x25G+8x100G.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ #polarity/lanemap is using TH2 style. core_clock_frequency=1525 dpp_clock_ratio=2:3 diff --git a/device/accton/x86_64-accton_as7726_32x-r0/Accton-AS7726-32X/td3-as7726-32x100G.config.bcm b/device/accton/x86_64-accton_as7726_32x-r0/Accton-AS7726-32X/td3-as7726-32x100G.config.bcm index e64fd49c6ec7..f88656bfd5cf 100755 --- a/device/accton/x86_64-accton_as7726_32x-r0/Accton-AS7726-32X/td3-as7726-32x100G.config.bcm +++ b/device/accton/x86_64-accton_as7726_32x-r0/Accton-AS7726-32X/td3-as7726-32x100G.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ #polarity/lanemap is using TH2 style. core_clock_frequency=1525 dpp_clock_ratio=2:3 diff --git a/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/td3-a7050cx3-32s-32x100G.config.bcm b/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/td3-a7050cx3-32s-32x100G.config.bcm index 10a5b822afce..c3b350204875 100644 --- a/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/td3-a7050cx3-32s-32x100G.config.bcm +++ b/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/td3-a7050cx3-32s-32x100G.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ host_as_route_disable=1 use_all_splithorizon_groups=1 riot_enable=1 @@ -7,7 +8,6 @@ riot_overlay_l3_egress_mem_size=32768 l3_ecmp_levels=3 riot_overlay_ecmp_resilient_hash_size=16384 flow_init_mode=1 -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ arl_clean_timeout_usec=15000000 asf_mem_profile=2 bcm_num_cos=10 diff --git a/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-D48C8/td3-a7050cx3-32s-48x50G+8x100G.config.bcm b/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-D48C8/td3-a7050cx3-32s-48x50G+8x100G.config.bcm index d71f01529b02..1b5b7e338708 100644 --- a/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-D48C8/td3-a7050cx3-32s-48x50G+8x100G.config.bcm +++ b/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-D48C8/td3-a7050cx3-32s-48x50G+8x100G.config.bcm @@ -1,3 +1,4 @@ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ host_as_route_disable=1 use_all_splithorizon_groups=1 riot_enable=1 @@ -7,7 +8,6 @@ riot_overlay_l3_egress_mem_size=32768 l3_ecmp_levels=3 riot_overlay_ecmp_resilient_hash_size=16384 flow_init_mode=1 -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ arl_clean_timeout_usec=15000000 asf_mem_profile=2 bcm_num_cos=8 diff --git a/device/celestica/x86_64-cel_seastone_2-r0/Seastone_2/td3-seastone_2-32x100G.config.bcm b/device/celestica/x86_64-cel_seastone_2-r0/Seastone_2/td3-seastone_2-32x100G.config.bcm index c146e4621023..62bcdbc58840 100644 --- a/device/celestica/x86_64-cel_seastone_2-r0/Seastone_2/td3-seastone_2-32x100G.config.bcm +++ b/device/celestica/x86_64-cel_seastone_2-r0/Seastone_2/td3-seastone_2-32x100G.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ help_cli_enable=1 ifp_inports_support_enable=1 ipv6_lpm_128b_enable=0x1 diff --git a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-C32/td3-s5232f-32x100G.config.bcm b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-C32/td3-s5232f-32x100G.config.bcm index 49eb1dc29289..bf15510bf49b 100644 --- a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-C32/td3-s5232f-32x100G.config.bcm +++ b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-C32/td3-s5232f-32x100G.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ os=unix core_clock_frequency=1525 diff --git a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-C8D48/td3-s5232f-8x100G+48x50G.config.bcm b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-C8D48/td3-s5232f-8x100G+48x50G.config.bcm index 2fa422fd1f5b..68fb77a4219f 100644 --- a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-C8D48/td3-s5232f-8x100G+48x50G.config.bcm +++ b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-C8D48/td3-s5232f-8x100G+48x50G.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ os=unix core_clock_frequency=1525 diff --git a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-100G/td3-s5232f-32x100G.config.bcm b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-100G/td3-s5232f-32x100G.config.bcm index 28743920ce93..c44e4805c62a 100644 --- a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-100G/td3-s5232f-32x100G.config.bcm +++ b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-100G/td3-s5232f-32x100G.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ os=unix core_clock_frequency=1525 diff --git a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-10G/td3-s5232f-96x10G+8x100G.config.bcm b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-10G/td3-s5232f-96x10G+8x100G.config.bcm index 1bda551a5b9a..6f62b7209198 100644 --- a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-10G/td3-s5232f-96x10G+8x100G.config.bcm +++ b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-10G/td3-s5232f-96x10G+8x100G.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ os=unix core_clock_frequency=1525 diff --git a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-25G/td3-s5232f-96x25G+8x100G.config.bcm b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-25G/td3-s5232f-96x25G+8x100G.config.bcm index cced29e6e494..a4fccde19686 100644 --- a/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-25G/td3-s5232f-96x25G+8x100G.config.bcm +++ b/device/dell/x86_64-dellemc_s5232f_c3538-r0/DellEMC-S5232f-P-25G/td3-s5232f-96x25G+8x100G.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ os=unix core_clock_frequency=1525 diff --git a/device/dell/x86_64-dellemc_s5248f_c3538-r0/DellEMC-S5248f-P-10G/td3-s5248f-10g.config.bcm b/device/dell/x86_64-dellemc_s5248f_c3538-r0/DellEMC-S5248f-P-10G/td3-s5248f-10g.config.bcm index c6f7d4bb5044..021f94dc32f7 100644 --- a/device/dell/x86_64-dellemc_s5248f_c3538-r0/DellEMC-S5248f-P-10G/td3-s5248f-10g.config.bcm +++ b/device/dell/x86_64-dellemc_s5248f_c3538-r0/DellEMC-S5248f-P-10G/td3-s5248f-10g.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ os=unix dpp_clock_ratio=2:3 oversubscribe_mode=1 diff --git a/device/dell/x86_64-dellemc_s5248f_c3538-r0/DellEMC-S5248f-P-25G/td3-s5248f-25g.config.bcm b/device/dell/x86_64-dellemc_s5248f_c3538-r0/DellEMC-S5248f-P-25G/td3-s5248f-25g.config.bcm index 31d03149e721..2630512df0ca 100644 --- a/device/dell/x86_64-dellemc_s5248f_c3538-r0/DellEMC-S5248f-P-25G/td3-s5248f-25g.config.bcm +++ b/device/dell/x86_64-dellemc_s5248f_c3538-r0/DellEMC-S5248f-P-25G/td3-s5248f-25g.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ os=unix dpp_clock_ratio=2:3 diff --git a/device/dell/x86_64-dellemc_s5296f_c3538-r0/DellEMC-S5296f-P-10G/td3-s5296f-10g.config.bcm b/device/dell/x86_64-dellemc_s5296f_c3538-r0/DellEMC-S5296f-P-10G/td3-s5296f-10g.config.bcm index 930c80978312..ddc14d9363d3 100644 --- a/device/dell/x86_64-dellemc_s5296f_c3538-r0/DellEMC-S5296f-P-10G/td3-s5296f-10g.config.bcm +++ b/device/dell/x86_64-dellemc_s5296f_c3538-r0/DellEMC-S5296f-P-10G/td3-s5296f-10g.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ os=unix portmap_5.0=5:10 portmap_6.0=6:10 diff --git a/device/dell/x86_64-dellemc_s5296f_c3538-r0/DellEMC-S5296f-P-25G/td3-s5296f-25g.config.bcm b/device/dell/x86_64-dellemc_s5296f_c3538-r0/DellEMC-S5296f-P-25G/td3-s5296f-25g.config.bcm index 496fc443539e..dd0901f5d01f 100644 --- a/device/dell/x86_64-dellemc_s5296f_c3538-r0/DellEMC-S5296f-P-25G/td3-s5296f-25g.config.bcm +++ b/device/dell/x86_64-dellemc_s5296f_c3538-r0/DellEMC-S5296f-P-25G/td3-s5296f-25g.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ os=unix portmap_5.0=5:25 portmap_6.0=6:25 diff --git a/device/delta/x86_64-delta_ag9032v2a-r0/Delta-ag9032v2a/td3-ag9032v2a-32x100G+1x10G.config.bcm b/device/delta/x86_64-delta_ag9032v2a-r0/Delta-ag9032v2a/td3-ag9032v2a-32x100G+1x10G.config.bcm index 634a0bb3876a..07600e0b8a65 100755 --- a/device/delta/x86_64-delta_ag9032v2a-r0/Delta-ag9032v2a/td3-ag9032v2a-32x100G+1x10G.config.bcm +++ b/device/delta/x86_64-delta_ag9032v2a-r0/Delta-ag9032v2a/td3-ag9032v2a-32x100G+1x10G.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ pbmp_oversubscribe=0x00003fc000000ff0000003fc000001fe pbmp_xport_xe=0xffffffffffffffffffffffffffffffffffff core_clock_frequency=1525 diff --git a/device/inventec/x86_64-inventec_d6332-r0/INVENTEC-D6332/td3-d6332-32x100G-SR4.config.bcm b/device/inventec/x86_64-inventec_d6332-r0/INVENTEC-D6332/td3-d6332-32x100G-SR4.config.bcm index 40ec86f0be9f..8fe7622f4b8f 100644 --- a/device/inventec/x86_64-inventec_d6332-r0/INVENTEC-D6332/td3-d6332-32x100G-SR4.config.bcm +++ b/device/inventec/x86_64-inventec_d6332-r0/INVENTEC-D6332/td3-d6332-32x100G-SR4.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ ### fix for sonic ptp_ts_pll_fref=50000000 ptp_bs_fref_0=50000000 diff --git a/device/inventec/x86_64-inventec_d6356-r0/INVENTEC-D6356/td3-d6356-48x25G-8x100G.config.bcm b/device/inventec/x86_64-inventec_d6356-r0/INVENTEC-D6356/td3-d6356-48x25G-8x100G.config.bcm index bd61d3610633..089207abd136 100644 --- a/device/inventec/x86_64-inventec_d6356-r0/INVENTEC-D6356/td3-d6356-48x25G-8x100G.config.bcm +++ b/device/inventec/x86_64-inventec_d6356-r0/INVENTEC-D6356/td3-d6356-48x25G-8x100G.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ ### fix for sonic ptp_ts_pll_fref=50000000 ptp_bs_fref_0=50000000 diff --git a/device/quanta/x86_64-quanta_ix7_rglbmc-r0/Quanta-IX7-32X/td3-ix7-32x100G.config.bcm b/device/quanta/x86_64-quanta_ix7_rglbmc-r0/Quanta-IX7-32X/td3-ix7-32x100G.config.bcm index 14cf4a16bfbe..7361ad2f57f3 100644 --- a/device/quanta/x86_64-quanta_ix7_rglbmc-r0/Quanta-IX7-32X/td3-ix7-32x100G.config.bcm +++ b/device/quanta/x86_64-quanta_ix7_rglbmc-r0/Quanta-IX7-32X/td3-ix7-32x100G.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ bcm_tunnel_term_compatible_mode=1 core_clock_frequency=1525 dpp_clock_ratio=2:3 diff --git a/device/quanta/x86_64-quanta_ix8_rglbmc-r0/Quanta-IX8-56X/td3-ix8-48x25G+8x100G.config.bcm b/device/quanta/x86_64-quanta_ix8_rglbmc-r0/Quanta-IX8-56X/td3-ix8-48x25G+8x100G.config.bcm index 4b146ad897ec..94560fb7e86c 100644 --- a/device/quanta/x86_64-quanta_ix8_rglbmc-r0/Quanta-IX8-56X/td3-ix8-48x25G+8x100G.config.bcm +++ b/device/quanta/x86_64-quanta_ix8_rglbmc-r0/Quanta-IX8-56X/td3-ix8-48x25G+8x100G.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ bcm_tunnel_term_compatible_mode=1 core_clock_frequency=1525 dpp_clock_ratio=2:3 diff --git a/device/quanta/x86_64-quanta_ix8c_bwde-r0/Quanta-IX8C-56X/td3-ix8c-48x25G+8x100G.config.bcm b/device/quanta/x86_64-quanta_ix8c_bwde-r0/Quanta-IX8C-56X/td3-ix8c-48x25G+8x100G.config.bcm index 4b146ad897ec..94560fb7e86c 100644 --- a/device/quanta/x86_64-quanta_ix8c_bwde-r0/Quanta-IX8C-56X/td3-ix8c-48x25G+8x100G.config.bcm +++ b/device/quanta/x86_64-quanta_ix8c_bwde-r0/Quanta-IX8C-56X/td3-ix8c-48x25G+8x100G.config.bcm @@ -1,4 +1,4 @@ -sai_load_hw_config=/etc/bcm/flex/bcm56870_a0/b870.6.6.1/ +sai_load_hw_config=/etc/bcm/flex/bcm56870_a0_issu/b870.6.4.1/ bcm_tunnel_term_compatible_mode=1 core_clock_frequency=1525 dpp_clock_ratio=2:3 From a3bdbb79c1ca73d7cdc3c2a73fc561588f98fd19 Mon Sep 17 00:00:00 2001 From: gechiang <62408185+gechiang@users.noreply.github.com> Date: Sun, 31 Jan 2021 16:59:01 -0800 Subject: [PATCH 0149/1674] [broadcom]: broadcom sai update to 4.3.0.10-3 (#6620) 1. BRCM SAI Debian build need not have any Kernel version dependency - Starting with 4.3 BRCM made changes in SAI so that this dependency has been cleaned up. We can now remove the Kernel Version dependency from Azure Pipeline build script. 2. Bypass PEER_MODE p2mp setting causing SYNCd crash on non-TD3 SKUs - Temporarily patch BRCM SAI code to not cause SYNCd crash when Orchagent program SAI_TUNNEL_ATTR_PEER_MODE: SAI_TUNNEL_PEER_MODE_P2MP on Non-TD3 SKUs. Will remove this when BRCM provide proper fix to address this issue. --- platform/broadcom/sai.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index 7a1e6cf99bd1..cfefdb860c83 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,8 +1,8 @@ -BRCM_SAI = libsaibcm_4.3.0.10-2_amd64.deb -$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.0.10-2_amd64.deb?sv=2015-04-05&sr=b&sig=1L2kJwYBuXDc9ObuVBBUS%2F%2FBVIfAA651ig5k6O1ZztE%3D&se=2022-06-10T21%3A25%3A43Z&sp=r" -BRCM_SAI_DEV = libsaibcm-dev_4.3.0.10-2_amd64.deb +BRCM_SAI = libsaibcm_4.3.0.10-3_amd64.deb +$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.0.10-3_amd64.deb?sv=2015-04-05&sr=b&sig=snXITt%2BRq2cKD7I%2Bqr2WCbj1Ly%2FB2NM8EW3R7wc%2B1ME%3D&se=2034-10-10T06%3A30%3A07Z&sp=r" +BRCM_SAI_DEV = libsaibcm-dev_4.3.0.10-3_amd64.deb $(eval $(call add_derived_package,$(BRCM_SAI),$(BRCM_SAI_DEV))) -$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.0.10-2_amd64.deb?sv=2015-04-05&sr=b&sig=2Vm6o8HtbjI%2BfVoHJUiO5b75USqGra9CLSFXViQm8yM%3D&se=2022-06-10T21%3A26%3A35Z&sp=r" +$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.0.10-3_amd64.deb?sv=2015-04-05&sr=b&sig=%2BfGcnKeMApru1b8aebMHT68zEc%2BCn%2BTcC27izdHNrlA%3D&se=2034-10-10T06%3A30%3A44Z&sp=r" SONIC_ONLINE_DEBS += $(BRCM_SAI) $(BRCM_SAI_DEV)_DEPENDS += $(BRCM_SAI) From eccff4bf17e7b273c002ca3ebe3a9d65ab4769af Mon Sep 17 00:00:00 2001 From: gechiang <62408185+gechiang@users.noreply.github.com> Date: Wed, 3 Feb 2021 15:59:56 -0800 Subject: [PATCH 0150/1674] BRCM SAI 4.3.0.10-4 Fix _brcm_sai_indexed_data_get () with unexpected queue causing _brcm_sai_switch_assert () after warm reboot (#6664) --- platform/broadcom/sai.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index cfefdb860c83..1b27d7bc1f88 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,8 +1,8 @@ -BRCM_SAI = libsaibcm_4.3.0.10-3_amd64.deb -$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.0.10-3_amd64.deb?sv=2015-04-05&sr=b&sig=snXITt%2BRq2cKD7I%2Bqr2WCbj1Ly%2FB2NM8EW3R7wc%2B1ME%3D&se=2034-10-10T06%3A30%3A07Z&sp=r" -BRCM_SAI_DEV = libsaibcm-dev_4.3.0.10-3_amd64.deb +BRCM_SAI = libsaibcm_4.3.0.10-4_amd64.deb +$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.0.10-4_amd64.deb?sv=2015-04-05&sr=b&sig=nfseU56PACVqklQ4MC0HvZ7qt7Ou4loQMBA7jx8CSOY%3D&se=2034-10-13T16%3A31%3A22Z&sp=r" +BRCM_SAI_DEV = libsaibcm-dev_4.3.0.10-4_amd64.deb $(eval $(call add_derived_package,$(BRCM_SAI),$(BRCM_SAI_DEV))) -$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.0.10-3_amd64.deb?sv=2015-04-05&sr=b&sig=%2BfGcnKeMApru1b8aebMHT68zEc%2BCn%2BTcC27izdHNrlA%3D&se=2034-10-10T06%3A30%3A44Z&sp=r" +$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.0.10-4_amd64.deb?sv=2015-04-05&sr=b&sig=4tF26GxI6jmrcvRyCezQ7RL6qMjzip7SFf61eqy%2Bvf4%3D&se=2034-10-13T16%3A31%3A53Z&sp=r" SONIC_ONLINE_DEBS += $(BRCM_SAI) $(BRCM_SAI_DEV)_DEPENDS += $(BRCM_SAI) From 0c17839908fefc3414899d4ddbf2e2136e2bb054 Mon Sep 17 00:00:00 2001 From: judyjoseph <53951155+judyjoseph@users.noreply.github.com> Date: Sat, 23 Jan 2021 20:57:52 -0800 Subject: [PATCH 0151/1674] [teamd]: Increase wait timeout for teamd docker stop to clean Port channels. (#6537) The Portchannels were not getting cleaned up as the cleanup activity was taking more than 10 secs which is default docker timeout after which a SIGKILL will be send. Fixes #6199 To check if it works out for this issue in 201911 ? #6503 This issue is significantly seen in master branch compared to 201911 because the Portchannel cleanup takes more time in master. Test on a DUT with 8 Port Channels. master admin@str-s6000-acs-8:~$ time sudo systemctl stop teamd real 0m15.599s user 0m0.061s sys 0m0.038s Sonic 201911.v58 admin@str-s6000-acs-8:~$ time sudo systemctl stop teamd real 0m5.541s user 0m0.020s sys 0m0.028s --- files/build_templates/docker_image_ctl.j2 | 3 ++ src/sonic-ctrmgrd/ctrmgr/container | 34 +++++++++++++---------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index dd37506f372f..5bc6ca0651d7 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -424,6 +424,9 @@ stop() { if [ "$DEV" ]; then ip netns delete "$NET_NS" fi + {%- elif docker_container_name == "teamd" %} + # Longer timeout of 60 sec to wait for Portchannels to be cleaned. + /usr/local/bin/container stop -t 60 $DOCKERNAME {%- else %} /usr/local/bin/container stop $DOCKERNAME {%- endif %} diff --git a/src/sonic-ctrmgrd/ctrmgr/container b/src/sonic-ctrmgrd/ctrmgr/container index ca0963946f4a..ff3706a6a7a7 100755 --- a/src/sonic-ctrmgrd/ctrmgr/container +++ b/src/sonic-ctrmgrd/ctrmgr/container @@ -100,12 +100,12 @@ def read_state(feature): [(CURRENT_OWNER, "none"), (REMOTE_STATE, "none"), (CONTAINER_ID, "")]) -def docker_action(action, feature): +def docker_action(action, feature, **kwargs): """ Execute docker action """ try: client = docker.from_env() container = client.containers.get(feature) - getattr(container, action)() + getattr(container, action)(**kwargs) syslog.syslog(syslog.LOG_INFO, "docker cmd: {} for {}".format(action, feature)) return 0 @@ -161,7 +161,7 @@ def container_id(feature): return data.get(CONTAINER_ID, feature) -def container_start(feature): +def container_start(feature, **kwargs): """ Starts a container for given feature. @@ -219,7 +219,7 @@ def container_start(feature): update_data(feature, data) if (start_val & START_LOCAL): - ret = docker_action("start", feature) + ret = docker_action("start", feature, **kwargs) if (start_val & START_KUBE): set_label(feature, True) @@ -227,7 +227,7 @@ def container_start(feature): return ret -def container_stop(feature): +def container_stop(feature, **kwargs): """ Stops the running container for this feature. @@ -257,7 +257,7 @@ def container_stop(feature): set_label(feature, False) if docker_id: - docker_action("stop", docker_id) + docker_action("stop", docker_id, **kwargs) else: syslog.syslog( syslog.LOG_ERR if current_owner != "none" else syslog.LOG_INFO, @@ -289,7 +289,7 @@ def container_stop(feature): debug_msg("END") -def container_kill(feature): +def container_kill(feature, **kwargs): """ Kills the running container for this feature. @@ -314,7 +314,7 @@ def container_kill(feature): set_label(feature, False) if docker_id: - docker_action("kill", docker_id) + docker_action("kill", docker_id, **kwargs) else: syslog.syslog( @@ -325,7 +325,7 @@ def container_kill(feature): debug_msg("END") -def container_wait(feature): +def container_wait(feature, **kwargs): """ Waits on the running container for this feature. @@ -378,30 +378,34 @@ def container_wait(feature): format(feature)) else: debug_msg("END -- transitioning to docker wait") - docker_action("wait", docker_id) + docker_action("wait", docker_id, **kwargs) def main(): parser=argparse.ArgumentParser(description="container commands for start/stop/wait/kill/id") parser.add_argument("action", choices=["start", "stop", "wait", "kill", "id"]) + parser.add_argument('-t', '--timeout', type=int, help='container action timeout value', default=None) parser.add_argument("name") args = parser.parse_args() + kwargs = {} if args.action == "start": - container_start(args.name) + container_start(args.name, **kwargs) elif args.action == "stop": - container_stop(args.name) + if args.timeout is not None: + kwargs['timeout'] = args.timeout + container_stop(args.name, **kwargs) elif args.action == "kill": - container_kill(args.name) + container_kill(args.name, **kwargs) elif args.action == "wait": - container_wait(args.name) + container_wait(args.name, **kwargs) elif args.action == "id": - id = container_id(args.name) + id = container_id(args.name, **kwargs) print(id) From 9b73492aedad02a985240af8bff0dbb5d6309bb9 Mon Sep 17 00:00:00 2001 From: Danny Allen Date: Sat, 6 Feb 2021 11:23:17 -0800 Subject: [PATCH 0152/1674] [submodule][202012]: Update sonic-swss and sonic-utilities submodules (#6701) sonic-swss: - [Mux] Route handling based on mux status, kernel tunnel support (#1615) - Reduce noise during frequent route update (#1624) - Changed Error log to Notice log during FDB flush notification after VLAN delete (#1618) - [PortsOrch] Add reference counting to ports for ACL bindings (#1614) - [crm]: Ignore unsupported/non-implemented switch attributes (#1613) - [Mux] Fix repeating logs in case of tunnel creation fail (#1610) sonic-utilities: - [config reload]: Restart mux container (#1401) - [storyteller] Enhance the storyteller utility (#1400) - [show] Fix int status when portchannel is in the system (#1376) - [config][show] cli support for retrieving ber, eye-info and configuring prbs, loopback on Y-cable (#1386) - Skip route check for tun0 interfaces (#1399) - do not parse stderr to get correct routing stack (#1398) - [storyteller] allow storyteller to work on downloaded logs (#1388) - [show] Run fwutil with sudo (#1364) Signed-off-by: Danny Allen --- src/sonic-swss | 2 +- src/sonic-utilities | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sonic-swss b/src/sonic-swss index 01c3abd3cf30..fc06176a164b 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit 01c3abd3cf30c76824b736fe65093fa065385c67 +Subproject commit fc06176a164b2325d34a3f137fa1015d757dd64c diff --git a/src/sonic-utilities b/src/sonic-utilities index c2fb28254c1e..ea6a38cda963 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit c2fb28254c1e35a3c7a85a3baaf1c05a4afcd9fe +Subproject commit ea6a38cda963d0ea0b6eaf52026c63e749f3ce35 From f5c2e1cb541ee9ff63df8d338099bc2826040811 Mon Sep 17 00:00:00 2001 From: Vaibhav Hemant Dixit Date: Fri, 5 Feb 2021 19:34:17 -0800 Subject: [PATCH 0153/1674] Add the 10G ports with updated speed (#6699) Port_config update for hwsku 7050CX3-32S-C3 - add two 10G ports. This change is added to fix issue of "PortsOrch initialization failure" seen by previous removal of these 10G ports. Tested on the device with new minigraph, and the PortsOrch initialization failure is not seen. --- .../Arista-7050CX3-32S-C32/port_config.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/port_config.ini b/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/port_config.ini index e24a70e97967..4b96b8cf87c9 100644 --- a/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/port_config.ini +++ b/device/arista/x86_64-arista_7050cx3_32s/Arista-7050CX3-32S-C32/port_config.ini @@ -31,3 +31,5 @@ Ethernet112 117,118,119,120 Ethernet29/1 29 100000 Ethernet116 113,114,115,116 Ethernet30/1 30 100000 Ethernet120 121,122,123,124 Ethernet31/1 31 100000 Ethernet124 125,126,127,128 Ethernet32/1 32 100000 +Ethernet128 129 Ethernet33 33 10000 +Ethernet132 128 Ethernet34 34 10000 From bb8a1452342b9f787f0b524e0fa70f66f53dbc9e Mon Sep 17 00:00:00 2001 From: abdosi <58047199+abdosi@users.noreply.github.com> Date: Sat, 6 Feb 2021 10:28:05 -0800 Subject: [PATCH 0154/1674] Remove makefile and dependency for python2 of dbsyncd. (#6702) * Remove makefile and As part of #6046 we have moved to python3 of dbsyncd. Cleanup the python2 makefile and dependency. Signed-off-by: Abhishek Dosi * Revert "Remove makefile and dependency for python2 of dbsyncd." This reverts commit ceaa4f8dd9c58975953145dcc0c9e045910e73ad. * Fix Signed-off-by: Abhishek Dosi --- rules/dbsyncd-py2.dep | 12 ------------ rules/dbsyncd-py2.mk | 7 ------- 2 files changed, 19 deletions(-) delete mode 100644 rules/dbsyncd-py2.dep delete mode 100644 rules/dbsyncd-py2.mk diff --git a/rules/dbsyncd-py2.dep b/rules/dbsyncd-py2.dep deleted file mode 100644 index 6ca1ab8dd786..000000000000 --- a/rules/dbsyncd-py2.dep +++ /dev/null @@ -1,12 +0,0 @@ - -SPATH := $($(DBSYNCD_PY2)_SRC_PATH) -DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/dbsyncd-py2.mk rules/dbsyncd-py2.dep -DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) -SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files)) - -$(DBSYNCD_PY2)_CACHE_MODE := GIT_CONTENT_SHA -$(DBSYNCD_PY2)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) -$(DBSYNCD_PY2)_DEP_FILES := $(DEP_FILES) -$(DBSYNCD_PY2)_SMDEP_FILES := $(SMDEP_FILES) -$(DBSYNCD_PY2)_SMDEP_PATHS := $(SPATH) - diff --git a/rules/dbsyncd-py2.mk b/rules/dbsyncd-py2.mk deleted file mode 100644 index 220dc5fe7a1d..000000000000 --- a/rules/dbsyncd-py2.mk +++ /dev/null @@ -1,7 +0,0 @@ -# sonic-dbsyncd python2 wheel - -DBSYNCD_PY2 = sonic_d-2.0.0-py2-none-any.whl -$(DBSYNCD_PY2)_SRC_PATH = $(SRC_PATH)/sonic-dbsyncd -$(DBSYNCD_PY2)_PYTHON_VERSION = 2 -$(DBSYNCD_PY2)_DEPENDS += $(SWSSSDK_PY2) -SONIC_PYTHON_WHEELS += $(DBSYNCD_PY2) From 742bbed255f2a3694db0706c3d99840536079219 Mon Sep 17 00:00:00 2001 From: Volodymyr Boiko <66446128+vboykox@users.noreply.github.com> Date: Sat, 6 Feb 2021 21:33:06 +0200 Subject: [PATCH 0155/1674] [barefoot][platform] Fix sonic-platform host installation (#6696) prerm is needed for platform modules package to be properly removed. Added prerm to remove installed in postinst wheel packages. Signed-off-by: Volodymyr Boyko --- .../sonic-platform-modules-bfn-montara/debian/prerm | 6 ++++++ .../sonic-platform-modules-bfn-newport/debian/prerm | 6 ++++++ platform/barefoot/sonic-platform-modules-bfn/debian/prerm | 6 ++++++ 3 files changed, 18 insertions(+) create mode 100755 platform/barefoot/sonic-platform-modules-bfn-montara/debian/prerm create mode 100644 platform/barefoot/sonic-platform-modules-bfn-newport/debian/prerm create mode 100755 platform/barefoot/sonic-platform-modules-bfn/debian/prerm diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/debian/prerm b/platform/barefoot/sonic-platform-modules-bfn-montara/debian/prerm new file mode 100755 index 000000000000..ee19dbb1db98 --- /dev/null +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/debian/prerm @@ -0,0 +1,6 @@ +#!/bin/sh + +python2 -m pip uninstall -y sonic-platform +python3 -m pip uninstall -y sonic-platform + +#DEBHELPER# diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/debian/prerm b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/prerm new file mode 100644 index 000000000000..ee19dbb1db98 --- /dev/null +++ b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/prerm @@ -0,0 +1,6 @@ +#!/bin/sh + +python2 -m pip uninstall -y sonic-platform +python3 -m pip uninstall -y sonic-platform + +#DEBHELPER# diff --git a/platform/barefoot/sonic-platform-modules-bfn/debian/prerm b/platform/barefoot/sonic-platform-modules-bfn/debian/prerm new file mode 100755 index 000000000000..ee19dbb1db98 --- /dev/null +++ b/platform/barefoot/sonic-platform-modules-bfn/debian/prerm @@ -0,0 +1,6 @@ +#!/bin/sh + +python2 -m pip uninstall -y sonic-platform +python3 -m pip uninstall -y sonic-platform + +#DEBHELPER# From 819d7b50a98a74c8892c5a2282e349a2c07949c5 Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Fri, 5 Feb 2021 20:52:10 -0800 Subject: [PATCH 0156/1674] [tacacs]: use stg to apply patch Signed-off-by: Guohan Lu --- src/tacacs/nss/Makefile | 17 +++-------------- .../0001-Modify-user-map-profile.patch | 0 ...Enable-modifying-local-user-permission.patch | 0 .../0003-management-vrf-support.patch | 0 ...-tacacs-servers-for-local-non-tacacs-u.patch | 0 ...parsing-of-IP-addr-and-port-number-str.patch | 0 ...piling-warning-about-token-dereference.patch | 0 ...-Add-support-for-TACACS-source-address.patch | 0 src/tacacs/nss/patch/series | 7 +++++++ 9 files changed, 10 insertions(+), 14 deletions(-) rename src/tacacs/nss/{ => patch}/0001-Modify-user-map-profile.patch (100%) rename src/tacacs/nss/{ => patch}/0002-Enable-modifying-local-user-permission.patch (100%) rename src/tacacs/nss/{ => patch}/0003-management-vrf-support.patch (100%) rename src/tacacs/nss/{ => patch}/0004-Skip-accessing-tacacs-servers-for-local-non-tacacs-u.patch (100%) rename src/tacacs/nss/{ => patch}/0005-libnss-Modify-parsing-of-IP-addr-and-port-number-str.patch (100%) rename src/tacacs/nss/{ => patch}/0006-fix-compiling-warning-about-token-dereference.patch (100%) rename src/tacacs/nss/{ => patch}/0007-Add-support-for-TACACS-source-address.patch (100%) create mode 100644 src/tacacs/nss/patch/series diff --git a/src/tacacs/nss/Makefile b/src/tacacs/nss/Makefile index 5fafd93b87fd..0c8f25f44eac 100644 --- a/src/tacacs/nss/Makefile +++ b/src/tacacs/nss/Makefile @@ -4,27 +4,16 @@ SHELL = /bin/bash MAIN_TARGET = libnss-tacplus_$(NSS_TACPLUS_VERSION)_$(CONFIGURED_ARCH).deb -GIT_APPLY = am -ifneq (,$(filter $(CONFIGURED_ARCH), armhf arm64)) -# Workaround git am issue "Out of memory getdelim failed" -GIT_APPLY = apply -endif - $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Obtain libnss-tacplus rm -rf ./libnss-tacplus git clone https://github.com/daveolson53/libnss-tacplus.git pushd ./libnss-tacplus - git checkout -f 19008ab + git checkout -b test -f 19008ab # Apply patch - git $(GIT_APPLY) ../0001-Modify-user-map-profile.patch - git $(GIT_APPLY) ../0002-Enable-modifying-local-user-permission.patch - git $(GIT_APPLY) ../0003-management-vrf-support.patch - git $(GIT_APPLY) ../0004-Skip-accessing-tacacs-servers-for-local-non-tacacs-u.patch - git $(GIT_APPLY) ../0005-libnss-Modify-parsing-of-IP-addr-and-port-number-str.patch - git $(GIT_APPLY) ../0006-fix-compiling-warning-about-token-dereference.patch - git $(GIT_APPLY) ../0007-Add-support-for-TACACS-source-address.patch + stg init + stg import -s ../patch/series dpkg-buildpackage -rfakeroot -b -us -uc -j$(SONIC_CONFIG_MAKE_JOBS) --admindir $(SONIC_DPKG_ADMINDIR) popd diff --git a/src/tacacs/nss/0001-Modify-user-map-profile.patch b/src/tacacs/nss/patch/0001-Modify-user-map-profile.patch similarity index 100% rename from src/tacacs/nss/0001-Modify-user-map-profile.patch rename to src/tacacs/nss/patch/0001-Modify-user-map-profile.patch diff --git a/src/tacacs/nss/0002-Enable-modifying-local-user-permission.patch b/src/tacacs/nss/patch/0002-Enable-modifying-local-user-permission.patch similarity index 100% rename from src/tacacs/nss/0002-Enable-modifying-local-user-permission.patch rename to src/tacacs/nss/patch/0002-Enable-modifying-local-user-permission.patch diff --git a/src/tacacs/nss/0003-management-vrf-support.patch b/src/tacacs/nss/patch/0003-management-vrf-support.patch similarity index 100% rename from src/tacacs/nss/0003-management-vrf-support.patch rename to src/tacacs/nss/patch/0003-management-vrf-support.patch diff --git a/src/tacacs/nss/0004-Skip-accessing-tacacs-servers-for-local-non-tacacs-u.patch b/src/tacacs/nss/patch/0004-Skip-accessing-tacacs-servers-for-local-non-tacacs-u.patch similarity index 100% rename from src/tacacs/nss/0004-Skip-accessing-tacacs-servers-for-local-non-tacacs-u.patch rename to src/tacacs/nss/patch/0004-Skip-accessing-tacacs-servers-for-local-non-tacacs-u.patch diff --git a/src/tacacs/nss/0005-libnss-Modify-parsing-of-IP-addr-and-port-number-str.patch b/src/tacacs/nss/patch/0005-libnss-Modify-parsing-of-IP-addr-and-port-number-str.patch similarity index 100% rename from src/tacacs/nss/0005-libnss-Modify-parsing-of-IP-addr-and-port-number-str.patch rename to src/tacacs/nss/patch/0005-libnss-Modify-parsing-of-IP-addr-and-port-number-str.patch diff --git a/src/tacacs/nss/0006-fix-compiling-warning-about-token-dereference.patch b/src/tacacs/nss/patch/0006-fix-compiling-warning-about-token-dereference.patch similarity index 100% rename from src/tacacs/nss/0006-fix-compiling-warning-about-token-dereference.patch rename to src/tacacs/nss/patch/0006-fix-compiling-warning-about-token-dereference.patch diff --git a/src/tacacs/nss/0007-Add-support-for-TACACS-source-address.patch b/src/tacacs/nss/patch/0007-Add-support-for-TACACS-source-address.patch similarity index 100% rename from src/tacacs/nss/0007-Add-support-for-TACACS-source-address.patch rename to src/tacacs/nss/patch/0007-Add-support-for-TACACS-source-address.patch diff --git a/src/tacacs/nss/patch/series b/src/tacacs/nss/patch/series new file mode 100644 index 000000000000..51a87171fbcc --- /dev/null +++ b/src/tacacs/nss/patch/series @@ -0,0 +1,7 @@ +0001-Modify-user-map-profile.patch +0002-Enable-modifying-local-user-permission.patch +0003-management-vrf-support.patch +0004-Skip-accessing-tacacs-servers-for-local-non-tacacs-u.patch +0005-libnss-Modify-parsing-of-IP-addr-and-port-number-str.patch +0006-fix-compiling-warning-about-token-dereference.patch +0007-Add-support-for-TACACS-source-address.patch From 99b7910ccfff7c9ce4aebc5d7b0814af3e363eb9 Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Sat, 6 Feb 2021 01:16:15 -0800 Subject: [PATCH 0157/1674] [tacacs]: do not modify local user if there is no priviledge check the uid before modify local user account. when run sudo, the process the invoke nss_tacplus library does not have priviledge to modify the user profile, and will generate below error messages: user_rw@sonic:~$ sudo bash usermod: Permission denied. usermod: cannot lock /etc/passwd; try again later. usermod: Permission denied. usermod: cannot lock /etc/passwd; try again later. Signed-off-by: Guohan Lu --- ...-modify-local-user-if-there-is-no-pr.patch | 32 +++++++++++++++++++ src/tacacs/nss/patch/series | 1 + 2 files changed, 33 insertions(+) create mode 100644 src/tacacs/nss/patch/0008-do-not-create-or-modify-local-user-if-there-is-no-pr.patch diff --git a/src/tacacs/nss/patch/0008-do-not-create-or-modify-local-user-if-there-is-no-pr.patch b/src/tacacs/nss/patch/0008-do-not-create-or-modify-local-user-if-there-is-no-pr.patch new file mode 100644 index 000000000000..1ab4a423663b --- /dev/null +++ b/src/tacacs/nss/patch/0008-do-not-create-or-modify-local-user-if-there-is-no-pr.patch @@ -0,0 +1,32 @@ +From c59b775a7c9226954c5eea4ba05469879b41a60d Mon Sep 17 00:00:00 2001 +From: Guohan Lu +Date: Sat, 6 Feb 2021 06:49:17 +0000 +Subject: [PATCH] do not create or modify local user if there is no privilege + +--- + nss_tacplus.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/nss_tacplus.c b/nss_tacplus.c +index fc9316f..cc6f0aa 100644 +--- a/nss_tacplus.c ++++ b/nss_tacplus.c +@@ -629,8 +629,13 @@ static int lookup_user_pw(struct pwbuf *pb, int level) + if(0 != ret) + return ret; + +- if(0 != create_or_modify_local_user(username, level, found)) +- return -1; ++ if(0 == getuid()) { ++ if(0 != create_or_modify_local_user(username, level, found)) ++ return -1; ++ } else { ++ if(debug) ++ syslog(LOG_DEBUG, "%d does not privilege to create or modify user %s", getuid(), username); ++ } + + ret = lookup_pw_local(username, pb, &found); + if(0 == ret && !found) { +-- +2.25.1 + diff --git a/src/tacacs/nss/patch/series b/src/tacacs/nss/patch/series index 51a87171fbcc..b60214ead9bc 100644 --- a/src/tacacs/nss/patch/series +++ b/src/tacacs/nss/patch/series @@ -5,3 +5,4 @@ 0005-libnss-Modify-parsing-of-IP-addr-and-port-number-str.patch 0006-fix-compiling-warning-about-token-dereference.patch 0007-Add-support-for-TACACS-source-address.patch +0008-do-not-create-or-modify-local-user-if-there-is-no-pr.patch From 5fe835297853770a20ab290d2094879110cefa83 Mon Sep 17 00:00:00 2001 From: Stepan Blyshchak <38952541+stepanblyschak@users.noreply.github.com> Date: Thu, 11 Feb 2021 09:13:06 +0200 Subject: [PATCH 0158/1674] [Mellanox][SAI] update submodule pointer (#6728) - Apply device MAC on port host interface when port is removed from LAG. - [Shared Headroom]: fixed watermark handling for SHP flow - Decrease verbosity of policer unbind message when no policer is attached Signed-off-by: Stepan Blyschak --- platform/mellanox/mlnx-sai/SAI-Implementation | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/mellanox/mlnx-sai/SAI-Implementation b/platform/mellanox/mlnx-sai/SAI-Implementation index abdc7c069ea8..80937117fcd5 160000 --- a/platform/mellanox/mlnx-sai/SAI-Implementation +++ b/platform/mellanox/mlnx-sai/SAI-Implementation @@ -1 +1 @@ -Subproject commit abdc7c069ea8714af53cd4337f05bd493f133668 +Subproject commit 80937117fcd54e8df0581368f652f3664af6aecb From 78ad83fe2a98e0cfdc4caff4267e10243135471e Mon Sep 17 00:00:00 2001 From: Aravind Mani <53524901+aravindmani-1@users.noreply.github.com> Date: Sun, 7 Feb 2021 03:23:35 +0530 Subject: [PATCH 0159/1674] [DellEMC Z9332f] Added support for platform system health daemon (#6642) --- .../system_health_monitoring_config.json | 11 ++++ .../common/ipmihelper.py | 10 ++-- .../common/sonic_platform/hwaccess.py | 29 +++++++++++ .../z9332f/sonic_platform/chassis.py | 51 ++++++++++++++++++- .../z9332f/sonic_platform/psu.py | 39 +++++++++++++- 5 files changed, 132 insertions(+), 8 deletions(-) create mode 100644 device/dell/x86_64-dellemc_z9332f_d1508-r0/system_health_monitoring_config.json diff --git a/device/dell/x86_64-dellemc_z9332f_d1508-r0/system_health_monitoring_config.json b/device/dell/x86_64-dellemc_z9332f_d1508-r0/system_health_monitoring_config.json new file mode 100644 index 000000000000..d52b24cf905d --- /dev/null +++ b/device/dell/x86_64-dellemc_z9332f_d1508-r0/system_health_monitoring_config.json @@ -0,0 +1,11 @@ +{ + "services_to_ignore": [], + "devices_to_ignore": ["asic","fan.speed"], + "user_defined_checkers": [], + "polling_interval": 60, + "led_color": { + "fault": "yellow", + "normal": "green", + "booting": "flash_green" + } +} diff --git a/platform/broadcom/sonic-platform-modules-dell/common/ipmihelper.py b/platform/broadcom/sonic-platform-modules-dell/common/ipmihelper.py index ceeaebfbf047..d95329c40de2 100644 --- a/platform/broadcom/sonic-platform-modules-dell/common/ipmihelper.py +++ b/platform/broadcom/sonic-platform-modules-dell/common/ipmihelper.py @@ -33,7 +33,7 @@ def get_ipmitool_raw_output(args): command = "ipmitool raw {}".format(args) try: proc = subprocess.Popen(command.split(), stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) + universal_newlines=True, stderr=subprocess.STDOUT) stdout = proc.communicate()[0] proc.wait() if not proc.returncode: @@ -175,11 +175,11 @@ def _get_ipmitool_fru_print(self): command = "ipmitool fru print {}".format(self.id) try: proc = subprocess.Popen(command.split(), stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) + universal_newlines=True, stderr=subprocess.STDOUT) stdout = proc.communicate()[0] proc.wait() if not proc.returncode: - result = stdout.decode('utf-8').rstrip('\n') + result = stdout.rstrip('\n') except EnvironmentError: pass @@ -248,11 +248,11 @@ def get_fru_data(self, offset, count=1): offset_MSB, count) try: proc = subprocess.Popen(command.split(), stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) + universal_newlines=True, stderr=subprocess.STDOUT) stdout = proc.communicate()[0] proc.wait() if not proc.returncode: - result = stdout.decode('utf-8').rstrip('\n') + result = stdout.rstrip('\n') except EnvironmentError: is_valid = False diff --git a/platform/broadcom/sonic-platform-modules-dell/common/sonic_platform/hwaccess.py b/platform/broadcom/sonic-platform-modules-dell/common/sonic_platform/hwaccess.py index b0020144a4fb..567669d36fc0 100644 --- a/platform/broadcom/sonic-platform-modules-dell/common/sonic_platform/hwaccess.py +++ b/platform/broadcom/sonic-platform-modules-dell/common/sonic_platform/hwaccess.py @@ -1,5 +1,6 @@ # Helper functions to access hardware +import os import struct import mmap import subprocess @@ -22,3 +23,31 @@ def pci_get_value(resource, offset): def i2c_get(bus, i2caddr, ofs): return int(subprocess.check_output(['/usr/sbin/i2cget', '-y', str(bus), str(i2caddr), str(ofs)]), 16) + +def io_reg_read(io_resource, offset): + fd = os.open(io_resource, os.O_RDONLY) + if fd < 0: + print('file open failed %s' % io_resource) + return -1 + if os.lseek(fd, offset, os.SEEK_SET) != offset: + print('lseek failed on %s' % io_resource) + return -1 + buf = os.read(fd, 1) + reg_val1 = ord(buf) + os.close(fd) + return reg_val1 + +def io_reg_write(io_resource, offset, val): + fd = os.open(io_resource, os.O_RDWR) + if fd < 0: + print('file open failed %s' % io_resource) + return False + if os.lseek(fd, offset, os.SEEK_SET) != offset: + print('lseek failed on %s' % io_resource) + return False + ret = os.write(fd, struct.pack('B', val)) + if ret != 1: + print('write failed %d' % ret) + return False + os.close(fd) + return True diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/chassis.py index 3651b0d4bf08..cead0eb326ef 100755 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/chassis.py @@ -19,6 +19,7 @@ from sonic_platform.thermal import Thermal from sonic_platform.fan_drawer import FanDrawer from sonic_platform.watchdog import Watchdog + import sonic_platform.hwaccess as hwaccess except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -53,9 +54,25 @@ class Chassis(ChassisBase): REBOOT_CAUSE_PATH = "/host/reboot-cause/platform/reboot_reason" oir_fd = -1 epoll = -1 + io_res = "/dev/port" + sysled_offset = 0xA162 + SYSLED_COLOR_TO_REG = { + "green": 0xd0, + "yellow": 0xe0, + "flash_green": 0xd2, + "flash_yellow": 0xe2 + } + + REG_TO_SYSLED_COLOR = { + 0xd0 : "green", + 0xe0 : "yellow", + 0xd2 : "flash_green", + 0xd1 : "flash_green", + 0xe2 : "flash_yellow", + 0xe1 : "flash_yellow" + } _global_port_pres_dict = {} - _port_to_i2c_mapping = { 1: 10, 2: 11, @@ -317,3 +334,35 @@ def get_reboot_cause(self): def get_qualified_media_list(self): return media_part_num_list + + def initizalize_system_led(self): + self.sys_ledcolor = "green" + + def get_status_led(self): + """ + Gets the current system LED color + + Returns: + A string that represents the supported color + """ + val = hwaccess.io_reg_read(self.io_res, self.sysled_offset) + if val != -1: + return self.REG_TO_SYSLED_COLOR.get(val) + return self.sys_ledcolor + + def set_status_led(self, color): + """ + Set system LED status based on the color type passed in the argument. + Argument: Color to be set + Returns: + bool: True is specified color is set, Otherwise return False + """ + + if color not in list(self.SYSLED_COLOR_TO_REG.keys()): + return False + + if(not hwaccess.io_reg_write(self.io_res, self.sysled_offset, self.SYSLED_COLOR_TO_REG[color])): + return False + self.sys_ledcolor = color + return True + diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/psu.py index 3be32043ade8..0d06c31fcf8f 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/psu.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/psu.py @@ -21,9 +21,11 @@ class Psu(PsuBase): # { PSU-ID: { Sensor-Name: Sensor-ID } } SENSOR_MAPPING = { 1: { "State": 0x2f, "Current": 0x37, - "Power": 0x38, "Voltage": 0x36 }, + "Power": 0x38, "Voltage": 0x36, + "Temperature": 0x35 }, 2: { "State": 0x39, "Current": 0x41, - "Power": 0x42, "Voltage": 0x40 } } + "Power": 0x42, "Voltage": 0x40, + "Temperature": 0x3F } } # ( PSU-ID: FRU-ID } FRU_MAPPING = { 1: 3, 2: 4 } @@ -36,6 +38,7 @@ def __init__(self, psu_index): self.voltage_sensor = IpmiSensor(self.SENSOR_MAPPING[self.index]["Voltage"]) self.current_sensor = IpmiSensor(self.SENSOR_MAPPING[self.index]["Current"]) self.power_sensor = IpmiSensor(self.SENSOR_MAPPING[self.index]["Power"]) + self.temp_sensor = IpmiSensor(self.SENSOR_MAPPING[self.index ]["Temperature"]) self.fru = IpmiFru(self.FRU_MAPPING[self.index]) self.psu_type_raw_cmd = "0x3A 0x0B {}".format(psu_index+1) @@ -112,6 +115,38 @@ def get_voltage(self): return "{:.1f}".format(voltage) + def get_voltage_low_threshold(self): + """ + Returns PSU low threshold in Volts + """ + return 11.4 + + def get_voltage_high_threshold(self): + """ + Returns PSU high threshold in Volts + """ + return 12.6 + + 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 + """ + is_valid, temperature = self.temp_sensor.get_reading() + if not is_valid: + temperature = 0 + + return float(temperature) + + def get_temperature_high_threshold(self): + """ + Returns the high temperature threshold for PSU in Celsius + """ + return 45.0 + def get_current(self): """ Retrieves present electric current supplied by PSU From 191e90e400674685f50dc4261194d805ae768bf7 Mon Sep 17 00:00:00 2001 From: Roy Lee Date: Sun, 7 Feb 2021 05:56:16 +0800 Subject: [PATCH 0160/1674] [device/accton/as4630-54pe] Fix accton driver not been installed (#6321) Accton util applies lsmod to check if drivers are installed. But lsmod may return error on startup and skip module installation. Signed-off-by: roy_lee --- .../as4630-54pe/utils/accton_as4630_54pe_util.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54pe/utils/accton_as4630_54pe_util.py b/platform/broadcom/sonic-platform-modules-accton/as4630-54pe/utils/accton_as4630_54pe_util.py index ed0df177ee13..4039119288a0 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as4630-54pe/utils/accton_as4630_54pe_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54pe/utils/accton_as4630_54pe_util.py @@ -214,10 +214,12 @@ def log_os_system(cmd, show): return status, output def driver_inserted(): - ret, lsmod = log_os_system("lsmod| grep accton", 0) + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) logging.info('mods:'+lsmod) - if len(lsmod) ==0: + if ret : return False + else : + return True #'modprobe cpr_4011_4mxx', From c70591650043b77efa6f58b602f4b5ad5d37635d Mon Sep 17 00:00:00 2001 From: Dmytro Shevchuk <68949102+dmytroxshevchuk@users.noreply.github.com> Date: Sun, 7 Feb 2021 03:38:29 +0200 Subject: [PATCH 0161/1674] [barefoot] Add hwsku.json, platform.json for montara (#6554) * [device] add platform.json hwsku.json for Montara * [device] add autonge, fec fields to hwsku --- .../montara/hwsku.json | 164 +++++++++++++++ .../platform.json | 196 ++++++++++++++++++ 2 files changed, 360 insertions(+) create mode 100644 device/barefoot/x86_64-accton_wedge100bf_32x-r0/montara/hwsku.json create mode 100644 device/barefoot/x86_64-accton_wedge100bf_32x-r0/platform.json diff --git a/device/barefoot/x86_64-accton_wedge100bf_32x-r0/montara/hwsku.json b/device/barefoot/x86_64-accton_wedge100bf_32x-r0/montara/hwsku.json new file mode 100644 index 000000000000..a253fa3bd480 --- /dev/null +++ b/device/barefoot/x86_64-accton_wedge100bf_32x-r0/montara/hwsku.json @@ -0,0 +1,164 @@ +{ + "interfaces": { + "Ethernet0": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet4": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet8": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet12": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet16": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet20": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet24": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet28": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet32": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet36": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet40": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet44": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet48": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet52": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet56": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet60": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet64": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet68": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet72": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet76": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet80": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet84": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet88": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet92": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet96": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet100": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet104": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet108": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet112": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet116": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet120": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + }, + "Ethernet124": { + "default_brkout_mode": "1x100G[40G]", + "autoneg": "0", + "fec": "rs" + } + } +} diff --git a/device/barefoot/x86_64-accton_wedge100bf_32x-r0/platform.json b/device/barefoot/x86_64-accton_wedge100bf_32x-r0/platform.json new file mode 100644 index 000000000000..0b68edf1610c --- /dev/null +++ b/device/barefoot/x86_64-accton_wedge100bf_32x-r0/platform.json @@ -0,0 +1,196 @@ +{ + "interfaces": { + "Ethernet0": { + "index": "1,1,1,1", + "lanes": "0,1,2,3", + "alias_at_lanes": "Ethernet0,Ethernet1,Ethernet2,Ethernet3", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet4": { + "index": "2,2,2,2", + "lanes": "4,5,6,7", + "alias_at_lanes": "Ethernet4,Ethernet5,Ethernet6,Ethernet7", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet8": { + "index": "3,3,3,3", + "lanes": "8,9,10,11", + "alias_at_lanes": "Ethernet8,Ethernet9,Ethernet10,Ethernet11", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet12": { + "index": "4,4,4,4", + "lanes": "12,13,14,15", + "alias_at_lanes": "Ethernet12,Ethernet13,Ethernet14,Ethernet15", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet16": { + "index": "5,5,5,5", + "lanes": "16,17,18,19", + "alias_at_lanes": "Ethernet16,Ethernet17,Ethernet18,Ethernet19", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet20": { + "index": "6,6,6,6", + "lanes": "20,21,22,23", + "alias_at_lanes": "Ethernet20,Ethernet21,Ethernet22,Ethernet23", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet24": { + "index": "7,7,7,7", + "lanes": "24,25,26,27", + "alias_at_lanes": "Ethernet24,Ethernet25,Ethernet26,Ethernet27", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet28": { + "index": "8,8,8,8", + "lanes": "28,29,30,31", + "alias_at_lanes": "Ethernet28,Ethernet29,Ethernet30,Ethernet31", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet32": { + "index": "9,9,9,9", + "lanes": "32,33,34,35", + "alias_at_lanes": "Ethernet32,Ethernet33,Ethernet34,Ethernet35", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet36": { + "index": "10,10,10,10", + "lanes": "36,37,38,39", + "alias_at_lanes": "Ethernet36,Ethernet37,Ethernet38,Ethernet39", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet40": { + "index": "11,11,11,11", + "lanes": "40,41,42,43", + "alias_at_lanes": "Ethernet40,Ethernet41,Ethernet42,Ethernet43", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet44": { + "index": "12,12,12,12", + "lanes": "44,45,46,47", + "alias_at_lanes": "Ethernet44,Ethernet45,Ethernet46,Ethernet47", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet48": { + "index": "13,13,13,13", + "lanes": "48,49,50,51", + "alias_at_lanes": "Ethernet48,Ethernet49,Ethernet50,Ethernet51", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet52": { + "index": "14,14,14,14", + "lanes": "52,53,54,55", + "alias_at_lanes": "Ethernet52,Ethernet53,Ethernet54,Ethernet55", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet56": { + "index": "15,15,15,15", + "lanes": "56,57,58,59", + "alias_at_lanes": "Ethernet56,Ethernet57,Ethernet58,Ethernet59", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet60": { + "index": "16,16,16,16", + "lanes": "60,61,62,63", + "alias_at_lanes": "Ethernet60,Ethernet61,Ethernet62,Ethernet63", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet64": { + "index": "17,17,17,17", + "lanes": "64,65,66,67", + "alias_at_lanes": "Ethernet64,Ethernet65,Ethernet66,Ethernet67", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet68": { + "index": "18,18,18,18", + "lanes": "68,69,70,71", + "alias_at_lanes": "Ethernet68,Ethernet69,Ethernet70,Ethernet71", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet72": { + "index": "19,19,19,19", + "lanes": "72,73,74,75", + "alias_at_lanes": "Ethernet72,Ethernet73,Ethernet74,Ethernet75", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet76": { + "index": "20,20,20,20", + "lanes": "76,77,78,79", + "alias_at_lanes": "Ethernet76,Ethernet77,Ethernet78,Ethernet79", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet80": { + "index": "21,21,21,21", + "lanes": "80,81,82,83", + "alias_at_lanes": "Ethernet80,Ethernet81,Ethernet82,Ethernet83", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet84": { + "index": "22,22,22,22", + "lanes": "84,85,86,87", + "alias_at_lanes": "Ethernet84,Ethernet85,Ethernet86,Ethernet87", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet88": { + "index": "23,23,23,23", + "lanes": "88,89,90,91", + "alias_at_lanes": "Ethernet88,Ethernet89,Ethernet90,Ethernet91", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet92": { + "index": "24,24,24,24", + "lanes": "92,93,94,95", + "alias_at_lanes": "Ethernet92,Ethernet93,Ethernet94,Ethernet95", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet96": { + "index": "25,25,25,25", + "lanes": "96,97,98,99", + "alias_at_lanes": "Ethernet96,Ethernet97,Ethernet98,Ethernet99", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet100": { + "index": "26,26,26,26", + "lanes": "100,101,102,103", + "alias_at_lanes": "Ethernet100,Ethernet101,Ethernet102,Ethernet103", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet104": { + "index": "27,27,27,27", + "lanes": "104,105,106,107", + "alias_at_lanes": "Ethernet104,Ethernet105,Ethernet106,Ethernet107", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet108": { + "index": "28,28,28,28", + "lanes": "108,109,110,111", + "alias_at_lanes": "Ethernet108,Ethernet109,Ethernet110,Ethernet111", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet112": { + "index": "29,29,29,29", + "lanes": "112,113,114,115", + "alias_at_lanes": "Ethernet112,Ethernet113,Ethernet114,Ethernet115", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet116": { + "index": "30,30,30,30", + "lanes": "116,117,118,119", + "alias_at_lanes": "Ethernet116,Ethernet117,Ethernet118,Ethernet119", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet120": { + "index": "31,31,31,31", + "lanes": "120,121,122,123", + "alias_at_lanes": "Ethernet120,Ethernet121,Ethernet122,Ethernet123", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + }, + "Ethernet124": { + "index": "32,32,32,32", + "lanes": "124,125,126,127", + "alias_at_lanes": "Ethernet124,Ethernet125,Ethernet126,Ethernet127", + "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" + } + } +} From ab03441ce994bb9ff5ca4e1aa9d619bcf8120bb3 Mon Sep 17 00:00:00 2001 From: lguohan Date: Sat, 6 Feb 2021 21:02:06 -0800 Subject: [PATCH 0162/1674] [sonic-linux-kernel]: security update to kernel 4.19.152 (#6490) Signed-off-by: Guohan Lu --- build_debian.sh | 2 +- installer/x86_64/install.sh | 4 +-- platform/barefoot/bfn-modules/debian/control | 2 +- .../debian/control | 2 +- .../debian/control | 4 +-- .../sonic-platform-modules-bfn/debian/control | 2 +- .../debian/control | 2 +- .../broadcom/saibcm-modules/debian/control | 2 +- .../debian/opennsl-modules.dirs | 2 +- .../debian/opennsl-modules.install | 12 ++++---- platform/broadcom/saibcm-modules/debian/rules | 4 +-- .../debian/control | 4 +-- .../sonic-platform-modules-cel/debian/control | 8 +++--- .../debian/control | 14 +++++----- .../debian/control | 12 ++++---- .../debian/control | 14 +++++----- .../debian/control | 2 +- .../cavm_platform_modules/DEBIAN/control | 2 +- .../debian/control | 4 +-- .../platform-modules-e530-24x2c.install | 4 +-- .../platform-modules-e530-48t4x-p.install | 4 +-- platform/centec-arm64/sonic_fit.its | 4 +-- .../centec-arm64/tsingma-bsp/debian/control | 2 +- .../tsingma-bsp/debian/tsingma-bsp.install | 28 +++++++++---------- .../debian/control | 4 +-- .../debian/control | 2 +- .../sonic-platform-modules-cel/debian/control | 2 +- .../debian/control | 2 +- platform/marvell-armhf/platform.conf | 4 +-- platform/nephos/nephos-modules/debian/control | 2 +- .../debian/control | 2 +- .../sonic-platform-modules-cig/debian/control | 6 ++-- .../debian/control | 2 +- rules/linux-kernel.mk | 6 ++-- src/sonic-linux-kernel | 2 +- 35 files changed, 87 insertions(+), 87 deletions(-) diff --git a/build_debian.sh b/build_debian.sh index 19ee92b8620d..cbb4a559e78b 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -32,7 +32,7 @@ CONFIGURED_ARCH=$([ -f .arch ] && cat .arch || echo amd64) ## docker engine version (with platform) DOCKER_VERSION=5:18.09.8~3-0~debian-$IMAGE_DISTRO -LINUX_KERNEL_VERSION=4.19.0-9-2 +LINUX_KERNEL_VERSION=4.19.0-12-2 ## Working directory to prepare the file system FILESYSTEM_ROOT=./fsroot diff --git a/installer/x86_64/install.sh b/installer/x86_64/install.sh index 349880114d04..5fa0cc087776 100755 --- a/installer/x86_64/install.sh +++ b/installer/x86_64/install.sh @@ -624,12 +624,12 @@ menuentry '$demo_grub_entry' { if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi insmod part_msdos insmod ext2 - linux /$image_dir/boot/vmlinuz-4.19.0-9-2-amd64 root=$grub_cfg_root rw $GRUB_CMDLINE_LINUX \ + linux /$image_dir/boot/vmlinuz-4.19.0-12-2-amd64 root=$grub_cfg_root rw $GRUB_CMDLINE_LINUX \ net.ifnames=0 biosdevname=0 \ loop=$image_dir/$FILESYSTEM_SQUASHFS loopfstype=squashfs \ apparmor=1 security=apparmor varlog_size=$VAR_LOG_SIZE usbcore.autosuspend=-1 $ONIE_PLATFORM_EXTRA_CMDLINE_LINUX echo 'Loading $demo_volume_label $demo_type initial ramdisk ...' - initrd /$image_dir/boot/initrd.img-4.19.0-9-2-amd64 + initrd /$image_dir/boot/initrd.img-4.19.0-12-2-amd64 } EOF diff --git a/platform/barefoot/bfn-modules/debian/control b/platform/barefoot/bfn-modules/debian/control index 2c3d8368bc4b..be1f6cc0443a 100644 --- a/platform/barefoot/bfn-modules/debian/control +++ b/platform/barefoot/bfn-modules/debian/control @@ -7,6 +7,6 @@ Standards-Version: 3.9.3 Package: bfn-modules Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for bfn asic for mmap diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/debian/control b/platform/barefoot/sonic-platform-modules-bfn-montara/debian/control index 7c46f1f96fa7..a3ea06992dc4 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/debian/control +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/debian/control @@ -7,6 +7,6 @@ Standards-Version: 3.9.3 Package: sonic-platform-modules-bfn-montara Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/debian/control b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/control index 89135fda2478..d2c37fe8d2b9 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-newport/debian/control +++ b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/control @@ -7,11 +7,11 @@ Standards-Version: 3.9.3 Package: sonic-platform-modules-bfn-newport-as9516 Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel module for bfn platform fpga and scripts for the devices such as fan, led, sfp Package: sonic-platform-modules-bfn-newport-as9516bf Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel module for bfn platform fpga and scripts for the devices such as fan, led, sfp diff --git a/platform/barefoot/sonic-platform-modules-bfn/debian/control b/platform/barefoot/sonic-platform-modules-bfn/debian/control index e5ce77ba7120..89c597303a78 100644 --- a/platform/barefoot/sonic-platform-modules-bfn/debian/control +++ b/platform/barefoot/sonic-platform-modules-bfn/debian/control @@ -7,6 +7,6 @@ Standards-Version: 3.9.3 Package: sonic-platform-modules-bfn Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/barefoot/sonic-platform-modules-wnc-osw1800/debian/control b/platform/barefoot/sonic-platform-modules-wnc-osw1800/debian/control index 6f7bd62ffcc2..eab1adcadecd 100644 --- a/platform/barefoot/sonic-platform-modules-wnc-osw1800/debian/control +++ b/platform/barefoot/sonic-platform-modules-wnc-osw1800/debian/control @@ -7,6 +7,6 @@ Standards-Version: 3.9.3 Package: platform-modules-wnc-osw1800 Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/broadcom/saibcm-modules/debian/control b/platform/broadcom/saibcm-modules/debian/control index d022eadb0501..60bcbafb1b1a 100644 --- a/platform/broadcom/saibcm-modules/debian/control +++ b/platform/broadcom/saibcm-modules/debian/control @@ -10,5 +10,5 @@ Standards-Version: 3.9.3 Package: opennsl-modules Architecture: amd64 Section: main -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for broadcom SAI diff --git a/platform/broadcom/saibcm-modules/debian/opennsl-modules.dirs b/platform/broadcom/saibcm-modules/debian/opennsl-modules.dirs index 27fae96d8a1a..140d1186059e 100644 --- a/platform/broadcom/saibcm-modules/debian/opennsl-modules.dirs +++ b/platform/broadcom/saibcm-modules/debian/opennsl-modules.dirs @@ -1 +1 @@ -lib/modules/4.19.0-9-2-amd64/extra +lib/modules/4.19.0-12-2-amd64/extra diff --git a/platform/broadcom/saibcm-modules/debian/opennsl-modules.install b/platform/broadcom/saibcm-modules/debian/opennsl-modules.install index ebb290820f03..c4d7ace79696 100644 --- a/platform/broadcom/saibcm-modules/debian/opennsl-modules.install +++ b/platform/broadcom/saibcm-modules/debian/opennsl-modules.install @@ -1,8 +1,8 @@ -systems/linux/user/x86-smp_generic_64-2_6/linux-bcm-knet.ko lib/modules/4.19.0-9-2-amd64/extra -systems/linux/user/x86-smp_generic_64-2_6/linux-kernel-bde.ko lib/modules/4.19.0-9-2-amd64/extra -systems/linux/user/x86-smp_generic_64-2_6/linux-user-bde.ko lib/modules/4.19.0-9-2-amd64/extra -systems/linux/user/x86-smp_generic_64-2_6/linux-knet-cb.ko lib/modules/4.19.0-9-2-amd64/extra -systems/linux/user/x86-smp_generic_64-2_6/psample.ko lib/modules/4.19.0-9-2-amd64/extra -systems/linux/user/x86-smp_generic_64-2_6/linux-bcm-ptp-clock.ko lib/modules/4.19.0-9-2-amd64/extra +systems/linux/user/x86-smp_generic_64-2_6/linux-bcm-knet.ko lib/modules/4.19.0-12-2-amd64/extra +systems/linux/user/x86-smp_generic_64-2_6/linux-kernel-bde.ko lib/modules/4.19.0-12-2-amd64/extra +systems/linux/user/x86-smp_generic_64-2_6/linux-user-bde.ko lib/modules/4.19.0-12-2-amd64/extra +systems/linux/user/x86-smp_generic_64-2_6/linux-knet-cb.ko lib/modules/4.19.0-12-2-amd64/extra +systems/linux/user/x86-smp_generic_64-2_6/psample.ko lib/modules/4.19.0-12-2-amd64/extra +systems/linux/user/x86-smp_generic_64-2_6/linux-bcm-ptp-clock.ko lib/modules/4.19.0-12-2-amd64/extra systemd/opennsl-modules.service lib/systemd/system sdklt/linux/bde/linux_ngbde.ko lib/modules/4.19.0-9-2-amd64/extra diff --git a/platform/broadcom/saibcm-modules/debian/rules b/platform/broadcom/saibcm-modules/debian/rules index 4fcf2db75a5f..572471027c87 100755 --- a/platform/broadcom/saibcm-modules/debian/rules +++ b/platform/broadcom/saibcm-modules/debian/rules @@ -34,8 +34,8 @@ sname:=opennsl PACKAGE=opennsl-modules # modifieable for experiments or debugging m-a MA_DIR ?= /usr/share/modass -KVERSION ?= 4.19.0-9-2-amd64 -KERNVERSION ?= 4.19.0-9-2 +KVERSION ?= 4.19.0-12-2-amd64 +KERNVERSION ?= 4.19.0-12-2 # load generic variable handling -include $(MA_DIR)/include/generic.make diff --git a/platform/broadcom/sonic-platform-modules-alphanetworks/debian/control b/platform/broadcom/sonic-platform-modules-alphanetworks/debian/control index 6c7b1c41446f..6535dbb88bb8 100644 --- a/platform/broadcom/sonic-platform-modules-alphanetworks/debian/control +++ b/platform/broadcom/sonic-platform-modules-alphanetworks/debian/control @@ -7,11 +7,11 @@ Standards-Version: 3.9.3 Package: sonic-platform-alphanetworks-snh60a0-320fv2 Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: sonic-platform-alphanetworks-snh60b0-640f Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/broadcom/sonic-platform-modules-cel/debian/control b/platform/broadcom/sonic-platform-modules-cel/debian/control index 1eedf83d07b0..a41f92ab54e9 100644 --- a/platform/broadcom/sonic-platform-modules-cel/debian/control +++ b/platform/broadcom/sonic-platform-modules-cel/debian/control @@ -7,21 +7,21 @@ Standards-Version: 3.9.3 Package: platform-modules-dx010 Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: platform-modules-haliburton Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: platform-modules-seastone2 Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as led, sfp Package: platform-modules-silverstone Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as led, sfp. diff --git a/platform/broadcom/sonic-platform-modules-dell/debian/control b/platform/broadcom/sonic-platform-modules-dell/debian/control index 82b0e402a15d..2920602fcd60 100644 --- a/platform/broadcom/sonic-platform-modules-dell/debian/control +++ b/platform/broadcom/sonic-platform-modules-dell/debian/control @@ -7,37 +7,37 @@ Standards-Version: 3.9.3 Package: platform-modules-s6000 Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: platform-modules-z9100 Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: platform-modules-s6100 Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: platform-modules-z9264f Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: platform-modules-s5232f Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: platform-modules-s5248f Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: platform-modules-z9332f Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: platform-modules-s5296f diff --git a/platform/broadcom/sonic-platform-modules-delta/debian/control b/platform/broadcom/sonic-platform-modules-delta/debian/control index 6105f280ad33..809c58b0c0b1 100644 --- a/platform/broadcom/sonic-platform-modules-delta/debian/control +++ b/platform/broadcom/sonic-platform-modules-delta/debian/control @@ -7,30 +7,30 @@ Standards-Version: 3.9.3 Package: platform-modules-ag9032v1 Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: platform-modules-ag9064 Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: platform-modules-ag5648 Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: platform-modules-et-6248brb Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: platform-modules-ag9032v2a Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as syseeprom, sfp Package: platform-modules-agc032 Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/broadcom/sonic-platform-modules-inventec/debian/control b/platform/broadcom/sonic-platform-modules-inventec/debian/control index d5ba6b0869e8..7a435d9b6e60 100644 --- a/platform/broadcom/sonic-platform-modules-inventec/debian/control +++ b/platform/broadcom/sonic-platform-modules-inventec/debian/control @@ -7,35 +7,35 @@ Standards-Version: 3.9.3 Package: platform-modules-d7032q28b Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led Package: platform-modules-d7054q28b Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led Package: platform-modules-d6254qs Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led Package: platform-modules-d6556 Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led Package: platform-modules-d6356 Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led Package: platform-modules-d7264q28b Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led Package: platform-modules-d6332 Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led diff --git a/platform/broadcom/sonic-platform-modules-mitac/debian/control b/platform/broadcom/sonic-platform-modules-mitac/debian/control index f1a62577f6e2..f909c6af9489 100644 --- a/platform/broadcom/sonic-platform-modules-mitac/debian/control +++ b/platform/broadcom/sonic-platform-modules-mitac/debian/control @@ -7,6 +7,6 @@ Standards-Version: 3.9.3 Package: sonic-platform-mitac-ly1200-32x Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/cavium/cavm_platform_modules/DEBIAN/control b/platform/cavium/cavm_platform_modules/DEBIAN/control index 938215c8f8ee..6a665e88c718 100755 --- a/platform/cavium/cavm_platform_modules/DEBIAN/control +++ b/platform/cavium/cavm_platform_modules/DEBIAN/control @@ -1,6 +1,6 @@ Package: cavm-platform-modules Version: 1.0 Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Maintainer: Nadiya.Stetskovych@cavium.com Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/centec-arm64/sonic-platform-modules-e530/debian/control b/platform/centec-arm64/sonic-platform-modules-e530/debian/control index 023a365f4d7b..2a1bc972a8b2 100644 --- a/platform/centec-arm64/sonic-platform-modules-e530/debian/control +++ b/platform/centec-arm64/sonic-platform-modules-e530/debian/control @@ -7,10 +7,10 @@ Standards-Version: 3.9.3 Package: platform-modules-e530-48t4x-p Architecture: arm64 -Depends: linux-image-4.19.0-9-2-arm64-unsigned +Depends: linux-image-4.19.0-12-2-arm64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: platform-modules-e530-24x2c Architecture: arm64 -Depends: linux-image-4.19.0-9-2-arm64-unsigned +Depends: linux-image-4.19.0-12-2-arm64-unsigned Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/centec-arm64/sonic-platform-modules-e530/debian/platform-modules-e530-24x2c.install b/platform/centec-arm64/sonic-platform-modules-e530/debian/platform-modules-e530-24x2c.install index f9fceaf20f23..b74a968fe976 100644 --- a/platform/centec-arm64/sonic-platform-modules-e530/debian/platform-modules-e530-24x2c.install +++ b/platform/centec-arm64/sonic-platform-modules-e530/debian/platform-modules-e530-24x2c.install @@ -1,3 +1,3 @@ -../../centec/centec-dal/dal.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra -24x2c/modules/centec_e530_24x2c_platform.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra +../../centec/centec-dal/dal.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra +24x2c/modules/centec_e530_24x2c_platform.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra 24x2c/service/24x2c_platform.service /lib/systemd/system diff --git a/platform/centec-arm64/sonic-platform-modules-e530/debian/platform-modules-e530-48t4x-p.install b/platform/centec-arm64/sonic-platform-modules-e530/debian/platform-modules-e530-48t4x-p.install index 57d2eb4470ad..7d1c00eebeae 100644 --- a/platform/centec-arm64/sonic-platform-modules-e530/debian/platform-modules-e530-48t4x-p.install +++ b/platform/centec-arm64/sonic-platform-modules-e530/debian/platform-modules-e530-48t4x-p.install @@ -1,3 +1,3 @@ -../../centec/centec-dal/dal.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra -48t4x_p/modules/centec_e530_48t4x_p_platform.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra +../../centec/centec-dal/dal.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra +48t4x_p/modules/centec_e530_48t4x_p_platform.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra 48t4x_p/service/48t4x_p_platform.service /lib/systemd/system diff --git a/platform/centec-arm64/sonic_fit.its b/platform/centec-arm64/sonic_fit.its index 8a358ac325f4..7ee89e6c812f 100644 --- a/platform/centec-arm64/sonic_fit.its +++ b/platform/centec-arm64/sonic_fit.its @@ -12,7 +12,7 @@ images { kernel_ctc { description = "ARM64 Kernel"; - data = /incbin/("./vmlinuz-4.19.0-9-2-arm64"); + data = /incbin/("./vmlinuz-4.19.0-12-2-arm64"); type = "kernel"; arch = "arm64"; os = "linux"; @@ -25,7 +25,7 @@ }; initramfs { description = "initramfs"; - data = /incbin/("./initrd.img-4.19.0-9-2-arm64"); + data = /incbin/("./initrd.img-4.19.0-12-2-arm64"); type = "ramdisk"; arch = "arm64"; os = "linux"; diff --git a/platform/centec-arm64/tsingma-bsp/debian/control b/platform/centec-arm64/tsingma-bsp/debian/control index e183844f01e1..fc6d0b8def4f 100644 --- a/platform/centec-arm64/tsingma-bsp/debian/control +++ b/platform/centec-arm64/tsingma-bsp/debian/control @@ -7,5 +7,5 @@ Standards-Version: 3.9.3 Package: tsingma-bsp Architecture: arm64 -Depends: linux-image-4.19.0-9-2-arm64-unsigned +Depends: linux-image-4.19.0-12-2-arm64-unsigned Description: kernel modules for tsingma bsp diff --git a/platform/centec-arm64/tsingma-bsp/debian/tsingma-bsp.install b/platform/centec-arm64/tsingma-bsp/debian/tsingma-bsp.install index 81d328b68996..e2fb35af1b6c 100644 --- a/platform/centec-arm64/tsingma-bsp/debian/tsingma-bsp.install +++ b/platform/centec-arm64/tsingma-bsp/debian/tsingma-bsp.install @@ -1,17 +1,17 @@ -src/ctc5236-mc/ctc5236-mc.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra -src/pwm-ctc/pwm-ctc.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra -src/ctc5236_switch/ctc5236_switch.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra -src/pinctrl-ctc/pinctrl-ctc.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra -src/ctc_wdt/ctc_wdt.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra -src/ctcmac/ctcmac.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra -src/ctcmac/ctcmac_test.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra -src/ctcmac/ctc5236_mdio.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra -src/i2c-ctc/i2c-ctc.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra -src/gpio-ctc/gpio-ctc.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra -src/ehci-ctc/ehci-ctc.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra -src/rtc-sd2405/rtc-sd2405.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra -src/sdhci-ctc5236/sdhci-ctc5236.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra -src/spi-ctc-qspi/spi-ctc-qspi.ko /lib/modules/4.19.0-9-2-arm64/kernel/extra +src/ctc5236-mc/ctc5236-mc.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra +src/pwm-ctc/pwm-ctc.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra +src/ctc5236_switch/ctc5236_switch.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra +src/pinctrl-ctc/pinctrl-ctc.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra +src/ctc_wdt/ctc_wdt.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra +src/ctcmac/ctcmac.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra +src/ctcmac/ctcmac_test.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra +src/ctcmac/ctc5236_mdio.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra +src/i2c-ctc/i2c-ctc.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra +src/gpio-ctc/gpio-ctc.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra +src/ehci-ctc/ehci-ctc.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra +src/rtc-sd2405/rtc-sd2405.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra +src/sdhci-ctc5236/sdhci-ctc5236.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra +src/spi-ctc-qspi/spi-ctc-qspi.ko /lib/modules/4.19.0-12-2-arm64/kernel/extra src/ctc-dts/e530-ctc5236.dtb /boot/ src/config/fw_env.config /etc/ src/config/tsingma-bsp.service /lib/systemd/system diff --git a/platform/centec/sonic-platform-modules-e582/debian/control b/platform/centec/sonic-platform-modules-e582/debian/control index 5d6bcc7002e8..97f617d4836a 100644 --- a/platform/centec/sonic-platform-modules-e582/debian/control +++ b/platform/centec/sonic-platform-modules-e582/debian/control @@ -7,11 +7,11 @@ Standards-Version: 3.9.3 Package: platform-modules-e582-48x2q4z Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: platform-modules-e582-48x6q Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/centec/sonic-platform-modules-embedway/debian/control b/platform/centec/sonic-platform-modules-embedway/debian/control index 781f4df43422..6fb02a824826 100644 --- a/platform/centec/sonic-platform-modules-embedway/debian/control +++ b/platform/centec/sonic-platform-modules-embedway/debian/control @@ -7,6 +7,6 @@ Standards-Version: 3.9.3 Package: platform-modules-embedway-es6220 Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/innovium/sonic-platform-modules-cel/debian/control b/platform/innovium/sonic-platform-modules-cel/debian/control index 3b9152232d38..374f1f75d3aa 100755 --- a/platform/innovium/sonic-platform-modules-cel/debian/control +++ b/platform/innovium/sonic-platform-modules-cel/debian/control @@ -7,5 +7,5 @@ Standards-Version: 3.9.3 Package: platform-modules-midstone-200i Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices diff --git a/platform/innovium/sonic-platform-modules-delta/debian/control b/platform/innovium/sonic-platform-modules-delta/debian/control index ac94e19b4cf8..bcfea2d42f1f 100644 --- a/platform/innovium/sonic-platform-modules-delta/debian/control +++ b/platform/innovium/sonic-platform-modules-delta/debian/control @@ -7,7 +7,7 @@ Standards-Version: 3.9.3 Package: platform-modules-et-c032if Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/marvell-armhf/platform.conf b/platform/marvell-armhf/platform.conf index 7fc7af8519bc..78f64b6fbe18 100644 --- a/platform/marvell-armhf/platform.conf +++ b/platform/marvell-armhf/platform.conf @@ -10,8 +10,8 @@ fdt_addr=0x1000000 initrd_addr=0x2000000 VAR_LOG=512 -kernel_fname="/boot/vmlinuz-4.19.0-9-2-armmp" -initrd_fname="/boot/initrd.img-4.19.0-9-2-armmp" +kernel_fname="/boot/vmlinuz-4.19.0-12-2-armmp" +initrd_fname="/boot/initrd.img-4.19.0-12-2-armmp" fdt_fname="/boot/armada-385-ET6448M_4G_Nand.dtb" if [ "$install_env" = "onie" ]; then diff --git a/platform/nephos/nephos-modules/debian/control b/platform/nephos/nephos-modules/debian/control index 78eb7af671fe..1b485d808f3e 100644 --- a/platform/nephos/nephos-modules/debian/control +++ b/platform/nephos/nephos-modules/debian/control @@ -7,6 +7,6 @@ Standards-Version: 3.9.3 Package: nephos-modules Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for nephos asic diff --git a/platform/nephos/sonic-platform-modules-accton/debian/control b/platform/nephos/sonic-platform-modules-accton/debian/control index e2b67b03b9e4..3020b86408d6 100755 --- a/platform/nephos/sonic-platform-modules-accton/debian/control +++ b/platform/nephos/sonic-platform-modules-accton/debian/control @@ -7,5 +7,5 @@ Standards-Version: 3.9.3 Package: sonic-platform-accton-as7116-54x Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/nephos/sonic-platform-modules-cig/debian/control b/platform/nephos/sonic-platform-modules-cig/debian/control index 870edcf1a234..fc0c6736ffa2 100644 --- a/platform/nephos/sonic-platform-modules-cig/debian/control +++ b/platform/nephos/sonic-platform-modules-cig/debian/control @@ -7,15 +7,15 @@ Standards-Version: 3.9.3 Package: sonic-platform-cig-cs6436-56p Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: sonic-platform-cig-cs6436-54p Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp Package: sonic-platform-cig-cs5435-54p Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/nephos/sonic-platform-modules-pegatron/debian/control b/platform/nephos/sonic-platform-modules-pegatron/debian/control index fc3054a4c876..8fc19980fc12 100755 --- a/platform/nephos/sonic-platform-modules-pegatron/debian/control +++ b/platform/nephos/sonic-platform-modules-pegatron/debian/control @@ -7,6 +7,6 @@ Standards-Version: 3.9.3 Package: sonic-platform-pegatron-porsche Architecture: amd64 -Depends: linux-image-4.19.0-9-2-amd64-unsigned +Depends: linux-image-4.19.0-12-2-amd64-unsigned Description: kernel modules for platform devices such as fan, led, sfp diff --git a/rules/linux-kernel.mk b/rules/linux-kernel.mk index 600600cc96f6..44107c4c7743 100644 --- a/rules/linux-kernel.mk +++ b/rules/linux-kernel.mk @@ -1,9 +1,9 @@ # linux kernel package -KVERSION_SHORT = 4.19.0-9-2 +KVERSION_SHORT = 4.19.0-12-2 KVERSION = $(KVERSION_SHORT)-$(CONFIGURED_ARCH) -KERNEL_VERSION = 4.19.118 -KERNEL_SUBVERSION = 2+deb10u1 +KERNEL_VERSION = 4.19.152 +KERNEL_SUBVERSION = 1 ifeq ($(CONFIGURED_ARCH), armhf) # Override kernel version for ARMHF as it uses arm MP (multi-platform) for short version KVERSION = $(KVERSION_SHORT)-armmp diff --git a/src/sonic-linux-kernel b/src/sonic-linux-kernel index 548e8e0be496..11f0da688d5b 160000 --- a/src/sonic-linux-kernel +++ b/src/sonic-linux-kernel @@ -1 +1 @@ -Subproject commit 548e8e0be49692050ea4071d5e9945816bc5aacc +Subproject commit 11f0da688d5bd7e206c3e50fd408d0717e9626d1 From a04d7efddc87797546f66963978d0022b938afd8 Mon Sep 17 00:00:00 2001 From: Junchao-Mellanox <57339448+Junchao-Mellanox@users.noreply.github.com> Date: Sun, 7 Feb 2021 17:21:44 +0800 Subject: [PATCH 0163/1674] Fix dynamic minimum fan table issue caused by python3 (#6690) **- Why I did it** After migrating to python3, the operator '/' always get a float result, but it gets integer result in python2. Need fix this in thermal_conditions. **- How I did it** 1. cast float value to int 2. change the unit test case to cover this situation **- How to verify it** Manually test and regression test --- .../mlnx-platform-api/sonic_platform/thermal_conditions.py | 2 +- .../mellanox/mlnx-platform-api/tests/test_thermal_policy.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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 94e18a2e00b0..a682061d12a8 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_conditions.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_conditions.py @@ -85,7 +85,7 @@ def is_match(self, thermal_info_dict): trust_state = Thermal.check_module_temperature_trustable() temperature = Thermal.get_min_amb_temperature() - temperature = temperature / 1000 + temperature = int(temperature / 1000) change_cooling_level = False if trust_state != MinCoolingLevelChangeCondition.trust_state: 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 87fac359b2fd..4d69a39c58a1 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_thermal_policy.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_thermal_policy.py @@ -482,7 +482,7 @@ def test_dynamic_minimum_policy(thermal_manager): 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=35000) + Thermal.get_min_amb_temperature = MagicMock(return_value=35001) assert condition.is_match(None) assert MinCoolingLevelChangeCondition.trust_state == 'trust' assert MinCoolingLevelChangeCondition.temperature == 35 @@ -492,7 +492,7 @@ def test_dynamic_minimum_policy(thermal_manager): assert condition.is_match(None) assert MinCoolingLevelChangeCondition.trust_state == 'untrust' - Thermal.get_min_amb_temperature = MagicMock(return_value=25000) + Thermal.get_min_amb_temperature = MagicMock(return_value=25999) assert condition.is_match(None) assert MinCoolingLevelChangeCondition.temperature == 25 From b92c2f5150e1109cd834861e544e7e44742222c0 Mon Sep 17 00:00:00 2001 From: vmittal-msft <46945843+vmittal-msft@users.noreply.github.com> Date: Mon, 8 Feb 2021 08:07:33 -0800 Subject: [PATCH 0164/1674] [broadcom]: BRCM SAI 4.3.0.10-5 : Fix for ACL entry set attribute for IN_PORTS for TD3 (#6718) ACL entry set attribute updates all the entries in the table. The correct behavior is to set the attribute on single entry. - How I did it Current SDK code, while setting the new attribute, is going through all the entries and updating it. Added a logic to check for requested entry and only allow for that ACL entry. A case has filed with BRCM. Once an official fix is provided by BRCM, we will then remove this in house fix and apply the official fix. --- platform/broadcom/sai.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index 1b27d7bc1f88..e36319619b0c 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,8 +1,8 @@ -BRCM_SAI = libsaibcm_4.3.0.10-4_amd64.deb -$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.0.10-4_amd64.deb?sv=2015-04-05&sr=b&sig=nfseU56PACVqklQ4MC0HvZ7qt7Ou4loQMBA7jx8CSOY%3D&se=2034-10-13T16%3A31%3A22Z&sp=r" -BRCM_SAI_DEV = libsaibcm-dev_4.3.0.10-4_amd64.deb +BRCM_SAI = libsaibcm_4.3.0.10-5_amd64.deb +$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.0.10-5_amd64.deb?sv=2019-12-12&st=2021-02-08T00%3A20%3A49Z&se=2030-02-09T00%3A20%3A00Z&sr=b&sp=r&sig=rEpcTHNsSr10rKhpr6Cx3EFNa2dRE7VLP7ybZijQKpE%3D" +BRCM_SAI_DEV = libsaibcm-dev_4.3.0.10-5_amd64.deb $(eval $(call add_derived_package,$(BRCM_SAI),$(BRCM_SAI_DEV))) -$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.0.10-4_amd64.deb?sv=2015-04-05&sr=b&sig=4tF26GxI6jmrcvRyCezQ7RL6qMjzip7SFf61eqy%2Bvf4%3D&se=2034-10-13T16%3A31%3A53Z&sp=r" +$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.0.10-5_amd64.deb?sv=2019-12-12&st=2021-02-08T00%3A21%3A42Z&se=2030-02-09T00%3A21%3A00Z&sr=b&sp=r&sig=gvDnVYkQe%2FA2Yqw9p404Vtmx%2Fo8NwJMFoCn7K4W1k0M%3D" SONIC_ONLINE_DEBS += $(BRCM_SAI) $(BRCM_SAI_DEV)_DEPENDS += $(BRCM_SAI) From de4a675dd136f5bae4853699f4a514bb2c8a77fa Mon Sep 17 00:00:00 2001 From: lguohan Date: Tue, 9 Feb 2021 08:48:23 -0800 Subject: [PATCH 0165/1674] [saibcm-modules]: match linux kernel version (#6732) Signed-off-by: Guohan Lu --- platform/broadcom/saibcm-modules/debian/opennsl-modules.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/broadcom/saibcm-modules/debian/opennsl-modules.install b/platform/broadcom/saibcm-modules/debian/opennsl-modules.install index c4d7ace79696..5e8e70bb189f 100644 --- a/platform/broadcom/saibcm-modules/debian/opennsl-modules.install +++ b/platform/broadcom/saibcm-modules/debian/opennsl-modules.install @@ -5,4 +5,4 @@ systems/linux/user/x86-smp_generic_64-2_6/linux-knet-cb.ko lib/modules/4.19.0-12 systems/linux/user/x86-smp_generic_64-2_6/psample.ko lib/modules/4.19.0-12-2-amd64/extra systems/linux/user/x86-smp_generic_64-2_6/linux-bcm-ptp-clock.ko lib/modules/4.19.0-12-2-amd64/extra systemd/opennsl-modules.service lib/systemd/system -sdklt/linux/bde/linux_ngbde.ko lib/modules/4.19.0-9-2-amd64/extra +sdklt/linux/bde/linux_ngbde.ko lib/modules/4.19.0-12-2-amd64/extra From fb6e157ab3c0c03ba3520c90d754576b970ce06d Mon Sep 17 00:00:00 2001 From: jostar-yang Date: Wed, 10 Feb 2021 02:02:09 +0800 Subject: [PATCH 0166/1674] [as7312-54x] Support platform API2.0 (#6272) Add platform 2.0 support for Accton as7312-54x platform --- .../sonic_platform/__init__.py | 2 + .../sonic_platform/chassis.py | 193 +++ .../sonic_platform/component.py | 125 ++ .../sonic_platform/eeprom.py | 102 ++ .../sonic_platform/fan.py | 177 +++ .../sonic_platform/helper.py | 117 ++ .../sonic_platform/platform.py | 21 + .../sonic_platform/psu.py | 220 +++ .../sonic_platform/sfp.py | 1228 +++++++++++++++++ .../sonic_platform/thermal.py | 146 ++ .../as7312-54x/sonic_platform_setup.py | 34 + .../as7312-54x/utils/accton_as7312_util.py | 60 +- .../debian/rules | 7 + .../sonic-platform-accton-as7312-54x.install | 2 + 14 files changed, 2427 insertions(+), 7 deletions(-) create mode 100644 device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/__init__.py create mode 100644 device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/chassis.py create mode 100644 device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/component.py create mode 100644 device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/eeprom.py create mode 100644 device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/fan.py create mode 100644 device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/helper.py create mode 100644 device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/platform.py create mode 100644 device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/psu.py create mode 100644 device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/sfp.py create mode 100644 device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/thermal.py create mode 100755 platform/broadcom/sonic-platform-modules-accton/as7312-54x/sonic_platform_setup.py create mode 100644 platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as7312-54x.install diff --git a/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/__init__.py b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/__init__.py new file mode 100644 index 000000000000..43435472a423 --- /dev/null +++ b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/__init__.py @@ -0,0 +1,2 @@ +__all__ = ['chassis', 'eeprom', 'platform', 'psu', 'sfp', 'thermal', 'fan'] +from . import platform diff --git a/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/chassis.py b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/chassis.py new file mode 100644 index 000000000000..ceece0f9db83 --- /dev/null +++ b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/chassis.py @@ -0,0 +1,193 @@ +############################################################################# +# Edgecore +# +# Module contains an implementation of SONiC Platform Base API and +# provides the Chassis information which are available in the platform +# +############################################################################# + +import os + +try: + from sonic_platform_base.chassis_base import ChassisBase + from .helper import APIHelper +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +NUM_FAN_TRAY = 6 +NUM_FAN = 2 +NUM_PSU = 2 +NUM_THERMAL = 4 +PORT_END = 54 +NUM_COMPONENT = 4 +HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/" +PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/" +REBOOT_CAUSE_FILE = "reboot-cause.txt" +PREV_REBOOT_CAUSE_FILE = "previous-reboot-cause.txt" +HOST_CHK_CMD = "docker > /dev/null 2>&1" + + +class Chassis(ChassisBase): + """Platform-specific Chassis class""" + + def __init__(self): + ChassisBase.__init__(self) + self._api_helper = APIHelper() + self._api_helper = APIHelper() + self.is_host = self._api_helper.is_host() + + self.config_data = {} + + self.__initialize_fan() + self.__initialize_psu() + self.__initialize_thermals() + self.__initialize_components() + self.__initialize_sfp() + self.__initialize_eeprom() + + def __initialize_sfp(self): + from sonic_platform.sfp import Sfp + for index in range(0, PORT_END): + sfp = Sfp(index) + self._sfp_list.append(sfp) + self.sfp_module_initialized = True + + def __initialize_fan(self): + from sonic_platform.fan import Fan + for fant_index in range(0, NUM_FAN_TRAY): + for fan_index in range(0, NUM_FAN): + fan = Fan(fant_index, fan_index) + self._fan_list.append(fan) + + def __initialize_psu(self): + from sonic_platform.psu import Psu + for index in range(0, NUM_PSU): + psu = Psu(index) + self._psu_list.append(psu) + + def __initialize_thermals(self): + from sonic_platform.thermal import Thermal + for index in range(0, NUM_THERMAL): + thermal = Thermal(index) + self._thermal_list.append(thermal) + + def __initialize_eeprom(self): + from sonic_platform.eeprom import Tlv + self._eeprom = Tlv() + + def __initialize_components(self): + from sonic_platform.component import Component + for index in range(0, NUM_COMPONENT): + component = Component(index) + self._component_list.append(component) + + def __initialize_watchdog(self): + from sonic_platform.watchdog import Watchdog + self._watchdog = Watchdog() + + + def __is_host(self): + return os.system(HOST_CHK_CMD) == 0 + + 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 None + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + + return self._api_helper.hwsku + + def get_presence(self): + """ + Retrieves the presence of the Chassis + Returns: + bool: True if Chassis is present, False if not + """ + return True + + def get_status(self): + """ + Retrieves the operational status of the device + Returns: + A boolean value, True if device is operating properly, False if not + """ + return True + + def get_base_mac(self): + """ + Retrieves the base MAC address for the chassis + Returns: + A string containing the MAC address in the format + 'XX:XX:XX:XX:XX:XX' + """ + return self._eeprom.get_mac() + + def get_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.get_serial() + + def get_system_eeprom_info(self): + """ + Retrieves the full content of system EEPROM information for the chassis + Returns: + A dictionary where keys are the type code defined in + OCP ONIE TlvInfo EEPROM format and values are their corresponding + values. + """ + return self._eeprom.get_eeprom() + + def get_reboot_cause(self): + """ + Retrieves the cause of the previous reboot + + Returns: + A tuple (string, string) where the first element is a string + containing the cause of the previous reboot. This string must be + one of the predefined strings in this class. If the first string + is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used + to pass a description of the reboot cause. + """ + + reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE) + sw_reboot_cause = self._api_helper.read_txt_file( + reboot_cause_path) or "Unknown" + + + return ('REBOOT_CAUSE_NON_HARDWARE', sw_reboot_cause) + + def get_sfp(self, index): + """ + Retrieves sfp represented by (1-based) index + Args: + index: An integer, the index (1-based) of the sfp to retrieve. + The index should be the sequence of a physical port in a chassis, + starting from 1. + For example, 1 for Ethernet0, 2 for Ethernet4 and so on. + Returns: + An object dervied from SfpBase representing the specified sfp + """ + sfp = None + if not self.sfp_module_initialized: + self.__initialize_sfp() + + try: + # The index will start from 1 + sfp = self._sfp_list[index-1] + except IndexError: + sys.stderr.write("SFP index {} out of range (1-{})\n".format( + index, len(self._sfp_list))) + return sfp diff --git a/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/component.py b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/component.py new file mode 100644 index 000000000000..5300e1e73233 --- /dev/null +++ b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/component.py @@ -0,0 +1,125 @@ +############################################################################# +# Celestica +# +# Component contains an implementation of SONiC Platform Base API and +# provides the components firmware management function +# +############################################################################# + +import shlex +import subprocess + +try: + from sonic_platform_base.component_base import ComponentBase + from .helper import APIHelper +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +CPLD_ADDR_MAPPING = { + "CPLD1": "4-0060", + "CPLD2": "5-0062", + "CPLD3": "6-0064", +} +SYSFS_PATH = "/sys/bus/i2c/devices/" +BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version" +COMPONENT_LIST= [ + ("CPLD1", "CPLD 1"), + ("CPLD2", "CPLD 2"), + ("CPLD3", "CPLD 3"), + ("BIOS", "Basic Input/Output System") + +] +COMPONENT_DES_LIST = ["CPLD","Basic Input/Output System"] + + +class Component(ComponentBase): + """Platform-specific Component class""" + + DEVICE_TYPE = "component" + + def __init__(self, component_index=0): + self._api_helper=APIHelper() + ComponentBase.__init__(self) + self.index = component_index + self.name = self.get_name() + + def __run_command(self, command): + # Run bash command and print output to stdout + try: + process = subprocess.Popen( + shlex.split(command), stdout=subprocess.PIPE) + while True: + output = process.stdout.readline() + if output == '' and process.poll() is not None: + break + rc = process.poll() + if rc != 0: + return False + except Exception: + return False + return True + + def __get_bios_version(self): + # Retrieves the BIOS firmware version + try: + with open(BIOS_VERSION_PATH, 'r') as fd: + bios_version = fd.read() + return bios_version.strip() + except Exception as e: + return None + + def __get_cpld_version(self): + # Retrieves the CPLD firmware version + cpld_version = dict() + for cpld_name in CPLD_ADDR_MAPPING: + try: + cpld_path = "{}{}{}".format(SYSFS_PATH, CPLD_ADDR_MAPPING[cpld_name], '/version') + cpld_version_raw= self._api_helper.read_txt_file(cpld_path) + cpld_version[cpld_name] = "{}".format(int(cpld_version_raw,16)) + except Exception as e: + print('Get exception when read cpld') + cpld_version[cpld_name] = 'None' + + return cpld_version + + def get_name(self): + """ + Retrieves the name of the component + Returns: + A string containing the name of the component + """ + return COMPONENT_LIST[self.index][0] + + def get_description(self): + """ + Retrieves the description of the component + Returns: + A string containing the description of the component + """ + return COMPONENT_LIST[self.index][1] + #return "testhwsku" + + def get_firmware_version(self): + """ + Retrieves the firmware version of module + Returns: + string: The firmware versions of the module + """ + fw_version = None + if self.name == "BIOS": + fw_version = self.__get_bios_version() + elif "CPLD" in self.name: + cpld_version = self.__get_cpld_version() + fw_version = cpld_version.get(self.name) + + return fw_version + + def install_firmware(self, image_path): + """ + Install firmware to module + Args: + image_path: A string, path to firmware image + Returns: + A boolean, True if install successfully, False if not + """ + raise NotImplementedError diff --git a/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/eeprom.py b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/eeprom.py new file mode 100644 index 000000000000..1b2f3f276c3e --- /dev/null +++ b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/eeprom.py @@ -0,0 +1,102 @@ +try: + import os + import sys + import re + if sys.version_info[0] >= 3: + from io import StringIO + else: + from cStringIO import StringIO + + from sonic_platform_base.sonic_eeprom import eeprom_tlvinfo +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +CACHE_ROOT = '/var/cache/sonic/decode-syseeprom' +CACHE_FILE = 'syseeprom_cache' + + +class Tlv(eeprom_tlvinfo.TlvInfoDecoder): + + EEPROM_DECODE_HEADLINES = 6 + + def __init__(self): + self._eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom" + super(Tlv, self).__init__(self._eeprom_path, 0, '', True) + self._eeprom = self._load_eeprom() + + def __parse_output(self, decode_output): + decode_output.replace('\0', '') + lines = decode_output.split('\n') + lines = lines[self.EEPROM_DECODE_HEADLINES:] + _eeprom_info_dict = dict() + + for line in lines: + try: + match = re.search( + '(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)([\S]+)', line) + if match is not None: + idx = match.group(1) + value = match.group(3).rstrip('\0') + + _eeprom_info_dict[idx] = value + except Exception: + pass + + return _eeprom_info_dict + + def _load_eeprom(self): + original_stdout = sys.stdout + sys.stdout = StringIO() + try: + self.read_eeprom_db() + except Exception: + decode_output = sys.stdout.getvalue() + sys.stdout = original_stdout + return self.__parse_output(decode_output) + + status = self.check_status() + if 'ok' not in status: + return False + + if not os.path.exists(CACHE_ROOT): + try: + os.makedirs(CACHE_ROOT) + except Exception: + pass + + # + # only the eeprom classes that inherit from eeprom_base + # support caching. Others will work normally + # + try: + self.set_cache_name(os.path.join(CACHE_ROOT, CACHE_FILE)) + except Exception: + pass + + e = self.read_eeprom() + if e is None: + return 0 + + try: + self.update_cache(e) + except Exception: + pass + + self.decode_eeprom(e) + decode_output = sys.stdout.getvalue() + sys.stdout = original_stdout + + (is_valid, valid_crc) = self.is_checksum_valid(e) + if not is_valid: + return False + + return self.__parse_output(decode_output) + + def get_eeprom(self): + return self._eeprom + + def get_serial(self): + return self._eeprom.get('0x23', "Undefined.") + + def get_mac(self): + return self._eeprom.get('0x24', "Undefined.") diff --git a/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/fan.py b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/fan.py new file mode 100644 index 000000000000..fc072941a3d3 --- /dev/null +++ b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/fan.py @@ -0,0 +1,177 @@ +############################################################################# +# Edgecore +# +# Module contains an implementation of SONiC Platform Base API and +# provides the fan status which are available in the platform +# +############################################################################# + + +try: + from sonic_platform_base.fan_base import FanBase + from .helper import APIHelper +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +PSU_FAN_MAX_RPM = 26688 + +CPLD_I2C_PATH = "/sys/bus/i2c/devices/2-0066/fan" +PSU_HWMON_I2C_PATH ="/sys/bus/i2c/devices/{}-00{}/" +PSU_I2C_MAPPING = { + 0: { + "num": 11, + "addr": "5b" + }, + 1: { + "num": 10, + "addr": "58" + }, +} + + +class Fan(FanBase): + """Platform-specific Fan class""" + + def __init__(self, fan_tray_index, fan_index=0, is_psu_fan=False, psu_index=0): + self._api_helper=APIHelper() + self.fan_index = fan_index + self.fan_tray_index = fan_tray_index + self.is_psu_fan = is_psu_fan + if self.is_psu_fan: + self.psu_index = psu_index + self.psu_i2c_num = PSU_I2C_MAPPING[self.psu_index]['num'] + self.psu_i2c_addr = PSU_I2C_MAPPING[self.psu_index]['addr'] + self.psu_hwmon_path = PSU_HWMON_I2C_PATH.format( + self.psu_i2c_num, self.psu_i2c_addr) + + FanBase.__init__(self) + + + def get_direction(self): + """ + Retrieves the direction of fan + Returns: + A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST + depending on fan direction + """ + + + if not self.is_psu_fan: + dir_str = "{}{}{}".format(CPLD_I2C_PATH, self.fan_tray_index, '_direction') + val=self._api_helper.read_txt_file(dir_str) + if val is not None: + if val==0:#F2B + direction=self.FAN_DIRECTION_EXHAUST + else: + direction=self.FAN_DIRECTION_INTAKE + else: + direction=self.FAN_DIRECTION_EXHAUST + + else: #For PSU + dir_str = "{}{}".format(self.psu_hwmon_path,'psu_hwmon_path') + val=self._api_helper.read_txt_file(dir_str) + if val is not None: + if val=='F2B': + direction=self.FAN_DIRECTION_EXHAUST + else: + direction=self.FAN_DIRECTION_INTAKE + else: + 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) + + """ + speed = 0 + if self.is_psu_fan: + psu_fan_path= "{}{}".format(self.psu_hwmon_path, 'psu_fan1_speed_rpm') + fan_speed_rpm = self._api_helper.read_txt_file(psu_fan_path) + if fan_speed_rpm is not None: + speed = (int(fan_speed_rpm,10))*100/26688 + if speed > 100: + speed=100 + else: + return 0 + + elif self.get_presence(): + speed_path = "{}{}".format(CPLD_I2C_PATH, '_duty_cycle_percentage') + speed=self._api_helper.read_txt_file(speed_path) + if speed is None: + return 0 + + return int(speed) + + def get_target_speed(self): + """ + Retrieves the target (expected) speed of the fan + Returns: + An integer, the percentage of full fan speed, in the range 0 (off) + to 100 (full speed) + + Note: + speed_pc = pwm_target/255*100 + + 0 : when PWM mode is use + pwm : when pwm mode is not use + """ + return False #Not supported + + 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 False #Not supported + + def set_speed(self, speed): + """ + Sets the fan speed + Args: + speed: An integer, the percentage of full fan speed to set fan to, + in the range 0 (off) to 100 (full speed) + Returns: + A boolean, True if speed is set successfully, False if not + + """ + + if not self.is_psu_fan and self.get_presence(): + speed_path = "{}{}".format(CPLD_I2C_PATH, '_duty_cycle_percentage') + return self._api_helper.write_txt_file(speed_path, int(speed)) + + return False + + def set_status_led(self, color): + """ + Sets the state of the fan module status LED + Args: + color: A string representing the color with which to set the + fan module status LED + Returns: + bool: True if status LED state is set successfully, False if not + """ + return False #Not supported + + def get_presence(self): + """ + Retrieves the presence of the FAN + Returns: + bool: True if FAN is present, False if not + """ + present_path = "{}{}{}".format(CPLD_I2C_PATH, self.fan_tray_index+1, '_present') + val=self._api_helper.read_txt_file(present_path) + + if not self.is_psu_fan: + if val is not None: + return int(val, 10)==1 + else: + return False + else: + return True diff --git a/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/helper.py b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/helper.py new file mode 100644 index 000000000000..4cd60ac90611 --- /dev/null +++ b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/helper.py @@ -0,0 +1,117 @@ +import os +import struct +import subprocess +from mmap import * +from sonic_py_common import device_info + +HOST_CHK_CMD = "docker > /dev/null 2>&1" +EMPTY_STRING = "" + + +class APIHelper(): + + def __init__(self): + (self.platform, self.hwsku) = device_info.get_platform_and_hwsku() + + def is_host(self): + return os.system(HOST_CHK_CMD) == 0 + + def pci_get_value(self, resource, offset): + status = True + result = "" + try: + fd = os.open(resource, os.O_RDWR) + mm = mmap(fd, 0) + mm.seek(int(offset)) + read_data_stream = mm.read(4) + result = struct.unpack('I', read_data_stream) + except Exception: + status = False + return status, result + + def run_command(self, cmd): + status = True + result = "" + try: + p = subprocess.Popen( + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err == '': + result = raw_data.strip() + except Exception: + status = False + return status, result + + def run_interactive_command(self, cmd): + try: + os.system(cmd) + except Exception: + return False + return True + + 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 None + + def write_txt_file(self, file_path, value): + try: + with open(file_path, 'w') as fd: + fd.write(str(value)) + except IOError: + return False + return True + + def ipmi_raw(self, netfn, cmd): + status = True + result = "" + try: + cmd = "ipmitool raw {} {}".format(str(netfn), str(cmd)) + p = subprocess.Popen( + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err == '': + result = raw_data.strip() + else: + status = False + except Exception: + status = False + return status, result + + def ipmi_fru_id(self, id, key=None): + status = True + result = "" + try: + cmd = "ipmitool fru print {}".format(str( + id)) if not key else "ipmitool fru print {0} | grep '{1}' ".format(str(id), str(key)) + + p = subprocess.Popen( + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err == '': + result = raw_data.strip() + else: + status = False + except Exception: + status = False + return status, result + + def ipmi_set_ss_thres(self, id, threshold_key, value): + status = True + result = "" + try: + cmd = "ipmitool sensor thresh '{}' {} {}".format(str(id), str(threshold_key), str(value)) + p = subprocess.Popen( + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err == '': + result = raw_data.strip() + else: + status = False + except Exception: + status = False + return status, result diff --git a/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/platform.py b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/platform.py new file mode 100644 index 000000000000..2f2c2a447fcf --- /dev/null +++ b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/platform.py @@ -0,0 +1,21 @@ +############################################################################# +# Edgecore +# +# Module contains an implementation of SONiC Platform Base API and +# provides the platform information +# +############################################################################# + +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): + """Platform-specific Platform class""" + + def __init__(self): + PlatformBase.__init__(self) + self._chassis = Chassis() diff --git a/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/psu.py b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/psu.py new file mode 100644 index 000000000000..cb715515d50e --- /dev/null +++ b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/psu.py @@ -0,0 +1,220 @@ +############################################################################# +# Edgecore +# +# Module contains an implementation of SONiC Platform Base API and +# provides the PSUs status which are available in the platform +# +############################################################################# + +#import sonic_platform + +try: + from sonic_platform_base.psu_base import PsuBase + from .helper import APIHelper +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +I2C_PATH ="/sys/bus/i2c/devices/{0}-00{1}/" + +PSU_NAME_LIST = ["PSU-1", "PSU-2"] +PSU_NUM_FAN = [1, 1] +PSU_HWMON_I2C_MAPPING = { + 0: { + "num": 11, + "addr": "5b" + }, + 1: { + "num": 10, + "addr": "58" + }, +} + +PSU_CPLD_I2C_MAPPING = { + 0: { + "num": 11, + "addr": "53" + }, + 1: { + "num": 10, + "addr": "50" + }, +} + +class Psu(PsuBase): + """Platform-specific Psu class""" + + def __init__(self, psu_index=0): + PsuBase.__init__(self) + self.index = psu_index + self._api_helper = APIHelper() + + self.i2c_num = PSU_HWMON_I2C_MAPPING[self.index]["num"] + self.i2c_addr = PSU_HWMON_I2C_MAPPING[self.index]["addr"] + self.hwmon_path = I2C_PATH.format(self.i2c_num, self.i2c_addr) + + self.i2c_num = PSU_CPLD_I2C_MAPPING[self.index]["num"] + self.i2c_addr = PSU_CPLD_I2C_MAPPING[self.index]["addr"] + self.cpld_path = I2C_PATH.format(self.i2c_num, self.i2c_addr) + self.__initialize_fan() + + def __initialize_fan(self): + from sonic_platform.fan import Fan + for fan_index in range(0, PSU_NUM_FAN[self.index]): + fan = Fan(fan_index, 0, is_psu_fan=True, psu_index=self.index) + self._fan_list.append(fan) + + def get_voltage(self): + """ + Retrieves current PSU voltage output + Returns: + A float number, the output voltage in volts, + e.g. 12.1 + """ + vout_path = "{}{}".format(self.hwmon_path, 'psu_v_out') + vout_val=self._api_helper.read_txt_file(vout_path) + return float(vout_val)/ 1000 + + def get_current(self): + """ + Retrieves present electric current supplied by PSU + Returns: + A float number, the electric current in amperes, e.g 15.4 + """ + iout_path = "{}{}".format(self.hwmon_path, 'psu_i_out') + val=self._api_helper.read_txt_file(iout_path) + if val is not None: + return float(val)/1000 + else: + return 0 + + def get_power(self): + """ + Retrieves current energy supplied by PSU + Returns: + A float number, the power in watts, e.g. 302.6 + """ + pout_path = "{}{}".format(self.hwmon_path, 'psu_p_out') + val=self._api_helper.read_txt_file(pout_path) + if val is not None: + return float(val)/1000 + else: + return 0 + + def get_powergood_status(self): + """ + Retrieves the powergood status of PSU + Returns: + A boolean, True if PSU has stablized its output voltages and passed all + its internal self-tests, False if not. + """ + return self.get_status() + + def set_status_led(self, color): + """ + Sets the state of the PSU status LED + Args: + color: A string representing the color with which to set the PSU status LED + Note: Only support green and off + Returns: + bool: True if status LED state is set successfully, False if not + """ + + return False #Controlled by HW + + def get_status_led(self): + """ + Gets the state of the PSU status LED + Returns: + A string, one of the predefined STATUS_LED_COLOR_* strings above + """ + + if self.get_status(): + return True + else: + return False + + def get_temperature(self): + """ + Retrieves current temperature reading from PSU + Returns: + A float number of current temperature in Celsius up to nearest thousandth + of one degree Celsius, e.g. 30.125 + """ + temp_path = "{}{}".format(self.hwmon_path, 'psu_temp1_input') + val=self._api_helper.read_txt_file(temp_path) + if val is not None: + return float(val)/1000 + else: + return 0 + + def get_temperature_high_threshold(self): + """ + Retrieves the high threshold temperature of PSU + Returns: + A float number, the high threshold temperature of PSU in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + return False #Not supported + + def get_voltage_high_threshold(self): + """ + Retrieves the high threshold PSU voltage output + Returns: + A float number, the high threshold output voltage in volts, + e.g. 12.1 + """ + vout_path = "{}{}".format(self.hwmon_path, 'psu_mfr_vout_max') + vout_val=self._api_helper.read_txt_file(vout_path) + if vout_val is not None: + return float(vout_val)/ 1000 + else: + return 0 + + def get_voltage_low_threshold(self): + """ + Retrieves the low threshold PSU voltage output + Returns: + A float number, the low threshold output voltage in volts, + e.g. 12.1 + """ + vout_path = "{}{}".format(self.hwmon_path, 'psu_mfr_vout_min') + vout_val=self._api_helper.read_txt_file(vout_path) + if vout_val is not None: + return float(vout_val)/ 1000 + else: + return 0 + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + return PSU_NAME_LIST[self.index] + + def get_presence(self): + """ + Retrieves the presence of the PSU + Returns: + bool: True if PSU is present, False if not + """ + presence_path="{}{}".format(self.cpld_path, 'psu_present') + val=self._api_helper.read_txt_file(presence_path) + if val is not None: + return int(val, 10) == 1 + else: + return 0 + + def get_status(self): + """ + Retrieves the operational status of the device + Returns: + A boolean value, True if device is operating properly, False if not + """ + power_path="{}{}".format(self.cpld_path, 'psu_power_good') + val=self._api_helper.read_txt_file(power_path) + if val is not None: + return int(val, 10) == 1 + else: + return 0 diff --git a/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/sfp.py b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/sfp.py new file mode 100644 index 000000000000..31a61ca0ab08 --- /dev/null +++ b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/sfp.py @@ -0,0 +1,1228 @@ +############################################################################# +# Edgecore +# +# 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 sys + +from ctypes import create_string_buffer + +try: + from sonic_platform_base.sfp_base import SfpBase + from sonic_platform_base.sonic_sfp.sff8436 import sff8436Dom + from sonic_platform_base.sonic_sfp.sff8436 import sff8436InterfaceId + from sonic_platform_base.sonic_sfp.sff8472 import sff8472Dom + from sonic_platform_base.sonic_sfp.sff8472 import sff8472InterfaceId + #from sonic_platform_base.sonic_sfp.sff8472 import sffbase + from sonic_platform_base.sonic_sfp.sfputilhelper import SfpUtilHelper + from .helper import APIHelper +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +CPLD_I2C_PATH = "/sys/bus/i2c/devices/" + +QSFP_INFO_OFFSET = 128 +QSFP_DOM_OFFSET = 0 + +SFP_INFO_OFFSET = 0 +SFP_DOM_OFFSET = 256 + +XCVR_INTFACE_BULK_OFFSET = 0 +XCVR_INTFACE_BULK_WIDTH_QSFP = 20 +XCVR_INTFACE_BULK_WIDTH_SFP = 21 +XCVR_HW_REV_WIDTH_QSFP = 2 +XCVR_HW_REV_WIDTH_SFP = 4 +XCVR_CABLE_LENGTH_WIDTH_QSFP = 5 +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_OSFP = 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 = 1 + +# 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_CHANNL_MON_OFFSET = 34 +QSFP_CHANNL_MON_WIDTH = 16 +QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH = 24 +QSFP_CONTROL_OFFSET = 86 +QSFP_CONTROL_WIDTH = 8 +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_POWEROVERRIDE_OFFSET = 93 +QSFP_POWEROVERRIDE_WIDTH = 1 +QSFP_MODULE_THRESHOLD_OFFSET = 128 +QSFP_MODULE_THRESHOLD_WIDTH = 24 +QSFP_CHANNEL_THRESHOLD_OFFSET = 176 +QSFP_CHANNEL_THRESHOLD_WIDTH = 16 + +qsfp_cable_length_tup = ('Length(km)', 'Length OM3(2m)', + 'Length OM2(m)', 'Length OM1(m)', + 'Length Cable Assembly(m)') + +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') + + +# Offset for values in SFP eeprom +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 + +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') + + +class Sfp(SfpBase): + """Platform-specific Sfp class""" + + # Port number + PORT_START = 1 + PORT_END = 54 + QSFP_PORT_START = 49 + + # Path to 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-accton_as7312_54x-r0" + HWSKU = "Accton-AS7312-54X" + + _cpld_mapping = { + 0: "4-0060", + 1: "5-0062", + 2: "6-0064", + } + _port_to_i2c_mapping = { + 1: 18, + 2: 19, + 3: 20, + 4: 21, + 5: 22, + 6: 23, + 7: 24, + 8: 25, + 9: 26, + 10: 27, + 11: 28, + 12: 29, + 13: 30, + 14: 31, + 15: 32, + 16: 33, + 17: 34, + 18: 35, + 19: 36, + 20: 37, + 21: 38, + 22: 39, + 23: 40, + 24: 41, + 25: 42, + 26: 43, + 27: 44, + 28: 45, + 29: 46, + 30: 47, + 31: 48, + 32: 49, + 33: 50, + 34: 51, + 35: 52, + 36: 53, + 37: 54, + 38: 55, + 39: 56, + 40: 57, + 41: 58, + 42: 59, + 43: 60, + 44: 61, + 45: 62, + 46: 63, + 47: 64, + 48: 65, + 49: 66, # QSFP49 + 50: 67, + 51: 68, + 52: 69, + 53: 70, + 54: 71, # QSFP54 + } + + + def __init__(self, sfp_index=0): + self._api_helper=APIHelper() + # Init index + self.index = sfp_index + self.port_num = self.index + 1 + + # Init eeprom path + eeprom_path = '/sys/bus/i2c/devices/{0}-0050/eeprom' + self.port_to_eeprom_mapping = {} + for x in range(self.PORT_START, self.PORT_END + 1): + self.port_to_eeprom_mapping[x] = eeprom_path.format(self._port_to_i2c_mapping[x]) + + 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'] + + 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 __get_cpld_num(self, port_num): + cpld_i = 1 + if (port_num > 24 and port_num < self.QSFP_PORT_START): + cpld_i = 2 + + if (port_num > 52): + cpld_i = 2 + + return cpld_i + + + 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 __write_txt_file(self, file_path, value): + try: + with open(file_path, 'w', buffering=0) as fd: + fd.write(str(value)) + except Exception: + return False + return True + + 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 __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) + if sys.version_info[0] >= 3: + for n in range(0, num_bytes): + eeprom_raw[n] = hex(raw[n])[2:].zfill(2) + else: + for n in range(0, num_bytes): + eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2) + except Exception: + pass + finally: + if sysfsfile_eeprom: + sysfsfile_eeprom.close() + + return eeprom_raw + + def get_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 + ======================================================================== + """ + # check present status + if self.port_num < 49: + sfpi_obj = sff8472InterfaceId() #SFP + else: + sfpi_obj = sff8436InterfaceId() #QSFP + if not self.get_presence() or not sfpi_obj: + return {} + + if self.port_num < 49: + offset = SFP_INFO_OFFSET + sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_INTFACE_BULK_OFFSET), XCVR_INTFACE_BULK_WIDTH_SFP) + else: + offset = QSFP_INFO_OFFSET + sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_INTFACE_BULK_OFFSET), XCVR_INTFACE_BULK_WIDTH_QSFP) + + sfp_interface_bulk_data = sfpi_obj.parse_sfp_info_bulk( + sfp_interface_bulk_raw, 0) + + sfp_vendor_name_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_VENDOR_NAME_OFFSET), XCVR_VENDOR_NAME_WIDTH) + sfp_vendor_name_data = sfpi_obj.parse_vendor_name( + sfp_vendor_name_raw, 0) + + sfp_vendor_pn_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_VENDOR_PN_OFFSET), XCVR_VENDOR_PN_WIDTH) + sfp_vendor_pn_data = sfpi_obj.parse_vendor_pn( + sfp_vendor_pn_raw, 0) + + if self.port_num < 49: + sfp_vendor_rev_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_HW_REV_OFFSET), XCVR_HW_REV_WIDTH_SFP) + else: + sfp_vendor_rev_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_HW_REV_OFFSET), XCVR_HW_REV_WIDTH_QSFP) + + sfp_vendor_rev_data = sfpi_obj.parse_vendor_rev( + sfp_vendor_rev_raw, 0) + + sfp_vendor_sn_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_VENDOR_SN_OFFSET), XCVR_VENDOR_SN_WIDTH) + sfp_vendor_sn_data = sfpi_obj.parse_vendor_sn( + sfp_vendor_sn_raw, 0) + + sfp_vendor_oui_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_VENDOR_OUI_OFFSET), XCVR_VENDOR_OUI_WIDTH) + if sfp_vendor_oui_raw is not None: + sfp_vendor_oui_data = sfpi_obj.parse_vendor_oui( + sfp_vendor_oui_raw, 0) + + sfp_vendor_date_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_VENDOR_DATE_OFFSET), XCVR_VENDOR_DATE_WIDTH) + sfp_vendor_date_data = sfpi_obj.parse_vendor_date( + sfp_vendor_date_raw, 0) + + transceiver_info_dict = dict.fromkeys(self.info_dict_keys, 'N/A') + compliance_code_dict = dict() + + if sfp_interface_bulk_data: + transceiver_info_dict['type'] = sfp_interface_bulk_data['data']['type']['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'] = sfp_interface_bulk_data['data']['type_abbrv_name']['value'] + + transceiver_info_dict['manufacturer'] = sfp_vendor_name_data[ + 'data']['Vendor Name']['value'] if sfp_vendor_name_data else 'N/A' + transceiver_info_dict['model'] = sfp_vendor_pn_data['data']['Vendor PN']['value'] if sfp_vendor_pn_data else 'N/A' + transceiver_info_dict['hardware_rev'] = sfp_vendor_rev_data['data']['Vendor Rev']['value'] if sfp_vendor_rev_data else 'N/A' + transceiver_info_dict['serial'] = sfp_vendor_sn_data['data']['Vendor SN']['value'] if sfp_vendor_sn_data else 'N/A' + transceiver_info_dict['vendor_oui'] = sfp_vendor_oui_data['data']['Vendor OUI']['value'] if sfp_vendor_oui_data else 'N/A' + transceiver_info_dict['vendor_date'] = sfp_vendor_date_data[ + 'data']['VendorDataCode(YYYY-MM-DD Lot)']['value'] if sfp_vendor_date_data else 'N/A' + transceiver_info_dict['cable_type'] = "Unknown" + transceiver_info_dict['cable_length'] = "Unknown" + + if self.port_num < 49: + 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']) + else: + 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']) + + + 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. + ======================================================================== + """ + # check present status + if self.port_num < 49: #SFP case + sfpd_obj = sff8472Dom() + if not self.get_presence() or not sfpd_obj: + return {} + + eeprom_ifraw = self.__read_eeprom_specific_bytes(0, SFP_DOM_OFFSET) + 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: #QSFP case + sfpd_obj = sff8436Dom() + sfpi_obj = sff8436InterfaceId() + + if not self.get_presence() or not sfpi_obj or not sfpd_obj: + return {} + + 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: + qspf_dom_capability_data = sfpi_obj.parse_qsfp_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 = qspf_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'] + #End of else + + + 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() + + 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. + ======================================================================== + """ + # check present status + if self.port_num < 49: + sfpd_obj = sff8472Dom() + + if not self.get_presence() and not sfpd_obj: + return {} + + eeprom_ifraw = self.__read_eeprom_specific_bytes(0, SFP_DOM_OFFSET) + sfpi_obj = sff8472InterfaceId(eeprom_ifraw) + cal_type = sfpi_obj.get_calibration_type() + sfpd_obj._calibration_type = cal_type + + offset = SFP_DOM_OFFSET + transceiver_dom_threshold_info_dict = dict.fromkeys( + self.threshold_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: + sfpd_obj = sff8436Dom() + + if not self.get_presence() or not sfpd_obj: + return {} + + transceiver_dom_threshold_dict = dict.fromkeys( + self.threshold_dict_keys, 'N/A') + dom_thres_raw = self.__read_eeprom_specific_bytes( + QSFP_MODULE_THRESHOLD_OFFSET, QSFP_MODULE_THRESHOLD_WIDTH) if self.get_presence() and sfpd_obj else None + + if dom_thres_raw: + module_threshold_values = sfpd_obj.parse_module_threshold_values( + dom_thres_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_thres_raw = self.__read_eeprom_specific_bytes( + QSFP_CHANNEL_THRESHOLD_OFFSET, QSFP_CHANNEL_THRESHOLD_WIDTH) if self.get_presence() and sfpd_obj else None + channel_threshold_values = sfpd_obj.parse_channel_threshold_values( + dom_thres_raw, 0) + channel_threshold_data = channel_threshold_values.get('data') + 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 + + def get_reset_status(self): + """ + Retrieves the reset status of SFP + Returns: + A Boolean, True if reset enabled, False if disabled + """ + if self.port_num <49: + return False # SPF port doesn't support this feature + + cpld_i = self.__get_cpld_num(self.port_num) + cpld_path = self._cpld_mapping[cpld_i] + reset_path = "{}{}{}{}".format(CPLD_I2C_PATH, cpld_path, '/module_reset_', self.port_num) + val=self._api_helper.read_txt_file(reset_path) + if val is None: + return 0 + + return int(val, 10)==1 + + def get_rx_los(self): + """ + Retrieves the RX LOS (lost-of-signal) status of SFP + Returns: + A Boolean, True if SFP has RX LOS, False if not. + Note : RX LOS status is latched until a call to get_rx_los or a reset. + """ + rx_los = False + if self.port_num < 49: + cpld_i = self.__get_cpld_num(self.port_num) + cpld_path = self._cpld_mapping[cpld_i] + rx_path = "{}{}{}{}".format(CPLD_I2C_PATH, cpld_path, '/module_rx_los_', self.port_num) + rx_los=self._api_helper.read_txt_file(rx_path) + if rx_los is None: + return False + #status_control_raw = self.__read_eeprom_specific_bytes( + # SFP_STATUS_CONTROL_OFFSET, SFP_STATUS_CONTROL_WIDTH) + #if status_control_raw: + # data = int(status_control_raw[0], 16) + # rx_los = (sffbase().test_bit(data, 1) != 0) + + else: + rx_los_list = [] + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + QSFP_CHANNL_RX_LOS_STATUS_OFFSET, QSFP_CHANNL_RX_LOS_STATUS_WIDTH) if self.get_presence() else None + if dom_channel_monitor_raw is not None: + rx_los_data = int(dom_channel_monitor_raw[0], 16) + rx_los_list.append(rx_los_data & 0x01 != 0) + rx_los_list.append(rx_los_data & 0x02 != 0) + rx_los_list.append(rx_los_data & 0x04 != 0) + rx_los_list.append(rx_los_data & 0x08 != 0) + rx_los = rx_los_list[0] and rx_los_list[1] and rx_los_list[2] and rx_los_list[3] + + return rx_los + + 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. + """ + tx_fault = False + if self.port_num < 49: + cpld_i = self.__get_cpld_num(self.port_num) + cpld_path = self._cpld_mapping[cpld_i] + tx_path = "{}{}{}{}".format(CPLD_I2C_PATH, cpld_path, '/module_tx_fault_', self.port_num) + tx_fault=self._api_helper.read_txt_file(tx_path) + if tx_fault is None: + return False + #status_control_raw = self.__read_eeprom_specific_bytes( + # SFP_STATUS_CONTROL_OFFSET, SFP_STATUS_CONTROL_WIDTH) + #if status_control_raw: + # data = int(status_control_raw[0], 16) + # tx_fault = (sffbase().test_bit(data, 2) != 0) + else: + tx_fault_list = [] + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + QSFP_CHANNL_TX_FAULT_STATUS_OFFSET, QSFP_CHANNL_TX_FAULT_STATUS_WIDTH) if self.get_presence() else None + if dom_channel_monitor_raw is not None: + tx_fault_data = int(dom_channel_monitor_raw[0], 16) + tx_fault_list.append(tx_fault_data & 0x01 != 0) + tx_fault_list.append(tx_fault_data & 0x02 != 0) + tx_fault_list.append(tx_fault_data & 0x04 != 0) + tx_fault_list.append(tx_fault_data & 0x08 != 0) + tx_fault = tx_fault_list[0] and tx_fault_list[1] and tx_fault_list[2] and tx_fault_list[3] + + return tx_fault + + 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 self.port_num < 49: + tx_disable = False + + cpld_i = self.__get_cpld_num(self.port_num) + cpld_path = self._cpld_mapping[cpld_i] + tx_path = "{}{}{}{}".format(CPLD_I2C_PATH, cpld_path, '/module_tx_disable_', self.port_num) + tx_disable=self._api_helper.read_txt_file(tx_path) + + #status_control_raw = self.__read_eeprom_specific_bytes( + # SFP_STATUS_CONTROL_OFFSET, SFP_STATUS_CONTROL_WIDTH) + #if status_control_raw: + # data = int(status_control_raw[0], 16) + # tx_disable_hard = (sffbase().test_bit( + # data, SFP_TX_DISABLE_HARD_BIT) != 0) + # tx_disable_soft = (sffbase().test_bit( + # data, SFP_TX_DISABLE_SOFT_BIT) != 0) + # tx_disable = tx_disable_hard | tx_disable_soft + if tx_disable is not None: + return tx_disable + else: + return False + + else: + tx_disable_list = [] + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return False + + dom_control_raw = self.__read_eeprom_specific_bytes( + QSFP_CONTROL_OFFSET, QSFP_CONTROL_WIDTH) if self.get_presence() else None + if dom_control_raw is not None: + dom_control_data = sfpd_obj.parse_control_bytes(dom_control_raw, 0) + tx_disable_list.append( + 'On' == dom_control_data['data']['TX1Disable']['value']) + tx_disable_list.append( + 'On' == dom_control_data['data']['TX2Disable']['value']) + tx_disable_list.append( + 'On' == dom_control_data['data']['TX3Disable']['value']) + tx_disable_list.append( + 'On' == dom_control_data['data']['TX4Disable']['value']) + + return tx_disable_list + + 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. + """ + if self.port_num < 49: + # SFP doesn't support this feature + return False + else: + tx_disable_list = self.get_tx_disable() + if tx_disable_list is None: + return 0 + tx_disabled = 0 + for i in range(len(tx_disable_list)): + if tx_disable_list[i]: + tx_disabled |= 1 << i + return tx_disabled + + def get_lpmode(self): + """ + Retrieves the lpmode (low power mode) status of this SFP + Returns: + A Boolean, True if lpmode is enabled, False if disabled + """ + if self.port_num < 49: + # SFP doesn't support this feature + return False + else: + power_set=self.get_power_set() + power_override = self.get_power_override() + return power_set and power_override + + + def get_power_set(self): + + if self.port_num < 49: + # SFP doesn't support this feature + return False + else: + power_set = False + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return False + + dom_control_raw = self.__read_eeprom_specific_bytes( + QSFP_POWEROVERRIDE_OFFSET, QSFP_CONTROL_WIDTH) if self.get_presence() else None + if dom_control_raw is not None: + dom_control_data = sfpd_obj.parse_control_bytes(dom_control_raw, 0) + power_set = ( + 'On' == dom_control_data['data']['PowerSet']['value']) + + return power_set + + def get_power_override(self): + """ + Retrieves the power-override status of this SFP + Returns: + A Boolean, True if power-override is enabled, False if disabled + """ + if self.port_num < 49: + return False # SFP doesn't support this feature + else: + power_override = False + + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return False + + dom_control_raw = self.__read_eeprom_specific_bytes( + QSFP_POWEROVERRIDE_OFFSET, QSFP_CONTROL_WIDTH) if self.get_presence() else None + if dom_control_raw is not None: + dom_control_data = sfpd_obj.parse_control_bytes(dom_control_raw, 0) + power_override = ( + 'On' == dom_control_data['data']['PowerOverride']['value']) + + return power_override + + def get_temperature(self): + """ + Retrieves the temperature of this SFP + Returns: + An integer number of current temperature in Celsius + """ + transceiver_dom_info_dict = self.get_transceiver_bulk_status() + return transceiver_dom_info_dict.get("temperature", "N/A") + + def get_voltage(self): + """ + Retrieves the supply voltage of this SFP + Returns: + An integer number of supply voltage in mV + """ + transceiver_dom_info_dict = self.get_transceiver_bulk_status() + return transceiver_dom_info_dict.get("voltage", "N/A") + + 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'] + """ + transceiver_dom_info_dict = self.get_transceiver_bulk_status() + + tx1_bs = transceiver_dom_info_dict.get("tx1bias", "N/A") + if self.port_num < 49: + return [tx1_bs, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else [] + + tx2_bs = transceiver_dom_info_dict.get("tx2bias", "N/A") + tx3_bs = transceiver_dom_info_dict.get("tx3bias", "N/A") + tx4_bs = transceiver_dom_info_dict.get("tx4bias", "N/A") + return [tx1_bs, tx2_bs, tx3_bs, tx4_bs] if transceiver_dom_info_dict else [] + + 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'] + """ + transceiver_dom_info_dict = self.get_transceiver_bulk_status() + + rx1_pw = transceiver_dom_info_dict.get("rx1power", "N/A") + if self.port_num < 49: + return [rx1_pw, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else [] + rx2_pw = transceiver_dom_info_dict.get("rx2power", "N/A") + rx3_pw = transceiver_dom_info_dict.get("rx3power", "N/A") + rx4_pw = transceiver_dom_info_dict.get("rx4power", "N/A") + return [rx1_pw, rx2_pw, rx3_pw, rx4_pw] if transceiver_dom_info_dict else [] + + 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'] + """ + transceiver_dom_info_dict = self.get_transceiver_bulk_status() + tx1_pw = transceiver_dom_info_dict.get("tx1power", "N/A") + if self.port_num < 49: + return [tx1_pw, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else [] + tx2_pw = transceiver_dom_info_dict.get("tx2power", "N/A") + tx3_pw = transceiver_dom_info_dict.get("tx3power", "N/A") + tx4_pw = transceiver_dom_info_dict.get("tx4power", "N/A") + return [tx1_pw, tx2_pw, tx3_pw, tx4_pw] + + def reset(self): + """ + Reset SFP and return all user module settings to their default srate. + Returns: + A boolean, True if successful, False if not + """ + if self.port_num <49: + return False # SFP doesn't support this feature + + cpld_i = self.__get_cpld_num(self.port_num) + cpld_path = self._cpld_mapping[cpld_i] + reset_path = "{}{}{}{}".format(CPLD_I2C_PATH, cpld_path, '/module_reset_', self.port_num) + ret = self.__write_txt_file(reset_path, 1) + if ret is not True: + return ret + + time.sleep(0.01) + ret = self.__write_txt_file(reset_path, 0) + time.sleep(0.2) + + return ret + + + def tx_disable(self, tx_disable): + """ + Disable SFP TX for all channels + Args: + tx_disable : A Boolean, True to enable tx_disable mode, False to disable + tx_disable mode. + Returns: + A boolean, True if tx_disable is set successfully, False if not + """ + if self.port_num < 49: + cpld_i = self.__get_cpld_num(self.port_num) + cpld_path = self._cpld_mapping[cpld_i] + tx_path = "{}{}{}{}".format(CPLD_I2C_PATH, cpld_path, '/module_tx_disable_', self.port_num) + ret = self.__write_txt_file(tx_path, 1 if tx_disable else 0) + time.sleep(0.01) + return ret + + else: + if not self.get_presence(): + return False + sysfsfile_eeprom = None + try: + tx_disable_ctl = 0xf if tx_disable else 0x0 + buffer = create_string_buffer(1) + if sys.version_info[0] >= 3: + buffer[0] = tx_disable_ctl + else: + buffer[0] = chr(tx_disable_ctl) + # Write to eeprom + sysfsfile_eeprom = open( + self.port_to_eeprom_mapping[self.port_num], "r+b") + sysfsfile_eeprom.seek(QSFP_CONTROL_OFFSET) + sysfsfile_eeprom.write(buffer[0]) + except IOError as e: + print ('Error: unable to open file: ',str(e)) + return False + finally: + if sysfsfile_eeprom is not None: + sysfsfile_eeprom.close() + time.sleep(0.01) + return True + + def tx_disable_channel(self, channel, disable): + """ + Sets the tx_disable for specified SFP channels + Args: + channel : A hex of 4 bits (bit 0 to bit 3) which represent channel 0 to 3, + e.g. 0x5 for channel 0 and channel 2. + disable : A boolean, True to disable TX channels specified in channel, + False to enable + Returns: + A boolean, True if successful, False if not + """ + + if self.port_num < 49: + return False # SFP doesn't support this feature + else: + if not self.get_presence(): + return False + + sysfsfile_eeprom = None + try: + channel_state = self.get_tx_disable_channel() + + for i in range(4): + channel_mask = (1 << i) + if not (channel & channel_mask): + continue + + if disable: + channel_state |= channel_mask + else: + channel_state &= ~channel_mask + + buffer = create_string_buffer(1) + if sys.version_info[0] >= 3: + buffer[0] = channel_state + else: + buffer[0] = chr(channel_state) + # Write to eeprom + sysfsfile_eeprom = open( + self.port_to_eeprom_mapping[self.port_num], "r+b") + sysfsfile_eeprom.seek(QSFP_CONTROL_OFFSET) + sysfsfile_eeprom.write(buffer[0]) + except IOError as e: + print ('Error: unable to open file: ', str(e)) + return False + finally: + if sysfsfile_eeprom is not None: + sysfsfile_eeprom.close() + time.sleep(0.01) + return True + + def set_lpmode(self, lpmode): + """ + Sets the lpmode (low power mode) of SFP + Args: + lpmode: A Boolean, True to enable lpmode, False to disable it + Note : lpmode can be overridden by set_power_override + Returns: + A boolean, True if lpmode is set successfully, False if not + """ + if self.port_num < 49: + return False # SFP doesn't support this feature + else: + if lpmode is True: + self.set_power_override(True, True) + else: + self.set_power_override(False, False) + + return True + + def set_power_override(self, power_override, power_set): + """ + Sets SFP power level using power_override and power_set + Args: + power_override : + A Boolean, True to override set_lpmode and use power_set + to control SFP power, False to disable SFP power control + through power_override/power_set and use set_lpmode + to control SFP power. + power_set : + Only valid when power_override is True. + A Boolean, True to set SFP to low power mode, False to set + SFP to high power mode. + Returns: + A boolean, True if power-override and power_set are set successfully, + False if not + """ + if self.port_num < 49: + return False # SFP doesn't support this feature + else: + if not self.get_presence(): + return False + try: + power_override_bit = (1 << 0) if power_override else 0 + power_set_bit = (1 << 1) if power_set else (1 << 3) + + buffer = create_string_buffer(1) + if sys.version_info[0] >= 3: + buffer[0] = (power_override_bit | power_set_bit) + else: + buffer[0] = chr(power_override_bit | power_set_bit) + # Write to eeprom + with open(self.port_to_eeprom_mapping[self.port_num], "r+b") as fd: + fd.seek(QSFP_POWEROVERRIDE_OFFSET) + fd.write(buffer[0]) + time.sleep(0.01) + except Exception: + print ('Error: unable to open file: ', str(e)) + return False + return True + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + sfputil_helper = SfpUtilHelper() + sfputil_helper.read_porttab_mappings( + self.__get_path_to_port_config_file()) + name = sfputil_helper.logical[self.index] or "Unknown" + return name + + def get_presence(self): + """ + Retrieves the presence of the device + Returns: + bool: True if device is present, False if not + """ + cpld_i = self.__get_cpld_num(self.port_num) + cpld_path = self._cpld_mapping[cpld_i] + present_path = "{}{}{}{}".format(CPLD_I2C_PATH, cpld_path, '/module_present_', self.port_num) + val=self._api_helper.read_txt_file(present_path) + if val is not None: + return int(val, 10)==1 + else: + return False + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + transceiver_dom_info_dict = self.get_transceiver_info() + return transceiver_dom_info_dict.get("model", "N/A") + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + transceiver_dom_info_dict = self.get_transceiver_info() + return transceiver_dom_info_dict.get("serial", "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_presence() and self.get_transceiver_bulk_status() diff --git a/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/thermal.py b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/thermal.py new file mode 100644 index 000000000000..aeab2caa23db --- /dev/null +++ b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/thermal.py @@ -0,0 +1,146 @@ +############################################################################# +# Edgecore +# +# Thermal contains an implementation of SONiC Platform Base API and +# provides the thermal device status which are available in the platform +# +############################################################################# + +import os +import os.path +import glob + +try: + from sonic_platform_base.thermal_base import ThermalBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Thermal(ThermalBase): + """Platform-specific Thermal class""" + + THERMAL_NAME_LIST = [] + SYSFS_PATH = "/sys/bus/i2c/devices" + + def __init__(self, thermal_index=0): + self.index = thermal_index + # Add thermal name + self.THERMAL_NAME_LIST.append("Temp sensor 1") + self.THERMAL_NAME_LIST.append("Temp sensor 2") + self.THERMAL_NAME_LIST.append("Temp sensor 3") + self.THERMAL_NAME_LIST.append("Temp sensor 4") + + # Set hwmon path + i2c_path = { + 0: "3-0048/hwmon/hwmon*/", + 1: "3-0049/hwmon/hwmon*/", + 2: "3-004a/hwmon/hwmon*/", + 3: "3-004b/hwmon/hwmon*/", + }.get(self.index, None) + + self.hwmon_path = "{}/{}".format(self.SYSFS_PATH, i2c_path) + self.ss_key = self.THERMAL_NAME_LIST[self.index] + self.ss_index = 1 + + def __read_txt_file(self, file_path): + for filename in glob.glob(file_path): + try: + with open(filename, 'r') as fd: + data =fd.readline().rstrip() + return data + except IOError as e: + pass + + return None + + 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) + if raw_temp is not None: + return float(raw_temp)/1000 + else: + return 0 + + + def __set_threshold(self, file_name, temperature): + temp_file_path = os.path.join(self.hwmon_path, file_name) + for filename in glob.glob(temp_file_path): + try: + with open(filename, 'w') as fd: + fd.write(str(temperature)) + return True + except IOError as e: + print("IOError") + + + 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 + """ + temp_file = "temp{}_max".format(self.ss_index) + return self.__get_temp(temp_file) + + def set_high_threshold(self, temperature): + """ + Sets the high threshold temperature of thermal + Args : + temperature: A float number up to nearest thousandth of one degree Celsius, + e.g. 30.125 + Returns: + A boolean, True if threshold is set successfully, False if not + """ + temp_file = "temp{}_max".format(self.ss_index) + temperature = temperature *1000 + self.__set_threshold(temp_file, temperature) + + return True + + def get_name(self): + """ + Retrieves the name of the thermal device + Returns: + string: The name of the thermal device + """ + return self.THERMAL_NAME_LIST[self.index] + + def get_presence(self): + """ + Retrieves the presence of the Thermal + Returns: + bool: True if Thermal is present, False if not + """ + temp_file = "temp{}_input".format(self.ss_index) + temp_file_path = os.path.join(self.hwmon_path, temp_file) + raw_txt = self.__read_txt_file(temp_file_path) + if raw_txt is not None: + return True + else: + return False + + def get_status(self): + """ + Retrieves the operational status of the device + Returns: + A boolean value, True if device is operating properly, False if not + """ + + file_str = "temp{}_input".format(self.ss_index) + file_path = os.path.join(self.hwmon_path, file_str) + raw_txt = self.__read_txt_file(file_path) + if raw_txt is None: + return False + else: + return int(raw_txt) != 0 diff --git a/platform/broadcom/sonic-platform-modules-accton/as7312-54x/sonic_platform_setup.py b/platform/broadcom/sonic-platform-modules-accton/as7312-54x/sonic_platform_setup.py new file mode 100755 index 000000000000..672fe89cef6c --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as7312-54x/sonic_platform_setup.py @@ -0,0 +1,34 @@ +from setuptools import setup + +DEVICE_NAME = 'accton' +HW_SKU = 'x86_64-accton_as7312_54x-r0' + +setup( + name='sonic-platform', + version='1.0', + description='SONiC platform API implementation on Accton Platforms', + license='Apache 2.0', + author='SONiC Team', + author_email='linuxnetdev@microsoft.com', + url='https://github.com/Azure/sonic-buildimage', + maintainer='Jostar Yang', + maintainer_email='jostar_yang@edge-core.com', + packages=[ + 'sonic_platform', + ], + package_dir={ + 'sonic_platform': '../../../../device/{}/{}/sonic_platform'.format(DEVICE_NAME, HW_SKU)}, + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Environment :: Plugins', + 'Intended Audience :: Developers', + 'Intended Audience :: Information Technology', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: Apache Software License', + 'Natural Language :: English', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python :: 3.7', + 'Topic :: Utilities', + ], + keywords='sonic SONiC platform PLATFORM', +) 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 b4516c07fae7..e2f058b4e37a 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 @@ -35,7 +35,7 @@ import logging import re import time - +import os PROJECT_NAME = 'as7312_54x' version = '0.1.0' @@ -90,6 +90,10 @@ def main(): do_install() elif arg == 'clean': do_uninstall() + elif arg == 'api': + do_sonic_platform_install() + elif arg == 'api_clean': + do_sonic_platform_clean() elif arg == 'show': device_traversal() elif arg == 'sff': @@ -358,6 +362,43 @@ def system_ready(): return False return True +PLATFORM_ROOT_PATH = '/usr/share/sonic/device' +PLATFORM_API2_WHL_FILE_PY3 ='sonic_platform-1.0-py3-none-any.whl' +def do_sonic_platform_install(): + device_path = "{}{}{}{}".format(PLATFORM_ROOT_PATH, '/x86_64-accton_', PROJECT_NAME, '-r0') + SONIC_PLATFORM_BSP_WHL_PKG_PY3 = "/".join([device_path, PLATFORM_API2_WHL_FILE_PY3]) + + #Check API2.0 on py whl file + status, output = log_os_system("pip3 show sonic-platform > /dev/null 2>&1", 0) + if status: + if os.path.exists(SONIC_PLATFORM_BSP_WHL_PKG_PY3): + status, output = log_os_system("pip3 install "+ SONIC_PLATFORM_BSP_WHL_PKG_PY3, 1) + if status: + print "Error: Failed to install {}".format(PLATFORM_API2_WHL_FILE_PY3) + return status + else: + print "Successfully installed {} package".format(PLATFORM_API2_WHL_FILE_PY3) + else: + print('{} is not found'.format(PLATFORM_API2_WHL_FILE_PY3)) + else: + print('{} has installed'.format(PLATFORM_API2_WHL_FILE_PY3)) + + return + +def do_sonic_platform_clean(): + status, output = log_os_system("pip3 show sonic-platform > /dev/null 2>&1", 0) + if status: + print('{} does not install, not need to uninstall'.format(PLATFORM_API2_WHL_FILE_PY3)) + + else: + status, output = log_os_system("pip3 uninstall sonic-platform -y", 0) + if status: + print('Error: Failed to uninstall {}'.format(PLATFORM_API2_WHL_FILE_PY3)) + return status + else: + print('{} is uninstalled'.format(PLATFORM_API2_WHL_FILE_PY3)) + + return def do_install(): print 'Checking system....' @@ -377,6 +418,8 @@ def do_install(): return status else: print PROJECT_NAME.upper() + ' devices detected....' + do_sonic_platform_install() + return @@ -397,6 +440,9 @@ def do_uninstall(): status = driver_uninstall() if status and FORCE == 0: return status + + do_sonic_platform_clean() + return None @@ -460,8 +506,8 @@ def devices_info(): def show_eeprom(index): if system_ready() is False: - print "System's not ready." - print 'Please install first!' + print('Systems not ready.') + print('Please install first!') return if len(ALL_DEVICE) == 0: @@ -488,7 +534,7 @@ def show_eeprom(index): if ret == 0: print log else: - print '**********device no found**********' + print( '**********device no found**********') return @@ -496,8 +542,8 @@ def set_device(args): global DEVICE_NO global ALL_DEVICE if system_ready() is False: - print "System's not ready." - print 'Please install first!' + print('System is not ready.') + print('Please install first!') return if not ALL_DEVICE: @@ -565,7 +611,7 @@ def get_value(i): def device_traversal(): if system_ready() is False: - print "System's not ready." + print "System is not ready." print 'Please install first!' return diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/rules b/platform/broadcom/sonic-platform-modules-accton/debian/rules index 722d4126ad0e..e894b10f8234 100755 --- a/platform/broadcom/sonic-platform-modules-accton/debian/rules +++ b/platform/broadcom/sonic-platform-modules-accton/debian/rules @@ -14,6 +14,7 @@ include /usr/share/dpkg/pkg-info.mk export INSTALL_MOD_DIR:=extra PYTHON ?= python2 +PYTHON3 ?= python3 PACKAGE_PRE_NAME := sonic-platform-accton KVERSION ?= $(shell uname -r) @@ -40,6 +41,12 @@ build: (for mod in $(MODULE_DIRS); do \ make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \ $(PYTHON) $${mod}/setup.py build; \ + cd $(MOD_SRC_DIR)/$${mod}; \ + if [ -f sonic_platform_setup.py ]; then \ + $(PYTHON3) sonic_platform_setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}; \ + echo "Finished makig whl package for $$mod"; \ + fi; \ + cd $(MOD_SRC_DIR); \ done) binary: binary-arch binary-indep diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as7312-54x.install b/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as7312-54x.install new file mode 100644 index 000000000000..c0e14a1f6b1b --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as7312-54x.install @@ -0,0 +1,2 @@ +as7312-54x/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-accton_as7312_54x-r0 + From becd143a41e0fbb5deb123d656325235f54b2516 Mon Sep 17 00:00:00 2001 From: Tamer Ahmed Date: Wed, 10 Feb 2021 02:26:31 -0800 Subject: [PATCH 0167/1674] [syncd-rpc] Install Libboost Atomic 1.71, Libqtcore And Libqtnetwork (#6689) When Building syncd-rpc, libthrift has dependency on libboost-atomic1.71.0, however the debian packager install version 1.67 instead. This PR preinstalls libboost-atomic v 1.71 to avoid falling back to v 1.67. signed-off-by: Tamer Ahmed --- .../docker-syncd-bfn-rpc/Dockerfile.j2 | 19 ++++++++------- .../docker-syncd-brcm-rpc/Dockerfile.j2 | 16 ++++++++----- .../docker-syncd-cavm-rpc/Dockerfile.j2 | 16 ++++++++----- .../docker-syncd-centec-rpc/Dockerfile.j2 | 18 +++++++++------ .../docker-syncd-centec-rpc/Dockerfile.j2 | 18 +++++++++------ .../docker-syncd-invm-rpc/Dockerfile.j2 | 16 ++++++++----- .../docker-syncd-mrvl-rpc/Dockerfile.j2 | 16 ++++++++----- .../docker-syncd-mrvl-rpc/Dockerfile.j2 | 16 ++++++++----- .../docker-syncd-mrvl-rpc/Dockerfile.j2 | 16 ++++++++----- .../docker-syncd-mlnx-rpc/Dockerfile.j2 | 23 +++++++++++++------ .../docker-syncd-nephos-rpc/Dockerfile.j2 | 16 ++++++++----- 11 files changed, 119 insertions(+), 71 deletions(-) diff --git a/platform/barefoot/docker-syncd-bfn-rpc/Dockerfile.j2 b/platform/barefoot/docker-syncd-bfn-rpc/Dockerfile.j2 index cf89b26b65e5..5e5f5f166e5e 100644 --- a/platform/barefoot/docker-syncd-bfn-rpc/Dockerfile.j2 +++ b/platform/barefoot/docker-syncd-bfn-rpc/Dockerfile.j2 @@ -11,11 +11,6 @@ debs/ RUN apt-get purge -y syncd -RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ -{% for deb in docker_syncd_bfn_rpc_debs.split(' ') -%} -dpkg_apt debs/{{ deb }}{{'; '}} -{%- endfor %} - ## Pre-install the fundamental packages RUN apt-get update \ && apt-get -y install \ @@ -28,8 +23,16 @@ RUN apt-get update \ python-dev \ wget \ cmake \ - libpython3.4 \ - && wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ + libqt5core5a \ + libqt5network5 \ + libboost-atomic1.71.0 + +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ +{% for deb in docker_syncd_bfn_rpc_debs.split(' ') -%} +dpkg_apt debs/{{ deb }}{{'; '}} +{%- endfor %} + +RUN wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ && tar xvfz 1.0.0.tar.gz \ && cd nanomsg-1.0.0 \ && mkdir -p build \ @@ -50,5 +53,5 @@ RUN apt-get update \ && rm -rf /root/deps COPY ["ptf_nn_agent.conf", "/etc/supervisor/conf.d/"] - + ENTRYPOINT ["/usr/local/bin/supervisord"] diff --git a/platform/broadcom/docker-syncd-brcm-rpc/Dockerfile.j2 b/platform/broadcom/docker-syncd-brcm-rpc/Dockerfile.j2 index ada6113ddf43..b832fd58864f 100644 --- a/platform/broadcom/docker-syncd-brcm-rpc/Dockerfile.j2 +++ b/platform/broadcom/docker-syncd-brcm-rpc/Dockerfile.j2 @@ -11,11 +11,6 @@ debs/ RUN apt-get purge -y syncd -RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ -{% for deb in docker_syncd_brcm_rpc_debs.split(' ') -%} -dpkg_apt debs/{{ deb }}{{'; '}} -{%- endfor %} - ## Pre-install the fundamental packages RUN apt-get update \ && apt-get -y install \ @@ -28,7 +23,16 @@ RUN apt-get update \ python-dev \ wget \ cmake \ - && wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ + libqt5core5a \ + libqt5network5 \ + libboost-atomic1.71.0 + +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ +{% for deb in docker_syncd_brcm_rpc_debs.split(' ') -%} +dpkg_apt debs/{{ deb }}{{'; '}} +{%- endfor %} + +RUN wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ && tar xvfz 1.0.0.tar.gz \ && cd nanomsg-1.0.0 \ && mkdir -p build \ diff --git a/platform/cavium/docker-syncd-cavm-rpc/Dockerfile.j2 b/platform/cavium/docker-syncd-cavm-rpc/Dockerfile.j2 index 3c49748ae8ae..e9e9facef5ee 100644 --- a/platform/cavium/docker-syncd-cavm-rpc/Dockerfile.j2 +++ b/platform/cavium/docker-syncd-cavm-rpc/Dockerfile.j2 @@ -11,11 +11,6 @@ debs/ RUN apt-get purge -y syncd -RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ -{% for deb in docker_syncd_cavm_rpc_debs.split(' ') -%} -dpkg_apt debs/{{ deb }}{{'; '}} -{%- endfor %} - ## Pre-install the fundamental packages RUN apt-get update \ && apt-get -y install \ @@ -27,7 +22,16 @@ RUN apt-get update \ python-dev \ wget \ cmake \ - && wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ + libqt5core5a \ + libqt5network5 \ + libboost-atomic1.71.0 + +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ +{% for deb in docker_syncd_cavm_rpc_debs.split(' ') -%} +dpkg_apt debs/{{ deb }}{{'; '}} +{%- endfor %} + +RUN wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ && tar xvfz 1.0.0.tar.gz \ && cd nanomsg-1.0.0 \ && mkdir -p build \ diff --git a/platform/centec-arm64/docker-syncd-centec-rpc/Dockerfile.j2 b/platform/centec-arm64/docker-syncd-centec-rpc/Dockerfile.j2 index 057d93efb6bb..bec9c7f4426b 100755 --- a/platform/centec-arm64/docker-syncd-centec-rpc/Dockerfile.j2 +++ b/platform/centec-arm64/docker-syncd-centec-rpc/Dockerfile.j2 @@ -11,11 +11,6 @@ debs/ RUN apt-get purge -y syncd -RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ -{% for deb in docker_syncd_centec_rpc_debs.split(' ') -%} -dpkg_apt debs/{{ deb }}{{'; '}} -{%- endfor %} - ## Pre-install the fundamental packages RUN apt-get update \ && apt-get -y install \ @@ -28,7 +23,16 @@ RUN apt-get update \ python-dev \ wget \ cmake \ - && wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ + libqt5core5a \ + libqt5network5 \ + libboost-atomic1.71.0 + +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ +{% for deb in docker_syncd_centec_rpc_debs.split(' ') -%} +dpkg_apt debs/{{ deb }}{{'; '}} +{%- endfor %} + +RUN wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ && tar xvfz 1.0.0.tar.gz \ && cd nanomsg-1.0.0 \ && mkdir -p build \ @@ -49,5 +53,5 @@ RUN apt-get update \ && rm -rf /root/deps COPY ["ptf_nn_agent.conf", "/etc/supervisor/conf.d/"] - + ENTRYPOINT ["/usr/local/bin/supervisord"] diff --git a/platform/centec/docker-syncd-centec-rpc/Dockerfile.j2 b/platform/centec/docker-syncd-centec-rpc/Dockerfile.j2 index 057d93efb6bb..bec9c7f4426b 100644 --- a/platform/centec/docker-syncd-centec-rpc/Dockerfile.j2 +++ b/platform/centec/docker-syncd-centec-rpc/Dockerfile.j2 @@ -11,11 +11,6 @@ debs/ RUN apt-get purge -y syncd -RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ -{% for deb in docker_syncd_centec_rpc_debs.split(' ') -%} -dpkg_apt debs/{{ deb }}{{'; '}} -{%- endfor %} - ## Pre-install the fundamental packages RUN apt-get update \ && apt-get -y install \ @@ -28,7 +23,16 @@ RUN apt-get update \ python-dev \ wget \ cmake \ - && wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ + libqt5core5a \ + libqt5network5 \ + libboost-atomic1.71.0 + +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ +{% for deb in docker_syncd_centec_rpc_debs.split(' ') -%} +dpkg_apt debs/{{ deb }}{{'; '}} +{%- endfor %} + +RUN wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ && tar xvfz 1.0.0.tar.gz \ && cd nanomsg-1.0.0 \ && mkdir -p build \ @@ -49,5 +53,5 @@ RUN apt-get update \ && rm -rf /root/deps COPY ["ptf_nn_agent.conf", "/etc/supervisor/conf.d/"] - + ENTRYPOINT ["/usr/local/bin/supervisord"] diff --git a/platform/innovium/docker-syncd-invm-rpc/Dockerfile.j2 b/platform/innovium/docker-syncd-invm-rpc/Dockerfile.j2 index 3a25afbe6161..eea52e3398b8 100755 --- a/platform/innovium/docker-syncd-invm-rpc/Dockerfile.j2 +++ b/platform/innovium/docker-syncd-invm-rpc/Dockerfile.j2 @@ -11,11 +11,6 @@ debs/ RUN dpkg -P syncd -RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ -{% for deb in docker_syncd_invm_rpc_debs.split(' ') -%} -dpkg_apt debs/{{ deb }}{{'; '}} -{%- endfor %} - ## Pre-install the fundamental packages RUN apt-get update \ && apt-get -y install \ @@ -29,7 +24,16 @@ RUN apt-get update \ libjansson4 \ wget \ cmake \ - && wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ + libqt5core5a \ + libqt5network5 \ + libboost-atomic1.71.0 + +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ +{% for deb in docker_syncd_invm_rpc_debs.split(' ') -%} +dpkg_apt debs/{{ deb }}{{'; '}} +{%- endfor %} + +RUN wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ && tar xvfz 1.0.0.tar.gz \ && cd nanomsg-1.0.0 \ && mkdir -p build \ diff --git a/platform/marvell-arm64/docker-syncd-mrvl-rpc/Dockerfile.j2 b/platform/marvell-arm64/docker-syncd-mrvl-rpc/Dockerfile.j2 index 6b9e3d8aaafc..118be5e1c5f2 100644 --- a/platform/marvell-arm64/docker-syncd-mrvl-rpc/Dockerfile.j2 +++ b/platform/marvell-arm64/docker-syncd-mrvl-rpc/Dockerfile.j2 @@ -11,11 +11,6 @@ debs/ RUN apt-get purge -y syncd -RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ -{% for deb in docker_syncd_mrvl_rpc_debs.split(' ') -%} -dpkg_apt debs/{{ deb }}{{'; '}} -{%- endfor %} - ## Pre-install the fundamental packages RUN apt-get update \ && apt-get -y install \ @@ -27,7 +22,16 @@ RUN apt-get update \ python-dev \ wget \ cmake \ - && wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ + libqt5core5a \ + libqt5network5 \ + libboost-atomic1.71.0 + +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ +{% for deb in docker_syncd_mrvl_rpc_debs.split(' ') -%} +dpkg_apt debs/{{ deb }}{{'; '}} +{%- endfor %} + +RUN wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ && tar xvfz 1.0.0.tar.gz \ && cd nanomsg-1.0.0 \ && mkdir -p build \ diff --git a/platform/marvell-armhf/docker-syncd-mrvl-rpc/Dockerfile.j2 b/platform/marvell-armhf/docker-syncd-mrvl-rpc/Dockerfile.j2 index 6b9e3d8aaafc..118be5e1c5f2 100644 --- a/platform/marvell-armhf/docker-syncd-mrvl-rpc/Dockerfile.j2 +++ b/platform/marvell-armhf/docker-syncd-mrvl-rpc/Dockerfile.j2 @@ -11,11 +11,6 @@ debs/ RUN apt-get purge -y syncd -RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ -{% for deb in docker_syncd_mrvl_rpc_debs.split(' ') -%} -dpkg_apt debs/{{ deb }}{{'; '}} -{%- endfor %} - ## Pre-install the fundamental packages RUN apt-get update \ && apt-get -y install \ @@ -27,7 +22,16 @@ RUN apt-get update \ python-dev \ wget \ cmake \ - && wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ + libqt5core5a \ + libqt5network5 \ + libboost-atomic1.71.0 + +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ +{% for deb in docker_syncd_mrvl_rpc_debs.split(' ') -%} +dpkg_apt debs/{{ deb }}{{'; '}} +{%- endfor %} + +RUN wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ && tar xvfz 1.0.0.tar.gz \ && cd nanomsg-1.0.0 \ && mkdir -p build \ diff --git a/platform/marvell/docker-syncd-mrvl-rpc/Dockerfile.j2 b/platform/marvell/docker-syncd-mrvl-rpc/Dockerfile.j2 index 6b9e3d8aaafc..118be5e1c5f2 100644 --- a/platform/marvell/docker-syncd-mrvl-rpc/Dockerfile.j2 +++ b/platform/marvell/docker-syncd-mrvl-rpc/Dockerfile.j2 @@ -11,11 +11,6 @@ debs/ RUN apt-get purge -y syncd -RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ -{% for deb in docker_syncd_mrvl_rpc_debs.split(' ') -%} -dpkg_apt debs/{{ deb }}{{'; '}} -{%- endfor %} - ## Pre-install the fundamental packages RUN apt-get update \ && apt-get -y install \ @@ -27,7 +22,16 @@ RUN apt-get update \ python-dev \ wget \ cmake \ - && wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ + libqt5core5a \ + libqt5network5 \ + libboost-atomic1.71.0 + +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ +{% for deb in docker_syncd_mrvl_rpc_debs.split(' ') -%} +dpkg_apt debs/{{ deb }}{{'; '}} +{%- endfor %} + +RUN wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ && tar xvfz 1.0.0.tar.gz \ && cd nanomsg-1.0.0 \ && mkdir -p build \ diff --git a/platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 b/platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 index b9aaa78118e0..b48d4ac3c793 100644 --- a/platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 +++ b/platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 @@ -11,17 +11,11 @@ RUN apt-get purge -y syncd {% if docker_syncd_mlnx_rpc_debs.strip() -%} # Copy locally-built Debian package dependencies {{ copy_files("debs/", docker_syncd_mlnx_rpc_debs.split(' '), "/debs/") }} - -# Install locally-built Debian packages and implicitly install their dependencies -{{ install_debian_packages(docker_syncd_mlnx_rpc_debs.split(' ')) }} {% endif %} {% if docker_syncd_mlnx_rpc_pydebs.strip() -%} # Copy locally-built Debian package dependencies {{ copy_files("python-debs/", docker_syncd_mlnx_rpc_pydebs.split(' '), "/debs/") }} - -# Install locally-built Debian packages and implicitly install their dependencies -{{ install_debian_packages(docker_syncd_mlnx_rpc_pydebs.split(' ')) }} {% endif %} ## Pre-install the fundamental packages @@ -36,7 +30,22 @@ RUN apt-get update \ python-dev \ wget \ cmake \ - && wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ + libqt5core5a \ + libqt5network5 \ + libboost-atomic1.71.0 + +{% if docker_syncd_mlnx_rpc_debs.strip() -%} +# Install locally-built Debian packages and implicitly install their dependencies +{{ install_debian_packages(docker_syncd_mlnx_rpc_debs.split(' ')) }} +{% endif %} + +{% if docker_syncd_mlnx_rpc_pydebs.strip() -%} +# Install locally-built Debian packages and implicitly install their dependencies +{{ install_debian_packages(docker_syncd_mlnx_rpc_pydebs.split(' ')) }} +{% endif %} + + +RUN wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ && tar xvfz 1.0.0.tar.gz \ && cd nanomsg-1.0.0 \ && mkdir -p build \ diff --git a/platform/nephos/docker-syncd-nephos-rpc/Dockerfile.j2 b/platform/nephos/docker-syncd-nephos-rpc/Dockerfile.j2 index 95703448c371..6c63efb69bb6 100644 --- a/platform/nephos/docker-syncd-nephos-rpc/Dockerfile.j2 +++ b/platform/nephos/docker-syncd-nephos-rpc/Dockerfile.j2 @@ -11,11 +11,6 @@ debs/ RUN apt-get purge -y syncd -RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ -{% for deb in docker_syncd_nephos_rpc_debs.split(' ') -%} -dpkg_apt debs/{{ deb }}{{'; '}} -{%- endfor %} - ## Pre-install the fundamental packages RUN apt-get update \ && apt-get -y install \ @@ -27,7 +22,16 @@ RUN apt-get update \ python-dev \ wget \ cmake \ - && wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ + libqt5core5a \ + libqt5network5 \ + libboost-atomic1.71.0 + +RUN dpkg_apt() { [ -f $1 ] && { dpkg -i $1 || apt-get -y install -f; } || return 1; } ; \ +{% for deb in docker_syncd_nephos_rpc_debs.split(' ') -%} +dpkg_apt debs/{{ deb }}{{'; '}} +{%- endfor %} + +RUN wget https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz \ && tar xvfz 1.0.0.tar.gz \ && cd nanomsg-1.0.0 \ && mkdir -p build \ From dc2ea28b1c4e745837fc4477561cda69c9cf211f Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Wed, 10 Feb 2021 06:12:49 -0800 Subject: [PATCH 0168/1674] [sonic-platform-common] Update submodule (#6742) Submodule commits included: * src/sonic-platform-common 6ad0004...bd4dc03 (1): > [sonic_sfp/qsfp_dd.py] Update DOM capability method name to align with other drivers (#163) Also align all calling function names to match. --- device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/sfp.py | 2 +- .../services/platform_api/sonic_platform/sfp.py | 2 +- platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py | 2 +- src/sonic-platform-common | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/sfp.py b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/sfp.py index 31a61ca0ab08..b5e38017bc90 100644 --- a/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/sfp.py +++ b/device/accton/x86_64-accton_as7312_54x-r0/sonic_platform/sfp.py @@ -506,7 +506,7 @@ def get_transceiver_bulk_status(self): 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: - qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability( + qspf_dom_capability_data = sfpi_obj.parse_dom_capability( qsfp_dom_capability_raw, 0) else: return None diff --git a/platform/broadcom/sonic-platform-modules-cel/services/platform_api/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-cel/services/platform_api/sonic_platform/sfp.py index 5906050fa139..07eac37d8d82 100644 --- a/platform/broadcom/sonic-platform-modules-cel/services/platform_api/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-cel/services/platform_api/sonic_platform/sfp.py @@ -407,7 +407,7 @@ def _dom_capability_detect(self): if qsfp_dom_capability_raw is not None: self.dom_temp_supported = True self.dom_volt_supported = True - dom_capability = sfpi_obj.parse_qsfp_dom_capability( + dom_capability = sfpi_obj.parse_dom_capability( qsfp_dom_capability_raw, 0) if dom_capability['data']['Flat_MEM']['value'] == 'Off': self.dom_supported = True diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py index 75ae9c8907e1..39ced89fcd59 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py @@ -482,7 +482,7 @@ def _dom_capability_detect(self): if qsfp_dom_capability_raw is not None: self.dom_temp_supported = True self.dom_volt_supported = True - dom_capability = sfpi_obj.parse_qsfp_dom_capability(qsfp_dom_capability_raw, 0) + dom_capability = sfpi_obj.parse_dom_capability(qsfp_dom_capability_raw, 0) if dom_capability['data']['Flat_MEM']['value'] == 'Off': self.dom_supported = True self.second_application_list = True diff --git a/src/sonic-platform-common b/src/sonic-platform-common index 6ad0004c29a1..bd4dc03d3d63 160000 --- a/src/sonic-platform-common +++ b/src/sonic-platform-common @@ -1 +1 @@ -Subproject commit 6ad0004c29a143a0635ad7f3c81ce652313569cb +Subproject commit bd4dc03d3d63075331ae4de8f35f35d7054d260f From 9f577512f8a3d665880588ac689820e6447c0419 Mon Sep 17 00:00:00 2001 From: Arun Saravanan Balachandran <52521751+ArunSaravananBalachandran@users.noreply.github.com> Date: Wed, 10 Feb 2021 14:13:24 +0000 Subject: [PATCH 0169/1674] Dell S6100: Watchdog - Fix Python3 incompatibility (#6734) To make watchdog.arm() method python3 compatible in DellEMC S6100. --- .../s6100/sonic_platform/watchdog.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/watchdog.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/watchdog.py index c6d5e6e2e9df..0e5e102b7b52 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/watchdog.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/watchdog.py @@ -151,9 +151,9 @@ def arm(self, seconds): if self.is_armed(): gpio_val = self._read_gpio_file(gpio) high_val = gpio_val | (1 << 15) - if self._write_gpio_file(gpio, hex(high_val)) != -1: + if self._write_gpio_file(gpio, hex(high_val).encode('utf-8')) != -1: low_val = high_val & 0xFFFF7FFF - if self._write_gpio_file(gpio, hex(low_val)) != -1: + if self._write_gpio_file(gpio, hex(low_val).encode('utf-8')) != -1: self.armed_time = self._get_time() self.timeout = seconds return seconds From b92dfb15cbb97fa0cdb9393e6cc8d912467f1aea Mon Sep 17 00:00:00 2001 From: Blueve <672454911@qq.com> Date: Wed, 10 Feb 2021 22:15:13 +0800 Subject: [PATCH 0170/1674] [Celestica][haliburton][cp210x] modprobe cp210x to ensure the driver loaded properly (#6715) This PR is to fix issue: #6603 The CP210x driver not attached properly after first login (cold-plug), lsusb and dmesg shown that the usb devices has been recognized but driver is missing. --- .../debian/platform-modules-haliburton.init | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-haliburton.init b/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-haliburton.init index 1dc0ea5cfeeb..80964d5338af 100644 --- a/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-haliburton.init +++ b/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-haliburton.init @@ -18,6 +18,7 @@ start) modprobe smc modprobe hlx_gpio_ich modprobe dps200 + modprobe cp210x found=0 for devnum in 0 1; do From 5df3154cb73d3f80d7e770c7ce0a1fc70c26763a Mon Sep 17 00:00:00 2001 From: Lior Avramov <73036155+liorghub@users.noreply.github.com> Date: Thu, 11 Feb 2021 01:20:30 +0200 Subject: [PATCH 0171/1674] [submodule] update sonic-sairedis (#6747) Includes below commits: 13474d1 2021-02-08 [sairedis][syncd] VidManager add updateIndex method (Azure#787) be8059f 2021-02-08 [sairedis] Add get response timeout knob (Azure#774) 3663e30 2021-02-06 [syncd] Create base class SaiSwitchInterface (Azure#786) 3360b0f 2021-02-05 Reduce log level of redis channel to debug (Azure#790) 08d338a 2021-02-05 syncd: Fix profile iterator bug (Azure#789) a6377d0 2021-02-03 [ci]: use publish pipeline artifacts to publish syslog (Azure#788) Signed-off-by: liora --- src/sonic-sairedis | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-sairedis b/src/sonic-sairedis index b39e74610ad7..13474d17435d 160000 --- a/src/sonic-sairedis +++ b/src/sonic-sairedis @@ -1 +1 @@ -Subproject commit b39e74610ad7a842618a025fdadbdc52d530483a +Subproject commit 13474d17435d3876e7bd6b50133d25bb11dd3c54 From b8abcb4a6d31d45d444e97b79edfadd2244bcb2b Mon Sep 17 00:00:00 2001 From: Volodymyr Boiko <66446128+vboykox@users.noreply.github.com> Date: Thu, 11 Feb 2021 04:32:22 +0200 Subject: [PATCH 0172/1674] [barefoot][device][plugins] Fix sfp reset (#6745) Fix sfp reset in Barefoot's sfputil Signed-off-by: Volodymyr Boyko --- .../barefoot/x86_64-accton_wedge100bf_32x-r0/plugins/sfputil.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/device/barefoot/x86_64-accton_wedge100bf_32x-r0/plugins/sfputil.py b/device/barefoot/x86_64-accton_wedge100bf_32x-r0/plugins/sfputil.py index 47d875432cc5..41d75501f491 100644 --- a/device/barefoot/x86_64-accton_wedge100bf_32x-r0/plugins/sfputil.py +++ b/device/barefoot/x86_64-accton_wedge100bf_32x-r0/plugins/sfputil.py @@ -160,7 +160,7 @@ def reset(self, port_num): status = pltfm_mgr.pltfm_mgr_qsfp_reset(port_num, True) status = pltfm_mgr.pltfm_mgr_qsfp_reset(port_num, False) self.thrift_teardown() - return status + return (status == 0) def check_transceiver_change(self): if not self.ready: From 5a3832cf4fbb326280cc97d3da61fc46005e40a8 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Wed, 10 Feb 2021 23:06:53 -0800 Subject: [PATCH 0173/1674] [sonic-platform-common] Update submodule (#6762) * src/sonic-platform-common bd4dc03...513920c (1): > [sffbase] Make convert_hex_to_string() compatible with both Python 2 and Python 3 (#165) --- src/sonic-platform-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-platform-common b/src/sonic-platform-common index bd4dc03d3d63..513920ceb241 160000 --- a/src/sonic-platform-common +++ b/src/sonic-platform-common @@ -1 +1 @@ -Subproject commit bd4dc03d3d63075331ae4de8f35f35d7054d260f +Subproject commit 513920ceb2419873a1e27969b428af95c2e9e60f From 44e2734cc4d7616f4c87bc070e48a90519dd4010 Mon Sep 17 00:00:00 2001 From: lguohan Date: Wed, 10 Feb 2021 23:07:22 -0800 Subject: [PATCH 0174/1674] [linux-kernel]: correct kernel package name for armhf (#6751) armhf kernel package name does not have `unsigned` string Signed-off-by: Guohan Lu --- rules/linux-kernel.mk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rules/linux-kernel.mk b/rules/linux-kernel.mk index 44107c4c7743..2d369361a9e5 100644 --- a/rules/linux-kernel.mk +++ b/rules/linux-kernel.mk @@ -18,5 +18,9 @@ SONIC_MAKE_DEBS += $(LINUX_HEADERS_COMMON) LINUX_HEADERS = linux-headers-$(KVERSION)_$(KERNEL_VERSION)-$(KERNEL_SUBVERSION)_$(CONFIGURED_ARCH).deb $(eval $(call add_derived_package,$(LINUX_HEADERS_COMMON),$(LINUX_HEADERS))) -LINUX_KERNEL = linux-image-$(KVERSION)-unsigned_$(KERNEL_VERSION)-$(KERNEL_SUBVERSION)_$(CONFIGURED_ARCH).deb +ifeq ($(CONFIGURED_ARCH), armhf) + LINUX_KERNEL = linux-image-$(KVERSION)_$(KERNEL_VERSION)-$(KERNEL_SUBVERSION)_$(CONFIGURED_ARCH).deb +else + LINUX_KERNEL = linux-image-$(KVERSION)-unsigned_$(KERNEL_VERSION)-$(KERNEL_SUBVERSION)_$(CONFIGURED_ARCH).deb +endif $(eval $(call add_derived_package,$(LINUX_HEADERS_COMMON),$(LINUX_KERNEL))) From a2e593fe3f3609d259ee324283c13feea825e1af Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Wed, 10 Feb 2021 23:25:05 -0800 Subject: [PATCH 0175/1674] [slave.mk] Remove PYTHON_CLICK target (#6763) We stopped building our own custom python-click package via #5549. This target should have been removed at that time but was missed. --- slave.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/slave.mk b/slave.mk index efe26a85f1a2..86bf063b31cd 100644 --- a/slave.mk +++ b/slave.mk @@ -842,7 +842,6 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ $(addprefix $(IMAGE_DISTRO_DEBS_PATH)/,$(INITRAMFS_TOOLS) \ $(LINUX_KERNEL) \ $(SONIC_DEVICE_DATA) \ - $(PYTHON_CLICK) \ $(IFUPDOWN2) \ $(KDUMP_TOOLS) \ $(NTP) \ From 8aa5fbbe794476b42eb0aa733fb8a17b7c476cbc Mon Sep 17 00:00:00 2001 From: vmittal-msft <46945843+vmittal-msft@users.noreply.github.com> Date: Thu, 11 Feb 2021 02:31:56 -0800 Subject: [PATCH 0176/1674] [broadcom]: Upgrading bcmsai from 4.3.0.10-5 to 4.3.0.13 (#6767) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merged bcmsai 4.3.0.13 code to top of master bcmsai 4.3.0.10-5. - How to verify it Ran nightly regression on T0 and T1 topology using bcmsai 4.3.0.13. Test results are better than previous runs. For T0 - New test passing - CRM, Decap, FDB, platform test, VxLAN New test failing – PFC unknown MAC For T1 – New test passing – Port Channel New test failing – platform test --- platform/broadcom/sai.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index e36319619b0c..fa27c92236ed 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,8 +1,8 @@ -BRCM_SAI = libsaibcm_4.3.0.10-5_amd64.deb -$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.0.10-5_amd64.deb?sv=2019-12-12&st=2021-02-08T00%3A20%3A49Z&se=2030-02-09T00%3A20%3A00Z&sr=b&sp=r&sig=rEpcTHNsSr10rKhpr6Cx3EFNa2dRE7VLP7ybZijQKpE%3D" -BRCM_SAI_DEV = libsaibcm-dev_4.3.0.10-5_amd64.deb +BRCM_SAI = libsaibcm_4.3.0.13_amd64.deb +$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.0.13_amd64.deb?sv=2019-12-12&st=2021-02-11T06%3A07%3A09Z&se=2030-02-12T06%3A07%3A00Z&sr=b&sp=r&sig=IlCyw1BGN0Ei56tPPeXJSucFSFj8SSqUGLB2A%2BRZ1w0%3D" +BRCM_SAI_DEV = libsaibcm-dev_4.3.0.13_amd64.deb $(eval $(call add_derived_package,$(BRCM_SAI),$(BRCM_SAI_DEV))) -$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.0.10-5_amd64.deb?sv=2019-12-12&st=2021-02-08T00%3A21%3A42Z&se=2030-02-09T00%3A21%3A00Z&sr=b&sp=r&sig=gvDnVYkQe%2FA2Yqw9p404Vtmx%2Fo8NwJMFoCn7K4W1k0M%3D" +$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.0.13_amd64.deb?sv=2019-12-12&st=2021-02-11T06%3A08%3A31Z&se=2030-02-12T06%3A08%3A00Z&sr=b&sp=r&sig=G5mYUa8gCnDNpuadvHEuH%2B4q2MuY0JYspPLt2gaC2NY%3D" SONIC_ONLINE_DEBS += $(BRCM_SAI) $(BRCM_SAI_DEV)_DEPENDS += $(BRCM_SAI) From 80b048d4d1a36efa6c698705fa1af8edddc65295 Mon Sep 17 00:00:00 2001 From: Lior Avramov <73036155+liorghub@users.noreply.github.com> Date: Thu, 11 Feb 2021 12:53:36 +0200 Subject: [PATCH 0177/1674] [systemd] Increase syncd startup script timeout to support FW upgrade on init. (#6709) **- Why I did it** To support FW upgrade on init. **- How I did it** Change timeout value **- How to verify it** I manually changed ASIC and Gearbox FW followed by hard reset in order for FW upgrade to take place on init. Signed-off-by: liora --- files/build_templates/per_namespace/syncd.service.j2 | 2 +- files/scripts/syncd.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/files/build_templates/per_namespace/syncd.service.j2 b/files/build_templates/per_namespace/syncd.service.j2 index 0c9bf073e940..8e0029a29421 100644 --- a/files/build_templates/per_namespace/syncd.service.j2 +++ b/files/build_templates/per_namespace/syncd.service.j2 @@ -26,7 +26,7 @@ ExecStartPre=/usr/local/bin/syncd.sh start{% if multi_instance == 'true' %} %i{% ExecStart=/usr/local/bin/syncd.sh wait{% if multi_instance == 'true' %} %i{% endif %} ExecStop=/usr/local/bin/syncd.sh stop{% if multi_instance == 'true' %} %i{% endif %} {% if sonic_asic_platform == 'mellanox' %} -TimeoutStartSec=150 +TimeoutStartSec=480 {% endif %} [Install] diff --git a/files/scripts/syncd.sh b/files/scripts/syncd.sh index 22fa992b8e80..95c3e3841ba8 100755 --- a/files/scripts/syncd.sh +++ b/files/scripts/syncd.sh @@ -21,9 +21,11 @@ function startplatform() { fi fi + debug "Starting Firmware update procedure" /usr/bin/mst start --with_i2cdev /usr/bin/mlnx-fw-upgrade.sh /etc/init.d/sxdkernel start + debug "Firmware update procedure ended" fi if [[ x"$WARM_BOOT" != x"true" ]]; then From 814cf03f988e9fbd4507d9cd72980a2723f6c92e Mon Sep 17 00:00:00 2001 From: Volodymyr Boiko <66446128+vboykox@users.noreply.github.com> Date: Thu, 11 Feb 2021 20:52:37 +0200 Subject: [PATCH 0178/1674] [platform][barefoot] Fix sonic_platform for x86_64-accton_wedge100bf_65x-r0 (#6612) platform modules' deb package rules for x86_64-accton_wedge100bf_65x-r0 was missing the code that installs the sonic_platform wheel package file under device directory on host (which is checked by pmon deamon on start) --- platform/barefoot/sonic-platform-modules-bfn/debian/rules | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platform/barefoot/sonic-platform-modules-bfn/debian/rules b/platform/barefoot/sonic-platform-modules-bfn/debian/rules index 37e264ad7ed8..0ee3dcfaf0e2 100755 --- a/platform/barefoot/sonic-platform-modules-bfn/debian/rules +++ b/platform/barefoot/sonic-platform-modules-bfn/debian/rules @@ -1,5 +1,6 @@ #!/usr/bin/make -f +PLATFORM_NAME := x86_64-accton_wedge100bf_65x-r0 PACKAGE_NAME := sonic-platform-modules-bfn SCRIPT_SRC := $(shell pwd)/scripts CONFIGS_SRC := $(shell pwd)/configs @@ -20,6 +21,8 @@ override_dh_auto_install: cp -r $(SCRIPT_SRC)/* debian/$(PACKAGE_NAME)/usr/local/bin dh_installdirs -p$(PACKAGE_NAME) etc/network/interfaces.d/ cp -r $(CONFIGS_SRC)/network/interfaces.d/* debian/$(PACKAGE_NAME)/etc/network/interfaces.d/ + dh_installdirs -p$(PACKAGE_NAME) usr/share/sonic/device/$(PLATFORM_NAME)/ + cp -r $(WHEEL_BUILD_DIR)/* debian/$(PACKAGE_NAME)/usr/share/sonic/device/$(PLATFORM_NAME)/ override_dh_usrlocal: From fce7f8a24f0299379d6cf372e62596e705ba1988 Mon Sep 17 00:00:00 2001 From: carl-nokia <63672637+carl-nokia@users.noreply.github.com> Date: Thu, 11 Feb 2021 16:17:00 -0500 Subject: [PATCH 0179/1674] [Platform][ixs7215]: Platform API test required files with Updates and Improvements (#6738) - Why I did it Enable platform API tests to run successfully by providing required test infrastructure files along with supporting changes. - How I did it Added platform.json along with supporting changes. - Addition of pcie.yaml supporting pcied - Addition of Real fan drawer support vs Virtual - Removal of python2 wheel with support in place for python3 - supporting changes platform api tests --- .../armhf-nokia_ixs7215_52x-r0/platform.json | 226 ++++++++++++++++++ .../plugins/pcie.yaml | 20 ++ .../7215/scripts/nokia-7215init.sh | 4 + .../7215/sonic_platform/chassis.py | 45 ++-- .../7215/sonic_platform/fan.py | 49 +++- .../7215/sonic_platform/fan_drawer.py | 68 +++++- .../7215/sonic_platform/psu.py | 61 +++-- .../7215/sonic_platform/sfp.py | 127 ++++++---- .../7215/sonic_platform/test/test-chassis.py | 2 - .../7215/sonic_platform/test/test-psu.py | 4 +- .../7215/sonic_platform/test/test-sfp.py | 10 +- .../7215/sonic_platform/test/test-thermal.py | 3 +- .../7215/sonic_platform/thermal.py | 19 +- .../7215/sonic_platform/watchdog.py | 2 +- .../sonic-platform-nokia/debian/rules | 4 +- .../debian/sonic-platform-nokia-7215.install | 1 - 16 files changed, 522 insertions(+), 123 deletions(-) create mode 100644 device/nokia/armhf-nokia_ixs7215_52x-r0/platform.json create mode 100644 device/nokia/armhf-nokia_ixs7215_52x-r0/plugins/pcie.yaml diff --git a/device/nokia/armhf-nokia_ixs7215_52x-r0/platform.json b/device/nokia/armhf-nokia_ixs7215_52x-r0/platform.json new file mode 100644 index 000000000000..d6a28d19b026 --- /dev/null +++ b/device/nokia/armhf-nokia_ixs7215_52x-r0/platform.json @@ -0,0 +1,226 @@ +{ + "chassis": { + "name": "7215 IXS-T1", + "components": [ + { + "name": "System-CPLD" + }, + { + "name": "U-Boot" + } + ], + "fans": [ + { + "name": "Fan1" + }, + { + "name": "Fan2" + } + ], + "fan_drawers": [ + { + "name": "drawer1", + "fans": [ + { + "name": "Fan1" + } + ] + }, + { + "name": "drawer2", + "fans": [ + { + "name": "Fan2" + } + ] + } + ], + "psus": [ + { + "name": "PSU1" + }, + { + "name": "PSU2" + } + ], + "thermals": [ + { + "name": "PCB PHY" + }, + { + "name": "PCB MAC" + }, + { + "name": "ADT7473-CPU" + }, + { + "name": "ADT7473-LOC" + }, + { + "name": "ADT7473-MAC" + }, + { + "name": "CPU Core" + } + ], + "sfps": [ + { + "name": "Ethernet0" + }, + { + "name": "Ethernet1" + }, + { + "name": "Ethernet2" + }, + { + "name": "Ethernet3" + }, + { + "name": "Ethernet4" + }, + { + "name": "Ethernet5" + }, + { + "name": "Ethernet6" + }, + { + "name": "Ethernet7" + }, + { + "name": "Ethernet8" + }, + { + "name": "Ethernet9" + }, + { + "name": "Ethernet10" + }, + { + "name": "Ethernet11" + }, + { + "name": "Ethernet12" + }, + { + "name": "Ethernet13" + }, + { + "name": "Ethernet14" + }, + { + "name": "Ethernet15" + }, + { + "name": "Ethernet16" + }, + { + "name": "Ethernet17" + }, + { + "name": "Ethernet18" + }, + { + "name": "Ethernet19" + }, + { + "name": "Ethernet20" + }, + { + "name": "Ethernet21" + }, + { + "name": "Ethernet22" + }, + { + "name": "Ethernet23" + }, + { + "name": "Ethernet24" + }, + { + "name": "Ethernet25" + }, + { + "name": "Ethernet26" + }, + { + "name": "Ethernet27" + }, + { + "name": "Ethernet28" + }, + { + "name": "Ethernet29" + }, + { + "name": "Ethernet30" + }, + { + "name": "Ethernet31" + }, + { + "name": "Ethernet32" + }, + { + "name": "Ethernet33" + }, + { + "name": "Ethernet34" + }, + { + "name": "Ethernet35" + }, + { + "name": "Ethernet36" + }, + { + "name": "Ethernet37" + }, + { + "name": "Ethernet38" + }, + { + "name": "Ethernet39" + }, + { + "name": "Ethernet40" + }, + { + "name": "Ethernet41" + }, + { + "name": "Ethernet42" + }, + { + "name": "Ethernet43" + }, + { + "name": "Ethernet44" + }, + { + "name": "Ethernet45" + }, + { + "name": "Ethernet46" + }, + { + "name": "Ethernet47" + }, + { + "name": "Ethernet48" + }, + { + "name": "Ethernet49" + }, + { + "name": "Ethernet50" + }, + { + "name": "Ethernet51" + } + ] + }, + "interfaces": {} +} diff --git a/device/nokia/armhf-nokia_ixs7215_52x-r0/plugins/pcie.yaml b/device/nokia/armhf-nokia_ixs7215_52x-r0/plugins/pcie.yaml new file mode 100644 index 000000000000..f24086a2228b --- /dev/null +++ b/device/nokia/armhf-nokia_ixs7215_52x-r0/plugins/pcie.yaml @@ -0,0 +1,20 @@ +- bus: '00' + dev: '01' + fn: '0' + id: '6820' + name: 'PCI bridge: Marvell Technology Group Ltd. Device 6820 (rev 0a)' +- bus: '00' + dev: '02' + fn: '0' + id: '6820' + name: 'PCI bridge: Marvell Technology Group Ltd. Device 6820 (rev 0a)' +- bus: '01' + dev: '00' + fn: '0' + id: c804 + name: 'Ethernet controller: Marvell Technology Group Ltd. Device c804' +- bus: '02' + dev: '00' + fn: '0' + id: c804 + name: 'Ethernet controller: Marvell Technology Group Ltd. Device c804' diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/scripts/nokia-7215init.sh b/platform/marvell-armhf/sonic-platform-nokia/7215/scripts/nokia-7215init.sh index 43cd86d59bd0..4cad43348e06 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/scripts/nokia-7215init.sh +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/scripts/nokia-7215init.sh @@ -51,6 +51,10 @@ chmod 644 /sys/class/i2c-adapter/i2c-0/0-0053/eeprom echo eeprom 0x55 > /sys/class/i2c-adapter/i2c-0/new_device echo eeprom 0x56 > /sys/class/i2c-adapter/i2c-0/new_device +# Enumerate psu eeprom devices +echo eeprom 0x51 > /sys/class/i2c-adapter/i2c-1/new_device +echo eeprom 0x52 > /sys/class/i2c-adapter/i2c-1/new_device + # Enable optical SFP Tx i2cset -y -m 0x0f 0 0x41 0x5 0x00 diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/chassis.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/chassis.py index 7597492cc003..b3ada4c71f9c 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/chassis.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/chassis.py @@ -13,7 +13,7 @@ from sonic_platform.sfp import Sfp from sonic_platform.eeprom import Eeprom from sonic_platform.fan import Fan - from .fan_drawer import VirtualDrawer + from .fan_drawer import RealDrawer from sonic_platform.psu import Psu from sonic_platform.thermal import Thermal from sonic_platform.component import Component @@ -35,8 +35,8 @@ PORT_END = 52 # Device counts -MAX_7215_FAN_DRAWER = 1 -MAX_7215_FAN = 2 +MAX_7215_FAN_DRAWERS = 2 +MAX_7215_FANS_PER_DRAWER = 1 MAX_7215_PSU = 2 MAX_7215_THERMAL = 6 @@ -89,9 +89,9 @@ def __init__(self): self._eeprom = Eeprom() # Construct lists fans, power supplies, thermals & components - drawer_num = MAX_7215_FAN_DRAWER - fan_num_per_drawer = MAX_7215_FAN - drawer_ctor = VirtualDrawer + drawer_num = MAX_7215_FAN_DRAWERS + fan_num_per_drawer = MAX_7215_FANS_PER_DRAWER + drawer_ctor = RealDrawer fan_index = 0 for drawer_index in range(drawer_num): drawer = drawer_ctor(drawer_index) @@ -159,14 +159,6 @@ def get_model(self): """ return self._eeprom.part_number_str() - def get_serial(self): - """ - Retrieves the serial number of the chassis (Service tag) - Returns: - string: Serial number of chassis - """ - return self._eeprom.serial_str() - def get_status(self): """ Retrieves the operational status of the chassis @@ -186,7 +178,7 @@ def get_base_mac(self): """ return self._eeprom.base_mac_addr() - def get_serial_number(self): + def get_serial(self): """ Retrieves the hardware serial number for the chassis @@ -307,7 +299,7 @@ def set_status_led(self, color): # Write sys led if smbus_present == 0: - sonic_logger.log_info("PMON LED SET ERROR-> smbus present = 0") + sonic_logger.log_warning("PMON LED SET -> smbus present = 0") else: bus = smbus.SMBus(0) DEVICE_ADDRESS = 0x41 @@ -328,7 +320,7 @@ def get_status_led(self): """ # Read sys led if smbus_present == 0: - sonic_logger.log_info("PMON LED GET ERROR-> smbus present = 0") + sonic_logger.log_warning("PMON LED GET -> smbus present = 0") return False else: bus = smbus.SMBus(0) @@ -372,6 +364,23 @@ def get_watchdog(self): watchdog_device_path = "/dev/watchdog0" self._watchdog = WatchdogImplBase(watchdog_device_path) except Exception as e: - sonic_logger.log_info("Fail to load watchdog {}".format(repr(e))) + sonic_logger.log_warning(" Fail to load watchdog {}".format(repr(e))) return self._watchdog + + 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 diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan.py index 0b08f3f6b4f2..67610a125fad 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan.py @@ -163,7 +163,24 @@ def get_direction(self): FAN_DIRECTION_EXHAUST depending on fan direction """ - return 'FAN_DIRECTION_INTAKE' + return 'intake' + + 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 + """ + return self.index + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return True + def get_speed(self): """ @@ -176,9 +193,13 @@ def get_speed(self): fan_speed = self._get_i2c_register(self.get_fan_speed_reg) if (fan_speed != 'ERR'): - speed = int(fan_speed) + speed_in_rpm = int(fan_speed) else: - speed = 0 + speed_in_rpm = 0 + + speed = 100*speed_in_rpm//MAX_IXS7215_FAN_SPEED + if speed > 100: + speed = 100 return speed @@ -320,11 +341,21 @@ def get_target_speed(self): (off) to 100 (full speed) """ speed = 0 + + fan_duty = self._get_i2c_register(self.set_fan_speed_reg) + if (fan_duty != 'ERR'): + dutyspeed = int(fan_duty) + if dutyspeed == 0: + speed = 0 + elif dutyspeed == 64: + speed = 25 + elif dutyspeed == 128: + speed = 50 + elif dutyspeed == 255: + speed = 100 + + return speed + - fan_speed = self._get_i2c_register(self.get_fan_speed_reg) - if (fan_speed != 'ERR'): - speed = int(fan_speed) - else: - speed = 0 - return speed + diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan_drawer.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan_drawer.py index ea0bc71bea5c..cabb15d455d6 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan_drawer.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan_drawer.py @@ -8,9 +8,11 @@ try: from sonic_platform_base.fan_drawer_base import FanDrawerBase + from sonic_py_common import logger except ImportError as e: raise ImportError(str(e) + "- required module not found") +sonic_logger = logger.Logger('fan_drawer') class NokiaFanDrawer(FanDrawerBase): def __init__(self, index): @@ -21,10 +23,59 @@ def __init__(self, index): def get_index(self): return self._index - def get_led(self): - return self._led + def get_presence(self): + return self._fan_list[0].get_presence() + def get_model(self): + """ + Retrieves the model number of the Fan Drawer + Returns: + string: Part number of Fan Drawer + """ + return self._fan_list[0].get_model() + def get_serial(self): + """ + Retrieves the serial number of the Fan Drawer + Returns: + string: Serial number of Fan + """ + return self._fan_list[0].get_serial() + + def get_status(self): + """ + Retrieves the operational status of the Fan Drawer + Returns: + bool: True if Fan is operating properly, False if not + """ + return self._fan_list[0].get_status() + + def get_direction(self): + return 'intake' + + def set_status_led(self, color): + return True + + def get_status_led(self, color): + return self._fan_list[0].get_status_led() + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + 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 + """ + return self._index + + # For Nokia platforms with fan drawer(s) class RealDrawer(NokiaFanDrawer): def __init__(self, index): @@ -33,15 +84,8 @@ def __init__(self, index): def get_name(self): return self._name + + + -# For Nokia platforms with no physical fan drawer(s) -class VirtualDrawer(NokiaFanDrawer): - def __init__(self, index): - super(VirtualDrawer, self).__init__(index) - - def get_name(self): - return 'N/A' - - def set_status_led(self, color): - return 'N/A' diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/psu.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/psu.py index 4b8029daaa12..ab53abebf934 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/psu.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/psu.py @@ -9,6 +9,7 @@ try: import sys from sonic_platform_base.psu_base import PsuBase + from sonic_py_common import logger except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -23,6 +24,7 @@ except ImportError as e: smbus_present = 0 +sonic_logger = logger.Logger('psu') class Psu(PsuBase): """Nokia platform-specific PSU class for 7215 """ @@ -76,7 +78,9 @@ def get_model(self): Returns: string: Part number of PSU """ - return self.eeprom.modelstr() + return "N/A" +# return self.eeprom.serial_number_str() + def get_serial(self): """ @@ -85,7 +89,9 @@ def get_serial(self): Returns: string: Serial number of PSU """ - return self.eeprom.serial_number_str() + return "N/A" +# return self.eeprom.serial_number_str() + def get_status(self): """ @@ -98,6 +104,7 @@ def get_status(self): if smbus_present == 0: cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 0 0x41 0xa') psustatus = int(psustatus, 16) + sonic_logger.log_warning("PMON psu-smbus - presence = 0 ") else: bus = smbus.SMBus(0) DEVICE_ADDRESS = 0x41 @@ -146,29 +153,45 @@ def get_voltage(self): psu_voltage = 0.0 return psu_voltage - def get_current(self): - """ - Retrieves present electric current supplied by PSU +# def get_current(self): +# """ +# Retrieves present electric current supplied by PSU +# +# Returns: +# A float number, electric current in amperes, +# e.g. 15.4 +# """ +# psu_current = 0.0 +# +# return psu_current +# +# def get_power(self): +# """ +# Retrieves current energy supplied by PSU +# +# Returns: +# A float number, the power in watts, +# e.g. 302.6 +# """ +# psu_power = 0.0 +# +# return psu_power + def get_position_in_parent(self): + """ + Retrieves 1-based relative physical position in parent device Returns: - A float number, electric current in amperes, - e.g. 15.4 + integer: The 1-based relative physical position in parent device """ - psu_current = 0.0 + return self.index - return psu_current - - def get_power(self): + def is_replaceable(self): """ - Retrieves current energy supplied by PSU - + Indicate whether this device is replaceable. Returns: - A float number, the power in watts, - e.g. 302.6 + bool: True if it is replaceable. """ - psu_power = 0.0 - - return psu_power + return True def get_powergood_status(self): """ @@ -220,6 +243,6 @@ def set_status_led(self, color): bool: True if status LED state is set successfully, False if not """ - # In IXR7220_D1, the firmware running in the PSU controls the LED + # In ISX7215 , the firmware running in the PSU controls the LED # and the PSU LED state cannot be changed from CPU. return False diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp.py index 274db04ded0b..cb9c1b910561 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp.py @@ -276,6 +276,7 @@ def get_transceiver_info(self): 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 ======================================================================== """ @@ -364,7 +365,8 @@ def get_transceiver_info(self): transceiver_info_dict['nominal_bit_rate'] = str( sfp_interface_bulk_data['data']['NominalSignallingRate(UnitsOf100Mbd)']['value']) - + transceiver_info_dict['application_advertisement'] = 'N/A' + return transceiver_info_dict def get_transceiver_bulk_status(self): @@ -557,26 +559,20 @@ def get_rx_los(self): A Boolean, True if SFP has RX LOS, False if not. """ if self.sfp_type == COPPER_TYPE: - return False + return None + if not self.dom_supported: + return None + rx_los_list = [] - if smbus_present == 0: - sonic_logger.log_info(" PMON - smbus ERROR - ") - cmdstatus, rxlosstatus = cmd.getstatusoutput('i2cget -y 0 0x41 0x4') - rxlosstatus = int(rxlosstatus, 16) + offset = 256 + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes((offset + SFP_CHANNL_STATUS_OFFSET), SFP_CHANNL_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 & 0x02 != 0) else: - bus = smbus.SMBus(0) - DEVICE_ADDRESS = 0x41 - DEVICE_REG = 0x4 - rxlosstatus = bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REG) - - pos = [1, 2, 4, 8] - bit_pos = pos[self.index-SFP_PORT_START] - rxlosstatus = rxlosstatus & (bit_pos) - - if rxlosstatus == 0: - return True - - return False + return None + + return rx_los_list def get_tx_fault(self): """ @@ -585,8 +581,21 @@ def get_tx_fault(self): 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 self.sfp_type == COPPER_TYPE: + return None + if not self.dom_supported: + return None + tx_fault_list = [] + + offset = 256 + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes((offset + SFP_CHANNL_STATUS_OFFSET), SFP_CHANNL_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 & 0x04 != 0) + else: + return None + return tx_fault_list - return False def get_tx_disable(self): """ @@ -596,26 +605,20 @@ def get_tx_disable(self): """ if self.sfp_type == COPPER_TYPE: - return False + return None + if not self.dom_supported: + return None - # Enable optical SFP Tx - if smbus_present == 0: - cmdstatus, disstatus = cmd.getstatusoutput('i2cget -y 0 0x41 0x5') - sonic_logger.log_info(" PMON - smbus ERROR tx- DEBUG ") + tx_disable_list = [] + offset = 256 + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes((offset + SFP_CHANNL_STATUS_OFFSET), SFP_CHANNL_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 & 0xC0 != 0) else: - bus = smbus.SMBus(0) - DEVICE_ADDRESS = 0x41 - DEVICE_REG = 0x5 - disstatus = bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REG) - - pos = [1, 2, 4, 8] - bit_pos = pos[self.index-SFP_PORT_START] - disstatus = disstatus & (bit_pos) - - if disstatus == 0: - return True - - return False + return None + + return tx_disable_list def get_tx_disable_channel(self): """ @@ -663,6 +666,9 @@ def get_temperature(self): Returns: An integer number of current temperature in Celsius """ + if self.sfp_type == COPPER_TYPE: + return None + transceiver_bulk_status = self.get_transceiver_bulk_status() return transceiver_bulk_status.get("temperature", "N/A") @@ -672,6 +678,9 @@ def get_voltage(self): Returns: An integer number of supply voltage in mV """ + if self.sfp_type == COPPER_TYPE: + return None + transceiver_bulk_status = self.get_transceiver_bulk_status() return transceiver_bulk_status.get("voltage", "N/A") @@ -679,18 +688,18 @@ 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'] + """ + if self.sfp_type == COPPER_TYPE: + return None + + tx_bias_list = [] transceiver_bulk_status = self.get_transceiver_bulk_status() - tx1_bs = transceiver_bulk_status.get("tx1bias", "N/A") - tx2_bs = transceiver_bulk_status.get("tx2bias", "N/A") - tx3_bs = transceiver_bulk_status.get("tx3bias", "N/A") - tx4_bs = transceiver_bulk_status.get("tx4bias", "N/A") - tx_bias_list = [tx1_bs, tx2_bs, tx3_bs, tx4_bs] + tx_bias_list.append(transceiver_bulk_status.get("tx1bias", "N/A")) + return tx_bias_list + def get_rx_power(self): """ Retrieves the received optical power for this SFP @@ -803,7 +812,7 @@ def tx_disable(self, tx_disable): A boolean, True if tx_disable is set successfully, False if not """ - return False + return NotImplementedError def tx_disable_channel(self, channel, disable): """ @@ -817,7 +826,7 @@ def tx_disable_channel(self, channel, disable): A boolean, True if successful, False if not """ - return False + return NotImplementedError def set_lpmode(self, lpmode): """ @@ -851,7 +860,7 @@ def set_power_override(self, power_override, power_set): False if not """ - return False + return NotImplementedError def get_name(self): """ @@ -917,3 +926,23 @@ def get_status(self): A boolean value, True if device is operating properly, False if not """ return self.get_presence() + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + + if self.sfp_type == "SFP": + return True + else: + return False + + 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 + """ + return self.index diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-chassis.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-chassis.py index ee7c21c4638d..775596159269 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-chassis.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-chassis.py @@ -23,8 +23,6 @@ def main(): print(" Chassis status: {}".format(chassis.get_status())) - print(" Chassis serial_number: {}".format(chassis.get_serial_number())) - print(" Chassis base_mac: {}".format(chassis.get_base_mac())) print(" Chassis reboot cause: {}\n".format(chassis.get_reboot_cause())) diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-psu.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-psu.py index 1a333aeac441..692430ff2991 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-psu.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-psu.py @@ -17,9 +17,7 @@ def main(): psu.get_status_led())) print(" Model: {}, Serial: {}".format(psu.get_model(), psu.get_serial())) - print(" Voltage: {}, Current: {}, Power: {}\n".format(psu.get_voltage(), - psu.get_current(), - psu.get_power())) + print(" Voltage: {}, Current: NO, Power: NO \n".format(psu.get_voltage())) return diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-sfp.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-sfp.py index 01f75562ad3b..f5437b18f82e 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-sfp.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-sfp.py @@ -1,21 +1,25 @@ #!/usr/bin/env python try: - import sonic_platform + from sonic_platform.chassis import Chassis except ImportError as e: raise ImportError(str(e) + "- required module not found") def main(): - PORT_START = 49 + PORT_START = 1 PORT_END = 52 - chassis = sonic_platform.platform.Platform().get_chassis() + chassis = Chassis() for physical_port in range(PORT_START, PORT_END+1): + + print(" ") print(" SFP transceiver tests PORT = ", physical_port) + name = chassis.get_sfp(physical_port).get_name() + print(" SFP transceiver tests NAME = ", name) presence = chassis.get_sfp(physical_port).get_presence() print("TEST 1 - sfp presence [ True ] ", physical_port, presence) diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-thermal.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-thermal.py index e0259347c04e..9e99b0da3f41 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-thermal.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-thermal.py @@ -16,8 +16,7 @@ def main(): thermal.get_status())) print(" Model: {}, Serial: {}".format(thermal.get_model(), thermal.get_serial())) - print(" Temperature: {}C, Low Threshold: {}C, High Threshold: {}C\n".format(thermal.get_temperature(), - thermal.get_low_threshold(), + print(" Temperature: {}C, High Threshold: {}C\n".format(thermal.get_temperature(), thermal.get_high_threshold())) return diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/thermal.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/thermal.py index 2743520de245..528a6e49d924 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/thermal.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/thermal.py @@ -10,9 +10,11 @@ try: import os from sonic_platform_base.thermal_base import ThermalBase + from sonic_py_common import logger except ImportError as e: raise ImportError(str(e) + "- required module not found") +sonic_logger = logger.Logger('thermal') class Thermal(ThermalBase): """Nokia platform-specific Thermal class""" @@ -175,7 +177,6 @@ def get_high_threshold(self): Celsius up to nearest thousandth of one degree Celsius, e.g. 30.125 """ - # Not implemented for this sensor if not self.thermal_high_threshold_file: raise NotImplementedError @@ -224,3 +225,19 @@ def get_high_critical_threshold(self): thermal_high_crit_threshold = 0.0 return float("{:.3f}".format(thermal_high_crit_threshold)) + + 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 + """ + return self.index + + def is_replaceable(self): + """ + Indicate whether this device is replaceable. + Returns: + bool: True if it is replaceable. + """ + return False diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/watchdog.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/watchdog.py index 5d75a223c523..75ec3ab177ae 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/watchdog.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/watchdog.py @@ -15,7 +15,7 @@ """ ioctl constants """ IO_READ = 0x80000000 IO_SIZE_INT = 0x00040000 -IO_TYPE_WATCHDOG = 'W' << 8 +IO_TYPE_WATCHDOG = ord('W') << 8 WDR_INT = IO_READ | IO_SIZE_INT | IO_TYPE_WATCHDOG diff --git a/platform/marvell-armhf/sonic-platform-nokia/debian/rules b/platform/marvell-armhf/sonic-platform-nokia/debian/rules index c1e6c1fbfb2b..b7592c2b51e9 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/debian/rules +++ b/platform/marvell-armhf/sonic-platform-nokia/debian/rules @@ -14,7 +14,7 @@ SERVICE_DIR := service PLATFORM_DIR := sonic_platform %: - dh $@ --with systemd,python2,python3 --buildsystem=pybuild + dh $@ --with systemd,python3 --buildsystem=pybuild clean: dh_testdir @@ -23,7 +23,6 @@ clean: build: (for mod in $(MODULE_DIRS); do \ - python2 $${mod}/setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}; \ python3 $${mod}/setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}; \ done) @@ -42,7 +41,6 @@ binary-indep: dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} /usr/local/bin; \ cp $(MOD_SRC_DIR)/$${mod}/$(SERVICE_DIR)/*.service debian/$(PACKAGE_PRE_NAME)-$${mod}/lib/systemd/system/; \ cp $(MOD_SRC_DIR)/$${mod}/$(UTILS_DIR)/* debian/$(PACKAGE_PRE_NAME)-$${mod}/usr/local/bin/; \ - python2 $${mod}/setup.py install --root=$(MOD_SRC_DIR)/debian/$(PACKAGE_PRE_NAME)-$${mod} --install-layout=deb; \ python3 $${mod}/setup.py install --root=$(MOD_SRC_DIR)/debian/$(PACKAGE_PRE_NAME)-$${mod} --install-layout=deb; \ done) diff --git a/platform/marvell-armhf/sonic-platform-nokia/debian/sonic-platform-nokia-7215.install b/platform/marvell-armhf/sonic-platform-nokia/debian/sonic-platform-nokia-7215.install index dc4df5540d96..ea347d79be3a 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/debian/sonic-platform-nokia-7215.install +++ b/platform/marvell-armhf/sonic-platform-nokia/debian/sonic-platform-nokia-7215.install @@ -1,7 +1,6 @@ nokia-7215_plt_setup.sh usr/sbin 7215/scripts/nokia-7215init.sh usr/local/bin 7215/service/nokia-7215init.service etc/systemd/system -7215/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/armhf-nokia_ixs7215_52x-r0 7215/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/armhf-nokia_ixs7215_52x-r0 entropy.py etc/ inband_mgmt.sh etc/ From 02b5fd841d0104aff6c61b145284c17c47433da3 Mon Sep 17 00:00:00 2001 From: Aravind Mani <53524901+aravindmani-1@users.noreply.github.com> Date: Fri, 12 Feb 2021 02:49:11 +0530 Subject: [PATCH 0180/1674] DellEMC: Z9332f enable mem cache flag (#6771) SER test script is failing as mem_cache flag is disabled. --- .../DellEMC-Z9332f-C32/th3-z9332f-32x100G.config.bcm | 2 +- .../DellEMC-Z9332f-M-O16C64/th3-z9332f-32x400G.config.bcm | 2 +- .../DellEMC-Z9332f-O32/th3-z9332f-32x400G.config.bcm | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-C32/th3-z9332f-32x100G.config.bcm b/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-C32/th3-z9332f-32x100G.config.bcm index 00e6887b4b49..67a24de577d4 100644 --- a/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-C32/th3-z9332f-32x100G.config.bcm +++ b/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-C32/th3-z9332f-32x100G.config.bcm @@ -8,7 +8,7 @@ load_firmware=0x2 ccm_dma_enable=0 ccmdma_intr_enable=0 -mem_cache_enable=0 +mem_cache_enable=1 phy_enable=0 phy_null=1 diff --git a/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-M-O16C64/th3-z9332f-32x400G.config.bcm b/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-M-O16C64/th3-z9332f-32x400G.config.bcm index 38296d61c1b7..fc6613601f52 100644 --- a/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-M-O16C64/th3-z9332f-32x400G.config.bcm +++ b/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-M-O16C64/th3-z9332f-32x400G.config.bcm @@ -8,7 +8,7 @@ load_firmware=0x2 ccm_dma_enable=0 ccmdma_intr_enable=0 -mem_cache_enable=0 +mem_cache_enable=1 phy_enable=0 phy_null=1 diff --git a/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-O32/th3-z9332f-32x400G.config.bcm b/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-O32/th3-z9332f-32x400G.config.bcm index 38296d61c1b7..fc6613601f52 100644 --- a/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-O32/th3-z9332f-32x400G.config.bcm +++ b/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-O32/th3-z9332f-32x400G.config.bcm @@ -8,7 +8,7 @@ load_firmware=0x2 ccm_dma_enable=0 ccmdma_intr_enable=0 -mem_cache_enable=0 +mem_cache_enable=1 phy_enable=0 phy_null=1 From 5aadc7ff55d577460fcc21b57f7184feba027b9f Mon Sep 17 00:00:00 2001 From: Volodymyr Boiko <66446128+vboykox@users.noreply.github.com> Date: Fri, 12 Feb 2021 01:00:35 +0200 Subject: [PATCH 0181/1674] [barefoot][sonic-platform] Fix get_system_eeprom_info and refactor eeprom.py (#6739) Signed-off-by: Volodymyr Boyko --- .../sonic_platform/chassis.py | 3 +- .../sonic_platform/eeprom.py | 112 +++++++++--------- 2 files changed, 57 insertions(+), 58 deletions(-) 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 7a8ed2ca9449..fad16cbdb8a2 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,6 +1,7 @@ #!/usr/bin/env python try: + import sys from sonic_platform_base.chassis_base import ChassisBase from sonic_platform.sfp import Sfp from sonic_platform.psu import Psu @@ -55,7 +56,7 @@ def get_serial(self): Returns: string: Serial number of chassis """ - return self._eeprom.serial_str() + return self._eeprom.serial_number_str() def get_sfp(self, index): """ 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 a98a6bc1d45a..587f57826fb5 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 @@ -6,6 +6,7 @@ import logging import logging.config import yaml + import re sys.path.append(os.path.dirname(__file__)) @@ -14,15 +15,15 @@ else: from cStringIO import StringIO - from sonic_eeprom import eeprom_base - from sonic_eeprom import eeprom_tlvinfo + from sonic_platform_base.sonic_eeprom import eeprom_base + from sonic_platform_base.sonic_eeprom import eeprom_tlvinfo from platform_thrift_client import thrift_try except ImportError as e: raise ImportError (str(e) + "- required module not found") -eeprom_default_dict = { +_platform_eeprom_map = { "prod_name" : ("Product Name", "0x21", 12), "odm_pcba_part_num" : ("Part Number", "0x22", 13), "prod_ser_num" : ("Serial Number", "0x23", 12), @@ -33,36 +34,13 @@ "sys_mfger" : ("Manufacturer", "0x2B", 8) } -eeprom_dict = { "version" : ("Version", None, 0), - "pcb_mfger" : ("PCB Manufacturer", "0x01", 8), - "prod_ser_num" : ("Serial Number", "0x23", 12), - "bfn_pcba_part_num" : ("Switch PCBA Part Number", "0x02", 12), - "odm_pcba_part_num" : ("Part Number", "0x22", 13), - "bfn_pcbb_part_num" : ("Switch PCBB Part Number", "0x04", 12), - "sys_asm_part_num" : ("System Assembly Part Number", "0x05", 12), - "prod_state" : ("Product Production State", "0x06", 1), - "location" : ("EEPROM Location of Fabric", "0x07", 8), - "ext_mac_addr_size" : ("Extende MAC Address Size", "0x08", 2), - "sys_mfg_date" : ("System Manufacturing Date", "0x25", 4), - "prod_name" : ("Product Name", "0x21", 12), - "prod_ver" : ("Product Version", "0x26", 1), - "prod_part_num" : ("Product Part Number", "0x09", 8), - "sys_mfger" : ("Manufacturer", "0x2B", 8), - "assembled_at" : ("Assembled at", "0x08", 8), - "prod_ast_tag" : ("Product Asset Tag", "0x09", 12), - "loc_mac_addr" : ("Local MAC address", "0x0A", 12), - "odm_pcba_ser_num" : ("ODM PBCA Serial Number", "0x0B", 12), - "ext_mac_addr" : ("Extended MAC Address Base", "0x0C", 12), - "prod_sub_ver" : ("Product Sub Version", "0x0D", 1) - } - -product_dict = { "Montara" : "Wedge100BF-32X-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" +_EEPROM_SYMLINK = "/var/run/platform/eeprom/syseeprom" +_EEPROM_STATUS = "/var/run/platform/eeprom/status" try: _str_type = basestring @@ -71,46 +49,43 @@ class Eeprom(eeprom_tlvinfo.TlvInfoDecoder): def __init__(self): - with open(os.path.dirname(__file__) + "/logging.conf", 'r') as f: config_dict = yaml.load(f, yaml.SafeLoader) logging.config.dictConfig(config_dict) - if not os.path.exists(os.path.dirname(EEPROM_SYMLINK)): + if not os.path.exists(os.path.dirname(_EEPROM_SYMLINK)): try: - os.makedirs(os.path.dirname(EEPROM_SYMLINK)) + os.makedirs(os.path.dirname(_EEPROM_SYMLINK)) except OSError as e: if e.errno != errno.EEXIST: raise - open(EEPROM_SYMLINK, 'a').close() - f = open(EEPROM_STATUS, 'w') - f.write("initializing..") - f.close() + open(_EEPROM_SYMLINK, 'a').close() + with open(_EEPROM_STATUS, 'w') as f: + f.write("initializing..") - self.eeprom_path = EEPROM_SYMLINK - super(Eeprom, self).__init__(self.eeprom_path, 0, EEPROM_STATUS, True) + self.eeprom_path = _EEPROM_SYMLINK + super(Eeprom, self).__init__(self.eeprom_path, 0, _EEPROM_STATUS, True) def sys_eeprom_get(client): return client.pltfm_mgr.pltfm_mgr_sys_eeprom_get() try: - self.eeprom = thrift_try(sys_eeprom_get) + platform_eeprom = thrift_try(sys_eeprom_get) except Exception: raise RuntimeError("eeprom.py: Initialization failed") - self.eeprom_parse() + self.__eeprom_init(platform_eeprom) - def eeprom_parse(self): - f = open(EEPROM_STATUS, 'w') - f.write("ok") - f.close() + def __eeprom_init(self, platform_eeprom): + with open(_EEPROM_STATUS, 'w') as f: + f.write("ok") eeprom_params = "" - for attr, val in self.eeprom.__dict__.items(): + for attr, val in platform_eeprom.__dict__.items(): if val is None: continue - elem = eeprom_default_dict.get(attr) + elem = _platform_eeprom_map.get(attr) if elem is None: continue @@ -122,7 +97,7 @@ def eeprom_parse(self): if attr == "sys_mfg_date": value = datetime.datetime.strptime(value, '%m-%d-%y').strftime('%m/%d/%Y 00:00:00') - product = product_dict.get(value) + product = _product_dict.get(value) if product is not None: value = product if len(eeprom_params) > 0: @@ -130,28 +105,51 @@ def eeprom_parse(self): eeprom_params += "{0:s}={1:s}".format(elem[1], value) orig_stdout = sys.stdout - sys.stdout = StringIO() try: - new_e = eeprom_tlvinfo.TlvInfoDecoder.set_eeprom(self, "", [eeprom_params]) + eeprom_data = eeprom_tlvinfo.TlvInfoDecoder.set_eeprom(self, "", [eeprom_params]) finally: + decode_output = sys.stdout.getvalue() sys.stdout = orig_stdout - eeprom_base.EepromDecoder.write_eeprom(self, new_e) + eeprom_base.EepromDecoder.write_eeprom(self, eeprom_data) + self.__eeprom_tlv_dict = self.__parse_output(decode_output) - return True + def __parse_output(self, decode_output): + EEPROM_DECODE_HEADLINES = 6 + lines = decode_output.replace('\0', '').split('\n') + lines = lines[EEPROM_DECODE_HEADLINES:] + res = dict() - def serial_str(self): - return self.eeprom.prod_ser_num + for line in lines: + try: + # match whitespace-separated tag hex, length and value (value is mathced with its whitespaces) + match = re.search('(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)([\S]+[\s]*[\S]*)', line) + if match is not None: + code = match.group(1) + value = match.group(3).rstrip('\0') + res[code] = value + except Exception: + pass + return res + + def __tlv_get(self, code): + return self.__eeprom_tlv_dict.get("0x{:X}".format(code), 'N/A') def system_eeprom_info(self): - return self.eeprom.__dict__ + return self.__eeprom_tlv_dict + + def serial_number_str(self): + return self.__tlv_get(self._TLV_CODE_SERIAL_NUMBER) + + def serial_str(self): + return self.serial_number_str() def base_mac_addr(self): - return self.eeprom.ext_mac_addr.rstrip('\x00') + return self.__tlv_get(self._TLV_CODE_MAC_BASE) def part_number_str(self): - return self.eeprom.prod_part_num + return self.__tlv_get(self._TLV_CODE_PART_NUMBER) def modelstr(self): - return self.eeprom.prod_name + return self.__tlv_get(self._TLV_CODE_PRODUCT_NAME) From bcc4a52f56e9daf2bbd44bb1b230acc3c4ec0399 Mon Sep 17 00:00:00 2001 From: Volodymyr Boiko <66446128+vboykox@users.noreply.github.com> Date: Fri, 12 Feb 2021 03:53:15 +0200 Subject: [PATCH 0182/1674] [barefoot][sonic-platform] Refactor sfp.py (#6770) Use separate file for each sfp eeprom operation Signed-off-by: Volodymyr Boyko --- .../sonic_platform/sfp.py | 55 ++++++++++--------- 1 file changed, 30 insertions(+), 25 deletions(-) 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 cb8931998e39..63c36d9a533a 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 @@ -4,7 +4,10 @@ import os import sys import time - import errno + + import tempfile + from contextlib import contextmanager + from copy import copy sys.path.append(os.path.dirname(__file__)) @@ -16,8 +19,6 @@ except ImportError as e: raise ImportError (str(e) + "- required module not found") -SFP_EEPROM_CACHE = "/var/run/platform/sfp/cache" - class SfpUtil(SfpUtilBase): """Platform-specific SfpUtil class""" @@ -55,15 +56,6 @@ def __init__(self): self.phy_port_cur_state = {} self.qsfp_interval = self.QSFP_CHECK_INTERVAL - if not os.path.exists(os.path.dirname(SFP_EEPROM_CACHE)): - try: - os.makedirs(os.path.dirname(SFP_EEPROM_CACHE)) - except OSError as e: - if e.errno != errno.EEXIST: - raise - - open(SFP_EEPROM_CACHE, 'ab').close() - SfpUtilBase.__init__(self) def update_port_info(self): @@ -200,21 +192,28 @@ def get_transceiver_change_event(self, timeout=0): return self.ready, self.phy_port_dict - def _get_port_eeprom_path(self, port_num, devid): - eeprom_path = None + @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 qsfp_info_get(client): return client.pltfm_mgr.pltfm_mgr_qsfp_info_get(port_num) if self.get_presence(port_num): eeprom_hex = thrift_try(qsfp_info_get) - eeprom_cache = open(SFP_EEPROM_CACHE, 'wb') eeprom_raw = bytearray.fromhex(eeprom_hex) - eeprom_cache.write(eeprom_raw) - eeprom_cache.close() - eeprom_path = SFP_EEPROM_CACHE + with open(self.eeprom_path, 'wb') as eeprom_cache: + eeprom_cache.write(eeprom_raw) + return self.eeprom_path - return eeprom_path + return None class Sfp(SfpBase): """Platform-specific Sfp class""" @@ -242,25 +241,31 @@ def __init__(self, port_num): SfpBase.__init__(self) def get_presence(self): - return Sfp.sfputil.get_presence(self.port_num) + with Sfp.sfputil.eeprom_action() as u: + return u.get_presence(self.port_num) def get_lpmode(self): - return Sfp.sfputil.get_low_power_mode(self.port_num) + with Sfp.sfputil.eeprom_action() as u: + return u.get_low_power_mode(self.port_num) def set_lpmode(self, lpmode): - return Sfp.sfputil.set_low_power_mode(self.port_num, lpmode) + with Sfp.sfputil.eeprom_action() as u: + return u.set_low_power_mode(self.port_num, lpmode) def reset(self): return Sfp.sfputil.reset(self.port_num) def get_transceiver_info(self): - return Sfp.sfputil.get_transceiver_info_dict(self.port_num) + with Sfp.sfputil.eeprom_action() as u: + return u.get_transceiver_info_dict(self.port_num) def get_transceiver_bulk_status(self): - return Sfp.sfputil.get_transceiver_dom_info_dict(self.port_num) + with Sfp.sfputil.eeprom_action() as u: + return u.get_transceiver_dom_info_dict(self.port_num) def get_transceiver_threshold_info(self): - return Sfp.sfputil.get_transceiver_dom_threshold_info_dict(self.port_num) + with Sfp.sfputil.eeprom_action() as u: + return u.get_transceiver_dom_threshold_info_dict(self.port_num) def get_change_event(self, timeout=0): return Sfp.get_transceiver_change_event(timeout) From 8b3813b63710a057910bcf2a78ace5a1653480f0 Mon Sep 17 00:00:00 2001 From: Volodymyr Boiko <66446128+vboykox@users.noreply.github.com> Date: Fri, 12 Feb 2021 04:13:53 +0200 Subject: [PATCH 0183/1674] [barefoot][sonic-platform] Fix sfp reset (#6746) Fix wrong sfp reset return value Signed-off-by: Volodymyr Boyko --- .../sonic-platform-modules-bfn-montara/sonic_platform/sfp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 63c36d9a533a..739a48a8f1eb 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 @@ -118,9 +118,9 @@ 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) - status = thrift_try(qsfp_reset) + err = thrift_try(qsfp_reset) - return status + return not err def check_transceiver_change(self): if not self.ready: From 5961e3206ef579f3a7f6a8489827ea23a0d067ed Mon Sep 17 00:00:00 2001 From: Arun Saravanan Balachandran <52521751+ArunSaravananBalachandran@users.noreply.github.com> Date: Fri, 12 Feb 2021 02:14:47 +0000 Subject: [PATCH 0184/1674] DellEMC: Add platform.json for S6000, S6100 (#6735) Add platform.json used for sonic-mgmt testing in DellEMC S6000, S6100 platforms. --- .../x86_64-dell_s6000_s1220-r0/platform.json | 228 ++++++++++++ .../x86_64-dell_s6100_c2538-r0/platform.json | 343 ++++++++++++++++++ 2 files changed, 571 insertions(+) create mode 100644 device/dell/x86_64-dell_s6000_s1220-r0/platform.json create mode 100644 device/dell/x86_64-dell_s6100_c2538-r0/platform.json diff --git a/device/dell/x86_64-dell_s6000_s1220-r0/platform.json b/device/dell/x86_64-dell_s6000_s1220-r0/platform.json new file mode 100644 index 000000000000..62a53fe328fc --- /dev/null +++ b/device/dell/x86_64-dell_s6000_s1220-r0/platform.json @@ -0,0 +1,228 @@ +{ + "chassis": { + "name": "S6000", + "components": [ + { + "name": "BIOS" + }, + { + "name": "System-CPLD" + }, + { + "name": "Master-CPLD" + }, + { + "name": "Slave-CPLD" + } + ], + "fans": [ + { + "name": "FanTray1-Fan1" + }, + { + "name": "FanTray1-Fan2" + }, + { + "name": "FanTray2-Fan1" + }, + { + "name": "FanTray2-Fan2" + }, + { + "name": "FanTray3-Fan1" + }, + { + "name": "FanTray3-Fan2" + } + ], + "fan_drawers":[ + { + "name": "FanTray1", + "fans": [ + { + "name": "FanTray1-Fan1" + }, + { + "name": "FanTray1-Fan2" + } + ] + }, + { + "name": "FanTray2", + "fans": [ + { + "name": "FanTray2-Fan1" + }, + { + "name": "FanTray2-Fan2" + } + ] + }, + { + "name": "FanTray3", + "fans": [ + { + "name": "FanTray3-Fan1" + }, + { + "name": "FanTray3-Fan2" + } + ] + } + ], + "psus": [ + { + "name": "PSU1", + "fans": [ + { + "name": "PSU1 Fan" + } + ], + "thermals": [ + { + "name": "PSU1-Sensor 1" + }, + { + "name": "PSU1-Sensor 2" + } + ] + }, + { + "name": "PSU2", + "fans": [ + { + "name": "PSU2 Fan" + } + ], + "thermals": [ + { + "name": "PSU2-Sensor 1" + }, + { + "name": "PSU2-Sensor 2" + } + ] + } + ], + "thermals": [ + { + "name": "ASIC On-board" + }, + { + "name": "NIC" + }, + { + "name": "System Front" + }, + { + "name": "DIMM" + }, + { + "name": "CPU Core 0" + }, + { + "name": "CPU Core 1" + } + ], + "modules": [], + "sfps": [ + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + } + ] + }, + "interfaces": {} +} diff --git a/device/dell/x86_64-dell_s6100_c2538-r0/platform.json b/device/dell/x86_64-dell_s6100_c2538-r0/platform.json new file mode 100644 index 000000000000..24e32b16bb15 --- /dev/null +++ b/device/dell/x86_64-dell_s6100_c2538-r0/platform.json @@ -0,0 +1,343 @@ +{ + "chassis": { + "name": "S6100-ON", + "components": [ + { + "name": "BIOS" + }, + { + "name": "CPLD" + }, + { + "name": "FPGA" + } + ], + "fans": [ + { + "name": "FanTray1-Fan1" + }, + { + "name": "FanTray2-Fan1" + }, + { + "name": "FanTray3-Fan1" + }, + { + "name": "FanTray4-Fan1" + } + ], + "fan_drawers":[ + { + "name": "FanTray1", + "fans": [ + { + "name": "FanTray1-Fan1" + } + ] + }, + { + "name": "FanTray2", + "fans": [ + { + "name": "FanTray2-Fan1" + } + ] + }, + { + "name": "FanTray3", + "fans": [ + { + "name": "FanTray3-Fan1" + } + ] + }, + { + "name": "FanTray4", + "fans": [ + { + "name": "FanTray4-Fan1" + } + ] + } + ], + "psus": [ + { + "name": "PSU1", + "fans": [ + { + "name": "PSU1 Fan" + } + ] + }, + { + "name": "PSU2", + "fans": [ + { + "name": "PSU2 Fan" + } + ] + } + ], + "thermals": [ + { + "name": "CPU On-board" + }, + { + "name": "ASIC On-board Front" + }, + { + "name": "System Front" + }, + { + "name": "ASIC On-board Rear" + }, + { + "name": "Front GE board" + }, + { + "name": "Front SFP+ board" + }, + { + "name": "CPU Core 0" + }, + { + "name": "CPU Core 1" + }, + { + "name": "CPU Core 2" + }, + { + "name": "CPU Core 3" + } + ], + "modules": [ + { + "name": "IOM1: 16x40G QSFP+ Module", + "components": [ + { + "name": "IOM1-CPLD" + } + ] + }, + { + "name": "IOM2: 16x40G QSFP+ Module", + "components": [ + { + "name": "IOM2-CPLD" + } + ] + }, + { + "name": "IOM3: 16x40G QSFP+ Module", + "components": [ + { + "name": "IOM3-CPLD" + } + ] + }, + { + "name": "IOM4: 16x40G QSFP+ Module", + "components": [ + { + "name": "IOM4-CPLD" + } + ] + } + ], + "sfps": [ + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + }, + { + "name": "QSFP+ or later" + } + ] + }, + "interfaces": {} +} From 5640958322d53028bbef53532826814db383085f Mon Sep 17 00:00:00 2001 From: gechiang <62408185+gechiang@users.noreply.github.com> Date: Fri, 12 Feb 2021 03:00:16 -0800 Subject: [PATCH 0185/1674] [broadcom]: BRCM SAI 4.3.0.13-1 Pick up BRCM Patch to fix bogus interface counters (#6775) This PR is needed to fix the show interface counters output issue where the counters are not correct due to an issue introduced in BRCM SAI 4.3. - How to verify it Without the fix if one injects packets, the expected counters for the interfaces involved do not show correct count values. The RX count looks to be TX count while TX count looks to be RX count but even that the values could not be trusted. After the fix the counters started to look correct. Here is one sample output taken after the fix is applied where I manually injected 10,000 packets into Ethernet92 to be routed out of the port channel member port Ethernet40. Also injected 10,000 invalid packets into the same Ethernet92 and all 10,000 packets were shown RX_DRP correctly. --- platform/broadcom/sai.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index fa27c92236ed..046aca2af658 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,8 +1,8 @@ -BRCM_SAI = libsaibcm_4.3.0.13_amd64.deb -$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.0.13_amd64.deb?sv=2019-12-12&st=2021-02-11T06%3A07%3A09Z&se=2030-02-12T06%3A07%3A00Z&sr=b&sp=r&sig=IlCyw1BGN0Ei56tPPeXJSucFSFj8SSqUGLB2A%2BRZ1w0%3D" -BRCM_SAI_DEV = libsaibcm-dev_4.3.0.13_amd64.deb +BRCM_SAI = libsaibcm_4.3.0.13-1_amd64.deb +$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.0.13-1_amd64.deb?sv=2015-04-05&sr=b&sig=e%2BBucofzEwCC%2BclqK1OeCi5YFpQAD4ID4FfODzszsuM%3D&se=2034-10-22T06%3A00%3A14Z&sp=r" +BRCM_SAI_DEV = libsaibcm-dev_4.3.0.13-1_amd64.deb $(eval $(call add_derived_package,$(BRCM_SAI),$(BRCM_SAI_DEV))) -$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.0.13_amd64.deb?sv=2019-12-12&st=2021-02-11T06%3A08%3A31Z&se=2030-02-12T06%3A08%3A00Z&sr=b&sp=r&sig=G5mYUa8gCnDNpuadvHEuH%2B4q2MuY0JYspPLt2gaC2NY%3D" +$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.0.13-1_amd64.deb?sv=2015-04-05&sr=b&sig=twfshldM6GQEphfU%2BQ4xmJlGJkv2Sy7KU1F72RYYM0A%3D&se=2034-10-22T06%3A00%3A45Z&sp=r" SONIC_ONLINE_DEBS += $(BRCM_SAI) $(BRCM_SAI_DEV)_DEPENDS += $(BRCM_SAI) From cdef77f4c5b4adbbc1f71a1fa819f5957febcc3c Mon Sep 17 00:00:00 2001 From: yozhao101 <56170650+yozhao101@users.noreply.github.com> Date: Fri, 12 Feb 2021 10:59:29 -0800 Subject: [PATCH 0186/1674] [SwSS] Disabled the autorestart of process `coppmgrd`. (#6774) coppmgrd process do not need to be auto-restarted if it exited unexpectedly. Signed-off-by: Yong Zhao --- dockers/docker-orchagent/supervisord.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockers/docker-orchagent/supervisord.conf b/dockers/docker-orchagent/supervisord.conf index 538f251c2621..af68c8c38ab7 100644 --- a/dockers/docker-orchagent/supervisord.conf +++ b/dockers/docker-orchagent/supervisord.conf @@ -87,7 +87,7 @@ dependent_startup_wait_for=swssconfig:exited command=/usr/bin/coppmgrd priority=6 autostart=false -autorestart=unexpected +autorestart=false startretries=0 startsecs=0 stdout_logfile=syslog From 27ca6040f111cac8066a484496d0fef5fd6d63e5 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Sun, 14 Feb 2021 10:40:24 -0800 Subject: [PATCH 0187/1674] [platform] Update path to udevprefix.conf file (#6779) Azure/sonic-utilities#1431 changes the path to the udevprefix.conf file. The file previously inappropriately resided in the /plugins/ directory. That directory is reserved for now-deprecated Python platform plugins, and will be removed in the near future. --- .../haliburton/script/udev_prefix.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-cel/haliburton/script/udev_prefix.sh b/platform/broadcom/sonic-platform-modules-cel/haliburton/script/udev_prefix.sh index 20fa0a278808..c5842fab0a7e 100644 --- a/platform/broadcom/sonic-platform-modules-cel/haliburton/script/udev_prefix.sh +++ b/platform/broadcom/sonic-platform-modules-cel/haliburton/script/udev_prefix.sh @@ -3,21 +3,21 @@ PREV_REBOOT_CAUSE="/host/reboot-cause/" DEVICE="/usr/share/sonic/device" PLATFORM=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) -FILES=$DEVICE/$PLATFORM/plugins +PLATFORM_PATH=$DEVICE/$PLATFORM FILENAME="udevprefix.conf" if [ "$1" = "clear" ] then - if [ -e $FILES/$FILENAME ]; then - rm $FILES/$FILENAME + if [ -e $PLATFORM_PATH/$FILENAME ]; then + rm $PLATFORM_PATH/$FILENAME fi else - if [ -e $FILES/$FILENAME ]; then - : > $FILES/$FILENAME - echo -n "$1" > $FILES/$FILENAME + if [ -e $PLATFORM_PATH/$FILENAME ]; then + : > $PLATFORM_PATH/$FILENAME + echo -n "$1" > $PLATFORM_PATH/$FILENAME else - touch $FILES/$FILENMAE - echo -n "$1" > $FILES/$FILENAME + touch $PLATFORM_PATH/$FILENMAE + echo -n "$1" > $PLATFORM_PATH/$FILENAME fi fi From e0efbc1e141191e4f532464a1783c90309a0b51c Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Sun, 14 Feb 2021 12:43:49 -0800 Subject: [PATCH 0188/1674] [swss]: Clear MUX-related state DB tables on start (#6759) * Add *MUX_CABLE_TABLE* to set of tables to clear on SWSS start, which will clear HW_MUX_CABLE_TABLE and MUX_CABLE_TABLE * Order swss to start before pmon to ensure that DBs are cleared before xcvrd (running inside pmon) starts and re-populates the tables Signed-off-by: Lawrence Lee --- files/build_templates/per_namespace/swss.service.j2 | 2 +- files/scripts/swss.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/files/build_templates/per_namespace/swss.service.j2 b/files/build_templates/per_namespace/swss.service.j2 index 352d1593a60b..8ac19037ffe7 100644 --- a/files/build_templates/per_namespace/swss.service.j2 +++ b/files/build_templates/per_namespace/swss.service.j2 @@ -12,7 +12,7 @@ Requires=opennsl-modules.service Requires=updategraph.service After=updategraph.service After=interfaces-config.service -Before=ntp-config.service +Before=ntp-config.service pmon.service StartLimitIntervalSec=1200 StartLimitBurst=3 diff --git a/files/scripts/swss.sh b/files/scripts/swss.sh index 1c54aefb0c0b..bde64fb53cb6 100755 --- a/files/scripts/swss.sh +++ b/files/scripts/swss.sh @@ -147,7 +147,7 @@ start() { $SONIC_DB_CLI ASIC_DB FLUSHDB $SONIC_DB_CLI COUNTERS_DB FLUSHDB $SONIC_DB_CLI FLEX_COUNTER_DB FLUSHDB - clean_up_tables STATE_DB "'PORT_TABLE*', 'MGMT_PORT_TABLE*', 'VLAN_TABLE*', 'VLAN_MEMBER_TABLE*', 'LAG_TABLE*', 'LAG_MEMBER_TABLE*', 'INTERFACE_TABLE*', 'MIRROR_SESSION*', 'VRF_TABLE*', 'FDB_TABLE*', 'FG_ROUTE_TABLE*', 'BUFFER_POOL*', 'BUFFER_PROFILE*'" + clean_up_tables STATE_DB "'PORT_TABLE*', 'MGMT_PORT_TABLE*', 'VLAN_TABLE*', 'VLAN_MEMBER_TABLE*', 'LAG_TABLE*', 'LAG_MEMBER_TABLE*', 'INTERFACE_TABLE*', 'MIRROR_SESSION*', 'VRF_TABLE*', 'FDB_TABLE*', 'FG_ROUTE_TABLE*', 'BUFFER_POOL*', 'BUFFER_PROFILE*', '*MUX_CABLE_TABLE*'" fi # start service docker From 6361d36fb2477299c8e268b4bdb64e57d661d8bd Mon Sep 17 00:00:00 2001 From: shlomibitton <60430976+shlomibitton@users.noreply.github.com> Date: Mon, 15 Feb 2021 16:05:34 +0200 Subject: [PATCH 0189/1674] Stop teamd service before syncd (#6755) - What I did All SWSS dependent services should stop before SWSS service to avoid future possible issues. For example 'teamd' service will stop before to allow the driver unload netdev gracefully. This is to stop all LAG's before restarting syncd service when running 'config reload' command. - How I did it Change the order of dependent services of SWSS. - How to verify it Run 'config reload' command. Previously the operation failed when a large number of PortChannel configured on the system. Signed-off-by: Shlomi Bitton --- files/scripts/swss.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/files/scripts/swss.sh b/files/scripts/swss.sh index bde64fb53cb6..97e50cb975e7 100755 --- a/files/scripts/swss.sh +++ b/files/scripts/swss.sh @@ -110,14 +110,6 @@ start_peer_and_dependent_services() { stop_peer_and_dependent_services() { # if warm/fast start enabled or peer lock exists, don't stop peer service docker if [[ x"$WARM_BOOT" != x"true" ]] && [[ x"$FAST_BOOT" != x"true" ]]; then - if [[ ! -z $DEV ]]; then - /bin/systemctl stop ${PEER}@$DEV - else - /bin/systemctl stop ${PEER} - fi - for dep in ${DEPENDENT}; do - /bin/systemctl stop ${dep} - done for dep in ${MULTI_INST_DEPENDENT}; do if [[ ! -z $DEV ]]; then /bin/systemctl stop ${dep}@$DEV @@ -125,7 +117,14 @@ stop_peer_and_dependent_services() { /bin/systemctl stop ${dep} fi done - + for dep in ${DEPENDENT}; do + /bin/systemctl stop ${dep} + done + if [[ ! -z $DEV ]]; then + /bin/systemctl stop ${PEER}@$DEV + else + /bin/systemctl stop ${PEER} + fi fi } From a5085607b4c60243d7786bfbe783228ef586c58b Mon Sep 17 00:00:00 2001 From: lguohan Date: Sun, 7 Feb 2021 19:51:22 -0800 Subject: [PATCH 0190/1674] [syncd-vs]: remove hardcode version for iproute2 and libcap2-bin (#6713) Fix #6711 the requirement was introduced in commit 75104bb35d86e3ec5565abe1cb49809e7790a155 to support sflow in stretch build. in buster build, the requirement is met, no need to pin down the version. Signed-off-by: Guohan Lu --- platform/vs/docker-gbsyncd-vs/Dockerfile.j2 | 2 +- platform/vs/docker-syncd-vs/Dockerfile.j2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/vs/docker-gbsyncd-vs/Dockerfile.j2 b/platform/vs/docker-gbsyncd-vs/Dockerfile.j2 index d740dca663cb..ae7e1c99b7c0 100644 --- a/platform/vs/docker-gbsyncd-vs/Dockerfile.j2 +++ b/platform/vs/docker-gbsyncd-vs/Dockerfile.j2 @@ -8,7 +8,7 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update -RUN apt-get install -f -y iproute2=4.20.0-2 libcap2-bin=1:2.25-2 +RUN apt-get install -f -y iproute2 libcap2-bin COPY \ {% for deb in docker_gbsyncd_vs_debs.split(' ') -%} diff --git a/platform/vs/docker-syncd-vs/Dockerfile.j2 b/platform/vs/docker-syncd-vs/Dockerfile.j2 index 1ef1245e14fb..b3d7dcef490b 100644 --- a/platform/vs/docker-syncd-vs/Dockerfile.j2 +++ b/platform/vs/docker-syncd-vs/Dockerfile.j2 @@ -8,7 +8,7 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update -RUN apt-get install -f -y iproute2=4.20.0-2 libcap2-bin=1:2.25-2 +RUN apt-get install -f -y iproute2 libcap2-bin COPY \ {% for deb in docker_syncd_vs_debs.split(' ') -%} From 8003e11b5364d1ba406e4ca250f22c454f75b5b6 Mon Sep 17 00:00:00 2001 From: Danny Allen Date: Wed, 17 Feb 2021 18:00:50 -0800 Subject: [PATCH 0191/1674] [202012][submodule] Update sonic-swss and sonic-utilities submodules (#6798) Signed-off-by: Danny Allen --- src/sonic-swss | 2 +- src/sonic-utilities | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sonic-swss b/src/sonic-swss index fc06176a164b..676f23dd2d04 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit fc06176a164b2325d34a3f137fa1015d757dd64c +Subproject commit 676f23dd2d04f60b2b289b3a318853ac29b2c388 diff --git a/src/sonic-utilities b/src/sonic-utilities index ea6a38cda963..148259bbbb48 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit ea6a38cda963d0ea0b6eaf52026c63e749f3ce35 +Subproject commit 148259bbbb480c9750052aa3f5c8925b2f2ff1dd From fbc6190c0cf87f76b127061de8521b68e7ae4db6 Mon Sep 17 00:00:00 2001 From: xumia <59720581+xumia@users.noreply.github.com> Date: Tue, 12 Jan 2021 02:33:08 +0800 Subject: [PATCH 0192/1674] [arista]: Fix web package md5 hash not correct issue (#6411) Need to add the follow redirection option -L when downloading the package with redirection. --- src/sonic-build-hooks/scripts/buildinfo_base.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-build-hooks/scripts/buildinfo_base.sh b/src/sonic-build-hooks/scripts/buildinfo_base.sh index 94b767861467..ae85c2dcf129 100755 --- a/src/sonic-build-hooks/scripts/buildinfo_base.sh +++ b/src/sonic-build-hooks/scripts/buildinfo_base.sh @@ -46,7 +46,7 @@ check_version_control() get_url_version() { local package_url=$1 - /usr/bin/curl -ks $package_url | md5sum | cut -d' ' -f1 + /usr/bin/curl -Lks $package_url | md5sum | cut -d' ' -f1 } check_if_url_exist() From fa7d63622602248343222e53cfcc0e6019bb2137 Mon Sep 17 00:00:00 2001 From: xumia <59720581+xumia@users.noreply.github.com> Date: Thu, 18 Feb 2021 14:59:52 +0800 Subject: [PATCH 0193/1674] Add mirrors for reproducible build (#6813) --- files/apt/sources.list.amd64 | 5 +++++ files/apt/sources.list.arm64 | 5 +++++ files/apt/sources.list.armhf | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/files/apt/sources.list.amd64 b/files/apt/sources.list.amd64 index 4a94e3161ab1..45902be1078c 100644 --- a/files/apt/sources.list.amd64 +++ b/files/apt/sources.list.amd64 @@ -6,3 +6,8 @@ deb-src [arch=amd64] http://debian-archive.trafficmanager.net/debian/ buster mai deb [arch=amd64] http://debian-archive.trafficmanager.net/debian-security/ buster/updates main contrib non-free deb-src [arch=amd64] http://debian-archive.trafficmanager.net/debian-security/ buster/updates main contrib non-free deb [arch=amd64] http://debian-archive.trafficmanager.net/debian/ buster-backports main contrib non-free +deb [arch=amd64] http://packages.trafficmanager.net/debian/debian buster main contrib non-free +deb-src [arch=amd64] http://packages.trafficmanager.net/debian/debian buster main contrib non-free +deb [arch=amd64] http://packages.trafficmanager.net/debian/debian-security/ buster_updates main contrib non-free +deb-src [arch=amd64] http://packages.trafficmanager.net/debian/debian-security/ buster_updates main contrib non-free +deb [arch=amd64] http://packages.trafficmanager.net/debian/debian buster-backports main contrib non-free diff --git a/files/apt/sources.list.arm64 b/files/apt/sources.list.arm64 index dd82c744de1d..58b84978d023 100644 --- a/files/apt/sources.list.arm64 +++ b/files/apt/sources.list.arm64 @@ -6,3 +6,8 @@ deb-src [arch=arm64] http://deb.debian.org/debian buster main contrib non-free deb [arch=arm64] http://deb.debian.org/debian buster-updates main contrib non-free deb-src [arch=arm64] http://deb.debian.org/debian buster-updates main contrib non-free deb [arch=arm64] http://ftp.debian.org/debian buster-backports main +deb [arch=arm64] http://packages.trafficmanager.net/debian/debian buster main contrib non-free +deb-src [arch=arm64] http://packages.trafficmanager.net/debian/debian buster main contrib non-free +deb [arch=arm64] http://packages.trafficmanager.net/debian/debian buster-updates main contrib non-free +deb-src [arch=arm64] http://packages.trafficmanager.net/debian/debian buster-updates main contrib non-free +deb [arch=arm64] http://packages.trafficmanager.net/debian/debian buster-backports main diff --git a/files/apt/sources.list.armhf b/files/apt/sources.list.armhf index 760906188a94..eb6fe3be6889 100644 --- a/files/apt/sources.list.armhf +++ b/files/apt/sources.list.armhf @@ -6,3 +6,8 @@ deb-src [arch=armhf] http://deb.debian.org/debian buster main contrib non-free deb [arch=armhf] http://deb.debian.org/debian buster-updates main contrib non-free deb-src [arch=armhf] http://deb.debian.org/debian buster-updates main contrib non-free deb [arch=armhf] http://ftp.debian.org/debian buster-backports main +deb [arch=armhf] http://packages.trafficmanager.net/debian/debian buster main contrib non-free +deb-src [arch=armhf] http://packages.trafficmanager.net/debian/debian buster main contrib non-free +deb [arch=armhf] http://packages.trafficmanager.net/debian/debian buster-updates main contrib non-free +deb-src [arch=armhf] http://packages.trafficmanager.net/debian/debian buster-updates main contrib non-free +deb [arch=armhf] http://packages.trafficmanager.net/debian/debian buster-backports main From 7c001068178511e0f8dba4d8969c78e42e787919 Mon Sep 17 00:00:00 2001 From: xumia <59720581+xumia@users.noreply.github.com> Date: Tue, 23 Feb 2021 10:36:32 +0800 Subject: [PATCH 0194/1674] Add the version files for the branch 202012 (#6836) --- .../versions-deb-buster | 115 ++ .../build-sonic-slave-buster/versions-py2 | 12 + .../build-sonic-slave-buster/versions-py3 | 6 + .../versions-deb-stretch | 23 + .../build-sonic-slave-stretch/versions-py2 | 3 + .../versions/default/versions-deb-buster | 226 +++ files/build/versions/default/versions-py2 | 28 + files/build/versions/default/versions-py3 | 47 + files/build/versions/default/versions-web | 61 + .../docker-base-stretch/versions-deb-stretch | 71 + .../dockers/docker-base-stretch/versions-py2 | 4 + .../docker-config-engine-buster/versions-py3 | 1 + .../versions-deb-stretch | 11 + .../docker-config-engine-stretch/versions-py2 | 4 + .../docker-database/versions-deb-buster | 12 + .../docker-dhcp-relay/versions-deb-buster | 13 + .../docker-fpm-frr/versions-deb-buster | 19 + .../dockers/docker-fpm-frr/versions-py3 | 1 + .../docker-gbsyncd-vs/versions-deb-buster | 5 + .../dockers/docker-lldp/versions-deb-buster | 16 + .../dockers/docker-nat/versions-deb-buster | 14 + .../docker-orchagent/versions-deb-buster | 15 + .../versions-deb-buster | 25 + .../versions-deb-buster | 12 + .../dockers/docker-sflow/versions-deb-buster | 12 + .../dockers/docker-snmp/versions-deb-buster | 17 + .../versions-deb-buster | 13 + .../docker-sonic-mgmt-framework/versions-py3 | 2 + .../versions-deb-buster | 12 + .../docker-syncd-bfn/versions-deb-buster | 12 + .../versions-deb-buster | 58 + .../docker-syncd-centec-rpc/versions-py2 | 5 + .../docker-syncd-centec/versions-deb-buster | 13 + .../docker-syncd-invm/versions-deb-stretch | 5 + .../docker-syncd-mlnx-rpc/versions-deb-buster | 58 + .../docker-syncd-mlnx-rpc/versions-py2 | 5 + .../docker-syncd-mlnx/versions-deb-buster | 21 + .../docker-syncd-nephos/versions-deb-stretch | 29 + .../docker-syncd-vs/versions-deb-buster | 5 + .../dockers/docker-teamd/versions-deb-buster | 16 + .../sonic-slave-buster/versions-deb-buster | 1665 +++++++++++++++++ .../dockers/sonic-slave-buster/versions-py2 | 92 + .../dockers/sonic-slave-buster/versions-py3 | 70 + .../sonic-slave-stretch/versions-deb-stretch | 1484 +++++++++++++++ .../dockers/sonic-slave-stretch/versions-py2 | 79 + .../dockers/sonic-slave-stretch/versions-py3 | 36 + .../host-base-image/versions-deb-buster | 84 + .../versions/host-image/versions-deb-buster | 283 +++ files/build/versions/host-image/versions-py2 | 33 + files/build/versions/host-image/versions-py3 | 42 + 50 files changed, 4895 insertions(+) create mode 100644 files/build/versions/build/build-sonic-slave-buster/versions-deb-buster create mode 100644 files/build/versions/build/build-sonic-slave-buster/versions-py2 create mode 100644 files/build/versions/build/build-sonic-slave-buster/versions-py3 create mode 100644 files/build/versions/build/build-sonic-slave-stretch/versions-deb-stretch create mode 100644 files/build/versions/build/build-sonic-slave-stretch/versions-py2 create mode 100644 files/build/versions/default/versions-deb-buster create mode 100644 files/build/versions/default/versions-py2 create mode 100644 files/build/versions/default/versions-py3 create mode 100644 files/build/versions/default/versions-web create mode 100644 files/build/versions/dockers/docker-base-stretch/versions-deb-stretch create mode 100644 files/build/versions/dockers/docker-base-stretch/versions-py2 create mode 100644 files/build/versions/dockers/docker-config-engine-buster/versions-py3 create mode 100644 files/build/versions/dockers/docker-config-engine-stretch/versions-deb-stretch create mode 100644 files/build/versions/dockers/docker-config-engine-stretch/versions-py2 create mode 100644 files/build/versions/dockers/docker-database/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-dhcp-relay/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-fpm-frr/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-fpm-frr/versions-py3 create mode 100644 files/build/versions/dockers/docker-gbsyncd-vs/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-lldp/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-nat/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-orchagent/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-platform-monitor/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-router-advertiser/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-sflow/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-snmp/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-sonic-mgmt-framework/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-sonic-mgmt-framework/versions-py3 create mode 100644 files/build/versions/dockers/docker-sonic-telemetry/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-syncd-bfn/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-syncd-centec-rpc/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-syncd-centec-rpc/versions-py2 create mode 100644 files/build/versions/dockers/docker-syncd-centec/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-syncd-invm/versions-deb-stretch create mode 100644 files/build/versions/dockers/docker-syncd-mlnx-rpc/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-syncd-mlnx-rpc/versions-py2 create mode 100644 files/build/versions/dockers/docker-syncd-mlnx/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-syncd-nephos/versions-deb-stretch create mode 100644 files/build/versions/dockers/docker-syncd-vs/versions-deb-buster create mode 100644 files/build/versions/dockers/docker-teamd/versions-deb-buster create mode 100644 files/build/versions/dockers/sonic-slave-buster/versions-deb-buster create mode 100644 files/build/versions/dockers/sonic-slave-buster/versions-py2 create mode 100644 files/build/versions/dockers/sonic-slave-buster/versions-py3 create mode 100644 files/build/versions/dockers/sonic-slave-stretch/versions-deb-stretch create mode 100644 files/build/versions/dockers/sonic-slave-stretch/versions-py2 create mode 100644 files/build/versions/dockers/sonic-slave-stretch/versions-py3 create mode 100644 files/build/versions/host-base-image/versions-deb-buster create mode 100644 files/build/versions/host-image/versions-deb-buster create mode 100644 files/build/versions/host-image/versions-py2 create mode 100644 files/build/versions/host-image/versions-py3 diff --git a/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster b/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster new file mode 100644 index 000000000000..3681bae194bf --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster @@ -0,0 +1,115 @@ +applibs==1.mlnx.4.4.2308 +applibs-dev==1.mlnx.4.4.2308 +bfnplatform==1.0.0 +gir1.2-atk-1.0==2.30.0-2 +gir1.2-atspi-2.0==2.30.0-7 +gir1.2-freedesktop==1.58.3-2 +gir1.2-gdkpixbuf-2.0==2.38.1+dfsg-1 +gir1.2-gtk-3.0==3.24.5-1 +gir1.2-harfbuzz-0.0==2.3.1-1 +gir1.2-pango-1.0==1.42.4-8~deb10u1 +iproute2==1.mlnx.4.4.2308 +iproute2-dev==1.mlnx.4.4.2308 +isc-dhcp-relay==4.4.1-2 +kernel-mft-dkms==4.15.3-3 +libatk-bridge2.0-dev==2.30.0-5 +libatk1.0-dev==2.30.0-2 +libatspi2.0-dev==2.30.0-7 +libcairo-script-interpreter2==1.16.0-4+deb10u1 +libcairo2-dev==1.16.0-4+deb10u1 +libegl1-mesa-dev==18.3.6-2+deb10u1 +libepoxy-dev==1.5.3-0.1 +libfontconfig1-dev==2.13.1-2 +libfreetype6-dev==2.9.1-3+deb10u2 +libfribidi-dev==1.0.5-3.1+deb10u1 +libgdk-pixbuf2.0-dev==2.38.1+dfsg-1 +libgraphite2-dev==1.3.13-7 +libgtk-3-dev==3.24.5-1 +libharfbuzz-dev==2.3.1-1 +libharfbuzz-gobject0==2.3.1-1 +libhiredis-dev==0.14.0-3~bpo9+1 +libhiredis0.14==0.14.0-3~bpo9+1 +libnl-3-200==3.5.0-1 +libnl-3-dev==3.5.0-1 +libnl-cli-3-200==3.5.0-1 +libnl-cli-3-dev==3.5.0-1 +libnl-genl-3-200==3.5.0-1 +libnl-genl-3-dev==3.5.0-1 +libnl-nf-3-200==3.5.0-1 +libnl-nf-3-dev==3.5.0-1 +libnl-route-3-200==3.5.0-1 +libnl-route-3-dev==3.5.0-1 +libpango1.0-dev==1.42.4-8~deb10u1 +libpangoxft-1.0-0==1.42.4-8~deb10u1 +libpixman-1-dev==0.36.0-1 +libsaibcm==4.3.0.13-1 +libsaimetadata==1.0.0 +libsaimetadata-dev==1.0.0 +libsairedis==1.0.0 +libsairedis-dev==1.0.0 +libsaithrift-dev==0.9.4 +libsaivs==1.0.0 +libsnmp-base==5.7.3+dfsg-5 +libsnmp-dev==5.7.3+dfsg-5 +libsnmp30==5.7.3+dfsg-5 +libswsscommon==1.0.0 +libswsscommon-dev==1.0.0 +libtac-dev==1.4.1-1 +libtac2==1.4.1-1 +libteam-dev==1.30-1 +libteam-utils==1.30-1 +libteam5==1.30-1 +libteamdctl0==1.30-1 +libthrift-0.11.0==0.11.0-4 +libthrift-dev==0.11.0-4 +libwayland-bin==1.16.0-1 +libwayland-dev==1.16.0-1 +libxcb-shm0-dev==1.13.1-2 +libxcomposite-dev==1:0.4.4-2 +libxcursor-dev==1:1.1.15-2 +libxft-dev==2.3.2-2 +libxi-dev==2:1.7.9-1 +libxinerama-dev==2:1.1.4-2 +libxkbcommon-dev==0.8.2-1 +libxrandr-dev==2:1.5.1-1 +libxrender-dev==1:0.9.10-1 +libxtst-dev==2:1.2.3-1 +libyang==1.0.73 +libyang-cpp==1.0.73 +libyang-dev==1.0.73 +linux-headers-4.19.0-12-2-amd64==4.19.152-1 +linux-headers-4.19.0-12-2-common==4.19.152-1 +lldpd==1.0.4-1 +lm-sensors==1:3.5.0-3 +mft==4.15.3-3 +pango1.0-tools==1.42.4-8~deb10u1 +python-swsscommon==1.0.0 +python-thrift==0.11.0-4 +python2-yang==1.0.73 +python3-swsscommon==1.0.0 +python3-yang==1.0.73 +sonic-mgmt-common==1.0.0 +sonic-mgmt-common-codegen==1.0.0 +sonic-mgmt-framework==1.0-01 +sx-acl-helper==1.mlnx.4.4.2308 +sx-acl-helper-dev==1.mlnx.4.4.2308 +sx-complib==1.mlnx.4.4.2308 +sx-complib-dev==1.mlnx.4.4.2308 +sx-examples==1.mlnx.4.4.2308 +sx-examples-dev==1.mlnx.4.4.2308 +sx-gen-utils==1.mlnx.4.4.2308 +sx-gen-utils-dev==1.mlnx.4.4.2308 +sx-scew==1.mlnx.4.4.2308 +sx-scew-dev==1.mlnx.4.4.2308 +sxd-libs==1.mlnx.4.4.2308 +sxd-libs-dev==1.mlnx.4.4.2308 +syncd==1.0.0 +thrift-compiler==0.11.0-4 +wayland-protocols==1.17-1 +wjh-libs==1.mlnx.4.4.2308 +wjh-libs-dev==1.mlnx.4.4.2308 +x11proto-composite-dev==1:2018.4-4 +x11proto-input-dev==2018.4-4 +x11proto-randr-dev==2018.4-4 +x11proto-record-dev==2018.4-4 +x11proto-xinerama-dev==2018.4-4 \ No newline at end of file diff --git a/files/build/versions/build/build-sonic-slave-buster/versions-py2 b/files/build/versions/build/build-sonic-slave-buster/versions-py2 new file mode 100644 index 000000000000..1f5c68c822d7 --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-buster/versions-py2 @@ -0,0 +1,12 @@ +bitarray==1.5.3 +contextlib2==0.6.0.post1 +future==0.18.2 +importlib-resources==3.3.1 +ipaddress==1.0.23 +natsort==6.2.1 +netaddr==0.8.0 +pyangbind==0.6.0 +redis==3.5.3 +SaiRedis==1.0 +thrift==0.11.0 +zipp==1.2.0 \ No newline at end of file diff --git a/files/build/versions/build/build-sonic-slave-buster/versions-py3 b/files/build/versions/build/build-sonic-slave-buster/versions-py3 new file mode 100644 index 000000000000..036738d13aec --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-buster/versions-py3 @@ -0,0 +1,6 @@ +bitarray==1.5.3 +ijson==2.6.1 +ipaddress==1.0.23 +natsort==6.2.1 +netaddr==0.8.0 +xmltodict==0.12.0 \ No newline at end of file diff --git a/files/build/versions/build/build-sonic-slave-stretch/versions-deb-stretch b/files/build/versions/build/build-sonic-slave-stretch/versions-deb-stretch new file mode 100644 index 000000000000..df28b25a1ff2 --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-stretch/versions-deb-stretch @@ -0,0 +1,23 @@ +innovium-sai==0.11.1 +innovium-sai-headers==0.11.1 +libhiredis-dev==0.14.0-3~bpo9+1 +libhiredis0.14==0.14.0-3~bpo9+1 +libnl-3-200==3.5.0-1 +libnl-3-dev==3.5.0-1 +libnl-cli-3-200==3.5.0-1 +libnl-cli-3-dev==3.5.0-1 +libnl-genl-3-200==3.5.0-1 +libnl-genl-3-dev==3.5.0-1 +libnl-nf-3-200==3.5.0-1 +libnl-nf-3-dev==3.5.0-1 +libnl-route-3-200==3.5.0-1 +libnl-route-3-dev==3.5.0-1 +libsainps==1.5.0 +libsairedis==1.0.0 +libsaithrift-dev==0.9.4 +libswsscommon==1.0.0 +libswsscommon-dev==1.0.0 +libthrift-0.11.0==0.11.0-4 +libthrift-dev==0.11.0-4 +python-swsscommon==1.0.0 +thrift-compiler==0.11.0-4 \ No newline at end of file diff --git a/files/build/versions/build/build-sonic-slave-stretch/versions-py2 b/files/build/versions/build/build-sonic-slave-stretch/versions-py2 new file mode 100644 index 000000000000..e4755ea87a52 --- /dev/null +++ b/files/build/versions/build/build-sonic-slave-stretch/versions-py2 @@ -0,0 +1,3 @@ +natsort==6.2.1 +redis==3.5.3 +SaiRedis==1.0 \ No newline at end of file diff --git a/files/build/versions/default/versions-deb-buster b/files/build/versions/default/versions-deb-buster new file mode 100644 index 000000000000..0ac1d545ff28 --- /dev/null +++ b/files/build/versions/default/versions-deb-buster @@ -0,0 +1,226 @@ +apt-utils==1.8.2.2 +arping==2.19-6 +bridge-utils==1.6-2 +bzip2==1.0.6-9.2~deb10u1 +ca-certificates==20200601~deb10u2 +conntrack==1:1.4.5-2 +cron==3.0pl1-134+deb10u1 +curl==7.64.0-4+deb10u1 +dmidecode==3.2-1 +dpkg-dev==1.19.7 +ethtool==1:4.19-1 +fancontrol==1:3.5.0-3 +fontconfig==2.13.1-2 +fontconfig-config==2.13.1-2 +fonts-dejavu-core==2.37-1 +freeipmi-common==1.6.3-1.1 +frr==7.5-sonic-0 +frr-snmp==7.5-sonic-0 +hsflowd==2.0.32-1 +i2c-tools==4.1-1 +ifupdown==0.8.35 +ipmitool==1.8.18-6 +iptables==1.8.2-4 +isc-dhcp-relay==4.4.1-2 +jq==1.5+dfsg-2+b1 +kmod==26-1 +less==487-0.1+b1 +libapt-inst2.0==1.8.2.2 +libatomic1==8.3.0-6 +libbsd0==0.9.1-2 +libc-ares2==1.14.0-1 +libc-dev-bin==2.28-10 +libc-l10n==2.28-10 +libc6-dev==2.28-10 +libcairo2==1.16.0-4+deb10u1 +libcurl4==7.64.0-4+deb10u1 +libdaemon0==0.14-7 +libdatrie1==0.2.12-2 +libdbi1==0.9.0-5 +libdbus-1-3==1.12.20-0+deb10u1 +libdns-export1104==1:9.11.5.P4+dfsg-5.1+deb10u3 +libestr0==0.1.10-2.1 +libevent-2.1-6==2.1.8-stable-4 +libexpat1==2.2.6-2+deb10u1 +libexplain51==1.4.D001-8 +libfastjson4==0.99.8-2 +libfontconfig1==2.13.1-2 +libfreeipmi17==1.6.3-1.1 +libfreetype6==2.9.1-3+deb10u2 +libfribidi0==1.0.5-3.1+deb10u1 +libgdbm-compat4==1.18.1-4 +libgdbm6==1.18.1-4 +libglib2.0-0==2.58.3-2+deb10u2 +libgraphite2-3==1.3.13-7 +libgssapi-krb5-2==1.17-3+deb10u1 +libharfbuzz0b==2.3.1-1 +libhiredis0.14==0.14.0-3~bpo9+1 +libi2c0==4.1-1 +libicu63==63.1-6+deb10u1 +libip4tc0==1.8.2-4 +libip6tc0==1.8.2-4 +libiptc0==1.8.2-4 +libirs-export161==1:9.11.5.P4+dfsg-5.1+deb10u3 +libisc-export1100==1:9.11.5.P4+dfsg-5.1+deb10u3 +libisccfg-export163==1:9.11.5.P4+dfsg-5.1+deb10u3 +libjansson4==2.12-1 +libjemalloc2==5.1.0-3 +libjq1==1.5+dfsg-2+b1 +libjson-c3==0.12.1+ds-2+deb10u1 +libk5crypto3==1.17-3+deb10u1 +libkeyutils1==1.6-6 +libkmod2==26-1 +libkrb5-3==1.17-3+deb10u1 +libkrb5support0==1.17-3+deb10u1 +libldap-2.4-2==2.4.47+dfsg-3+deb10u6 +libldap-common==2.4.47+dfsg-3+deb10u6 +liblognorm5==2.0.5-1 +liblua5.1-0==5.1.5-8.1+b2 +libmariadb3==1:10.3.27-0+deb10u1 +libmpdec2==2.4.2-2 +libncurses6==6.1+20181013-2+deb10u2 +libnet1==1.1.6+dfsg-3.1 +libnetfilter-conntrack3==1.0.7-1 +libnfnetlink0==1.0.1-3+b1 +libnftnl11==1.1.2-2 +libnghttp2-14==1.36.0-2+deb10u1 +libnl-3-200==3.5.0-1 +libnl-cli-3-200==3.5.0-1 +libnl-genl-3-200==3.5.0-1 +libnl-nf-3-200==3.5.0-1 +libnl-route-3-200==3.5.0-1 +libnorm1==1.5.8+dfsg2-1 +libonig5==6.9.1-1 +libpango-1.0-0==1.42.4-8~deb10u1 +libpangocairo-1.0-0==1.42.4-8~deb10u1 +libpangoft2-1.0-0==1.42.4-8~deb10u1 +libpcap0.8==1.8.1-6 +libpci3==1:3.5.2-1 +libperl5.28==5.28.1-6+deb10u1 +libpgm-5.2-0==5.2.122~dfsg-3 +libpixman-1-0==0.36.0-1 +libpng16-16==1.6.36-6 +libpopt0==1.16-12 +libprocps7==2:3.3.15-2 +libprotobuf-dev==3.6.1.3-2 +libprotobuf-lite17==3.6.1.3-2 +libprotobuf17==3.6.1.3-2 +libpsl5==0.20.2-2 +libpython-stdlib==2.7.16-1 +libpython2-stdlib==2.7.16-1 +libpython2.7==2.7.16-2+deb10u1 +libpython2.7-minimal==2.7.16-2+deb10u1 +libpython2.7-stdlib==2.7.16-2+deb10u1 +libpython3-stdlib==3.7.3-1 +libpython3.7==3.7.3-2+deb10u2 +libpython3.7-minimal==3.7.3-2+deb10u2 +libpython3.7-stdlib==3.7.3-2+deb10u2 +libreadline7==7.0-5 +librrd-dev==1.7.1-2 +librrd8==1.7.1-2 +librtmp1==2.4+20151223.gitfa8646d.1-2 +libsaibcm==4.3.0.13-1 +libsaimetadata==1.0.0 +libsairedis==1.0.0 +libsasl2-2==2.1.27+dfsg-1+deb10u1 +libsasl2-modules-db==2.1.27+dfsg-1+deb10u1 +libsensors-config==1:3.5.0-3 +libsensors5==1:3.5.0-3 +libsodium23==1.0.17-1 +libsqlite3-0==3.27.2-3+deb10u1 +libssh2-1==1.8.0-2.1 +libssl1.1==1.1.1d-0+deb10u5 +libswsscommon==1.0.0 +libteam-utils==1.30-1 +libteam5==1.30-1 +libteamdctl0==1.30-1 +libthai-data==0.1.28-2 +libthai0==0.1.28-2 +libunwind8==1.2.1-10~deb10u1 +libwrap0==7.6.q-28 +libx11-6==2:1.6.7-1+deb10u1 +libx11-data==2:1.6.7-1+deb10u1 +libxau6==1:1.0.8-1+b2 +libxcb-render0==1.13.1-2 +libxcb-shm0==1.13.1-2 +libxcb1==1.13.1-2 +libxdmcp6==1:1.1.2-3 +libxext6==2:1.3.3-1+b2 +libxml2==2.9.4+dfsg1-7+deb10u1 +libxrender1==1:0.9.10-1 +libyaml-0-2==0.2.1-1 +libyaml-dev==0.2.1-1 +libyang==1.0.73 +libyang1==1.0.184-2 +libzmq5==4.3.1-4+deb10u2 +linux-libc-dev==4.19.171-2 +lldpd==1.0.4-1 +lm-sensors==1:3.5.0-3 +locales==2.28-10 +logrotate==3.14.0-4 +lsb-base==10.2019051400 +lsof==4.91+dfsg-1 +lua-bitop==1.0.2-5 +lua-cjson==2.1.0+dfsg-2.1 +mariadb-common==1:10.3.27-0+deb10u1 +mime-support==3.62 +mysql-common==5.8+1.0.5 +ndisc6==1.0.4-1 +ndppd==0.2.5-4+deb10u1 +net-tools==1.60+git20180626.aebd88e-1 +openssl==1.1.1d-0+deb10u5 +perl==5.28.1-6+deb10u1 +perl-modules-5.28==5.28.1-6+deb10u1 +procps==2:3.3.15-2 +psample==1.1-1 +python==2.7.16-1 +python-funcsigs==1.0.2-4 +python-functools32==3.2.3.2-3 +python-jsonschema==2.6.0-4 +python-minimal==2.7.16-1 +python-mock==2.0.0-4 +python-pbr==4.2.0-5 +python-pkg-resources==40.8.0-1 +python-setuptools==40.8.0-1 +python-six==1.12.0-1 +python-smbus==4.1-1 +python-swsscommon==1.0.0 +python2==2.7.16-1 +python2-minimal==2.7.16-1 +python2.7==2.7.16-2+deb10u1 +python2.7-minimal==2.7.16-2+deb10u1 +python3==3.7.3-1 +python3-distutils==3.7.3-1 +python3-lib2to3==3.7.3-1 +python3-minimal==3.7.3-1 +python3-smbus==4.1-1 +python3-swsscommon==1.0.0 +python3.7==3.7.3-2+deb10u2 +python3.7-minimal==3.7.3-2+deb10u2 +radvd==1:2.17-2 +readline-common==7.0-5 +redis-server==5:6.0.6-1~bpo10+1 +redis-tools==5:6.0.6-1~bpo10+1 +rrdtool==1.7.1-2 +rsyslog==8.1901.0-1 +sensible-utils==0.0.12 +sensord==1:3.5.0-3 +sflowtool==5.04 +smartmontools==6.6-1 +snmp==5.7.3+dfsg-5 +snmpd==5.7.3+dfsg-5 +socat==1.7.3.1-2+deb9u1 +sonic-dhcpmon==1.0.0-0 +sonic-mgmt-common==1.0.0 +sonic-mgmt-framework==1.0-01 +sonic-telemetry==0.1 +swss==1.0.0 +syncd==1.0.0 +tcpdump==4.9.3-1~deb10u2 +ucf==3.0038+nmu1 +udev==241-7~deb10u6 +vim-common==2:8.1.0875-5 +vim-tiny==2:8.1.0875-5 +xxd==2:8.1.0875-5 +xz-utils==5.2.4-1 +zlib1g-dev==1:1.2.11.dfsg-1 \ No newline at end of file diff --git a/files/build/versions/default/versions-py2 b/files/build/versions/default/versions-py2 new file mode 100644 index 000000000000..722c73af5c7d --- /dev/null +++ b/files/build/versions/default/versions-py2 @@ -0,0 +1,28 @@ +bitarray==1.5.3 +contextlib2==0.6.0.post1 +enum34==1.1.10 +funcsigs==1.0.2 +functools32==3.2.3.post2 +future==0.18.2 +importlib-resources==3.3.1 +ipaddress==1.0.23 +Jinja2==2.11.3 +jsonschema==2.6.0 +lxml==4.6.2 +MarkupSafe==1.1.1 +mock==2.0.0 +natsort==6.2.1 +netaddr==0.8.0 +pathlib2==2.3.5 +pbr==4.2.0 +pyang==2.4.0 +pyangbind==0.6.0 +PyYAML==5.4.1 +redis==3.5.3 +redis-dump-load==1.1 +scandir==1.10.0 +singledispatch==3.6.0 +six==1.12.0 +thrift==0.13.0 +typing==3.7.4.3 +zipp==1.2.0 \ No newline at end of file diff --git a/files/build/versions/default/versions-py3 b/files/build/versions/default/versions-py3 new file mode 100644 index 000000000000..0c5748ac896a --- /dev/null +++ b/files/build/versions/default/versions-py3 @@ -0,0 +1,47 @@ +attrs==20.3.0 +bitarray==1.5.3 +certifi==2017.4.17 +chardet==4.0.0 +click==7.1.2 +clickclick==20.10.2 +connexion==2.7.0 +Flask==1.1.2 +grpcio==1.35.0 +grpcio-tools==1.20.0 +hiredis==1.1.0 +idna==2.10 +importlib-metadata==3.4.0 +inflection==0.5.1 +ipaddress==1.0.23 +itsdangerous==1.1.0 +j2cli==0.3.10 +Jinja2==2.11.3 +jsonschema==3.2.0 +lxml==4.6.2 +MarkupSafe==1.1.1 +natsort==6.2.1 +netaddr==0.8.0 +netifaces==0.10.9 +openapi-spec-validator==0.2.9 +protobuf==3.15.1 +psutil==5.8.0 +pyang==2.4.0 +pyangbind==0.8.1 +pyroute2==0.5.14 +pyrsistent==0.17.3 +python-arptable==0.0.2 +python-dateutil==2.6.0 +PyYAML==5.4.1 +redis==3.5.3 +redis-dump-load==1.1 +regex==2020.11.13 +requests==2.25.1 +scapy==2.4.4 +smbus==1.1.post2 +supervisor==4.2.1 +supervisord-dependent-startup==1.4.0 +thrift==0.13.0 +toposort==1.6 +typing-extensions==3.7.4.3 +urllib3==1.21.1 +Werkzeug==1.0.1 \ No newline at end of file diff --git a/files/build/versions/default/versions-web b/files/build/versions/default/versions-web new file mode 100644 index 000000000000..b0a9be7c03a7 --- /dev/null +++ b/files/build/versions/default/versions-web @@ -0,0 +1,61 @@ +http://deb.debian.org/debian/pool/main/i/iptables/iptables_1.8.2-4.debian.tar.xz==c27e499611c48ba307792518d29cdcc7 +http://deb.debian.org/debian/pool/main/i/iptables/iptables_1.8.2-4.dsc==d9572a9f48c88293341681601a7b18c5 +http://deb.debian.org/debian/pool/main/i/iptables/iptables_1.8.2.orig.tar.bz2==944558e88ddcc3b9b0d9550070fa3599 +http://deb.debian.org/debian/pool/main/l/lm-sensors/lm-sensors_3.5.0-3.debian.tar.xz==c2a4cd6b79350378ca9a337b45b732c5 +http://deb.debian.org/debian/pool/main/l/lm-sensors/lm-sensors_3.5.0-3.dsc==86e28662fa00bec000f22257d212873d +http://deb.debian.org/debian/pool/main/l/lm-sensors/lm-sensors_3.5.0.orig.tar.gz==37981f5d3a0f649381529cb41c0f1ff3 +http://deb.debian.org/debian/pool/main/m/makedumpfile/makedumpfile_1.6.1-1.debian.tar.xz==a677f850ad1e4f2600cc9c3f3c872927 +http://deb.debian.org/debian/pool/main/m/makedumpfile/makedumpfile_1.6.1.orig.tar.gz==16c0ae9902ae57be4a603a6ab1e86c53 +http://deb.debian.org/debian/pool/main/n/ntp/ntp_4.2.8p12+dfsg-4.debian.tar.xz==bec40e0bda23a893e76843579c68d901 +http://deb.debian.org/debian/pool/main/n/ntp/ntp_4.2.8p12+dfsg.orig.tar.xz==71044a49f4ab09c9bc10ed9862d22939 +http://http.debian.net/debian/pool/main/h/hiredis/hiredis_0.14.0-3~bpo9+1.debian.tar.xz==ef340aedc6fd42c549cd503bffb498b2 +http://http.debian.net/debian/pool/main/h/hiredis/hiredis_0.14.0-3~bpo9+1.dsc==be4ce11ef67268e59e4b6be587327c40 +http://http.debian.net/debian/pool/main/h/hiredis/hiredis_0.14.0.orig.tar.gz==6d565680a4af0d2e261abbc3e3431b2b +http://www.mellanox.com/downloads/MFT/mft-4.15.3-3-x86_64-deb.tgz==21caa3657b4100da3d08cf47961edc6f +https://chrome-infra-packages.appspot.com/client?platform=linux-amd64&version=git_revision:61ac72e84956112656e2500701dd252c5d92f6e6==314a78da036bd5b54637cd17c54ccfd9 +https://download.docker.com/linux/debian/gpg==1afae06b34a13c1b3d9cb61a26285a15 +https://github.com/aristanetworks/sonic-firmware/raw/78a3df2/phy/phy-credo_1.0_amd64.deb==f0d5b5efa18cf775cdc3fccaba7ac181 +https://github.com/barefootnetworks/sonic-release-pkgs/raw/dev/bfnplatform_20201228_deb10.deb==d4045769acf8abd2ff176ff7e659cc69 +https://github.com/barefootnetworks/sonic-release-pkgs/raw/dev/bfnsdk_20201228_deb10.deb==b59589104e5189b1f598b8c46d3d6c8a +https://github.com/CentecNetworks/sonic-binaries/raw/master/amd64/libsai_1.6.3-1_amd64.deb==e7a41e5cf06b44ae3ed615d553de40d3 +https://github.com/CumulusNetworks/ifupdown2/archive/1.2.8-1.tar.gz==12f45e90d23178e96cf70f68dc9455e6 +https://github.com/Innovium/SONiC/raw/master/debian/master/ipd.deb==a0f512aba05180b15c2f6b5809b9d5c1 +https://github.com/Innovium/SONiC/raw/master/debian/master/isai.deb==2ed19469078ff5b04208ed2042d30e05 +https://github.com/Innovium/SONiC/raw/master/debian/master/saihdr.deb==f1e60b01f5c1ae9832931166ba786202 +https://github.com/nanomsg/nanomsg/archive/1.0.0.tar.gz==6f56ef28c93cee644e8c4aaaef7cfb55 +https://github.com/NephosInc/SONiC/raw/master/sai/libsainps-dev_3.0.0_sai_1.5.0_06a67d_amd64.deb==64931041f82533e2a05e003ed9d878c8 +https://github.com/NephosInc/SONiC/raw/master/sai/libsainps_3.0.0_sai_1.5.0_06a67d_amd64.deb==385b84051259ebb2580522a990cca161 +https://github.com/NephosInc/SONiC/raw/master/sdk/npx_diag==a444c876aaf2a8b4c99238f15fbc13a0 +https://raw.githubusercontent.com/p4lang/ptf/master/ptf_nn/ptf_nn_agent.py==628956b660575965429cec84b1778816 +https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.5/swagger-codegen-cli-2.4.5.jar==219f1453ff22482d9e080effbfa7fa81 +https://sonicstorage.blob.core.windows.net/debian-security/pool/updates/main/l/linux/linux_4.19.152-1.debian.tar.xz==875d84b0edad0210c090195a8df4eb6c +https://sonicstorage.blob.core.windows.net/debian-security/pool/updates/main/l/linux/linux_4.19.152-1.dsc==e76d5deda89795939828c3b39b31d38f +https://sonicstorage.blob.core.windows.net/debian-security/pool/updates/main/l/linux/linux_4.19.152.orig.tar.xz==e3afaa4ac1387449dec703da494dd991 +https://sonicstorage.blob.core.windows.net/debian/pool/main/l/lldpd/lldpd_1.0.4-1.debian.tar.xz==0a529cf8d1717b5c3dbe0c61b3512aa1 +https://sonicstorage.blob.core.windows.net/debian/pool/main/l/lldpd/lldpd_1.0.4-1.dsc==b88b922d96688c948e90987fcaa3a2de +https://sonicstorage.blob.core.windows.net/debian/pool/main/l/lldpd/lldpd_1.0.4.orig.tar.gz==33e8d58623f99184e4e709cbbfe45db3 +https://sonicstorage.blob.core.windows.net/debian/pool/main/liby/libyang/libyang_1.0.184-2.debian.tar.xz==f159fbedc0b69d00b2bdb08db283c0bb +https://sonicstorage.blob.core.windows.net/debian/pool/main/liby/libyang/libyang_1.0.184-2.dsc==98c68654fadc116346007be9282ae357 +https://sonicstorage.blob.core.windows.net/debian/pool/main/liby/libyang/libyang_1.0.184.orig.tar.gz==0ddfdf2dba5e73486c133c1fba1b3e8e +https://sonicstorage.blob.core.windows.net/debian/pool/main/n/net-snmp/net-snmp_5.7.3+dfsg-5.debian.tar.xz==ad957e90207d0669beb2109e4e325def +https://sonicstorage.blob.core.windows.net/debian/pool/main/n/net-snmp/net-snmp_5.7.3+dfsg-5.dsc==2443e4dffbdb020e7ab4f947a7904912 +https://sonicstorage.blob.core.windows.net/debian/pool/main/n/net-snmp/net-snmp_5.7.3+dfsg.orig.tar.xz==6391ae27eb1ae34ff5530712bb1c4209 +https://sonicstorage.blob.core.windows.net/packages/20190307/bcmcmd?sv=2015-04-05&sr=b&sig=sUdbU7oVbh5exbXXHVL5TDFBTWDDBASHeJ8Cp0B0TIc%3D&se=2038-05-06T22%3A34%3A19Z&sp=r==b8aefc751bdf93218716bca6797460ff +https://sonicstorage.blob.core.windows.net/packages/20190307/dsserve?sv=2015-04-05&sr=b&sig=lk7BH3DtW%2F5ehc0Rkqfga%2BUCABI0UzQmDamBsZH9K6w%3D&se=2038-05-06T22%3A34%3A45Z&sp=r==f9d4b815ebb9be9f755dedca8a51170d +https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.0.13-1_amd64.deb?sv=2015-04-05&sr=b&sig=twfshldM6GQEphfU%2BQ4xmJlGJkv2Sy7KU1F72RYYM0A%3D&se=2034-10-22T06%3A00%3A45Z&sp=r==84fd57e010281c66d2343b68bd10f7a2 +https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.0.13-1_amd64.deb?sv=2015-04-05&sr=b&sig=e%2BBucofzEwCC%2BclqK1OeCi5YFpQAD4ID4FfODzszsuM%3D&se=2034-10-22T06%3A00%3A14Z&sp=r==d4f4fb23b955792d102351e23678eba8 +https://sonicstorage.blob.core.windows.net/packages/cmake/cmake-data_3.13.2-1_bpo9%2B1_all.deb?st=2020-03-27T02%3A22%3A24Z&se=2100-03-26T19%3A00%3A00Z&sp=rl&sv=2018-03-28&sr=b&sig=Xby%2Bm3OZOjPB%2FSlDbHD65yDcPzAgoys%2FA3vK8RB4BzA%3D==147cf42f3a68f6d6f1e53d95a599a1af +https://sonicstorage.blob.core.windows.net/packages/cmake/cmake_3.13.2-1_bpo9%2B1_amd64.deb?st=2020-03-27T02%3A27%3A21Z&se=2100-03-26T19%3A00%3A00Z&sp=rl&sv=2018-03-28&sr=b&sig=4MvmmDBQuicFEJYakLm7xCNU19yJ8GIP4ankFSnITKY%3D==e75c741e8b6918b8f03625e456fa0275 +https://sonicstorage.blob.core.windows.net/packages/debian/smartmontools_6.6-1.debian.tar.xz?sv=2015-04-05&sr=b&sig=H0RFeC41MCvhTQCln85DuPLn5v2goozwz%2FB9sA9p5eQ%3D&se=2046-08-20T23%3A46%3A02Z&sp=r==47a284f4762f86ba24753ea75d85e6cb +https://sonicstorage.blob.core.windows.net/packages/debian/smartmontools_6.6-1.dsc?sv=2015-04-05&sr=b&sig=IS7FKUN%2Bvq0T55f4X2hGAViB70Y%2FgzjGgvzpUJLyUfA%3D&se=2046-08-20T23%3A46%3A57Z&sp=r==151f97b46df2dafbd5bb954bb419642c +https://sonicstorage.blob.core.windows.net/packages/debian/smartmontools_6.6.orig.tar.gz?sv=2015-04-05&sr=b&sig=JZx4qiLuO36T0rsGqk4V2RDuWjRw6NztsLK7vlBYAkg%3D&se=2046-08-20T23%3A47%3A13Z&sp=r==9ae2c6e7131cd2813edcc65cbe5f223f +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==84dc9e966e116384ac13aeca16b9437a +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==b14d356861eaa916f7f19098ab7b1d4e +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==fbab6334919cbd71433213db18dbbdf0 +https://sonicstorage.blob.core.windows.net/packages/debian/thrift_0.11.0-4.debian.tar.xz?sv=2015-04-05&sr=b&sig=dj9uJ5YjUNupcmuxSX6%2F5IS9NqaGAyM9iF2h%2F2rROZA%3D&se=2156-02-02T17%3A19%3A34Z&sp=r==52ad383b97ad051f4d1d25b54aaad569 +https://sonicstorage.blob.core.windows.net/packages/debian/thrift_0.11.0-4.dsc?sv=2015-04-05&sr=b&sig=pWfg55owvQ2jZtZ6ylHp0OP8uZyfc9sxO6H%2BP4Ez7w4%3D&se=2156-02-02T17%3A20%3A05Z&sp=r==6917fe7b3ada9313be94713dd50fee7b +https://sonicstorage.blob.core.windows.net/packages/debian/thrift_0.11.0.orig.tar.gz?sv=2015-04-05&sr=b&sig=%2BrAjWESiSNRCMN7NGqEqVGceLefpwwS%2FWPKEfJpPLSQ%3D&se=2156-02-02T17%3A17%3A20Z&sp=r==0be59730ebce071eceaf6bfdb8d3a20e +https://sonicstorage.blob.core.windows.net/packages/onie/onie-recovery-x86_64-kvm_x86_64-r0.iso?sv=2015-04-05&sr=b&sig=XMAk1cttBFM369CMbihe5oZgXwe4uaDVfwg4CTLT%2F5U%3D&se=2155-10-13T10%3A40%3A13Z&sp=r==54e11e450a461b1f4ae39c3ce3f15eff +https://sonicstorage.blob.core.windows.net/packages/redis/redis-server_6.0.6-1~bpo10+1_amd64.deb?sv=2015-04-05&sr=b&sig=2Ketg7BmkZEaTxR%2FgvAFVmhjn7ywdmkc7l2T2rsL57o%3D&se=2030-09-06T19%3A45%3A20Z&sp=r==09af97c096f4c854d238f91614a3415b +https://sonicstorage.blob.core.windows.net/packages/redis/redis-tools_6.0.6-1~bpo10+1_amd64.deb?sv=2015-04-05&sr=b&sig=73zbmjkf3pi%2Bn0R8Hy7CWT2EUvOAyzM5aLYJWCLySGM%3D&se=2030-09-06T19%3A44%3A59Z&sp=r==2d58c3c3358290c04d5e0ba70f297f18 +https://storage.googleapis.com/golang/go1.14.2.linux-amd64.tar.gz==856d248e3ea8a287d13e5f6afd086282 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-base-stretch/versions-deb-stretch b/files/build/versions/dockers/docker-base-stretch/versions-deb-stretch new file mode 100644 index 000000000000..f760bca27701 --- /dev/null +++ b/files/build/versions/dockers/docker-base-stretch/versions-deb-stretch @@ -0,0 +1,71 @@ +ca-certificates==20200601~deb9u1 +curl==7.52.1-5+deb9u13 +jq==1.5+dfsg-1.3 +less==481-2.1 +libcurl3==7.52.1-5+deb9u13 +libdaemon0==0.14-6 +libdbus-1-3==1.10.32-0+deb9u1 +libestr0==0.1.10-2 +libexpat1==2.2.0-2+deb9u3 +libfastjson4==0.99.8-1~bpo9+1 +libffi6==3.2.1-6 +libgdbm3==1.8.3-14 +libgmp10==2:6.1.2+dfsg-1 +libgnutls30==3.5.8-5+deb9u5 +libgssapi-krb5-2==1.15-1+deb9u2 +libhogweed4==3.3-1+b2 +libidn2-0==0.16-1+deb9u1 +libjansson4==2.9-1 +libjq1==1.5+dfsg-1.3 +libk5crypto3==1.15-1+deb9u2 +libkeyutils1==1.5.9-9 +libkrb5-3==1.15-1+deb9u2 +libkrb5support0==1.15-1+deb9u2 +libldap-2.4-2==2.4.44+dfsg-5+deb9u8 +libldap-common==2.4.44+dfsg-5+deb9u8 +liblognorm5==2.0.3-1~bpo9+1 +libncurses5==6.0+20161126-1+deb9u2 +libnghttp2-14==1.18.1-1+deb9u1 +libonig4==6.1.3-2+deb9u2 +libp11-kit0==0.23.3-2+deb9u1 +libperl5.24==5.24.1-3+deb9u7 +libpgm-5.2-0==5.2.122~dfsg-2 +libprocps6==2:3.3.12-3+deb9u1 +libpsl5==0.17.0-3 +libpython-stdlib==2.7.13-2 +libpython2.7==2.7.13-2+deb9u4 +libpython2.7-minimal==2.7.13-2+deb9u4 +libpython2.7-stdlib==2.7.13-2+deb9u4 +libreadline7==7.0-3 +librtmp1==2.4+20151223.gitfa8646d.1-1+b1 +libsasl2-2==2.1.27~101-g0780600+dfsg-3+deb9u1 +libsasl2-modules-db==2.1.27~101-g0780600+dfsg-3+deb9u1 +libsodium18==1.0.11-2 +libsqlite3-0==3.16.2-5+deb9u3 +libssh2-1==1.7.0-1+deb9u1 +libssl1.0.2==1.0.2u-1~deb9u4 +libssl1.1==1.1.0l-1~deb9u3 +libtasn1-6==4.10-1.1+deb9u1 +libunistring0==0.9.6+really0.9.3-0.1 +libwrap0==7.6.q-26 +libzmq5==4.2.1-4+deb9u3 +lua-cjson==2.1.0+dfsg-2 +mime-support==3.60 +net-tools==1.60+git20161116.90da8a0-1 +openssl==1.1.0l-1~deb9u3 +perl==5.24.1-3+deb9u7 +perl-modules-5.24==5.24.1-3+deb9u7 +procps==2:3.3.12-3+deb9u1 +python==2.7.13-2 +python-minimal==2.7.13-2 +python-pip==9.0.1-2+deb9u2 +python-pip-whl==9.0.1-2+deb9u2 +python2.7==2.7.13-2+deb9u4 +python2.7-minimal==2.7.13-2+deb9u4 +readline-common==7.0-3 +redis-tools==5:6.0.6-1~bpo10+1 +rsyslog==8.1901.0-1~bpo9+1 +socat==1.7.3.1-2+deb9u1 +vim-common==2:8.0.0197-4+deb9u3 +vim-tiny==2:8.0.0197-4+deb9u3 +xxd==2:8.0.0197-4+deb9u3 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-base-stretch/versions-py2 b/files/build/versions/dockers/docker-base-stretch/versions-py2 new file mode 100644 index 000000000000..54e22f62fbab --- /dev/null +++ b/files/build/versions/dockers/docker-base-stretch/versions-py2 @@ -0,0 +1,4 @@ +j2cli==0.3.10 +supervisor==4.2.1 +supervisord-dependent-startup==1.4.0 +toposort==1.6 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-config-engine-buster/versions-py3 b/files/build/versions/dockers/docker-config-engine-buster/versions-py3 new file mode 100644 index 000000000000..80be8cff9a6c --- /dev/null +++ b/files/build/versions/dockers/docker-config-engine-buster/versions-py3 @@ -0,0 +1 @@ +six==1.15.0 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-config-engine-stretch/versions-deb-stretch b/files/build/versions/dockers/docker-config-engine-stretch/versions-deb-stretch new file mode 100644 index 000000000000..bcd99b6899bd --- /dev/null +++ b/files/build/versions/dockers/docker-config-engine-stretch/versions-deb-stretch @@ -0,0 +1,11 @@ +bzip2==1.0.6-8.1 +dpkg-dev==1.18.25 +libhiredis0.14==0.14.0-3~bpo9+1 +libnl-3-200==3.5.0-1 +libnl-cli-3-200==3.5.0-1 +libnl-genl-3-200==3.5.0-1 +libnl-nf-3-200==3.5.0-1 +libnl-route-3-200==3.5.0-1 +libswsscommon==1.0.0 +python-swsscommon==1.0.0 +xz-utils==5.2.2-1.2+b1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-config-engine-stretch/versions-py2 b/files/build/versions/dockers/docker-config-engine-stretch/versions-py2 new file mode 100644 index 000000000000..c2bea3fa5a42 --- /dev/null +++ b/files/build/versions/dockers/docker-config-engine-stretch/versions-py2 @@ -0,0 +1,4 @@ +six==1.15.0 +sonic-config-engine==1.0 +sonic-py-common==1.0 +swsssdk==2.0.1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-database/versions-deb-buster b/files/build/versions/dockers/docker-database/versions-deb-buster new file mode 100644 index 000000000000..f8cf36dc0e12 --- /dev/null +++ b/files/build/versions/dockers/docker-database/versions-deb-buster @@ -0,0 +1,12 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libbabeltrace1==1.5.6-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libgpm2==1.20.7-5 +libipt2==2.0-2 +openssh-client==1:7.9p1-10+deb10u2 +sshpass==1.06-1 +strace==4.26-0.2 +vim==2:8.1.0875-5 +vim-runtime==2:8.1.0875-5 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-dhcp-relay/versions-deb-buster b/files/build/versions/dockers/docker-dhcp-relay/versions-deb-buster new file mode 100644 index 000000000000..090a9af05b59 --- /dev/null +++ b/files/build/versions/dockers/docker-dhcp-relay/versions-deb-buster @@ -0,0 +1,13 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +isc-dhcp-relay-dbgsym==4.4.1-2 +libbabeltrace1==1.5.6-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libgpm2==1.20.7-5 +libipt2==2.0-2 +openssh-client==1:7.9p1-10+deb10u2 +sshpass==1.06-1 +strace==4.26-0.2 +vim==2:8.1.0875-5 +vim-runtime==2:8.1.0875-5 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-fpm-frr/versions-deb-buster b/files/build/versions/dockers/docker-fpm-frr/versions-deb-buster new file mode 100644 index 000000000000..f7c4d4703113 --- /dev/null +++ b/files/build/versions/dockers/docker-fpm-frr/versions-deb-buster @@ -0,0 +1,19 @@ +frr-dbgsym==7.5-sonic-0 +frr-snmp-dbgsym==7.5-sonic-0 +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libbabeltrace1==1.5.6-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libgpm2==1.20.7-5 +libipt2==2.0-2 +libsnmp-base==5.7.3+dfsg-5+deb10u2 +libsnmp30==5.7.3+dfsg-5+deb10u2 +libswsscommon-dbg==1.0.0 +libyang1-dbgsym==1.0.184-2 +openssh-client==1:7.9p1-10+deb10u2 +sshpass==1.06-1 +strace==4.26-0.2 +swss-dbg==1.0.0 +vim==2:8.1.0875-5 +vim-runtime==2:8.1.0875-5 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-fpm-frr/versions-py3 b/files/build/versions/dockers/docker-fpm-frr/versions-py3 new file mode 100644 index 000000000000..ff7826d683d4 --- /dev/null +++ b/files/build/versions/dockers/docker-fpm-frr/versions-py3 @@ -0,0 +1 @@ +zipp==1.2.0 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-gbsyncd-vs/versions-deb-buster b/files/build/versions/dockers/docker-gbsyncd-vs/versions-deb-buster new file mode 100644 index 000000000000..abd21dae6b32 --- /dev/null +++ b/files/build/versions/dockers/docker-gbsyncd-vs/versions-deb-buster @@ -0,0 +1,5 @@ +iproute2==4.20.0-2 +libsaivs==1.0.0 +libsaivs-dbg==1.0.0 +syncd-vs==1.0.0 +syncd-vs-dbg==1.0.0 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-lldp/versions-deb-buster b/files/build/versions/dockers/docker-lldp/versions-deb-buster new file mode 100644 index 000000000000..dced6f540d81 --- /dev/null +++ b/files/build/versions/dockers/docker-lldp/versions-deb-buster @@ -0,0 +1,16 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libbabeltrace1==1.5.6-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libgpm2==1.20.7-5 +libipt2==2.0-2 +libsnmp-base==5.7.3+dfsg-5 +libsnmp30==5.7.3+dfsg-5 +libswsscommon-dbg==1.0.0 +lldpd-dbgsym==1.0.4-1 +openssh-client==1:7.9p1-10+deb10u2 +sshpass==1.06-1 +strace==4.26-0.2 +vim==2:8.1.0875-5 +vim-runtime==2:8.1.0875-5 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-nat/versions-deb-buster b/files/build/versions/dockers/docker-nat/versions-deb-buster new file mode 100644 index 000000000000..159c8c90df8b --- /dev/null +++ b/files/build/versions/dockers/docker-nat/versions-deb-buster @@ -0,0 +1,14 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libbabeltrace1==1.5.6-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libgpm2==1.20.7-5 +libipt2==2.0-2 +libswsscommon-dbg==1.0.0 +openssh-client==1:7.9p1-10+deb10u2 +sshpass==1.06-1 +strace==4.26-0.2 +swss-dbg==1.0.0 +vim==2:8.1.0875-5 +vim-runtime==2:8.1.0875-5 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-orchagent/versions-deb-buster b/files/build/versions/dockers/docker-orchagent/versions-deb-buster new file mode 100644 index 000000000000..0969e5edd95e --- /dev/null +++ b/files/build/versions/dockers/docker-orchagent/versions-deb-buster @@ -0,0 +1,15 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libbabeltrace1==1.5.6-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libgpm2==1.20.7-5 +libipt2==2.0-2 +libsairedis-dbg==1.0.0 +libswsscommon-dbg==1.0.0 +openssh-client==1:7.9p1-10+deb10u2 +sshpass==1.06-1 +strace==4.26-0.2 +swss-dbg==1.0.0 +vim==2:8.1.0875-5 +vim-runtime==2:8.1.0875-5 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-platform-monitor/versions-deb-buster b/files/build/versions/dockers/docker-platform-monitor/versions-deb-buster new file mode 100644 index 000000000000..2789343f7e62 --- /dev/null +++ b/files/build/versions/dockers/docker-platform-monitor/versions-deb-buster @@ -0,0 +1,25 @@ +applibs==1.mlnx.4.4.2308 +applibs-dev==1.mlnx.4.4.2308 +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libbabeltrace1==1.5.6-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libgpm2==1.20.7-5 +libipt2==2.0-2 +libsensors5-dbgsym==1:3.5.0-3 +libswsscommon-dbg==1.0.0 +lm-sensors-dbgsym==1:3.5.0-3 +openssh-client==1:7.9p1-10+deb10u2 +python-sdk-api==1.mlnx.4.4.2308 +sensord-dbgsym==1:3.5.0-3 +sshpass==1.06-1 +strace==4.26-0.2 +sx-complib==1.mlnx.4.4.2308 +sx-complib-dev==1.mlnx.4.4.2308 +sx-gen-utils==1.mlnx.4.4.2308 +sx-gen-utils-dev==1.mlnx.4.4.2308 +sxd-libs==1.mlnx.4.4.2308 +sxd-libs-dev==1.mlnx.4.4.2308 +vim==2:8.1.0875-5 +vim-runtime==2:8.1.0875-5 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-router-advertiser/versions-deb-buster b/files/build/versions/dockers/docker-router-advertiser/versions-deb-buster new file mode 100644 index 000000000000..f8cf36dc0e12 --- /dev/null +++ b/files/build/versions/dockers/docker-router-advertiser/versions-deb-buster @@ -0,0 +1,12 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libbabeltrace1==1.5.6-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libgpm2==1.20.7-5 +libipt2==2.0-2 +openssh-client==1:7.9p1-10+deb10u2 +sshpass==1.06-1 +strace==4.26-0.2 +vim==2:8.1.0875-5 +vim-runtime==2:8.1.0875-5 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-sflow/versions-deb-buster b/files/build/versions/dockers/docker-sflow/versions-deb-buster new file mode 100644 index 000000000000..f8cf36dc0e12 --- /dev/null +++ b/files/build/versions/dockers/docker-sflow/versions-deb-buster @@ -0,0 +1,12 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libbabeltrace1==1.5.6-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libgpm2==1.20.7-5 +libipt2==2.0-2 +openssh-client==1:7.9p1-10+deb10u2 +sshpass==1.06-1 +strace==4.26-0.2 +vim==2:8.1.0875-5 +vim-runtime==2:8.1.0875-5 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-snmp/versions-deb-buster b/files/build/versions/dockers/docker-snmp/versions-deb-buster new file mode 100644 index 000000000000..8baa3d5cd96b --- /dev/null +++ b/files/build/versions/dockers/docker-snmp/versions-deb-buster @@ -0,0 +1,17 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libbabeltrace1==1.5.6-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libgpm2==1.20.7-5 +libipt2==2.0-2 +libsnmp-base==5.7.3+dfsg-5 +libsnmp30==5.7.3+dfsg-5 +libsnmp30-dbg==5.7.3+dfsg-5 +openssh-client==1:7.9p1-10+deb10u2 +snmp-dbgsym==5.7.3+dfsg-5 +snmpd-dbgsym==5.7.3+dfsg-5 +sshpass==1.06-1 +strace==4.26-0.2 +vim==2:8.1.0875-5 +vim-runtime==2:8.1.0875-5 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-sonic-mgmt-framework/versions-deb-buster b/files/build/versions/dockers/docker-sonic-mgmt-framework/versions-deb-buster new file mode 100644 index 000000000000..a29d8370e78a --- /dev/null +++ b/files/build/versions/dockers/docker-sonic-mgmt-framework/versions-deb-buster @@ -0,0 +1,13 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libbabeltrace1==1.5.6-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libgpm2==1.20.7-5 +libipt2==2.0-2 +openssh-client==1:7.9p1-10+deb10u2 +sonic-mgmt-framework-dbg==1.0-01 +sshpass==1.06-1 +strace==4.26-0.2 +vim==2:8.1.0875-5 +vim-runtime==2:8.1.0875-5 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-sonic-mgmt-framework/versions-py3 b/files/build/versions/dockers/docker-sonic-mgmt-framework/versions-py3 new file mode 100644 index 000000000000..494327b626b8 --- /dev/null +++ b/files/build/versions/dockers/docker-sonic-mgmt-framework/versions-py3 @@ -0,0 +1,2 @@ +six==1.11.0 +zipp==3.4.0 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-sonic-telemetry/versions-deb-buster b/files/build/versions/dockers/docker-sonic-telemetry/versions-deb-buster new file mode 100644 index 000000000000..f8cf36dc0e12 --- /dev/null +++ b/files/build/versions/dockers/docker-sonic-telemetry/versions-deb-buster @@ -0,0 +1,12 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libbabeltrace1==1.5.6-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libgpm2==1.20.7-5 +libipt2==2.0-2 +openssh-client==1:7.9p1-10+deb10u2 +sshpass==1.06-1 +strace==4.26-0.2 +vim==2:8.1.0875-5 +vim-runtime==2:8.1.0875-5 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-bfn/versions-deb-buster b/files/build/versions/dockers/docker-syncd-bfn/versions-deb-buster new file mode 100644 index 000000000000..79bde915fac7 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-bfn/versions-deb-buster @@ -0,0 +1,12 @@ +bfnplatform==1.0.0 +bfnsdk==1.0.0 +libcurl3-gnutls==7.64.0-4+deb10u1 +libcurl4-gnutls-dev==7.64.0-4+deb10u1 +libgoogle-perftools4==2.7-1 +liblzma-dev==5.2.4-1 +libpcap-dev==1.8.1-6 +libpcap0.8-dev==1.8.1-6 +libtcmalloc-minimal4==2.7-1 +libunwind-dev==1.2.1-10~deb10u1 +libusb-1.0-0==2:1.0.22-2 +libusb-1.0-0-dev==2:1.0.22-2 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-centec-rpc/versions-deb-buster b/files/build/versions/dockers/docker-syncd-centec-rpc/versions-deb-buster new file mode 100644 index 000000000000..e29438991e1b --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-centec-rpc/versions-deb-buster @@ -0,0 +1,58 @@ +binutils==2.31.1-16 +binutils-common==2.31.1-16 +binutils-x86-64-linux-gnu==2.31.1-16 +build-essential==12.6 +cmake==3.13.4-1 +cmake-data==3.13.4-1 +cpp==4:8.3.0-1 +cpp-8==8.3.0-6 +g++==4:8.3.0-1 +g++-8==8.3.0-6 +gcc==4:8.3.0-1 +gcc-8==8.3.0-6 +libarchive13==3.3.3-4+deb10u1 +libasan5==8.3.0-6 +libbinutils==2.31.1-16 +libboost-atomic1.67.0==1.67.0-13+deb10u1 +libboost-atomic1.71.0==1.71.0-6~bpo10+1 +libcc1-0==8.3.0-6 +libdouble-conversion1==3.1.0-3 +libdpkg-perl==1.19.7 +libexpat1-dev==2.2.6-2+deb10u1 +libffi-dev==3.2.1-9 +libgcc-8-dev==8.3.0-6 +libgomp1==8.3.0-6 +libisl19==0.20-2 +libitm1==8.3.0-6 +libjsoncpp1==1.7.4-3 +liblsan0==8.3.0-6 +libmpc3==1.1.0-1 +libmpfr6==4.0.2-1 +libmpx2==8.3.0-6 +libpcre2-16-0==10.32-5 +libpcre2-8-0==10.32-5 +libpython-dev==2.7.16-1 +libpython2-dev==2.7.16-1 +libpython2.7-dev==2.7.16-2+deb10u1 +libqt5core5a==5.11.3+dfsg1-1+deb10u4 +libqt5dbus5==5.11.3+dfsg1-1+deb10u4 +libqt5network5==5.11.3+dfsg1-1+deb10u4 +libquadmath0==8.3.0-6 +librhash0==1.3.8-1 +libssl-dev==1.1.1d-0+deb10u5 +libstdc++-8-dev==8.3.0-6 +libthrift-0.11.0==0.11.0-4 +libtsan0==8.3.0-6 +libubsan1==8.3.0-6 +libuv1==1.24.1-1 +make==4.2.1-1.2 +patch==2.7.6-3+deb10u1 +python-dev==2.7.16-1 +python-pip==18.1-5 +python-pip-whl==18.1-5 +python-ptf==0.9-1 +python-scapy==2.4.0-2 +python2-dev==2.7.16-1 +python2.7-dev==2.7.16-2+deb10u1 +syncd-rpc==1.0.0 +wget==1.20.1-1.1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-centec-rpc/versions-py2 b/files/build/versions/dockers/docker-syncd-centec-rpc/versions-py2 new file mode 100644 index 000000000000..f2d6dd3c856c --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-centec-rpc/versions-py2 @@ -0,0 +1,5 @@ +cffi==1.7.0 +nnpy==1.4.2 +ptf==0.9.1 +pycparser==2.20 +scapy==2.4.0 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-centec/versions-deb-buster b/files/build/versions/dockers/docker-syncd-centec/versions-deb-buster new file mode 100644 index 000000000000..74abbdb5bd6f --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-centec/versions-deb-buster @@ -0,0 +1,13 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libbabeltrace1==1.5.6-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libgpm2==1.20.7-5 +libipt2==2.0-2 +libsai==1.6.3-1 +openssh-client==1:7.9p1-10+deb10u2 +sshpass==1.06-1 +strace==4.26-0.2 +vim==2:8.1.0875-5 +vim-runtime==2:8.1.0875-5 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-invm/versions-deb-stretch b/files/build/versions/dockers/docker-syncd-invm/versions-deb-stretch new file mode 100644 index 000000000000..c9d822e1191a --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-invm/versions-deb-stretch @@ -0,0 +1,5 @@ +innovium-sai==0.11.1 +innovium-sai-headers==0.11.1 +libsaimetadata==1.0.0 +libsairedis==1.0.0 +syncd==1.0.0 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-mlnx-rpc/versions-deb-buster b/files/build/versions/dockers/docker-syncd-mlnx-rpc/versions-deb-buster new file mode 100644 index 000000000000..e29438991e1b --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-mlnx-rpc/versions-deb-buster @@ -0,0 +1,58 @@ +binutils==2.31.1-16 +binutils-common==2.31.1-16 +binutils-x86-64-linux-gnu==2.31.1-16 +build-essential==12.6 +cmake==3.13.4-1 +cmake-data==3.13.4-1 +cpp==4:8.3.0-1 +cpp-8==8.3.0-6 +g++==4:8.3.0-1 +g++-8==8.3.0-6 +gcc==4:8.3.0-1 +gcc-8==8.3.0-6 +libarchive13==3.3.3-4+deb10u1 +libasan5==8.3.0-6 +libbinutils==2.31.1-16 +libboost-atomic1.67.0==1.67.0-13+deb10u1 +libboost-atomic1.71.0==1.71.0-6~bpo10+1 +libcc1-0==8.3.0-6 +libdouble-conversion1==3.1.0-3 +libdpkg-perl==1.19.7 +libexpat1-dev==2.2.6-2+deb10u1 +libffi-dev==3.2.1-9 +libgcc-8-dev==8.3.0-6 +libgomp1==8.3.0-6 +libisl19==0.20-2 +libitm1==8.3.0-6 +libjsoncpp1==1.7.4-3 +liblsan0==8.3.0-6 +libmpc3==1.1.0-1 +libmpfr6==4.0.2-1 +libmpx2==8.3.0-6 +libpcre2-16-0==10.32-5 +libpcre2-8-0==10.32-5 +libpython-dev==2.7.16-1 +libpython2-dev==2.7.16-1 +libpython2.7-dev==2.7.16-2+deb10u1 +libqt5core5a==5.11.3+dfsg1-1+deb10u4 +libqt5dbus5==5.11.3+dfsg1-1+deb10u4 +libqt5network5==5.11.3+dfsg1-1+deb10u4 +libquadmath0==8.3.0-6 +librhash0==1.3.8-1 +libssl-dev==1.1.1d-0+deb10u5 +libstdc++-8-dev==8.3.0-6 +libthrift-0.11.0==0.11.0-4 +libtsan0==8.3.0-6 +libubsan1==8.3.0-6 +libuv1==1.24.1-1 +make==4.2.1-1.2 +patch==2.7.6-3+deb10u1 +python-dev==2.7.16-1 +python-pip==18.1-5 +python-pip-whl==18.1-5 +python-ptf==0.9-1 +python-scapy==2.4.0-2 +python2-dev==2.7.16-1 +python2.7-dev==2.7.16-2+deb10u1 +syncd-rpc==1.0.0 +wget==1.20.1-1.1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-mlnx-rpc/versions-py2 b/files/build/versions/dockers/docker-syncd-mlnx-rpc/versions-py2 new file mode 100644 index 000000000000..f2d6dd3c856c --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-mlnx-rpc/versions-py2 @@ -0,0 +1,5 @@ +cffi==1.7.0 +nnpy==1.4.2 +ptf==0.9.1 +pycparser==2.20 +scapy==2.4.0 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-mlnx/versions-deb-buster b/files/build/versions/dockers/docker-syncd-mlnx/versions-deb-buster new file mode 100644 index 000000000000..9a3346645c8d --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-mlnx/versions-deb-buster @@ -0,0 +1,21 @@ +applibs==1.mlnx.4.4.2308 +applibs-dev==1.mlnx.4.4.2308 +iproute2==1.mlnx.4.4.2308 +iproute2-dev==1.mlnx.4.4.2308 +libelf1==0.176-1.1 +mlnx-sai==1.mlnx.SAIRel1.18.1.0 +python-sdk-api==1.mlnx.4.4.2308 +sx-acl-helper==1.mlnx.4.4.2308 +sx-acl-helper-dev==1.mlnx.4.4.2308 +sx-complib==1.mlnx.4.4.2308 +sx-complib-dev==1.mlnx.4.4.2308 +sx-examples==1.mlnx.4.4.2308 +sx-examples-dev==1.mlnx.4.4.2308 +sx-gen-utils==1.mlnx.4.4.2308 +sx-gen-utils-dev==1.mlnx.4.4.2308 +sx-scew==1.mlnx.4.4.2308 +sx-scew-dev==1.mlnx.4.4.2308 +sxd-libs==1.mlnx.4.4.2308 +sxd-libs-dev==1.mlnx.4.4.2308 +wjh-libs==1.mlnx.4.4.2308 +wjh-libs-dev==1.mlnx.4.4.2308 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-nephos/versions-deb-stretch b/files/build/versions/dockers/docker-syncd-nephos/versions-deb-stretch new file mode 100644 index 000000000000..6494a41ddc7f --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-nephos/versions-deb-stretch @@ -0,0 +1,29 @@ +gdb==7.12-6 +gdbserver==7.12-6 +libbabeltrace-ctf1==1.5.1-1 +libbabeltrace1==1.5.1-1 +libbsd0==0.8.3-1 +libdw1==0.168-1 +libedit2==3.1-20160903-3 +libglib2.0-0==2.50.3-2+deb9u2 +libgpm2==1.20.4-6.2+b1 +libicu57==57.1-6+deb9u4 +libmpdec2==2.4.2-1 +libpopt0==1.16-10+b2 +libpython3.5==3.5.3-1+deb9u3 +libpython3.5-minimal==3.5.3-1+deb9u3 +libpython3.5-stdlib==3.5.3-1+deb9u3 +libsaimetadata==1.0.0 +libsaimetadata-dbg==1.0.0 +libsainps==1.5.0 +libsairedis==1.0.0 +libsairedis-dbg==1.0.0 +libswsscommon-dbg==1.0.0 +libxml2==2.9.4+dfsg1-2.2+deb9u3 +openssh-client==1:7.4p1-10+deb9u7 +sshpass==1.06-1 +strace==4.15-2 +syncd==1.0.0 +syncd-dbg==1.0.0 +vim==2:8.0.0197-4+deb9u3 +vim-runtime==2:8.0.0197-4+deb9u3 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-vs/versions-deb-buster b/files/build/versions/dockers/docker-syncd-vs/versions-deb-buster new file mode 100644 index 000000000000..abd21dae6b32 --- /dev/null +++ b/files/build/versions/dockers/docker-syncd-vs/versions-deb-buster @@ -0,0 +1,5 @@ +iproute2==4.20.0-2 +libsaivs==1.0.0 +libsaivs-dbg==1.0.0 +syncd-vs==1.0.0 +syncd-vs-dbg==1.0.0 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-teamd/versions-deb-buster b/files/build/versions/dockers/docker-teamd/versions-deb-buster new file mode 100644 index 000000000000..eeb36c01b260 --- /dev/null +++ b/files/build/versions/dockers/docker-teamd/versions-deb-buster @@ -0,0 +1,16 @@ +gdb==8.2.1-2+b3 +gdbserver==8.2.1-2+b3 +libbabeltrace1==1.5.6-2+deb10u1 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libgpm2==1.20.7-5 +libipt2==2.0-2 +libswsscommon-dbg==1.0.0 +libteam-utils-dbgsym==1.30-1 +libteamdctl0-dbgsym==1.30-1 +openssh-client==1:7.9p1-10+deb10u2 +sshpass==1.06-1 +strace==4.26-0.2 +swss-dbg==1.0.0 +vim==2:8.1.0875-5 +vim-runtime==2:8.1.0875-5 \ No newline at end of file diff --git a/files/build/versions/dockers/sonic-slave-buster/versions-deb-buster b/files/build/versions/dockers/sonic-slave-buster/versions-deb-buster new file mode 100644 index 000000000000..5ae65c86315a --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-buster/versions-deb-buster @@ -0,0 +1,1665 @@ +adwaita-icon-theme==3.30.1-1 +ant==1.10.5-2 +ant-optional==1.10.5-2 +apt-file==3.2.2 +apt-transport-https==1.8.2.2 +apt-utils==1.8.2.2 +arch-test==0.15-2+deb10u1 +asciidoctor==1.5.8-1 +aspell==0.60.7~20110707-6 +aspell-en==2018.04.16-0-1 +at==3.1.23-1 +at-spi2-core==2.30.0-7 +aufs-dkms==4.19+20190211-1 +aufs-tools==1:4.14+20190211-1 +augeas-lenses==1.11.0-3 +augeas-tools==1.11.0-3 +autoconf==2.69-11 +autoconf-archive==20180313-1 +autogen==1:5.18.12-4 +autogen-doc==1:5.18.12-4 +automake==1:1.16.1-4 +automake1.11==1:1.11.6-5 +autopoint==0.19.8.1-9 +autotools-dev==20180224.1 +bash-completion==1:2.8-6 +bc==1.07.1-2+b1 +bind9-host==1:9.11.5.P4+dfsg-5.1+deb10u3 +binfmt-support==2.2.0-2 +binutils==2.31.1-16 +binutils-common==2.31.1-16 +binutils-x86-64-linux-gnu==2.31.1-16 +bison==2:3.3.2.dfsg-1 +blt==2.5.3+dfsg-4 +bsd-mailx==8.1.2-0.20180807cvs-1 +bsdmainutils==11.1.2+b1 +build-essential==12.6 +byacc==20140715-1+b1 +bzip2==1.0.6-9.2~deb10u1 +bzip2-doc==1.0.6-9.2~deb10u1 +ca-certificates==20200601~deb10u2 +ca-certificates-java==20190405 +cdbs==0.4.159 +cgroupfs-mount==1.4 +check==0.10.0-3+b3 +chrpath==0.16-2+b1 +clang==1:7.0-47 +clang-7==1:7.0.1-8+deb10u2 +cm-super-minimal==0.3.4-14 +cmake==3.13.4-1 +cmake-data==3.13.4-1 +cmocka-doc==1.1.3-1 +comerr-dev==2.1-1.44.5-1+deb10u3 +containerd.io==1.4.3-1 +cowbuilder==0.88 +cowdancer==0.88 +cpio==2.12+dfsg-9 +cpp==4:8.3.0-1 +cpp-8==8.3.0-6 +cppcheck==1.86-1 +cron==3.0pl1-134+deb10u1 +curl==7.64.0-4+deb10u1 +dbus==1.12.20-0+deb10u1 +dbus-user-session==1.12.20-0+deb10u1 +dconf-gsettings-backend==0.30.1-2 +dconf-service==0.30.1-2 +dctrl-tools==2.24-3 +debhelper==12.1.1 +debian-keyring==2019.02.25 +debootstrap==1.0.114 +default-jdk-headless==2:1.11-71 +default-jre==2:1.11-71 +default-jre-headless==2:1.11-71 +default-libmysqlclient-dev==1.0.5 +device-tree-compiler==1.4.7-4 +devscripts==2.19.5+deb10u1 +dh-apparmor==2.13.2-10 +dh-autoreconf==19 +dh-exec==0.23.1 +dh-make==2.201802 +dh-python==3.20190308 +dh-strip-nondeterminism==1.1.2-1 +dh-systemd==12.1.1 +dictionaries-common==1.28.1 +diffstat==1.62-1 +dirmngr==2.2.12-1+deb10u1 +distro-info-data==0.41+deb10u3 +dkms==2.6.1-4 +dmeventd==2:1.02.155-3 +dmsetup==2:1.02.155-3 +dnsutils==1:9.11.5.P4+dfsg-5.1+deb10u3 +docker-ce==5:18.09.5~3-0~debian-buster +docker-ce-cli==5:18.09.5~3-0~debian-buster +docutils-common==0.14+dfsg-4 +docutils-doc==0.14+dfsg-4 +dosfstools==4.1-2 +doxygen==1.8.13-10 +dpatch==2.0.38+nmu1 +dpkg-dev==1.19.7 +dput==1.0.3 +dvipng==1.15-1.1 +dwz==0.12-3 +eatmydata==105-7 +emacsen-common==3.0.4 +equivs==2.2.0 +exim4-base==4.92-8+deb10u4 +exim4-config==4.92-8+deb10u4 +exim4-daemon-light==4.92-8+deb10u4 +expat==2.2.6-2+deb10u1 +exuberant-ctags==1:5.9~svn20110310-12 +fakeroot==1.23-1 +file==1:5.35-4+deb10u2 +flex==2.6.4-6.2 +fontconfig==2.13.1-2 +fontconfig-config==2.13.1-2 +fonts-dejavu-core==2.37-1 +fonts-dejavu-extra==2.37-1 +fonts-droid-fallback==1:6.0.1r16-1.1 +fonts-font-awesome==5.0.10+really4.7.0~dfsg-1 +fonts-glyphicons-halflings==1.009~3.4.1+dfsg-1 +fonts-lato==2.0-2 +fonts-liberation==1:1.07.4-9 +fonts-lmodern==2.004.5-6 +fonts-noto-mono==20181227-1 +fonts-roboto-slab==1.100263+20170512-1 +fonts-texgyre==20180621-3 +g++==4:8.3.0-1 +g++-8==8.3.0-6 +gawk==1:4.2.1+dfsg-1 +gcc==4:8.3.0-1 +gcc-8==8.3.0-6 +gcc-8-multilib==8.3.0-6 +gcc-multilib==4:8.3.0-1 +gcovr==4.1-2 +gdb==8.2.1-2+b3 +gem2deb==0.43 +gem2deb-test-runner==0.43 +geoip-database==20181108-1 +gettext==0.19.8.1-9 +gettext-base==0.19.8.1-9 +gfortran==4:8.3.0-1 +gfortran-8==8.3.0-6 +ghostscript==9.27~dfsg-2+deb10u4 +gir1.2-glib-2.0==1.58.3-2 +gir1.2-packagekitglib-1.0==1.1.12-5 +git==1:2.20.1-2+deb10u3 +git-buildpackage==0.9.14 +git-man==1:2.20.1-2+deb10u3 +glib-networking==2.58.0-2+deb10u2 +glib-networking-common==2.58.0-2+deb10u2 +glib-networking-services==2.58.0-2+deb10u2 +gnupg==2.2.12-1+deb10u1 +gnupg-l10n==2.2.12-1+deb10u1 +gnupg-utils==2.2.12-1+deb10u1 +gnupg2==2.2.12-1+deb10u1 +googletest==1.8.1-3 +gpg==2.2.12-1+deb10u1 +gpg-agent==2.2.12-1+deb10u1 +gpg-wks-client==2.2.12-1+deb10u1 +gpg-wks-server==2.2.12-1+deb10u1 +gpgconf==2.2.12-1+deb10u1 +gpgsm==2.2.12-1+deb10u1 +graphviz==2.40.1-6 +groff==1.22.4-3 +groff-base==1.22.4-3 +gsettings-desktop-schemas==3.28.1-1 +gsfonts==1:8.11+urwcyr1.0.7~pre44-4.4 +gstreamer1.0-libav==1.15.0.1+git20180723+db823502-2 +gstreamer1.0-plugins-base==1.14.4-2 +gstreamer1.0-plugins-good==1.14.4-1 +gstreamer1.0-plugins-ugly==1.14.4-1 +gstreamer1.0-x==1.14.4-2 +gtk-update-icon-cache==3.24.5-1 +guile-2.0-libs==2.0.13+1-5.1 +hicolor-icon-theme==0.17-2 +i965-va-driver==2.3.0+dfsg1-1 +ibverbs-providers==22.1-1 +icc-profiles-free==2.0.1+dfsg-1 +icu-devtools==63.1-6+deb10u1 +imagemagick==8:6.9.10.23+dfsg-2.1+deb10u1 +imagemagick-6-common==8:6.9.10.23+dfsg-2.1+deb10u1 +imagemagick-6.q16==8:6.9.10.23+dfsg-2.1+deb10u1 +install-info==6.5.0.dfsg.1-4+b1 +intel-media-va-driver==18.4.1+dfsg1-1 +intltool-debian==0.35.0+20060710.5 +iptables==1.8.2-4 +iptables-dev==1.8.2-4 +ipxe-qemu==1.0.0+git-20190125.36a4c85-1 +iso-codes==4.2-1 +java-common==0.71 +java-wrappers==0.3 +javahelper==0.72.9 +javascript-common==11 +kernel-wedge==2.99 +kmod==26-1 +krb5-locales==1.17-3+deb10u1 +krb5-multidev==1.17-3+deb10u1 +lcov==1.13-4 +less==487-0.1+b1 +lib32asan5==8.3.0-6 +lib32atomic1==8.3.0-6 +lib32gcc-8-dev==8.3.0-6 +lib32gcc1==1:8.3.0-6 +lib32gomp1==8.3.0-6 +lib32itm1==8.3.0-6 +lib32mpx2==8.3.0-6 +lib32quadmath0==8.3.0-6 +lib32stdc++6==8.3.0-6 +lib32ubsan1==8.3.0-6 +liba52-0.7.4==0.7.4-19 +libaa1==1.4p5-46 +libaacs0==0.9.0-2 +libaio1==0.3.112-3 +libalgorithm-diff-perl==1.19.03-2 +libalgorithm-diff-xs-perl==0.04-5+b1 +libalgorithm-merge-perl==0.08-3 +libaom0==1.0.0-3 +libaopalliance-java==20070526-6 +libapache-pom-java==18-1 +libapparmor1==2.13.2-10 +libappstream4==0.12.5-1 +libapt-inst2.0==1.8.2.2 +libapt-pkg-perl==0.1.34+b1 +libarchive-cpio-perl==0.10-1 +libarchive-zip-perl==1.64-1 +libarchive13==3.3.3-4+deb10u1 +libargon2-1==0~20171227-0.2 +libasan5==8.3.0-6 +libasm-java==7.0-1 +libasound2==1.1.8-1 +libasound2-data==1.1.8-1 +libaspell15==0.60.7~20110707-6 +libass9==1:0.14.0-2 +libassuan0==2.5.2-1 +libasync-mergepoint-perl==0.04-2 +libasyncns0==0.8-6 +libatinject-jsr330-api-java==1.0+ds1-5 +libatk-bridge2.0-0==2.30.0-5 +libatk-wrapper-java==0.33.3-22 +libatk-wrapper-java-jni==0.33.3-22 +libatk1.0-0==2.30.0-2 +libatk1.0-data==2.30.0-2 +libatm1==1:2.5.1-2 +libatm1-dev==1:2.5.1-2 +libatomic1==8.3.0-6 +libatspi2.0-0==2.30.0-7 +libaudio2==1.9.4-6 +libaudit-dev==1:2.8.4-3 +libaugeas0==1.11.0-3 +libauthen-sasl-perl==2.1600-1 +libavahi-client3==0.7-4+b1 +libavahi-common-data==0.7-4+b1 +libavahi-common3==0.7-4+b1 +libavalon-framework-java==4.2.0-10 +libavc1394-0==0.5.4-5 +libavcodec58==7:4.1.6-1~deb10u1 +libavfilter7==7:4.1.6-1~deb10u1 +libavformat58==7:4.1.6-1~deb10u1 +libavutil56==7:4.1.6-1~deb10u1 +libb-hooks-endofscope-perl==0.24-1 +libb-hooks-op-check-perl==0.22-1+b1 +libbabeltrace-dev==1.5.6-2+deb10u1 +libbabeltrace1==1.5.6-2+deb10u1 +libbatik-java==1.10-2+deb10u1 +libbdplus0==0.1.2-3 +libbind-export-dev==1:9.11.5.P4+dfsg-5.1+deb10u3 +libbind9-161==1:9.11.5.P4+dfsg-5.1+deb10u3 +libbinutils==2.31.1-16 +libbison-dev==2:3.3.2.dfsg-1 +libbit-vector-perl==7.4-1+b5 +libblkid-dev==2.33.1-0.1 +libbluetooth3==5.50-1.2~deb10u1 +libbluray2==1:1.1.0-1 +libboost-atomic1.71-dev==1.71.0-6~bpo10+1 +libboost-atomic1.71.0==1.71.0-6~bpo10+1 +libboost-chrono1.71-dev==1.71.0-6~bpo10+1 +libboost-chrono1.71.0==1.71.0-6~bpo10+1 +libboost-container1.71-dev==1.71.0-6~bpo10+1 +libboost-container1.71.0==1.71.0-6~bpo10+1 +libboost-context1.71-dev==1.71.0-6~bpo10+1 +libboost-context1.71.0==1.71.0-6~bpo10+1 +libboost-contract1.71-dev==1.71.0-6~bpo10+1 +libboost-contract1.71.0==1.71.0-6~bpo10+1 +libboost-coroutine1.71-dev==1.71.0-6~bpo10+1 +libboost-coroutine1.71.0==1.71.0-6~bpo10+1 +libboost-date-time1.71-dev==1.71.0-6~bpo10+1 +libboost-date-time1.71.0==1.71.0-6~bpo10+1 +libboost-fiber1.71-dev==1.71.0-6~bpo10+1 +libboost-fiber1.71.0==1.71.0-6~bpo10+1 +libboost-filesystem1.71-dev==1.71.0-6~bpo10+1 +libboost-filesystem1.71.0==1.71.0-6~bpo10+1 +libboost-graph-parallel1.71-dev==1.71.0-6~bpo10+1 +libboost-graph-parallel1.71.0==1.71.0-6~bpo10+1 +libboost-log1.71-dev==1.71.0-6~bpo10+1 +libboost-log1.71.0==1.71.0-6~bpo10+1 +libboost-mpi1.71.0==1.71.0-6~bpo10+1 +libboost-program-options1.71-dev==1.71.0-6~bpo10+1 +libboost-program-options1.71.0==1.71.0-6~bpo10+1 +libboost-regex1.71-dev==1.71.0-6~bpo10+1 +libboost-regex1.71.0==1.71.0-6~bpo10+1 +libboost-serialization1.71-dev==1.71.0-6~bpo10+1 +libboost-serialization1.71.0==1.71.0-6~bpo10+1 +libboost-system1.71-dev==1.71.0-6~bpo10+1 +libboost-system1.71.0==1.71.0-6~bpo10+1 +libboost-test1.71-dev==1.71.0-6~bpo10+1 +libboost-test1.71.0==1.71.0-6~bpo10+1 +libboost-thread1.71-dev==1.71.0-6~bpo10+1 +libboost-thread1.71.0==1.71.0-6~bpo10+1 +libboost1.71-dev==1.71.0-6~bpo10+1 +libbrlapi0.6==5.6-10+deb10u1 +libbrotli1==1.0.7-2+deb10u1 +libbs2b0==3.1.0+dfsg-2.2 +libbsd-dev==0.9.1-2 +libbsd0==0.9.1-2 +libbsh-java==2.0b4-19 +libbz2-dev==1.0.6-9.2~deb10u1 +libc-ares-dev==1.14.0-1 +libc-ares2==1.14.0-1 +libc-dev-bin==2.28-10 +libc6-dbg==2.28-10 +libc6-dev==2.28-10 +libc6-dev-i386==2.28-10 +libc6-dev-x32==2.28-10 +libc6-i386==2.28-10 +libc6-x32==2.28-10 +libcaca0==0.99.beta19-2.1 +libcacard0==1:2.6.1-1 +libcaf-openmpi-3==2.4.0-2 +libcairo-gobject2==1.16.0-4+deb10u1 +libcairo2==1.16.0-4+deb10u1 +libcap-dev==1:2.25-2 +libcap-ng-dev==0.7.9-2 +libcapstone3==4.0.1+really+3.0.5-1 +libcapture-tiny-perl==0.48-1 +libcarp-clan-perl==6.07-1 +libcc1-0==8.3.0-6 +libcdi-api-java==1.2-2 +libcdio18==2.0.0-2 +libcdparanoia0==3.10.2+debian-13 +libcdt5==2.40.1-6 +libcgi-fast-perl==1:2.13-1 +libcgi-pm-perl==4.40-1 +libcglib-java==3.2.10-1 +libcgraph6==2.40.1-6 +libchromaprint1==1.4.3-3 +libclang-common-7-dev==1:7.0.1-8+deb10u2 +libclang1-6.0==1:6.0.1-10 +libclang1-7==1:7.0.1-8+deb10u2 +libclass-accessor-perl==0.51-1 +libclass-inspector-perl==1.32-1 +libclass-method-modifiers-perl==2.12-1 +libclass-xsaccessor-perl==1.19-3+b2 +libclone-perl==0.41-1+b1 +libcmocka-dev==1.1.3-1 +libcmocka0==1.1.3-1 +libcoarrays-dev==2.4.0-2 +libcoarrays-openmpi-dev==2.4.0-2 +libcodec2-0.8.1==0.8.1-2 +libcolord2==1.4.3-4 +libcommon-sense-perl==3.74-2+b7 +libcommons-beanutils-java==1.9.3-1 +libcommons-cli-java==1.4-1 +libcommons-codec-java==1.11-1 +libcommons-collections3-java==3.2.2-2 +libcommons-compress-java==1.18-2+deb10u1 +libcommons-configuration-java==1.10-5 +libcommons-digester-java==1.8.1-5 +libcommons-io-java==2.6-2 +libcommons-lang-java==2.6-8 +libcommons-lang3-java==3.8-2 +libcommons-logging-java==1.2-2 +libcommons-parent-java==43-1 +libcommons-validator-java==1:1.6-2 +libconst-fast-perl==0.014-1 +libcontextual-return-perl==0.004014-2 +libconvert-binhex-perl==1.125-1 +libcroco3==0.6.12-3 +libcryptsetup12==2:2.1.0-5+deb10u2 +libcrystalhd3==1:0.0~git20110715.fdd2f19-13 +libcups2==2.2.10-6+deb10u4 +libcupsfilters1==1.21.6-5 +libcupsimage2==2.2.10-6+deb10u4 +libcurl3-gnutls==7.64.0-4+deb10u1 +libcurl3-nss==7.64.0-4+deb10u1 +libcurl4==7.64.0-4+deb10u1 +libcurl4-nss-dev==7.64.0-4+deb10u1 +libdaemon-dev==0.14-7 +libdaemon0==0.14-7 +libdata-dump-perl==1.23-1 +libdata-optlist-perl==0.110-1 +libdatrie1==0.2.12-2 +libdb-dev==5.3.1+nmu1 +libdb5.3-dev==5.3.28+dfsg1-0.5 +libdbi1==0.9.0-5 +libdbus-1-3==1.12.20-0+deb10u1 +libdbus-1-dev==1.12.20-0+deb10u1 +libdconf1==0.30.1-2 +libde265-0==1.0.3-1+b1 +libdevel-callchecker-perl==0.008-1 +libdevel-globaldestruction-perl==0.14-1 +libdevmapper-event1.02.1==2:1.02.155-3 +libdevmapper1.02.1==2:1.02.155-3 +libdigest-bubblebabble-perl==0.02-2 +libdigest-hmac-perl==1.03+dfsg-2 +libdistro-info-perl==0.21 +libdjvulibre-text==3.5.27.1-10 +libdjvulibre21==3.5.27.1-10 +libdns-export1104==1:9.11.5.P4+dfsg-5.1+deb10u3 +libdns1104==1:9.11.5.P4+dfsg-5.1+deb10u3 +libdom4j-java==2.1.1-2 +libdouble-conversion1==3.1.0-3 +libdoxia-core-java==1.7-2 +libdoxia-java==1.7-2 +libdoxia-sitetools-java==1.7.5-1 +libdpkg-perl==1.19.7 +libdrm-amdgpu1==2.4.97-1 +libdrm-common==2.4.97-1 +libdrm-dev==2.4.97-1 +libdrm-intel1==2.4.97-1 +libdrm-nouveau2==2.4.97-1 +libdrm-radeon1==2.4.97-1 +libdrm2==2.4.97-1 +libdv4==1.0.0-12 +libdvdnav4==6.0.0-1 +libdvdread4==6.0.1-1 +libdw-dev==0.176-1.1 +libdw1==0.176-1.1 +libdynaloader-functions-perl==0.003-1 +libeatmydata1==105-7 +libedit-dev==3.1-20181209-1 +libedit2==3.1-20181209-1 +libegl-mesa0==18.3.6-2+deb10u1 +libegl1==1.1.0-1 +libel-api-java==3.0.0-2+deb10u1 +libelf-dev==0.176-1.1 +libemail-valid-perl==1.202-1 +libencode-locale-perl==1.05-1 +libepoxy0==1.5.3-0.1 +liberror-perl==0.17027-2 +libestr0==0.1.10-2.1 +libevdev2==1.6.0+dfsg-1 +libevent-2.1-6==2.1.8-stable-4 +libevent-core-2.1-6==2.1.8-stable-4 +libevent-dev==2.1.8-stable-4 +libevent-extra-2.1-6==2.1.8-stable-4 +libevent-openssl-2.1-6==2.1.8-stable-4 +libevent-pthreads-2.1-6==2.1.8-stable-4 +libexpat1==2.2.6-2+deb10u1 +libexpat1-dev==2.2.6-2+deb10u1 +libexplain-dev==1.4.D001-8 +libexplain51==1.4.D001-8 +libexporter-tiny-perl==1.002001-1 +libfabric1==1.6.2-3 +libfakeroot==1.23-1 +libfastjson4==0.99.8-2 +libfcgi-perl==0.78-2+b3 +libfdt1==1.4.7-4 +libffi-dev==3.2.1-9 +libfftw3-double3==3.3.8-2 +libfile-basedir-perl==0.08-1 +libfile-chdir-perl==0.1008-1 +libfile-desktopentry-perl==0.22-1 +libfile-fcntllock-perl==0.22-3+b5 +libfile-homedir-perl==1.004-1 +libfile-listing-perl==6.04-1 +libfile-mimeinfo-perl==0.29-1 +libfile-stripnondeterminism-perl==1.1.2-1 +libfile-which-perl==1.23-1 +libfl-dev==2.6.4-6.2 +libfl2==2.6.4-6.2 +libflac8==1.3.2-3 +libflite1==2.1-release-3 +libfont-afm-perl==1.20-2 +libfontbox2-java==2.0.13-2 +libfontconfig1==2.13.1-2 +libfontenc1==1:1.1.3-1+b2 +libfop-java==1:2.3-2 +libfreetype6==2.9.1-3+deb10u2 +libfribidi0==1.0.5-3.1+deb10u1 +libfstrm0==0.4.0-1 +libfuture-perl==0.39-1 +libgail-common==2.24.32-3 +libgail18==2.24.32-3 +libgbm1==18.3.6-2+deb10u1 +libgc1c2==1:7.6.4-0.4 +libgcc-8-dev==8.3.0-6 +libgd-perl==2.71-2 +libgd3==2.2.5-5.2 +libgdbm-compat4==1.18.1-4 +libgdbm6==1.18.1-4 +libgdk-pixbuf2.0-0==2.38.1+dfsg-1 +libgdk-pixbuf2.0-bin==2.38.1+dfsg-1 +libgdk-pixbuf2.0-common==2.38.1+dfsg-1 +libgeoip1==1.6.12-1 +libgeronimo-annotation-1.3-spec-java==1.0-1 +libgeronimo-interceptor-3.0-spec-java==1.0.1-4 +libgetopt-long-descriptive-perl==0.103-2 +libgfortran-8-dev==8.3.0-6 +libgfortran5==8.3.0-6 +libgif7==5.1.4-3 +libgirepository-1.0-1==1.58.3-2 +libgit-wrapper-perl==0.048-1 +libgitlab-api-v4-perl==0.16-1 +libgl1==1.1.0-1 +libgl1-mesa-dev==18.3.6-2+deb10u1 +libgl1-mesa-dri==18.3.6-2+deb10u1 +libglapi-mesa==18.3.6-2+deb10u1 +libgles1==1.1.0-1 +libgles2==1.1.0-1 +libglib2.0-0==2.58.3-2+deb10u2 +libglib2.0-bin==2.58.3-2+deb10u2 +libglib2.0-data==2.58.3-2+deb10u2 +libglib2.0-dev==2.58.3-2+deb10u2 +libglib2.0-dev-bin==2.58.3-2+deb10u2 +libglu1-mesa==9.0.0-2.1+b3 +libglu1-mesa-dev==9.0.0-2.1+b3 +libglvnd-core-dev==1.1.0-1 +libglvnd-dev==1.1.0-1 +libglvnd0==1.1.0-1 +libglx-mesa0==18.3.6-2+deb10u1 +libglx0==1.1.0-1 +libgme0==0.6.2-1 +libgmp-dev==2:6.1.2+dfsg-4 +libgmpxx4ldbl==2:6.1.2+dfsg-4 +libgnutls-dane0==3.6.7-4+deb10u6 +libgnutls-openssl27==3.6.7-4+deb10u6 +libgnutls28-dev==3.6.7-4+deb10u6 +libgnutlsxx28==3.6.7-4+deb10u6 +libgomp1==8.3.0-6 +libgoogle-perftools4==2.7-1 +libgpgme11==1.12.0-6 +libgpm2==1.20.7-5 +libgraphite2-3==1.3.13-7 +libgs9==9.27~dfsg-2+deb10u4 +libgs9-common==9.27~dfsg-2+deb10u4 +libgsm1==1.0.18-2 +libgssapi-krb5-2==1.17-3+deb10u1 +libgssrpc4==1.17-3+deb10u1 +libgstreamer-plugins-base1.0-0==1.14.4-2 +libgstreamer1.0-0==1.14.4-1 +libgtest-dev==1.8.1-3 +libgtk-3-0==3.24.5-1 +libgtk-3-bin==3.24.5-1 +libgtk-3-common==3.24.5-1 +libgtk2.0-0==2.24.32-3 +libgtk2.0-bin==2.24.32-3 +libgtk2.0-common==2.24.32-3 +libgts-0.7-5==0.7.6+darcs121130-4 +libgts-bin==0.7.6+darcs121130-4 +libguava-java==19.0-1 +libgudev-1.0-0==232-2 +libguice-java==4.2.1-1 +libgvc6==2.40.1-6 +libgvpr2==2.40.1-6 +libharfbuzz-icu0==2.3.1-1 +libharfbuzz0b==2.3.1-1 +libhawtjni-runtime-java==1.16-1 +libheif1==1.3.2-2~deb10u1 +libhtml-form-perl==6.03-1 +libhtml-format-perl==2.12-1 +libhtml-parser-perl==3.72-3+b3 +libhtml-tagset-perl==3.20-3 +libhtml-tree-perl==5.07-2 +libhttp-cookies-perl==6.04-1 +libhttp-daemon-perl==6.01-3 +libhttp-date-perl==6.02-1 +libhttp-message-perl==6.18-1 +libhttp-negotiate-perl==6.01-1 +libhttp-tiny-multipart-perl==0.08-1 +libhttpclient-java==4.5.7-1+deb10u1 +libhttpcore-java==4.4.11-1 +libhwloc-dev==1.11.12-3 +libhwloc-plugins==1.11.12-3 +libhwloc5==1.11.12-3 +libiberty-dev==20190122-1 +libibverbs-dev==22.1-1 +libibverbs1==22.1-1 +libice-dev==2:1.0.9-2 +libice6==2:1.0.9-2 +libicu-dev==63.1-6+deb10u1 +libicu63==63.1-6+deb10u1 +libidn11==1.33-2.2 +libidn2-dev==2.0.5-1+deb10u1 +libiec61883-0==1.2.0-3 +libigdgmm5==18.4.1+ds1-1 +libijs-0.35==0.35-14 +libilmbase23==2.2.1-2 +libimagequant0==2.12.2-1.1 +libimport-into-perl==1.002005-1 +libinput-bin==1.12.6-2+deb10u1 +libinput10==1.12.6-2+deb10u1 +libio-async-perl==0.72-1 +libio-html-perl==1.001-1 +libio-prompter-perl==0.004015-1 +libio-pty-perl==1:1.08-1.1+b5 +libio-sessiondata-perl==1.03-1 +libio-socket-ssl-perl==2.060-3 +libio-string-perl==1.08-3 +libio-stringy-perl==2.111-3 +libip4tc-dev==1.8.2-4 +libip4tc0==1.8.2-4 +libip6tc-dev==1.8.2-4 +libip6tc0==1.8.2-4 +libipc-run-perl==20180523.0-1 +libipc-system-simple-perl==1.25-4 +libipt2==2.0-2 +libiptc-dev==1.8.2-4 +libiptc0==1.8.2-4 +libirs-export161==1:9.11.5.P4+dfsg-5.1+deb10u3 +libirs161==1:9.11.5.P4+dfsg-5.1+deb10u3 +libisc-export1100==1:9.11.5.P4+dfsg-5.1+deb10u3 +libisc1100==1:9.11.5.P4+dfsg-5.1+deb10u3 +libisccc-export161==1:9.11.5.P4+dfsg-5.1+deb10u3 +libisccc161==1:9.11.5.P4+dfsg-5.1+deb10u3 +libisccfg-export163==1:9.11.5.P4+dfsg-5.1+deb10u3 +libisccfg163==1:9.11.5.P4+dfsg-5.1+deb10u3 +libisl19==0.20-2 +libitext1-java==1.4-7 +libitm1==8.3.0-6 +libjack-jackd2-0==1.9.12~dfsg-2 +libjansi-java==1.17.1-1 +libjansi-native-java==1.8-1 +libjansson-dev==2.12-1 +libjansson4==2.12-1 +libjaxen-java==1.1.6-4 +libjaxp1.3-java==1.3.05-5 +libjbig0==2.1-3.1+b2 +libjbig2dec0==0.16-1 +libjemalloc-dev==5.1.0-3 +libjemalloc2==5.1.0-3 +libjetty9-java==9.4.15-1 +libjpeg62-turbo==1:1.5.2-2+deb10u1 +libjs-bootstrap==3.4.1+dfsg-1 +libjs-jquery==3.3.1~dfsg-3 +libjs-jquery-hotkeys==0~20130707+git2d51e3a9+dfsg-2 +libjs-jquery-isonscreen==1.2.0-1 +libjs-jquery-metadata==12-1.1 +libjs-jquery-tablesorter==1:2.31.1+dfsg1-1 +libjs-jquery-throttle-debounce==1.1+dfsg.1-1 +libjs-modernizr==2.6.2+ds1-3 +libjs-sphinxdoc==1.8.4-1 +libjs-underscore==1.9.1~dfsg-1 +libjson-c-dev==0.12.1+ds-2+deb10u1 +libjson-c3==0.12.1+ds-2+deb10u1 +libjson-glib-1.0-0==1.4.4-2 +libjson-glib-1.0-common==1.4.4-2 +libjson-perl==4.02000-1 +libjson-xs-perl==3.040-1+b1 +libjsoncpp1==1.7.4-3 +libjsp-api-java==2.3.4-2+deb10u1 +libjsr305-java==0.1~+svn49-11 +libjtidy-java==7+svn20110807-5 +libjudy-dev==1.0.5-5 +libjudydebian1==1.0.5-5 +libjxr-tools==1.1-6+b1 +libjxr0==1.1-6+b1 +libk5crypto3==1.17-3+deb10u1 +libkadm5clnt-mit11==1.17-3+deb10u1 +libkadm5srv-mit11==1.17-3+deb10u1 +libkdb5-9==1.17-3+deb10u1 +libkeyutils1==1.6-6 +libkmod2==26-1 +libkpathsea6==2018.20181218.49446-1 +libkrb5-3==1.17-3+deb10u1 +libkrb5-dev==1.17-3+deb10u1 +libkrb5support0==1.17-3+deb10u1 +libksba8==1.3.5-2 +liblab-gamut1==2.40.1-6 +liblcms2-2==2.9-3 +libldap-2.4-2==2.4.47+dfsg-3+deb10u6 +libldap-common==2.4.47+dfsg-3+deb10u6 +libldap2-dev==2.4.47+dfsg-3+deb10u6 +liblilv-0-0==0.24.2~dfsg0-2 +liblist-compare-perl==0.53-1 +liblist-moreutils-perl==0.416-1+b4 +libllvm6.0==1:6.0.1-10 +libllvm7==1:7.0.1-8+deb10u2 +liblmdb0==0.9.22-1 +liblocale-gettext-perl==1.07-3+b4 +liblockfile-bin==1.14-1.1 +liblockfile1==1.14-1.1 +liblog-any-adapter-screen-perl==0.140-1 +liblog-any-perl==1.707-1 +liblog4j1.2-java==1.2.17-8+deb10u1 +liblognorm5==2.0.5-1 +liblqr-1-0==0.4.2-2.1 +liblsan0==8.3.0-6 +libltdl-dev==2.4.6-9 +libltdl7==2.4.6-9 +liblua5.1-0==5.1.5-8.1+b2 +liblua5.1-0-dev==5.1.5-8.1+b2 +liblvm2cmd2.03==2.03.02-3 +liblwp-mediatypes-perl==6.02-1 +liblwp-protocol-https-perl==6.07-2 +liblwres161==1:9.11.5.P4+dfsg-5.1+deb10u3 +liblzma-dev==5.2.4-1 +liblzo2-2==2.10-0.1 +liblzo2-dev==2.10-0.1 +libmagic-mgc==1:5.35-4+deb10u2 +libmagic1==1:5.35-4+deb10u2 +libmagickcore-6.q16-6==8:6.9.10.23+dfsg-2.1+deb10u1 +libmagickcore-6.q16-6-extra==8:6.9.10.23+dfsg-2.1+deb10u1 +libmagickwand-6.q16-6==8:6.9.10.23+dfsg-2.1+deb10u1 +libmail-sendmail-perl==0.80-1 +libmailtools-perl==2.18-1 +libmariadb-dev==1:10.3.27-0+deb10u1 +libmariadb-dev-compat==1:10.3.27-0+deb10u1 +libmariadb3==1:10.3.27-0+deb10u1 +libmaven-archiver-java==3.2.0-2 +libmaven-clean-plugin-java==3.1.0-1 +libmaven-common-artifact-filters-java==3.0.1-3 +libmaven-compiler-plugin-java==3.8.0-2 +libmaven-filtering-java==3.1.1-1 +libmaven-jar-plugin-java==3.1.1-1 +libmaven-parent-java==31-2 +libmaven-plugin-tools-java==3.6.0-1 +libmaven-reporting-api-java==3.0-1 +libmaven-reporting-exec-java==1.4-2 +libmaven-reporting-impl-java==3.0.0-2 +libmaven-resolver-java==1.3.1-1 +libmaven-resources-plugin-java==3.1.0-1 +libmaven-shared-incremental-java==1.1-3 +libmaven-shared-utils-java==3.3.0-1 +libmaven-site-plugin-java==3.6-3 +libmaven3-core-java==3.6.0-1 +libmime-tools-perl==5.509-1 +libmng1==1.0.10+dfsg-3.1+b5 +libmnl-dev==1.0.4-2 +libmodule-implementation-perl==0.09-1 +libmodule-runtime-perl==0.016-1 +libmoo-perl==2.003004-2 +libmount-dev==2.33.1-0.1 +libmp3lame0==3.100-2+b1 +libmpc3==1.1.0-1 +libmpdec2==2.4.2-2 +libmpeg2-4==0.5.1-8 +libmpfr6==4.0.2-1 +libmpg123-0==1.25.10-2 +libmpx2==8.3.0-6 +libmtdev1==1.1.5-1+b1 +libmysofa0==0.6~dfsg0-3+deb10u1 +libnamespace-clean-perl==0.27-1 +libnanomsg-dev==1.1.5+dfsg-1 +libnanomsg5==1.1.5+dfsg-1 +libncurses-dev==6.1+20181013-2+deb10u2 +libncurses5-dev==6.1+20181013-2+deb10u2 +libncurses6==6.1+20181013-2+deb10u2 +libnet-dbus-perl==1.1.0-5+b1 +libnet-dns-perl==1.19-1 +libnet-dns-sec-perl==1.11-1 +libnet-domain-tld-perl==1.75-1 +libnet-http-perl==6.18-1 +libnet-ip-perl==1.26-2 +libnet-libidn-perl==0.12.ds-3+b1 +libnet-smtp-ssl-perl==1.04-1 +libnet-ssleay-perl==1.85-2+b1 +libnetfilter-conntrack-dev==1.0.7-1 +libnetfilter-conntrack3==1.0.7-1 +libnetpbm10==2:10.0-15.3+b2 +libnewt-dev==0.52.20-8 +libnewt0.52==0.52.20-8 +libnfnetlink-dev==1.0.1-3+b1 +libnfnetlink0==1.0.1-3+b1 +libnftables0==0.9.0-2 +libnftnl-dev==1.1.2-2 +libnftnl11==1.1.2-2 +libnghttp2-14==1.36.0-2+deb10u1 +libnl-3-200==3.4.0-1 +libnl-3-dev==3.4.0-1 +libnl-route-3-200==3.4.0-1 +libnl-route-3-dev==3.4.0-1 +libnorm-dev==1.5.8+dfsg2-1 +libnorm1==1.5.8+dfsg2-1 +libnpth0==1.6-1 +libnspr4==2:4.20-1 +libnss-systemd==241-7~deb10u6 +libnss3==2:3.42.1-1+deb10u3 +libnuma-dev==2.0.12-1 +libnuma1==2.0.12-1 +libnumber-compare-perl==0.03-1 +libnumber-range-perl==0.12-1 +libobjc-8-dev==8.3.0-6 +libobjc4==8.3.0-6 +libogg0==1.3.2-1+b1 +libomp-7-dev==1:7.0.1-8+deb10u2 +libomp5-7==1:7.0.1-8+deb10u2 +libopencore-amrnb0==0.1.3-2.1+b2 +libopencore-amrwb0==0.1.3-2.1+b2 +libopencsd-dev==0.10.1-1 +libopencsd0==0.10.1-1 +libopenexr23==2.2.1-4.1+deb10u1 +libopengl0==1.1.0-1 +libopenjp2-7==2.3.0-2+deb10u1 +libopenmpi-dev==3.1.3-11 +libopenmpi3==3.1.3-11 +libopenmpt0==0.4.3-1+deb10u1 +libopts25==1:5.18.12-4 +libopts25-dev==1:5.18.12-4 +libopus0==1.3-1 +liborc-0.4-0==1:0.4.28-3.1 +liboro-java==2.0.8a-13 +libosp5==1.5.2-13+b1 +libossp-uuid-perl==1.6.2-1.5+b7 +libossp-uuid16==1.6.2-1.5+b7 +libp11-kit-dev==0.23.15-2+deb10u1 +libpackage-stash-perl==0.38-1 +libpackage-stash-xs-perl==0.29-1 +libpackagekit-glib2-18==1.1.12-5 +libpam-systemd==241-7~deb10u6 +libpam0g-dev==1.3.1-5 +libpango-1.0-0==1.42.4-8~deb10u1 +libpangocairo-1.0-0==1.42.4-8~deb10u1 +libpangoft2-1.0-0==1.42.4-8~deb10u1 +libpaper-utils==1.1.28 +libpaper1==1.1.28 +libparams-classify-perl==0.015-1+b1 +libparams-util-perl==1.07-3+b4 +libparams-validate-perl==1.29-1+b1 +libparboiled-java==1.1.7-2 +libparse-debianchangelog-perl==1.2.0-13 +libpath-iterator-rule-perl==1.014-1 +libpath-tiny-perl==0.108-1 +libpathplan4==2.40.1-6 +libpcap-dev==1.8.1-6 +libpcap0.8==1.8.1-6 +libpcap0.8-dev==1.8.1-6 +libpci-dev==1:3.5.2-1 +libpci3==1:3.5.2-1 +libpciaccess0==0.14-1 +libpcre16-3==2:8.39-12 +libpcre2-16-0==10.32-5 +libpcre2-8-0==10.32-5 +libpcre3-dev==2:8.39-12 +libpcre32-3==2:8.39-12 +libpcrecpp0v5==2:8.39-12 +libpcsclite1==1.8.24-1 +libpegdown-java==1.6.0-1 +libperl-dev==5.28.1-6+deb10u1 +libperl5.28==5.28.1-6+deb10u1 +libperlio-gzip-perl==0.19-1+b5 +libpgm-5.2-0==5.2.122~dfsg-3 +libpgm-dev==5.2.122~dfsg-3 +libpipeline1==1.5.1-2 +libpixman-1-0==0.36.0-1 +libplexus-ant-factory-java==1.0~alpha2.1-4 +libplexus-archiver-java==3.6.0-2 +libplexus-bsh-factory-java==1.0~alpha7-4 +libplexus-build-api-java==0.0.7-3 +libplexus-cipher-java==1.7-3 +libplexus-classworlds-java==2.6.0-1 +libplexus-compiler-java==2.8.5-1 +libplexus-component-annotations-java==1.7.1-7 +libplexus-container-default-java==1.7.1-7 +libplexus-container-default1.5-java==1.7.1-7 +libplexus-i18n-java==1.0-beta-10-5 +libplexus-interpolation-java==1.25-1 +libplexus-io-java==3.1.1-1 +libplexus-languages-java==0.9.10-1 +libplexus-sec-dispatcher-java==1.4-4 +libplexus-utils2-java==3.1.1-1 +libplexus-velocity-java==1.2-3 +libpmix2==3.1.2-3 +libpng-dev==1.6.36-6 +libpng16-16==1.6.36-6 +libpod-constants-perl==0.19-1 +libpolkit-agent-1-0==0.105-25 +libpolkit-backend-1-0==0.105-25 +libpolkit-gobject-1-0==0.105-25 +libpopt0==1.16-12 +libpostproc55==7:4.1.6-1~deb10u1 +libpotrace0==1.15-1 +libprocps7==2:3.3.15-2 +libprotobuf-c1==1.3.1-1+b1 +libprotobuf-dev==3.6.1.3-2 +libprotobuf-lite17==3.6.1.3-2 +libprotobuf17==3.6.1.3-2 +libprotoc17==3.6.1.3-2 +libproxy1v5==0.4.15-5+deb10u1 +libpsl5==0.20.2-2 +libpsm-infinipath1==3.3+20.604758e7-6 +libpsm2-2==11.2.78-1 +libptexenc1==2018.20181218.49446-1 +libpthread-stubs0-dev==0.4-1 +libpulse0==12.2-4+deb10u1 +libpython-all-dev==2.7.16-1 +libpython-dev==2.7.16-1 +libpython-stdlib==2.7.16-1 +libpython2-dev==2.7.16-1 +libpython2-stdlib==2.7.16-1 +libpython2.7==2.7.16-2+deb10u1 +libpython2.7-dev==2.7.16-2+deb10u1 +libpython2.7-minimal==2.7.16-2+deb10u1 +libpython2.7-stdlib==2.7.16-2+deb10u1 +libpython3-all-dbg==3.7.3-1 +libpython3-all-dev==3.7.3-1 +libpython3-dbg==3.7.3-1 +libpython3-dev==3.7.3-1 +libpython3-stdlib==3.7.3-1 +libpython3.7==3.7.3-2+deb10u2 +libpython3.7-dbg==3.7.3-2+deb10u2 +libpython3.7-dev==3.7.3-2+deb10u2 +libpython3.7-minimal==3.7.3-2+deb10u2 +libpython3.7-stdlib==3.7.3-2+deb10u2 +libqdox-java==1.12.1-3 +libqdox2-java==2.0~M10-1 +libqt4-dbus==4:4.8.7+dfsg-18+deb10u1 +libqt4-declarative==4:4.8.7+dfsg-18+deb10u1 +libqt4-designer==4:4.8.7+dfsg-18+deb10u1 +libqt4-dev==4:4.8.7+dfsg-18+deb10u1 +libqt4-dev-bin==4:4.8.7+dfsg-18+deb10u1 +libqt4-help==4:4.8.7+dfsg-18+deb10u1 +libqt4-network==4:4.8.7+dfsg-18+deb10u1 +libqt4-opengl==4:4.8.7+dfsg-18+deb10u1 +libqt4-opengl-dev==4:4.8.7+dfsg-18+deb10u1 +libqt4-qt3support==4:4.8.7+dfsg-18+deb10u1 +libqt4-script==4:4.8.7+dfsg-18+deb10u1 +libqt4-scripttools==4:4.8.7+dfsg-18+deb10u1 +libqt4-sql==4:4.8.7+dfsg-18+deb10u1 +libqt4-sql-mysql==4:4.8.7+dfsg-18+deb10u1 +libqt4-svg==4:4.8.7+dfsg-18+deb10u1 +libqt4-test==4:4.8.7+dfsg-18+deb10u1 +libqt4-xml==4:4.8.7+dfsg-18+deb10u1 +libqt4-xmlpatterns==4:4.8.7+dfsg-18+deb10u1 +libqt5concurrent5==5.11.3+dfsg1-1+deb10u4 +libqt5core5a==5.11.3+dfsg1-1+deb10u4 +libqt5dbus5==5.11.3+dfsg1-1+deb10u4 +libqt5gui5==5.11.3+dfsg1-1+deb10u4 +libqt5network5==5.11.3+dfsg1-1+deb10u4 +libqt5opengl5==5.11.3+dfsg1-1+deb10u4 +libqt5opengl5-dev==5.11.3+dfsg1-1+deb10u4 +libqt5printsupport5==5.11.3+dfsg1-1+deb10u4 +libqt5sql5==5.11.3+dfsg1-1+deb10u4 +libqt5sql5-sqlite==5.11.3+dfsg1-1+deb10u4 +libqt5svg5==5.11.3-2 +libqt5test5==5.11.3+dfsg1-1+deb10u4 +libqt5widgets5==5.11.3+dfsg1-1+deb10u4 +libqt5xml5==5.11.3+dfsg1-1+deb10u4 +libqtcore4==4:4.8.7+dfsg-18+deb10u1 +libqtdbus4==4:4.8.7+dfsg-18+deb10u1 +libqtgui4==4:4.8.7+dfsg-18+deb10u1 +libquadmath0==8.3.0-6 +libraw1394-11==2.1.2-1+b1 +librdmacm1==22.1-1 +libreadline-dev==7.0-5 +libreadline5==5.2+dfsg-3+b13 +libreadline7==7.0-5 +libreadonly-perl==2.050-1 +libref-util-perl==0.204-1 +libref-util-xs-perl==0.117-1+b1 +libregexp-assemble-perl==0.36-1 +libregexp-pattern-license-perl==3.0.31-4 +librest-0.7-0==0.8.1-1 +librhash0==1.3.8-1 +librole-tiny-perl==2.000006-1 +librrd-dev==1.7.1-2 +librrd8==1.7.1-2 +librsvg2-2==2.44.10-2.1 +librsvg2-common==2.44.10-2.1 +librtmp1==2.4+20151223.gitfa8646d.1-2 +librubberband2==1.8.1-7 +libruby2.5==2.5.5-3+deb10u3 +libsamplerate0==0.1.9-2 +libsasl2-2==2.1.27+dfsg-1+deb10u1 +libsasl2-modules==2.1.27+dfsg-1+deb10u1 +libsasl2-modules-db==2.1.27+dfsg-1+deb10u1 +libsaxon-java==1:6.5.5-12 +libselinux1-dev==2.8-1+b1 +libsensors-config==1:3.5.0-3 +libsensors4-dev==1:3.5.0-3 +libsensors5==1:3.5.0-3 +libsepol1-dev==2.8-1 +libserd-0-0==0.28.0~dfsg0-1 +libsereal-decoder-perl==4.005+ds-1+b1 +libsereal-encoder-perl==4.005+ds-1+b1 +libsereal-perl==4.005-1 +libservlet-api-java==4.0.1-2 +libservlet3.1-java==1:4.0.1-2 +libshine3==3.1.1-2 +libshout3==2.4.1-2 +libsidplay1v5==1.36.59-11 +libsigsegv2==2.12-2 +libsisu-guice-java==4.2.0-1 +libsisu-inject-java==0.3.3-1 +libsisu-ioc-java==2.3.0-11 +libsisu-plexus-java==0.3.3-3 +libslang2==2.3.2-2 +libslang2-dev==2.3.2-2 +libslf4j-java==1.7.25-3 +libsm-dev==2:1.2.3-1 +libsm6==2:1.2.3-1 +libsnappy-java==1.1.7.2-1 +libsnappy-jni==1.1.7.2-1 +libsnappy1v5==1.1.7-1 +libsndfile1==1.0.28-6 +libsnmp-base==5.7.3+dfsg-5+deb10u2 +libsnmp-dev==5.7.3+dfsg-5+deb10u2 +libsnmp30==5.7.3+dfsg-5+deb10u2 +libsoap-lite-perl==1.27-1 +libsodium-dev==1.0.17-1 +libsodium23==1.0.17-1 +libsord-0-0==0.16.0~dfsg0-1+b1 +libsort-key-perl==1.33-2+b1 +libsort-versions-perl==1.62-1 +libsoup-gnome2.4-1==2.64.2-2 +libsoup2.4-1==2.64.2-2 +libsoxr0==0.1.2-3 +libspeex1==1.2~rc1.2-1+b2 +libspice-server1==0.14.0-1.3+deb10u1 +libsqlite3-0==3.27.2-3+deb10u1 +libsratom-0-0==0.6.0~dfsg0-1 +libssh-gcrypt-4==0.8.7-1+deb10u1 +libssh2-1==1.8.0-2.1 +libssl-dev==1.1.1d-0+deb10u5 +libssl1.1==1.1.1d-0+deb10u5 +libstdc++-8-dev==8.3.0-6 +libstemmer0d==0+svn585-1+b2 +libstrictures-perl==2.000005-1 +libstring-copyright-perl==0.003006-1 +libstring-escape-perl==2010.002-2 +libstring-shellquote-perl==1.04-1 +libstruct-dumb-perl==0.09-1 +libsub-exporter-perl==0.987-1 +libsub-exporter-progressive-perl==0.001013-1 +libsub-identify-perl==0.14-1+b1 +libsub-install-perl==0.928-1 +libsub-name-perl==0.21-1+b3 +libsub-quote-perl==2.005001-1 +libsubunit-dev==1.3.0-1 +libsubunit0==1.3.0-1 +libsurefire-java==2.22.1-1 +libswitch-perl==2.17-2 +libswresample3==7:4.1.6-1~deb10u1 +libswscale5==7:4.1.6-1~deb10u1 +libsynctex2==2018.20181218.49446-1 +libsys-hostname-long-perl==1.5-1 +libsystemd-dev==241-7~deb10u6 +libtag1v5==1.11.1+dfsg.1-0.3+deb10u1 +libtag1v5-vanilla==1.11.1+dfsg.1-0.3+deb10u1 +libtask-weaken-perl==1.06-1 +libtasn1-6-dev==4.13-3 +libtasn1-doc==4.13-3 +libtcl8.6==8.6.9+dfsg-2 +libtcmalloc-minimal4==2.7-1 +libteckit0==2.5.8+ds2-5 +libterm-readkey-perl==2.38-1 +libtest-fatal-perl==0.014-1 +libtest-refcount-perl==0.08-3 +libtexlua52==2018.20181218.49446-1 +libtexlua53==2018.20181218.49446-1 +libtexluajit2==2018.20181218.49446-1 +libtext-charwidth-perl==0.04-7.1+b1 +libtext-glob-perl==0.10-1 +libtext-iconv-perl==1.7-5+b7 +libtext-levenshtein-perl==0.13-1 +libtext-unidecode-perl==1.30-1 +libtext-wrapi18n-perl==0.06-7.1 +libthai-data==0.1.28-2 +libthai0==0.1.28-2 +libtheora0==1.1.1+dfsg.1-15 +libtie-ixhash-perl==1.23-2 +libtiff5==4.1.0+git191117-2~deb10u1 +libtimedate-perl==2.3000-2+deb10u1 +libtinyxml2-6a==7.0.0+dfsg-1 +libtinyxml2-dev==7.0.0+dfsg-1 +libtk8.6==8.6.9-2 +libtool==2.4.6-9 +libtool-bin==2.4.6-9 +libtry-tiny-perl==0.30-1 +libtsan0==8.3.0-6 +libtwolame0==0.3.13-4 +libtype-tiny-perl==1.004004-1 +libtype-tiny-xs-perl==0.014-1+b1 +libtypes-serialiser-perl==1.0-1 +libubsan1==8.3.0-6 +libuchardet0==0.0.6-3 +libudev-dev==241-7~deb10u6 +libunbound8==1.9.0-2+deb10u2 +libunicode-utf8-perl==0.62-1 +libunwind-dev==1.2.1-10~deb10u1 +libunwind8==1.2.1-10~deb10u1 +liburi-perl==1.76-1 +libusb-0.1-4==2:0.1.12-32 +libusb-1.0-0==2:1.0.22-2 +libusb-1.0-0-dev==2:1.0.22-2 +libusb-1.0-doc==2:1.0.22-2 +libusb-dev==2:0.1.12-32 +libusbredirparser1==0.8.0-1 +libutempter0==1.1.6-3 +libuv1==1.24.1-1 +libv4l-0==1.16.3-3 +libv4lconvert0==1.16.3-3 +libva-drm2==2.4.0-1 +libva-x11-2==2.4.0-1 +libva2==2.4.0-1 +libvariable-magic-perl==0.62-1+b1 +libvdeplug2==2.3.2+r586-2.2 +libvdpau-va-gl1==0.4.2-1+b1 +libvdpau1==1.1.1-10 +libvelocity-tools-java==2.0-7 +libvidstab1.1==1.1.0-2 +libvirglrenderer0==0.7.0-2 +libvirt-clients==5.0.0-4+deb10u1 +libvirt0==5.0.0-4+deb10u1 +libvisual-0.4-0==0.4.0-15 +libvorbis0a==1.3.6-2 +libvorbisenc2==1.3.6-2 +libvorbisfile3==1.3.6-2 +libvpx5==1.7.0-3+deb10u1 +libvte-2.91-0==0.54.2-2 +libvte-2.91-common==0.54.2-2 +libvulkan-dev==1.1.97-2 +libvulkan1==1.1.97-2 +libwacom-bin==0.32-1 +libwacom-common==0.32-1 +libwacom2==0.32-1 +libwagon-file-java==3.3.1-2 +libwagon-http-shaded-java==3.3.1-2 +libwagon-provider-api-java==3.3.1-2 +libwant-perl==0.29-1+b4 +libwavpack1==5.1.0-6 +libwayland-client0==1.16.0-1 +libwayland-cursor0==1.16.0-1 +libwayland-egl1==1.16.0-1 +libwayland-server0==1.16.0-1 +libwebp6==0.6.1-2 +libwebpdemux2==0.6.1-2 +libwebpmux3==0.6.1-2 +libwebsocket-api-java==1.1-1+deb10u1 +libwmf0.2-7==0.2.8.4-14 +libwoff1==1.0.2-1 +libwrap0==7.6.q-28 +libwrap0-dev==7.6.q-28 +libwww-perl==6.36-2 +libwww-robotrules-perl==6.02-1 +libx11-6==2:1.6.7-1+deb10u1 +libx11-data==2:1.6.7-1+deb10u1 +libx11-dev==2:1.6.7-1+deb10u1 +libx11-protocol-perl==0.56-7 +libx11-xcb-dev==2:1.6.7-1+deb10u1 +libx11-xcb1==2:1.6.7-1+deb10u1 +libx264-155==2:0.155.2917+git0a84d98-2 +libx265-165==2.9-4 +libx32asan5==8.3.0-6 +libx32atomic1==8.3.0-6 +libx32gcc-8-dev==8.3.0-6 +libx32gcc1==1:8.3.0-6 +libx32gomp1==8.3.0-6 +libx32itm1==8.3.0-6 +libx32quadmath0==8.3.0-6 +libx32stdc++6==8.3.0-6 +libx32ubsan1==8.3.0-6 +libxalan2-java==2.7.2-2 +libxapian30==1.4.11-1 +libxau-dev==1:1.0.8-1+b2 +libxau6==1:1.0.8-1+b2 +libxaw7==2:1.0.13-1+b2 +libxbean-reflect-java==4.5-8 +libxcb-dri2-0==1.13.1-2 +libxcb-dri2-0-dev==1.13.1-2 +libxcb-dri3-0==1.13.1-2 +libxcb-dri3-dev==1.13.1-2 +libxcb-glx0==1.13.1-2 +libxcb-glx0-dev==1.13.1-2 +libxcb-icccm4==0.4.1-1.1 +libxcb-image0==0.4.0-1+b2 +libxcb-keysyms1==0.4.0-1+b2 +libxcb-present-dev==1.13.1-2 +libxcb-present0==1.13.1-2 +libxcb-randr0==1.13.1-2 +libxcb-randr0-dev==1.13.1-2 +libxcb-render-util0==0.3.9-1+b1 +libxcb-render0==1.13.1-2 +libxcb-render0-dev==1.13.1-2 +libxcb-shape0==1.13.1-2 +libxcb-shape0-dev==1.13.1-2 +libxcb-shm0==1.13.1-2 +libxcb-sync-dev==1.13.1-2 +libxcb-sync1==1.13.1-2 +libxcb-util0==0.3.8-3+b2 +libxcb-xfixes0==1.13.1-2 +libxcb-xfixes0-dev==1.13.1-2 +libxcb-xinerama0==1.13.1-2 +libxcb-xkb1==1.13.1-2 +libxcb1==1.13.1-2 +libxcb1-dev==1.13.1-2 +libxcomposite1==1:0.4.4-2 +libxcursor1==1:1.1.15-2 +libxdamage-dev==1:1.1.4-3+b3 +libxdamage1==1:1.1.4-3+b3 +libxdelta2==1.1.3-9.2 +libxdmcp-dev==1:1.1.2-3 +libxdmcp6==1:1.1.2-3 +libxdot4==2.40.1-6 +libxencall1==4.11.4+57-g41a822c392-2 +libxendevicemodel1==4.11.4+57-g41a822c392-2 +libxenevtchn1==4.11.4+57-g41a822c392-2 +libxenforeignmemory1==4.11.4+57-g41a822c392-2 +libxengnttab1==4.11.4+57-g41a822c392-2 +libxenmisc4.11==4.11.4+57-g41a822c392-2 +libxenstore3.0==4.11.4+57-g41a822c392-2 +libxentoolcore1==4.11.4+57-g41a822c392-2 +libxentoollog1==4.11.4+57-g41a822c392-2 +libxerces2-java==2.12.0-1 +libxext-dev==2:1.3.3-1+b2 +libxext6==2:1.3.3-1+b2 +libxfixes-dev==1:5.0.3-1 +libxfixes3==1:5.0.3-1 +libxft2==2.3.2-2 +libxi6==2:1.7.9-1 +libxinerama1==2:1.1.4-2 +libxkbcommon-x11-0==0.8.2-1 +libxkbcommon0==0.8.2-1 +libxml-commons-external-java==1.4.01-3 +libxml-commons-resolver1.1-java==1.2-9 +libxml-libxml-perl==2.0134+dfsg-1 +libxml-namespacesupport-perl==1.12-1 +libxml-parser-perl==2.44-4 +libxml-sax-base-perl==1.09-1 +libxml-sax-expat-perl==0.51-1 +libxml-sax-perl==1.00+dfsg-1 +libxml-simple-perl==2.25-1 +libxml-twig-perl==1:3.50-1.1 +libxml-xpathengine-perl==0.14-1 +libxml2==2.9.4+dfsg1-7+deb10u1 +libxml2-dev==2.9.4+dfsg1-7+deb10u1 +libxml2-utils==2.9.4+dfsg1-7+deb10u1 +libxmlgraphics-commons-java==2.3-1 +libxmlrpc-lite-perl==0.717-2 +libxmu6==2:1.1.2-2+b3 +libxmuu1==2:1.1.2-2+b3 +libxpm4==1:3.5.12-1 +libxrandr2==2:1.5.1-1 +libxrender1==1:0.9.10-1 +libxshmfence-dev==1.3-1 +libxshmfence1==1.3-1 +libxslt1.1==1.1.32-2.2~deb10u1 +libxss1==1:1.2.3-1 +libxt-dev==1:1.1.5-1+b3 +libxt6==1:1.1.5-1+b3 +libxtables-dev==1.8.2-4 +libxtst6==2:1.2.3-1 +libxv1==2:1.0.11-1 +libxvidcore4==2:1.3.5-1 +libxxf86dga1==2:1.1.4-1+b3 +libxxf86vm-dev==1:1.1.4-1+b2 +libxxf86vm1==1:1.1.4-1+b2 +libxxhash0==0.6.5-2 +libxz-java==1.8-2 +libyajl2==2.1.0-3 +libyaml-0-2==0.2.1-1 +libyaml-dev==0.2.1-1 +libyaml-libyaml-perl==0.76+repack-1 +libzmq3-dev==4.3.1-4+deb10u2 +libzmq5==4.3.1-4+deb10u2 +libzvbi-common==0.2.35-16 +libzvbi0==0.2.35-16 +libzzip-0-13==0.13.62-3.2 +licensecheck==3.0.31-3 +lintian==2.15.0 +linux-compiler-gcc-8-x86==4.19.171-2 +linux-headers-4.19.0-14-amd64==4.19.171-2 +linux-headers-4.19.0-14-common==4.19.171-2 +linux-headers-amd64==4.19+105+deb10u9 +linux-kbuild-4.19==4.19.171-2 +linux-libc-dev==4.19.171-2 +linuxdoc-tools==0.9.73-2 +llvm-7==1:7.0.1-8+deb10u2 +llvm-7-dev==1:7.0.1-8+deb10u2 +llvm-7-runtime==1:7.0.1-8+deb10u2 +lmodern==2.004.5-6 +logrotate==3.14.0-4 +lsb-base==10.2019051400 +lsb-release==10.2019051400 +lsof==4.91+dfsg-1 +lua-bitop==1.0.2-5 +lua-bitop-dev==1.0.2-5 +lua-cjson==2.1.0+dfsg-2.1 +lua-cjson-dev==2.1.0+dfsg-2.1 +lvm2==2.03.02-3 +lynx==2.8.9rel.1-3 +lynx-common==2.8.9rel.1-3 +m4==1.4.18-2 +make==4.2.1-1.2 +man-db==2.8.5-2 +manpages==4.16-2 +manpages-dev==4.16-2 +mariadb-common==1:10.3.27-0+deb10u1 +maven==3.6.0-1 +maven-debian-helper==2.3.2 +maven-repo-helper==1.9.3 +mesa-common-dev==18.3.6-2+deb10u1 +mesa-va-drivers==18.3.6-2+deb10u1 +mesa-vdpau-drivers==18.3.6-2+deb10u1 +mime-support==3.62 +module-assistant==0.11.10 +mysql-common==5.8+1.0.5 +ncurses-term==6.1+20181013-2+deb10u2 +netbase==5.6 +netpbm==2:10.0-15.3+b2 +nettle-dev==3.4.1-1 +nftables==0.9.0-2 +ocl-icd-libopencl1==2.2.12-2 +openjdk-11-jdk==11.0.9.1+1-1~deb10u2 +openjdk-11-jdk-headless==11.0.9.1+1-1~deb10u2 +openjdk-11-jre==11.0.9.1+1-1~deb10u2 +openjdk-11-jre-headless==11.0.9.1+1-1~deb10u2 +openmpi-bin==3.1.3-11 +openmpi-common==3.1.3-11 +opensp==1.5.2-13+b1 +openssh-client==1:7.9p1-10+deb10u2 +openssh-server==1:7.9p1-10+deb10u2 +openssh-sftp-server==1:7.9p1-10+deb10u2 +openssl==1.1.1d-0+deb10u5 +ovmf==0~20181115.85588389-3+deb10u3 +packagekit==1.1.12-5 +packagekit-tools==1.1.12-5 +patch==2.7.6-3+deb10u1 +patchutils==0.3.4-2 +pbuilder==0.230.4 +pbzip2==1.1.9-1+b1 +perl==5.28.1-6+deb10u1 +perl-modules-5.28==5.28.1-6+deb10u1 +perl-openssl-defaults==3 +php-cli==2:7.3+69 +php-codecoverage==6.1.4+dfsg-1 +php-common==2:69 +php-deepcopy==1.8.1-1 +php-doctrine-instantiator==1.1.0-2 +php-file-iterator==2.0.2-1 +php-mbstring==2:7.3+69 +php-pear==1:1.10.6+submodules+notgz-1.1+deb10u1 +php-phar-io-manifest==1.0.3-1 +php-phar-io-version==2.0.1-1 +php-phpdocumentor-reflection-common==1.0.1-1 +php-phpdocumentor-reflection-docblock==4.3.0-1 +php-phpdocumentor-type-resolver==0.4.0-2 +php-phpspec-prophecy==1.8.0-1 +php-text-template==1.2.1-2 +php-timer==2.1.1-1 +php-token-stream==3.0.1-1 +php-tokenizer==1.1.0-1 +php-webmozart-assert==1.4.0-3 +php-xml==2:7.3+69 +php7.3-cli==7.3.27-1~deb10u1 +php7.3-common==7.3.27-1~deb10u1 +php7.3-json==7.3.27-1~deb10u1 +php7.3-mbstring==7.3.27-1~deb10u1 +php7.3-opcache==7.3.27-1~deb10u1 +php7.3-readline==7.3.27-1~deb10u1 +php7.3-xml==7.3.27-1~deb10u1 +phpunit==7.5.6-1 +phpunit-code-unit-reverse-lookup==1.0.1-1 +phpunit-comparator==3.0.2-1 +phpunit-diff==3.0.2-1 +phpunit-environment==4.1.0-1 +phpunit-exporter==3.1.0-2 +phpunit-global-state==2.0.0really2.0.0-2 +phpunit-object-enumerator==3.0.3-3 +phpunit-object-reflector==1.1.1-2 +phpunit-recursion-context==3.0.0-2 +phpunit-resource-operations==2.0.1-1 +phpunit-version==2.0.1-1 +pigz==2.4-1 +pinentry-curses==1.1.0-2 +pkg-config==0.29-6 +pkg-php-tools==1.37 +po-debconf==1.0.21 +policykit-1==0.105-25 +poppler-data==0.4.9-2 +pps-tools==1.0.2-1 +preview-latex-style==11.91-2 +pristine-tar==1.46 +procmail==3.22-26 +procps==2:3.3.15-2 +protobuf-compiler==3.6.1.3-2 +psmisc==23.2-1 +psutils==1.17.dfsg-4 +publicsuffix==20190415.1030-1 +pylint==1.9.4-1 +python==2.7.16-1 +python-alabaster==0.7.8-1 +python-all==2.7.16-1 +python-all-dev==2.7.16-1 +python-apt-common==1.8.4.3 +python-asn1crypto==0.24.0-1 +python-astroid==1.6.5-3 +python-atomicwrites==1.1.5-2 +python-attr==18.2.0-1 +python-automat==0.6.0-1 +python-babel==2.6.0+dfsg.1-1 +python-babel-localedata==2.6.0+dfsg.1-1 +python-backports.functools-lru-cache==1.5-3 +python-bs4==4.7.1-1 +python-certifi==2018.8.24-1 +python-cffi-backend==1.12.2-1 +python-chardet==3.0.4-3 +python-click==7.0-1 +python-colorama==0.3.7-1 +python-concurrent.futures==3.2.0-2 +python-configparser==3.5.0b2-1 +python-constantly==15.1.0-1 +python-cov-core==1.15.0-2 +python-coverage==4.5.2+dfsg.1-1 +python-crypto==2.6.1-9+b1 +python-cryptography==2.6.1-3+deb10u2 +python-dbus==1.2.8-3 +python-dev==2.7.16-1 +python-docutils==0.14+dfsg-4 +python-egenix-mxdatetime==3.2.9-1 +python-egenix-mxtools==3.2.9-1 +python-entrypoints==0.3-1 +python-enum34==1.1.6-2 +python-funcsigs==1.0.2-4 +python-gi==3.30.4-1 +python-html5lib==1.0.1-1 +python-hyperlink==17.3.1-2 +python-idna==2.6-1 +python-imagesize==1.0.0-1 +python-incremental==16.10.1-3 +python-ipaddr==2.2.0-2 +python-ipaddress==1.0.17-1 +python-isort==4.3.4+ds1-1.1 +python-jinja2==2.10-2 +python-keyring==17.1.1-1 +python-keyrings.alt==3.1.1-1 +python-lazy-object-proxy==1.3.1-1+b1 +python-logilab-common==1.4.2-1 +python-lxml==4.3.2-1+deb10u2 +python-markupsafe==1.1.0-1 +python-mccabe==0.6.1-2 +python-minimal==2.7.16-1 +python-mock==2.0.0-4 +python-more-itertools==4.2.0-1 +python-nose2==0.8.0-1 +python-olefile==0.46-1 +python-openssl==19.0.0-1 +python-packaging==19.0-1 +python-parse==1.6.6-0.1 +python-pathlib2==2.3.3-1 +python-pbr==4.2.0-5 +python-pil==5.4.1-2+deb10u2 +python-pip-whl==18.1-5 +python-pkg-resources==40.8.0-1 +python-pluggy==0.8.0-1 +python-py==1.7.0-2 +python-pyasn1==0.4.2-3 +python-pyasn1-modules==0.2.1-0.2 +python-pygments==2.3.1+dfsg-1 +python-pyparsing==2.2.0+dfsg1-2 +python-pytest==3.10.1-2 +python-pytest-cov==2.6.0-1 +python-requests==2.21.0-1 +python-roman==2.0.0-3 +python-scandir==1.9.0-2 +python-secretstorage==2.3.1-2 +python-service-identity==16.0.0-2 +python-setuptools==40.8.0-1 +python-singledispatch==3.4.0.3-2 +python-six==1.12.0-1 +python-soupsieve==1.8+dfsg-1 +python-sphinx==1.8.4-1 +python-stdeb==0.8.5-1 +python-tk==2.7.16-2 +python-twisted==18.9.0-3 +python-twisted-bin==18.9.0-3 +python-twisted-core==18.9.0-3 +python-typing==3.6.6-1 +python-tz==2019.1-1 +python-urllib3==1.24.1-1 +python-webencodings==0.5.1-1 +python-wheel==0.32.3-2 +python-wrapt==1.10.11-1 +python-xdg==0.25-5 +python-zope.interface==4.3.2-1+b2 +python2==2.7.16-1 +python2-dev==2.7.16-1 +python2-minimal==2.7.16-1 +python2.7==2.7.16-2+deb10u1 +python2.7-dev==2.7.16-2+deb10u1 +python2.7-minimal==2.7.16-2+deb10u1 +python3==3.7.3-1 +python3-alabaster==0.7.8-1 +python3-all==3.7.3-1 +python3-all-dbg==3.7.3-1 +python3-all-dev==3.7.3-1 +python3-apt==1.8.4.3 +python3-asn1crypto==0.24.0-1 +python3-atomicwrites==1.1.5-2 +python3-attr==18.2.0-1 +python3-babel==2.6.0+dfsg.1-1 +python3-certifi==2018.8.24-1 +python3-cffi-backend==1.12.2-1 +python3-chardet==3.0.4-3 +python3-cov-core==1.15.0-2 +python3-coverage==4.5.2+dfsg.1-1 +python3-crypto==2.6.1-9+b1 +python3-cryptography==2.6.1-3+deb10u2 +python3-dateutil==2.7.3-3 +python3-dbg==3.7.3-1 +python3-dbus==1.2.8-3 +python3-debian==0.1.35 +python3-dev==3.7.3-1 +python3-distro-info==0.21 +python3-distutils==3.7.3-1 +python3-docutils==0.14+dfsg-4 +python3-entrypoints==0.3-1 +python3-gi==3.30.4-1 +python3-gpg==1.12.0-6 +python3-idna==2.6-1 +python3-imagesize==1.0.0-1 +python3-jinja2==2.10-2 +python3-keyring==17.1.1-1 +python3-keyrings.alt==3.1.1-1 +python3-lib2to3==3.7.3-1 +python3-magic==2:0.4.15-2 +python3-markupsafe==1.1.0-1 +python3-minimal==3.7.3-1 +python3-mock==2.0.0-4 +python3-more-itertools==4.2.0-1 +python3-nose2==0.8.0-1 +python3-olefile==0.46-1 +python3-packaging==19.0-1 +python3-pbr==4.2.0-5 +python3-pil==5.4.1-2+deb10u2 +python3-pkg-resources==40.8.0-1 +python3-pluggy==0.8.0-1 +python3-py==1.7.0-2 +python3-pycurl==7.43.0.2-0.1 +python3-pygments==2.3.1+dfsg-1 +python3-pyparsing==2.2.0+dfsg1-2 +python3-pytest==3.10.1-2 +python3-pytest-cov==2.6.0-1 +python3-requests==2.21.0-1 +python3-roman==2.0.0-3 +python3-secretstorage==2.3.1-2 +python3-setuptools==40.8.0-1 +python3-six==1.12.0-1 +python3-software-properties==0.96.20.2-2 +python3-sphinx==1.8.4-1 +python3-sphinx-rtd-theme==0.4.3+dfsg-1 +python3-tz==2019.1-1 +python3-unidiff==0.5.4-1 +python3-urllib3==1.24.1-1 +python3-wheel==0.32.3-2 +python3-xdg==0.25-5 +python3.7==3.7.3-2+deb10u2 +python3.7-dbg==3.7.3-2+deb10u2 +python3.7-dev==3.7.3-2+deb10u2 +python3.7-minimal==3.7.3-2+deb10u2 +qdbus==4:4.8.7+dfsg-18+deb10u1 +qemu-kvm==1:3.1+dfsg-8+deb10u8 +qemu-system-common==1:3.1+dfsg-8+deb10u8 +qemu-system-data==1:3.1+dfsg-8+deb10u8 +qemu-system-gui==1:3.1+dfsg-8+deb10u8 +qemu-system-x86==1:3.1+dfsg-8+deb10u8 +qemu-utils==1:3.1+dfsg-8+deb10u8 +qt-at-spi==0.4.0-9 +qt4-linguist-tools==4:4.8.7+dfsg-18+deb10u1 +qt4-qmake==4:4.8.7+dfsg-18+deb10u1 +qt5-default==5.11.3+dfsg1-1+deb10u4 +qt5-gtk-platformtheme==5.11.3+dfsg1-1+deb10u4 +qt5-qmake==5.11.3+dfsg1-1+deb10u4 +qt5-qmake-bin==5.11.3+dfsg1-1+deb10u4 +qtbase5-dev==5.11.3+dfsg1-1+deb10u4 +qtbase5-dev-tools==5.11.3+dfsg1-1+deb10u4 +qtchooser==66-2 +qtcore4-l10n==4:4.8.7+dfsg-18+deb10u1 +qttranslations5-l10n==5.11.3-2 +quilt==0.65-3 +rake==12.3.1-3+deb10u1 +readline-common==7.0-5 +rrdtool==1.7.1-2 +rsync==3.1.3-6 +rsyslog==8.1901.0-1 +ruby==1:2.5.1 +ruby-all-dev==1:2.5.1 +ruby-asciidoctor==1.5.8-1 +ruby-did-you-mean==1.2.1-1 +ruby-minitest==5.11.3-1 +ruby-net-telnet==0.1.1-2 +ruby-power-assert==1.1.1-1 +ruby-setup==3.4.1-9 +ruby-test-unit==3.2.8-1 +ruby-xmlrpc==0.3.0-2 +ruby2.5==2.5.5-3+deb10u3 +ruby2.5-dev==2.5.5-3+deb10u3 +ruby2.5-doc==2.5.5-3+deb10u3 +rubygems-integration==1.11+deb10u1 +seabios==1.12.0-1 +sensible-utils==0.0.12 +sgml-base==1.29 +sgml-data==2.0.11 +shared-mime-info==1.10-1 +shellcheck==0.5.0-3 +software-properties-common==0.96.20.2-2 +sphinx-common==1.8.4-1 +sphinx-rtd-theme-common==0.4.3+dfsg-1 +squashfs-tools==1:4.3-12 +stgit==0.18-1 +strace==4.26-0.2 +sudo==1.8.27-1+deb10u3 +swig==3.0.12-2 +swig3.0==3.0.12-2 +systemd==241-7~deb10u6 +systemd-sysv==241-7~deb10u6 +t1utils==1.41-3 +tcl==8.6.9+1 +tcl8.6==8.6.9+dfsg-2 +telnet==0.17-41.2 +tex-common==6.11 +tex-gyre==20180621-3 +texi2html==1.82+dfsg1-5 +texinfo==6.5.0.dfsg.1-4+b1 +texlive-base==2018.20190227-2 +texlive-binaries==2018.20181218.49446-1 +texlive-fonts-recommended==2018.20190227-2 +texlive-generic-recommended==2018.20190227-2 +texlive-latex-base==2018.20190227-2 +texlive-latex-extra==2018.20190227-2 +texlive-latex-recommended==2018.20190227-2 +texlive-pictures==2018.20190227-2 +texlive-plain-generic==2018.20190227-2 +thin-provisioning-tools==0.7.6-2.1 +tipa==2:1.3-20 +tk==8.6.9+1 +tk8.6==8.6.9-2 +tk8.6-blt2.5==2.5.3+dfsg-4 +ucf==3.0038+nmu1 +unattended-upgrades==1.11.2 +unzip==6.0-23+deb10u2 +uuid-dev==2.33.1-0.1 +va-driver-all==2.4.0-1 +vdpau-driver-all==1.1.1-10 +velocity==1.7-5 +vim==2:8.1.0875-5 +vim-common==2:8.1.0875-5 +vim-runtime==2:8.1.0875-5 +wdiff==1.2.2-2+b1 +wget==1.20.1-1.1 +x11-common==1:7.7+19 +x11-utils==7.7+4 +x11-xserver-utils==7.7+8 +x11proto-core-dev==2018.4-4 +x11proto-damage-dev==1:2018.4-4 +x11proto-dev==2018.4-4 +x11proto-fixes-dev==1:2018.4-4 +x11proto-xext-dev==2018.4-4 +x11proto-xf86vidmode-dev==2018.4-4 +xauth==1:1.0.10-1 +xbitmaps==1.1.1-2 +xdelta==1.1.3-9.2 +xdelta3==3.0.11-dfsg-1+b1 +xdg-user-dirs==0.17-2 +xdg-utils==1.1.3-1+deb10u1 +xfonts-encodings==1:1.0.4-2 +xfonts-utils==1:7.7+6 +xkb-data==2.26-2 +xml-core==0.18+nmu1 +xorg-sgml-doctools==1:1.11-1 +xsltproc==1.1.32-2.2~deb10u1 +xterm==344-1 +xtrans-dev==1.3.5-1 +xxd==2:8.1.0875-5 +xz-utils==5.2.4-1 +zip==3.0-11+b1 +zlib1g-dev==1:1.2.11.dfsg-1 \ No newline at end of file diff --git a/files/build/versions/dockers/sonic-slave-buster/versions-py2 b/files/build/versions/dockers/sonic-slave-buster/versions-py2 new file mode 100644 index 000000000000..bc9a8d62e678 --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-buster/versions-py2 @@ -0,0 +1,92 @@ +alabaster==0.7.8 +asn1crypto==0.24.0 +astroid==1.6.5 +atomicwrites==1.1.5 +attrs==18.2.0 +Automat==0.6.0 +Babel==2.6.0 +backports.functools-lru-cache==1.5 +beautifulsoup4==4.7.1 +certifi==2018.8.24 +chardet==3.0.4 +Click==7.0 +colorama==0.3.7 +configparser==3.5.0b2 +constantly==15.1.0 +cov-core==1.15.0 +coverage==4.5.2 +crc16==0.1.1 +cryptography==2.6.1 +ctypesgen==1.0.2 +docutils==0.14 +entrypoints==0.3 +enum34==1.1.6 +fastentrypoints==0.12 +funcsigs==1.0.2 +futures==3.2.0 +html5lib==1.0.1 +hyperlink==17.3.1 +idna==2.6 +imagesize==1.0.0 +incremental==16.10.1 +ipaddr==2.2.0 +ipaddress==1.0.17 +isort==4.3.4 +j2cli==0.3.10 +Jinja2==2.10 +keyring==17.1.1 +keyrings.alt==3.1.1 +lazy-object-proxy==1.3.1 +logilab-common==1.4.2 +lxml==4.6.2 +M2Crypto==0.36.0 +MarkupSafe==1.1.0 +mccabe==0.6.1 +mmh3==2.5.1 +mock==3.0.5 +mockredispy==2.9.3 +more-itertools==4.2.0 +nose2==0.8.0 +olefile==0.46 +packaging==19.0 +parse==1.6.6 +pathlib2==2.3.3 +pbr==4.2.0 +pexpect==4.6.0 +Pillow==5.4.1 +pluggy==0.8.0 +ptyprocess==0.7.0 +py==1.7.0 +pyang==2.1.1 +pyasn1==0.4.2 +pyasn1-modules==0.2.1 +pycrypto==2.6.1 +Pygments==2.3.1 +PyGObject==3.30.4 +pylint==1.9.4 +Pympler==0.8 +pyOpenSSL==19.0.0 +pyparsing==2.2.0 +pytest==3.10.1 +pytest-cov==2.6.0 +pytest-runner==4.4 +pytz==2019.1 +pyxdg==0.25 +PyYAML==5.4.1 +requests==2.21.0 +roman==2.0.0 +scandir==1.9.0 +SecretStorage==2.3.1 +service-identity==16.0.0 +singledispatch==3.4.0.3 +six==1.12.0 +soupsieve==1.8 +Sphinx==1.8.4 +stdeb==0.8.5 +stgit==0.18 +Twisted==18.9.0 +typing==3.6.6 +urllib3==1.24.1 +webencodings==0.5.1 +wrapt==1.10.11 +zope.interface==4.3.2 \ No newline at end of file diff --git a/files/build/versions/dockers/sonic-slave-buster/versions-py3 b/files/build/versions/dockers/sonic-slave-buster/versions-py3 new file mode 100644 index 000000000000..891ccaee5773 --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-buster/versions-py3 @@ -0,0 +1,70 @@ +alabaster==0.7.8 +asn1crypto==0.24.0 +atomicwrites==1.1.5 +attrs==18.2.0 +Babel==2.6.0 +bitarray==1.6.3 +certifi==2018.8.24 +chardet==3.0.4 +cov-core==1.15.0 +coverage==4.5.2 +cryptography==2.6.1 +devscripts==2.19.5+deb10u1 +distro-info==0.21 +docutils==0.14 +entrypoints==0.3 +fastentrypoints==0.12 +gbp==0.9.14 +gcovr==4.1 +gpg==1.12.0 +idna==2.6 +imagesize==1.0.0 +Jinja2==2.10 +keyring==17.1.1 +keyrings.alt==3.1.1 +lxml==4.6.2 +M2Crypto==0.37.1 +MarkupSafe==1.1.0 +mmh3==2.5.1 +mock==2.0.0 +mockredispy==2.9.3 +more-itertools==4.2.0 +nose2==0.8.0 +olefile==0.46 +packaging==19.0 +parameterized==0.8.1 +pbr==4.2.0 +pexpect==4.8.0 +Pillow==5.4.1 +pluggy==0.8.0 +ptyprocess==0.7.0 +py==1.7.0 +pyang==2.1.1 +pyangbind==0.8.1 +pycrypto==2.6.1 +pycurl==7.43.0.2 +Pygments==2.3.1 +PyGObject==3.30.4 +Pympler==0.8 +pyparsing==2.2.0 +pytest==3.10.1 +pytest-cov==2.6.0 +pytest-runner==5.2 +python-apt==1.8.4.3 +python-dateutil==2.7.3 +python-debian==0.1.35 +python-magic==0.4.16 +pytz==2019.1 +pyxdg==0.25 +PyYAML==5.4.1 +redis==3.5.3 +regex==2020.11.13 +requests==2.21.0 +roman==2.0.0 +SecretStorage==2.3.1 +six==1.12.0 +Sphinx==1.8.4 +sphinx-rtd-theme==0.4.3 +unattended-upgrades==0.1 +unidiff==0.5.4 +urllib3==1.24.1 \ No newline at end of file diff --git a/files/build/versions/dockers/sonic-slave-stretch/versions-deb-stretch b/files/build/versions/dockers/sonic-slave-stretch/versions-deb-stretch new file mode 100644 index 000000000000..2863f0c1cc03 --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-stretch/versions-deb-stretch @@ -0,0 +1,1484 @@ +adwaita-icon-theme==3.22.0-1+deb9u1 +ant==1.9.9-1+deb9u1 +ant-optional==1.9.9-1+deb9u1 +apt-file==3.1.4 +apt-transport-https==1.4.11 +apt-utils==1.4.11 +asciidoc-base==8.6.9-5 +asciidoc-common==8.6.9-5 +aspell==0.60.7~20110707-3+b2 +aspell-en==2016.11.20-0-0.1 +at==3.1.20-3 +at-spi2-core==2.22.0-6+deb9u1 +aufs-dkms==4.9+20161219-1 +aufs-tools==1:4.1+20161219-1 +augeas-lenses==1.8.0-1+deb9u1 +augeas-tools==1.8.0-1+deb9u1 +autoconf==2.69-10 +autoconf-archive==20160916-1 +automake==1:1.15-6 +automake1.11==1:1.11.6-4 +autopoint==0.19.8.1-2+deb9u1 +autotools-dev==20161112.1 +bash-completion==1:2.1-4.3 +bc==1.06.95-9+b3 +bind9-host==1:9.10.3.dfsg.P4-12.3+deb9u8 +binfmt-support==2.1.6-2 +binutils==2.28-5 +bison==2:3.0.4.dfsg-1+b1 +blt==2.5.3+dfsg-3 +bsdmainutils==9.0.12+nmu1 +build-essential==12.3 +byacc==20140715-1+b1 +bzip2==1.0.6-8.1 +ca-certificates==20200601~deb9u1 +ca-certificates-java==20170929~deb9u3 +cdbs==0.4.150 +cgmanager==0.41-2 +cgroupfs-mount==1.3 +check==0.10.0-3+b3 +chrpath==0.16-2+b1 +clang==1:3.8-36 +clang-3.8==1:3.8.1-24 +cm-super-minimal==0.3.4-9 +cmake==3.13.2-1~bpo9+1 +cmake-data==3.13.2-1~bpo9+1 +cmocka-doc==1.0.1-3 +containerd.io==1.4.3-1 +cowbuilder==0.85 +cowdancer==0.85 +cpio==2.11+dfsg-6 +cpp==4:6.3.0-4 +cpp-6==6.3.0-18+deb9u1 +cppcheck==1.76.1-1 +cron==3.0pl1-128+deb9u1 +curl==7.52.1-5+deb9u13 +dbus==1.10.32-0+deb9u1 +dconf-gsettings-backend==0.26.0-2+b1 +dconf-service==0.26.0-2+b1 +dctrl-tools==2.24-2+b1 +debhelper==12.1.1~bpo9+1 +debian-keyring==2017.05.28 +debootstrap==1.0.89 +default-jdk-headless==2:1.8-58+deb9u1 +default-jre==2:1.8-58+deb9u1 +default-jre-headless==2:1.8-58+deb9u1 +default-libmysqlclient-dev==1.0.2 +devscripts==2.17.6+deb9u2 +dh-autoreconf==17~bpo9+1 +dh-exec==0.23+b1 +dh-make==2.201608 +dh-python==2.20170125 +dh-strip-nondeterminism==0.034-1 +dh-systemd==10.2.5 +dictionaries-common==1.27.2 +diffstat==1.61-1+b1 +dirmngr==2.1.18-8~deb9u4 +distro-info-data==0.36 +dkms==2.3-2 +dmeventd==2:1.02.137-2 +dmsetup==2:1.02.137-2 +dnsutils==1:9.10.3.dfsg.P4-12.3+deb9u8 +docbook-xml==4.5-8 +docbook-xsl==1.79.1+dfsg-2 +docker-ce==5:18.09.5~3-0~debian-stretch +docker-ce-cli==5:18.09.5~3-0~debian-stretch +docutils-common==0.13.1+dfsg-2 +docutils-doc==0.13.1+dfsg-2 +dosfstools==4.1-1 +doxygen==1.8.13-4+b1 +dpatch==2.0.38+nmu1~bpo9+1 +dpkg-dev==1.18.25 +dput==0.12.1 +dwz==0.12-1+b1 +eatmydata==105-5 +emacsen-common==2.0.8 +equivs==2.0.9+nmu1 +exim4==4.89-2+deb9u7 +exim4-base==4.89-2+deb9u7 +exim4-config==4.89-2+deb9u7 +exim4-daemon-light==4.89-2+deb9u7 +expat==2.2.0-2+deb9u3 +exuberant-ctags==1:5.9~svn20110310-11 +fakeroot==1.21-3.1 +file==1:5.30-1+deb9u3 +flex==2.6.1-1.3 +fontconfig==2.11.0-6.7+b1 +fontconfig-config==2.11.0-6.7 +fonts-dejavu-core==2.37-1 +fonts-dejavu-extra==2.37-1 +fonts-droid-fallback==1:6.0.1r16-1.1 +fonts-font-awesome==4.7.0~dfsg-1 +fonts-lato==2.0-1 +fonts-liberation==1:1.07.4-2 +fonts-lmodern==2.004.5-3 +fonts-noto-mono==20161116-1 +fonts-texgyre==20160520-1 +fop==1:2.1-6 +g++==4:6.3.0-4 +g++-6==6.3.0-18+deb9u1 +gawk==1:4.1.4+dfsg-1 +gcc==4:6.3.0-4 +gcc-6==6.3.0-18+deb9u1 +gcc-6-multilib==6.3.0-18+deb9u1 +gcc-multilib==4:6.3.0-4 +gcovr==3.3-1 +gdb==7.12-6 +gem2deb==0.33.1 +gem2deb-test-runner==0.33.1 +geoip-database==20170512-1 +gettext==0.19.8.1-2+deb9u1 +gettext-base==0.19.8.1-2+deb9u1 +ghostscript==9.26a~dfsg-0+deb9u7 +gir1.2-glib-2.0==1.50.0-1+b1 +gir1.2-packagekitglib-1.0==1.1.5-2+deb9u2 +git==1:2.11.0-3+deb9u7 +git-buildpackage==0.8.12.2 +git-man==1:2.11.0-3+deb9u7 +glib-networking==2.50.0-1+deb9u1 +glib-networking-common==2.50.0-1+deb9u1 +glib-networking-services==2.50.0-1+deb9u1 +gnome-icon-theme==3.12.0-2 +gnupg==2.1.18-8~deb9u4 +gnupg-agent==2.1.18-8~deb9u4 +gnupg-l10n==2.1.18-8~deb9u4 +gnupg2==2.1.18-8~deb9u4 +googletest==1.8.0-6 +graphviz==2.38.0-17 +groff==1.22.3-9 +groff-base==1.22.3-9 +gsettings-desktop-schemas==3.22.0-1 +gsfonts==1:8.11+urwcyr1.0.7~pre44-4.3 +gtk-update-icon-cache==3.22.11-1 +guile-2.0-libs==2.0.13+1-4 +hicolor-icon-theme==0.15-1 +icc-profiles-free==2.0.1+dfsg-1 +icu-devtools==57.1-6+deb9u4 +imagemagick==8:6.9.7.4+dfsg-11+deb9u11 +imagemagick-6-common==8:6.9.7.4+dfsg-11+deb9u11 +imagemagick-6.q16==8:6.9.7.4+dfsg-11+deb9u11 +install-info==6.3.0.dfsg.1-1+b2 +intltool-debian==0.35.0+20060710.4 +iptables==1.6.0+snapshot20161117-6 +iptables-dev==1.6.0+snapshot20161117-6 +ipxe-qemu==1.0.0+git-20161027.b991c67-1 +iso-codes==3.75-1 +java-common==0.58+deb9u1 +java-wrappers==0.1.28 +javahelper==0.59 +javascript-common==11 +junit==3.8.2-8 +junit4==4.12-4+deb9u1 +kernel-wedge==2.96 +kmod==23-2 +krb5-locales==1.15-1+deb9u2 +less==481-2.1 +lib32asan3==6.3.0-18+deb9u1 +lib32atomic1==6.3.0-18+deb9u1 +lib32cilkrts5==6.3.0-18+deb9u1 +lib32gcc-6-dev==6.3.0-18+deb9u1 +lib32gcc1==1:6.3.0-18+deb9u1 +lib32gomp1==6.3.0-18+deb9u1 +lib32itm1==6.3.0-18+deb9u1 +lib32mpx2==6.3.0-18+deb9u1 +lib32quadmath0==6.3.0-18+deb9u1 +lib32stdc++6==6.3.0-18+deb9u1 +lib32ubsan0==6.3.0-18+deb9u1 +libaio1==0.3.110-3 +libalgorithm-diff-perl==1.19.03-1 +libalgorithm-diff-xs-perl==0.04-4+b2 +libalgorithm-merge-perl==0.08-3 +libann0==1.1.2+doc-6 +libaopalliance-java==20070526-5 +libapache-pom-java==10-2 +libapparmor1==2.11.0-3+deb9u2 +libapt-inst2.0==1.4.11 +libapt-pkg-perl==0.1.32 +libarchive-zip-perl==1.59-1+deb9u1 +libarchive13==3.2.2-2+deb9u2 +libasan3==6.3.0-18+deb9u1 +libasm-java==5.2-2 +libasound2==1.1.3-5 +libasound2-data==1.1.3-5 +libaspell15==0.60.7~20110707-3+b2 +libassuan0==2.4.3-2 +libasyncns0==0.8-6 +libatinject-jsr330-api-java==1.0+ds1-2 +libatk-bridge2.0-0==2.22.0-2 +libatk-wrapper-java==0.33.3-13+deb9u1 +libatk-wrapper-java-jni==0.33.3-13+deb9u1 +libatk1.0-0==2.22.0-1 +libatk1.0-data==2.22.0-1 +libatm1==1:2.5.1-2 +libatm1-dev==1:2.5.1-2 +libatomic1==6.3.0-18+deb9u1 +libatspi2.0-0==2.22.0-6+deb9u1 +libaudio2==1.9.4-5+b1 +libaudit-dev==1:2.6.7-2 +libaugeas0==1.8.0-1+deb9u1 +libauthen-sasl-perl==2.1600-1 +libavahi-client3==0.6.32-2 +libavahi-common-data==0.6.32-2 +libavahi-common3==0.6.32-2 +libavalon-framework-java==4.2.0-9 +libb-hooks-endofscope-perl==0.21-1 +libbabeltrace-ctf-dev==1.5.1-1 +libbabeltrace-ctf1==1.5.1-1 +libbabeltrace-dev==1.5.1-1 +libbabeltrace1==1.5.1-1 +libbatik-java==1.8-4+deb9u2 +libbind-export-dev==1:9.10.3.dfsg.P4-12.3+deb9u8 +libbind9-140==1:9.10.3.dfsg.P4-12.3+deb9u8 +libbison-dev==2:3.0.4.dfsg-1+b1 +libbit-vector-perl==7.4-1+b2 +libbluetooth3==5.43-2+deb9u3 +libboost-all-dev==1.62.0.1 +libboost-atomic-dev==1.62.0.1 +libboost-atomic1.62-dev==1.62.0+dfsg-4 +libboost-atomic1.62.0==1.62.0+dfsg-4 +libboost-chrono-dev==1.62.0.1 +libboost-chrono1.62-dev==1.62.0+dfsg-4 +libboost-chrono1.62.0==1.62.0+dfsg-4 +libboost-context-dev==1.62.0.1 +libboost-context1.62-dev==1.62.0+dfsg-4 +libboost-context1.62.0==1.62.0+dfsg-4 +libboost-coroutine-dev==1.62.0.1 +libboost-coroutine1.62-dev==1.62.0+dfsg-4 +libboost-coroutine1.62.0==1.62.0+dfsg-4 +libboost-date-time-dev==1.62.0.1 +libboost-date-time1.62-dev==1.62.0+dfsg-4 +libboost-date-time1.62.0==1.62.0+dfsg-4 +libboost-dev==1.62.0.1 +libboost-exception-dev==1.62.0.1 +libboost-exception1.62-dev==1.62.0+dfsg-4 +libboost-fiber-dev==1.62.0.1 +libboost-fiber1.62-dev==1.62.0+dfsg-4 +libboost-fiber1.62.0==1.62.0+dfsg-4 +libboost-filesystem-dev==1.62.0.1 +libboost-filesystem1.62-dev==1.62.0+dfsg-4 +libboost-filesystem1.62.0==1.62.0+dfsg-4 +libboost-graph-dev==1.62.0.1 +libboost-graph-parallel-dev==1.62.0.1 +libboost-graph-parallel1.62-dev==1.62.0+dfsg-4 +libboost-graph-parallel1.62.0==1.62.0+dfsg-4 +libboost-graph1.62-dev==1.62.0+dfsg-4 +libboost-graph1.62.0==1.62.0+dfsg-4 +libboost-iostreams-dev==1.62.0.1 +libboost-iostreams1.62-dev==1.62.0+dfsg-4 +libboost-iostreams1.62.0==1.62.0+dfsg-4 +libboost-locale-dev==1.62.0.1 +libboost-locale1.62-dev==1.62.0+dfsg-4 +libboost-locale1.62.0==1.62.0+dfsg-4 +libboost-log-dev==1.62.0.1 +libboost-log1.62-dev==1.62.0+dfsg-4 +libboost-log1.62.0==1.62.0+dfsg-4 +libboost-math-dev==1.62.0.1 +libboost-math1.62-dev==1.62.0+dfsg-4 +libboost-math1.62.0==1.62.0+dfsg-4 +libboost-mpi-dev==1.62.0.1 +libboost-mpi-python-dev==1.62.0.1 +libboost-mpi-python1.62-dev==1.62.0+dfsg-4 +libboost-mpi-python1.62.0==1.62.0+dfsg-4 +libboost-mpi1.62-dev==1.62.0+dfsg-4 +libboost-mpi1.62.0==1.62.0+dfsg-4 +libboost-program-options-dev==1.62.0.1 +libboost-program-options1.62-dev==1.62.0+dfsg-4 +libboost-program-options1.62.0==1.62.0+dfsg-4 +libboost-python-dev==1.62.0.1 +libboost-python1.62-dev==1.62.0+dfsg-4 +libboost-python1.62.0==1.62.0+dfsg-4 +libboost-random-dev==1.62.0.1 +libboost-random1.62-dev==1.62.0+dfsg-4 +libboost-random1.62.0==1.62.0+dfsg-4 +libboost-regex-dev==1.62.0.1 +libboost-regex1.62-dev==1.62.0+dfsg-4 +libboost-regex1.62.0==1.62.0+dfsg-4 +libboost-serialization-dev==1.62.0.1 +libboost-serialization1.62-dev==1.62.0+dfsg-4 +libboost-serialization1.62.0==1.62.0+dfsg-4 +libboost-signals-dev==1.62.0.1 +libboost-signals1.62-dev==1.62.0+dfsg-4 +libboost-signals1.62.0==1.62.0+dfsg-4 +libboost-system-dev==1.62.0.1 +libboost-system1.62-dev==1.62.0+dfsg-4 +libboost-system1.62.0==1.62.0+dfsg-4 +libboost-test-dev==1.62.0.1 +libboost-test1.62-dev==1.62.0+dfsg-4 +libboost-test1.62.0==1.62.0+dfsg-4 +libboost-thread-dev==1.62.0.1 +libboost-thread1.62-dev==1.62.0+dfsg-4 +libboost-thread1.62.0==1.62.0+dfsg-4 +libboost-timer-dev==1.62.0.1 +libboost-timer1.62-dev==1.62.0+dfsg-4 +libboost-timer1.62.0==1.62.0+dfsg-4 +libboost-tools-dev==1.62.0.1 +libboost-type-erasure-dev==1.62.0.1 +libboost-type-erasure1.62-dev==1.62.0+dfsg-4 +libboost-type-erasure1.62.0==1.62.0+dfsg-4 +libboost-wave-dev==1.62.0.1 +libboost-wave1.62-dev==1.62.0+dfsg-4 +libboost-wave1.62.0==1.62.0+dfsg-4 +libboost1.62-dev==1.62.0+dfsg-4 +libboost1.62-tools-dev==1.62.0+dfsg-4 +libbrlapi0.6==5.4-7+deb9u1 +libbsd-dev==0.8.3-1+deb9u1 +libbsd0==0.8.3-1+deb9u1 +libbsf-java==1:2.4.0-5 +libbsh-java==2.0b4-18 +libc-ares-dev==1.12.0-1+deb9u1 +libc-ares2==1.12.0-1+deb9u1 +libc-dev-bin==2.24-11+deb9u4 +libc6-dbg==2.24-11+deb9u4 +libc6-dev==2.24-11+deb9u4 +libc6-dev-i386==2.24-11+deb9u4 +libc6-dev-x32==2.24-11+deb9u4 +libc6-i386==2.24-11+deb9u4 +libc6-x32==2.24-11+deb9u4 +libcaca0==0.99.beta19-2.1~deb9u1 +libcacard0==1:2.5.0-3 +libcairo-gobject2==1.14.8-1+deb9u1 +libcairo2==1.14.8-1+deb9u1 +libcap-dev==1:2.25-1 +libcap-ng-dev==0.7.7-3+b1 +libcap2-bin==1:2.25-1 +libcarp-clan-perl==6.06-1 +libcc1-0==6.3.0-18+deb9u1 +libcdi-api-java==1.0-2 +libcdt5==2.38.0-17 +libcgi-fast-perl==1:2.12-1 +libcgi-pm-perl==4.35-1 +libcglib-java==3.2.4-1 +libcgmanager0==0.41-2 +libcgraph6==2.38.0-17 +libcilkrts5==6.3.0-18+deb9u1 +libclang-common-3.8-dev==1:3.8.1-24 +libclang1-3.8==1:3.8.1-24 +libclang1-3.9==1:3.9.1-9 +libclass-accessor-perl==0.34-1 +libclass-inspector-perl==1.31-1 +libclass-method-modifiers-perl==2.12-1 +libclass-xsaccessor-perl==1.19-2+b7 +libclassworlds-java==1.1-final-5 +libclone-perl==0.38-2+b1 +libcmocka-dev==1.0.1-3 +libcmocka0==1.0.1-3 +libcolord2==1.3.3-2 +libcommons-beanutils-java==1.9.3-1 +libcommons-cli-java==1.3.1-3 +libcommons-codec-java==1.10-1 +libcommons-collections3-java==3.2.2-1 +libcommons-configuration-java==1.10-4 +libcommons-digester-java==1.8.1-4 +libcommons-httpclient-java==3.1-12 +libcommons-io-java==2.5-1 +libcommons-lang-java==2.6-6 +libcommons-lang3-java==3.5-1 +libcommons-logging-java==1.2-1 +libcommons-net-java==3.5-1 +libcommons-parent-java==39-3 +libcommons-validator-java==1:1.5.1-1 +libconvert-binhex-perl==1.125-1 +libcroco3==0.6.11-3 +libcryptsetup4==2:1.7.3-4 +libcups2==2.2.1-8+deb9u6 +libcupsfilters1==1.11.6-3+deb9u1 +libcupsimage2==2.2.1-8+deb9u6 +libcurl3==7.52.1-5+deb9u13 +libcurl3-gnutls==7.52.1-5+deb9u13 +libcurl3-nss==7.52.1-5+deb9u13 +libcurl4-nss-dev==7.52.1-5+deb9u13 +libdaemon-dev==0.14-6 +libdaemon0==0.14-6 +libdata-optlist-perl==0.110-1 +libdatrie1==0.2.10-4+b1 +libdb-dev==5.3.1 +libdb5.3-dev==5.3.28-12+deb9u1 +libdbi1==0.9.0-4+deb9u2 +libdbus-1-3==1.10.32-0+deb9u1 +libdbus-1-dev==1.10.32-0+deb9u1 +libdbus-glib-1-2==0.108-2 +libdconf1==0.26.0-2+b1 +libdevel-globaldestruction-perl==0.14-1 +libdevmapper-event1.02.1==2:1.02.137-2 +libdevmapper1.02.1==2:1.02.137-2 +libdigest-hmac-perl==1.03+dfsg-1 +libdistro-info-perl==0.14 +libdjvulibre-text==3.5.27.1-7 +libdjvulibre21==3.5.27.1-7 +libdns-export162==1:9.10.3.dfsg.P4-12.3+deb9u8 +libdns162==1:9.10.3.dfsg.P4-12.3+deb9u8 +libdom4j-java==1.6.1+dfsg.3-2+deb9u1 +libdouble-conversion1==2.0.1-4 +libdoxia-core-java==1.1.4-6 +libdoxia-java==1.1.4-6 +libdoxia-sitetools-java==1.1.4-1.1 +libdpkg-perl==1.18.25 +libdrm-amdgpu1==2.4.74-1 +libdrm-dev==2.4.74-1 +libdrm-intel1==2.4.74-1 +libdrm-nouveau2==2.4.74-1 +libdrm-radeon1==2.4.74-1 +libdrm2==2.4.74-1 +libdw-dev==0.168-1 +libdw1==0.168-1 +libeasymock-java==3.4+ds-1 +libeatmydata1==105-5 +libeclipse-aether-java==1.0.2-1 +libedit-dev==3.1-20160903-3 +libedit2==3.1-20160903-3 +libegl1-mesa==13.0.6-1+b2 +libelf-dev==0.168-1 +libemail-valid-perl==1.202-1 +libencode-locale-perl==1.05-1 +libepoxy0==1.3.1-2 +liberror-perl==0.17024-1 +libestr0==0.1.10-2 +libevdev2==1.5.6+dfsg-1 +libevent-2.0-5==2.0.21-stable-3 +libevent-core-2.0-5==2.0.21-stable-3 +libevent-dev==2.0.21-stable-3 +libevent-extra-2.0-5==2.0.21-stable-3 +libevent-openssl-2.0-5==2.0.21-stable-3 +libevent-pthreads-2.0-5==2.0.21-stable-3 +libexpat1==2.2.0-2+deb9u3 +libexpat1-dev==2.2.0-2+deb9u3 +libexplain-dev==1.4.D001-6 +libexplain51==1.4.D001-6 +libexporter-tiny-perl==0.042-1 +libfabric1==1.4.0-1 +libfakeroot==1.21-3.1 +libfastjson4==0.99.4-1 +libfcgi-perl==0.78-2 +libfdt1==1.4.2-1 +libffi-dev==3.2.1-6 +libffi6==3.2.1-6 +libfftw3-double3==3.3.5-3 +libfile-basedir-perl==0.07-1 +libfile-chdir-perl==0.1008-1 +libfile-desktopentry-perl==0.22-1 +libfile-fcntllock-perl==0.22-3+b2 +libfile-homedir-perl==1.00-1 +libfile-listing-perl==6.04-1 +libfile-mimeinfo-perl==0.27-1 +libfile-stripnondeterminism-perl==0.034-1 +libfile-which-perl==1.21-1 +libfl-dev==2.6.1-1.3 +libflac8==1.3.2-2+deb9u1 +libfont-afm-perl==1.20-2 +libfontbox-java==1:1.8.12-1 +libfontconfig1==2.11.0-6.7+b1 +libfontenc1==1:1.1.3-1+b2 +libfop-java==1:2.1-6 +libfreetype6==2.6.3-3.2+deb9u2 +libfribidi0==0.19.7-1+deb9u1 +libgail-common==2.24.31-2 +libgail18==2.24.31-2 +libgbm1==13.0.6-1+b2 +libgc1c2==1:7.4.2-8 +libgcc-6-dev==6.3.0-18+deb9u1 +libgd3==2.2.4-2+deb9u5 +libgdbm3==1.8.3-14 +libgdk-pixbuf2.0-0==2.36.5-2+deb9u2 +libgdk-pixbuf2.0-common==2.36.5-2+deb9u2 +libgeoip1==1.6.9-4 +libgeronimo-interceptor-3.0-spec-java==1.0.1-3 +libgetopt-long-descriptive-perl==0.100-1 +libgfortran3==6.3.0-18+deb9u1 +libgif7==5.1.4-0.4 +libgirepository-1.0-1==1.50.0-1+b1 +libgit-wrapper-perl==0.047-1 +libgl1-mesa-dev==13.0.6-1+b2 +libgl1-mesa-dri==13.0.6-1+b2 +libgl1-mesa-glx==13.0.6-1+b2 +libglapi-mesa==13.0.6-1+b2 +libglew2.0==2.0.0-3+b1 +libglib2.0-0==2.50.3-2+deb9u2 +libglib2.0-bin==2.50.3-2+deb9u2 +libglib2.0-data==2.50.3-2+deb9u2 +libglib2.0-dev==2.50.3-2+deb9u2 +libglu1-mesa==9.0.0-2.1 +libglu1-mesa-dev==9.0.0-2.1 +libgmp-dev==2:6.1.2+dfsg-1 +libgmp10==2:6.1.2+dfsg-1 +libgmpxx4ldbl==2:6.1.2+dfsg-1 +libgnutls30==3.5.8-5+deb9u5 +libgomp1==6.3.0-18+deb9u1 +libgoogle-perftools4==2.5-2.2 +libgpgme11==1.8.0-3+b2 +libgpm2==1.20.4-6.2+b1 +libgraphite2-3==1.3.10-1 +libgs9==9.26a~dfsg-0+deb9u7 +libgs9-common==9.26a~dfsg-0+deb9u7 +libgsasl7==1.8.0-8+b2 +libgssapi-krb5-2==1.15-1+deb9u2 +libgstreamer1.0-0==1.10.4-1 +libgtest-dev==1.8.0-6 +libgtk-3-0==3.22.11-1 +libgtk-3-bin==3.22.11-1 +libgtk-3-common==3.22.11-1 +libgtk2.0-0==2.24.31-2 +libgtk2.0-bin==2.24.31-2 +libgtk2.0-common==2.24.31-2 +libgts-0.7-5==0.7.6+darcs121130-4 +libgts-bin==0.7.6+darcs121130-4 +libguava-java==19.0-1 +libgudev-1.0-0==230-3 +libguice-java==4.0-3 +libgvc6==2.38.0-17 +libgvpr2==2.38.0-17 +libhamcrest-java==1.3-6 +libharfbuzz-icu0==1.4.2-1 +libharfbuzz0b==1.4.2-1 +libhogweed4==3.3-1+b2 +libhtml-form-perl==6.03-1 +libhtml-format-perl==2.12-1 +libhtml-parser-perl==3.72-3 +libhtml-tagset-perl==3.20-3 +libhtml-tree-perl==5.03-2 +libhttp-cookies-perl==6.01-1 +libhttp-daemon-perl==6.01-1 +libhttp-date-perl==6.02-1 +libhttp-message-perl==6.11-1 +libhttp-negotiate-perl==6.00-2 +libhttpclient-java==4.5.2-2+deb9u1 +libhttpcore-java==4.4.6-1 +libhwloc-dev==1.11.5-1 +libhwloc-plugins==1.11.5-1 +libhwloc5==1.11.5-1 +libiberty-dev==20161220-1 +libibverbs-dev==1.2.1-2 +libibverbs1==1.2.1-2 +libice-dev==2:1.0.9-2 +libice6==2:1.0.9-2 +libicu-dev==57.1-6+deb9u4 +libicu57==57.1-6+deb9u4 +libidn2-0==0.16-1+deb9u1 +libijs-0.35==0.35-12 +libilmbase12==2.2.0-12 +libimport-into-perl==1.002005-1 +libinput-bin==1.6.3-1 +libinput10==1.6.3-1 +libio-html-perl==1.001-1 +libio-pty-perl==1:1.08-1.1+b2 +libio-sessiondata-perl==1.03-1 +libio-socket-inet6-perl==2.72-2 +libio-socket-ssl-perl==2.044-1 +libio-string-perl==1.08-3 +libio-stringy-perl==2.111-2 +libip4tc-dev==1.6.0+snapshot20161117-6 +libip4tc0==1.6.0+snapshot20161117-6 +libip6tc-dev==1.6.0+snapshot20161117-6 +libip6tc0==1.6.0+snapshot20161117-6 +libipc-run-perl==0.94-1+deb9u1 +libipc-system-simple-perl==1.25-3 +libiptc-dev==1.6.0+snapshot20161117-6 +libiptc0==1.6.0+snapshot20161117-6 +libirs-export141==1:9.10.3.dfsg.P4-12.3+deb9u8 +libisc-export160==1:9.10.3.dfsg.P4-12.3+deb9u8 +libisc160==1:9.10.3.dfsg.P4-12.3+deb9u8 +libisccc-export140==1:9.10.3.dfsg.P4-12.3+deb9u8 +libisccc140==1:9.10.3.dfsg.P4-12.3+deb9u8 +libisccfg-export140==1:9.10.3.dfsg.P4-12.3+deb9u8 +libisccfg140==1:9.10.3.dfsg.P4-12.3+deb9u8 +libisl15==0.18-1 +libisorelax-java==20041111-9 +libitext1-java==1.4-6 +libitm1==6.3.0-18+deb9u1 +libjansson-dev==2.9-1 +libjansson4==2.9-1 +libjaxen-java==1.1.6-1+deb9u1 +libjaxp1.3-java==1.3.05-2 +libjbig0==2.1-3.1+b2 +libjbig2dec0==0.13-4.1 +libjdom1-java==1.1.3-1 +libjemalloc-dev==3.6.0-9.1 +libjemalloc1==3.6.0-9.1 +libjetty9-java==9.2.21-1+deb9u1 +libjline-java==1.0-2 +libjpeg62-turbo==1:1.5.1-2+deb9u1 +libjs-bootstrap==3.3.7+dfsg-2+deb9u2 +libjs-jquery==3.1.1-2+deb9u1 +libjs-jquery-hotkeys==0~20130707+git2d51e3a9+dfsg-2 +libjs-jquery-isonscreen==1.2.0-1 +libjs-jquery-metadata==11-3 +libjs-jquery-tablesorter==11-3 +libjs-jquery-throttle-debounce==1.1+dfsg.1-1 +libjs-modernizr==2.6.2+ds1-1 +libjs-sphinxdoc==1.4.9-2 +libjs-twitter-bootstrap==2.0.2+dfsg-10 +libjs-underscore==1.8.3~dfsg-1 +libjsch-java==0.1.54-1 +libjson-c-dev==0.12.1-1.1+deb9u1 +libjson-c3==0.12.1-1.1+deb9u1 +libjson-glib-1.0-0==1.2.6-1 +libjson-glib-1.0-common==1.2.6-1 +libjsoncpp1==1.7.4-3 +libjsoup-java==1.10.2-1 +libjsr305-java==0.1~+svn49-10 +libjtidy-java==7+svn20110807-4 +libjudy-dev==1.0.5-5 +libjudydebian1==1.0.5-5 +libjxr-tools==1.1-6+b1 +libjxr0==1.1-6+b1 +libjzlib-java==1.1.3-1 +libk5crypto3==1.15-1+deb9u2 +libkeyutils1==1.5.9-9 +libkmod2==23-2 +libkpathsea6==2016.20160513.41080.dfsg-2+deb9u1 +libkrb5-3==1.15-1+deb9u2 +libkrb5support0==1.15-1+deb9u2 +libksba8==1.3.5-2 +libkyotocabinet16v5==1.2.76-4.2+b1 +liblcms2-2==2.8-4+deb9u1 +libldap-2.4-2==2.4.44+dfsg-5+deb9u8 +libldap-common==2.4.44+dfsg-5+deb9u8 +libldap2-dev==2.4.44+dfsg-5+deb9u8 +liblist-compare-perl==0.53-1 +liblist-moreutils-perl==0.416-1+b1 +libllvm3.8==1:3.8.1-24 +libllvm3.9==1:3.9.1-9 +liblocale-gettext-perl==1.07-3+b1 +liblog4j1.2-java==1.2.17-7+deb9u1 +liblogging-stdlog0==1.0.5-2+b2 +liblognorm5==2.0.1-1.1+b1 +liblqr-1-0==0.4.2-2+b2 +liblsan0==6.3.0-18+deb9u1 +libltdl-dev==2.4.6-2 +libltdl7==2.4.6-2 +liblua5.1-0==5.1.5-8.1+b2 +liblua5.1-0-dev==5.1.5-8.1+b2 +liblvm2app2.2==2.02.168-2 +liblvm2cmd2.02==2.02.168-2 +liblwp-mediatypes-perl==6.02-1 +liblwp-protocol-https-perl==6.06-2 +liblwres141==1:9.10.3.dfsg.P4-12.3+deb9u8 +liblzo2-2==2.08-1.2+b2 +liblzo2-dev==2.08-1.2+b2 +libmagic-mgc==1:5.30-1+deb9u3 +libmagic1==1:5.30-1+deb9u3 +libmagickcore-6.q16-3==8:6.9.7.4+dfsg-11+deb9u11 +libmagickcore-6.q16-3-extra==8:6.9.7.4+dfsg-11+deb9u11 +libmagickwand-6.q16-3==8:6.9.7.4+dfsg-11+deb9u11 +libmail-sendmail-perl==0.79.16-2 +libmailtools-perl==2.18-1 +libmailutils5==1:3.1.1-1 +libmariadbclient-dev==10.1.48-0+deb9u1 +libmariadbclient-dev-compat==10.1.48-0+deb9u1 +libmariadbclient18==10.1.48-0+deb9u1 +libmaven-ant-tasks-java==2.1.3-4 +libmaven-archiver-java==2.6-3 +libmaven-clean-plugin-java==2.5-1 +libmaven-common-artifact-filters-java==1.4-1 +libmaven-compiler-plugin-java==3.2-5 +libmaven-doxia-tools-java==1.2.1-2 +libmaven-filtering-java==1.1-1 +libmaven-jar-plugin-java==2.4-1 +libmaven-parent-java==21-2 +libmaven-plugin-tools-java==3.3-5 +libmaven-reporting-impl-java==2.3-1 +libmaven-resources-plugin-java==2.6-1 +libmaven-shared-incremental-java==1.1-1 +libmaven-shared-utils-java==3.0.0-1 +libmaven-site-plugin-java==2.1-4 +libmaven2-core-java==2.2.1-26 +libmaven3-core-java==3.3.9-4 +libmime-tools-perl==5.508-1 +libmng1==1.0.10+dfsg-3.1+b5 +libmnl-dev==1.0.4-2 +libmodule-implementation-perl==0.09-1 +libmodule-runtime-perl==0.014-2 +libmoo-perl==2.002005-1 +libmpc3==1.0.3-1+b2 +libmpdec2==2.4.2-1 +libmpfr4==3.1.5-1 +libmpx2==6.3.0-18+deb9u1 +libmsv-java==2009.1+dfsg1-5 +libmtdev1==1.1.5-1+b1 +libnamespace-clean-perl==0.27-1 +libnanomsg-dev==0.8~beta+dfsg-1+b1 +libnanomsg4==0.8~beta+dfsg-1+b1 +libncurses5==6.0+20161126-1+deb9u2 +libncurses5-dev==6.0+20161126-1+deb9u2 +libnet-dbus-perl==1.1.0-4+b1 +libnet-dns-perl==1.07-1 +libnet-domain-tld-perl==1.75-1 +libnet-http-perl==6.12-1 +libnet-ip-perl==1.26-1 +libnet-smtp-ssl-perl==1.04-1 +libnet-ssleay-perl==1.80-1 +libnetfilter-conntrack-dev==1.0.6-2 +libnetfilter-conntrack3==1.0.6-2 +libnetpbm10==2:10.0-15.3+b2 +libnewt-dev==0.52.19-1+b1 +libnewt0.52==0.52.19-1+b1 +libnfnetlink-dev==1.0.1-3 +libnfnetlink0==1.0.1-3 +libnftnl-dev==1.0.7-1 +libnftnl4==1.0.7-1 +libnghttp2-14==1.18.1-1+deb9u1 +libnih-dbus1==1.0.3-8 +libnih1==1.0.3-8 +libnl-3-200==3.2.27-2 +libnl-route-3-200==3.2.27-2 +libnpth0==1.3-1 +libnspr4==2:4.12-6 +libnss3==2:3.26.2-1.1+deb9u2 +libntlm0==1.4-8 +libnuma-dev==2.0.11-2.1 +libnuma1==2.0.11-2.1 +libnumber-compare-perl==0.03-1 +libnumber-range-perl==0.12-1 +libobjc-6-dev==6.3.0-18+deb9u1 +libobjc4==6.3.0-18+deb9u1 +libobjenesis-java==2.5.1-1 +libogg0==1.3.2-1 +libopenexr22==2.2.0-11+deb9u2 +libopenjp2-7==2.1.2-1.1+deb9u6 +libopenmpi-dev==2.0.2-2 +libopenmpi2==2.0.2-2 +libopus0==1.2~alpha2-1 +liboro-java==2.0.8a-12 +libosp5==1.5.2-13+b1 +libossp-uuid-perl==1.6.2-1.5+b4 +libossp-uuid16==1.6.2-1.5+b4 +libp11-kit0==0.23.3-2+deb9u1 +libpackage-stash-perl==0.37-1 +libpackage-stash-xs-perl==0.28-3+b1 +libpackagekit-glib2-18==1.1.5-2+deb9u2 +libpam-cap==1:2.25-1 +libpam-systemd==232-25+deb9u12 +libpam0g-dev==1.1.8-3.6 +libpango-1.0-0==1.40.5-1 +libpangocairo-1.0-0==1.40.5-1 +libpangoft2-1.0-0==1.40.5-1 +libpaper-utils==1.1.24+nmu5 +libpaper1==1.1.24+nmu5 +libparams-classify-perl==0.013-6+b1 +libparams-util-perl==1.07-3+b1 +libparams-validate-perl==1.26-1 +libparse-debianchangelog-perl==1.2.0-12 +libpath-iterator-rule-perl==1.009-1 +libpath-tiny-perl==0.100-1 +libpathplan4==2.38.0-17 +libpcap-dev==1.8.1-3 +libpcap0.8==1.8.1-3 +libpcap0.8-dev==1.8.1-3 +libpci-dev==1:3.5.2-1 +libpci3==1:3.5.2-1 +libpciaccess0==0.13.4-1+b2 +libpcre16-3==2:8.39-3 +libpcre3-dev==2:8.39-3 +libpcre32-3==2:8.39-3 +libpcrecpp0v5==2:8.39-3 +libpcsclite1==1.8.20-1 +libperl-dev==5.24.1-3+deb9u7 +libperl5.24==5.24.1-3+deb9u7 +libperlio-gzip-perl==0.19-1+b2 +libpgm-5.2-0==5.2.122~dfsg-2 +libpipeline1==1.4.1-2 +libpixman-1-0==0.34.0-1 +libplexus-ant-factory-java==1.0~alpha2.1-3 +libplexus-archiver-java==2.2-1+deb9u1 +libplexus-bsh-factory-java==1.0~alpha7-3.1 +libplexus-build-api-java==0.0.7-1 +libplexus-cipher-java==1.7-1 +libplexus-classworlds-java==1.5.0-5 +libplexus-classworlds2-java==2.5.2-1 +libplexus-cli-java==1.2-5 +libplexus-compiler-java==2.4-3 +libplexus-component-annotations-java==1.6-3 +libplexus-component-metadata-java==1.6-3 +libplexus-container-default-java==1.0-alpha-9-stable-1-7 +libplexus-container-default1.5-java==1.6-3 +libplexus-containers-java==1.0~beta3.0.7-8 +libplexus-containers1.5-java==1.6-3 +libplexus-i18n-java==1.0-beta-10-3 +libplexus-interactivity-api-java==1.0-alpha-6-7 +libplexus-interpolation-java==1.21-1 +libplexus-io-java==1.0~alpha5-2 +libplexus-sec-dispatcher-java==1.3.1-6 +libplexus-utils-java==1:1.5.15-4+deb9u1 +libplexus-utils2-java==3.0.22-1 +libplexus-velocity-java==1.2-1 +libpng-dev==1.6.28-1+deb9u1 +libpng16-16==1.6.28-1+deb9u1 +libpod-constants-perl==0.19-1 +libpolkit-agent-1-0==0.105-18+deb9u1 +libpolkit-backend-1-0==0.105-18+deb9u1 +libpolkit-gobject-1-0==0.105-18+deb9u1 +libpoppler64==0.48.0-2+deb9u4 +libpopt0==1.16-10+b2 +libpotrace0==1.13-3 +libprocps6==2:3.3.12-3+deb9u1 +libprotobuf-dev==3.0.0-9 +libprotobuf-lite10==3.0.0-9 +libprotobuf10==3.0.0-9 +libprotoc10==3.0.0-9 +libproxy1v5==0.4.14-2+deb9u2 +libpsl5==0.17.0-3 +libpsm-infinipath1==3.3+19.g67c0807.open-3 +libptexenc1==2016.20160513.41080.dfsg-2+deb9u1 +libpthread-stubs0-dev==0.3-4 +libpulse0==10.0-1+deb9u1 +libpython-all-dev==2.7.13-2 +libpython-dev==2.7.13-2 +libpython-stdlib==2.7.13-2 +libpython2.7==2.7.13-2+deb9u4 +libpython2.7-dev==2.7.13-2+deb9u4 +libpython2.7-minimal==2.7.13-2+deb9u4 +libpython2.7-stdlib==2.7.13-2+deb9u4 +libpython3-all-dbg==3.5.3-1 +libpython3-all-dev==3.5.3-1 +libpython3-dbg==3.5.3-1 +libpython3-dev==3.5.3-1 +libpython3-stdlib==3.5.3-1 +libpython3.5==3.5.3-1+deb9u3 +libpython3.5-dbg==3.5.3-1+deb9u3 +libpython3.5-dev==3.5.3-1+deb9u3 +libpython3.5-minimal==3.5.3-1+deb9u3 +libpython3.5-stdlib==3.5.3-1+deb9u3 +libqdox-java==1.12.1-2 +libqdox2-java==2.0~M3-3 +libqt4-dbus==4:4.8.7+dfsg-11+deb9u1 +libqt4-declarative==4:4.8.7+dfsg-11+deb9u1 +libqt4-designer==4:4.8.7+dfsg-11+deb9u1 +libqt4-dev==4:4.8.7+dfsg-11+deb9u1 +libqt4-dev-bin==4:4.8.7+dfsg-11+deb9u1 +libqt4-help==4:4.8.7+dfsg-11+deb9u1 +libqt4-network==4:4.8.7+dfsg-11+deb9u1 +libqt4-opengl==4:4.8.7+dfsg-11+deb9u1 +libqt4-opengl-dev==4:4.8.7+dfsg-11+deb9u1 +libqt4-qt3support==4:4.8.7+dfsg-11+deb9u1 +libqt4-script==4:4.8.7+dfsg-11+deb9u1 +libqt4-scripttools==4:4.8.7+dfsg-11+deb9u1 +libqt4-sql==4:4.8.7+dfsg-11+deb9u1 +libqt4-sql-mysql==4:4.8.7+dfsg-11+deb9u1 +libqt4-svg==4:4.8.7+dfsg-11+deb9u1 +libqt4-test==4:4.8.7+dfsg-11+deb9u1 +libqt4-xml==4:4.8.7+dfsg-11+deb9u1 +libqt4-xmlpatterns==4:4.8.7+dfsg-11+deb9u1 +libqt5concurrent5==5.7.1+dfsg-3+deb9u3 +libqt5core5a==5.7.1+dfsg-3+deb9u3 +libqt5dbus5==5.7.1+dfsg-3+deb9u3 +libqt5gui5==5.7.1+dfsg-3+deb9u3 +libqt5network5==5.7.1+dfsg-3+deb9u3 +libqt5opengl5==5.7.1+dfsg-3+deb9u3 +libqt5opengl5-dev==5.7.1+dfsg-3+deb9u3 +libqt5printsupport5==5.7.1+dfsg-3+deb9u3 +libqt5sql5==5.7.1+dfsg-3+deb9u3 +libqt5sql5-sqlite==5.7.1+dfsg-3+deb9u3 +libqt5svg5==5.7.1~20161021-2.1 +libqt5test5==5.7.1+dfsg-3+deb9u3 +libqt5widgets5==5.7.1+dfsg-3+deb9u3 +libqt5xml5==5.7.1+dfsg-3+deb9u3 +libqtcore4==4:4.8.7+dfsg-11+deb9u1 +libqtdbus4==4:4.8.7+dfsg-11+deb9u1 +libqtgui4==4:4.8.7+dfsg-11+deb9u1 +libquadmath0==6.3.0-18+deb9u1 +librdmacm1==1.1.0-2 +libreadline-dev==7.0-3 +libreadline5==5.2+dfsg-3+b1 +libreadline7==7.0-3 +libregexp-assemble-perl==0.36-1 +librelaxng-datatype-java==1.0+ds1-3 +librest-0.7-0==0.8.0-2 +librhash0==1.3.3-1+b2 +librhino-java==1.7.7.1-1 +librole-tiny-perl==2.000005-1 +librrd-dev==1.6.0-1+b2 +librrd8==1.6.0-1+b2 +librsvg2-2==2.40.21-0+deb9u1 +librsvg2-common==2.40.21-0+deb9u1 +librtmp1==2.4+20151223.gitfa8646d.1-1+b1 +libruby2.3==2.3.3-1+deb9u9 +libsasl2-2==2.1.27~101-g0780600+dfsg-3+deb9u1 +libsasl2-modules==2.1.27~101-g0780600+dfsg-3+deb9u1 +libsasl2-modules-db==2.1.27~101-g0780600+dfsg-3+deb9u1 +libsaxon-java==1:6.5.5-10 +libscalar-list-utils-perl==1:1.47-1 +libsdl1.2debian==1.2.15+dfsg1-4 +libseccomp2==2.3.1-2.1+deb9u1 +libselinux1-dev==2.6-3+b3 +libsensors4==1:3.4.0-4 +libsensors4-dev==1:3.4.0-4 +libsepol1-dev==2.6-2 +libservlet3.1-java==8.5.54-0+deb9u5 +libsigsegv2==2.10-5 +libsisu-inject-java==0.3.2-2 +libsisu-plexus-java==0.3.2-1 +libslang2==2.3.1-5 +libslang2-dev==2.3.1-5 +libslf4j-java==1.7.22-1 +libsm-dev==2:1.2.2-1+b3 +libsm6==2:1.2.2-1+b3 +libsndfile1==1.0.27-3+deb9u1 +libsnmp-base==5.7.3+dfsg-1.7+deb9u3 +libsnmp-dev==5.7.3+dfsg-1.7+deb9u3 +libsnmp30==5.7.3+dfsg-1.7+deb9u3 +libsoap-lite-perl==1.20-1 +libsocket6-perl==0.27-1+b1 +libsodium18==1.0.11-2 +libsort-key-perl==1.33-1+b3 +libsort-versions-perl==1.62-1 +libsoup-gnome2.4-1==2.56.0-2+deb9u2 +libsoup2.4-1==2.56.0-2+deb9u2 +libspice-server1==0.12.8-2.1+deb9u4 +libsqlite3-0==3.16.2-5+deb9u3 +libssh2-1==1.7.0-1+deb9u1 +libssl-dev==1.1.0l-1~deb9u3 +libssl1.0.2==1.0.2u-1~deb9u4 +libssl1.1==1.1.0l-1~deb9u3 +libstax-java==1.2.0-3 +libstdc++-6-dev==6.3.0-18+deb9u1 +libstrictures-perl==2.000003-1 +libstring-copyright-perl==0.003005-1 +libstring-escape-perl==2010.002-1 +libsub-exporter-perl==0.986-1 +libsub-exporter-progressive-perl==0.001013-1 +libsub-identify-perl==0.12-2+b1 +libsub-install-perl==0.928-1 +libsub-name-perl==0.21-1 +libsubunit-dev==1.1.0-3 +libsubunit0==1.1.0-3 +libsurefire-java==2.17-3 +libswitch-perl==2.17-2 +libsynctex1==2016.20160513.41080.dfsg-2+deb9u1 +libsys-hostname-long-perl==1.5-1 +libsystemd-dev==232-25+deb9u12 +libtask-weaken-perl==1.04-1 +libtasn1-6==4.10-1.1+deb9u1 +libtcl8.6==8.6.6+dfsg-1+b1 +libtcmalloc-minimal4==2.5-2.2 +libtexlua52==2016.20160513.41080.dfsg-2+deb9u1 +libtexluajit2==2016.20160513.41080.dfsg-2+deb9u1 +libtext-charwidth-perl==0.04-7+b5 +libtext-glob-perl==0.10-1 +libtext-iconv-perl==1.7-5+b4 +libtext-levenshtein-perl==0.13-1 +libtext-unidecode-perl==1.30-1 +libtext-wrapi18n-perl==0.06-7.1 +libthai-data==0.1.26-1 +libthai0==0.1.26-1 +libtie-ixhash-perl==1.23-2 +libtiff5==4.0.8-2+deb9u5 +libtimedate-perl==2.3000-2+deb9u1 +libtinfo-dev==6.0+20161126-1+deb9u2 +libtinyxml2-4==4.0.1-1 +libtinyxml2-dev==4.0.1-1 +libtk8.6==8.6.6-1+b1 +libtool==2.4.6-2 +libtool-bin==2.4.6-2 +libtry-tiny-perl==0.28-1 +libtsan0==6.3.0-18+deb9u1 +libtxc-dxtn-s2tc==1.0+git20151227-2 +libubsan0==6.3.0-18+deb9u1 +libudev-dev==232-25+deb9u12 +libunicode-utf8-perl==0.60-1+b3 +libunistring0==0.9.6+really0.9.3-0.1 +libunwind-dev==1.1-4.1 +libunwind8==1.1-4.1 +libunwind8-dev==1.1-4.1 +liburi-perl==1.71-1 +libusb-0.1-4==2:0.1.12-30 +libusb-1.0-0==2:1.0.21-1 +libusb-1.0-0-dev==2:1.0.21-1 +libusb-1.0-doc==2:1.0.21-1 +libusb-dev==2:0.1.12-30 +libusbredirparser1==0.7.1-1 +libutempter0==1.1.6-3 +libuv1==1.34.2-1~bpo9+1 +libvariable-magic-perl==0.61-1 +libvdeplug2==2.3.2+r586-2.1 +libvirt-clients==3.0.0-4+deb9u5 +libvirt0==3.0.0-4+deb9u5 +libvorbis0a==1.3.5-4+deb9u2 +libvorbisenc2==1.3.5-4+deb9u2 +libwacom-bin==0.22-1+b1 +libwacom-common==0.22-1 +libwacom2==0.22-1+b1 +libwagon-java==1.0.0-9 +libwagon2-java==2.10-6 +libwayland-client0==1.12.0-1+deb9u1 +libwayland-cursor0==1.12.0-1+deb9u1 +libwayland-egl1-mesa==13.0.6-1+b2 +libwayland-server0==1.12.0-1+deb9u1 +libwebp6==0.5.2-1 +libwebpdemux2==0.5.2-1 +libwebpmux2==0.5.2-1 +libwmf0.2-7==0.2.8.4-10.6 +libwrap0==7.6.q-26 +libwrap0-dev==7.6.q-26 +libwww-perl==6.15-1 +libwww-robotrules-perl==6.01-1 +libx11-6==2:1.6.4-3+deb9u3 +libx11-data==2:1.6.4-3+deb9u3 +libx11-dev==2:1.6.4-3+deb9u3 +libx11-doc==2:1.6.4-3+deb9u3 +libx11-protocol-perl==0.56-7 +libx11-xcb-dev==2:1.6.4-3+deb9u3 +libx11-xcb1==2:1.6.4-3+deb9u3 +libx32asan3==6.3.0-18+deb9u1 +libx32atomic1==6.3.0-18+deb9u1 +libx32cilkrts5==6.3.0-18+deb9u1 +libx32gcc-6-dev==6.3.0-18+deb9u1 +libx32gcc1==1:6.3.0-18+deb9u1 +libx32gomp1==6.3.0-18+deb9u1 +libx32itm1==6.3.0-18+deb9u1 +libx32quadmath0==6.3.0-18+deb9u1 +libx32stdc++6==6.3.0-18+deb9u1 +libx32ubsan0==6.3.0-18+deb9u1 +libxalan2-java==2.7.1-9 +libxapian30==1.4.3-2+deb9u3 +libxau-dev==1:1.0.8-1 +libxau6==1:1.0.8-1 +libxaw7==2:1.0.13-1+b2 +libxbean-java==4.5-4 +libxcb-dri2-0==1.12-1 +libxcb-dri2-0-dev==1.12-1 +libxcb-dri3-0==1.12-1 +libxcb-dri3-dev==1.12-1 +libxcb-glx0==1.12-1 +libxcb-glx0-dev==1.12-1 +libxcb-icccm4==0.4.1-1 +libxcb-image0==0.4.0-1+b2 +libxcb-keysyms1==0.4.0-1+b2 +libxcb-present-dev==1.12-1 +libxcb-present0==1.12-1 +libxcb-randr0==1.12-1 +libxcb-randr0-dev==1.12-1 +libxcb-render-util0==0.3.9-1 +libxcb-render0==1.12-1 +libxcb-render0-dev==1.12-1 +libxcb-shape0==1.12-1 +libxcb-shape0-dev==1.12-1 +libxcb-shm0==1.12-1 +libxcb-sync-dev==1.12-1 +libxcb-sync1==1.12-1 +libxcb-util0==0.3.8-3+b2 +libxcb-xfixes0==1.12-1 +libxcb-xfixes0-dev==1.12-1 +libxcb-xinerama0==1.12-1 +libxcb-xkb1==1.12-1 +libxcb1==1.12-1 +libxcb1-dev==1.12-1 +libxcomposite1==1:0.4.4-2 +libxcursor1==1:1.1.14-1+deb9u2 +libxdamage-dev==1:1.1.4-2+b3 +libxdamage1==1:1.1.4-2+b3 +libxdelta2==1.1.3-9.1+b1 +libxdmcp-dev==1:1.1.2-3 +libxdmcp6==1:1.1.2-3 +libxdot4==2.38.0-17 +libxen-4.8==4.8.5.final+shim4.10.4-1+deb9u12 +libxenstore3.0==4.8.5.final+shim4.10.4-1+deb9u12 +libxerces2-java==2.11.0-7 +libxext-dev==2:1.3.3-1+b2 +libxext6==2:1.3.3-1+b2 +libxfixes-dev==1:5.0.3-1 +libxfixes3==1:5.0.3-1 +libxft2==2.3.2-1+b2 +libxi6==2:1.7.9-1 +libxinerama1==2:1.1.3-1+b3 +libxkbcommon-x11-0==0.7.1-2~deb9u1 +libxkbcommon0==0.7.1-2~deb9u1 +libxml-commons-external-java==1.4.01-2 +libxml-commons-resolver1.1-java==1.2-7 +libxml-libxml-perl==2.0128+dfsg-1+deb9u1 +libxml-namespacesupport-perl==1.11-1 +libxml-parser-perl==2.44-2+b1 +libxml-sax-base-perl==1.07-1 +libxml-sax-expat-perl==0.40-2 +libxml-sax-perl==0.99+dfsg-2 +libxml-simple-perl==2.22-1 +libxml-twig-perl==1:3.50-1 +libxml-xpathengine-perl==0.13-1 +libxml2==2.9.4+dfsg1-2.2+deb9u3 +libxml2-dev==2.9.4+dfsg1-2.2+deb9u3 +libxml2-utils==2.9.4+dfsg1-2.2+deb9u3 +libxmlgraphics-commons-java==2.1-2 +libxmlrpc-lite-perl==0.717-1 +libxmu6==2:1.1.2-2 +libxmuu1==2:1.1.2-2 +libxom-java==1.2.10-1 +libxpm4==1:3.5.12-1 +libxpp2-java==2.1.10-7 +libxpp3-java==1.1.4c-2 +libxrandr2==2:1.5.1-1 +libxrender1==1:0.9.10-1 +libxshmfence-dev==1.2-1+b2 +libxshmfence1==1.2-1+b2 +libxslt1.1==1.1.29-2.1+deb9u2 +libxss1==1:1.2.2-1 +libxt-dev==1:1.1.5-1 +libxt6==1:1.1.5-1 +libxtables-dev==1.6.0+snapshot20161117-6 +libxtables12==1.6.0+snapshot20161117-6 +libxtst6==2:1.2.3-1 +libxv1==2:1.0.11-1 +libxxf86dga1==2:1.1.4-1+b3 +libxxf86vm-dev==1:1.1.4-1+b2 +libxxf86vm1==1:1.1.4-1+b2 +libyajl2==2.1.0-2+b3 +libyaml-0-2==0.1.7-2 +libyaml-dev==0.1.7-2 +libyaml-libyaml-perl==0.63-2 +libyaml-tiny-perl==1.70-1 +libzmq3-dev==4.2.1-4+deb9u3 +libzmq5==4.2.1-4+deb9u3 +libzzip-0-13==0.13.62-3.2~deb9u1 +licensecheck==3.0.29-1 +lintian==2.5.50.4 +linux-compiler-gcc-6-x86==4.9.246-2 +linux-headers-4.9.0-14-amd64==4.9.246-2 +linux-headers-4.9.0-14-common==4.9.246-2 +linux-headers-amd64==4.9+80+deb9u12 +linux-kbuild-4.9==4.9.246-2 +linux-libc-dev==4.9.246-2 +linuxdoc-tools==0.9.72-4 +llvm-3.8==1:3.8.1-24 +llvm-3.8-dev==1:3.8.1-24 +llvm-3.8-runtime==1:3.8.1-24 +lmodern==2.004.5-3 +logrotate==3.11.0-0.1 +lsb-release==9.20161125 +lsof==4.89+dfsg-0.1 +lua-bitop==1.0.2-4 +lua-bitop-dev==1.0.2-4 +lua-cjson==2.1.0+dfsg-2 +lua-cjson-dev==2.1.0+dfsg-2 +lvm2==2.02.168-2 +lynx==2.8.9dev11-1 +lynx-common==2.8.9dev11-1 +m4==1.4.18-1 +mailutils==1:3.1.1-1 +mailutils-common==1:3.1.1-1 +make==4.1-9.1 +man-db==2.7.6.1-2 +manpages==4.10-2 +manpages-dev==4.10-2 +maven==3.3.9-4 +maven-debian-helper==2.1.3 +maven-repo-helper==1.9.2 +mesa-common-dev==13.0.6-1+b2 +mesa-utils==8.3.0-3 +mime-support==3.60 +module-assistant==0.11.9 +mpi-default-bin==1.8 +mpi-default-dev==1.8 +mysql-common==5.8+1.0.2 +ncurses-term==6.0+20161126-1+deb9u2 +netbase==5.4 +netpbm==2:10.0-15.3+b2 +ocl-icd-libopencl1==2.2.11-1 +openjdk-8-jdk==8u275-b01-1~deb9u1 +openjdk-8-jdk-headless==8u275-b01-1~deb9u1 +openjdk-8-jre==8u275-b01-1~deb9u1 +openjdk-8-jre-headless==8u275-b01-1~deb9u1 +openmpi-bin==2.0.2-2 +openmpi-common==2.0.2-2 +opensp==1.5.2-13+b1 +openssh-client==1:7.4p1-10+deb9u7 +openssh-server==1:7.4p1-10+deb9u7 +openssh-sftp-server==1:7.4p1-10+deb9u7 +openssl==1.1.0l-1~deb9u3 +packagekit==1.1.5-2+deb9u2 +packagekit-tools==1.1.5-2+deb9u2 +patch==2.7.5-1+deb9u2 +patchutils==0.3.4-2 +pbuilder==0.228.7 +pbzip2==1.1.9-1+b1 +perl==5.24.1-3+deb9u7 +perl-modules-5.24==5.24.1-3+deb9u7 +perl-openssl-defaults==3 +php-cli==1:7.0+49 +php-codecoverage==4.0.0+dfsg-1 +php-common==1:49 +php-deepcopy==1.5.5-1 +php-doctrine-instantiator==1.0.5-2 +php-file-iterator==1.4.1-2 +php-pear==1:1.10.1+submodules+notgz-9+deb9u2 +php-phpdocumentor-reflection-docblock==2.0.4-2 +php-phpspec-prophecy==1.6.2-1 +php-symfony-yaml==2.8.7+dfsg-1.3+deb9u3 +php-text-template==1.2.1-2 +php-timer==1.0.8-1 +php-token-stream==1.4.8-2 +php-xml==1:7.0+49 +php7.0-cli==7.0.33-0+deb9u10 +php7.0-common==7.0.33-0+deb9u10 +php7.0-json==7.0.33-0+deb9u10 +php7.0-opcache==7.0.33-0+deb9u10 +php7.0-readline==7.0.33-0+deb9u10 +php7.0-xml==7.0.33-0+deb9u10 +phpunit==5.4.6-2~deb9u1 +phpunit-code-unit-reverse-lookup==1.0.0-2 +phpunit-comparator==1.2.0-2 +phpunit-diff==1.4.1-2 +phpunit-environment==1.3.7-1 +phpunit-exporter==1.2.2-1 +phpunit-global-state==1.1.1-2 +phpunit-mock-object==3.2.3-1 +phpunit-object-enumerator==1.0.0-2 +phpunit-recursion-context==1.0.2-2 +phpunit-resource-operations==1.0.0-2 +phpunit-version==2.0.0-2 +pigz==2.3.4-1 +pinentry-curses==1.0.0-2 +pkg-config==0.29-4+b1 +pkg-php-tools==1.35 +po-debconf==1.0.20 +policykit-1==0.105-18+deb9u1 +poppler-data==0.4.7-8 +preview-latex-style==11.90-1 +pristine-tar==1.38 +procmail==3.22-25+deb9u1 +procps==2:3.3.12-3+deb9u1 +prosper==1.00.4+cvs.2007.05.01-4.1 +protobuf-compiler==3.0.0-9 +ps2eps==1.68+binaryfree-2 +psmisc==22.21-2.1+b2 +psutils==1.17.dfsg-4 +publicsuffix==20190415.1030-0+deb9u1 +pylint==1.6.5-1 +python==2.7.13-2 +python-alabaster==0.7.8-1 +python-all==2.7.13-2 +python-all-dev==2.7.13-2 +python-apt==1.4.3 +python-apt-common==1.4.3 +python-astroid==1.4.9-1 +python-attr==16.3.0-1 +python-babel==2.3.4+dfsg.1-2 +python-babel-localedata==2.3.4+dfsg.1-2 +python-backports.functools-lru-cache==1.3-1 +python-bs4==4.5.3-1 +python-cffi-backend==1.9.1-2 +python-chardet==2.3.0-2 +python-click==6.6-1 +python-colorama==0.3.7-1 +python-constantly==15.1.0-1 +python-cov-core==1.15.0-1 +python-coverage==4.2+dfsg.1-2 +python-crypto==2.6.1-7 +python-cryptography==1.7.1-3+deb9u2 +python-dateutil==2.5.3-2 +python-dbus==1.2.4-1+b1 +python-debian==0.1.30 +python-dev==2.7.13-2 +python-docutils==0.13.1+dfsg-2 +python-enum34==1.1.6-1 +python-gi==3.22.0-2 +python-gpg==1.8.0-3+b2 +python-html5lib==0.999999999-1 +python-idna==2.2-1 +python-imagesize==0.7.1-1 +python-incremental==16.10.1-3 +python-ipaddr==2.1.11-2 +python-ipaddress==1.0.17-1 +python-isort==4.2.5+ds1-2+deb9u1 +python-jinja2==2.8-1 +python-keyring==10.1-1 +python-keyrings.alt==1.3-1 +python-lazy-object-proxy==1.2.2-1 +python-lxml==3.7.1-1+deb9u3 +python-markupsafe==0.23-3 +python-minimal==2.7.13-2 +python-nose2==0.6.5-2 +python-openssl==16.2.0-1 +python-pam==0.4.2-13.2 +python-parse==1.6.6-0.1 +python-pil==4.0.0-4+deb9u2 +python-pip-whl==9.0.1-2+deb9u2 +python-pkg-resources==33.1.1-1 +python-py==1.4.32-3 +python-pyasn1==0.1.9-2 +python-pyasn1-modules==0.0.7-0.1 +python-pygments==2.2.0+dfsg-1 +python-pytest==3.0.6-1 +python-pytest-cov==2.4.0-2 +python-requests==2.12.4-1 +python-roman==2.0.0-2 +python-secretstorage==2.3.1-2 +python-serial==3.2.1-1 +python-service-identity==16.0.0-2 +python-setuptools==33.1.1-1 +python-six==1.10.0-3 +python-sphinx==1.4.9-2 +python-sphinx-rtd-theme==0.1.9-1 +python-stdeb==0.8.5-1 +python-tk==2.7.13-1 +python-twisted==16.6.0-2 +python-twisted-bin==16.6.0-2 +python-twisted-core==16.6.0-2 +python-tz==2016.7-0.3 +python-urllib3==1.19.1-1 +python-webencodings==0.5-2 +python-wheel==0.29.0-2 +python-wrapt==1.9.0-2 +python-xdg==0.25-4 +python-zope.interface==4.3.2-1 +python2.7==2.7.13-2+deb9u4 +python2.7-dev==2.7.13-2+deb9u4 +python2.7-minimal==2.7.13-2+deb9u4 +python3==3.5.3-1 +python3-alabaster==0.7.8-1 +python3-all==3.5.3-1 +python3-all-dbg==3.5.3-1 +python3-all-dev==3.5.3-1 +python3-apt==1.4.3 +python3-babel==2.3.4+dfsg.1-2 +python3-cffi-backend==1.9.1-2 +python3-chardet==2.3.0-2 +python3-crypto==2.6.1-7 +python3-cryptography==1.7.1-3+deb9u2 +python3-dbg==3.5.3-1 +python3-dbus==1.2.4-1+b1 +python3-debian==0.1.30 +python3-dev==3.5.3-1 +python3-docutils==0.13.1+dfsg-2 +python3-gi==3.22.0-2 +python3-idna==2.2-1 +python3-imagesize==0.7.1-1 +python3-jinja2==2.8-1 +python3-keyring==10.1-1 +python3-keyrings.alt==1.3-1 +python3-magic==1:5.30-1+deb9u3 +python3-markupsafe==0.23-3 +python3-minimal==3.5.3-1 +python3-pil==4.0.0-4+deb9u2 +python3-pkg-resources==33.1.1-1 +python3-pyasn1==0.1.9-2 +python3-pycurl==7.43.0-2 +python3-pygments==2.2.0+dfsg-1 +python3-roman==2.0.0-2 +python3-secretstorage==2.3.1-2 +python3-setuptools==33.1.1-1 +python3-six==1.10.0-3 +python3-software-properties==0.96.20.2-1+deb9u1 +python3-sphinx==1.4.9-2 +python3-tz==2016.7-0.3 +python3-wheel==0.29.0-2 +python3-xdg==0.25-4 +python3.5==3.5.3-1+deb9u3 +python3.5-dbg==3.5.3-1+deb9u3 +python3.5-dev==3.5.3-1+deb9u3 +python3.5-minimal==3.5.3-1+deb9u3 +qdbus==4:4.8.7+dfsg-11+deb9u1 +qemu-kvm==1:2.8+dfsg-6+deb9u13 +qemu-system-common==1:2.8+dfsg-6+deb9u13 +qemu-system-x86==1:2.8+dfsg-6+deb9u13 +qemu-utils==1:2.8+dfsg-6+deb9u13 +qt-at-spi==0.4.0-5 +qt4-linguist-tools==4:4.8.7+dfsg-11+deb9u1 +qt4-qmake==4:4.8.7+dfsg-11+deb9u1 +qt5-default==5.7.1+dfsg-3+deb9u3 +qt5-gtk-platformtheme==5.7.1+dfsg-3+deb9u3 +qt5-qmake==5.7.1+dfsg-3+deb9u3 +qtbase5-dev==5.7.1+dfsg-3+deb9u3 +qtbase5-dev-tools==5.7.1+dfsg-3+deb9u3 +qtchooser==63-g13a3d08-1 +qtcore4-l10n==4:4.8.7+dfsg-11+deb9u1 +qttranslations5-l10n==5.7.1~20161021-1 +quilt==0.65-2~bpo9+1 +rake==10.5.0-2+deb9u1 +readline-common==7.0-3 +rename==0.20-4 +rhino==1.7.7.1-1 +rrdtool==1.6.0-1+b2 +rsync==3.1.2-1+deb9u2 +rsyslog==8.24.0-1 +ruby==1:2.3.3 +ruby-all-dev==1:2.3.3 +ruby-did-you-mean==1.0.0-2 +ruby-minitest==5.9.0-1 +ruby-net-telnet==0.1.1-2 +ruby-power-assert==0.3.0-1 +ruby-setup==3.4.1-9 +ruby-test-unit==3.1.7-2 +ruby2.3==2.3.3-1+deb9u9 +ruby2.3-dev==2.3.3-1+deb9u9 +rubygems-integration==1.11 +seabios==1.10.2-1 +sgml-base==1.29 +sgml-data==2.0.10 +shared-mime-info==1.8-1+deb9u1 +software-properties-common==0.96.20.2-1+deb9u1 +sphinx-common==1.4.9-2 +sphinx-rtd-theme-common==0.1.9-1 +squashfs-tools==1:4.3-3+deb9u1 +stgit==0.17.1-1 +strace==4.15-2 +sudo==1.8.19p1-2.1+deb9u3 +swig==3.0.10-1.1 +swig3.0==3.0.10-1.1 +systemd==232-25+deb9u12 +systemd-shim==10-3 +t1utils==1.39-2 +tcl==8.6.0+9 +tcl8.6==8.6.6+dfsg-1+b1 +tcpd==7.6.q-26 +telnet==0.17-41 +tex-common==6.06 +tex-gyre==20160520-1 +texi2html==1.82+dfsg1-5 +texinfo==6.3.0.dfsg.1-1+b2 +texlive-base==2016.20170123-5 +texlive-binaries==2016.20160513.41080.dfsg-2+deb9u1 +texlive-extra-utils==2016.20170123-5 +texlive-font-utils==2016.20170123-5 +texlive-fonts-recommended==2016.20170123-5 +texlive-fonts-recommended-doc==2016.20170123-5 +texlive-generic-extra==2016.20170123-5 +texlive-generic-recommended==2016.20170123-5 +texlive-latex-base==2016.20170123-5 +texlive-latex-base-doc==2016.20170123-5 +texlive-latex-extra==2016.20170123-5 +texlive-latex-extra-doc==2016.20170123-5 +texlive-latex-recommended==2016.20170123-5 +texlive-latex-recommended-doc==2016.20170123-5 +texlive-pictures==2016.20170123-5 +texlive-pictures-doc==2016.20170123-5 +texlive-pstricks==2016.20170123-5 +texlive-pstricks-doc==2016.20170123-5 +tipa==2:1.3-20 +tk==8.6.0+9 +tk8.6==8.6.6-1+b1 +tk8.6-blt2.5==2.5.3+dfsg-3 +ucf==3.0036 +unattended-upgrades==0.93.1+nmu1 +unzip==6.0-21+deb9u2 +velocity==1.7-5 +vim==2:8.0.0197-4+deb9u3 +vim-common==2:8.0.0197-4+deb9u3 +vim-runtime==2:8.0.0197-4+deb9u3 +wdiff==1.2.2-2 +wget==1.18-5+deb9u3 +x11-common==1:7.7+19 +x11-utils==7.7+3+b1 +x11-xserver-utils==7.7+7+b1 +x11proto-core-dev==7.0.31-1 +x11proto-damage-dev==1:1.2.1-2 +x11proto-dri2-dev==2.8-2 +x11proto-fixes-dev==1:5.0-2 +x11proto-gl-dev==1.4.17-1 +x11proto-input-dev==2.3.2-1 +x11proto-kb-dev==1.0.7-1 +x11proto-xext-dev==7.3.0-1 +x11proto-xf86vidmode-dev==2.3.1-2 +xauth==1:1.0.9-1+b2 +xbitmaps==1.1.1-2 +xdelta==1.1.3-9.1+b1 +xdelta3==3.0.11-dfsg-1+b1 +xdg-user-dirs==0.15-2+b1 +xdg-utils==1.1.1-1+deb9u2 +xkb-data==2.19-1+deb9u1 +xml-core==0.17 +xmlto==0.0.28-1 +xorg-sgml-doctools==1:1.11-1 +xsltproc==1.1.29-2.1+deb9u2 +xterm==327-2+deb9u1 +xtrans-dev==1.3.5-1 +xxd==2:8.0.0197-4+deb9u3 +xz-utils==5.2.2-1.2+b1 +zip==3.0-11+b1 +zlib1g-dev==1:1.2.8.dfsg-5 \ No newline at end of file diff --git a/files/build/versions/dockers/sonic-slave-stretch/versions-py2 b/files/build/versions/dockers/sonic-slave-stretch/versions-py2 new file mode 100644 index 000000000000..2e3b1f405aa4 --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-stretch/versions-py2 @@ -0,0 +1,79 @@ +alabaster==0.7.8 +astroid==1.4.9 +attrs==16.3.0 +Babel==2.3.4 +backports.functools-lru-cache==1.3 +beautifulsoup4==4.5.3 +chardet==2.3.0 +click==6.6 +colorama==0.3.7 +constantly==15.1.0 +cov-core==1.15.0 +coverage==4.2 +crc16==0.1.1 +cryptography==1.7.1 +ctypesgen==0.post125 +docutils==0.13.1 +enum34==1.1.6 +gbp==0.8.12.2 +gcovr==3.3 +gpg==1.8.0 +html5lib==0.999999999 +idna==2.2 +imagesize==0.7.1 +incremental==16.10.1 +ipaddr==2.1.11 +ipaddress==1.0.17 +isort==4.2.5 +j2cli==0.3.10 +Jinja2==2.11.3 +keyring==10.1 +keyrings.alt==1.3 +lazy-object-proxy==1.2.2 +lxml==4.6.2 +M2Crypto==0.36.0 +MarkupSafe==1.1.1 +mmh3==2.5.1 +mockredispy==2.9.3 +nose2==0.6.5 +PAM==0.4.2 +parse==1.6.6 +pexpect==4.6.0 +Pillow==4.0.0 +ptyprocess==0.7.0 +py==1.4.32 +pyang==2.1.1 +pyasn1==0.1.9 +pyasn1-modules==0.0.7 +pycrypto==2.6.1 +Pygments==2.2.0 +pygobject==3.22.0 +pylint==1.6.5 +Pympler==0.8 +pyOpenSSL==16.2.0 +pyserial==3.2.1 +Pyste==0.9.10 +pytest==3.0.6 +pytest-cov==2.4.0 +pytest-runner==4.4 +python-apt==1.4.3 +python-dateutil==2.5.3 +python-debian==0.1.30 +pytz==2016.7 +pyxdg==0.25 +PyYAML==5.3.1 +requests==2.12.4 +roman==2.0.0 +SecretStorage==2.3.1 +service-identity==16.0.0 +six==1.10.0 +Sphinx==1.4.9 +sphinx-rtd-theme==0.1.9 +stdeb==0.8.5 +stgit===0.17.1-dirty +Twisted==16.6.0 +typing==3.7.4.3 +urllib3==1.19.1 +webencodings==0.5 +wrapt==1.9.0 +zope.interface==4.3.2 \ No newline at end of file diff --git a/files/build/versions/dockers/sonic-slave-stretch/versions-py3 b/files/build/versions/dockers/sonic-slave-stretch/versions-py3 new file mode 100644 index 000000000000..7b9cc6ebd6ad --- /dev/null +++ b/files/build/versions/dockers/sonic-slave-stretch/versions-py3 @@ -0,0 +1,36 @@ +alabaster==0.7.8 +Babel==2.3.4 +bitarray==1.6.3 +chardet==2.3.0 +cryptography==1.7.1 +devscripts==2.17.6+deb9u2 +docutils==0.13.1 +file-magic==0.3.0 +idna==2.2 +imagesize==0.7.1 +Jinja2==2.8 +keyring==10.1 +keyrings.alt==1.3 +lxml==4.6.2 +MarkupSafe==0.23 +mockredispy==2.9.3 +Pillow==4.0.0 +pyang==2.4.0 +pyangbind==0.8.1 +pyasn1==0.1.9 +pycrypto==2.6.1 +pycurl==7.43.0 +Pygments==2.2.0 +pygobject==3.22.0 +python-apt==1.4.3 +python-debian==0.1.30 +pytz==2016.7 +pyxdg==0.25 +PyYAML==5.3.1 +redis==3.5.3 +regex==2020.11.13 +roman==2.0.0 +SecretStorage==2.3.1 +six==1.10.0 +Sphinx==1.4.9 +unattended-upgrades==0.1 \ No newline at end of file diff --git a/files/build/versions/host-base-image/versions-deb-buster b/files/build/versions/host-base-image/versions-deb-buster new file mode 100644 index 000000000000..0325858b9320 --- /dev/null +++ b/files/build/versions/host-base-image/versions-deb-buster @@ -0,0 +1,84 @@ +adduser==3.118 +apt==1.8.2.2 +base-files==10.3+deb10u8 +base-passwd==3.5.46 +bash==5.0-4 +bsdutils==1:2.33.1-0.1 +coreutils==8.30-3 +dash==0.5.10.2-5 +debconf==1.5.71 +debian-archive-keyring==2019.1 +debianutils==4.8.6.1 +diffutils==1:3.7-3 +dpkg==1.19.7 +e2fsprogs==1.44.5-1+deb10u3 +fdisk==2.33.1-0.1 +findutils==4.6.0+git+20190209-2 +gcc-8-base==8.3.0-6 +gpgv==2.2.12-1+deb10u1 +grep==3.3-1 +gzip==1.9-3 +hostname==3.21 +init-system-helpers==1.56+nmu1 +libacl1==2.2.53-4 +libapt-pkg5.0==1.8.2.2 +libattr1==1:2.4.48-4 +libaudit-common==1:2.8.4-3 +libaudit1==1:2.8.4-3 +libblkid1==2.33.1-0.1 +libbz2-1.0==1.0.6-9.2~deb10u1 +libc-bin==2.28-10 +libc6==2.28-10 +libcap-ng0==0.7.9-2 +libcom-err2==1.44.5-1+deb10u3 +libdb5.3==5.3.28+dfsg1-0.5 +libdebconfclient0==0.249 +libext2fs2==1.44.5-1+deb10u3 +libfdisk1==2.33.1-0.1 +libffi6==3.2.1-9 +libgcc1==1:8.3.0-6 +libgcrypt20==1.8.4-5 +libgmp10==2:6.1.2+dfsg-4 +libgnutls30==3.6.7-4+deb10u6 +libgpg-error0==1.35-1 +libhogweed4==3.4.1-1 +libidn2-0==2.0.5-1+deb10u1 +liblz4-1==1.8.3-1 +liblzma5==5.2.4-1 +libmount1==2.33.1-0.1 +libncursesw6==6.1+20181013-2+deb10u2 +libnettle6==3.4.1-1 +libp11-kit0==0.23.15-2+deb10u1 +libpam-modules==1.3.1-5 +libpam-modules-bin==1.3.1-5 +libpam-runtime==1.3.1-5 +libpam0g==1.3.1-5 +libpcre3==2:8.39-12 +libseccomp2==2.3.3-4 +libselinux1==2.8-1+b1 +libsemanage-common==2.8-2 +libsemanage1==2.8-2 +libsepol1==2.8-1 +libsmartcols1==2.33.1-0.1 +libss2==1.44.5-1+deb10u3 +libstdc++6==8.3.0-6 +libsystemd0==241-7~deb10u6 +libtasn1-6==4.13-3 +libtinfo6==6.1+20181013-2+deb10u2 +libudev1==241-7~deb10u6 +libunistring2==0.9.10-1 +libuuid1==2.33.1-0.1 +libzstd1==1.3.8+dfsg-3 +login==1:4.5-1.1 +mawk==1.3.3-17+b3 +mount==2.33.1-0.1 +ncurses-base==6.1+20181013-2+deb10u2 +ncurses-bin==6.1+20181013-2+deb10u2 +passwd==1:4.5-1.1 +perl-base==5.28.1-6+deb10u1 +sed==4.7-1 +sysvinit-utils==2.93-8 +tar==1.30+dfsg-6 +tzdata==2021a-0+deb10u1 +util-linux==2.33.1-0.1 +zlib1g==1:1.2.11.dfsg-1 \ No newline at end of file diff --git a/files/build/versions/host-image/versions-deb-buster b/files/build/versions/host-image/versions-deb-buster new file mode 100644 index 000000000000..e99804d35b45 --- /dev/null +++ b/files/build/versions/host-image/versions-deb-buster @@ -0,0 +1,283 @@ +acl==2.2.53-4 +apparmor==2.13.2-10 +apt-transport-https==1.8.2.2 +bash-completion==1:2.8-6 +bfn-modules==1.0 +bridge-utils==1.6-2 +bsdmainutils==11.1.2+b1 +busybox==1:1.30.1-4 +ca-certificates==20200601~deb10u2 +cgroup-tools==0.41-8.1 +conntrack==1:1.4.5-2 +containerd.io==1.4.3-1 +cpio==2.12+dfsg-9 +cron==3.0pl1-134+deb10u1 +curl==7.64.0-4+deb10u1 +dbus==1.12.20-0+deb10u1 +device-tree-compiler==1.4.7-4 +dirmngr==2.2.12-1+deb10u1 +dmidecode==3.2-1 +dmsetup==2:1.02.155-3 +docker-ce==5:18.09.8~3-0~debian-buster +docker-ce-cli==5:18.09.8~3-0~debian-buster +dpkg-dev==1.19.7 +drivers-sonic-platform-arista==1.0 +ebtables==2.0.10.4+snapshot20181205-3 +efibootmgr==15-1 +ethtool==1:4.19-1 +file==1:5.35-4+deb10u2 +firmware-amd-graphics==20190114-2 +firmware-linux-nonfree==20190114-2 +firmware-misc-nonfree==20190114-2 +flashrom==1.0-1 +freeipmi-common==1.6.3-1.1 +gdisk==1.0.3-1.1 +gettext-base==0.19.8.1-9 +gnupg==2.2.12-1+deb10u1 +gnupg-l10n==2.2.12-1+deb10u1 +gnupg-utils==2.2.12-1+deb10u1 +gpg==2.2.12-1+deb10u1 +gpg-agent==2.2.12-1+deb10u1 +gpg-wks-client==2.2.12-1+deb10u1 +gpg-wks-server==2.2.12-1+deb10u1 +gpgconf==2.2.12-1+deb10u1 +gpgsm==2.2.12-1+deb10u1 +grub-common==2.02+dfsg1-20+deb10u3 +grub2-common==2.02+dfsg1-20+deb10u3 +haveged==1.9.1-7 +hdparm==9.58+ds-1 +hping3==3.a2.ds2-7 +hw-management==1.mlnx.7.0010.1300 +i2c-tools==4.1-1 +ifmetric==0.3-5 +ifupdown2==1.2.8-1 +initramfs-tools==0.133 +initramfs-tools-core==0.133 +innovium-platform-driver==0.11.1 +ipmitool==1.8.18-6 +iproute2==4.20.0-2+deb10u1 +iptables==1.8.2-4 +iptables-persistent==1.0.11+deb10u1 +iputils-ping==3:20180629-2+deb10u1 +isc-dhcp-client==4.4.1-2 +jq==1.5+dfsg-2+b1 +kdump-tools==1:1.6.1-1 +kernel-mft-dkms-modules-4.19.0-12-2-amd64==4.15.3 +kexec-tools==1:2.0.18-1 +klibc-utils==2.0.6-1 +kmod==26-1 +less==487-0.1+b1 +libapparmor1==2.13.2-10 +libapt-inst2.0==1.8.2.2 +libargon2-1==0~20171227-0.2 +libassuan0==2.5.2-1 +libbsd0==0.9.1-2 +libc-l10n==2.28-10 +libcap2==1:2.25-2 +libcap2-bin==1:2.25-2 +libcgroup1==0.41-8.1 +libcryptsetup12==2:2.1.0-5+deb10u2 +libcurl4==7.64.0-4+deb10u1 +libdbd-sqlite3-perl==1.62-3 +libdbi-perl==1.642-1+deb10u2 +libdbus-1-3==1.12.20-0+deb10u1 +libdevmapper1.02.1==2:1.02.155-3 +libdns-export1104==1:9.11.5.P4+dfsg-5.1+deb10u3 +libdw1==0.176-1.1 +libedit2==3.1-20181209-1 +libefiboot1==37-2+deb10u1 +libefivar1==37-2+deb10u1 +libelf1==0.176-1.1 +libestr0==0.1.10-2.1 +libexpat1==2.2.6-2+deb10u1 +libfastjson4==0.99.8-2 +libffi-dev==3.2.1-9 +libfreeipmi17==1.6.3-1.1 +libfreetype6==2.9.1-3+deb10u2 +libftdi1-2==1.4-1+b2 +libfuse2==2.9.9-1+deb10u1 +libgdbm-compat4==1.18.1-4 +libgdbm6==1.18.1-4 +libglib2.0-0==2.58.3-2+deb10u2 +libgpm2==1.20.7-5 +libgssapi-krb5-2==1.17-3+deb10u1 +libhavege1==1.9.1-7 +libhiredis0.14==0.14.0-3~bpo9+1 +libi2c0==4.1-1 +libidn11==1.33-2.2 +libip4tc0==1.8.2-4 +libip6tc0==1.8.2-4 +libiptc0==1.8.2-4 +libisc-export1100==1:9.11.5.P4+dfsg-5.1+deb10u3 +libjq1==1.5+dfsg-2+b1 +libjson-c3==0.12.1+ds-2+deb10u1 +libk5crypto3==1.17-3+deb10u1 +libkeyutils1==1.6-6 +libklibc==2.0.6-1 +libkmod2==26-1 +libkrb5-3==1.17-3+deb10u1 +libkrb5support0==1.17-3+deb10u1 +libksba8==1.3.5-2 +libldap-2.4-2==2.4.47+dfsg-3+deb10u6 +libldap-common==2.4.47+dfsg-3+deb10u6 +liblognorm5==2.0.5-1 +liblzo2-2==2.10-0.1 +libmagic-mgc==1:5.35-4+deb10u2 +libmagic1==1:5.35-4+deb10u2 +libmnl0==1.0.4-2 +libmpdec2==2.4.2-2 +libncurses6==6.1+20181013-2+deb10u2 +libnet1==1.1.6+dfsg-3.1 +libnetfilter-conntrack3==1.0.7-1 +libnfnetlink0==1.0.1-3+b1 +libnftnl11==1.1.2-2 +libnghttp2-14==1.36.0-2+deb10u1 +libnl-3-200==3.5.0-1 +libnl-cli-3-200==3.5.0-1 +libnl-genl-3-200==3.5.0-1 +libnl-nf-3-200==3.5.0-1 +libnl-route-3-200==3.5.0-1 +libnpth0==1.6-1 +libnss-tacplus==1.0.4-1 +libonig5==6.9.1-1 +libopts25==1:5.18.12-4 +libpam-tacplus==1.4.1-1 +libpcap0.8==1.8.1-6 +libpci3==1:3.5.2-1 +libperl5.28==5.28.1-6+deb10u1 +libpng16-16==1.6.36-6 +libpopt0==1.16-12 +libprocps7==2:3.3.15-2 +libpsl5==0.20.2-2 +libpython-stdlib==2.7.16-1 +libpython2-stdlib==2.7.16-1 +libpython2.7==2.7.16-2+deb10u1 +libpython2.7-minimal==2.7.16-2+deb10u1 +libpython2.7-stdlib==2.7.16-2+deb10u1 +libpython3-stdlib==3.7.3-1 +libpython3.7==3.7.3-2+deb10u2 +libpython3.7-minimal==3.7.3-2+deb10u2 +libpython3.7-stdlib==3.7.3-2+deb10u2 +libreadline7==7.0-5 +librtmp1==2.4+20151223.gitfa8646d.1-2 +libsasl2-2==2.1.27+dfsg-1+deb10u1 +libsasl2-modules-db==2.1.27+dfsg-1+deb10u1 +libsqlite3-0==3.27.2-3+deb10u1 +libssh2-1==1.8.0-2.1 +libssl1.1==1.1.1d-0+deb10u5 +libswsscommon==1.0.0 +libsysfs2==2.1.0+repack-5 +libtac2==1.4.1-1 +libtcl8.6==8.6.9+dfsg-2 +libusb-0.1-4==2:0.1.12-32 +libusb-1.0-0==2:1.0.22-2 +libutempter0==1.1.6-3 +libwrap0==7.6.q-28 +libxtables12==1.8.2-4 +libyaml-0-2==0.2.1-1 +libyang==1.0.73 +libyang-cpp==1.0.73 +libzstd1==1.3.8+dfsg-3+deb10u2 +linux-base==4.6 +linux-image-4.19.0-12-2-amd64-unsigned==4.19.152-1 +locales==2.28-10 +logrotate==3.14.0-4 +lsb-base==10.2019051400 +lsb-release==10.2019051400 +makedev==2.3.1-94 +makedumpfile==1:1.6.5-1 +mft==4.15.3-3 +mft-oem==4.15.3-3 +mime-support==3.62 +monit==1:5.20.0-6 +mtd-utils==1:2.0.1-1 +mtr-tiny==0.92-2 +ndisc6==1.0.4-1 +nephos-modules==1.0.1 +net-tools==1.60+git20180626.aebd88e-1 +netbase==5.6 +netfilter-persistent==1.0.11+deb10u1 +ntp==1:4.2.8p12+dfsg-4+deb10u2 +ntpstat==0.0.0.1-2 +opennsl-modules==4.3.0.10-2 +openssh-client==1:7.9p1-10+deb10u2 +openssh-server==1:7.9p1-10+deb10u2 +openssh-sftp-server==1:7.9p1-10+deb10u2 +openssl==1.1.1d-0+deb10u5 +pciutils==1:3.5.2-1 +perl==5.28.1-6+deb10u1 +perl-modules-5.28==5.28.1-6+deb10u1 +phy-credo==1.0 +picocom==3.1-2 +pinentry-curses==1.1.0-2 +procps==2:3.3.15-2 +psmisc==23.2-1 +python==2.7.16-1 +python-apt==1.8.4.3 +python-apt-common==1.8.4.3 +python-argcomplete==1.8.1-1 +python-bottle==0.12.15-2+deb10u1 +python-enum34==1.1.6-2 +python-funcsigs==1.0.2-4 +python-functools32==3.2.3.2-3 +python-ipaddr==2.2.0-2 +python-jsonschema==2.6.0-4 +python-minimal==2.7.16-1 +python-mock==2.0.0-4 +python-pbr==4.2.0-5 +python-pkg-resources==40.8.0-1 +python-scapy==2.4.0-2 +python-setuptools==40.8.0-1 +python-six==1.12.0-1 +python-smbus==4.1-1 +python-sonic-platform-arista==1.0 +python-swsscommon==1.0.0 +python-yaml==3.13-2 +python2==2.7.16-1 +python2-minimal==2.7.16-1 +python2-yang==1.0.73 +python2.7==2.7.16-2+deb10u1 +python2.7-minimal==2.7.16-2+deb10u1 +python3==3.7.3-1 +python3-bottle==0.12.15-2+deb10u1 +python3-distutils==3.7.3-1 +python3-lib2to3==3.7.3-1 +python3-minimal==3.7.3-1 +python3-smbus==4.1-1 +python3-sonic-platform-arista==1.0 +python3-swsscommon==1.0.0 +python3-yaml==3.13-2 +python3-yang==1.0.73 +python3.7==3.7.3-2+deb10u2 +python3.7-minimal==3.7.3-2+deb10u2 +rasdaemon==0.6.0-1.2 +readline-common==7.0-5 +rsyslog==8.1901.0-1 +screen==4.6.2-3+deb10u1 +sensible-utils==0.0.12 +software-properties-common==0.96.20.2-2 +sonic-device-data==1.0-1 +sonic-host-services-data==1.0-1 +sonic-platform-arista==1.0 +sonic-utilities-data==1.0-1 +sqlite3==3.27.2-3+deb10u1 +squashfs-tools==1:4.3-12 +sudo==1.8.27-1+deb10u3 +sx-kernel==1.mlnx.4.4.2308 +sysfsutils==2.1.0+repack-5 +systemd==241-7~deb10u6 +systemd-sonic-generator==1.0.0 +systemd-sysv==241-7~deb10u6 +tcpdump==4.9.3-1~deb10u2 +tcptraceroute==1.5beta7+debian-4+b2 +traceroute==1:2.1.0-2 +u-boot-tools==2019.01+dfsg-7 +ucf==3.0038+nmu1 +udev==241-7~deb10u6 +unzip==6.0-23+deb10u2 +usb.ids==2019.07.27-0+deb10u1 +usbutils==1:010-3 +vim==2:8.1.0875-5 +vim-common==2:8.1.0875-5 +vim-runtime==2:8.1.0875-5 +xxd==2:8.1.0875-5 \ No newline at end of file diff --git a/files/build/versions/host-image/versions-py2 b/files/build/versions/host-image/versions-py2 new file mode 100644 index 000000000000..ad64a2a881b0 --- /dev/null +++ b/files/build/versions/host-image/versions-py2 @@ -0,0 +1,33 @@ +argcomplete==1.8.1 +bitarray==1.5.3 +bottle==0.12.15 +contextlib2==0.6.0.post1 +enum34==1.1.6 +funcsigs==1.0.2 +functools32==3.2.3.post2 +future==0.18.2 +importlib-resources==3.3.1 +ipaddr==2.2.0 +ipaddress==1.0.23 +Jinja2==2.11.3 +jsonschema==2.6.0 +lxml==4.6.2 +MarkupSafe==1.1.1 +mock==2.0.0 +natsort==6.2.1 +netaddr==0.8.0 +pathlib2==2.3.5 +pbr==4.2.0 +platform-arista==1.0 +pyang==2.4.0 +pyangbind==0.6.0 +python-apt==1.8.4.3 +PyYAML==5.4.1 +redis==3.5.3 +scandir==1.10.0 +scapy==2.4.0 +singledispatch==3.6.0 +six==1.12.0 +thrift==0.13.0 +typing==3.7.4.3 +zipp==1.2.0 \ No newline at end of file diff --git a/files/build/versions/host-image/versions-py3 b/files/build/versions/host-image/versions-py3 new file mode 100644 index 000000000000..502409926941 --- /dev/null +++ b/files/build/versions/host-image/versions-py3 @@ -0,0 +1,42 @@ +azure-common==1.1.26 +azure-nspkg==3.0.2 +azure-storage==0.36.0 +bitarray==1.5.3 +bottle==0.12.15 +certifi==2020.12.5 +cffi==1.14.5 +chardet==3.0.4 +Click==7.0 +cryptography==3.4.6 +docker==4.3.1 +idna==2.10 +ijson==2.6.1 +ipaddress==1.0.23 +Jinja2==2.11.3 +jsondiff==1.2.0 +lxml==4.6.2 +M2Crypto==0.31.0 +MarkupSafe==1.1.1 +natsort==6.2.1 +netaddr==0.8.0 +netifaces==0.10.7 +pathtools==0.1.2 +pexpect==4.8.0 +platform-arista==1.0 +psutil==5.8.0 +ptyprocess==0.7.0 +pyang==2.4.0 +pyangbind==0.8.1 +pycparser==2.20 +python-dateutil==2.8.1 +PyYAML==5.4.1 +redis==3.5.3 +regex==2020.11.13 +requests==2.25.0 +six==1.15.0 +tabulate==0.8.2 +thrift==0.13.0 +urllib3==1.26.3 +watchdog==0.10.3 +websocket-client==0.57.0 +xmltodict==0.12.0 \ No newline at end of file From c2409296076ecd79457004b0956f5ccbdf78e641 Mon Sep 17 00:00:00 2001 From: pra-moh <49077256+pra-moh@users.noreply.github.com> Date: Wed, 17 Feb 2021 17:23:00 -0800 Subject: [PATCH 0195/1674] [StreamingTelemetry] add noTLS support for debug purpose (#6704) adding noTLS mode for debugging purpose Removing config-set for port 8080. It fails to start telemetry if docker restarts in case on noTLS mode because it expects log_level config to be present as well. --- dockers/docker-sonic-telemetry/telemetry.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dockers/docker-sonic-telemetry/telemetry.sh b/dockers/docker-sonic-telemetry/telemetry.sh index 0fd80fcbfcc8..1f92657e3b8f 100755 --- a/dockers/docker-sonic-telemetry/telemetry.sh +++ b/dockers/docker-sonic-telemetry/telemetry.sh @@ -46,13 +46,12 @@ elif [ -n "$X509" ]; then TELEMETRY_ARGS+=" --ca_crt $CA_CRT" fi else - TELEMETRY_ARGS+=" --insecure" + TELEMETRY_ARGS+=" --noTLS" fi # If no configuration entry exists for TELEMETRY, create one default port if [ -z "$GNMI" ]; then PORT=8080 - sonic-db-cli CONFIG_DB hset "TELEMETRY|gnmi" port $PORT else PORT=$(echo $GNMI | jq -r '.port') fi From d7517a704c1e44dbf7e6a9ea9afd07109fd23721 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 7 Jan 2021 10:03:29 -0800 Subject: [PATCH 0196/1674] [PDDF] Build and install Python 3 package (#6286) - Make PDDF code compliant with both Python 2 and Python 3 - Align code with PEP8 standards using autopep8 - Build and install both Python 2 and Python 3 PDDF packages --- build_debian.sh | 1 - dockers/docker-platform-monitor/Dockerfile.j2 | 4 +- .../build_templates/sonic_debian_extension.j2 | 18 +- platform/pddf/platform-api-pddf-base.dep | 4 + platform/pddf/platform-api-pddf-base.mk | 13 + platform/pddf/platform-api-pddf-base/setup.py | 4 + .../sonic_platform_pddf_base/pddf_chassis.py | 34 +- .../sonic_platform_pddf_base/pddf_eeprom.py | 18 +- .../sonic_platform_pddf_base/pddf_fan.py | 47 +- .../sonic_platform_pddf_base/pddf_platform.py | 5 +- .../sonic_platform_pddf_base/pddf_psu.py | 41 +- .../sonic_platform_pddf_base/pddf_sfp.py | 149 +- .../sonic_platform_pddf_base/pddf_thermal.py | 59 +- .../sonic_platform_pddf_base/pddfparse.py | 1307 ++++++++--------- slave.mk | 1 + 15 files changed, 837 insertions(+), 868 deletions(-) diff --git a/build_debian.sh b/build_debian.sh index cbb4a559e78b..f94f1665f570 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -275,7 +275,6 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in ntpstat \ openssh-server \ python \ - python-jsonschema \ python-apt \ traceroute \ iputils-ping \ diff --git a/dockers/docker-platform-monitor/Dockerfile.j2 b/dockers/docker-platform-monitor/Dockerfile.j2 index 9662f7248001..fc46dc6a52b9 100755 --- a/dockers/docker-platform-monitor/Dockerfile.j2 +++ b/dockers/docker-platform-monitor/Dockerfile.j2 @@ -24,13 +24,13 @@ RUN apt-get update && \ python3-smbus \ ethtool \ dmidecode \ - i2c-tools \ - python-jsonschema + i2c-tools # 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 diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index b1955919149e..fd5a9735bfaf 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -193,19 +193,25 @@ sudo cp {{platform_common_py2_wheel_path}} $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY2 sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip2 install $PLATFORM_COMMON_PY2_WHEEL_NAME sudo rm -rf $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY2_WHEEL_NAME +# Install sonic-platform-common Python 3 package +PLATFORM_COMMON_PY3_WHEEL_NAME=$(basename {{platform_common_py3_wheel_path}}) +sudo cp {{platform_common_py3_wheel_path}} $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY3_WHEEL_NAME +sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install $PLATFORM_COMMON_PY3_WHEEL_NAME +sudo rm -rf $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY3_WHEEL_NAME + {% if pddf_support == "y" %} # Install pddf-platform-api-base Python 2 package PLATFORM_PDDF_COMMON_PY2_WHEEL_NAME=$(basename {{pddf_platform_api_base_py2_wheel_path}}) sudo cp {{pddf_platform_api_base_py2_wheel_path}} $FILESYSTEM_ROOT/$PLATFORM_PDDF_COMMON_PY2_WHEEL_NAME sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip2 install $PLATFORM_PDDF_COMMON_PY2_WHEEL_NAME sudo rm -rf $FILESYSTEM_ROOT/$PLATFORM_PDDF_COMMON_PY2_WHEEL_NAME -{% endif %} -# Install sonic-platform-common Python 3 package -PLATFORM_COMMON_PY3_WHEEL_NAME=$(basename {{platform_common_py3_wheel_path}}) -sudo cp {{platform_common_py3_wheel_path}} $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY3_WHEEL_NAME -sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install $PLATFORM_COMMON_PY3_WHEEL_NAME -sudo rm -rf $FILESYSTEM_ROOT/$PLATFORM_COMMON_PY3_WHEEL_NAME +# Install pddf-platform-api-base Python 3 package +PLATFORM_PDDF_COMMON_PY3_WHEEL_NAME=$(basename {{pddf_platform_api_base_py3_wheel_path}}) +sudo cp {{pddf_platform_api_base_py3_wheel_path}} $FILESYSTEM_ROOT/$PLATFORM_PDDF_COMMON_PY3_WHEEL_NAME +sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install $PLATFORM_PDDF_COMMON_PY3_WHEEL_NAME +sudo rm -rf $FILESYSTEM_ROOT/$PLATFORM_PDDF_COMMON_PY3_WHEEL_NAME +{% endif %} {# Barefoot platform vendors' sonic_platform packages import the Python 'thrift' library #} {% if sonic_asic_platform == "barefoot" %} diff --git a/platform/pddf/platform-api-pddf-base.dep b/platform/pddf/platform-api-pddf-base.dep index 9184925b1e6f..aaaedb068384 100644 --- a/platform/pddf/platform-api-pddf-base.dep +++ b/platform/pddf/platform-api-pddf-base.dep @@ -7,3 +7,7 @@ DEP_FILES += $(shell git ls-files $(MPATH)) $(PDDF_PLATFORM_API_BASE_PY2)_CACHE_MODE := GIT_CONTENT_SHA $(PDDF_PLATFORM_API_BASE_PY2)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) $(PDDF_PLATFORM_API_BASE_PY2)_DEP_FILES := $(DEP_FILES) + +$(PDDF_PLATFORM_API_BASE_PY3)_CACHE_MODE := GIT_CONTENT_SHA +$(PDDF_PLATFORM_API_BASE_PY3)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(PDDF_PLATFORM_API_BASE_PY3)_DEP_FILES := $(DEP_FILES) diff --git a/platform/pddf/platform-api-pddf-base.mk b/platform/pddf/platform-api-pddf-base.mk index 80478d4f3db1..ce818707ba7e 100644 --- a/platform/pddf/platform-api-pddf-base.mk +++ b/platform/pddf/platform-api-pddf-base.mk @@ -13,3 +13,16 @@ SONIC_PYTHON_WHEELS += $(PDDF_PLATFORM_API_BASE_PY2) export pddf_platform_api_base_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(PDDF_PLATFORM_API_BASE_PY2))" export PDDF_PLATFORM_API_BASE_PY2 + +PDDF_PLATFORM_API_BASE_PY3 = sonic_platform_pddf_common-$(PDDF_PLATFORM_API_BASE_VERSION)-py3-none-any.whl +$(PDDF_PLATFORM_API_BASE_PY3)_SRC_PATH = $(PLATFORM_PDDF_PATH)/platform-api-pddf-base +$(PDDF_PLATFORM_API_BASE_PY3)_PYTHON_VERSION = 3 +$(PDDF_PLATFORM_API_BASE_PY3)_DEPENDS = $(SONIC_CONFIG_ENGINE) +# Synthetic dependency to avoid building the Python 2 and 3 packages +# simultaneously and any potential conflicts which may arise +$(PDDF_PLATFORM_API_BASE_PY3)_DEPENDS += $(PDDF_PLATFORM_API_BASE_PY2) +$(PDDF_PLATFORM_API_BASE_PY3)_TEST = n +SONIC_PYTHON_WHEELS += $(PDDF_PLATFORM_API_BASE_PY3) + +export pddf_platform_api_base_py3_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(PDDF_PLATFORM_API_BASE_PY3))" +export PDDF_PLATFORM_API_BASE_PY3 diff --git a/platform/pddf/platform-api-pddf-base/setup.py b/platform/pddf/platform-api-pddf-base/setup.py index 5f5ac9194cd9..0d8b4a6b2df2 100755 --- a/platform/pddf/platform-api-pddf-base/setup.py +++ b/platform/pddf/platform-api-pddf-base/setup.py @@ -14,6 +14,9 @@ packages=[ 'sonic_platform_pddf_base', ], + install_requires=[ + 'jsonschema==2.6.0' + ], classifiers=[ 'Development Status :: 3 - Alpha', 'Environment :: Plugins', @@ -24,6 +27,7 @@ 'Natural Language :: English', 'Operating System :: POSIX :: Linux', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.7', 'Topic :: Utilities', ], keywords='sonic SONiC platform PLATFORM', 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 index 942be25ed1c7..0e77a90dbab1 100755 --- 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 @@ -18,6 +18,7 @@ except ImportError as e: raise ImportError(str(e) + "- required module not found") + class PddfChassis(ChassisBase): """ PDDF Generic Chassis class @@ -33,7 +34,7 @@ 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: - import pddfparse + from . import pddfparse import json self.pddf_obj = pddfparse.PddfParse() with open('/usr/share/sonic/platform/pddf/pd-plugin.json') as pd: @@ -67,8 +68,8 @@ 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 - """ + # SYSTEM LED Test Cases + """ #comment out test cases sys_led_list= { "LOC":0, "DIAG":0, @@ -90,8 +91,6 @@ def __init__(self, pddf_data=None, pddf_plugin_data=None): print "Set off: " + color """ - - def get_name(self): """ Retrieves the name of the chassis @@ -438,34 +437,32 @@ def get_sfp(self, index): # System LED methods ############################################## def set_system_led(self, led_device_name, color): - result, msg = self.pddf_obj.is_supported_sysled_state(led_device_name, color); + result, msg = self.pddf_obj.is_supported_sysled_state(led_device_name, color) if result == False: - print msg - return (False) + print(msg) + return (False) - index=self.pddf_obj.data[led_device_name]['dev_attr']['index'] - device_name=self.pddf_obj.data[led_device_name]['dev_info']['device_name'] + index = self.pddf_obj.data[led_device_name]['dev_attr']['index'] + device_name = self.pddf_obj.data[led_device_name]['dev_info']['device_name'] self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path()) self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path()) self.pddf_obj.create_attr('color', color, self.pddf_obj.get_led_cur_state_path()) self.pddf_obj.create_attr('dev_ops', 'set_status', self.pddf_obj.get_led_path()) return (True) - def get_system_led(self, led_device_name): - if (not led_device_name in self.pddf_obj.data.keys()): - status= "[FAILED] " + led_device_name + " is not configured" - return (status) + if led_device_name not in self.pddf_obj.data.keys(): + status = "[FAILED] " + led_device_name + " is not configured" + return (status) - index=self.pddf_obj.data[led_device_name]['dev_attr']['index'] - device_name=self.pddf_obj.data[led_device_name]['dev_info']['device_name'] + index = self.pddf_obj.data[led_device_name]['dev_attr']['index'] + device_name = self.pddf_obj.data[led_device_name]['dev_info']['device_name'] self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path()) self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path()) self.pddf_obj.create_attr('dev_ops', 'get_status', self.pddf_obj.get_led_path()) - color=self.pddf_obj.get_led_color() + color = self.pddf_obj.get_led_color() return (color) - ############################################## # Other methods ############################################## @@ -513,4 +510,3 @@ def get_change_event(self, timeout=0): 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_eeprom.py b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_eeprom.py index 222cdcf4edd3..592485d617e4 100644 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_eeprom.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddf_eeprom.py @@ -67,47 +67,41 @@ def __init__(self, pddf_data=None, pddf_plugin_data=None): tlv_index += ord(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) + (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] def base_mac_addr(self): - (is_valid, t) = self.get_tlv_field( - self.eeprom_data, self._TLV_CODE_MAC_BASE) + (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) + (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] def part_number_str(self): - (is_valid, results) = self.get_tlv_field( - self.eeprom_data, self._TLV_CODE_PART_NUMBER) + (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] def serial_str(self): - (is_valid, results) = self.get_tlv_field( - self.eeprom_data, self._TLV_CODE_SERVICE_TAG) + (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] def revision_str(self): - (is_valid, results) = self.get_tlv_field( - self.eeprom_data, self._TLV_CODE_DEVICE_VERSION) + (is_valid, results) = self.get_tlv_field(self.eeprom_data, self._TLV_CODE_DEVICE_VERSION) if not is_valid: return "N/A" 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 index f189ca2a4e2e..5930345070b4 100755 --- 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 @@ -22,7 +22,7 @@ class PddfFan(FanBase): plugin_data = {} def __init__(self, tray_idx, fan_idx=0, pddf_data=None, pddf_plugin_data=None, is_psu_fan=False, psu_index=0): - # idx is 0-based + # idx is 0-based if not pddf_data or not pddf_plugin_data: raise ValueError('PDDF JSON data error') @@ -30,12 +30,12 @@ def __init__(self, tray_idx, fan_idx=0, pddf_data=None, pddf_plugin_data=None, i self.plugin_data = pddf_plugin_data self.platform = self.pddf_obj.get_platform() - if tray_idx<0 or tray_idx>=self.platform['num_fantrays']: - print "Invalid fantray index %d\n"%tray_idx + if tray_idx < 0 or tray_idx >= self.platform['num_fantrays']: + print("Invalid fantray index %d\n" % tray_idx) return - - if fan_idx<0 or fan_idx>=self.platform['num_fans_pertray']: - print "Invalid fan index (within a tray) %d\n"%fan_idx + + if fan_idx < 0 or fan_idx >= self.platform['num_fans_pertray']: + print("Invalid fan index (within a tray) %d\n" % fan_idx) return self.fantray_index = tray_idx+1 @@ -160,7 +160,7 @@ def get_speed(self): if not output: return 0 - + output['status'] = output['status'].rstrip() if output['status'].isalpha(): return 0 @@ -185,7 +185,7 @@ def get_speed_rpm(self): output = self.pddf_obj.get_attr_name_output(device, attr) if not output: return 0 - + output['status'] = output['status'].rstrip() if output['status'].isalpha(): return 0 @@ -229,7 +229,7 @@ def get_target_speed(self): if not output: return 0 - + output['status'] = output['status'].rstrip() if output['status'].isalpha(): return 0 @@ -250,7 +250,7 @@ def get_speed_tolerance(self): An integer, the percentage of variance from target speed which is considered tolerable """ - # Fix the speed vairance to 10 percent. If it changes based on platforms, overwrite + # Fix the speed vairance to 10 percent. If it changes based on platforms, overwrite # this value in derived pddf fan class return 10 @@ -266,28 +266,27 @@ def set_speed(self, speed): A boolean, True if speed is set successfully, False if not """ if self.is_psu_fan: - print "Setting PSU fan speed is not allowed" + print("Setting PSU fan speed is not allowed") return False else: - if speed<0 or speed>100: - print "Error: Invalid speed %d. Please provide a valid speed percentage"%speed + if speed < 0 or speed > 100: + print("Error: Invalid speed %d. Please provide a valid speed percentage" % speed) return False if 'duty_cycle_to_pwm' not in self.plugin_data['FAN']: - print "Setting fan speed is not allowed !" + print("Setting fan speed is not allowed !") return False else: duty_cycle_to_pwm = eval(self.plugin_data['FAN']['duty_cycle_to_pwm']) pwm = int(round(duty_cycle_to_pwm(speed))) - status = False idx = (self.fantray_index-1)*self.platform['num_fans_pertray'] + self.fan_index attr = "fan" + str(idx) + "_pwm" output = self.pddf_obj.set_attr_name_output("FAN-CTRL", attr, pwm) if not output: return False - + status = output['status'] return status @@ -296,36 +295,34 @@ def set_status_led(self, color): index = str(self.fantray_index-1) led_device_name = "FANTRAY{}".format(self.fantray_index) + "_LED" - result, msg = self.pddf_obj.is_supported_sysled_state(led_device_name, color); + result, msg = self.pddf_obj.is_supported_sysled_state(led_device_name, color) if result == False: - print msg - return (False) + print(msg) + return (False) - - device_name=self.pddf_obj.data[led_device_name]['dev_info']['device_name'] + device_name = self.pddf_obj.data[led_device_name]['dev_info']['device_name'] self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path()) self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path()) self.pddf_obj.create_attr('color', color, self.pddf_obj.get_led_cur_state_path()) self.pddf_obj.create_attr('dev_ops', 'set_status', self.pddf_obj.get_led_path()) return (True) - def get_status_led(self): index = str(self.fantray_index-1) fan_led_device = "FANTRAY{}".format(self.fantray_index) + "_LED" - if (not fan_led_device in self.pddf_obj.data.keys()): + if fan_led_device not in self.pddf_obj.data.keys(): # Implement a generic status_led color scheme if self.get_status(): return self.STATUS_LED_COLOR_GREEN else: return self.STATUS_LED_COLOR_OFF - device_name=self.pddf_obj.data[fan_led_device]['dev_info']['device_name'] + device_name = self.pddf_obj.data[fan_led_device]['dev_info']['device_name'] self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path()) self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path()) self.pddf_obj.create_attr('dev_ops', 'get_status', self.pddf_obj.get_led_path()) - color=self.pddf_obj.get_led_color() + color = self.pddf_obj.get_led_color() return (color) def dump_sysfs(self): 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 index 20b87db99910..00eefc9a815e 100755 --- 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 @@ -10,7 +10,7 @@ try: import json - import pddfparse + from . import pddfparse from sonic_platform_base.platform_base import PlatformBase from sonic_platform.chassis import Chassis except ImportError as e: @@ -23,6 +23,7 @@ class PddfPlatform(PlatformBase): """ pddf_data = {} pddf_plugin_data = {} + def __init__(self): # Initialize the JSON data self.pddf_data = pddfparse.PddfParse() @@ -30,7 +31,7 @@ def __init__(self): self.pddf_plugin_data = json.load(pd) if not self.pddf_data or not self.pddf_plugin_data: - print "Error: PDDF JSON data is not loaded properly ... Exiting" + print("Error: PDDF JSON data is not loaded properly ... Exiting") raise ValueError PlatformBase.__init__(self) 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 index b378be7dad39..58b69ce0aa73 100755 --- 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 @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# All the supported PSU SysFS aattributes are +# All the supported PSU SysFS aattributes are #- psu_present #- psu_model_name #- psu_power_good @@ -18,7 +18,7 @@ from sonic_platform_base.psu_base import PsuBase from sonic_platform.fan import Fan except ImportError as e: - raise ImportError (str(e) + "- required module not found") + raise ImportError(str(e) + "- required module not found") class PddfPsu(PsuBase): @@ -27,7 +27,6 @@ class PddfPsu(PsuBase): pddf_obj = {} plugin_data = {} - def __init__(self, index, pddf_data=None, pddf_plugin_data=None): PsuBase.__init__(self) if not pddf_data or not pddf_plugin_data: @@ -37,7 +36,7 @@ def __init__(self, index, pddf_data=None, pddf_plugin_data=None): self.plugin_data = pddf_plugin_data self.platform = self.pddf_obj.get_platform() self.psu_index = index + 1 - + self._fan_list = [] # _fan_list under PsuBase class is a global variable, hence we need to use _fan_list per class instatiation self.num_psu_fans = int(self.pddf_obj.get_num_psu_fans('PSU{}'.format(index+1))) for psu_fan_idx in range(self.num_psu_fans): @@ -75,11 +74,11 @@ def get_presence(self): status = 0 device = "PSU{}".format(self.psu_index) output = self.pddf_obj.get_attr_name_output(device, "psu_present") - if not output: - return False + if not output: + return False mode = output['mode'] - status = output['status'] + status = output['status'] vmap = self.plugin_data['PSU']['psu_present'][mode]['valmap'] @@ -98,7 +97,7 @@ def get_model(self): device = "PSU{}".format(self.psu_index) output = self.pddf_obj.get_attr_name_output(device, "psu_model_name") if not output: - return None + return None model = output['status'] @@ -118,7 +117,7 @@ def get_serial(self): device = "PSU{}".format(self.psu_index) output = self.pddf_obj.get_attr_name_output(device, "psu_serial_num") if not output: - return None + return None serial = output['status'] @@ -138,7 +137,7 @@ def get_status(self): return False mode = output['mode'] - status = output ['status'] + status = output['status'] vmap = self.plugin_data['PSU']['psu_power_good'][mode]['valmap'] @@ -157,9 +156,9 @@ def get_mfr_id(self): device = "PSU{}".format(self.psu_index) output = self.pddf_obj.get_attr_name_output(device, "psu_mfr_id") if not output: - return None + return None - mfr = output['status'] + mfr = output['status'] return mfr.rstrip('\n') @@ -171,11 +170,11 @@ def get_voltage(self): A float number, the output voltage in volts, e.g. 12.1 """ - device = "PSU{}".format(self.psu_index) + device = "PSU{}".format(self.psu_index) output = self.pddf_obj.get_attr_name_output(device, "psu_v_out") if not output: return 0.0 - + v_out = output['status'] return float(v_out)/1000 @@ -230,12 +229,12 @@ def set_status_led(self, color): index = str(self.psu_index-1) led_device_name = "PSU{}".format(self.psu_index) + "_LED" - result, msg = self.pddf_obj.is_supported_sysled_state(led_device_name, color); + result, msg = self.pddf_obj.is_supported_sysled_state(led_device_name, color) if result == False: - print msg - return (False) + print(msg) + return (False) - device_name=self.pddf_obj.data[led_device_name]['dev_info']['device_name'] + device_name = self.pddf_obj.data[led_device_name]['dev_info']['device_name'] self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path()) self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path()) self.pddf_obj.create_attr('color', color, self.pddf_obj.get_led_cur_state_path()) @@ -245,18 +244,18 @@ def set_status_led(self, color): def get_status_led(self): index = str(self.psu_index-1) psu_led_device = "PSU{}_LED".format(self.psu_index) - if (not psu_led_device in self.pddf_obj.data.keys()): + if psu_led_device not in self.pddf_obj.data.keys(): # Implement a generic status_led color scheme if self.get_powergood_status(): return self.STATUS_LED_COLOR_GREEN else: return self.STATUS_LED_COLOR_OFF - device_name=self.pddf_obj.data[psu_led_device]['dev_info']['device_name'] + device_name = self.pddf_obj.data[psu_led_device]['dev_info']['device_name'] self.pddf_obj.create_attr('device_name', device_name, self.pddf_obj.get_led_path()) self.pddf_obj.create_attr('index', index, self.pddf_obj.get_led_path()) self.pddf_obj.create_attr('dev_ops', 'get_status', self.pddf_obj.get_led_path()) - color=self.pddf_obj.get_led_color() + color = self.pddf_obj.get_led_color() return (color) def get_input_voltage(self): 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 index d53c23061b2d..dc37bba6e888 100755 --- 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 @@ -10,8 +10,8 @@ from sonic_platform_base.sonic_sfp.sff8472 import sff8472Dom from sonic_platform_base.sonic_sfp.sff8472 import sffbase from sonic_platform_base.sonic_sfp.inf8628 import inf8628InterfaceId -except ImportError, e: - raise ImportError (str(e) + "- required module not found") +except ImportError as e: + raise ImportError(str(e) + "- required module not found") # definitions of the offset and width for values in XCVR info eeprom XCVR_INTFACE_BULK_OFFSET = 0 @@ -58,7 +58,7 @@ OSFP_HW_REV_OFFSET = 164 OSFP_VENDOR_SN_OFFSET = 166 -#definitions of the offset and width for values in DOM info eeprom +# definitions of the offset and width for values in DOM info eeprom QSFP_DOM_REV_OFFSET = 1 QSFP_DOM_REV_WIDTH = 1 QSFP_TEMPE_OFFSET = 22 @@ -107,10 +107,10 @@ 'LengthCable(UnitsOfm)', 'LengthOM3(UnitsOf10m)') sfp_compliance_code_tup = ('10GEthernetComplianceCode', 'InfinibandComplianceCode', - 'ESCONComplianceCodes', 'SONETComplianceCodes', - 'EthernetComplianceCodes','FibreChannelLinkLength', - 'FibreChannelTechnology', 'SFP+CableTechnology', - 'FibreChannelTransmissionMedia','FibreChannelSpeed') + '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', @@ -126,6 +126,7 @@ DOM_OFFSET = 0 DOM_OFFSET1 = 384 + class PddfSfp(SfpBase): """ PDDF generic Sfp class @@ -154,7 +155,7 @@ def __read_eeprom_specific_bytes(self, offset, num_bytes): for n in range(0, num_bytes): eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2) except Exception as e: - print "Error: Unable to open eeprom_path: %s"%(str(e)) + print("Error: Unable to open eeprom_path: %s" % (str(e))) finally: if sysfsfile_eeprom: sysfsfile_eeprom.close() @@ -174,29 +175,29 @@ def __init__(self, index, pddf_data=None, pddf_plugin_data=None): self._port_start = 0 self._port_end = int(self.platform['num_ports']) if index < self._port_start or index >= self._port_end: - print "Invalid port index %d"%index - return + print("Invalid port index %d" % index) + return self.port_index = index+1 self.device = 'PORT{}'.format(self.port_index) self.sfp_type = self.pddf_obj.get_device_type(self.device) - self.is_qsfp_port = True if (self.sfp_type=='QSFP' or self.sfp_type=='QSFP28') else False - self.is_osfp_port = True if (self.sfp_type=='OSFP' or self.sfp_type=='QSFP-DD') else False + self.is_qsfp_port = True if (self.sfp_type == 'QSFP' or self.sfp_type == 'QSFP28') else False + self.is_osfp_port = True if (self.sfp_type == 'OSFP' or self.sfp_type == 'QSFP-DD') else False self.eeprom_path = self.pddf_obj.get_path(self.device, 'eeprom') - 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.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'] + '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'] + 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) @@ -226,9 +227,8 @@ def get_transceiver_info(self): ======================================================================== """ # check present status - if not self.get_presence(): - return None - + if not self.get_presence(): + return None if self.is_osfp_port: sfpi_obj = inf8628InterfaceId() @@ -267,7 +267,6 @@ def get_transceiver_info(self): if sfpi_obj is None: return None - if self.is_osfp_port: sfp_type_raw = self.__read_eeprom_specific_bytes((offset + type_offset), XCVR_TYPE_WIDTH) @@ -275,19 +274,21 @@ def get_transceiver_info(self): sfp_type_data = sfpi_obj.parse_sfp_type(sfp_type_raw, 0) sfp_type_abbrv_name = sfpi_obj.parse_sfp_type_abbrv_name(sfp_typ_raw, 0) else: - sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes((offset + XCVR_INTFACE_BULK_OFFSET), interface_info_bulk_width) + sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_INTFACE_BULK_OFFSET), interface_info_bulk_width) if sfp_interface_bulk_raw is not None: sfp_interface_bulk_data = sfpi_obj.parse_sfp_info_bulk(sfp_interface_bulk_raw, 0) - sfp_vendor_oui_raw = self.__read_eeprom_specific_bytes((offset + XCVR_VENDOR_OUI_OFFSET), XCVR_VENDOR_OUI_WIDTH) + sfp_vendor_oui_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_VENDOR_OUI_OFFSET), XCVR_VENDOR_OUI_WIDTH) if sfp_vendor_oui_raw is not None: sfp_vendor_oui_data = sfpi_obj.parse_vendor_oui(sfp_vendor_oui_raw, 0) - sfp_vendor_date_raw = self.__read_eeprom_specific_bytes((offset + XCVR_VENDOR_DATE_OFFSET), XCVR_VENDOR_DATE_WIDTH) + sfp_vendor_date_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_VENDOR_DATE_OFFSET), XCVR_VENDOR_DATE_WIDTH) if sfp_vendor_date_raw is not None: sfp_vendor_date_data = sfpi_obj.parse_vendor_date(sfp_vendor_date_raw, 0) - sfp_vendor_name_raw = self.__read_eeprom_specific_bytes( (offset + vendor_name_offset), XCVR_VENDOR_NAME_WIDTH) sfp_vendor_name_data = sfpi_obj.parse_vendor_name( @@ -327,7 +328,8 @@ def get_transceiver_info(self): xcvr_info_dict['hardware_rev'] = sfp_vendor_rev_data['data']['Vendor Rev']['value'] if sfp_vendor_rev_data else 'N/A' xcvr_info_dict['serial'] = sfp_vendor_sn_data['data']['Vendor SN']['value'] if sfp_vendor_sn_data else 'N/A' xcvr_info_dict['vendor_oui'] = sfp_vendor_oui_data['data']['Vendor OUI']['value'] if sfp_vendor_oui_data else 'N/A' - xcvr_info_dict['vendor_date'] = sfp_vendor_date_data['data']['VendorDataCode(YYYY-MM-DD Lot)']['value'] if sfp_vendor_date_data else 'N/A' + xcvr_info_dict['vendor_date'] = sfp_vendor_date_data['data'][ + 'VendorDataCode(YYYY-MM-DD Lot)']['value'] if sfp_vendor_date_data else 'N/A' xcvr_info_dict['cable_type'] = "Unknown" xcvr_info_dict['cable_length'] = "Unknown" @@ -342,9 +344,10 @@ def get_transceiver_info(self): compliance_code_dict[key] = sfp_interface_bulk_data['data']['Specification compliance']['value'][key]['value'] xcvr_info_dict['specification_compliance'] = str(compliance_code_dict) - nkey='Nominal Bit Rate(100Mbs)' + nkey = 'Nominal Bit Rate(100Mbs)' if nkey in sfp_interface_bulk_data['data']: - xcvr_info_dict['nominal_bit_rate'] = str(sfp_interface_bulk_data['data']['Nominal Bit Rate(100Mbs)']['value']) + xcvr_info_dict['nominal_bit_rate'] = str( + sfp_interface_bulk_data['data']['Nominal Bit Rate(100Mbs)']['value']) else: xcvr_info_dict['nominal_bit_rate'] = 'N/A' elif sfp_type == 'OSFP': @@ -360,7 +363,8 @@ def get_transceiver_info(self): compliance_code_dict[key] = sfp_interface_bulk_data['data']['Specification compliance']['value'][key]['value'] xcvr_info_dict['specification_compliance'] = str(compliance_code_dict) - xcvr_info_dict['nominal_bit_rate'] = str(sfp_interface_bulk_data['data']['NominalSignallingRate(UnitsOf100Mbd)']['value']) + xcvr_info_dict['nominal_bit_rate'] = str( + sfp_interface_bulk_data['data']['NominalSignallingRate(UnitsOf100Mbd)']['value']) return xcvr_info_dict @@ -419,19 +423,19 @@ def get_transceiver_bulk_status(self): else: return None - dom_temperature_raw = self.__read_eeprom_specific_bytes( (offset + QSFP_TEMPE_OFFSET), QSFP_TEMPE_WIDTH) + 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) else: return None - dom_voltage_raw = self.__read_eeprom_specific_bytes( (offset + QSFP_VOLT_OFFSET), QSFP_VOLT_WIDTH) + 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) else: return None - qsfp_dom_rev_raw = self.__read_eeprom_specific_bytes( (offset + QSFP_DOM_REV_OFFSET), QSFP_DOM_REV_WIDTH) + 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) else: @@ -446,7 +450,8 @@ def get_transceiver_bulk_status(self): qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value'] qsfp_tx_power_support = qspf_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) + 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: @@ -457,13 +462,14 @@ def get_transceiver_bulk_status(self): xcvr_dom_info_dict['tx3power'] = 'N/A' xcvr_dom_info_dict['tx4power'] = 'N/A' else: - dom_channel_monitor_raw = self.__read_eeprom_specific_bytes((offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH) + 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) + dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power( + dom_channel_monitor_raw, 0) else: return None - xcvr_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TX1Power']['value'] xcvr_dom_info_dict['tx2power'] = dom_channel_monitor_data['data']['TX2Power']['value'] xcvr_dom_info_dict['tx3power'] = dom_channel_monitor_data['data']['TX3Power']['value'] @@ -489,19 +495,20 @@ def get_transceiver_bulk_status(self): if sfpd_obj is None: return None - dom_temperature_raw = self.__read_eeprom_specific_bytes( (offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH) + 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) else: return None - dom_voltage_raw = self.__read_eeprom_specific_bytes( (offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH) + 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) else: return None - dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH) + 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) else: @@ -527,7 +534,6 @@ def get_transceiver_bulk_status(self): xcvr_dom_info_dict['reset_status'] = self.get_reset_status() xcvr_dom_info_dict['lp_mode'] = self.get_lpmode() - return xcvr_dom_info_dict def get_transceiver_threshold_info(self): @@ -591,7 +597,8 @@ def get_transceiver_threshold_info(self): xcvr_dom_threshold_info_dict['vcchighwarning'] = module_threshold_data['VccHighWarning']['value'] xcvr_dom_threshold_info_dict['vcclowwarning'] = module_threshold_data['VccLowWarning']['value'] - dom_thres_raw = self.__read_eeprom_specific_bytes(QSFP_CHANNEL_THRESHOLD_OFFSET, QSFP_CHANNEL_THRESHOLD_WIDTH) + dom_thres_raw = self.__read_eeprom_specific_bytes( + QSFP_CHANNEL_THRESHOLD_OFFSET, QSFP_CHANNEL_THRESHOLD_WIDTH) if dom_thres_raw: channel_threshold_values = sfpd_obj.parse_channel_threshold_values( dom_thres_raw, 0) @@ -647,8 +654,6 @@ def get_transceiver_threshold_info(self): xcvr_dom_threshold_info_dict['rxpowerhighwarning'] = dom_module_threshold_data['data']['RXPowerHighWarning']['value'] xcvr_dom_threshold_info_dict['rxpowerlowwarning'] = dom_module_threshold_data['data']['RXPowerLowWarning']['value'] - - return xcvr_dom_threshold_info_dict def get_reset_status(self): @@ -668,7 +673,7 @@ def get_reset_status(self): status = int(output['status'].rstrip()) - if status==1: + if status == 1: reset_status = True else: reset_status = False @@ -715,13 +720,13 @@ def get_rx_los(self): else: status = int(output['status'].rstrip()) - if status==1: + if status == 1: rx_los = True else: rx_los = False return rx_los - + def get_tx_fault(self): """ Retrieves the TX fault status of SFP @@ -761,7 +766,7 @@ def get_tx_fault(self): else: status = int(output['status'].rstrip()) - if status==1: + if status == 1: tx_fault = True else: tx_fault = False @@ -821,7 +826,7 @@ def get_tx_disable(self): else: status = int(output['status'].rstrip()) - if status==1: + if status == 1: tx_disable = True else: tx_disable = False @@ -852,7 +857,7 @@ def get_tx_disable_channel(self): tx_disabled |= 1 << i return tx_disabled else: - # SFP doesnt support this + # SFP doesnt support this return 0 def get_lpmode(self): @@ -884,13 +889,15 @@ def get_lpmode(self): status = ord(eeprom.read(1)) if ((status & 0x3) == 0x3): - lpmode = True # Low Power Mode if "Power override" bit is 1 and "Power set" bit is 1 + # Low Power Mode if "Power override" bit is 1 and "Power set" bit is 1 + lpmode = True else: - lpmode = False # High Power Mode if one of the following conditions is matched: - # 1. "Power override" bit is 0 - # 2. "Power override" bit is 1 and "Power set" bit is 0 + # High Power Mode if one of the following conditions is matched: + # 1. "Power override" bit is 0 + # 2. "Power override" bit is 1 and "Power set" bit is 0 + lpmode = False except IOError as e: - print "Error: unable to open file: %s" % str(e) + print("Error: unable to open file: %s" % str(e)) return False finally: if eeprom is not None: @@ -919,7 +926,6 @@ def get_power_override(self): if not self.get_presence(): return power_override - if self.is_osfp_port: pass elif self.is_qsfp_port: @@ -1032,7 +1038,7 @@ def reset(self): # TODO: Implement a wrapper set function to write the sequence path = self.pddf_obj.get_path(device, 'xcvr_reset') - # TODO: put the optic based reset logic using EEPROM + # TODO: put the optic based reset logic using EEPROM if path is None: pass else: @@ -1040,7 +1046,7 @@ def reset(self): f = open(path, 'r+') except IOError as e: return False - + try: f.seek(0) f.write('1') @@ -1054,7 +1060,7 @@ def reset(self): status = False return status - + def tx_disable(self, tx_disable): """ Disable SFP TX for all channels @@ -1087,13 +1093,13 @@ def tx_disable(self, tx_disable): eeprom_f.seek(QSFP_CONTROL_OFFSET) eeprom_f.write(buf[0]) except IOError as e: - print "Error: unable to open file: %s" % str(e) + print("Error: unable to open file: %s" % str(e)) return False finally: if eeprom_f is not None: eeprom_f.close() time.sleep(0.01) - + status = True else: status_control_raw = self.__read_eeprom_specific_bytes( @@ -1113,7 +1119,7 @@ def tx_disable(self, tx_disable): eeprom_f.seek(SFP_STATUS_CONTROL_OFFSET) eeprom_f.write(buf[0]) except Exception as e: - print("Error: unable to open file: %s" % str(e)) + print(("Error: unable to open file: %s" % str(e))) return False finally: if eeprom_f: @@ -1168,7 +1174,7 @@ def tx_disable_channel(self, channel, disable): eeprom_f.seek(QSFP_CONTROL_OFFSET) eeprom_f.write(buf[0]) except IOError as e: - print "Error: unable to open file: %s" % str(e) + print("Error: unable to open file: %s" % str(e)) return False finally: if eeprom_f is not None: @@ -1208,7 +1214,7 @@ def set_lpmode(self, lpmode): return False # Fill in write buffer - regval = 0x3 if lpmode else 0x1 # 0x3:Low Power Mode, 0x1:High Power Mode + regval = 0x3 if lpmode else 0x1 # 0x3:Low Power Mode, 0x1:High Power Mode buffer = create_string_buffer(1) buffer[0] = chr(regval) @@ -1218,7 +1224,7 @@ def set_lpmode(self, lpmode): eeprom_f.write(buffer[0]) return True except IOError as e: - print "Error: unable to open file: %s" % str(e) + print("Error: unable to open file: %s" % str(e)) return False finally: if eeprom_f is not None: @@ -1286,7 +1292,7 @@ def set_power_override(self, power_override, power_set): eeprom_f.seek(QSFP_POWEROVERRIDE_OFFSET) eeprom_f.write(buffer[0]) except IOError as e: - print "Error: unable to open file: %s" % str(e) + print("Error: unable to open file: %s" % str(e)) return False finally: if eeprom_f is not None: @@ -1298,14 +1304,13 @@ def set_power_override(self, power_override, power_set): return status - def get_name(self): """ Retrieves the name of the device Returns: string: The name of the device """ - # Name of the port/sfp ? + # Name of the port/sfp ? return 'PORT{}'.format(self.port_index) def get_presence(self): 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 index 01cd4080db10..cd09041e152f 100755 --- 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 @@ -1,6 +1,6 @@ #!/usr/bin/env python -# All the supported Temperature Sensor SysFS aattributes are +# All the supported Temperature Sensor SysFS aattributes are #- temp1_high_crit_threshold #- temp1_high_threshold #- temp1_input @@ -13,7 +13,6 @@ raise ImportError(str(e) + "- required module not found") - class PddfThermal(ThermalBase): """PDDF generic Thermal class""" pddf_obj = {} @@ -37,24 +36,23 @@ def get_name(self): if 'display_name' in self.thermal_obj['dev_attr']: return str(self.thermal_obj['dev_attr']['display_name']) # In case of errors - return (self.thermal_obj_name) + return (self.thermal_obj_name) def get_temperature(self): output = self.pddf_obj.get_attr_name_output(self.thermal_obj_name, "temp1_input") if not output: - return None + return None if output['status'].isalpha(): attr_value = None else: attr_value = float(output['status']) - - if output['mode']=='bmc': - return attr_value + + if output['mode'] == 'bmc': + return attr_value else: return (attr_value/float(1000)) - def get_high_threshold(self): output = self.pddf_obj.get_attr_name_output(self.thermal_obj_name, "temp1_high_threshold") if not output: @@ -65,12 +63,11 @@ def get_high_threshold(self): else: attr_value = float(output['status']) - if output['mode']=='bmc': - return attr_value + if output['mode'] == 'bmc': + return attr_value else: return (attr_value/float(1000)) - def get_low_threshold(self): output = self.pddf_obj.get_attr_name_output(self.thermal_obj_name, "temp1_low_threshold") if not output: @@ -80,31 +77,29 @@ def get_low_threshold(self): attr_value = None else: attr_value = float(output['status']) - - if output['mode']=='bmc': - return attr_value + + if output['mode'] == 'bmc': + return attr_value else: return (attr_value/float(1000)) - def set_high_threshold(self, temperature): node = self.pddf_obj.get_path(self.thermal_obj_name, "temp1_high_threshold") if node is None: - print "ERROR %s does not exist"%node + print("ERROR %s does not exist" % node) return None - - cmd = "echo '%d' > %s"%(temperature * 1000, node) - os.system(cmd) - return (True) + cmd = "echo '%d' > %s" % (temperature * 1000, node) + os.system(cmd) + return (True) def set_low_threshold(self, temperature): node = self.pddf_obj.get_path(self.thermal_obj_name, "temp1_low_threshold") if node is None: - print "ERROR %s does not exist"%node + print("ERROR %s does not exist" % node) return None - cmd = "echo '%d' > %s"%(temperature * 1000, node) + cmd = "echo '%d' > %s" % (temperature * 1000, node) os.system(cmd) return (True) @@ -126,12 +121,11 @@ def get_high_critical_threshold(self): else: attr_value = float(output['status']) - if output['mode']=='bmc': + if output['mode'] == 'bmc': return attr_value else: return (attr_value/float(1000)) - def get_low_critical_threshold(self): """ Retrieves the low critical threshold temperature of thermal @@ -149,26 +143,25 @@ def get_low_critical_threshold(self): else: attr_value = float(output['status']) - if output['mode']=='bmc': + if output['mode'] == 'bmc': return attr_value else: return (attr_value/float(1000)) - # Helper Functions + def get_temp_label(self): - if 'bmc' in self.pddf_obj.data[self.thermal_obj_name].keys(): - return None + if 'bmc' in self.pddf_obj.data[self.thermal_obj_name].keys(): + return None else: if self.thermal_obj_name in self.pddf_obj.data.keys(): - dev= self.pddf_obj.data[self.thermal_obj_name] + dev = self.pddf_obj.data[self.thermal_obj_name] topo_info = dev['i2c']['topo_info'] - label="%s-i2c-%d-%x" % (topo_info['dev_type'], int(topo_info['parent_bus'], 0), - int(topo_info['dev_addr'], 0)) - return (label) + label = "%s-i2c-%d-%x" % (topo_info['dev_type'], int(topo_info['parent_bus'], 0), + int(topo_info['dev_addr'], 0)) + return (label) else: return None - def dump_sysfs(self): return self.pddf_obj.cli_dump_dsysfs('temp-sensors') 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/pddfparse.py index aa47beaa0fc7..6ca59206fd56 100755 --- a/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfparse.py +++ b/platform/pddf/platform-api-pddf-base/sonic_platform_pddf_base/pddfparse.py @@ -8,24 +8,24 @@ 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", - "STATUS_LED_COLOR_RED" : "red", - "STATUS_LED_COLOR_AMBER" : "amber", - "STATUS_LED_COLOR_BLUE" : "blue", - "STATUS_LED_COLOR_GREEN_BLINK" : "blinking green", - "STATUS_LED_COLOR_RED_BLINK" : "blinking red", - "STATUS_LED_COLOR_AMBER_BLINK" : "blinking amber", - "STATUS_LED_COLOR_BLUE_BLINK" : "blinking blue", - "STATUS_LED_COLOR_OFF" : "off" + "STATUS_LED_COLOR_GREEN": "green", + "STATUS_LED_COLOR_RED": "red", + "STATUS_LED_COLOR_AMBER": "amber", + "STATUS_LED_COLOR_BLUE": "blue", + "STATUS_LED_COLOR_GREEN_BLINK": "blinking green", + "STATUS_LED_COLOR_RED_BLINK": "blinking red", + "STATUS_LED_COLOR_AMBER_BLINK": "blinking amber", + "STATUS_LED_COLOR_BLUE_BLINK": "blinking blue", + "STATUS_LED_COLOR_OFF": "off" } @@ -37,17 +37,16 @@ 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") - - 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): try: proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY], @@ -65,7 +64,7 @@ def get_platform_and_hwsku(self): 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) @@ -75,16 +74,15 @@ def get_platform_and_hwsku(self): ################################################################################################################# def runcmd(self, cmd): rc = os.system(cmd) - if rc!=0: - print "%s -- command failed"%cmd - return rc + 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): aa = target + attr @@ -95,88 +93,85 @@ def get_path(self, target, attr): string = None 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 }) + 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 else: if target in self.data.keys(): - path = self.dev_parse(self.data[target], { "cmd": "show_attr", "target":target, "attr":attr }) + path = self.dev_parse(self.data[target], {"cmd": "show_attr", "target": target, "attr": attr}) if path != "": string = path - if string is not None: string = string.rstrip() - cache[aa]=string + cache[aa] = string return string - 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]) - def get_led_color_devtype(self, key): - attr_list=self.data[key]['i2c']['attr_list'] + attr_list = self.data[key]['i2c']['attr_list'] for attr in attr_list: if 'attr_devtype' in attr: - return attr['attr_devtype'].strip() + return attr['attr_devtype'].strip() else: - return 'cpld' + return 'cpld' def get_led_color_from_gpio(self, led_device_name): - attr_list=self.data[led_device_name]['i2c']['attr_list'] - attr=attr_list[0] + attr_list = self.data[led_device_name]['i2c']['attr_list'] + attr = attr_list[0] if ':' in attr['bits']: - bits_list=attr['bits'].split(':') + bits_list = attr['bits'].split(':') bits_list.sort(reverse=True) - max_bit=int(bits_list[0]) + max_bit = int(bits_list[0]) else: - max_bit=0 - base_offset=int(attr['swpld_addr_offset'], 16) + max_bit = 0 + base_offset = int(attr['swpld_addr_offset'], 16) value = 0 bit = 0 while bit <= max_bit: - offset=base_offset + bit + offset = base_offset + bit if 'attr_devname' in attr: attr_path = self.get_gpio_attr_path(self.data[attr['attr_devname']], hex(offset)) else: - status= "[FAILED] attr_devname is not configured" - return (status) + status = "[FAILED] attr_devname is not configured" + return (status) if not os.path.exists(attr_path): - status= "[FAILED] {} does not exist".format(attr_path) - return (status) + status = "[FAILED] {} does not exist".format(attr_path) + return (status) cmd = 'cat ' + attr_path gpio_value = subprocess.check_output(cmd, shell=True) value |= int(gpio_value) << bit @@ -184,110 +179,107 @@ def get_led_color_from_gpio(self, led_device_name): for attr in attr_list: if int(attr['value'].strip(), 16) == value: - return(color_map[attr['attr_name']]) - return (color_map['STATUS_LED_COLOR_OFF']) - + return(color_map[attr['attr_name']]) + return (color_map['STATUS_LED_COLOR_OFF']) def get_led_color_from_cpld(self, led_device_name): - index=self.data[led_device_name]['dev_attr']['index'] - device_name=self.data[led_device_name]['dev_info']['device_name'] + index = self.data[led_device_name]['dev_attr']['index'] + device_name = self.data[led_device_name]['dev_info']['device_name'] self.create_attr('device_name', device_name, self.get_led_path()) self.create_attr('index', index, self.get_led_path()) self.create_attr('dev_ops', 'get_status', self.get_led_path()) return self.get_led_color() def set_led_color_from_gpio(self, led_device_name, color): - attr_list=self.data[led_device_name]['i2c']['attr_list'] + attr_list = self.data[led_device_name]['i2c']['attr_list'] for attr in attr_list: if attr['attr_name'].strip() == color.strip(): - base_offset=int(attr['swpld_addr_offset'], 16) - if ':' in attr['bits']: - bits_list=attr['bits'].split(':') - bits_list.sort(reverse=True) - max_bit = int(bits_list[0]) - else: - max_bit=0 - value=int(attr['value'], 16) - 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)) - i += 1 - try: - cmd = "echo {} > {}".format(_value, attr_path) - self.runcmd(cmd) - except Exception as e: - print "Invalid gpio path : " + attr_path - return (False) + base_offset = int(attr['swpld_addr_offset'], 16) + if ':' in attr['bits']: + bits_list = attr['bits'].split(':') + bits_list.sort(reverse=True) + max_bit = int(bits_list[0]) + else: + max_bit = 0 + value = int(attr['value'], 16) + 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)) + i += 1 + try: + cmd = "echo {} > {}".format(_value, attr_path) + self.runcmd(cmd) + except Exception as e: + print("Invalid gpio path : " + attr_path) + return (False) return (True) def set_led_color_from_cpld(self, led_device_name, color): - index=self.data[led_device_name]['dev_attr']['index'] - device_name=self.data[led_device_name]['dev_info']['device_name'] + index = self.data[led_device_name]['dev_attr']['index'] + device_name = self.data[led_device_name]['dev_info']['device_name'] self.create_attr('device_name', device_name, self.get_led_path()) self.create_attr('index', index, self.get_led_path()) self.create_attr('color', color, self.get_led_cur_state_path()) self.create_attr('dev_ops', 'set_status', self.get_led_path()) - return (True) - + return (True) def get_system_led_color(self, led_device_name): - if (not led_device_name in self.data.keys()): - status= "[FAILED] " + led_device_name + " is not configured" + if led_device_name not in self.data.keys(): + status = "[FAILED] " + led_device_name + " is not configured" return (status) type = self.get_led_color_devtype(led_device_name) if type == 'gpio': - color = self.get_led_color_from_gpio(led_device_name) - elif type == 'cpld': - color = self.get_led_color_from_cpld(led_device_name) + color = self.get_led_color_from_gpio(led_device_name) + elif type == 'cpld': + color = self.get_led_color_from_cpld(led_device_name) return color def set_system_led_color(self, led_device_name, color): - result, msg = self.is_supported_sysled_state(led_device_name, color); + result, msg = self.is_supported_sysled_state(led_device_name, color) if result == False: - print msg - return (result) + print(msg) + return (result) type = self.get_led_color_devtype(led_device_name) if type == 'gpio': - return (self.set_led_color_from_gpio(led_device_name, color)) - else: - return (self.set_led_color_from_cpld(led_device_name, color)) + return (self.set_led_color_from_gpio(led_device_name, color)) + else: + return (self.set_led_color_from_cpld(led_device_name, color)) ################################################################################################################### # 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) return (False) - 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) + return "/sys/bus/i2c/devices/"+"i2c-%d" % int(pdev['i2c']['topo_info']['dev_addr'], 0) 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' - # This is alid for 'at24' type of EEPROM devices. 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="" + 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': @@ -297,28 +289,27 @@ def show_attr_eeprom_device(self, dev, ops): 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]: + "/%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 def show_attr_gpio_device(self, dev, ops): ret = "" - KEY="gpio" - if not KEY in self.data_sysfs_obj: - self.data_sysfs_obj[KEY]=[] + 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]=[] + KEY = "mux" + if KEY not in self.data_sysfs_obj: + self.data_sysfs_obj[KEY] = [] return ret @@ -330,24 +321,24 @@ def get_gpio_attr_path(self, dev, offset): return path def show_attr_psu_i2c_device(self, dev, ops): - target=ops['target'] - attr_name=ops['attr'] + target = ops['target'] + attr_name = ops['attr'] ret = "" - KEY="psu" - dsysfs_path="" + 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'] 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 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' else: @@ -357,29 +348,26 @@ def show_attr_psu_i2c_device(self, dev, ops): 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]: + "/%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) ret += dsysfs_path+"\n" 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 = "" - 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]=[] + attr_name = ops['attr'] + attr_list = dev['i2c']['attr_list'] + 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': @@ -387,7 +375,7 @@ def show_attr_fan_device(self, dev, ops): # 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 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' else: @@ -396,11 +384,11 @@ def show_attr_fan_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) ret += dsysfs_path+"\n" return ret @@ -408,19 +396,18 @@ def show_attr_fan_device(self, dev, ops): # This is only valid for LM75 def show_attr_temp_sensor_device(self, dev, ops): 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]=[] + attr_name = ops['attr'] + attr_list = dev['i2c']['attr_list'] + 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)) + 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)) if 'drv_attr_name' in attr.keys(): real_name = attr['drv_attr_name'] else: @@ -428,50 +415,48 @@ 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) str += full_path + "\n" return str 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]=[] + 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 += dsysfs_path+"\n" return ret - def show_attr_xcvr_i2c_device(self, dev, ops): - target=ops['target'] - attr_name=ops['attr'] + 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 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' else: @@ -481,238 +466,228 @@ def show_attr_xcvr_i2c_device(self, dev, ops): 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]: + "/%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) ret += dsysfs_path+"\n" 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: - self.data_sysfs_obj[KEY]=[] + 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) + 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: - if not sysfs in obj[KEY]: + 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 not sysfs_path in obj[obj_key]: - obj[obj_key].append(sysfs_path) - + 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 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 sysfs_path not 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 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 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 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' + 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) - - 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) + 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 + self.show_psu_i2c_device(dev, ops) + return def show_client_device(self): - 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) - + 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' + 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) + 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 + return def show_sysstatus_device(self, dev, ops): - KEY ='sysstatus' - if not KEY in self.sysfs_obj: + 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 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 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' + 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) + 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 + 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) + 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 not KEY in self.sysfs_obj: + 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' + 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 not KEY in self.sysfs_obj: + KEY = 'led' + if KEY not in self.sysfs_obj: self.sysfs_obj[KEY] = [] - path="pddf/devices/led" + 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_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'] + 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 not sysfs_path in 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', + 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'] @@ -723,7 +698,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']: @@ -731,9 +706,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'] @@ -746,7 +721,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'] @@ -757,7 +732,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'] @@ -765,20 +740,19 @@ 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'] @@ -790,7 +764,7 @@ 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" @@ -799,12 +773,12 @@ def validate_fan_device(self, dev, ops): if dev['i2c']['dev_attr']['num_fan'] 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']: @@ -814,272 +788,263 @@ 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 + # 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 DIR] " + dir + ": not configured" - - + print("[SYSFS DIR] " + dir + ": 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"] + 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") ################################################################################################################### # PARSE DEFS ################################################################################################################### + def psu_parse(self, dev, ops): - parse_str="" - ret="" + 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: + ret = getattr(self, ops['cmd']+"_psu_device")(self.data[ifce['dev']], ops) + if ret is not None: if str(ret).isdigit(): - if ret!=0: + if ret != 0: # in case if 'create' functions - print "{}_psu_device failed".format(ops['cmd']) + print("{}_psu_device failed".format(ops['cmd'])) return ret else: pass else: # in case of 'show_attr' functions - parse_str+=ret + parse_str += ret return parse_str def fan_parse(self, dev, ops): - parse_str="" - ret=getattr(self, ops['cmd']+"_fan_device")(dev, ops ) - if not ret is None: + parse_str = "" + ret = getattr(self, ops['cmd']+"_fan_device")(dev, ops) + if ret is not None: if str(ret).isdigit(): - if ret!=0: + if ret != 0: # in case if 'create' functions - print "{}_fan_device failed".format(ops['cmd']) + print("{}_fan_device failed".format(ops['cmd'])) return ret else: pass else: # in case of 'show_attr' functions - parse_str+=ret + parse_str += ret return parse_str 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: + parse_str = "" + ret = getattr(self, ops['cmd']+"_temp_sensor_device")(dev, ops) + if ret is not None: + if str(ret).isdigit(): + if ret != 0: # in case if 'create' functions - print "{}_temp_sensor_device failed".format(ops['cmd']) + print("{}_temp_sensor_device failed".format(ops['cmd'])) return ret else: pass else: # in case of 'show_attr' functions - parse_str+=ret + parse_str += ret return parse_str def cpld_parse(self, dev, ops): parse_str = "" ret = getattr(self, ops['cmd']+"_cpld_device")(dev, ops) - if not ret is None: + if ret is not None: if str(ret).isdigit(): - if ret!=0: + if ret != 0: # in case if 'create' functions - print "{}_cpld_device failed".format(ops['cmd']) + print("{}_cpld_device failed".format(ops['cmd'])) return ret else: pass else: # in case of 'show_attr' functions - parse_str+=ret + parse_str += ret return parse_str - - - - def sysstatus_parse(self, dev,ops): + def sysstatus_parse(self, dev, ops): parse_str = "" ret = getattr(self, ops['cmd']+"_sysstatus_device")(dev, ops) - if not ret is None: + if ret is not None: if str(ret).isdigit(): - if ret!=0: + if ret != 0: # in case if 'create' functions - print "{}_sysstatus_device failed".format(ops['cmd']) + print("{}_sysstatus_device failed".format(ops['cmd'])) return ret else: pass else: # in case of 'show_attr' functions - parse_str+=ret + parse_str += ret - return parse_str + return parse_str def gpio_parse(self, dev, ops): parse_str = "" ret = getattr(self, ops['cmd']+"_gpio_device")(dev, ops) - if not ret is None: + if ret is not None: if str(ret).isdigit(): - if ret!=0: + if ret != 0: # in case if 'create' functions - print "{}_temp_sensor_device failed".format(ops['cmd']) + print("{}_temp_sensor_device failed".format(ops['cmd'])) return ret else: pass @@ -1089,15 +1054,14 @@ def gpio_parse(self, dev, ops): return parse_str - def mux_parse(self, dev, ops): parse_str = "" ret = getattr(self, ops['cmd']+"_mux_device")(dev, ops) - if not ret is None: + if ret is not None: if str(ret).isdigit(): - if ret!=0: + if ret != 0: # in case if 'create' functions - print "{}_mux_device() cmd failed".format(ops['cmd']) + print("{}_mux_device() cmd failed".format(ops['cmd'])) return ret else: pass @@ -1105,10 +1069,10 @@ def mux_parse(self, dev, ops): parse_str += ret for ch in dev['i2c']['channel']: - ret = self.dev_parse(self.data[ch['dev']], ops) - if not ret is None: + ret = self.dev_parse(self.data[ch['dev']], ops) + if ret is not None: if str(ret).isdigit(): - if ret!=0: + if ret != 0: # in case if 'create' functions return ret else: @@ -1120,10 +1084,10 @@ def mux_parse(self, dev, ops): def mux_parse_reverse(self, dev, ops): parse_str = "" for ch in reversed(dev['i2c']['channel']): - ret = self.dev_parse(self.data[ch['dev']], ops) - if not ret is None: + ret = self.dev_parse(self.data[ch['dev']], ops) + if ret is not None: if str(ret).isdigit(): - if ret!=0: + if ret != 0: # in case if 'create' functions return ret else: @@ -1132,11 +1096,11 @@ def mux_parse_reverse(self, dev, ops): parse_str += ret ret = getattr(self, ops['cmd']+"_mux_device")(dev, ops) - if not ret is None: + if ret is not None: if str(ret).isdigit(): - if ret!=0: + if ret != 0: # in case if 'create' functions - print "{}_mux_device() cmd failed".format(ops['cmd']) + print("{}_mux_device() cmd failed".format(ops['cmd'])) return ret else: pass @@ -1145,15 +1109,14 @@ def mux_parse_reverse(self, dev, ops): return parse_str - def eeprom_parse(self, dev, ops): parse_str = "" ret = getattr(self, ops['cmd']+"_eeprom_device")(dev, ops) - if not ret is None: + if ret is not None: if str(ret).isdigit(): - if ret!=0: + if ret != 0: # in case if 'create' functions - print "{}_eeprom_device() cmd failed".format(ops['cmd']) + print("{}_eeprom_device() cmd failed".format(ops['cmd'])) return ret else: pass @@ -1163,20 +1126,20 @@ def eeprom_parse(self, dev, ops): return parse_str def optic_parse(self, dev, ops): - parse_str="" - ret="" + parse_str = "" + ret = "" for ifce in dev['i2c']['interface']: - ret=getattr(self, ops['cmd']+"_xcvr_device")(self.data[ifce['dev']], ops ) - if not ret is None: + 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 != 0: # in case if 'create' functions - print "{}_eeprom_device() cmd failed".format(ops['cmd']) + print("{}_eeprom_device() cmd failed".format(ops['cmd'])) return ret else: pass else: - parse_str+=ret + parse_str += ret return parse_str def cpu_parse(self, bus, ops): @@ -1184,10 +1147,10 @@ def cpu_parse(self, bus, ops): 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: + ret = self.dev_parse(self.data[d['dev']], ops) + if ret is not None: if str(ret).isdigit(): - if ret!=0: + if ret != 0: # in case if 'create' functions return ret else: @@ -1201,10 +1164,10 @@ def cpu_parse_reverse(self, bus, ops): 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 not ret is None: + ret = self.dev_parse(self.data[d['dev']], ops) + if ret is not None: if str(ret).isdigit(): - if ret!=0: + if ret != 0: # in case if 'create' functions return ret else: @@ -1213,68 +1176,67 @@ def cpu_parse_reverse(self, bus, ops): parse_str += ret return parse_str - 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) - - 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) + 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'] == 'GPIO': - return self.gpio_parse(dev, ops) + if attr['device_type'] == 'EEPROM': + return self.eeprom_parse(dev, ops) - if attr['device_type'] == 'PSU': - return self.psu_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'] == 'FAN': - return self.fan_parse(dev, ops) + if attr['device_type'] == 'PSU': + return self.psu_parse(dev, ops) - if attr['device_type'] == 'TEMP_SENSOR': - return self.temp_sensor_parse(dev, ops) + if attr['device_type'] == 'FAN': + return self.fan_parse(dev, ops) - if 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) + if attr['device_type'] == 'TEMP_SENSOR': + return self.temp_sensor_parse(dev, ops) - if attr['device_type'] == 'CPLD': - return self.cpld_parse(dev, ops) + if 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) - if attr['device_type'] == 'SYSSTAT': - return self.sysstatus_parse(dev,ops) + if attr['device_type'] == 'CPLD': + return self.cpld_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, "supported" - return False, "[FAILED]: Invalid color" + if sysled_name not 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, "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' + 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" + 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) @@ -1283,111 +1245,107 @@ def create_led_device(self, key, ops): 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" + 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: + 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: + 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" } ) + 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 + # 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() + 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 + 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 not bmc_cmd in bmc_cache: - self.populate_bmc_cache_db(bmc_attr) + if bmc_cmd not in bmc_cache: + 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()[field_pos] + data = bmc_cache[bmc_cmd][field_name] + value = data.split()[field_pos] 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: @@ -1397,7 +1355,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() @@ -1406,10 +1364,10 @@ def raw_ipmi_get_request(self, bmc_attr): if value != 'N/A': value = str(int(value, 16) & mask) - + return value - if bmc_attr['type'] == 'ascii': + if bmc_attr['type'] == 'ascii': try: value = subprocess.check_output(cmd, shell=True) except Exception as e: @@ -1417,19 +1375,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 str(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' @@ -1439,14 +1397,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 @@ -1459,43 +1417,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)) @@ -1505,4 +1463,3 @@ def set_attr_name_output(self, device_name, attr_name, val): output['status'] = True return output - diff --git a/slave.mk b/slave.mk index 86bf063b31cd..54470e27dc34 100644 --- a/slave.mk +++ b/slave.mk @@ -867,6 +867,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ $(addprefix $(PYTHON_WHEELS_PATH)/,$(REDIS_DUMP_LOAD_PY2)) \ $(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PLATFORM_API_PY2)) \ $(if $(findstring y,$(PDDF_SUPPORT)),$(addprefix $(PYTHON_WHEELS_PATH)/,$(PDDF_PLATFORM_API_BASE_PY2))) \ + $(if $(findstring y,$(PDDF_SUPPORT)),$(addprefix $(PYTHON_WHEELS_PATH)/,$(PDDF_PLATFORM_API_BASE_PY3))) \ $(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_YANG_MODELS_PY3)) \ $(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_CTRMGRD)) \ $(addprefix $(FILES_PATH)/,$($(SONIC_CTRMGRD)_FILES)) \ From d7be5a021acbf1fb822a865ea720a92583c9a2e7 Mon Sep 17 00:00:00 2001 From: arlakshm <55814491+arlakshm@users.noreply.github.com> Date: Fri, 22 Jan 2021 09:42:19 -0800 Subject: [PATCH 0197/1674] [Multi Asic] support of swss.rec and sairedis.rec for multi asic (#6310) Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan arlakshm@microsoft.com - Why I did it This PR has the changes to support having different swss.rec and sairedis.rec for each asic. The logrotate script is updated as well - How I did it Update the orchagent.sh script to use the logfile name options in these PRs(Azure/sonic-swss#1546 and Azure/sonic-sairedis#747) In multi asic platforms the record files will be different for each asic, with the format swss.asic{x}.rec and sairedis.asic{x}.rec Update the logrotate script for multiasic platform . --- dockers/docker-orchagent/orchagent.sh | 5 +++++ .../logrotate/logrotate.d/rsyslog | 21 ++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/dockers/docker-orchagent/orchagent.sh b/dockers/docker-orchagent/orchagent.sh index 45715dc61f9c..aaa047a42036 100755 --- a/dockers/docker-orchagent/orchagent.sh +++ b/dockers/docker-orchagent/orchagent.sh @@ -41,6 +41,11 @@ then ORCHAGENT_ARGS+="-i $asic_id " fi +# for multi asic platforms add the asic name to the record file names +if [[ "$NAMESPACE_ID" ]]; then + ORCHAGENT_ARGS+="-f swss.asic$NAMESPACE_ID.rec -j sairedis.asic$NAMESPACE_ID.rec " +fi + # Add platform specific arguments if necessary if [ "$platform" == "broadcom" ]; then ORCHAGENT_ARGS+="-m $MAC_ADDRESS" diff --git a/files/image_config/logrotate/logrotate.d/rsyslog b/files/image_config/logrotate/logrotate.d/rsyslog index 792e3e9a2d57..cbf6e722eb90 100644 --- a/files/image_config/logrotate/logrotate.d/rsyslog +++ b/files/image_config/logrotate/logrotate.d/rsyslog @@ -30,8 +30,8 @@ /var/log/telemetry.log /var/log/frr/bgpd.log /var/log/frr/zebra.log -/var/log/swss/sairedis.rec -/var/log/swss/swss.rec +/var/log/swss/sairedis*.rec +/var/log/swss/swss*.rec { size 1M rotate 5000 @@ -85,7 +85,22 @@ endscript postrotate if [ $(echo $1 | grep -c "/var/log/swss/") -gt 0 ]; then - pgrep -x orchagent | xargs /bin/kill -HUP 2>/dev/null || true + # for multi asic platforms, there are multiple orchagents + # send the SIGHUP only to the orchagent the which needs log file rotation + PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform` + ASIC_CONF=/usr/share/sonic/device/$PLATFORM/asic.conf + if [ -f "$ASIC_CONF" ]; then + . $ASIC_CONF + fi + if [ $NUM_ASIC -gt 1 ]; then + log_file=$1 + log_file_name=${log_file#/var/log/swss/} + logger -p syslog.info -t "logrotate" "Sending SIGHUP to OA log_file_name: $log_file_name" + pgrep -xa orchagent | grep $log_file_name | awk '{ print $1; }' | xargs /bin/kill -HUP 2>/dev/null || true + else + logger -p syslog.info -t "logrotate" "Sending SIGHUP to OA log_file_name: $1" + pgrep -x orchagent | xargs /bin/kill -HUP 2>/dev/null || true + fi else /bin/kill -HUP $(cat /var/run/rsyslogd.pid) fi From 97e6b4d15ca5a659ac9fd814795e941697325e86 Mon Sep 17 00:00:00 2001 From: Stephen Sun <5379172+stephenxs@users.noreply.github.com> Date: Wed, 17 Feb 2021 00:53:40 +0800 Subject: [PATCH 0198/1674] Support shared headroom pool for Microsoft SKUs (#6366) - Why I did it Support shared headroom pool Signed-off-by: Stephen Sun stephens@nvidia.com - How I did it Port configurations for SKUs based on 2700/3800 platform from 201911 For SN3800 platform: C64: 32 100G down links and 32 100G up links. D112C8: 112 50G down links and 8 100G up links. D24C52: 24 50G down links, 20 100G down links, and 32 100G up links. D28C50: 28 50G down links, 18 100G down links, and 32 100G up links. For SN2700 platform: D48C8: 48 50G down links and 8 100G up links C32: 16 100G downlinks and 16 100G uplinks Add configuration for Mellanox-SN4600C-D112C8 112 50G down links and 8 100G up links. - How to verify it Run regression test. --- .../buffers_defaults_t0.j2 | 6 ++-- .../buffers_defaults_t1.j2 | 6 ++-- .../pg_profile_lookup.ini | 30 +++++++++---------- .../Mellanox-SN2700/buffers_defaults_t0.j2 | 6 ++-- .../Mellanox-SN2700/buffers_defaults_t1.j2 | 6 ++-- .../buffers_defaults_t0.j2 | 6 ++-- .../buffers_defaults_t1.j2 | 6 ++-- .../buffers_defaults_t0.j2 | 6 ++-- .../buffers_defaults_t1.j2 | 6 ++-- .../pg_profile_lookup.ini | 30 +++++++++---------- .../buffers_defaults_t0.j2 | 6 ++-- .../buffers_defaults_t1.j2 | 6 ++-- .../buffers_defaults_t0.j2 | 6 ++-- .../buffers_defaults_t1.j2 | 6 ++-- .../buffers_defaults_t0.j2 | 10 ++++--- .../buffers_defaults_t1.j2 | 10 ++++--- .../pg_profile_lookup.ini | 30 +++++++++---------- 17 files changed, 105 insertions(+), 77 deletions(-) diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_t0.j2 index 0ad78e08c6b5..6fc5efcf9b88 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_t0.j2 @@ -1,7 +1,8 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '6687744' %} +{% set ingress_lossless_pool_size = '7719936' %} +{% set ingress_lossless_pool_xoff = '1032192' %} {% set egress_lossless_pool_size = '13945824' %} -{% set egress_lossy_pool_size = '6687744' %} +{% set egress_lossy_pool_size = '7719936' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -15,6 +16,7 @@ "ingress_lossless_pool": { {%- if dynamic_mode is not defined %} "size": "{{ ingress_lossless_pool_size }}", + "xoff": "{{ ingress_lossless_pool_xoff }}", {%- endif %} "type": "ingress", "mode": "dynamic" diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_t1.j2 index 82f6a15b33c8..95d35539253e 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_t1.j2 @@ -1,7 +1,8 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '8506368' %} +{% set ingress_lossless_pool_size = '9686016' %} +{% set ingress_lossless_pool_xoff = '1179648' %} {% set egress_lossless_pool_size = '13945824' %} -{% set egress_lossy_pool_size = '8506368' %} +{% set egress_lossy_pool_size = '9686016' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -15,6 +16,7 @@ "ingress_lossless_pool": { {%- if dynamic_mode is not defined %} "size": "{{ ingress_lossless_pool_size }}", + "xoff": "{{ ingress_lossless_pool_xoff }}", {%- endif %} "type": "ingress", "mode": "dynamic" diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/pg_profile_lookup.ini b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/pg_profile_lookup.ini index 15c12c1637e6..cdd674e4e715 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/pg_profile_lookup.ini +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/pg_profile_lookup.ini @@ -1,17 +1,17 @@ # PG lossless profiles. # speed cable size xon xoff threshold - 10000 5m 41984 19456 22528 0 - 25000 5m 41984 19456 22528 0 - 40000 5m 41984 19456 22528 0 - 50000 5m 41984 19456 22528 0 - 100000 5m 43008 19456 23552 0 - 10000 40m 41984 19456 22528 0 - 25000 40m 44032 19456 24576 0 - 40000 40m 45056 19456 25600 0 - 50000 40m 45056 19456 25600 0 - 100000 40m 49152 19456 29696 0 - 10000 300m 47104 19456 27648 0 - 25000 300m 56320 19456 36864 0 - 40000 300m 64512 19456 45056 0 - 50000 300m 69632 19456 50176 0 - 100000 300m 98304 19456 78848 0 + 10000 5m 19456 19456 22528 0 + 25000 5m 19456 19456 22528 0 + 40000 5m 19456 19456 22528 0 + 50000 5m 19456 19456 22528 0 + 100000 5m 19456 19456 23552 0 + 10000 40m 19456 19456 22528 0 + 25000 40m 19456 19456 24576 0 + 40000 40m 19456 19456 25600 0 + 50000 40m 19456 19456 25600 0 + 100000 40m 19456 19456 29696 0 + 10000 300m 19456 19456 27648 0 + 25000 300m 19456 19456 36864 0 + 40000 300m 19456 19456 45056 0 + 50000 300m 19456 19456 50176 0 + 100000 300m 19456 19456 78848 0 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/buffers_defaults_t0.j2 index 41afd1f22444..d2bf72b15f7c 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/buffers_defaults_t0.j2 @@ -1,7 +1,8 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '9489408' %} +{% set ingress_lossless_pool_size = '10177536' %} +{% set ingress_lossless_pool_xoff = '688128' %} {% set egress_lossless_pool_size = '13945824' %} -{% set egress_lossy_pool_size = '9489408' %} +{% set egress_lossy_pool_size = '10177536' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -15,6 +16,7 @@ "ingress_lossless_pool": { {%- if dynamic_mode is not defined %} "size": "{{ ingress_lossless_pool_size }}", + "xoff": "{{ ingress_lossless_pool_xoff }}", {%- endif %} "type": "ingress", "mode": "dynamic" diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/buffers_defaults_t1.j2 index 08e21ba05f75..c4422556d87a 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/buffers_defaults_t1.j2 @@ -1,7 +1,8 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '7719936' %} +{% set ingress_lossless_pool_size = '9292800' %} +{% set ingress_lossless_pool_xoff = '1572864' %} {% set egress_lossless_pool_size = '13945824' %} -{% set egress_lossy_pool_size = '7719936' %} +{% set egress_lossy_pool_size = '9292800' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -15,6 +16,7 @@ "ingress_lossless_pool": { {%- if dynamic_mode is not defined %} "size": "{{ ingress_lossless_pool_size }}", + "xoff": "{{ ingress_lossless_pool_xoff }}", {%- endif %} "type": "ingress", "mode": "dynamic" diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/buffers_defaults_t0.j2 index 2bc09d9ccc83..a59beaeeb698 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/buffers_defaults_t0.j2 @@ -1,7 +1,8 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '23343104' %} +{% set ingress_lossless_pool_size = '25866240' %} +{% set ingress_lossless_pool_xoff = '2523136' %} {% set egress_lossless_pool_size = '34287552' %} -{% set egress_lossy_pool_size = '23343104' %} +{% set egress_lossy_pool_size = '25866240' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -15,6 +16,7 @@ "ingress_lossless_pool": { {%- if dynamic_mode is not defined %} "size": "{{ ingress_lossless_pool_size }}", + "xoff": "{{ ingress_lossless_pool_xoff }}", {%- endif %} "type": "ingress", "mode": "dynamic" diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/buffers_defaults_t1.j2 index 531f1587ba7a..d610abeb4f26 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/buffers_defaults_t1.j2 @@ -1,7 +1,8 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '19410944' %} +{% set ingress_lossless_pool_size = '23900160' %} +{% set ingress_lossless_pool_xoff = '4489216' %} {% set egress_lossless_pool_size = '34287552' %} -{% set egress_lossy_pool_size = '19410944' %} +{% set egress_lossy_pool_size = '23900160' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -15,6 +16,7 @@ "ingress_lossless_pool": { {%- if dynamic_mode is not defined %} "size": "{{ ingress_lossless_pool_size }}", + "xoff": "{{ ingress_lossless_pool_xoff }}", {%- endif %} "type": "ingress", "mode": "dynamic" diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/buffers_defaults_t0.j2 index 26e89cf269ff..63e5d5f3a85a 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/buffers_defaults_t0.j2 @@ -1,7 +1,8 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '16576512' %} +{% set ingress_lossless_pool_size = '20017152' %} +{% set ingress_lossless_pool_xoff = '3440640' %} {% set egress_lossless_pool_size = '34287552' %} -{% set egress_lossy_pool_size = '16576512' %} +{% set egress_lossy_pool_size = '20017152' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -15,6 +16,7 @@ "ingress_lossless_pool": { {%- if dynamic_mode is not defined %} "size": "{{ ingress_lossless_pool_size }}", + "xoff": "{{ ingress_lossless_pool_xoff }}", {%- endif %} "type": "ingress", "mode": "dynamic" diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/buffers_defaults_t1.j2 index 31fd4c7692dd..d1ccce62bb14 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/buffers_defaults_t1.j2 @@ -1,7 +1,8 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '14790656' %} +{% set ingress_lossless_pool_size = '19124224' %} +{% set ingress_lossless_pool_xoff = '4333568' %} {% set egress_lossless_pool_size = '34287552' %} -{% set egress_lossy_pool_size = '14790656' %} +{% set egress_lossy_pool_size = '19124224' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -15,6 +16,7 @@ "ingress_lossless_pool": { {%- if dynamic_mode is not defined %} "size": "{{ ingress_lossless_pool_size }}", + "xoff": "{{ ingress_lossless_pool_xoff }}", {%- endif %} "type": "ingress", "mode": "dynamic" diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/pg_profile_lookup.ini b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/pg_profile_lookup.ini index ea772d0823a1..810d7e77e61f 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/pg_profile_lookup.ini +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/pg_profile_lookup.ini @@ -1,17 +1,17 @@ # PG lossless profiles. # speed cable size xon xoff threshold - 10000 5m 45056 19456 25600 0 - 25000 5m 48128 19456 28672 0 - 40000 5m 50176 19456 30720 0 - 50000 5m 52224 19456 32768 0 - 100000 5m 60416 19456 40960 0 - 10000 40m 46080 19456 26624 0 - 25000 40m 50176 19456 30720 0 - 40000 40m 53248 19456 33792 0 - 50000 40m 56320 19456 36864 0 - 100000 40m 67584 19456 48128 0 - 10000 300m 51200 19456 31744 0 - 25000 300m 63488 19456 44032 0 - 40000 300m 74752 19456 55296 0 - 50000 300m 82944 19456 63488 0 - 100000 300m 121856 19456 102400 0 + 10000 5m 19456 19456 25600 0 + 25000 5m 19456 19456 28672 0 + 40000 5m 19456 19456 30720 0 + 50000 5m 19456 19456 32768 0 + 100000 5m 19456 19456 40960 0 + 10000 40m 19456 19456 26624 0 + 25000 40m 19456 19456 30720 0 + 40000 40m 19456 19456 33792 0 + 50000 40m 19456 19456 36864 0 + 100000 40m 19456 19456 48128 0 + 10000 300m 19456 19456 31744 0 + 25000 300m 19456 19456 44032 0 + 40000 300m 19456 19456 55296 0 + 50000 300m 19456 19456 63488 0 + 100000 300m 19456 19456 102400 0 diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/buffers_defaults_t0.j2 index edccf5e652bc..0ff424a30a57 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/buffers_defaults_t0.j2 @@ -1,7 +1,8 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '21819392' %} +{% set ingress_lossless_pool_size = '24576000' %} +{% set ingress_lossless_pool_xoff = '2756608' %} {% set egress_lossless_pool_size = '34287552' %} -{% set egress_lossy_pool_size = '21819392' %} +{% set egress_lossy_pool_size = '24576000' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -15,6 +16,7 @@ "ingress_lossless_pool": { {%- if dynamic_mode is not defined %} "size": "{{ ingress_lossless_pool_size }}", + "xoff": "{{ ingress_lossless_pool_xoff }}", {%- endif %} "type": "ingress", "mode": "dynamic" diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/buffers_defaults_t1.j2 index 90f626db6a52..49adf1331c1c 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/buffers_defaults_t1.j2 @@ -1,7 +1,8 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '17862656' %} +{% set ingress_lossless_pool_size = '22597632' %} +{% set ingress_lossless_pool_xoff = '4734976' %} {% set egress_lossless_pool_size = '34287552' %} -{% set egress_lossy_pool_size = '17862656' %} +{% set egress_lossy_pool_size = '22597632' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -15,6 +16,7 @@ "ingress_lossless_pool": { {%- if dynamic_mode is not defined %} "size": "{{ ingress_lossless_pool_size }}", + "xoff": "{{ ingress_lossless_pool_xoff }}", {%- endif %} "type": "ingress", "mode": "dynamic" diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/buffers_defaults_t0.j2 index e732ff1a3d65..c64f1c548631 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/buffers_defaults_t0.j2 @@ -1,7 +1,8 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '21565440' %} +{% set ingress_lossless_pool_size = '24360960' %} +{% set ingress_lossless_pool_xoff = '2795520' %} {% set egress_lossless_pool_size = '34287552' %} -{% set egress_lossy_pool_size = '21565440' %} +{% set egress_lossy_pool_size = '24360960' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -15,6 +16,7 @@ "ingress_lossless_pool": { {%- if dynamic_mode is not defined %} "size": "{{ ingress_lossless_pool_size }}", + "xoff": "{{ ingress_lossless_pool_xoff }}", {%- endif %} "type": "ingress", "mode": "dynamic" diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/buffers_defaults_t1.j2 index a6556db59587..bbb51cc778b2 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/buffers_defaults_t1.j2 @@ -1,7 +1,8 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '17604608' %} +{% set ingress_lossless_pool_size = '22380544' %} +{% set ingress_lossless_pool_xoff = '4775936' %} {% set egress_lossless_pool_size = '34287552' %} -{% set egress_lossy_pool_size = '17604608' %} +{% set egress_lossy_pool_size = '22380544' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -15,6 +16,7 @@ "ingress_lossless_pool": { {%- if dynamic_mode is not defined %} "size": "{{ ingress_lossless_pool_size }}", + "xoff": "{{ ingress_lossless_pool_xoff }}", {%- endif %} "type": "ingress", "mode": "dynamic" 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 33df493e117e..aa74c4645678 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 @@ -1,7 +1,8 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '56369152' %} +{% set ingress_lossless_pool_size = '47587328' %} +{% set ingress_lossless_xoff_size = '2400256' %} {% set egress_lossless_pool_size = '60817392' %} -{% set egress_lossy_pool_size = '56369152' %} +{% set egress_lossy_pool_size = '47587328' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -15,6 +16,7 @@ "ingress_lossless_pool": { {%- if dynamic_mode is not defined %} "size": "{{ ingress_lossless_pool_size }}", + "xoff": "{{ ingress_lossless_xoff_size }}", {%- endif %} "type": "ingress", "mode": "dynamic" @@ -39,7 +41,7 @@ "dynamic_th":"7" }, "ingress_lossy_profile": { - "pool":"[BUFFER_POOL|ingress_lossy_pool]", + "pool":"[BUFFER_POOL|ingress_lossless_pool]", "size":"0", "dynamic_th":"3" }, @@ -50,7 +52,7 @@ }, "egress_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", - "size":"4096", + "size":"9216", "dynamic_th":"7" }, "q_lossy_profile": { 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 7b6e6fdf3883..1cc727f8c85e 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 @@ -1,7 +1,8 @@ {% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '55115776' %} +{% set ingress_lossless_pool_size = '46702592' %} +{% set ingress_lossless_xoff_size = '3284992' %} {% set egress_lossless_pool_size = '60817392' %} -{% set egress_lossy_pool_size = '55115776' %} +{% set egress_lossy_pool_size = '46702592' %} {%- macro generate_port_lists(PORT_ALL) %} {# Generate list of ports #} @@ -15,6 +16,7 @@ "ingress_lossless_pool": { {%- if dynamic_mode is not defined %} "size": "{{ ingress_lossless_pool_size }}", + "xoff": "{{ ingress_lossless_xoff_size }}", {%- endif %} "type": "ingress", "mode": "dynamic" @@ -39,7 +41,7 @@ "dynamic_th":"7" }, "ingress_lossy_profile": { - "pool":"[BUFFER_POOL|ingress_lossy_pool]", + "pool":"[BUFFER_POOL|ingress_lossless_pool]", "size":"0", "dynamic_th":"3" }, @@ -50,7 +52,7 @@ }, "egress_lossy_profile": { "pool":"[BUFFER_POOL|egress_lossy_pool]", - "size":"4096", + "size":"9216", "dynamic_th":"7" }, "q_lossy_profile": { diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/pg_profile_lookup.ini b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/pg_profile_lookup.ini index ab397d98de54..4931d4e1d7ae 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/pg_profile_lookup.ini +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/pg_profile_lookup.ini @@ -1,17 +1,17 @@ # PG lossless profiles. # speed cable size xon xoff threshold - 10000 5m 44032 19456 24576 0 - 25000 5m 44032 19456 24576 0 - 40000 5m 44032 19456 24576 0 - 50000 5m 44032 19456 24576 0 - 100000 5m 45056 19456 25600 0 - 10000 40m 44032 19456 24576 0 - 25000 40m 46080 19456 26624 0 - 40000 40m 47104 19456 27648 0 - 50000 40m 48128 19456 28672 0 - 100000 40m 52224 19456 32768 0 - 10000 300m 50176 19456 30720 0 - 25000 300m 59392 19456 39936 0 - 40000 300m 68608 19456 49152 0 - 50000 300m 74752 19456 55296 0 - 100000 300m 105472 19456 86016 0 + 10000 5m 19456 19456 24576 0 + 25000 5m 19456 19456 24576 0 + 40000 5m 19456 19456 24576 0 + 50000 5m 19456 19456 24576 0 + 100000 5m 19456 19456 25600 0 + 10000 40m 19456 19456 24576 0 + 25000 40m 19456 19456 26624 0 + 40000 40m 19456 19456 27648 0 + 50000 40m 19456 19456 28672 0 + 100000 40m 19456 19456 32768 0 + 10000 300m 19456 19456 30720 0 + 25000 300m 19456 19456 39936 0 + 40000 300m 19456 19456 49152 0 + 50000 300m 19456 19456 55296 0 + 100000 300m 19456 19456 86016 0 From 569686ed843407cc3201ab100eedd110f42e4bac Mon Sep 17 00:00:00 2001 From: Andriy Yurkiv <70649192+ayurkiv-nvda@users.noreply.github.com> Date: Wed, 17 Feb 2021 20:04:48 +0200 Subject: [PATCH 0199/1674] Enable SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS counter by default (#6444) Signed-off-by: Andriy Yurkiv --- dockers/docker-orchagent/enable_counters.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dockers/docker-orchagent/enable_counters.py b/dockers/docker-orchagent/enable_counters.py index 6c938230d210..5455f5923571 100755 --- a/dockers/docker-orchagent/enable_counters.py +++ b/dockers/docker-orchagent/enable_counters.py @@ -34,6 +34,7 @@ def enable_counters(): enable_counter_group(db, 'QUEUE') enable_counter_group(db, 'PFCWD') enable_counter_group(db, 'PG_WATERMARK') + enable_counter_group(db, 'PG_DROP') enable_counter_group(db, 'QUEUE_WATERMARK') enable_counter_group(db, 'BUFFER_POOL_WATERMARK') enable_counter_group(db, 'PORT_BUFFER_DROP') From b6aaeb979e1adb05d7ec59e1ee364e5406a7f704 Mon Sep 17 00:00:00 2001 From: SuvarnaMeenakshi <50386592+SuvarnaMeenakshi@users.noreply.github.com> Date: Thu, 4 Feb 2021 14:10:56 -0800 Subject: [PATCH 0200/1674] [multi_asic][vs]: Add dependency in teamd service to start after topology service(#6594) [multi_asic][vs]: Add dependency in teamd service to start after topology service. - Why I did it In multi-asic VS, topology service is run after database service to set up the internal asic topology. swss and syncd have a dependency to start after topology service is run so that the interfaces are moved to right namespace and created in the right namespace. In case of multi-asic vs, during the initial boot up, when there is no configuration added, teamd service starts and swss/syncd do not start as topology service does not start. Upon loading configuration using config_db or minigraph, swss and sycnd start up , but teamd is not restarted as swss is not stopped and started. This causes teamd to be in a bad state and requires a reload of config. - How I did it Add dependency in teamd service to start after topology service is completed. - How to verify it No change in single asic vs or platform. No change in multi-asic regular image. Change only in multi-asic VS. Bring up a multi-asic VS image without any configration, teamd service will fail to start due to dependency failure. Load minigraph, start topology service, load configuration, ensure all services come up. Signed-off-by: SuvarnaMeenakshi --- files/build_templates/per_namespace/teamd.service.j2 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/files/build_templates/per_namespace/teamd.service.j2 b/files/build_templates/per_namespace/teamd.service.j2 index 322ffdc407ed..f5936baa6a79 100644 --- a/files/build_templates/per_namespace/teamd.service.j2 +++ b/files/build_templates/per_namespace/teamd.service.j2 @@ -1,6 +1,10 @@ [Unit] Description=TEAMD container After=swss{% if multi_instance == 'true' %}@%i{% endif %}.service +{% if multi_instance == 'true' and sonic_asic_platform == 'vs' %} +Requires=topology.service +After=topology.service +{% endif %} Requires=updategraph.service After=updategraph.service Before=ntp-config.service From faf2fd3be13dd3936530577f1c5e882987b040da Mon Sep 17 00:00:00 2001 From: Myron Sosyak <49795530+msosyak@users.noreply.github.com> Date: Mon, 22 Feb 2021 20:23:46 +0200 Subject: [PATCH 0201/1674] [BFN] Fix MTU for internal interface (#6783) Set correct MTU size of internal interface for Newport platform --- .../configs/network/interfaces.d/eth2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/configs/network/interfaces.d/eth2 b/platform/barefoot/sonic-platform-modules-bfn-newport/configs/network/interfaces.d/eth2 index 725bc89e0ebb..aded25af63b7 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-newport/configs/network/interfaces.d/eth2 +++ b/platform/barefoot/sonic-platform-modules-bfn-newport/configs/network/interfaces.d/eth2 @@ -1,4 +1,4 @@ # eth cpu port auto eth2 iface eth2 inet -up ifconfig eth2 promisc mtu 9000 +up ifconfig eth2 promisc mtu 9216 From 5661d20e2189456ae6164d1c7f1d359ddba6e2e7 Mon Sep 17 00:00:00 2001 From: dflynn-Nokia <60479697+dflynn-Nokia@users.noreply.github.com> Date: Tue, 23 Feb 2021 12:25:14 -0500 Subject: [PATCH 0202/1674] [Nokia ixs7215] Platform API 2.0 improvements (#6787) - Improve sonic-mgmt platform test suite pass rate - Improve coverage of platform unit tests - Provide platform specific reboot logic as per platform porting guide - Fix bug due to pcie.yaml file being located in the wrong directory --- .../{plugins => }/pcie.yaml | 0 .../platform_reboot | 11 ++ .../7215/scripts/nokia-7215init.sh | 2 +- .../7215/sonic_platform/__init__.py | 2 + .../7215/sonic_platform/chassis.py | 10 +- .../7215/sonic_platform/component.py | 20 +- .../7215/sonic_platform/eeprom.py | 183 +++++++++++------- .../7215/sonic_platform/fan.py | 37 +++- .../7215/sonic_platform/fan_drawer.py | 13 +- .../7215/sonic_platform/psu.py | 57 +++--- .../7215/sonic_platform/sfp.py | 18 +- .../7215/sonic_platform/sfp_event.py | 2 +- .../7215/sonic_platform/test/test-chassis.py | 4 + .../sonic_platform/test/test-component.py | 5 + .../7215/sonic_platform/test/test-eeprom.py | 10 +- .../7215/sonic_platform/test/test-fan.py | 23 ++- .../7215/sonic_platform/test/test-psu.py | 29 ++- .../7215/sonic_platform/test/test-sfp.py | 9 +- .../7215/sonic_platform/test/test-thermal.py | 41 +++- 19 files changed, 308 insertions(+), 168 deletions(-) rename device/nokia/armhf-nokia_ixs7215_52x-r0/{plugins => }/pcie.yaml (100%) create mode 100644 device/nokia/armhf-nokia_ixs7215_52x-r0/platform_reboot diff --git a/device/nokia/armhf-nokia_ixs7215_52x-r0/plugins/pcie.yaml b/device/nokia/armhf-nokia_ixs7215_52x-r0/pcie.yaml similarity index 100% rename from device/nokia/armhf-nokia_ixs7215_52x-r0/plugins/pcie.yaml rename to device/nokia/armhf-nokia_ixs7215_52x-r0/pcie.yaml diff --git a/device/nokia/armhf-nokia_ixs7215_52x-r0/platform_reboot b/device/nokia/armhf-nokia_ixs7215_52x-r0/platform_reboot new file mode 100644 index 000000000000..83fc5d8028f2 --- /dev/null +++ b/device/nokia/armhf-nokia_ixs7215_52x-r0/platform_reboot @@ -0,0 +1,11 @@ +#!/bin/bash + +function SafePwrCycle() { + sync ; sync + umount -fa > /dev/null 2&>1 + + # Write CPLD register to initiate cold reboot + sudo i2cset -f -y 0 0x41 0x10 0x00 +} + +SafePwrCycle diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/scripts/nokia-7215init.sh b/platform/marvell-armhf/sonic-platform-nokia/7215/scripts/nokia-7215init.sh index 4cad43348e06..3f23afe1fce2 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/scripts/nokia-7215init.sh +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/scripts/nokia-7215init.sh @@ -51,7 +51,7 @@ chmod 644 /sys/class/i2c-adapter/i2c-0/0-0053/eeprom echo eeprom 0x55 > /sys/class/i2c-adapter/i2c-0/new_device echo eeprom 0x56 > /sys/class/i2c-adapter/i2c-0/new_device -# Enumerate psu eeprom devices +# Enumerate PSU eeprom devices echo eeprom 0x51 > /sys/class/i2c-adapter/i2c-1/new_device echo eeprom 0x52 > /sys/class/i2c-adapter/i2c-1/new_device diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/__init__.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/__init__.py index 139597f9cb07..39c712316dc6 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/__init__.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/__init__.py @@ -1,2 +1,4 @@ +__all__ = ["platform", "chassis"] +from sonic_platform import * diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/chassis.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/chassis.py index b3ada4c71f9c..a01aca24b684 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/chassis.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/chassis.py @@ -159,6 +159,14 @@ def get_model(self): """ return self._eeprom.part_number_str() + def get_service_tag(self): + """ + Retrieves the Service Tag of the chassis + Returns: + string: Service Tag of chassis + """ + return self._eeprom.service_tag_str() + def get_status(self): """ Retrieves the operational status of the chassis @@ -367,7 +375,7 @@ def get_watchdog(self): sonic_logger.log_warning(" Fail to load watchdog {}".format(repr(e))) return self._watchdog - + def get_position_in_parent(self): """ Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/component.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/component.py index 6a5410458df7..1c219d7920a5 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/component.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/component.py @@ -16,6 +16,7 @@ except ImportError as e: raise ImportError(str(e) + "- required module not found") +smbus_present = 1 try: import smbus except ImportError as e: @@ -34,6 +35,7 @@ class Component(ComponentBase): ["System-CPLD", "Used for managing SFPs, LEDs, PSUs and FANs "], ["U-Boot", "Performs initialization during booting"], ] + CPLD_UPDATE_COMMAND = 'cp /usr/sbin/vme /tmp; cp {} /tmp; cd /tmp; ./vme {};' def __init__(self, component_index): self.index = component_index @@ -55,12 +57,12 @@ def _get_command_result(self, cmdline): def _get_cpld_version(self, cpld_number): if smbus_present == 0: - cmdstatus, cpld_version = cmd.getstatusoutput('i2cget -y 0 0x41 0x2') + cmdstatus, cpld_version = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0x2') else: bus = smbus.SMBus(0) DEVICE_ADDRESS = 0x41 DEVICE_REG = 0x2 - cpld_version = bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REG) + cpld_version = str(bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REG)) return str(int(cpld_version, 16)) @@ -93,7 +95,7 @@ def get_firmware_version(self): return self._get_cpld_version(self.index) if self.index == 1: - cmdstatus, uboot_version = cmd.getstatusoutput('grep --null-data U-Boot /dev/mtd0ro|head -1 | cut -c 1-30') + cmdstatus, uboot_version = cmd.getstatusoutput('grep --null-data U-Boot /dev/mtd0ro|head -1 | cut -d" " -f2-4') return uboot_version def install_firmware(self, image_path): @@ -114,6 +116,18 @@ def install_firmware(self, image_path): print("ERROR: the cpld image {} doesn't exist ".format(image_path)) return False + cmdline = self.CPLD_UPDATE_COMMAND.format(image_path, image_name) + success_flag = False + try: + subprocess.check_call(cmdline, stderr=subprocess.STDOUT, shell=True) + success_flag = True + except subprocess.CalledProcessError as e: + print("ERROR: Failed to upgrade CPLD: rc={}".format(e.returncode)) + + if success_flag: + print("INFO: Refresh or power cycle is required to finish CPLD installation") + return success_flag + diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/eeprom.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/eeprom.py index cefcedaedf12..d0e3e00fffc2 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/eeprom.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/eeprom.py @@ -1,5 +1,5 @@ ######################################################################## -# Nokia IXR7220_D1 +# Nokia IXS7215 # # Module contains platform specific implementation of SONiC Platform # Base API and provides the EEPROMs' information. @@ -7,10 +7,9 @@ # The different EEPROMs available are as follows: # - System EEPROM : Contains Serial number, Service tag, Base MA # address, etc. in ONIE TlvInfo EEPROM format. -# - PSU EEPROM : Contains Serial number, Part number, Service Tag, -# PSU type, Revision. -# - Fan EEPROM : Contains Serial number, Part number, Service Tag, -# Fan type, Number of Fans in Fantray, Revision. +# - PSU EEPROM : Contains Model name and Part number. +# - Fan EEPROM : Contains Part number, Serial number, Manufacture Date, +# and Service Tag. ######################################################################## @@ -23,15 +22,9 @@ # PSU eeprom fields in format required by EepromDecoder psu_eeprom_format = [ - ('PPID', 's', 20), ('DPN Rev', 's', 3), ('Service Tag', 's', 7), - ('Part Number', 's', 10), ('Part Num Revision', 's', 3), - ('Mfg Test', 's', 2), ('Redundant copy', 's', 83), ('PSU Type', 's', 1), - ('Fab Rev', 's', 2) - ] - -# Fan eeprom fields in format required by EepromDecoder -fan_eeprom_format = [ - ('Model', 's', 12), ('Serial Number', 's', 13) + ('Model', 's', 15), ('burn', 'x', 1), + ('Part Number', 's', 14), ('burn', 'x', 40), + ('Serial Number', 's', 11) ] @@ -48,6 +41,7 @@ def __init__(self, is_psu=False, psu_index=0, is_fan=False, fan_index=0): if self.is_sys_eeprom: self.start_offset = 0 self.eeprom_path = self.I2C_DIR + "i2c-0/0-0053/eeprom" + # System EEPROM is in ONIE TlvInfo EEPROM format super(Eeprom, self).__init__(self.eeprom_path, self.start_offset, '', True) @@ -55,18 +49,24 @@ def __init__(self, is_psu=False, psu_index=0, is_fan=False, fan_index=0): else: if self.is_psu_eeprom: self.index = psu_index - self.start_offset = 6 + self.start_offset = 18 self.eeprom_path = self.I2C_DIR \ - + "i2c-1/1-005{}/eeprom".format(2 - self.index) + + "i2c-1/1-005{}/eeprom".format(self.index) self.format = psu_eeprom_format + + # Decode device eeprom as per specified format + EepromDecoder.__init__(self, self.eeprom_path, self.format, + self.start_offset, '', True) else: self.index = fan_index - self.start_offset = 13 + self.start_offset = 0 self.eeprom_path = self.I2C_DIR \ - + "i2c-4{0}/4{0}-0050/eeprom".format(self.index - 1) - self.format = fan_eeprom_format - EepromDecoder.__init__(self, self.eeprom_path, self.format, - self.start_offset, '', True) + + "i2c-0/0-005{}/eeprom".format(self.index + 4) + + # Fan EEPROM is in ONIE TlvInfo EEPROM format + super(Eeprom, self).__init__(self.eeprom_path, + self.start_offset, '', True) + self._load_device_eeprom() def _load_system_eeprom(self): @@ -83,24 +83,24 @@ def _load_system_eeprom(self): self.serial_number = 'NA' self.part_number = 'NA' self.model_str = 'NA' - self.serial = 'NA' + self.service_tag = 'NA' self.eeprom_tlv_dict = dict() else: eeprom = self.eeprom_data - self.eeprom_tlv_dict = dict() - if not self.is_valid_tlvinfo_header(eeprom): self.base_mac = 'NA' self.serial_number = 'NA' self.part_number = 'NA' self.model_str = 'NA' - self.serial = 'NA' + self.service_tag = 'NA' return total_length = (eeprom[9] << 8) | eeprom[10] tlv_index = self._TLV_INFO_HDR_LEN tlv_end = self._TLV_INFO_HDR_LEN + total_length + # Construct dictionary of eeprom TLV entries + self.eeprom_tlv_dict = dict() while (tlv_index + 2) < len(eeprom) and tlv_index < tlv_end: if not self.is_valid_tlv(eeprom[tlv_index:]): break @@ -108,7 +108,7 @@ def _load_system_eeprom(self): tlv = eeprom[tlv_index:tlv_index + 2 + eeprom[tlv_index + 1]] code = "0x%02X" % (tlv[0]) - + name, value = self.decoder(None, tlv) self.eeprom_tlv_dict[code] = value @@ -118,56 +118,98 @@ def _load_system_eeprom(self): tlv_index += eeprom[tlv_index+1] + 2 self.base_mac = self.eeprom_tlv_dict.get( - "0x%X" % (self._TLV_CODE_MAC_BASE), 'NA') + "0x%X" % (self._TLV_CODE_MAC_BASE), 'NA') self.serial_number = self.eeprom_tlv_dict.get( - "0x%X" % (self._TLV_CODE_SERIAL_NUMBER), 'NA') + "0x%X" % (self._TLV_CODE_SERIAL_NUMBER), 'NA') self.part_number = self.eeprom_tlv_dict.get( - "0x%X" % (self._TLV_CODE_PART_NUMBER), 'NA') + "0x%X" % (self._TLV_CODE_PART_NUMBER), 'NA') self.model_str = self.eeprom_tlv_dict.get( - "0x%X" % (self._TLV_CODE_PRODUCT_NAME), 'NA') - self.serial = self.eeprom_tlv_dict.get( - "0x%X" % (self._TLV_CODE_SERVICE_TAG), 'NA') + "0x%X" % (self._TLV_CODE_PRODUCT_NAME), 'NA') + self.service_tag = self.eeprom_tlv_dict.get( + "0x%X" % (self._TLV_CODE_SERVICE_TAG), 'NA') def _load_device_eeprom(self): """ - Reads the Fan/PSU EEPROM and retrieves the serial number and - model number of the device. + Reads the Fan/PSU EEPROM and interprets as per the specified format """ - try: - # Read Fan/PSU EEPROM as per the specified format. - self.eeprom_data = EepromDecoder.read_eeprom(self) - except Exception as e: - self.serial_number = 'NA' - self.part_number = 'NA' - self.model_str = 'NA' - self.serial = 'NA' - else: + self.serial_number = 'NA' + self.part_number = 'NA' + self.model_str = 'NA' + self.service_tag = 'NA' + self.mfg_date = 'NA' + + # PSU device eeproms use proprietary format + if self.is_psu_eeprom: + try: + # Read Fan/PSU EEPROM as per the specified format. + self.eeprom_data = EepromDecoder.read_eeprom(self) + except Exception as e: + return + + # Bail out if PSU eeprom unavailable + if self.eeprom_data[0] == 255: + return + (valid, data) = self._get_eeprom_field("Model") if valid: - self.model_str = data - else: - self.model_str = 'NA' + self.model_str = data.decode() - (valid, data) = self._get_eeprom_field("Serial Number") + (valid, data) = self._get_eeprom_field("Part Number") if valid: - self.serial_number = data - else: - self.serial_number = 'NA' + self.part_number = data.decode() - if self.is_psu_eeprom: - (valid, data) = self._get_eeprom_field("PSU Type") + # Early PSU device eeproms were not programmed with serial # + try: + (valid, data) = self._get_eeprom_field("Serial Number") if valid: - self.psu_type = data - else: - self.psu_type = 'NA' - else: - (valid, data) = self._get_eeprom_field("Fan Type") - if valid: - self.fan_type = data - else: - self.fan_type = 'NA' + self.serial_number = data.decode() + except Exception as e: + return + + # Fan device eeproms use ONIE TLV format + else: + try: + # Read Fan EEPROM as per ONIE TlvInfo EEPROM format. + self.eeprom_data = self.read_eeprom() + except Exception as e: + return + + 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 + + # Construct dictionary of eeprom TLV entries + self.eeprom_tlv_dict = dict() + 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]) + + 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 + + self.serial_number = self.eeprom_tlv_dict.get( + "0x%X" % (self._TLV_CODE_SERIAL_NUMBER), 'NA') + self.part_number = self.eeprom_tlv_dict.get( + "0x%X" % (self._TLV_CODE_PART_NUMBER), 'NA') + self.model_str = self.eeprom_tlv_dict.get( + "0x%X" % (self._TLV_CODE_PRODUCT_NAME), 'NA') + self.service_tag = self.eeprom_tlv_dict.get( + "0x%X" % (self._TLV_CODE_SERVICE_TAG), 'NA') - def _get_eeprom_field(self, field_name): + def _get_eeprom_field(self, field_name, decode=False): """ For a field name specified in the EEPROM format, returns the presence of the field and the value for the same. @@ -205,24 +247,23 @@ def airflow_fan_type(self): else: return int(self.fan_type.encode('hex'), 16) - # System EEPROM specific methods - def base_mac_addr(self): - """ - Returns the base MAC address found in the system EEPROM. - """ - return self.base_mac - def modelstr(self): """ Returns the Model name. """ return self.model_str - def serial_str(self): + def base_mac_addr(self): + """ + Returns the base MAC address found in the system EEPROM. + """ + return self.base_mac + + def service_tag_str(self): """ Returns the servicetag number. """ - return self.serial + return self.service_tag def system_eeprom_info(self): """ diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan.py index 67610a125fad..14c00c763dde 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan.py @@ -1,5 +1,5 @@ ######################################################################## -# Nokia 7215 +# Nokia IXS7215 # # Module contains an implementation of SONiC Platform Base API and # provides the Fans' information which are available in the platform @@ -9,7 +9,9 @@ try: import os + import time from sonic_platform_base.fan_base import FanBase + from sonic_platform.eeprom import Eeprom from sonic_py_common import logger except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -41,6 +43,9 @@ def __init__(self, fan_index, fan_drawer, psu_fan=False, dependency=None): self.get_fan_speed_reg = ADT7473_DIR+"fan{}_input".format(self.index) self.max_fan_speed = MAX_IXS7215_FAN_SPEED self.supported_led_color = ['off', 'green', 'red'] + + # Fan eeprom + self.eeprom = Eeprom(is_fan=True, fan_index=self.index) else: # this is a PSU Fan self.index = fan_index @@ -78,6 +83,12 @@ def _set_i2c_register(self, reg_file, value): except Exception as e: rv = 'ERR' + # Ensure that the write operation has succeeded + if (int(self._get_i2c_register(reg_file)) != value ): + time.sleep(3) + if (int(self._get_i2c_register(reg_file)) != value ): + rv = 'ERR' + return rv def get_name(self): @@ -123,10 +134,9 @@ def get_model(self): Retrieves the model number of the Fan Returns: - string: Part number of Fan + string: Model number of Fan. Use part number for this. """ - - return 'NA' + return self.eeprom.part_number_str() def get_serial(self): """ @@ -135,8 +145,25 @@ def get_serial(self): Returns: string: Serial number of Fan """ + return self.eeprom.serial_number_str() + + def get_part_number(self): + """ + Retrieves the part number of the Fan + + Returns: + string: Part number of Fan + """ + return self.eeprom.part_number_str() - return 'NA' + def get_service_tag(self): + """ + Retrieves the service tag of the Fan + + Returns: + string: Service Tag of Fan + """ + return self.eeprom.service_tag_str() def get_status(self): """ diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan_drawer.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan_drawer.py index cabb15d455d6..35b663cbb786 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan_drawer.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/fan_drawer.py @@ -30,7 +30,7 @@ def get_model(self): """ Retrieves the model number of the Fan Drawer Returns: - string: Part number of Fan Drawer + string: Part number of Fan Drawer """ return self._fan_list[0].get_model() @@ -49,7 +49,7 @@ def get_status(self): bool: True if Fan is operating properly, False if not """ return self._fan_list[0].get_status() - + def get_direction(self): return 'intake' @@ -74,8 +74,8 @@ def get_position_in_parent(self): integer: The 1-based relative physical position in parent device """ return self._index - - + + # For Nokia platforms with fan drawer(s) class RealDrawer(NokiaFanDrawer): def __init__(self, index): @@ -84,8 +84,3 @@ def __init__(self, index): def get_name(self): return self._name - - - - - diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/psu.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/psu.py index ab53abebf934..9de9ebec3699 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/psu.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/psu.py @@ -1,5 +1,5 @@ ######################################################################## -# Nokia 7215 +# Nokia IXS7215 # # Module contains an implementation of SONiC Platform Base API and # provides the PSUs' information which are available in the platform @@ -10,6 +10,7 @@ import sys from sonic_platform_base.psu_base import PsuBase from sonic_py_common import logger + from sonic_platform.eeprom import Eeprom except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -34,6 +35,9 @@ def __init__(self, psu_index): self.index = psu_index + 1 self._fan_list = [] + # PSU eeprom + self.eeprom = Eeprom(is_psu=True, psu_index=self.index) + def get_name(self): """ Retrieves the name of the device @@ -52,7 +56,7 @@ def get_presence(self): """ if smbus_present == 0: # if called from psuutil outside of pmon - cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 0 0x41 0xa') + cmdstatus, psustatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0xa') psustatus = int(psustatus, 16) else: bus = smbus.SMBus(0) @@ -78,8 +82,7 @@ def get_model(self): Returns: string: Part number of PSU """ - return "N/A" -# return self.eeprom.serial_number_str() + return self.eeprom.modelstr() def get_serial(self): @@ -89,9 +92,17 @@ def get_serial(self): Returns: string: Serial number of PSU """ - return "N/A" -# return self.eeprom.serial_number_str() + return self.eeprom.serial_number_str() + + + def get_part_number(self): + """ + Retrieves the part number of the PSU + Returns: + string: Part number of PSU + """ + return self.eeprom.part_number_str() def get_status(self): """ @@ -102,7 +113,7 @@ def get_status(self): """ if smbus_present == 0: - cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 0 0x41 0xa') + cmdstatus, psustatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0xa') psustatus = int(psustatus, 16) sonic_logger.log_warning("PMON psu-smbus - presence = 0 ") else: @@ -131,7 +142,7 @@ def get_voltage(self): e.g. 12.1 """ if smbus_present == 0: - cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 0 0x41 0xa') + cmdstatus, psustatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0xa') psustatus = int(psustatus, 16) else: bus = smbus.SMBus(0) @@ -153,30 +164,6 @@ def get_voltage(self): psu_voltage = 0.0 return psu_voltage -# def get_current(self): -# """ -# Retrieves present electric current supplied by PSU -# -# Returns: -# A float number, electric current in amperes, -# e.g. 15.4 -# """ -# psu_current = 0.0 -# -# return psu_current -# -# def get_power(self): -# """ -# Retrieves current energy supplied by PSU -# -# Returns: -# A float number, the power in watts, -# e.g. 302.6 -# """ -# psu_power = 0.0 -# -# return psu_power - def get_position_in_parent(self): """ Retrieves 1-based relative physical position in parent device @@ -191,7 +178,7 @@ def is_replaceable(self): Returns: bool: True if it is replaceable. """ - return True + return True def get_powergood_status(self): """ @@ -202,7 +189,7 @@ def get_powergood_status(self): """ if smbus_present == 0: - cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 0 0x41 0xa') + cmdstatus, psustatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0xa') psustatus = int(psustatus, 16) else: bus = smbus.SMBus(0) @@ -243,6 +230,6 @@ def set_status_led(self, color): bool: True if status LED state is set successfully, False if not """ - # In ISX7215 , the firmware running in the PSU controls the LED + # The firmware running in the PSU controls the LED # and the PSU LED state cannot be changed from CPU. return False diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp.py index cb9c1b910561..57fcde16149d 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp.py @@ -366,7 +366,7 @@ def get_transceiver_info(self): transceiver_info_dict['nominal_bit_rate'] = str( sfp_interface_bulk_data['data']['NominalSignallingRate(UnitsOf100Mbd)']['value']) transceiver_info_dict['application_advertisement'] = 'N/A' - + return transceiver_info_dict def get_transceiver_bulk_status(self): @@ -571,7 +571,7 @@ def get_rx_los(self): rx_los_list.append(rx_los_data & 0x02 != 0) else: return None - + return rx_los_list def get_tx_fault(self): @@ -617,7 +617,7 @@ def get_tx_disable(self): tx_disable_list.append(tx_disable_data & 0xC0 != 0) else: return None - + return tx_disable_list def get_tx_disable_channel(self): @@ -668,7 +668,7 @@ def get_temperature(self): """ if self.sfp_type == COPPER_TYPE: return None - + transceiver_bulk_status = self.get_transceiver_bulk_status() return transceiver_bulk_status.get("temperature", "N/A") @@ -680,7 +680,7 @@ def get_voltage(self): """ if self.sfp_type == COPPER_TYPE: return None - + transceiver_bulk_status = self.get_transceiver_bulk_status() return transceiver_bulk_status.get("voltage", "N/A") @@ -688,11 +688,11 @@ def get_tx_bias(self): """ Retrieves the TX bias current of this SFP Returns: - + """ if self.sfp_type == COPPER_TYPE: return None - + tx_bias_list = [] transceiver_bulk_status = self.get_transceiver_bulk_status() tx_bias_list.append(transceiver_bulk_status.get("tx1bias", "N/A")) @@ -884,7 +884,7 @@ def get_presence(self): return False if smbus_present == 0: # if called from sfputil outside of pmon - cmdstatus, sfpstatus = cmd.getstatusoutput('i2cget -y 0 0x41 0x3') + cmdstatus, sfpstatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0x3') sfpstatus = int(sfpstatus, 16) else: bus = smbus.SMBus(0) @@ -938,7 +938,7 @@ def is_replaceable(self): return True else: return False - + def get_position_in_parent(self): """ Retrieves 1-based relative physical position in parent device diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp_event.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp_event.py index ed2143886760..fd494ca674f5 100644 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp_event.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/sfp_event.py @@ -51,7 +51,7 @@ def deinitialize(self): def _get_transceiver_status(self): if smbus_present == 0: sonic_logger.log_info(" PMON - smbus ERROR - DEBUG sfp_event ") - cmdstatus, sfpstatus = cmd.getstatusoutput('i2cget -y 0 0x41 0x3') + cmdstatus, sfpstatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0x3') sfpstatus = int(sfpstatus, 16) else: bus = smbus.SMBus(0) diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-chassis.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-chassis.py index 775596159269..53c047ca2329 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-chassis.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-chassis.py @@ -41,6 +41,10 @@ def main(): print(" Chassis all_fans: {}\n".format(chassis.get_all_fans())) + print(" Chassis num_psus: {}".format(chassis.get_num_psus())) + + print(" Chassis all_psus: {}\n".format(chassis.get_all_psus())) + print(" Chassis num_thermals: {}".format(chassis.get_num_thermals())) print(" Chassis all_thermals: {}\n".format(chassis.get_all_thermals())) diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-component.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-component.py index edc9e03b3f66..1116cc7b5857 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-component.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-component.py @@ -10,6 +10,11 @@ def main(): chassis = Chassis() + for component in chassis.get_all_components(): + print(" Name: {}".format(component.get_name())) + print(" Description: {}".format(component.get_description())) + print(" FW version: {}\n".format(component.get_firmware_version())) + return diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-eeprom.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-eeprom.py index 76f3d8995e4a..40836611692b 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-eeprom.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-eeprom.py @@ -12,11 +12,11 @@ def main(): eeprom = chassis.get_eeprom() - print " Model: {}, Serial: {}".format(eeprom.modelstr(), - eeprom.serial_str()) - print " Part#: {}, Serial#: {}".format(eeprom.part_number_str(), - eeprom.serial_number_str()) - print " Base MAC: {}".format(eeprom.base_mac_addr()) + print(" Model: {}, Service Tag: {}".format(eeprom.modelstr(), + eeprom.service_tag_str())) + print(" Part#: {}, Serial#: {}".format(eeprom.part_number_str(), + eeprom.serial_number_str())) + print(" Base MAC: {}".format(eeprom.base_mac_addr())) return diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-fan.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-fan.py index 6f1ebd42adbe..9bbf4d864acb 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-fan.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-fan.py @@ -11,15 +11,20 @@ def main(): chassis = Chassis() for fan in chassis.get_all_fans(): - print(" Name:", fan.get_name()) - print(" Presence: {}, Status: {}, LED: {}".format(fan.get_presence(), - fan.get_status(), - fan.get_status_led())) - print(" Model: {}, Serial: {}".format(fan.get_model(), - fan.get_serial())) - print(" Direction: {}, Speed: {}RPM, Target Speed: {}%\n".format(fan.get_direction(), - str(fan.get_speed()), - str(fan.get_target_speed()))) + if not fan.get_presence(): + print(" Name: {} not present".format(fan.get_name())) + else: + print(" Name:", fan.get_name()) + print(" Presence: {}, Status: {}, LED: {}".format(fan.get_presence(), + fan.get_status(), + fan.get_status_led())) + print(" Model: {}, Serial#: {}".format(fan.get_model(), + fan.get_serial())) + print(" Part#: {}, Service Tag: {}".format(fan.get_part_number(), + fan.get_service_tag())) + print(" Direction: {}, Speed: {}RPM, Target Speed: {}%\n".format(fan.get_direction(), + str(fan.get_speed()), + str(fan.get_target_speed()))) return diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-psu.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-psu.py index 692430ff2991..e3979b8c4175 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-psu.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-psu.py @@ -11,13 +11,28 @@ def main(): chassis = Chassis() for psu in chassis.get_all_psus(): - print(" Name:", psu.get_name()) - print(" Presence: {}, Status: {}, LED: {}".format(psu.get_presence(), - psu.get_status(), - psu.get_status_led())) - print(" Model: {}, Serial: {}".format(psu.get_model(), - psu.get_serial())) - print(" Voltage: {}, Current: NO, Power: NO \n".format(psu.get_voltage())) + if not psu.get_presence(): + print(" Name: {} not present".format(psu.get_name())) + else: + print(" Name:", psu.get_name()) + print(" Presence: {}, Status: {}, LED: {}".format(psu.get_presence(), + psu.get_status(), + psu.get_status_led())) + print(" Model: {}, Serial#: {}, Part#: {}".format(psu.get_model(), + psu.get_serial(), + psu.get_part_number())) + try: + current = psu.get_current() + except NotImplementedError: + current = "NA" + try: + power = psu.get_power() + except NotImplementedError: + power = "NA" + + print(" Voltage: {}, Current: {}, Power: {}\n".format(psu.get_voltage(), + current, + power)) return diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-sfp.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-sfp.py index f5437b18f82e..4d283fa2eb03 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-sfp.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-sfp.py @@ -7,15 +7,16 @@ def main(): + print("---------------------") + print("Chassis SFP Unit Test") + print("---------------------") + + chassis = Chassis() PORT_START = 1 PORT_END = 52 - chassis = Chassis() - for physical_port in range(PORT_START, PORT_END+1): - - print(" ") print(" SFP transceiver tests PORT = ", physical_port) name = chassis.get_sfp(physical_port).get_name() diff --git a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-thermal.py b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-thermal.py index 9e99b0da3f41..91ef75d8f9a7 100755 --- a/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-thermal.py +++ b/platform/marvell-armhf/sonic-platform-nokia/7215/sonic_platform/test/test-thermal.py @@ -2,7 +2,6 @@ from sonic_platform.chassis import Chassis - def main(): print("-------------------------") print("Chassis Thermal Unit Test") @@ -11,13 +10,39 @@ def main(): chassis = Chassis() for thermal in chassis.get_all_thermals(): - print(" Name:", thermal.get_name()) - print(" Presence: {}, Status: {}".format(thermal.get_presence(), - thermal.get_status())) - print(" Model: {}, Serial: {}".format(thermal.get_model(), - thermal.get_serial())) - print(" Temperature: {}C, High Threshold: {}C\n".format(thermal.get_temperature(), - thermal.get_high_threshold())) + if not thermal.get_presence(): + print(" Name: {} not present".format(thermal.get_name())) + else: + print(" Name:", thermal.get_name()) + print(" Presence: {}, Status: {}".format(thermal.get_presence(), + thermal.get_status())) + print(" Model: {}, Serial#: {}".format(thermal.get_model(), + thermal.get_serial())) + print(" Temperature(C): {}".format(thermal.get_temperature())) + + try: + low_thresh = thermal.get_low_threshold() + except NotImplementedError: + low_thresh = "NA" + try: + high_thresh = thermal.get_high_threshold() + except NotImplementedError: + high_thresh = "NA" + + print(" Low Threshold(C): {}, High Threshold(C): {}".format(low_thresh, + high_thresh)) + + try: + crit_low_thresh = thermal.get_low_critical_threshold() + except NotImplementedError: + crit_low_thresh = "NA" + try: + crit_high_thresh = thermal.get_high_critical_threshold() + except NotImplementedError: + crit_high_thresh = "NA" + + print(" Crit Low Threshold(C): {}, Crit High Threshold(C): {}\n".format(crit_low_thresh, + crit_high_thresh)) return From b2d0cd03a830af29debe5c702c38e90622178bfa Mon Sep 17 00:00:00 2001 From: vdahiya12 <67608553+vdahiya12@users.noreply.github.com> Date: Wed, 17 Feb 2021 10:39:17 -0800 Subject: [PATCH 0203/1674] [sonic-platform-common] sub_module update (#6797) This PR updates the following commits c6b642b [ci]: download from sonic-buildimage.vs artifact (#168) e76ecc6 [sonic_y_cable] add support for retrieving firmware info for Y cable, internal and nic temperature and voltage (#162) f9cf8c9 [GitHub] Add pull request template (#167) c31636e [ci] Call pip2/3 using sudo (#166) 5521f67 [ci] Test and build packages using Azure Pipelines (#164) faca35c [ci]: Set up CI with Azure Pipelines Signed-off-by: vaibhav-dahiya --- src/sonic-platform-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-platform-common b/src/sonic-platform-common index 513920ceb241..c6b642b03a64 160000 --- a/src/sonic-platform-common +++ b/src/sonic-platform-common @@ -1 +1 @@ -Subproject commit 513920ceb2419873a1e27969b428af95c2e9e60f +Subproject commit c6b642b03a64fbd530b229a0a79d5bff9a938845 From 246c00d5067adb65280ac2e9eea99068e6016962 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Wed, 17 Feb 2021 10:37:47 -0800 Subject: [PATCH 0204/1674] [build] Install Python 3 scapy version 2.4.4 in host OS (#6799) As we are currently in the process of removing Python 2 from SONiC, to ensure a seamless transition to Python 3. --- build_debian.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build_debian.sh b/build_debian.sh index f94f1665f570..61252adabe2d 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -430,6 +430,9 @@ sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install 'wheel # docker Python API package is needed by Ansible docker module as well as some SONiC applications sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install 'docker==4.3.1' +# Install scapy +sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install 'scapy==2.4.4' + ## Note: keep pip installed for maintainance purpose # Install GCC, needed for building/installing some Python packages From 2b64e72fa87bf1590d0b18fe543d4c3077c326ef Mon Sep 17 00:00:00 2001 From: Volodymyr Samotiy Date: Thu, 18 Feb 2021 11:53:19 +0200 Subject: [PATCH 0205/1674] [Mellanox][SAI] update submodule pointer (#6806) Open ACL Outer VLAN ID for egress for ports part of VLAN RIF - Why I did it Open ACL Outer VLAN ID for egress for ports part of VLAN RIF - How I did it Updated SAI submodule pointer - How to verify it Build an image, deploy and check all is up and running. Verify ACL sonic-mgmt test is passing Signed-off-by: Volodymyr Samotiy --- platform/mellanox/mlnx-sai/SAI-Implementation | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/mellanox/mlnx-sai/SAI-Implementation b/platform/mellanox/mlnx-sai/SAI-Implementation index 80937117fcd5..aa467f9462d0 160000 --- a/platform/mellanox/mlnx-sai/SAI-Implementation +++ b/platform/mellanox/mlnx-sai/SAI-Implementation @@ -1 +1 @@ -Subproject commit 80937117fcd54e8df0581368f652f3664af6aecb +Subproject commit aa467f9462d063c79875b3a6ea699e9d0b1d8b57 From 7a003d56781334deb37db903910da229ae2b8ee3 Mon Sep 17 00:00:00 2001 From: Shi Su <67605788+shi-su@users.noreply.github.com> Date: Wed, 17 Feb 2021 23:03:19 -0800 Subject: [PATCH 0206/1674] [frr]: upgrade frr to frr-7.5-s3 tag (#6807) Update FRR 7.5 head. The following is a list of new commits. ``` e2f17ae47ad047e66923c2ff1e84c9ba10d4ad38 Merge pull request #8096 from idryzhov/7.5-backports-2021-02-16 380341362ced8e317c18b7395acb012de1f23acd ospf6d: Don't send hellos on loopback interface 7fa78b659f8e720466e0df62689327ea4b9ff867 bgpd: send correct BMP down message when nht fails 385faf6c079a41def1e6eb882cbfd50047559644 [filter]: change return code for errors d9a0e9a2934f2f75c64496fe4c724a18aa581fcb bfdd: fix session lookup 08afa0a75311a4e8cb2a18116384b603f7f2d751 ospf6d : fix issue in ecmp inter area route 2299afa1a9128d87d5169742b993c0ada575eb83 ospfd: Prevent duplicate packet read in certain vrf situations ff42a28af659ee61c0efb877b10738a5812f4bc2 vrf: use wrappers to change VRF_CONFIGURED flag 2bdc59ca21da2d67b77ec70a2fadffbca60690cd vrf: mark vrf as configured when entering vrf node b9611f65a71adc0b8fa14a5a4d1a8f44e04dcd85 ospf6d: Fix LSA formatting out-of-bounds access 610ebf56913fa56167b0a2a127b07afe020a1efe bfdd: Prevent use after free ( again ) 35b0cd5d753dda9aa70ea1c06db61a8d4b8671e3 *: Fix usage of bfd_adj_event 95b8915d0f4de3eae5438632ecd0827061ef48e8 ospf6d: Fix LSA formatting inconsistent retvals 49d73d8be84dbd23d767697474019165e511786c pimd: SGRpt prune received during prune didn't override holdtime 1d0d19afa9bb7cd4bc476d00c887876bc04eee95 eigrpd: Correctly set the mtu for eigrp packets sent bbb08db69f8eb554d23b4920c1c1e3982d8d2a91 zebra: Prevent sending of unininted data 0813d650a8120458ab7d9317061f3864dbc6f2f7 ospf6d: prevent use after free 2f2e981d967b36b240fca82fea8a961d927ef43c lib: Prevent unininted usage of data 6171becdb391ea5b88916a3a28b04b555e1fc518 bfdd: Prevent storage of ifp pointer that has been deleted 9ebb41cf4bb51e0872796530bf8c7a4d819053db bfdd: Prevent unininited data transmittal 72e16db6fea3629111537f9eb10c86f2d275adcb eigrpd: Prevent uninitialized value from being used 72b61a5bb09d59c3cc0d1d401d51de96949dff52 zebra: disallow resolution to duplicate nexthops 1083bae40b00c0ed2c9f3521ae1ab9675a87202e bgpd: Initialize bgp_notify.raw_data before passing to bgp_notify_receive() 31df7314310416f10c133dcfe9c4586edadf3fbb doc: ebgp-requires-policy requires manuall session clearing ecc8ec678d2d8a1c3d1d50a22732f9fc4bad689c watchfrr: fix SA warning 9d9365d161979a031de817c1fbcab6508dfee013 watchfrr: fix crash on missing optional argument 907e600d63c1c5b6bda40b0a08344a72533b1787 pimd: Prevent use after free b47374f0e95d99c93bfe2d14afe55219a9fda455 doc: Update bgp doc for more rfc-8212 talk 4fbeef60cc8dc5362ff84fc91d1a4e343e4e32c7 docker: centos 7, 8 yang bump and repo fixes 808e6d731f330df4a91fdfd6df6a3c8dce1651a6 docker: prefer alpine:latest for building 91b3c471f1c48818370a0f218add917f0d46aa47 Merge pull request #8092 from donaldsharp/7.5_track 60be43c0bf63c16ca42008fa802d0a2050f3fce2 Merge pull request #8090 from ton31337/fix/static_network_vrf_7.5 1f6785aa60cc57a5c8d5de98c9c09a344a0c9262 ospf6d: Track wait_timer and disable when needed c89e326be91312bed066eb2447ea8944e25a225e bgpd: Check for peer->su_remote if not NULL when handling IPv6 nexthop 15e070f6448870c98c030b6b5013ad8750d8918b Merge pull request #8047 from pguibert6WIND/nhrp_shortcut_routes_75 912994efec94082ae7d8c5e014c410964bea19f4 Merge pull request #8034 from qlyoung/fix-gnu-readline-bracketed-paste-7.5.1 9f50536993f1eb900fbfbe98d21b8c072bbd9c15 nhrpd: replace nhrp route nexthop with onlink route when prefix=nh 8c185008246db31c34574d7b79358001ac411f84 nhrpd: shortcut routes installed with nexthop. c46c87d19758040bc3f3902ab8e4a0f1bb908721 vtysh: disable bracketed paste in readline 20b35e4c3386de798f3b0cb9f2a7e6b04d995485 Merge pull request #8018 from ton31337/fix/drop_aggregate_as_attribute_if_malformed_7.5 fa25d7327fd64613cc7530aba2edfcde038da074 bgpd: Unset only aggregator flag when AGGREGATOR_AS is 0 3ee9a3726fe1a526d946c1978487a4509fe98f29 bgpd: Drop aggregator_as attribute if malformed in case of BGP_AS_ZERO be88595c6a2011f0e882bfa663baa61c86ede14e Merge pull request #8005 from opensourcerouting/snap-libyang1-fix-75 fd840ad37f2e836b210c6e60fc6325a4c3e495ce snapcraft: Update rtrlib to 0.7.0 3d00552fa9aedb96acd7ea773bc14fd2b77e7e0f snapcraft: Fix passthrough path for Libyang 1.x ``` --- rules/frr.mk | 2 +- src/sonic-frr/frr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rules/frr.mk b/rules/frr.mk index bb6a96a61fa4..c8175339f444 100644 --- a/rules/frr.mk +++ b/rules/frr.mk @@ -3,7 +3,7 @@ FRR_VERSION = 7.5 FRR_SUBVERSION = 0 FRR_BRANCH = frr/7.5 -FRR_TAG = frr-7.5-s2 +FRR_TAG = frr-7.5-s3 export FRR_VERSION FRR_SUBVERSION FRR_BRANCH FRR_TAG diff --git a/src/sonic-frr/frr b/src/sonic-frr/frr index 6b2b5cce3557..e2f17ae47ad0 160000 --- a/src/sonic-frr/frr +++ b/src/sonic-frr/frr @@ -1 +1 @@ -Subproject commit 6b2b5cce3557a383942fc194257da77e4e5270e4 +Subproject commit e2f17ae47ad047e66923c2ff1e84c9ba10d4ad38 From 5c4114bd899f4607976057c2a1cbc61a59392f0a Mon Sep 17 00:00:00 2001 From: Prince Sunny Date: Fri, 19 Feb 2021 13:33:31 -0800 Subject: [PATCH 0207/1674] Submodule update for restapi (#6808) --- src/sonic-restapi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-restapi b/src/sonic-restapi index b0024559f6a8..71847d3fbe16 160000 --- a/src/sonic-restapi +++ b/src/sonic-restapi @@ -1 +1 @@ -Subproject commit b0024559f6a888444dc5159c80ac9212cce77a07 +Subproject commit 71847d3fbe16f191efa7ffac6901d5599d044c5f From 4a79583b4c0fe7a5cfa1a2d83d1d33118956b4c9 Mon Sep 17 00:00:00 2001 From: vdahiya12 <67608553+vdahiya12@users.noreply.github.com> Date: Thu, 18 Feb 2021 00:56:30 -0800 Subject: [PATCH 0208/1674] [sonic-platform-daemons] sub_module update (#6814) This PR includes the following commit in sonic-platform-daemons 068bccc [xcvrd] Store mux_cable telemetry data in State DB (#148) 93cac0a [ci]: download from sonic-buildimage.vs artifact (#152) d651e9b [GitHub] Add pull request template (#151) bd7830b [pcied] Remove unnecessary message and move the configuration path (#144) 9080fda [ci] Call pip2/3 using sudo (#150) de60784 [ci] Test and build packages using Azure Pipelines (#149) 8bf0fd1 [ledd] Refactor to allow for more thorough unit testing; Increase unit test coverage (#147) 26bdc9e Set up CI with Azure Pipelines 1fcaa57 [pcied] Add PCIe AER stats collection (#100) Signed-off-by: vaibhav-dahiya --- src/sonic-platform-daemons | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-platform-daemons b/src/sonic-platform-daemons index e72f6cd95881..068bcccf1f30 160000 --- a/src/sonic-platform-daemons +++ b/src/sonic-platform-daemons @@ -1 +1 @@ -Subproject commit e72f6cd958810e3af9b18a71bc078dbb8c5d6cac +Subproject commit 068bcccf1f3057607b8f37709033d7f44a6ff844 From 024b173521688a294103b6587b3e588708c9d851 Mon Sep 17 00:00:00 2001 From: roman_savchuk Date: Tue, 23 Feb 2021 09:31:33 +0200 Subject: [PATCH 0209/1674] [build]: fixed BFN target build (#6826) #### Why I did it Fix runtime issues caused by SONiC update #### How I did it - new attribute SAI_ACL_ENTRY_ATTR_FIELD_ACL_IP_TYPE supported - new attribute SAI_SWITCH_ATTR_AVAILABLE_IPMC_ENTRY supported Signed-off-by: Roman Savchuk --- platform/barefoot/bfn-platform.mk | 2 +- platform/barefoot/bfn-sai.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/barefoot/bfn-platform.mk b/platform/barefoot/bfn-platform.mk index 1db534775acd..5abcd3fe4655 100644 --- a/platform/barefoot/bfn-platform.mk +++ b/platform/barefoot/bfn-platform.mk @@ -1,4 +1,4 @@ -BFN_PLATFORM = bfnplatform_20201228_deb10.deb +BFN_PLATFORM = bfnplatform_20210219_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 4f6322239d05..54285aa32cd9 100644 --- a/platform/barefoot/bfn-sai.mk +++ b/platform/barefoot/bfn-sai.mk @@ -1,4 +1,4 @@ -BFN_SAI = bfnsdk_20201228_deb10.deb +BFN_SAI = bfnsdk_20210219_deb10.deb $(BFN_SAI)_URL = "https://github.com/barefootnetworks/sonic-release-pkgs/raw/dev/$(BFN_SAI)" $(BFN_SAI)_DEPENDS += $(LIBNL_GENL3_DEV) From ceeb7ba57c113c4840e66c6591762b6eed7c53e2 Mon Sep 17 00:00:00 2001 From: donNewtonAlpha Date: Tue, 23 Feb 2021 16:26:00 -0500 Subject: [PATCH 0210/1674] [build]: .gitmodules: Fix make init (#6828) * remove trailing / from url for submodule "platform/mellanox/hw-management/hw-mgmt" Signed-off-by: Don Newton don@opennetworking.org --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 38b22c4fd687..4e1ae4863d09 100644 --- a/.gitmodules +++ b/.gitmodules @@ -59,7 +59,7 @@ url = https://github.com/aristanetworks/sonic [submodule "platform/mellanox/hw-management/hw-mgmt"] path = platform/mellanox/hw-management/hw-mgmt - url = https://github.com/Mellanox/hw-mgmt/ + url = https://github.com/Mellanox/hw-mgmt [submodule "src/redis-dump-load"] path = src/redis-dump-load url = https://github.com/p/redis-dump-load.git From 414a9424624b312e2f2c0b8d6a73b1643d43aebd Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Sat, 20 Feb 2021 11:01:12 -0800 Subject: [PATCH 0211/1674] [radv] Disable radv for specific deployment_id (#6830) --- ...cker-router-advertiser.supervisord.conf.j2 | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/dockers/docker-router-advertiser/docker-router-advertiser.supervisord.conf.j2 b/dockers/docker-router-advertiser/docker-router-advertiser.supervisord.conf.j2 index 5cbfd60322e1..9312a1a20c14 100644 --- a/dockers/docker-router-advertiser/docker-router-advertiser.supervisord.conf.j2 +++ b/dockers/docker-router-advertiser/docker-router-advertiser.supervisord.conf.j2 @@ -40,15 +40,18 @@ dependent_startup_wait_for=rsyslogd:running {# Router advertiser should only run on ToR (T0) devices which have #} {# at least one VLAN interface which has an IPv6 address asigned #} +{# But not for specific deployment_id #} {%- set vlan_v6 = namespace(count=0) -%} -{%- if "ToRRouter" in DEVICE_METADATA.localhost.type and DEVICE_METADATA.localhost.type != "MgmtToRRouter" -%} - {%- if VLAN_INTERFACE -%} - {%- for (name, prefix) in VLAN_INTERFACE|pfx_filter -%} - {# If this VLAN has an IPv6 address... #} - {%- if prefix | ipv6 -%} - {%- set vlan_v6.count = vlan_v6.count + 1 -%} - {%- endif -%} - {%- endfor -%} +{%- if DEVICE_METADATA.localhost.deployment_id != "8" -%} + {%- if "ToRRouter" in DEVICE_METADATA.localhost.type and DEVICE_METADATA.localhost.type != "MgmtToRRouter" -%} + {%- if VLAN_INTERFACE -%} + {%- for (name, prefix) in VLAN_INTERFACE|pfx_filter -%} + {# If this VLAN has an IPv6 address... #} + {%- if prefix | ipv6 -%} + {%- set vlan_v6.count = vlan_v6.count + 1 -%} + {%- endif -%} + {%- endfor -%} + {%- endif -%} {%- endif -%} {%- endif -%} From 038c6aa7cb9ff5636c6aee4402f0101b3c24fd06 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Wed, 24 Feb 2021 09:56:59 -0800 Subject: [PATCH 0212/1674] [202012][utilities][swss] update submodule head (#6869) - swss: * 459d09b 2021-02-22 | [acl] Enable VLAN ID qualifier for ACL rules (#1648) (HEAD -> 202012) [Danny Allen] * 60859b1 2021-02-08 | [buffermgr] Support maximum port headroom checking (#1607) [Stephen Sun] * 3161cbb 2021-02-17 | Add SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS counter, create new FlexCounter group (#1600) [Andriy Yurkiv] * 256ed9c 2021-02-08 | Support shared headroom pool on top of dynamic buffer calculation (#1581) [Stephen Sun] - utilities: * 30d7069 2021-02-16 | [decode-syseeprom] Refactor to utilize sonic-platform package (#1435) (HEAD -> 202012, tag: foo) [Joe LeVeque] * 891fef4 2021-02-16 | [psuutil] Refactor to utilize sonic-platform package (#1434) [Joe LeVeque] * 8c5e505 2021-02-17 | [sfputil] Refactor to utilize sonic-platform package (#1421) [Joe LeVeque] * ca5dd2c 2021-02-17 | [sfpshow] Cleanup (#1405) [Joe LeVeque] * bf489ea 2021-02-17 | Add new cli for SAI_INGRESS_PRIORITY_GROUP_STAT_DROPPED_PACKETS counter in counterpoll utility (#1355) [Andriy Yurkiv] * 25feed3 2021-02-08 | Support shared headroom pool on top of dynamic buffer calculation (#1348) [Stephen Sun] * aaa323a 2021-02-02 | [vrf]: Fix freezing during interface binding (#1325) [maksymbelei95] * cc0bb6e 2021-01-27 | [show] fix "show interfaces breakout" command (#1198) [Dmytro Shevchuk] Signed-off-by: Ying Xie --- src/sonic-swss | 2 +- src/sonic-utilities | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sonic-swss b/src/sonic-swss index 676f23dd2d04..459d09b791db 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit 676f23dd2d04f60b2b289b3a318853ac29b2c388 +Subproject commit 459d09b791db1bced2e7dc221d47e66f7d706dd0 diff --git a/src/sonic-utilities b/src/sonic-utilities index 148259bbbb48..30d70691b379 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit 148259bbbb480c9750052aa3f5c8925b2f2ff1dd +Subproject commit 30d70691b379f5e68e572fbc69f2d0db32e8c19c From a654518968d603a76aa555546cb8edb304f922f7 Mon Sep 17 00:00:00 2001 From: Samuel Angebault Date: Wed, 24 Feb 2021 10:09:52 -0800 Subject: [PATCH 0213/1674] [Arista] Driver and platform update (#6468) (#6872) - Add support for `DCS-7050SX3-48YC8` and `DCS-7050SX3-48C8` platform - Add support for more variants of `DCS-7280CR3-32[PD]4` - Add Supervisor to Linecard consutil support - Complete Watchdog platform API support - Fix some PSU behavior on `DCS-7050QX-32` and `DCS-7060CX-32S` - Fix SEU management on `DCS-7060CX-32S` - Allow kernel modules to build up to linux 5.10 - Rename led color `orange` to `amber` - Miscellaneous fixes --- device/arista/x86_64-arista_7050sx3_48c8 | 1 + .../Arista-7050SX3-48YC8/buffers.json.j2 | 2 + .../buffers_defaults_t0.j2 | 50 +++ .../pg_profile_lookup.ini | 17 + .../Arista-7050SX3-48YC8/port_config.ini | 57 +++ .../Arista-7050SX3-48YC8/qos.json.j2 | 21 + .../Arista-7050SX3-48YC8/sai.profile | 2 + ...d3-a7050sx3_48yc8-48x25G+8x100G.config.bcm | 422 ++++++++++++++++++ .../x86_64-arista_7050sx3_48yc8/default_sku | 1 + .../platform_reboot | 1 + .../plugins/eeprom.py | 1 + .../plugins/led_control.py | 1 + .../plugins/psuutil.py | 1 + .../plugins/sfputil.py | 1 + .../pmon_daemon_control.json | 1 + .../x86_64-arista_7050sx3_48yc8/sensors.conf | 50 +++ .../system_health_monitoring_config.json | 1 + .../thermal_policy.json | 1 + .../jr2-a7280cr3-32d4-40x100G.config.bcm | 12 +- ...jr2-a7280cr3-32p4-28x100G-8x10G.config.bcm | 12 +- .../jr2-a7280cr3-32p4-40x100G.config.bcm | 18 +- device/arista/x86_64-arista_7280cr3mk_32d4 | 1 + device/arista/x86_64-arista_7280cr3mk_32p4 | 1 + device/arista/x86_64-arista_7800_sup/plugins | 1 - .../x86_64-arista_7800_sup/plugins/eeprom.py | 1 + .../plugins/led_control.py | 1 + .../x86_64-arista_7800_sup/plugins/psuutil.py | 1 + .../x86_64-arista_7800_sup/plugins/sfputil.py | 1 + .../plugins/udevprefix.conf | 1 + .../system_health_monitoring_config.json | 4 +- files/Aboot/boot0.j2 | 22 +- .../barefoot/sonic-platform-modules-arista | 2 +- .../broadcom/sonic-platform-modules-arista | 2 +- 33 files changed, 681 insertions(+), 30 deletions(-) create mode 120000 device/arista/x86_64-arista_7050sx3_48c8 create mode 100644 device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/buffers.json.j2 create mode 100644 device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/buffers_defaults_t0.j2 create mode 100644 device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/pg_profile_lookup.ini create mode 100644 device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/port_config.ini create mode 100644 device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/qos.json.j2 create mode 100644 device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/sai.profile create mode 100644 device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/td3-a7050sx3_48yc8-48x25G+8x100G.config.bcm create mode 100644 device/arista/x86_64-arista_7050sx3_48yc8/default_sku create mode 120000 device/arista/x86_64-arista_7050sx3_48yc8/platform_reboot create mode 120000 device/arista/x86_64-arista_7050sx3_48yc8/plugins/eeprom.py create mode 120000 device/arista/x86_64-arista_7050sx3_48yc8/plugins/led_control.py create mode 120000 device/arista/x86_64-arista_7050sx3_48yc8/plugins/psuutil.py create mode 120000 device/arista/x86_64-arista_7050sx3_48yc8/plugins/sfputil.py create mode 120000 device/arista/x86_64-arista_7050sx3_48yc8/pmon_daemon_control.json create mode 100644 device/arista/x86_64-arista_7050sx3_48yc8/sensors.conf create mode 120000 device/arista/x86_64-arista_7050sx3_48yc8/system_health_monitoring_config.json create mode 120000 device/arista/x86_64-arista_7050sx3_48yc8/thermal_policy.json create mode 120000 device/arista/x86_64-arista_7280cr3mk_32d4 create mode 120000 device/arista/x86_64-arista_7280cr3mk_32p4 delete mode 120000 device/arista/x86_64-arista_7800_sup/plugins create mode 120000 device/arista/x86_64-arista_7800_sup/plugins/eeprom.py create mode 120000 device/arista/x86_64-arista_7800_sup/plugins/led_control.py create mode 120000 device/arista/x86_64-arista_7800_sup/plugins/psuutil.py create mode 120000 device/arista/x86_64-arista_7800_sup/plugins/sfputil.py create mode 100644 device/arista/x86_64-arista_7800_sup/plugins/udevprefix.conf diff --git a/device/arista/x86_64-arista_7050sx3_48c8 b/device/arista/x86_64-arista_7050sx3_48c8 new file mode 120000 index 000000000000..0334c5411d31 --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48c8 @@ -0,0 +1 @@ +x86_64-arista_7050sx3_48yc8 \ No newline at end of file diff --git a/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/buffers.json.j2 b/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/buffers.json.j2 new file mode 100644 index 000000000000..1083a6210fc9 --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/buffers.json.j2 @@ -0,0 +1,2 @@ +{%- set default_topo = 't0' %} +{%- include 'buffers_config.j2' %} diff --git a/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/buffers_defaults_t0.j2 b/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/buffers_defaults_t0.j2 new file mode 100644 index 000000000000..b6e6a948928d --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/buffers_defaults_t0.j2 @@ -0,0 +1,50 @@ +{%- set default_cable = '5m' %} + +{%- macro generate_port_lists(PORT_ALL) %} + {# Generate list of ports #} + {%- for port_idx in range(0,28) %} + {%- if PORT_ALL.append("Ethernet%d" % (port_idx * 4)) %}{%- endif %} + {%- if PORT_ALL.append("Ethernet%d" % (port_idx * 4 + 2)) %}{%- endif %} + {%- endfor %} + {%- for port_idx in range(28,32) %} + {%- if PORT_ALL.append("Ethernet%d" % (port_idx * 4)) %}{%- endif %} + {%- endfor %} +{%- endmacro %} + +{%- macro generate_buffer_pool_and_profiles() %} + "BUFFER_POOL": { + "ingress_lossless_pool": { + "size": "10875072", + "type": "ingress", + "mode": "dynamic", + "xoff": "4194112" + }, + "egress_lossy_pool": { + "size": "9243812", + "type": "egress", + "mode": "dynamic" + }, + "egress_lossless_pool": { + "size": "15982720", + "type": "egress", + "mode": "static" + } + }, + "BUFFER_PROFILE": { + "ingress_lossy_profile": { + "pool":"[BUFFER_POOL|ingress_lossless_pool]", + "size":"0", + "dynamic_th":"3" + }, + "egress_lossless_profile": { + "pool":"[BUFFER_POOL|egress_lossless_pool]", + "size":"1518", + "static_th":"15982720" + }, + "egress_lossy_profile": { + "pool":"[BUFFER_POOL|egress_lossy_pool]", + "size":"1518", + "dynamic_th":"3" + } + }, +{%- endmacro %} diff --git a/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/pg_profile_lookup.ini b/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/pg_profile_lookup.ini new file mode 100644 index 000000000000..0b5d680edda7 --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/pg_profile_lookup.ini @@ -0,0 +1,17 @@ +# PG lossless profiles. +# speed cable size xon xoff threshold xon_offset + 10000 5m 1248 2288 35776 0 2288 + 25000 5m 1248 2288 53248 0 2288 + 40000 5m 1248 2288 66560 0 2288 + 50000 5m 1248 2288 79872 0 2288 + 100000 5m 1248 2288 165568 0 2288 + 10000 40m 1248 2288 37024 0 2288 + 25000 40m 1248 2288 56160 0 2288 + 40000 40m 1248 2288 71552 0 2288 + 50000 40m 1248 2288 85696 0 2288 + 100000 40m 1248 2288 177632 0 2288 + 10000 300m 1248 2288 46176 0 2288 + 25000 300m 1248 2288 79040 0 2288 + 40000 300m 1248 2288 108160 0 2288 + 50000 300m 1248 2288 141856 0 2288 + 100000 300m 1248 2288 268736 0 2288 diff --git a/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/port_config.ini b/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/port_config.ini new file mode 100644 index 000000000000..bccaa602f203 --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/port_config.ini @@ -0,0 +1,57 @@ +# name lanes alias index speed +Ethernet0 1,2 Ethernet1/1 1 25000 +Ethernet2 3,4 Ethernet1/3 1 25000 +Ethernet4 5,6 Ethernet2/1 2 25000 +Ethernet6 7,8 Ethernet2/3 2 25000 +Ethernet8 9,10 Ethernet3/1 3 25000 +Ethernet10 11,12 Ethernet3/3 3 25000 +Ethernet12 13,14 Ethernet4/1 4 25000 +Ethernet14 15,16 Ethernet4/3 4 25000 +Ethernet16 21,22 Ethernet5/1 5 25000 +Ethernet18 23,24 Ethernet5/3 5 25000 +Ethernet20 17,18 Ethernet6/1 6 25000 +Ethernet22 19,20 Ethernet6/3 6 25000 +Ethernet24 25,26 Ethernet7/1 7 25000 +Ethernet26 27,28 Ethernet7/3 7 25000 +Ethernet28 29,30 Ethernet8/1 8 25000 +Ethernet30 31,32 Ethernet8/3 8 25000 +Ethernet32 37,38 Ethernet9/1 9 25000 +Ethernet34 39,40 Ethernet9/3 9 25000 +Ethernet36 33,34 Ethernet10/1 10 25000 +Ethernet38 35,46 Ethernet10/3 10 25000 +Ethernet40 41,42 Ethernet11/1 11 25000 +Ethernet42 43,44 Ethernet11/3 11 25000 +Ethernet44 45,46 Ethernet12/1 12 25000 +Ethernet46 47,48 Ethernet12/3 12 25000 +Ethernet48 53,54 Ethernet13/1 13 25000 +Ethernet50 55,56 Ethernet13/3 13 25000 +Ethernet52 49,50 Ethernet14/1 14 25000 +Ethernet54 51,52 Ethernet14/3 14 25000 +Ethernet56 57,58 Ethernet15/1 15 25000 +Ethernet58 59,60 Ethernet15/3 15 25000 +Ethernet60 61,62 Ethernet16/1 16 25000 +Ethernet62 63,64 Ethernet16/3 16 25000 +Ethernet64 69,70 Ethernet17/1 17 25000 +Ethernet66 71,72 Ethernet17/3 17 25000 +Ethernet68 65,66 Ethernet18/1 18 25000 +Ethernet70 67,68 Ethernet18/3 18 25000 +Ethernet72 73,74 Ethernet19/1 19 25000 +Ethernet74 75,76 Ethernet19/3 19 25000 +Ethernet76 77,78 Ethernet20/1 20 25000 +Ethernet78 79,80 Ethernet20/3 20 25000 +Ethernet80 85,86 Ethernet21/1 21 25000 +Ethernet82 87,88 Ethernet21/3 21 25000 +Ethernet84 81,82 Ethernet22/1 22 25000 +Ethernet86 83,84 Ethernet22/3 22 25000 +Ethernet88 89,90 Ethernet23/1 23 25000 +Ethernet88 91,92 Ethernet23/3 23 25000 +Ethernet92 93,94 Ethernet24/1 24 25000 +Ethernet92 95,96 Ethernet24/3 24 25000 +Ethernet96 101,102,103,104 Ethernet25/1 25 100000 +Ethernet100 97,98,99,100 Ethernet26/1 26 100000 +Ethernet104 105,106,107,108 Ethernet27/1 27 100000 +Ethernet108 109,110,111,112 Ethernet28/1 28 100000 +Ethernet112 117,118,119,120 Ethernet29/1 29 100000 +Ethernet116 113,114,115,116 Ethernet30/1 30 100000 +Ethernet120 121,122,123,124 Ethernet31/1 31 100000 +Ethernet124 125,126,127,128 Ethernet32/1 32 100000 diff --git a/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/qos.json.j2 b/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/qos.json.j2 new file mode 100644 index 000000000000..34002048afdb --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/qos.json.j2 @@ -0,0 +1,21 @@ +{%- macro generate_wred_profiles() %} + "WRED_PROFILE": { + "AZURE_LOSSLESS" : { + "wred_green_enable" : "true", + "wred_yellow_enable" : "true", + "wred_red_enable" : "true", + "ecn" : "ecn_all", + "green_max_threshold" : "2097152", + "green_min_threshold" : "250000", + "yellow_max_threshold" : "2097152", + "yellow_min_threshold" : "1048576", + "red_max_threshold" : "2097152", + "red_min_threshold" : "1048576", + "green_drop_probability" : "5", + "yellow_drop_probability": "5", + "red_drop_probability" : "5" + } + }, +{%- endmacro %} + +{%- include 'qos_config.j2' %} diff --git a/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/sai.profile b/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/sai.profile new file mode 100644 index 000000000000..7342226cd38c --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/sai.profile @@ -0,0 +1,2 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/td3-a7050sx3_48yc8-48x25G+8x100G.config.bcm +SAI_NUM_ECMP_MEMBERS=64 diff --git a/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/td3-a7050sx3_48yc8-48x25G+8x100G.config.bcm b/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/td3-a7050sx3_48yc8-48x25G+8x100G.config.bcm new file mode 100644 index 000000000000..aa9b32d4a350 --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48yc8/Arista-7050SX3-48YC8/td3-a7050sx3_48yc8-48x25G+8x100G.config.bcm @@ -0,0 +1,422 @@ +PHY_AN_ALLOW_PLL_CHANGE=1 +arl_clean_timeout_usec=15000000 +asf_mem_profile=2 +bcm_num_cos=8 +bcm_stat_flags=1 +bcm_stat_jumbo=9236 +cdma_timeout_usec=15000000 +dma_desc_timeout_usec=15000000 +fpem_mem_entries=0 +higig2_hdr_mode=1 +ifp_inports_support_enable=1 +ipv6_lpm_128b_enable=0 +l2xmsg_mode=1 +l2_mem_entries=163840 +l3_mem_entries=147456 +max_vp_lags=0 +miim_intr_enable=0 +module_64ports=1 +multicast_l2_range=16383 +multicast_l3_range=0 +num_ipv6_lpm_128b_entries=0 +os=unix +oversubscribe_mode=1 +pbmp_xport_xe=0x1ffffffe1ffffffe +phy_an_c73_1=1 +phy_an_c73_2=1 +phy_an_c73_3=1 +phy_an_c73_4=1 +phy_an_c73_5=1 +phy_an_c73_6=1 +phy_an_c73_7=1 +phy_an_c73_8=1 +phy_an_c73_9=1 +phy_an_c73_10=1 +phy_an_c73_11=1 +phy_an_c73_12=1 +phy_an_c73_13=1 +phy_an_c73_14=1 +phy_an_c73_15=1 +phy_an_c73_16=1 +phy_an_c73_17=1 +phy_an_c73_18=1 +phy_an_c73_19=1 +phy_an_c73_20=1 +phy_an_c73_21=1 +phy_an_c73_22=1 +phy_an_c73_23=1 +phy_an_c73_24=1 +phy_an_c73_25=0 +phy_an_c73_26=0 +phy_an_c73_27=0 +phy_an_c73_28=0 +phy_an_c73_33=1 +phy_an_c73_34=1 +phy_an_c73_35=1 +phy_an_c73_36=1 +phy_an_c73_37=1 +phy_an_c73_38=1 +phy_an_c73_39=1 +phy_an_c73_40=1 +phy_an_c73_41=1 +phy_an_c73_42=1 +phy_an_c73_43=1 +phy_an_c73_44=1 +phy_an_c73_45=1 +phy_an_c73_46=1 +phy_an_c73_47=1 +phy_an_c73_48=1 +phy_an_c73_49=1 +phy_an_c73_50=1 +phy_an_c73_51=1 +phy_an_c73_52=1 +phy_an_c73_53=1 +phy_an_c73_54=1 +phy_an_c73_55=1 +phy_an_c73_56=1 +phy_an_c73_57=0 +phy_an_c73_58=0 +phy_an_c73_59=0 +phy_an_c73_60=0 +phy_chain_rx_lane_map_physical{1.0}=0x0123 +phy_chain_rx_lane_map_physical{5.0}=0x0123 +phy_chain_rx_lane_map_physical{9.0}=0x0123 +phy_chain_rx_lane_map_physical{13.0}=0x0123 +phy_chain_rx_lane_map_physical{17.0}=0x0123 +phy_chain_rx_lane_map_physical{21.0}=0x0123 +phy_chain_rx_lane_map_physical{25.0}=0x0213 +phy_chain_rx_lane_map_physical{29.0}=0x2031 +phy_chain_rx_lane_map_physical{33.0}=0x1302 +phy_chain_rx_lane_map_physical{37.0}=0x3120 +phy_chain_rx_lane_map_physical{41.0}=0x2031 +phy_chain_rx_lane_map_physical{45.0}=0x0213 +phy_chain_rx_lane_map_physical{49.0}=0x2031 +phy_chain_rx_lane_map_physical{53.0}=0x0213 +phy_chain_rx_lane_map_physical{57.0}=0x3210 +phy_chain_rx_lane_map_physical{61.0}=0x3210 +phy_chain_rx_lane_map_physical{65.0}=0x3210 +phy_chain_rx_lane_map_physical{69.0}=0x3210 +phy_chain_rx_lane_map_physical{73.0}=0x3210 +phy_chain_rx_lane_map_physical{77.0}=0x3210 +phy_chain_rx_polarity_flip_physical{1.0}=0x0 +phy_chain_rx_polarity_flip_physical{2.0}=0x1 +phy_chain_rx_polarity_flip_physical{3.0}=0x0 +phy_chain_rx_polarity_flip_physical{4.0}=0x1 +phy_chain_rx_polarity_flip_physical{5.0}=0x1 +phy_chain_rx_polarity_flip_physical{6.0}=0x0 +phy_chain_rx_polarity_flip_physical{7.0}=0x1 +phy_chain_rx_polarity_flip_physical{8.0}=0x0 +phy_chain_rx_polarity_flip_physical{9.0}=0x1 +phy_chain_rx_polarity_flip_physical{10.0}=0x0 +phy_chain_rx_polarity_flip_physical{11.0}=0x1 +phy_chain_rx_polarity_flip_physical{12.0}=0x0 +phy_chain_rx_polarity_flip_physical{13.0}=0x1 +phy_chain_rx_polarity_flip_physical{14.0}=0x0 +phy_chain_rx_polarity_flip_physical{15.0}=0x1 +phy_chain_rx_polarity_flip_physical{16.0}=0x0 +phy_chain_rx_polarity_flip_physical{17.0}=0x0 +phy_chain_rx_polarity_flip_physical{18.0}=0x1 +phy_chain_rx_polarity_flip_physical{19.0}=0x0 +phy_chain_rx_polarity_flip_physical{20.0}=0x1 +phy_chain_rx_polarity_flip_physical{21.0}=0x1 +phy_chain_rx_polarity_flip_physical{22.0}=0x0 +phy_chain_rx_polarity_flip_physical{23.0}=0x1 +phy_chain_rx_polarity_flip_physical{24.0}=0x0 +phy_chain_rx_polarity_flip_physical{25.0}=0x0 +phy_chain_rx_polarity_flip_physical{26.0}=0x0 +phy_chain_rx_polarity_flip_physical{27.0}=0x0 +phy_chain_rx_polarity_flip_physical{28.0}=0x0 +phy_chain_rx_polarity_flip_physical{29.0}=0x0 +phy_chain_rx_polarity_flip_physical{30.0}=0x0 +phy_chain_rx_polarity_flip_physical{31.0}=0x1 +phy_chain_rx_polarity_flip_physical{32.0}=0x1 +phy_chain_rx_polarity_flip_physical{33.0}=0x1 +phy_chain_rx_polarity_flip_physical{34.0}=0x1 +phy_chain_rx_polarity_flip_physical{35.0}=0x0 +phy_chain_rx_polarity_flip_physical{36.0}=0x0 +phy_chain_rx_polarity_flip_physical{37.0}=0x1 +phy_chain_rx_polarity_flip_physical{38.0}=0x0 +phy_chain_rx_polarity_flip_physical{39.0}=0x0 +phy_chain_rx_polarity_flip_physical{40.0}=0x0 +phy_chain_rx_polarity_flip_physical{41.0}=0x1 +phy_chain_rx_polarity_flip_physical{42.0}=0x0 +phy_chain_rx_polarity_flip_physical{43.0}=0x0 +phy_chain_rx_polarity_flip_physical{44.0}=0x1 +phy_chain_rx_polarity_flip_physical{45.0}=0x1 +phy_chain_rx_polarity_flip_physical{46.0}=0x0 +phy_chain_rx_polarity_flip_physical{47.0}=0x0 +phy_chain_rx_polarity_flip_physical{48.0}=0x1 +phy_chain_rx_polarity_flip_physical{49.0}=0x0 +phy_chain_rx_polarity_flip_physical{50.0}=0x0 +phy_chain_rx_polarity_flip_physical{51.0}=0x0 +phy_chain_rx_polarity_flip_physical{52.0}=0x1 +phy_chain_rx_polarity_flip_physical{53.0}=0x1 +phy_chain_rx_polarity_flip_physical{54.0}=0x0 +phy_chain_rx_polarity_flip_physical{55.0}=0x0 +phy_chain_rx_polarity_flip_physical{56.0}=0x1 +phy_chain_rx_polarity_flip_physical{57.0}=0x0 +phy_chain_rx_polarity_flip_physical{58.0}=0x1 +phy_chain_rx_polarity_flip_physical{59.0}=0x0 +phy_chain_rx_polarity_flip_physical{60.0}=0x1 +phy_chain_rx_polarity_flip_physical{61.0}=0x1 +phy_chain_rx_polarity_flip_physical{62.0}=0x0 +phy_chain_rx_polarity_flip_physical{63.0}=0x1 +phy_chain_rx_polarity_flip_physical{64.0}=0x0 +phy_chain_rx_polarity_flip_physical{65.0}=0x0 +phy_chain_rx_polarity_flip_physical{66.0}=0x1 +phy_chain_rx_polarity_flip_physical{67.0}=0x0 +phy_chain_rx_polarity_flip_physical{68.0}=0x1 +phy_chain_rx_polarity_flip_physical{69.0}=0x0 +phy_chain_rx_polarity_flip_physical{70.0}=0x1 +phy_chain_rx_polarity_flip_physical{71.0}=0x0 +phy_chain_rx_polarity_flip_physical{72.0}=0x1 +phy_chain_rx_polarity_flip_physical{73.0}=0x0 +phy_chain_rx_polarity_flip_physical{74.0}=0x1 +phy_chain_rx_polarity_flip_physical{75.0}=0x0 +phy_chain_rx_polarity_flip_physical{76.0}=0x1 +phy_chain_rx_polarity_flip_physical{77.0}=0x1 +phy_chain_rx_polarity_flip_physical{78.0}=0x0 +phy_chain_rx_polarity_flip_physical{79.0}=0x1 +phy_chain_rx_polarity_flip_physical{80.0}=0x0 +phy_chain_tx_lane_map_physical{1.0}=0x0123 +phy_chain_tx_lane_map_physical{5.0}=0x0123 +phy_chain_tx_lane_map_physical{9.0}=0x0123 +phy_chain_tx_lane_map_physical{13.0}=0x0123 +phy_chain_tx_lane_map_physical{17.0}=0x0123 +phy_chain_tx_lane_map_physical{21.0}=0x0123 +phy_chain_tx_lane_map_physical{25.0}=0x0123 +phy_chain_tx_lane_map_physical{29.0}=0x3210 +phy_chain_tx_lane_map_physical{33.0}=0x0123 +phy_chain_tx_lane_map_physical{37.0}=0x3201 +phy_chain_tx_lane_map_physical{41.0}=0x3201 +phy_chain_tx_lane_map_physical{45.0}=0x0123 +phy_chain_tx_lane_map_physical{49.0}=0x3201 +phy_chain_tx_lane_map_physical{53.0}=0x0132 +phy_chain_tx_lane_map_physical{57.0}=0x3210 +phy_chain_tx_lane_map_physical{61.0}=0x3210 +phy_chain_tx_lane_map_physical{65.0}=0x3210 +phy_chain_tx_lane_map_physical{69.0}=0x3210 +phy_chain_tx_lane_map_physical{73.0}=0x3210 +phy_chain_tx_lane_map_physical{77.0}=0x3210 +phy_chain_tx_polarity_flip_physical{1.0}=0x0 +phy_chain_tx_polarity_flip_physical{2.0}=0x0 +phy_chain_tx_polarity_flip_physical{3.0}=0x0 +phy_chain_tx_polarity_flip_physical{4.0}=0x0 +phy_chain_tx_polarity_flip_physical{5.0}=0x0 +phy_chain_tx_polarity_flip_physical{6.0}=0x0 +phy_chain_tx_polarity_flip_physical{7.0}=0x0 +phy_chain_tx_polarity_flip_physical{8.0}=0x0 +phy_chain_tx_polarity_flip_physical{9.0}=0x0 +phy_chain_tx_polarity_flip_physical{10.0}=0x0 +phy_chain_tx_polarity_flip_physical{11.0}=0x0 +phy_chain_tx_polarity_flip_physical{12.0}=0x0 +phy_chain_tx_polarity_flip_physical{13.0}=0x0 +phy_chain_tx_polarity_flip_physical{14.0}=0x0 +phy_chain_tx_polarity_flip_physical{15.0}=0x0 +phy_chain_tx_polarity_flip_physical{16.0}=0x0 +phy_chain_tx_polarity_flip_physical{17.0}=0x0 +phy_chain_tx_polarity_flip_physical{18.0}=0x0 +phy_chain_tx_polarity_flip_physical{19.0}=0x0 +phy_chain_tx_polarity_flip_physical{20.0}=0x0 +phy_chain_tx_polarity_flip_physical{21.0}=0x0 +phy_chain_tx_polarity_flip_physical{22.0}=0x0 +phy_chain_tx_polarity_flip_physical{23.0}=0x0 +phy_chain_tx_polarity_flip_physical{24.0}=0x0 +phy_chain_tx_polarity_flip_physical{25.0}=0x0 +phy_chain_tx_polarity_flip_physical{26.0}=0x0 +phy_chain_tx_polarity_flip_physical{27.0}=0x0 +phy_chain_tx_polarity_flip_physical{28.0}=0x0 +phy_chain_tx_polarity_flip_physical{29.0}=0x0 +phy_chain_tx_polarity_flip_physical{30.0}=0x0 +phy_chain_tx_polarity_flip_physical{31.0}=0x0 +phy_chain_tx_polarity_flip_physical{32.0}=0x0 +phy_chain_tx_polarity_flip_physical{33.0}=0x0 +phy_chain_tx_polarity_flip_physical{34.0}=0x0 +phy_chain_tx_polarity_flip_physical{35.0}=0x0 +phy_chain_tx_polarity_flip_physical{36.0}=0x0 +phy_chain_tx_polarity_flip_physical{37.0}=0x0 +phy_chain_tx_polarity_flip_physical{38.0}=0x0 +phy_chain_tx_polarity_flip_physical{39.0}=0x0 +phy_chain_tx_polarity_flip_physical{40.0}=0x1 +phy_chain_tx_polarity_flip_physical{41.0}=0x0 +phy_chain_tx_polarity_flip_physical{42.0}=0x0 +phy_chain_tx_polarity_flip_physical{43.0}=0x0 +phy_chain_tx_polarity_flip_physical{44.0}=0x0 +phy_chain_tx_polarity_flip_physical{45.0}=0x0 +phy_chain_tx_polarity_flip_physical{46.0}=0x0 +phy_chain_tx_polarity_flip_physical{47.0}=0x0 +phy_chain_tx_polarity_flip_physical{48.0}=0x1 +phy_chain_tx_polarity_flip_physical{49.0}=0x1 +phy_chain_tx_polarity_flip_physical{50.0}=0x0 +phy_chain_tx_polarity_flip_physical{51.0}=0x0 +phy_chain_tx_polarity_flip_physical{52.0}=0x0 +phy_chain_tx_polarity_flip_physical{53.0}=0x0 +phy_chain_tx_polarity_flip_physical{54.0}=0x0 +phy_chain_tx_polarity_flip_physical{55.0}=0x0 +phy_chain_tx_polarity_flip_physical{56.0}=0x0 +phy_chain_tx_polarity_flip_physical{57.0}=0x1 +phy_chain_tx_polarity_flip_physical{58.0}=0x1 +phy_chain_tx_polarity_flip_physical{59.0}=0x1 +phy_chain_tx_polarity_flip_physical{60.0}=0x1 +phy_chain_tx_polarity_flip_physical{61.0}=0x1 +phy_chain_tx_polarity_flip_physical{62.0}=0x1 +phy_chain_tx_polarity_flip_physical{63.0}=0x1 +phy_chain_tx_polarity_flip_physical{64.0}=0x0 +phy_chain_tx_polarity_flip_physical{65.0}=0x0 +phy_chain_tx_polarity_flip_physical{66.0}=0x0 +phy_chain_tx_polarity_flip_physical{67.0}=0x0 +phy_chain_tx_polarity_flip_physical{68.0}=0x0 +phy_chain_tx_polarity_flip_physical{69.0}=0x0 +phy_chain_tx_polarity_flip_physical{70.0}=0x0 +phy_chain_tx_polarity_flip_physical{71.0}=0x0 +phy_chain_tx_polarity_flip_physical{72.0}=0x0 +phy_chain_tx_polarity_flip_physical{73.0}=0x0 +phy_chain_tx_polarity_flip_physical{74.0}=0x0 +phy_chain_tx_polarity_flip_physical{75.0}=0x0 +phy_chain_tx_polarity_flip_physical{76.0}=0x0 +phy_chain_tx_polarity_flip_physical{77.0}=0x0 +phy_chain_tx_polarity_flip_physical{78.0}=0x0 +phy_chain_tx_polarity_flip_physical{79.0}=0x0 +phy_chain_tx_polarity_flip_physical{80.0}=0x0 +portmap_1=1:25 +portmap_2=2:25 +portmap_3=3:25 +portmap_4=4:25 +portmap_5=5:25 +portmap_6=6:25 +portmap_7=7:25 +portmap_8=8:25 +portmap_9=9:25 +portmap_10=10:25 +portmap_11=11:25 +portmap_12=12:25 +portmap_13=13:25 +portmap_14=14:25 +portmap_15=15:25 +portmap_16=16:25 +portmap_17=17:25 +portmap_18=18:25 +portmap_19=19:25 +portmap_20=20:25 +portmap_21=21:25 +portmap_22=22:25 +portmap_23=23:25 +portmap_24=24:25 +portmap_25=25:100:4 +portmap_26=29:100:4 +portmap_27=33:100:4 +portmap_28=37:100:4 +portmap_33=57:25 +portmap_34=58:25 +portmap_35=59:25 +portmap_36=60:25 +portmap_37=61:25 +portmap_38=62:25 +portmap_39=63:25 +portmap_40=64:25 +portmap_41=65:25 +portmap_42=66:25 +portmap_43=67:25 +portmap_44=68:25 +portmap_45=69:25 +portmap_46=70:25 +portmap_47=71:25 +portmap_48=72:25 +portmap_49=73:25 +portmap_50=74:25 +portmap_51=75:25 +portmap_52=76:25 +portmap_53=77:25 +portmap_54=78:25 +portmap_55=79:25 +portmap_56=80:25 +portmap_57=41:100:4 +portmap_58=45:100:4 +portmap_59=49:100:4 +portmap_60=53:100:4 +port_flex_enable=1 +port_init_autoneg_1=0 +port_init_autoneg_5=0 +port_init_autoneg_9=0 +port_init_autoneg_13=0 +port_init_autoneg_17=0 +port_init_autoneg_21=0 +port_init_autoneg_25=0 +port_init_autoneg_26=0 +port_init_autoneg_27=0 +port_init_autoneg_28=0 +port_init_autoneg_33=0 +port_init_autoneg_37=0 +port_init_autoneg_41=0 +port_init_autoneg_45=0 +port_init_autoneg_49=0 +port_init_autoneg_53=0 +port_init_autoneg_57=0 +port_init_autoneg_58=0 +port_init_autoneg_59=0 +port_init_autoneg_60=0 +port_phy_addr_1=0xff +port_phy_addr_5=0xff +port_phy_addr_9=0xff +port_phy_addr_13=0xff +port_phy_addr_17=0xff +port_phy_addr_21=0xff +port_phy_addr_25=0xff +port_phy_addr_26=0xff +port_phy_addr_27=0xff +port_phy_addr_28=0xff +port_phy_addr_33=0xff +port_phy_addr_37=0xff +port_phy_addr_41=0xff +port_phy_addr_45=0xff +port_phy_addr_49=0xff +port_phy_addr_53=0xff +port_phy_addr_57=0xff +port_phy_addr_58=0xff +port_phy_addr_59=0xff +port_phy_addr_60=0xff +robust_hash_disable_egress_vlan=1 +robust_hash_disable_mpls=1 +robust_hash_disable_vlan=1 +serdes_core_rx_polarity_flip_physical{1}=0xa +serdes_core_rx_polarity_flip_physical{5}=0x5 +serdes_core_rx_polarity_flip_physical{9}=0x5 +serdes_core_rx_polarity_flip_physical{13}=0x5 +serdes_core_rx_polarity_flip_physical{17}=0xa +serdes_core_rx_polarity_flip_physical{21}=0x5 +serdes_core_rx_polarity_flip_physical{25}=0x0 +serdes_core_rx_polarity_flip_physical{29}=0xc +serdes_core_rx_polarity_flip_physical{33}=0x3 +serdes_core_rx_polarity_flip_physical{37}=0x1 +serdes_core_rx_polarity_flip_physical{41}=0x9 +serdes_core_rx_polarity_flip_physical{45}=0x9 +serdes_core_rx_polarity_flip_physical{49}=0x8 +serdes_core_rx_polarity_flip_physical{53}=0x9 +serdes_core_rx_polarity_flip_physical{57}=0xa +serdes_core_rx_polarity_flip_physical{61}=0x5 +serdes_core_rx_polarity_flip_physical{65}=0xa +serdes_core_rx_polarity_flip_physical{69}=0xa +serdes_core_rx_polarity_flip_physical{73}=0xa +serdes_core_rx_polarity_flip_physical{77}=0x5 +serdes_core_tx_polarity_flip_physical{1}=0x0 +serdes_core_tx_polarity_flip_physical{5}=0x0 +serdes_core_tx_polarity_flip_physical{9}=0x0 +serdes_core_tx_polarity_flip_physical{13}=0x0 +serdes_core_tx_polarity_flip_physical{17}=0x0 +serdes_core_tx_polarity_flip_physical{21}=0x0 +serdes_core_tx_polarity_flip_physical{25}=0x0 +serdes_core_tx_polarity_flip_physical{29}=0x0 +serdes_core_tx_polarity_flip_physical{33}=0x0 +serdes_core_tx_polarity_flip_physical{37}=0x8 +serdes_core_tx_polarity_flip_physical{41}=0x0 +serdes_core_tx_polarity_flip_physical{45}=0x8 +serdes_core_tx_polarity_flip_physical{49}=0x1 +serdes_core_tx_polarity_flip_physical{53}=0x0 +serdes_core_tx_polarity_flip_physical{57}=0xf +serdes_core_tx_polarity_flip_physical{61}=0x7 +serdes_core_tx_polarity_flip_physical{65}=0x0 +serdes_core_tx_polarity_flip_physical{69}=0x0 +serdes_core_tx_polarity_flip_physical{73}=0x0 +serdes_core_tx_polarity_flip_physical{77}=0x0 +tdma_timeout_usec=15000000 +tslam_timeout_usec=15000000 diff --git a/device/arista/x86_64-arista_7050sx3_48yc8/default_sku b/device/arista/x86_64-arista_7050sx3_48yc8/default_sku new file mode 100644 index 000000000000..4332a11e9f75 --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48yc8/default_sku @@ -0,0 +1 @@ +Arista-7050SX3-48YC8 t1 diff --git a/device/arista/x86_64-arista_7050sx3_48yc8/platform_reboot b/device/arista/x86_64-arista_7050sx3_48yc8/platform_reboot new file mode 120000 index 000000000000..7f94a49e38b0 --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48yc8/platform_reboot @@ -0,0 +1 @@ +../x86_64-arista_common/platform_reboot \ No newline at end of file diff --git a/device/arista/x86_64-arista_7050sx3_48yc8/plugins/eeprom.py b/device/arista/x86_64-arista_7050sx3_48yc8/plugins/eeprom.py new file mode 120000 index 000000000000..35cfaff3de4e --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48yc8/plugins/eeprom.py @@ -0,0 +1 @@ +../../x86_64-arista_common/plugins/eeprom.py \ No newline at end of file diff --git a/device/arista/x86_64-arista_7050sx3_48yc8/plugins/led_control.py b/device/arista/x86_64-arista_7050sx3_48yc8/plugins/led_control.py new file mode 120000 index 000000000000..8d733780117e --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48yc8/plugins/led_control.py @@ -0,0 +1 @@ +../../x86_64-arista_common/plugins/led_control.py \ No newline at end of file diff --git a/device/arista/x86_64-arista_7050sx3_48yc8/plugins/psuutil.py b/device/arista/x86_64-arista_7050sx3_48yc8/plugins/psuutil.py new file mode 120000 index 000000000000..2b0024ade969 --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48yc8/plugins/psuutil.py @@ -0,0 +1 @@ +../../x86_64-arista_common/plugins/psuutil.py \ No newline at end of file diff --git a/device/arista/x86_64-arista_7050sx3_48yc8/plugins/sfputil.py b/device/arista/x86_64-arista_7050sx3_48yc8/plugins/sfputil.py new file mode 120000 index 000000000000..c333e23763d7 --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48yc8/plugins/sfputil.py @@ -0,0 +1 @@ +../../x86_64-arista_common/plugins/sfputil.py \ No newline at end of file diff --git a/device/arista/x86_64-arista_7050sx3_48yc8/pmon_daemon_control.json b/device/arista/x86_64-arista_7050sx3_48yc8/pmon_daemon_control.json new file mode 120000 index 000000000000..51d5ab7b0059 --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48yc8/pmon_daemon_control.json @@ -0,0 +1 @@ +../x86_64-arista_common/pmon_daemon_control.json \ No newline at end of file diff --git a/device/arista/x86_64-arista_7050sx3_48yc8/sensors.conf b/device/arista/x86_64-arista_7050sx3_48yc8/sensors.conf new file mode 100644 index 000000000000..c6c60f294675 --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48yc8/sensors.conf @@ -0,0 +1,50 @@ +# libsensors configuration file for DCS-7050SX3-48YC8 +# --------------------------------------------------- +# + +bus "i2c-8" "SCD 0000:02:00.0 SMBus master 0 bus 0" +bus "i2c-9" "SCD 0000:02:00.0 SMBus master 0 bus 1" +bus "i2c-10" "SCD 0000:02:00.0 SMBus master 0 bus 2" +bus "i2c-72" "SCD 0000:00:09.0 SMBus master 0 bus 2" + +chip "k10temp-pci-00c3" + label temp1 "Cpu temp sensor" + +chip "pmbus-i2c-8-58" + label temp1 "Power supply 1 hotspot sensor" + label temp2 "Power supply 1 inlet temp sensor" + label temp3 "Power supply 1 sensor" + +chip "pmbus-i2c-9-58" + label temp1 "Power supply 2 hotspot sensor" + label temp2 "Power supply 2 inlet temp sensor" + label temp3 "Power supply 2 sensor" + +chip "max6658-i2c-72-4c" + label temp1 "Board temp sensor" + set temp1_max 75 + set temp1_crit 85 + + label temp2 "Front panel temp sensor" + set temp2_max 75 + set temp2_crit 85 + +chip "tmp464-i2c-10-48" + label temp1 "Switch Card temp sensor" + set temp1_max 100 + set temp1_crit 110 + + label temp2 "Front-panel temp sensor" + set temp2_max 65 + set temp2_crit 75 + + label temp3 "Front PCB temp sensor" + set temp3_max 75 + set temp3_crit 80 + + ignore temp4 + ignore temp5 + ignore temp6 + ignore temp7 + ignore temp8 + ignore temp9 diff --git a/device/arista/x86_64-arista_7050sx3_48yc8/system_health_monitoring_config.json b/device/arista/x86_64-arista_7050sx3_48yc8/system_health_monitoring_config.json new file mode 120000 index 000000000000..1185f771fa8e --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48yc8/system_health_monitoring_config.json @@ -0,0 +1 @@ +../x86_64-arista_common/system_health_monitoring_config.json \ No newline at end of file diff --git a/device/arista/x86_64-arista_7050sx3_48yc8/thermal_policy.json b/device/arista/x86_64-arista_7050sx3_48yc8/thermal_policy.json new file mode 120000 index 000000000000..0991dc7f3638 --- /dev/null +++ b/device/arista/x86_64-arista_7050sx3_48yc8/thermal_policy.json @@ -0,0 +1 @@ +../x86_64-arista_common/thermal_policy.json \ No newline at end of file diff --git a/device/arista/x86_64-arista_7280cr3_32d4/Arista-7280CR3-C40/jr2-a7280cr3-32d4-40x100G.config.bcm b/device/arista/x86_64-arista_7280cr3_32d4/Arista-7280CR3-C40/jr2-a7280cr3-32d4-40x100G.config.bcm index 4467d5d033ce..4e9d02fdc821 100644 --- a/device/arista/x86_64-arista_7280cr3_32d4/Arista-7280CR3-C40/jr2-a7280cr3-32d4-40x100G.config.bcm +++ b/device/arista/x86_64-arista_7280cr3_32d4/Arista-7280CR3-C40/jr2-a7280cr3-32d4-40x100G.config.bcm @@ -135,13 +135,13 @@ tm_port_header_type_in_203.BCM8869X=INJECTED_2_PP tm_port_header_type_out_203.BCM8869X=ETH sat_enable.BCM8869X=1 -tm_port_header_type_out_218.BCM8869X=CPU -tm_port_header_type_in_218.BCM8869X=INJECTED_2 +tm_port_header_type_out_210.BCM8869X=CPU +tm_port_header_type_in_210.BCM8869X=INJECTED_2 -tm_port_header_type_in_232.BCM8869X=INJECTED_2 -tm_port_header_type_out_232.BCM8869X=CPU -tm_port_header_type_in_233.BCM8869X=INJECTED_2 -tm_port_header_type_out_233.BCM8869X=CPU +tm_port_header_type_in_211.BCM8869X=INJECTED_2 +tm_port_header_type_out_211.BCM8869X=CPU +tm_port_header_type_in_212.BCM8869X=INJECTED_2 +tm_port_header_type_out_212.BCM8869X=CPU tm_port_header_type_in_240.BCM8869X=INJECTED_2 tm_port_header_type_out_240.BCM8869X=RAW diff --git a/device/arista/x86_64-arista_7280cr3_32p4/Arista-7280CR3-C28S8/jr2-a7280cr3-32p4-28x100G-8x10G.config.bcm b/device/arista/x86_64-arista_7280cr3_32p4/Arista-7280CR3-C28S8/jr2-a7280cr3-32p4-28x100G-8x10G.config.bcm index 3d89e2b41b4a..541e26302dc0 100644 --- a/device/arista/x86_64-arista_7280cr3_32p4/Arista-7280CR3-C28S8/jr2-a7280cr3-32p4-28x100G-8x10G.config.bcm +++ b/device/arista/x86_64-arista_7280cr3_32p4/Arista-7280CR3-C28S8/jr2-a7280cr3-32p4-28x100G-8x10G.config.bcm @@ -131,13 +131,13 @@ tm_port_header_type_in_203.BCM8869X=INJECTED_2_PP tm_port_header_type_out_203.BCM8869X=ETH sat_enable.BCM8869X=1 -tm_port_header_type_out_218.BCM8869X=CPU -tm_port_header_type_in_218.BCM8869X=INJECTED_2 +tm_port_header_type_out_210.BCM8869X=CPU +tm_port_header_type_in_210.BCM8869X=INJECTED_2 -tm_port_header_type_in_232.BCM8869X=INJECTED_2 -tm_port_header_type_out_232.BCM8869X=CPU -tm_port_header_type_in_233.BCM8869X=INJECTED_2 -tm_port_header_type_out_233.BCM8869X=CPU +tm_port_header_type_in_211.BCM8869X=INJECTED_2 +tm_port_header_type_out_211.BCM8869X=CPU +tm_port_header_type_in_212.BCM8869X=INJECTED_2 +tm_port_header_type_out_212.BCM8869X=CPU tm_port_header_type_in_240.BCM8869X=INJECTED_2 tm_port_header_type_out_240.BCM8869X=RAW diff --git a/device/arista/x86_64-arista_7280cr3_32p4/Arista-7280CR3-C40/jr2-a7280cr3-32p4-40x100G.config.bcm b/device/arista/x86_64-arista_7280cr3_32p4/Arista-7280CR3-C40/jr2-a7280cr3-32p4-40x100G.config.bcm index 654a4d8f158f..ca3c266eadfc 100644 --- a/device/arista/x86_64-arista_7280cr3_32p4/Arista-7280CR3-C40/jr2-a7280cr3-32p4-40x100G.config.bcm +++ b/device/arista/x86_64-arista_7280cr3_32p4/Arista-7280CR3-C40/jr2-a7280cr3-32p4-40x100G.config.bcm @@ -108,7 +108,7 @@ ucode_port_139.BCM8869X=RCY_MIRROR.19:core_1.139 port_priorities.BCM8869X=8 -ucode_port_240.BCM8869X=OLP:core_0.240 +ucode_port_213.BCM8869X=OLP:core_0.213 sw_state_max_size.BCM8869X=750000000 @@ -135,16 +135,16 @@ tm_port_header_type_in_203.BCM8869X=INJECTED_2_PP tm_port_header_type_out_203.BCM8869X=ETH sat_enable.BCM8869X=1 -tm_port_header_type_out_218.BCM8869X=CPU -tm_port_header_type_in_218.BCM8869X=INJECTED_2 +tm_port_header_type_out_210.BCM8869X=CPU +tm_port_header_type_in_210.BCM8869X=INJECTED_2 -tm_port_header_type_in_232.BCM8869X=INJECTED_2 -tm_port_header_type_out_232.BCM8869X=CPU -tm_port_header_type_in_233.BCM8869X=INJECTED_2 -tm_port_header_type_out_233.BCM8869X=CPU +tm_port_header_type_in_211.BCM8869X=INJECTED_2 +tm_port_header_type_out_211.BCM8869X=CPU +tm_port_header_type_in_212.BCM8869X=INJECTED_2 +tm_port_header_type_out_212.BCM8869X=CPU -tm_port_header_type_in_240.BCM8869X=INJECTED_2 -tm_port_header_type_out_240.BCM8869X=RAW +tm_port_header_type_in_213.BCM8869X=INJECTED_2 +tm_port_header_type_out_213.BCM8869X=RAW dtm_flow_mapping_mode_region_64.BCM8869X=3 dtm_flow_mapping_mode_region_65.BCM8869X=3 diff --git a/device/arista/x86_64-arista_7280cr3mk_32d4 b/device/arista/x86_64-arista_7280cr3mk_32d4 new file mode 120000 index 000000000000..50478132d933 --- /dev/null +++ b/device/arista/x86_64-arista_7280cr3mk_32d4 @@ -0,0 +1 @@ +x86_64-arista_7280cr3_32d4 \ No newline at end of file diff --git a/device/arista/x86_64-arista_7280cr3mk_32p4 b/device/arista/x86_64-arista_7280cr3mk_32p4 new file mode 120000 index 000000000000..d6e2ddbb64bd --- /dev/null +++ b/device/arista/x86_64-arista_7280cr3mk_32p4 @@ -0,0 +1 @@ +x86_64-arista_7280cr3_32p4 \ No newline at end of file diff --git a/device/arista/x86_64-arista_7800_sup/plugins b/device/arista/x86_64-arista_7800_sup/plugins deleted file mode 120000 index 789a45fcace9..000000000000 --- a/device/arista/x86_64-arista_7800_sup/plugins +++ /dev/null @@ -1 +0,0 @@ -../x86_64-arista_common/plugins \ No newline at end of file diff --git a/device/arista/x86_64-arista_7800_sup/plugins/eeprom.py b/device/arista/x86_64-arista_7800_sup/plugins/eeprom.py new file mode 120000 index 000000000000..35cfaff3de4e --- /dev/null +++ b/device/arista/x86_64-arista_7800_sup/plugins/eeprom.py @@ -0,0 +1 @@ +../../x86_64-arista_common/plugins/eeprom.py \ No newline at end of file diff --git a/device/arista/x86_64-arista_7800_sup/plugins/led_control.py b/device/arista/x86_64-arista_7800_sup/plugins/led_control.py new file mode 120000 index 000000000000..8d733780117e --- /dev/null +++ b/device/arista/x86_64-arista_7800_sup/plugins/led_control.py @@ -0,0 +1 @@ +../../x86_64-arista_common/plugins/led_control.py \ No newline at end of file diff --git a/device/arista/x86_64-arista_7800_sup/plugins/psuutil.py b/device/arista/x86_64-arista_7800_sup/plugins/psuutil.py new file mode 120000 index 000000000000..2b0024ade969 --- /dev/null +++ b/device/arista/x86_64-arista_7800_sup/plugins/psuutil.py @@ -0,0 +1 @@ +../../x86_64-arista_common/plugins/psuutil.py \ No newline at end of file diff --git a/device/arista/x86_64-arista_7800_sup/plugins/sfputil.py b/device/arista/x86_64-arista_7800_sup/plugins/sfputil.py new file mode 120000 index 000000000000..c333e23763d7 --- /dev/null +++ b/device/arista/x86_64-arista_7800_sup/plugins/sfputil.py @@ -0,0 +1 @@ +../../x86_64-arista_common/plugins/sfputil.py \ No newline at end of file diff --git a/device/arista/x86_64-arista_7800_sup/plugins/udevprefix.conf b/device/arista/x86_64-arista_7800_sup/plugins/udevprefix.conf new file mode 100644 index 000000000000..e2f2966c864d --- /dev/null +++ b/device/arista/x86_64-arista_7800_sup/plugins/udevprefix.conf @@ -0,0 +1 @@ +ttySCD \ No newline at end of file diff --git a/device/arista/x86_64-arista_common/system_health_monitoring_config.json b/device/arista/x86_64-arista_common/system_health_monitoring_config.json index 1733fcffdba3..5ceec23fd26f 100644 --- a/device/arista/x86_64-arista_common/system_health_monitoring_config.json +++ b/device/arista/x86_64-arista_common/system_health_monitoring_config.json @@ -9,8 +9,8 @@ "user_defined_checkers": [], "polling_interval": 60, "led_color": { - "fault": "orange", + "fault": "amber", "normal": "green", - "booting": "orange_blink" + "booting": "amber_blink" } } diff --git a/files/Aboot/boot0.j2 b/files/Aboot/boot0.j2 index 2384357c7a97..7e1f41ac04c4 100644 --- a/files/Aboot/boot0.j2 +++ b/files/Aboot/boot0.j2 @@ -510,6 +510,14 @@ write_platform_specific_cmdline() { aboot_machine=arista_7050cx3_32s flash_size=3700 fi + if [ "$sid" = "Marysville" ]; then + aboot_machine=arista_7050sx3_48yc8 + flash_size=7382 + fi + if [ "$sid" = "Marysville10" ]; then + aboot_machine=arista_7050sx3_48c8 + flash_size=7382 + fi if [ "$sid" = "BlackhawkO" ]; then aboot_machine=arista_7060px4_32 flash_size=28000 @@ -520,19 +528,21 @@ write_platform_specific_cmdline() { fi if [ "$sid" = "Smartsville" ]; then aboot_machine=arista_7280cr3_32p4 - flash_size=7382 fi if [ "$sid" = "SmartsvilleBK" ]; then aboot_machine=arista_7280cr3k_32p4 - flash_size=7382 + fi + if [ "$sid" = "SmartsvilleBkMs" ] || [ "$sid" = "SmartsvilleBkMsTpm" ]; then + aboot_machine=arista_7280cr3mk_32p4 fi if [ "$sid" = "SmartsvilleDD" ]; then aboot_machine=arista_7280cr3_32d4 - flash_size=7382 fi if [ "$sid" = "SmartsvilleDDBK" ]; then aboot_machine=arista_7280cr3k_32d4 - flash_size=7382 + fi + if [ "$sid" = "SmartsvilleDDBkMs" ] || [ "$sid" = "SmartsvilleDDBkMsTpm" ]; then + aboot_machine=arista_7280cr3mk_32d4 fi if [ "$sid" = "Clearwater2" ]; then aboot_machine=arista_7800r3_48cq2_lc @@ -547,6 +557,10 @@ write_platform_specific_cmdline() { flash_size=30000 sonic_mode=$supervisor_mode fi + if [ "$sid" = "SmartsvilleBkMs" ]; then + aboot_machine=arista_7280cr3mk_32p4 + flash_size=7382 + fi if in_array "$platform" "rook" "magpie" "woodpecker" "sprucefish"; then cmdline_add tsc=reliable cmdline_add pcie_ports=native diff --git a/platform/barefoot/sonic-platform-modules-arista b/platform/barefoot/sonic-platform-modules-arista index 937ea8abc1de..86f7b81834a1 160000 --- a/platform/barefoot/sonic-platform-modules-arista +++ b/platform/barefoot/sonic-platform-modules-arista @@ -1 +1 @@ -Subproject commit 937ea8abc1de457b26b7bb7a5208dab6ce40f4a1 +Subproject commit 86f7b81834a1093d1df644b09232ddacb40784ef diff --git a/platform/broadcom/sonic-platform-modules-arista b/platform/broadcom/sonic-platform-modules-arista index 937ea8abc1de..86f7b81834a1 160000 --- a/platform/broadcom/sonic-platform-modules-arista +++ b/platform/broadcom/sonic-platform-modules-arista @@ -1 +1 @@ -Subproject commit 937ea8abc1de457b26b7bb7a5208dab6ce40f4a1 +Subproject commit 86f7b81834a1093d1df644b09232ddacb40784ef From 08bf372b3436244210accf33aec186a14e81c1fd Mon Sep 17 00:00:00 2001 From: Tamer Ahmed Date: Thu, 18 Feb 2021 11:25:03 -0800 Subject: [PATCH 0214/1674] [sonic-swss-common] Submodule Update (#6812) Change in this update: b75aab7 [swss-common] Add LINKMGR CFG and MUX LINKMGR state table names (#421) 4a77d1c [ci]: add vstest (#459) 07258a6 [ci]: use build template (#457) ddcae3e runRedisScript api to process integer returned by script run in the redis (#447) 33d89c7 [systemlag] Schema defs for system lag (#448) af01f37 spell check fixes (#456) 7afd43d Update to make getNamespaces() API at par with the get_ns_list() swssdk-py API. (#455) signed-off-by: Tamer Ahmed --- src/sonic-swss-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-swss-common b/src/sonic-swss-common index 9e91e0d89139..b75aab763602 160000 --- a/src/sonic-swss-common +++ b/src/sonic-swss-common @@ -1 +1 @@ -Subproject commit 9e91e0d891398b468b8087682ae91335791fac51 +Subproject commit b75aab7636021199d3f6498eb2295f8e9dc34d73 From f700dcad5cd83d1385ef5c02618979f91a5a7199 Mon Sep 17 00:00:00 2001 From: Vadym Hlushko <62022266+vadymhlushko-mlnx@users.noreply.github.com> Date: Sun, 28 Feb 2021 18:28:00 +0200 Subject: [PATCH 0215/1674] [Mellanox] Removed files related to the Dynamic Port Breakout feature (#6880) - Why I did it While DPB files are provided, SONiC community deploy via minigraph is not supported. As of that platfrom.json and hwsku.json files related to Mellanox platforms are removed for now. - How I did it Remove platfrom.json and hwsku.json files for Mellanox platforms/SKU --- .../ACS-MSN3700C/hwsku.json | 100 --------- .../x86_64-mlnx_msn3700c-r0/platform.json | 196 ------------------ .../ACS-MSN4700/hwsku.json | 100 --------- .../x86_64-mlnx_msn4700-r0/platform.json | 196 ------------------ 4 files changed, 592 deletions(-) delete mode 100644 device/mellanox/x86_64-mlnx_msn3700c-r0/ACS-MSN3700C/hwsku.json delete mode 100644 device/mellanox/x86_64-mlnx_msn3700c-r0/platform.json delete mode 100644 device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/hwsku.json delete mode 100644 device/mellanox/x86_64-mlnx_msn4700-r0/platform.json diff --git a/device/mellanox/x86_64-mlnx_msn3700c-r0/ACS-MSN3700C/hwsku.json b/device/mellanox/x86_64-mlnx_msn3700c-r0/ACS-MSN3700C/hwsku.json deleted file mode 100644 index 7c5a8c1d95d2..000000000000 --- a/device/mellanox/x86_64-mlnx_msn3700c-r0/ACS-MSN3700C/hwsku.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "interfaces": { - "Ethernet0": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet4": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet8": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet12": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet16": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet20": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet24": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet28": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet32": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet36": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet40": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet44": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet48": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet52": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet56": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet60": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet64": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet68": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet72": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet76": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet80": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet84": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet88": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet92": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet96": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet100": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet104": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet108": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet112": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet116": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet120": { - "default_brkout_mode": "1x100G[40G]" - }, - "Ethernet124": { - "default_brkout_mode": "1x100G[40G]" - } - } -} diff --git a/device/mellanox/x86_64-mlnx_msn3700c-r0/platform.json b/device/mellanox/x86_64-mlnx_msn3700c-r0/platform.json deleted file mode 100644 index 26eb952ab525..000000000000 --- a/device/mellanox/x86_64-mlnx_msn3700c-r0/platform.json +++ /dev/null @@ -1,196 +0,0 @@ -{ - "interfaces": { - "Ethernet0": { - "index": "1,1,1,1", - "lanes": "0,1,2,3", - "alias_at_lanes": "etp1a, etp1b, etp1c, etp1d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet4": { - "index": "2,2,2,2", - "lanes": "4,5,6,7", - "alias_at_lanes": "etp2a, etp2b, etp2c, etp2d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet8": { - "index": "3,3,3,3", - "lanes": "8,9,10,11", - "alias_at_lanes": "etp3a, etp3b, etp3c, etp3d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet12": { - "index": "4,4,4,4", - "lanes": "12,13,14,15", - "alias_at_lanes": "etp4a, etp4b, etp4c, etp4d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet16": { - "index": "5,5,5,5", - "lanes": "16,17,18,19", - "alias_at_lanes": "etp5a, etp5b, etp5c, etp5d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet20": { - "index": "6,6,6,6", - "lanes": "20,21,22,23", - "alias_at_lanes": "etp6a, etp6b, etp6c, etp6d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet24": { - "index": "7,7,7,7", - "lanes": "24,25,26,27", - "alias_at_lanes": "etp7a, etp7b, etp7c, etp7d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet28": { - "index": "8,8,8,8", - "lanes": "28,29,30,31", - "alias_at_lanes": "etp8a, etp8b, etp8c, etp8d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet32": { - "index": "9,9,9,9", - "lanes": "32,33,34,35", - "alias_at_lanes": "etp9a, etp9b, etp9c, etp9d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet36": { - "index": "10,10,10,10", - "lanes": "36,37,38,39", - "alias_at_lanes": "etp10a, etp10b, etp10c, etp10d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet40": { - "index": "11,11,11,11", - "lanes": "40,41,42,43", - "alias_at_lanes": "etp11a, etp11b, etp11c, etp11d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet44": { - "index": "12,12,12,12", - "lanes": "44,45,46,47", - "alias_at_lanes": "etp12a, etp12b, etp12c, etp12d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet48": { - "index": "13,13,13,13", - "lanes": "48,49,50,51", - "alias_at_lanes": "etp13a, etp13b, etp13c, etp13d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet52": { - "index": "14,14,14,14", - "lanes": "52,53,54,55", - "alias_at_lanes": "etp14a, etp14b, etp14c, etp14d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet56": { - "index": "15,15,15,15", - "lanes": "56,57,58,59", - "alias_at_lanes": "etp15a, etp15b, etp15c, etp15d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet60": { - "index": "16,16,16,16", - "lanes": "60,61,62,63", - "alias_at_lanes": "etp16a, etp16b, etp16c, etp16d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet64": { - "index": "17,17,17,17", - "lanes": "64,65,66,67", - "alias_at_lanes": "etp17a, etp17b, etp17c, etp17d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet68": { - "index": "18,18,18,18", - "lanes": "68,69,70,71", - "alias_at_lanes": "etp18a, etp18b, etp18c, etp18d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet72": { - "index": "19,19,19,19", - "lanes": "72,73,74,75", - "alias_at_lanes": "etp19a, etp19b, etp19c, etp19d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet76": { - "index": "20,20,20,20", - "lanes": "76,77,78,79", - "alias_at_lanes": "etp20a, etp20b, etp20c, etp20d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet80": { - "index": "21,21,21,21", - "lanes": "80,81,82,83", - "alias_at_lanes": "etp21a, etp21b, etp21c, etp21d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet84": { - "index": "22,22,22,22", - "lanes": "84,85,86,87", - "alias_at_lanes": "etp22a, etp22b, etp22c, etp22d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet88": { - "index": "23,23,23,23", - "lanes": "88,89,90,91", - "alias_at_lanes": "etp23a, etp23b, etp23c, etp23d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet92": { - "index": "24,24,24,24", - "lanes": "92,93,94,95", - "alias_at_lanes": "etp24a, etp24b, etp24c, etp24d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet96": { - "index": "25,25,25,25", - "lanes": "96,97,98,99", - "alias_at_lanes": "etp25a, etp25b, etp25c, etp25d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet100": { - "index": "26,26,26,26", - "lanes": "100,101,102,103", - "alias_at_lanes": "etp26a, etp26b, etp26c, etp26d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet104": { - "index": "27,27,27,27", - "lanes": "104,105,106,107", - "alias_at_lanes": "etp27a, etp27b, etp27c, etp27d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet108": { - "index": "28,28,28,28", - "lanes": "108,109,110,111", - "alias_at_lanes": "etp28a, etp28b, etp28c, etp28d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet112": { - "index": "29,29,29,29", - "lanes": "112,113,114,115", - "alias_at_lanes": "etp29a, etp29b, etp29c, etp29d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet116": { - "index": "30,30,30,30", - "lanes": "116,117,118,119", - "alias_at_lanes": "etp30a, etp30b, etp30c, etp30d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet120": { - "index": "31,31,31,31", - "lanes": "120,121,122,123", - "alias_at_lanes": "etp31a, etp31b, etp31c, etp31d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - }, - "Ethernet124": { - "index": "32,32,32,32", - "lanes": "124,125,126,127", - "alias_at_lanes": "etp32a, etp32b, etp32c, etp32d", - "breakout_modes": "1x100G[40G],2x50G,4x25G[10G]" - } - } -} diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/hwsku.json b/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/hwsku.json deleted file mode 100644 index 4c3dee3d17a7..000000000000 --- a/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/hwsku.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "interfaces": { - "Ethernet0": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet8": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet16": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet24": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet32": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet40": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet48": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet56": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet64": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet72": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet80": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet88": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet96": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet104": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet112": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet120": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet128": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet136": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet144": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet152": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet160": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet168": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet176": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet184": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet192": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet200": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet208": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet216": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet224": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet232": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet240": { - "default_brkout_mode": "1x400G[200G]" - }, - "Ethernet248": { - "default_brkout_mode": "1x400G[200G]" - } - } -} \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/platform.json b/device/mellanox/x86_64-mlnx_msn4700-r0/platform.json deleted file mode 100644 index 7a3d3d1048b9..000000000000 --- a/device/mellanox/x86_64-mlnx_msn4700-r0/platform.json +++ /dev/null @@ -1,196 +0,0 @@ -{ - "interfaces": { - "Ethernet0": { - "index": "1,1,1,1,1,1,1,1", - "lanes": "0,1,2,3,4,5,6,7", - "alias_at_lanes": "etp1a, etp1b, etp1c, etp1d, etp1e, etp1f, etp1g, etp1h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet8": { - "index": "2,2,2,2,2,2,2,2", - "lanes": "8,9,10,11,12,13,14,15", - "alias_at_lanes": "etp2a, etp2b, etp2c, etp2d, etp2e, etp2f, etp2g, etp2h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet16": { - "index": "3,3,3,3,3,3,3,3", - "lanes": "16,17,18,19,20,21,22,23", - "alias_at_lanes": "etp3a, etp3b, etp3c, etp3d, etp3e, etp3f, etp3g, etp3h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet24": { - "index": "4,4,4,4,4,4,4,4", - "lanes": "24,25,26,27,28,29,30,31", - "alias_at_lanes": "etp4a, etp4b, etp4c, etp4d, etp4e, etp4f, etp4g, etp4h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet32": { - "index": "5,5,5,5,5,5,5,5", - "lanes": "32,33,34,35,36,37,38,39", - "alias_at_lanes": "etp5a, etp5b, etp5c, etp5d, etp5e, etp5f, etp5g, etp5h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet40": { - "index": "6,6,6,6,6,6,6,6", - "lanes": "40,41,42,43,44,45,46,47", - "alias_at_lanes": "etp6a, etp6b, etp6c, etp6d, etp6e, etp6f, etp6g, etp6h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet48": { - "index": "7,7,7,7,7,7,7,7", - "lanes": "48,49,50,51,52,53,54,55", - "alias_at_lanes": "etp7a, etp7b, etp7c, etp7d, etp7e, etp7f, etp7g, etp7h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet56": { - "index": "8,8,8,8,8,8,8,8", - "lanes": "56,57,58,59,60,61,62,63", - "alias_at_lanes": "etp8a, etp8b, etp8c, etp8d, etp8e, etp8f, etp8g, etp8h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet64": { - "index": "9,9,9,9,9,9,9,9", - "lanes": "64,65,66,67,68,69,70,71", - "alias_at_lanes": "etp9a, etp9b, etp9c, etp9d, etp9e, etp9f, etp9g, etp9h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet72": { - "index": "10,10,10,10,10,10,10,10", - "lanes": "72,73,74,75,76,77,78,79", - "alias_at_lanes": "etp10a, etp10b, etp10c, etp10d, etp10e, etp10f, etp10g, etp10h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet80": { - "index": "11,11,11,11,11,11,11,11", - "lanes": "80,81,82,83,84,85,86,87", - "alias_at_lanes": "etp11a, etp11b, etp11c, etp11d, etp11e, etp11f, etp11g, etp11h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet88": { - "index": "12,12,12,12,12,12,12,12", - "lanes": "88,89,90,91,92,93,94,95", - "alias_at_lanes": "etp12a, etp12b, etp12c, etp12d, etp12e, etp12f, etp12g, etp12h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet96": { - "index": "13,13,13,13,13,13,13,13", - "lanes": "96,97,98,99,100,101,102,103", - "alias_at_lanes": "etp13a, etp13b, etp13c, etp13d, etp13e, etp13f, etp13g, etp13h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet104": { - "index": "14,14,14,14,14,14,14,14", - "lanes": "104,105,106,107,108,109,110,111", - "alias_at_lanes": "etp14a, etp14b, etp14c, etp14d, etp14e, etp14f, etp14g, etp14h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet112": { - "index": "15,15,15,15,15,15,15,15", - "lanes": "112,113,114,115,116,117,118,119", - "alias_at_lanes": "etp15a, etp15b, etp15c, etp15d, etp15e, etp15f, etp15g, etp15h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet120": { - "index": "16,16,16,16,16,16,16,16", - "lanes": "120,121,122,123,124,125,126,127", - "alias_at_lanes": "etp16a, etp16b, etp16c, etp16d, etp16e, etp16f, etp16g, etp16h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet128": { - "index": "17,17,17,17,17,17,17,17", - "lanes": "128,129,130,131,132,133,134,135", - "alias_at_lanes": "etp17a, etp17b, etp17c, etp17d, etp17e, etp17f, etp17g, etp17h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet136": { - "index": "18,18,18,18,18,18,18,18", - "lanes": "136,137,138,139,140,141,142,143", - "alias_at_lanes": "etp18a, etp18b, etp18c, etp18d, etp18e, etp18f, etp18g, etp18h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet144": { - "index": "19,19,19,19,19,19,19,19", - "lanes": "144,145,146,147,148,149,150,151", - "alias_at_lanes": "etp19a, etp19b, etp19c, etp19d, etp19e, etp19f, etp19g, etp19h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet152": { - "index": "20,20,20,20,20,20,20,20", - "lanes": "152,153,154,155,156,157,158,159", - "alias_at_lanes": "etp20a, etp20b, etp20c, etp20d, etp20e, etp20f, etp20g, etp20h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet160": { - "index": "21,21,21,21,21,21,21,21", - "lanes": "160,161,162,163,164,165,166,167", - "alias_at_lanes": "etp21a, etp21b, etp21c, etp21d, etp21e, etp21f, etp21g, etp21h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet168": { - "index": "22,22,22,22,22,22,22,22", - "lanes": "168,169,170,171,172,173,174,175", - "alias_at_lanes": "etp22a, etp22b, etp22c, etp22d, etp22e, etp22f, etp22g, etp22h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet176": { - "index": "23,23,23,23,23,23,23,23", - "lanes": "176,177,178,179,180,181,182,183", - "alias_at_lanes": "etp23a, etp23b, etp23c, etp23d, etp23e, etp23f, etp23g, etp23h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet184": { - "index": "24,24,24,24,24,24,24,24", - "lanes": "184,185,186,187,188,189,190,191", - "alias_at_lanes": "etp24a, etp24b, etp24c, etp24d, etp24e, etp24f, etp24g, etp24h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet192": { - "index": "25,25,25,25,25,25,25,25", - "lanes": "192,193,194,195,196,197,198,199", - "alias_at_lanes": "etp25a, etp25b, etp25c, etp25d, etp25e, etp25f, etp25g, etp25h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet200": { - "index": "26,26,26,26,26,26,26,26", - "lanes": "200,201,202,203,204,205,206,207", - "alias_at_lanes": "etp26a, etp26b, etp26c, etp26d, etp26e, etp26f, etp26g, etp26h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet208": { - "index": "27,27,27,27,27,27,27,27", - "lanes": "208,209,210,211,212,213,214,215", - "alias_at_lanes": "etp27a, etp27b, etp27c, etp27d, etp27e, etp27f, etp27g, etp27h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet216": { - "index": "28,28,28,28,28,28,28,28", - "lanes": "216,217,218,219,220,221,222,223", - "alias_at_lanes": "etp28a, etp28b, etp28c, etp28d, etp28e, etp28f, etp28g, etp28h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet224": { - "index": "29,29,29,29,29,29,29,29", - "lanes": "224,225,226,227,228,229,230,231", - "alias_at_lanes": "etp29a, etp29b, etp29c, etp29d, etp29e, etp29f, etp29g, etp29h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet232": { - "index": "30,30,30,30,30,30,30,30", - "lanes": "232,233,234,235,236,237,238,239", - "alias_at_lanes": "etp30a, etp30b, etp30c, etp30d, etp30e, etp30f, etp30g, etp30h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet240": { - "index": "31,31,31,31,31,31,31,31", - "lanes": "240,241,242,243,244,245,246,247", - "alias_at_lanes": "etp31a, etp31b, etp31c, etp31d, etp31e, etp31f, etp31g, etp31h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - }, - "Ethernet248": { - "index": "32,32,32,32,32,32,32,32", - "lanes": "248,249,250,251,252,253,254,255", - "alias_at_lanes": "etp32a, etp32b, etp32c, etp32d, etp32e, etp32f, etp32g, etp32h", - "breakout_modes": "1x400G[200G],2x200G[100G,40G],4x100G" - } - } -} \ No newline at end of file From f355ce18ec9487d494bc8ec2956be01f2aef351d Mon Sep 17 00:00:00 2001 From: xumia <59720581+xumia@users.noreply.github.com> Date: Thu, 25 Feb 2021 13:44:58 +0800 Subject: [PATCH 0216/1674] Add azure pipelines for reproducible build (#6870) * Add azure pipelines for reproducible build * Add always build flag for upgrade build * Fix the build version ubuntu-20.04 --- .azure-pipelines/azure-pipelines-Official.yml | 31 +++++ .../azure-pipelines-UpgrateVersion.yml | 109 ++++++++++++++++++ .azure-pipelines/azure-pipelines-build.yml | 72 ++++++++++++ .../azure-pipelines-job-groups.yml | 53 +++++++++ 4 files changed, 265 insertions(+) create mode 100644 .azure-pipelines/azure-pipelines-Official.yml create mode 100644 .azure-pipelines/azure-pipelines-UpgrateVersion.yml create mode 100644 .azure-pipelines/azure-pipelines-build.yml create mode 100644 .azure-pipelines/azure-pipelines-job-groups.yml diff --git a/.azure-pipelines/azure-pipelines-Official.yml b/.azure-pipelines/azure-pipelines-Official.yml new file mode 100644 index 000000000000..a5a08167ca1d --- /dev/null +++ b/.azure-pipelines/azure-pipelines-Official.yml @@ -0,0 +1,31 @@ +# Starter pipeline +# Start with a minimal pipeline that you can customize to build and deploy your code. +# Add steps that build, run tests, deploy, and more: +# https://aka.ms/yaml + +trigger: none +pr: none + +schedules: +- cron: "0 0 * * *" + displayName: Daily Build + branches: + include: + - 202012 + always: true + +pool: sonicbld + +stages: +- stage: Build + jobs: + - template: azure-pipelines-build.yml + parameters: + buildOptions: 'SONIC_CONFIG_BUILD_JOBS=1 SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web' + postSteps: + - script: | + make freeze + git status files/build/versions + git add files/build/versions + git diff HEAD files/build/versions + displayName: "Show git diff" diff --git a/.azure-pipelines/azure-pipelines-UpgrateVersion.yml b/.azure-pipelines/azure-pipelines-UpgrateVersion.yml new file mode 100644 index 000000000000..172cccab0783 --- /dev/null +++ b/.azure-pipelines/azure-pipelines-UpgrateVersion.yml @@ -0,0 +1,109 @@ +# Starter pipeline +# Start with a minimal pipeline that you can customize to build and deploy your code. +# Add steps that build, run tests, deploy, and more: +# https://aka.ms/yaml + +trigger: none +pr: none + +schedules: +- cron: "0 0 * * *" + displayName: Daily Build + branches: + include: + - 202012 + always: true + +pool: sonicbld + +stages: +- stage: Build + jobs: + - template: azure-pipelines-build.yml + parameters: + buildSlave: y +- stage: UpgradeVersions + jobs: + - job: UpgradeVersions + pool: + vmImage: 'ubuntu-20.04' + steps: + - script: | + if [ -z "$(which gh)" ]; then + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0 + sudo apt-add-repository https://cli.github.com/packages + sudo apt update + sudo apt install gh + fi + displayName: 'Install gh' + - checkout: self + displayName: 'Checkout code' + - download: current + patterns: '**/versions-*' + - script: | + mkdir -p target + default_platform=broadcom + artifacts=$(find $(Pipeline.Workspace) -maxdepth 1 -type d -name 'sonic-buildimage.*' | grep -v "sonic-buildimage.${default_platform}") + echo "artifacts$artifacts" + cp -r $(Pipeline.Workspace)/sonic-buildimage.${default_platform}/versions target/ + make freeze FREEZE_VERSION_OPTIONS=-r + find files/build/versions + for artifact in $artifacts + do + rm -rf target/versions + cp -r $artifact/versions target/ + make freeze FREEZE_VERSION_OPTIONS="-a -d" + done + git diff files/build/versions + displayName: 'Freeze Versions' + - script: | + if [ -z "$GIT_USER" ]; then + echo "Skipped to send the pull request, GIT_USER not set." + exit 0 + fi + GIT_STATUS=$(git status --porcelain files/build/versions) + if [ -z "$GIT_STATUS" ]; then + echo "Skipped to send the pull request, no version change in files/build/versions" + exit 0 + fi + if [ ! -d "$HOME" ]; then + sudo mkdir -p $HOME + sudo chown -R $(id -un):$(id -gn) $HOME + fi + SOURCE_BRANCH=$(Build.SourceBranch) + REPO_NAME=$(Build.Repository.Name) + [ -z "$GIT_REPO" ] && GIT_REPO=${REPO_NAME#*/} + BRANCH_NAME=repd/versions/${SOURCE_BRANCH#refs/heads/} + echo '#!/bin/bash' > git_env_password.sh + echo 'echo $GIT_PASSWORD' >> git_env_password.sh + chmod a+x git_env_password.sh + export GIT_ASKPASS=./git_env_password.sh + + git config user.name $GIT_USER + git config credential.https://github.com.username $GIT_USER + git add files/build/versions + git commit -m "Update SONiC version files" + git checkout -b $BRANCH_NAME + git remote add remote https://github.com/$GIT_USER/$GIT_REPO + git push remote HEAD:refs/heads/$BRANCH_NAME -f + git branch -u remote/$BRANCH_NAME + + echo $GIT_PASSWORD | gh auth login --with-token + TITLE="Upgrade SONiC Versions" + BODY="Upgrade SONiC Versions" + RET=0 + if ! gh pr create -t "$TITLE" -b "$BODY" -B $(Build.SourceBranch) -R $(Build.Repository.Name) > pr.log 2>&1; then + if ! grep -q "already exists" pr.log; then + RET=1 + fi + fi + cat pr.log + exit $RET + env: + GIT_USER: $(GIT_USER) + GIT_PASSWORD: $(GIT_PASSWORD) + displayName: 'Send Pull Request' + - publish: $(System.DefaultWorkingDirectory)/files/build/versions + artifact: 'sonic-buildimage.versions' + displayName: 'Archive SONiC versions' + diff --git a/.azure-pipelines/azure-pipelines-build.yml b/.azure-pipelines/azure-pipelines-build.yml new file mode 100644 index 000000000000..550e2ccd9799 --- /dev/null +++ b/.azure-pipelines/azure-pipelines-build.yml @@ -0,0 +1,72 @@ +parameters: +- name: 'jobFilters' + type: object + default: '' +- name: 'buildOptions' + type: string + default: 'SONIC_CONFIG_BUILD_JOBS=1' +- name: 'buildSlave' + type: string + default: 'n' +- name: 'postSteps' + type: stepList + default: [] + +jobs: +- template: azure-pipelines-job-groups.yml + parameters: + jobFilters: ${{ parameters.jobFilters }} + preSteps: + - script: | + containers=$(docker container ls | grep "sonic-slave" | awk '{ print $1 }') + if [ ! -z "$containers" ]; then + docker container kill $containers || true + sleep 5 + fi + if [ "${{ parameters.buildSlave }}" == "y" ]; then + images=$(docker images 'sonic-slave-*' -a -q) + [ ! -z "$images" ] && docker rmi -f $images + fi + sudo rm -rf $(ls -A1) + displayName: 'Init' + - checkout: self + submodules: recursive + displayName: 'Checkout code' + - script: | + make ${{ parameters.buildOptions }} PLATFORM=$GROUP_NAME configure + displayName: 'Make configure' + postSteps: + - ${{ parameters.postSteps }} + - publish: $(System.DefaultWorkingDirectory)/target + artifact: 'sonic-buildimage.$(GROUP_NAME)$(GROUP_EXTNAME)' + displayName: "Archive sonic image" + jobGroups: + - name: vs + script: | + sudo bash -c "echo 1 > /proc/sys/vm/compact_memory" + make ${{ parameters.buildOptions }} target/sonic-vs.img.gz + - name: broadcom + script: | + make ${{ parameters.buildOptions }} target/sonic-broadcom.bin target/sonic-aboot-broadcom.swi + - name: barefoot + script: | + make ${{ parameters.buildOptions }} target/sonic-barefoot.bin target/sonic-aboot-barefoot.swi + - name: centec + script: | + make ${{ parameters.buildOptions }} INSTALL_DEBUG_TOOLS=y target/sonic-centec.bin + mv target/sonic-centec.bin target/sonic-centec-dbg.bin + make ${{ parameters.buildOptions }} target/sonic-centec.bin + make ${{ parameters.buildOptions }} ENABLE_SYNCD_RPC=y target/docker-syncd-centec-rpc.gz + - name: innovium + script: | + make ${{ parameters.buildOptions }} SONIC_CONFIG_BUILD_JOBS=1 target/sonic-innovium.bin + - name: mellanox + script: | + make ${{ parameters.buildOptions }} target/sonic-mellanox.bin + - name: mellanox + extName: _rpc + script: | + make ${{ parameters.buildOptions }} ENABLE_SYNCD_RPC=y all + - name: nephos + script: | + make ${{ parameters.buildOptions }} target/sonic-nephos.bin diff --git a/.azure-pipelines/azure-pipelines-job-groups.yml b/.azure-pipelines/azure-pipelines-job-groups.yml new file mode 100644 index 000000000000..1ca5c932b0a6 --- /dev/null +++ b/.azure-pipelines/azure-pipelines-job-groups.yml @@ -0,0 +1,53 @@ +parameters: +- name: 'preSteps' + type: stepList + default: [] +- name: "postSteps" + type: stepList + default: [] +- name: 'jobGroups' + type: object + default: [] +- name: 'jobVariables' + type: object + default: {} +- name: 'scriptEnv' + type: object + default: '' +- name: 'timeoutInMinutes' + type: 'number' + default: 1440 +- name: 'jobFilters' + type: object + default: '' + +jobs: +- ${{ each jobGroup in parameters.jobGroups }}: + - ${{ if or(eq(parameters.jobFilters, ''), containsValue(parameters.jobFilters, jobGroup.name)) }}: + - job: ${{ replace(format('{0}{1}', jobGroup.name, jobGroup.extName), '-', '_') }} + ${{ each pair in jobGroup }}: + ${{ if not(in(pair.key, 'job', 'name', 'extName', 'variables', 'steps', 'script', 'scriptEnv')) }}: + ${{ pair.key }}: ${{ pair.value }} + ${{ if eq(jobGroup.timeoutInMinutes, '') }}: + timeoutInMinutes: ${{ parameters.timeoutInMinutes }} + variables: + GROUP_NAME: ${{ jobGroup.name }} + GROUP_EXTNAME: '${{ jobGroup.extName }}' + GROUP_NAMES: ${{ join(',', parameters.jobGroups.*.name ) }} + ${{ if ne(jobGroup.variables, '') }}: + ${{ jobGroup.variables }} + ${{ each para in parameters.jobvariables }}: + ${{ if eq(jobGroup.variables[para.key], '') }}: + ${{ para.key }}: ${{ para.value }} + steps: + - ${{ parameters.preSteps }} + - ${{ if ne(jobGroup.script, '') }}: + - script: | + ${{ jobGroup.script }} + env: + ${{ if ne(parameters.scriptEnv, '') }}: + ${{ parameters.scriptEnv }} + displayName: 'JobScript' + - ${{ if ne(jobGroup.steps, '') }}: + - ${{ jobGroup.steps }} + - ${{ parameters.postSteps }} From e3ab6b0494f5f8f81416ae733c2174f5e617c035 Mon Sep 17 00:00:00 2001 From: dflynn-Nokia <60479697+dflynn-Nokia@users.noreply.github.com> Date: Sun, 14 Feb 2021 13:36:04 -0500 Subject: [PATCH 0217/1674] [armhf build] Fix azure-storage dependency on cryptography package (#6780) Fix marvell-armhf build break The azure-storage package depends on the cryptography package. Newer versions of cryptography require the rust compiler, the correct version for which is not readily available in buster. Hence we pre-install an older version here to satisfy the azure-storage dependency. Note: This is not a problem for other architectures as pre-built versions of cryptography are available for those. This sequence can be removed after upgrading to debian bullseye. --- files/build_templates/sonic_debian_extension.j2 | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index fd5a9735bfaf..e0199db84b99 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -388,12 +388,23 @@ sudo cp $IMAGE_CONFIGS/corefile_uploader/core_analyzer.rc.json $FILESYSTEM_ROOT_ sudo chmod og-rw $FILESYSTEM_ROOT_ETC_SONIC/core_analyzer.rc.json sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install libffi-dev libssl-dev + +if [[ $CONFIGURED_ARCH == armhf ]]; then + # The azure-storage package depends on the cryptography package. Newer + # versions of cryptography require the rust compiler, the correct version + # for which is not readily available in buster. Hence we pre-install an + # older version here to satisfy the azure-storage dependency. + # Note: This is not a problem for other architectures as pre-built versions + # of cryptography are available for those. This sequence can be removed + # after upgrading to debian bullseye. + sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install cryptography==3.3.1 +fi sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install azure-storage==0.36.0 sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install watchdog==0.10.3 {% if include_kubernetes == "y" %} # Install remote Container mgmt package -# Required even if include_kubernetes != y, as it contains the +# Required even if include_kubernetes != y, as it contains the # the container wrapper for docker start/stop/wait commands. # SONIC_CTRMGMT_WHEEL_NAME=$(basename {{sonic_ctrmgmt_py3_wheel_path}}) @@ -417,7 +428,7 @@ sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable ctrmgrd.service # kubelet service is controlled by ctrmgrd daemon. sudo LANG=C chroot $FILESYSTEM_ROOT systemctl disable kubelet.service {% else %} -# container script for docker commands, which is required as +# container script for docker commands, which is required as # all docker commands are replaced with container commands. # So just copy that file only. # From 193fc248a054bfeccb870b230dff6897fb893127 Mon Sep 17 00:00:00 2001 From: mssonicbld <79238446+mssonicbld@users.noreply.github.com> Date: Wed, 3 Mar 2021 19:05:52 +0800 Subject: [PATCH 0218/1674] Update SONiC version files (#6927) Co-authored-by: mssonicbld --- .../build/build-sonic-slave-buster/versions-deb-buster | 1 + .../build/build-sonic-slave-buster/versions-py2 | 2 ++ files/build/versions/default/versions-deb-buster | 8 -------- files/build/versions/default/versions-py2 | 7 ++----- files/build/versions/default/versions-py3 | 10 ++++++---- files/build/versions/default/versions-web | 6 +++--- .../versions/dockers/docker-base-stretch/versions-py2 | 2 +- .../docker-syncd-centec-rpc/versions-deb-buster | 2 ++ .../dockers/docker-syncd-mlnx-rpc/versions-deb-buster | 2 ++ .../versions/dockers/sonic-slave-buster/versions-py3 | 2 +- .../versions/dockers/sonic-slave-stretch/versions-py2 | 2 +- .../versions/dockers/sonic-slave-stretch/versions-py3 | 2 +- files/build/versions/host-image/versions-deb-buster | 8 -------- files/build/versions/host-image/versions-py2 | 7 ++----- files/build/versions/host-image/versions-py3 | 2 ++ 15 files changed, 26 insertions(+), 37 deletions(-) diff --git a/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster b/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster index 3681bae194bf..44be902df6cc 100644 --- a/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster +++ b/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster @@ -91,6 +91,7 @@ python3-yang==1.0.73 sonic-mgmt-common==1.0.0 sonic-mgmt-common-codegen==1.0.0 sonic-mgmt-framework==1.0-01 +swss==1.0.0 sx-acl-helper==1.mlnx.4.4.2308 sx-acl-helper-dev==1.mlnx.4.4.2308 sx-complib==1.mlnx.4.4.2308 diff --git a/files/build/versions/build/build-sonic-slave-buster/versions-py2 b/files/build/versions/build/build-sonic-slave-buster/versions-py2 index 1f5c68c822d7..b740e4ebeb83 100644 --- a/files/build/versions/build/build-sonic-slave-buster/versions-py2 +++ b/files/build/versions/build/build-sonic-slave-buster/versions-py2 @@ -1,8 +1,10 @@ bitarray==1.5.3 contextlib2==0.6.0.post1 +functools32==3.2.3.post2 future==0.18.2 importlib-resources==3.3.1 ipaddress==1.0.23 +jsonschema==2.6.0 natsort==6.2.1 netaddr==0.8.0 pyangbind==0.6.0 diff --git a/files/build/versions/default/versions-deb-buster b/files/build/versions/default/versions-deb-buster index 0ac1d545ff28..6a82e67ada8c 100644 --- a/files/build/versions/default/versions-deb-buster +++ b/files/build/versions/default/versions-deb-buster @@ -174,15 +174,7 @@ perl-modules-5.28==5.28.1-6+deb10u1 procps==2:3.3.15-2 psample==1.1-1 python==2.7.16-1 -python-funcsigs==1.0.2-4 -python-functools32==3.2.3.2-3 -python-jsonschema==2.6.0-4 python-minimal==2.7.16-1 -python-mock==2.0.0-4 -python-pbr==4.2.0-5 -python-pkg-resources==40.8.0-1 -python-setuptools==40.8.0-1 -python-six==1.12.0-1 python-smbus==4.1-1 python-swsscommon==1.0.0 python2==2.7.16-1 diff --git a/files/build/versions/default/versions-py2 b/files/build/versions/default/versions-py2 index 722c73af5c7d..6f9cf7f55055 100644 --- a/files/build/versions/default/versions-py2 +++ b/files/build/versions/default/versions-py2 @@ -1,7 +1,6 @@ bitarray==1.5.3 contextlib2==0.6.0.post1 enum34==1.1.10 -funcsigs==1.0.2 functools32==3.2.3.post2 future==0.18.2 importlib-resources==3.3.1 @@ -10,19 +9,17 @@ Jinja2==2.11.3 jsonschema==2.6.0 lxml==4.6.2 MarkupSafe==1.1.1 -mock==2.0.0 natsort==6.2.1 netaddr==0.8.0 pathlib2==2.3.5 -pbr==4.2.0 pyang==2.4.0 pyangbind==0.6.0 PyYAML==5.4.1 redis==3.5.3 redis-dump-load==1.1 scandir==1.10.0 -singledispatch==3.6.0 -six==1.12.0 +singledispatch==3.6.1 +six==1.15.0 thrift==0.13.0 typing==3.7.4.3 zipp==1.2.0 \ No newline at end of file diff --git a/files/build/versions/default/versions-py3 b/files/build/versions/default/versions-py3 index 0c5748ac896a..b00f6be0ec4c 100644 --- a/files/build/versions/default/versions-py3 +++ b/files/build/versions/default/versions-py3 @@ -6,13 +6,14 @@ click==7.1.2 clickclick==20.10.2 connexion==2.7.0 Flask==1.1.2 -grpcio==1.35.0 +grpcio==1.36.0 grpcio-tools==1.20.0 hiredis==1.1.0 idna==2.10 -importlib-metadata==3.4.0 +importlib-metadata==3.7.0 inflection==0.5.1 ipaddress==1.0.23 +isodate==0.6.0 itsdangerous==1.1.0 j2cli==0.3.10 Jinja2==2.11.3 @@ -22,8 +23,9 @@ MarkupSafe==1.1.1 natsort==6.2.1 netaddr==0.8.0 netifaces==0.10.9 -openapi-spec-validator==0.2.9 -protobuf==3.15.1 +openapi-schema-validator==0.1.4 +openapi-spec-validator==0.3.0 +protobuf==3.15.3 psutil==5.8.0 pyang==2.4.0 pyangbind==0.8.1 diff --git a/files/build/versions/default/versions-web b/files/build/versions/default/versions-web index b0a9be7c03a7..38cd555295ad 100644 --- a/files/build/versions/default/versions-web +++ b/files/build/versions/default/versions-web @@ -12,11 +12,11 @@ http://http.debian.net/debian/pool/main/h/hiredis/hiredis_0.14.0-3~bpo9+1.debian http://http.debian.net/debian/pool/main/h/hiredis/hiredis_0.14.0-3~bpo9+1.dsc==be4ce11ef67268e59e4b6be587327c40 http://http.debian.net/debian/pool/main/h/hiredis/hiredis_0.14.0.orig.tar.gz==6d565680a4af0d2e261abbc3e3431b2b http://www.mellanox.com/downloads/MFT/mft-4.15.3-3-x86_64-deb.tgz==21caa3657b4100da3d08cf47961edc6f -https://chrome-infra-packages.appspot.com/client?platform=linux-amd64&version=git_revision:61ac72e84956112656e2500701dd252c5d92f6e6==314a78da036bd5b54637cd17c54ccfd9 +https://chrome-infra-packages.appspot.com/client?platform=linux-amd64&version=git_revision:e75c9bf286fbb31347379cb478df2a556ab185b1==9df7a96a4a4fb6e484027d80b3ee821c https://download.docker.com/linux/debian/gpg==1afae06b34a13c1b3d9cb61a26285a15 https://github.com/aristanetworks/sonic-firmware/raw/78a3df2/phy/phy-credo_1.0_amd64.deb==f0d5b5efa18cf775cdc3fccaba7ac181 -https://github.com/barefootnetworks/sonic-release-pkgs/raw/dev/bfnplatform_20201228_deb10.deb==d4045769acf8abd2ff176ff7e659cc69 -https://github.com/barefootnetworks/sonic-release-pkgs/raw/dev/bfnsdk_20201228_deb10.deb==b59589104e5189b1f598b8c46d3d6c8a +https://github.com/barefootnetworks/sonic-release-pkgs/raw/dev/bfnplatform_20210219_deb10.deb==4bd3f9c10d159d6d32e984c1de5a569c +https://github.com/barefootnetworks/sonic-release-pkgs/raw/dev/bfnsdk_20210219_deb10.deb==57e0b2f6a8412de63e307105571b7ed2 https://github.com/CentecNetworks/sonic-binaries/raw/master/amd64/libsai_1.6.3-1_amd64.deb==e7a41e5cf06b44ae3ed615d553de40d3 https://github.com/CumulusNetworks/ifupdown2/archive/1.2.8-1.tar.gz==12f45e90d23178e96cf70f68dc9455e6 https://github.com/Innovium/SONiC/raw/master/debian/master/ipd.deb==a0f512aba05180b15c2f6b5809b9d5c1 diff --git a/files/build/versions/dockers/docker-base-stretch/versions-py2 b/files/build/versions/dockers/docker-base-stretch/versions-py2 index 54e22f62fbab..e95c173112e9 100644 --- a/files/build/versions/dockers/docker-base-stretch/versions-py2 +++ b/files/build/versions/dockers/docker-base-stretch/versions-py2 @@ -1,4 +1,4 @@ j2cli==0.3.10 -supervisor==4.2.1 +supervisor==4.2.2 supervisord-dependent-startup==1.4.0 toposort==1.6 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-centec-rpc/versions-deb-buster b/files/build/versions/dockers/docker-syncd-centec-rpc/versions-deb-buster index e29438991e1b..1f61b36d3891 100644 --- a/files/build/versions/dockers/docker-syncd-centec-rpc/versions-deb-buster +++ b/files/build/versions/dockers/docker-syncd-centec-rpc/versions-deb-buster @@ -50,8 +50,10 @@ patch==2.7.6-3+deb10u1 python-dev==2.7.16-1 python-pip==18.1-5 python-pip-whl==18.1-5 +python-pkg-resources==40.8.0-1 python-ptf==0.9-1 python-scapy==2.4.0-2 +python-setuptools==40.8.0-1 python2-dev==2.7.16-1 python2.7-dev==2.7.16-2+deb10u1 syncd-rpc==1.0.0 diff --git a/files/build/versions/dockers/docker-syncd-mlnx-rpc/versions-deb-buster b/files/build/versions/dockers/docker-syncd-mlnx-rpc/versions-deb-buster index e29438991e1b..1f61b36d3891 100644 --- a/files/build/versions/dockers/docker-syncd-mlnx-rpc/versions-deb-buster +++ b/files/build/versions/dockers/docker-syncd-mlnx-rpc/versions-deb-buster @@ -50,8 +50,10 @@ patch==2.7.6-3+deb10u1 python-dev==2.7.16-1 python-pip==18.1-5 python-pip-whl==18.1-5 +python-pkg-resources==40.8.0-1 python-ptf==0.9-1 python-scapy==2.4.0-2 +python-setuptools==40.8.0-1 python2-dev==2.7.16-1 python2.7-dev==2.7.16-2+deb10u1 syncd-rpc==1.0.0 diff --git a/files/build/versions/dockers/sonic-slave-buster/versions-py3 b/files/build/versions/dockers/sonic-slave-buster/versions-py3 index 891ccaee5773..4288fd5abc41 100644 --- a/files/build/versions/dockers/sonic-slave-buster/versions-py3 +++ b/files/build/versions/dockers/sonic-slave-buster/versions-py3 @@ -3,7 +3,7 @@ asn1crypto==0.24.0 atomicwrites==1.1.5 attrs==18.2.0 Babel==2.6.0 -bitarray==1.6.3 +bitarray==1.7.0 certifi==2018.8.24 chardet==3.0.4 cov-core==1.15.0 diff --git a/files/build/versions/dockers/sonic-slave-stretch/versions-py2 b/files/build/versions/dockers/sonic-slave-stretch/versions-py2 index 2e3b1f405aa4..6588cc6c920d 100644 --- a/files/build/versions/dockers/sonic-slave-stretch/versions-py2 +++ b/files/build/versions/dockers/sonic-slave-stretch/versions-py2 @@ -33,7 +33,7 @@ lazy-object-proxy==1.2.2 lxml==4.6.2 M2Crypto==0.36.0 MarkupSafe==1.1.1 -mmh3==2.5.1 +mmh3==3.0.0 mockredispy==2.9.3 nose2==0.6.5 PAM==0.4.2 diff --git a/files/build/versions/dockers/sonic-slave-stretch/versions-py3 b/files/build/versions/dockers/sonic-slave-stretch/versions-py3 index 7b9cc6ebd6ad..b23a75b0d3f8 100644 --- a/files/build/versions/dockers/sonic-slave-stretch/versions-py3 +++ b/files/build/versions/dockers/sonic-slave-stretch/versions-py3 @@ -1,6 +1,6 @@ alabaster==0.7.8 Babel==2.3.4 -bitarray==1.6.3 +bitarray==1.7.0 chardet==2.3.0 cryptography==1.7.1 devscripts==2.17.6+deb9u2 diff --git a/files/build/versions/host-image/versions-deb-buster b/files/build/versions/host-image/versions-deb-buster index e99804d35b45..01cb7447bb94 100644 --- a/files/build/versions/host-image/versions-deb-buster +++ b/files/build/versions/host-image/versions-deb-buster @@ -218,17 +218,9 @@ python-apt-common==1.8.4.3 python-argcomplete==1.8.1-1 python-bottle==0.12.15-2+deb10u1 python-enum34==1.1.6-2 -python-funcsigs==1.0.2-4 -python-functools32==3.2.3.2-3 python-ipaddr==2.2.0-2 -python-jsonschema==2.6.0-4 python-minimal==2.7.16-1 -python-mock==2.0.0-4 -python-pbr==4.2.0-5 -python-pkg-resources==40.8.0-1 python-scapy==2.4.0-2 -python-setuptools==40.8.0-1 -python-six==1.12.0-1 python-smbus==4.1-1 python-sonic-platform-arista==1.0 python-swsscommon==1.0.0 diff --git a/files/build/versions/host-image/versions-py2 b/files/build/versions/host-image/versions-py2 index ad64a2a881b0..1359a2472dc6 100644 --- a/files/build/versions/host-image/versions-py2 +++ b/files/build/versions/host-image/versions-py2 @@ -3,7 +3,6 @@ bitarray==1.5.3 bottle==0.12.15 contextlib2==0.6.0.post1 enum34==1.1.6 -funcsigs==1.0.2 functools32==3.2.3.post2 future==0.18.2 importlib-resources==3.3.1 @@ -13,11 +12,9 @@ Jinja2==2.11.3 jsonschema==2.6.0 lxml==4.6.2 MarkupSafe==1.1.1 -mock==2.0.0 natsort==6.2.1 netaddr==0.8.0 pathlib2==2.3.5 -pbr==4.2.0 platform-arista==1.0 pyang==2.4.0 pyangbind==0.6.0 @@ -26,8 +23,8 @@ PyYAML==5.4.1 redis==3.5.3 scandir==1.10.0 scapy==2.4.0 -singledispatch==3.6.0 -six==1.12.0 +singledispatch==3.6.1 +six==1.15.0 thrift==0.13.0 typing==3.7.4.3 zipp==1.2.0 \ No newline at end of file diff --git a/files/build/versions/host-image/versions-py3 b/files/build/versions/host-image/versions-py3 index 502409926941..661e6c171995 100644 --- a/files/build/versions/host-image/versions-py3 +++ b/files/build/versions/host-image/versions-py3 @@ -14,6 +14,7 @@ ijson==2.6.1 ipaddress==1.0.23 Jinja2==2.11.3 jsondiff==1.2.0 +jsonschema==2.6.0 lxml==4.6.2 M2Crypto==0.31.0 MarkupSafe==1.1.1 @@ -33,6 +34,7 @@ PyYAML==5.4.1 redis==3.5.3 regex==2020.11.13 requests==2.25.0 +scapy==2.4.4 six==1.15.0 tabulate==0.8.2 thrift==0.13.0 From 5afaf2fe80a92bf8c27d28af26e8b1515472abb3 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Wed, 3 Mar 2021 07:44:43 -0800 Subject: [PATCH 0219/1674] [202012][swss][utils] advance submodule head (#6950) swss: * 9376ec6 2021-02-22 | [orchagent] Increase SAI REDIS response timeout to support FW upgrade during init (Mellanox only). (#1637) (HEAD -> 202012) [Lior Avramov] * 6c285f6 2021-02-22 | Updated PFCWD to use single ACL table for PFCWD and MUX (#1620) [vmittal-msft] utilities: * d2f0e8f 2021-02-24 | [route_check]: Dropped redundant code. (#1463) (HEAD -> 202012, github/202012) [Renuka Manavalan] * 9aaef9b 2021-02-25 | [Mellanox] Add support for SN4600 system (#1462) [DavidZagury] * 60843dd 2021-03-01 | [reboot] Add platform-specific reboot cause update hook (#1454) [rkdevi27] * d9c308c 2021-02-24 | [vlan] Vlan deletion is not allowed when there are members assigned to this VLAN. (#1420) [Eran Dahan] * a72165a 2021-02-25 | [psushow] Add more output columns; Add option to output in JSON format (#1416) [Joe LeVeque] Signed-off-by: Ying Xie --- src/sonic-swss | 2 +- src/sonic-utilities | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sonic-swss b/src/sonic-swss index 459d09b791db..9376ec694925 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit 459d09b791db1bced2e7dc221d47e66f7d706dd0 +Subproject commit 9376ec694925c5cd715870e48a5aec7c8060c8a8 diff --git a/src/sonic-utilities b/src/sonic-utilities index 30d70691b379..d2f0e8fdd74b 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit 30d70691b379f5e68e572fbc69f2d0db32e8c19c +Subproject commit d2f0e8fdd74b21700d535843ca30c12d448bd04d From 38a013939aad82f803d3d0ffbd65d29fd8be5f08 Mon Sep 17 00:00:00 2001 From: Junchao-Mellanox <57339448+Junchao-Mellanox@users.noreply.github.com> Date: Thu, 4 Mar 2021 06:25:02 +0800 Subject: [PATCH 0220/1674] [submodule][202012]: Update submodule pointer for snmpagent (#6954) 183162f Fix issue: expect redis pubsub data to be str type instead of bytes type (#196) #### Why I did it Update submoduel for snmpagent for 202012 branch since there is not 202012 branch for snmpagent #### How I did it Update submodule pointer #### How to verify it Run build --- src/sonic-snmpagent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-snmpagent b/src/sonic-snmpagent index 3885f193be05..183162fcc468 160000 --- a/src/sonic-snmpagent +++ b/src/sonic-snmpagent @@ -1 +1 @@ -Subproject commit 3885f193be05099659808092d22c5f69407cdda4 +Subproject commit 183162fcc468b3af774be2353b84bdf0b8365b46 From 9b570cb04d48d4cef665c9547cd3fb4a115cf234 Mon Sep 17 00:00:00 2001 From: vmittal-msft <46945843+vmittal-msft@users.noreply.github.com> Date: Wed, 3 Mar 2021 09:07:53 -0800 Subject: [PATCH 0221/1674] Updated BCM SAI to latest 4.3.3.1 drop (#6947) --- platform/broadcom/sai.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index 046aca2af658..41e028ee2e1d 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,8 +1,8 @@ -BRCM_SAI = libsaibcm_4.3.0.13-1_amd64.deb -$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.0.13-1_amd64.deb?sv=2015-04-05&sr=b&sig=e%2BBucofzEwCC%2BclqK1OeCi5YFpQAD4ID4FfODzszsuM%3D&se=2034-10-22T06%3A00%3A14Z&sp=r" -BRCM_SAI_DEV = libsaibcm-dev_4.3.0.13-1_amd64.deb +BRCM_SAI = libsaibcm_4.3.3.1_amd64.deb +$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.3.1_amd64.deb?sv=2019-12-12&st=2021-03-03T00%3A35%3A37Z&se=2030-03-04T00%3A35%3A00Z&sr=b&sp=r&sig=1miXMYs0%2BZ6v9Dpby1vSYsDezWDnr%2Be4gZ7Gi3kAQXE%3D" +BRCM_SAI_DEV = libsaibcm-dev_4.3.3.1_amd64.deb $(eval $(call add_derived_package,$(BRCM_SAI),$(BRCM_SAI_DEV))) -$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.0.13-1_amd64.deb?sv=2015-04-05&sr=b&sig=twfshldM6GQEphfU%2BQ4xmJlGJkv2Sy7KU1F72RYYM0A%3D&se=2034-10-22T06%3A00%3A45Z&sp=r" +$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.3.1_amd64.deb?sv=2019-12-12&st=2021-03-03T00%3A37%3A16Z&se=2030-03-04T00%3A37%3A00Z&sr=b&sp=r&sig=xxnhJC%2FKsOvApuAlB1Yds8Uzzkdyy6fmWX%2BuJ4v0UYA%3D" SONIC_ONLINE_DEBS += $(BRCM_SAI) $(BRCM_SAI_DEV)_DEPENDS += $(BRCM_SAI) From 097430e66fb93cd52f590d2a006c2640094bd68b Mon Sep 17 00:00:00 2001 From: Srideep Date: Mon, 1 Mar 2021 09:53:35 -0800 Subject: [PATCH 0222/1674] [DellEMC:Z9332f] Modify SKU-DellEMC-Z9332f-M-O16C64 to support different port-config (#6906) --- .../DellEMC-Z9332f-M-O16C64/port_config.ini | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-M-O16C64/port_config.ini b/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-M-O16C64/port_config.ini index 542992d761a6..101780149b57 100644 --- a/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-M-O16C64/port_config.ini +++ b/device/dell/x86_64-dellemc_z9332f_d1508-r0/DellEMC-Z9332f-M-O16C64/port_config.ini @@ -15,10 +15,22 @@ Ethernet24 57,58 hundredGigE1/4/1 4 1 Ethernet26 59,60 hundredGigE1/4/2 4 100000 Ethernet28 61,62 hundredGigE1/4/3 4 100000 Ethernet30 63,64 hundredGigE1/4/4 4 100000 -Ethernet32 65,66,67,68,69,70,71,72 fourhundredGigE1/5 5 400000 -Ethernet40 73,74,75,76,77,78,79,80 fourhundredGigE1/6 6 400000 -Ethernet48 81,82,83,84,85,86,87,88 fourhundredGigE1/7 7 400000 -Ethernet56 89,90,91,92,93,94,95,96 fourhundredGigE1/8 8 400000 +Ethernet32 65,66 hundredGigE1/5/1 5 100000 +Ethernet34 67,68 hundredGigE1/5/2 5 100000 +Ethernet36 69,70 hundredGigE1/5/3 5 100000 +Ethernet38 71,72 hundredGigE1/5/4 5 100000 +Ethernet40 73,74 hundredGigE1/6/1 6 100000 +Ethernet42 75,76 hundredGigE1/6/2 6 100000 +Ethernet44 77,78 hundredGigE1/6/3 6 100000 +Ethernet46 79,80 hundredGigE1/6/4 6 100000 +Ethernet48 81,82 hundredGigE1/7/1 7 100000 +Ethernet50 83,84 hundredGigE1/7/2 7 100000 +Ethernet52 85,86 hundredGigE1/7/3 7 100000 +Ethernet54 87,88 hundredGigE1/7/4 7 100000 +Ethernet56 89,90 hundredGigE1/8/1 8 100000 +Ethernet58 91,92 hundredGigE1/8/2 8 100000 +Ethernet60 93,94 hundredGigE1/8/3 8 100000 +Ethernet62 95,96 hundredGigE1/8/4 8 100000 Ethernet64 1,2 hundredGigE1/9/1 9 100000 Ethernet66 3,4 hundredGigE1/9/2 9 100000 Ethernet68 5,6 hundredGigE1/9/3 9 100000 @@ -39,45 +51,33 @@ Ethernet96 97,98,99,100,101,102,103,104 fourhundredGigE1/13 13 4 Ethernet104 105,106,107,108,109,110,111,112 fourhundredGigE1/14 14 400000 Ethernet112 113,114,115,116,117,118,119,120 fourhundredGigE1/15 15 400000 Ethernet120 121,122,123,124,125,126,127,128 fourhundredGigE1/16 16 400000 -Ethernet128 129,130,131,132,133,134,135,136 fourhundredGigE1/17 17 400000 -Ethernet136 137,138,139,140,141,142,143,144 fourhundredGigE1/18 18 400000 -Ethernet144 145,146,147,148,149,150,151,152 fourhundredGigE1/19 19 400000 -Ethernet152 153,154,155,156,157,158,159,160 fourhundredGigE1/20 20 400000 -Ethernet160 225,226 hundredGigE1/21/1 21 100000 -Ethernet162 227,228 hundredGigE1/21/2 21 100000 -Ethernet164 229,230 hundredGigE1/21/3 21 100000 -Ethernet166 231,232 hundredGigE1/21/4 21 100000 -Ethernet168 233,234 hundredGigE1/22/1 22 100000 -Ethernet170 235,236 hundredGigE1/22/2 22 100000 -Ethernet172 237,238 hundredGigE1/22/3 22 100000 -Ethernet174 239,240 hundredGigE1/22/4 22 100000 -Ethernet176 241,242 hundredGigE1/23/1 23 100000 -Ethernet178 243,244 hundredGigE1/23/2 23 100000 -Ethernet180 245,246 hundredGigE1/23/3 23 100000 -Ethernet182 247,248 hundredGigE1/23/4 23 100000 -Ethernet184 249,250 hundredGigE1/24/1 24 100000 -Ethernet186 251,252 hundredGigE1/24/2 24 100000 -Ethernet188 253,254 hundredGigE1/24/3 24 100000 -Ethernet190 255,256 hundredGigE1/24/4 24 100000 +Ethernet128 129,130 hundredGigE1/17/1 17 100000 +Ethernet130 131,132 hundredGigE1/17/2 17 100000 +Ethernet132 133,134 hundredGigE1/17/3 17 100000 +Ethernet134 135,136 hundredGigE1/17/4 17 100000 +Ethernet136 137,138 hundredGigE1/18/1 18 100000 +Ethernet138 139,140 hundredGigE1/18/2 18 100000 +Ethernet140 141,142 hundredGigE1/18/3 18 100000 +Ethernet142 143,144 hundredGigE1/18/4 18 100000 +Ethernet144 145,146 hundredGigE1/19/1 19 100000 +Ethernet146 147,148 hundredGigE1/19/2 19 100000 +Ethernet148 149,150 hundredGigE1/19/3 19 100000 +Ethernet150 151,152 hundredGigE1/19/4 19 100000 +Ethernet152 153,154 hundredGigE1/20/1 20 100000 +Ethernet154 155,156 hundredGigE1/20/2 20 100000 +Ethernet156 157,158 hundredGigE1/20/3 20 100000 +Ethernet158 159,160 hundredGigE1/20/4 20 100000 +Ethernet160 225,226,227,228,229,230,231,232 fourhundredGigE1/21 21 400000 +Ethernet168 233,234,235,236,237,238,239,240 fourhundredGigE1/22 22 400000 +Ethernet176 241,242,243,244,245,246,247,248 fourhundredGigE1/23 23 400000 +Ethernet184 249,250,251,252,253,254,255,256 fourhundredGigE1/24 24 400000 Ethernet192 161,162,163,164,165,166,167,168 fourhundredGigE1/25 25 400000 Ethernet200 169,170,171,172,173,174,175,176 fourhundredGigE1/26 26 400000 Ethernet208 177,178,179,180,181,182,183,184 fourhundredGigE1/27 27 400000 Ethernet216 185,186,187,188,189,190,191,192 fourhundredGigE1/28 28 400000 -Ethernet224 193,194 hundredGigE1/29/1 29 100000 -Ethernet226 195,196 hundredGigE1/29/2 29 100000 -Ethernet228 197,198 hundredGigE1/29/3 29 100000 -Ethernet230 199,200 hundredGigE1/29/4 29 100000 -Ethernet232 201,202 hundredGigE1/30/1 30 100000 -Ethernet234 203,204 hundredGigE1/30/2 30 100000 -Ethernet236 205,206 hundredGigE1/30/3 30 100000 -Ethernet238 207,208 hundredGigE1/30/4 30 100000 -Ethernet240 209,210 hundredGigE1/31/1 31 100000 -Ethernet242 211,212 hundredGigE1/31/2 31 100000 -Ethernet244 213,214 hundredGigE1/31/3 31 100000 -Ethernet246 215,216 hundredGigE1/31/4 31 100000 -Ethernet248 217,218 hundredGigE1/32/1 32 100000 -Ethernet250 219,220 hundredGigE1/32/2 32 100000 -Ethernet252 221,222 hundredGigE1/32/3 32 100000 -Ethernet254 223,224 hundredGigE1/32/4 32 100000 +Ethernet224 193,194,195,196,197,198,199,200 fourhundredGigE1/29 29 400000 +Ethernet232 201,202,203,204,205,206,207,208 fourhundredGigE1/30 30 400000 +Ethernet240 209,210,211,212,213,214,215,216 fourhundredGigE1/31 31 400000 +Ethernet248 217,218,219,220,221,222,223,224 fourhundredGigE1/32 32 400000 Ethernet256 257 tenGigE1/33 33 10000 Ethernet257 258 tenGigE1/34 34 10000 From e7356da98631d27d86635d885065d0af75497af1 Mon Sep 17 00:00:00 2001 From: pra-moh <49077256+pra-moh@users.noreply.github.com> Date: Wed, 24 Feb 2021 17:22:54 -0800 Subject: [PATCH 0223/1674] [submodule]: update telemetry submodule (#6810) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Adding instructions to build telemetry server/go client inside docker (#68) - Add RBAC, gNOI, API Versioning and Bulk Set operations. (#61) … - Support NonTLS option for testing purpose only. (#67) … - Oc gnmi examples (#62) … --- src/sonic-telemetry | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-telemetry b/src/sonic-telemetry index 9ceb58ca1f93..7cd86c5a6bc3 160000 --- a/src/sonic-telemetry +++ b/src/sonic-telemetry @@ -1 +1 @@ -Subproject commit 9ceb58ca1f93c266b0ef2723d99696d14f4b0b20 +Subproject commit 7cd86c5a6bc38b94f0d7e87c9c278b9d20779a2b From 7fb5a72d2334cbce2735410f8bd52247bf2f17fb Mon Sep 17 00:00:00 2001 From: Stepan Blyshchak <38952541+stepanblyschak@users.noreply.github.com> Date: Thu, 25 Feb 2021 14:26:24 +0200 Subject: [PATCH 0224/1674] [services] introduce sonic.target (#5705) - Why I did it Group all SONiC services together and able to manage them together. Will be used in config reload command as much simpler and generic way to restart services. - How I did it Add services to sonic.target - How to verify it Together with Azure/sonic-utilities#1199 config reload -y Signed-off-by: Stepan Blyshchak --- files/build_templates/dhcp_relay.service.j2 | 4 +++- files/build_templates/gbsyncd.service.j2 | 4 +++- files/build_templates/iccpd.service.j2 | 4 +++- files/build_templates/mgmt-framework.service.j2 | 3 ++- files/build_templates/mgmt-framework.timer | 4 +++- files/build_templates/nat.service.j2 | 4 +++- files/build_templates/per_namespace/bgp.service.j2 | 4 +++- files/build_templates/per_namespace/lldp.service.j2 | 6 +++++- files/build_templates/per_namespace/swss.service.j2 | 4 +++- files/build_templates/per_namespace/syncd.service.j2 | 4 +++- files/build_templates/per_namespace/teamd.service.j2 | 4 +++- files/build_templates/pmon.service.j2 | 4 +++- files/build_templates/radv.service.j2 | 4 +++- files/build_templates/restapi.service.j2 | 4 +++- files/build_templates/sflow.service.j2 | 4 +++- files/build_templates/snmp.service.j2 | 4 ++-- files/build_templates/snmp.timer | 2 +- files/build_templates/sonic.target | 5 +++++ files/build_templates/sonic_debian_extension.j2 | 3 +++ files/build_templates/telemetry.service.j2 | 3 ++- files/build_templates/telemetry.timer | 4 +++- files/image_config/hostname/hostname-config.service | 5 ++++- files/image_config/interfaces/interfaces-config.service | 5 ++++- files/image_config/ntp/ntp-config.service | 5 ++++- files/image_config/ntp/ntp.service | 2 ++ files/image_config/rsyslog/rsyslog-config.service | 5 ++++- .../debian/sonic-host-services-data.caclmgrd.service | 4 +++- .../debian/sonic-host-services-data.hostcfgd.service | 5 ++++- .../sonic-host-services-data.procdockerstatsd.service | 5 +++-- 29 files changed, 90 insertions(+), 28 deletions(-) create mode 100644 files/build_templates/sonic.target diff --git a/files/build_templates/dhcp_relay.service.j2 b/files/build_templates/dhcp_relay.service.j2 index d501a663feba..b7b590a1036a 100644 --- a/files/build_templates/dhcp_relay.service.j2 +++ b/files/build_templates/dhcp_relay.service.j2 @@ -2,6 +2,8 @@ Description=DHCP relay container Requires=updategraph.service After=updategraph.service swss.service syncd.service teamd.service +BindsTo=sonic.target +After=sonic.target Before=ntp-config.service StartLimitIntervalSec=1200 StartLimitBurst=3 @@ -15,4 +17,4 @@ Restart=always RestartSec=30 [Install] -WantedBy=multi-user.target +WantedBy=sonic.target diff --git a/files/build_templates/gbsyncd.service.j2 b/files/build_templates/gbsyncd.service.j2 index e1080ae7d526..b33dfea6b00d 100644 --- a/files/build_templates/gbsyncd.service.j2 +++ b/files/build_templates/gbsyncd.service.j2 @@ -5,6 +5,8 @@ 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] @@ -15,4 +17,4 @@ ExecStart=/usr/local/bin/gbsyncd.sh wait ExecStop=/usr/local/bin/gbsyncd.sh stop [Install] -WantedBy=multi-user.target +WantedBy=sonic.target diff --git a/files/build_templates/iccpd.service.j2 b/files/build_templates/iccpd.service.j2 index 979c45de72c5..d78407a87be3 100644 --- a/files/build_templates/iccpd.service.j2 +++ b/files/build_templates/iccpd.service.j2 @@ -2,6 +2,8 @@ Description=ICCPD container Requires=updategraph.service swss.service After=updategraph.service swss.service +BindsTo=sonic.target +After=sonic.target [Service] User={{ sonicadmin_user }} @@ -10,4 +12,4 @@ ExecStart=/usr/bin/{{docker_container_name}}.sh wait ExecStop=/usr/bin/{{docker_container_name}}.sh stop [Install] -WantedBy=multi-user.target swss.service +WantedBy=sonic.target swss.service diff --git a/files/build_templates/mgmt-framework.service.j2 b/files/build_templates/mgmt-framework.service.j2 index 883711aa82eb..1eb983a897fb 100644 --- a/files/build_templates/mgmt-framework.service.j2 +++ b/files/build_templates/mgmt-framework.service.j2 @@ -2,6 +2,8 @@ Description=Management Framework container Requires=database.service After=database.service swss.service syncd.service +BindsTo=sonic.target +After=sonic.target Before=ntp-config.service [Service] @@ -9,4 +11,3 @@ User={{ sonicadmin_user }} ExecStartPre=/usr/bin/{{docker_container_name}}.sh start ExecStart=/usr/bin/{{docker_container_name}}.sh wait ExecStop=/usr/bin/{{docker_container_name}}.sh stop - diff --git a/files/build_templates/mgmt-framework.timer b/files/build_templates/mgmt-framework.timer index 62ab8ef1bd58..37389fbc6db5 100644 --- a/files/build_templates/mgmt-framework.timer +++ b/files/build_templates/mgmt-framework.timer @@ -1,9 +1,11 @@ [Unit] Description=Delays management framework container until SONiC has started +PartOf=mgmt-framework.service [Timer] +OnUnitActiveSec=0 sec OnBootSec=3min 30 sec Unit=mgmt-framework.service [Install] -WantedBy=timers.target +WantedBy=timers.target sonic.target diff --git a/files/build_templates/nat.service.j2 b/files/build_templates/nat.service.j2 index 1d267cfe9302..10dc7cadf18c 100644 --- a/files/build_templates/nat.service.j2 +++ b/files/build_templates/nat.service.j2 @@ -2,6 +2,8 @@ Description=NAT container Requires=updategraph.service After=updategraph.service swss.service syncd.service +BindsTo=sonic.target +After=sonic.target Before=ntp-config.service StartLimitIntervalSec=1200 StartLimitBurst=3 @@ -15,5 +17,5 @@ Restart=always RestartSec=30 [Install] -WantedBy=multi-user.target +WantedBy=sonic.target diff --git a/files/build_templates/per_namespace/bgp.service.j2 b/files/build_templates/per_namespace/bgp.service.j2 index 9f3c72e20db5..5ba49ffc441a 100644 --- a/files/build_templates/per_namespace/bgp.service.j2 +++ b/files/build_templates/per_namespace/bgp.service.j2 @@ -4,6 +4,8 @@ Requires=database{% if multi_instance == 'true' %}@%i{% endif %}.service After=database{% if multi_instance == 'true' %}@%i{% endif %}.service Requires=updategraph.service After=updategraph.service +BindsTo=sonic.target +After=sonic.target Before=ntp-config.service StartLimitIntervalSec=1200 StartLimitBurst=3 @@ -18,4 +20,4 @@ Restart=always RestartSec=30 [Install] -WantedBy=multi-user.target +WantedBy=sonic.target diff --git a/files/build_templates/per_namespace/lldp.service.j2 b/files/build_templates/per_namespace/lldp.service.j2 index b48675b03202..fca84462934b 100644 --- a/files/build_templates/per_namespace/lldp.service.j2 +++ b/files/build_templates/per_namespace/lldp.service.j2 @@ -6,6 +6,10 @@ After=swss{% if multi_instance == 'true' %}@%i{% endif %}.service After=syncd{% if multi_instance == 'true' %}@%i{% endif %}.service Requires=updategraph.service After=updategraph.service +BindsTo=sonic.target +After=sonic.target +BindsTo=sonic.target +After=sonic.target Before=ntp-config.service StartLimitIntervalSec=1200 StartLimitBurst=3 @@ -19,4 +23,4 @@ Restart=always RestartSec=30 [Install] -WantedBy=multi-user.target +WantedBy=sonic.target diff --git a/files/build_templates/per_namespace/swss.service.j2 b/files/build_templates/per_namespace/swss.service.j2 index 8ac19037ffe7..5fb86929d3ba 100644 --- a/files/build_templates/per_namespace/swss.service.j2 +++ b/files/build_templates/per_namespace/swss.service.j2 @@ -12,6 +12,8 @@ Requires=opennsl-modules.service Requires=updategraph.service After=updategraph.service After=interfaces-config.service +BindsTo=sonic.target +After=sonic.target Before=ntp-config.service pmon.service StartLimitIntervalSec=1200 StartLimitBurst=3 @@ -26,4 +28,4 @@ Restart=always RestartSec=30 [Install] -WantedBy=multi-user.target +WantedBy=sonic.target diff --git a/files/build_templates/per_namespace/syncd.service.j2 b/files/build_templates/per_namespace/syncd.service.j2 index 8e0029a29421..9acf97c29fd4 100644 --- a/files/build_templates/per_namespace/syncd.service.j2 +++ b/files/build_templates/per_namespace/syncd.service.j2 @@ -17,6 +17,8 @@ After=nps-modules.service Requires=updategraph.service After=updategraph.service After=interfaces-config.service +BindsTo=sonic.target +After=sonic.target Before=ntp-config.service [Service] @@ -30,4 +32,4 @@ TimeoutStartSec=480 {% endif %} [Install] -WantedBy=multi-user.target +WantedBy=sonic.target diff --git a/files/build_templates/per_namespace/teamd.service.j2 b/files/build_templates/per_namespace/teamd.service.j2 index f5936baa6a79..7dff23fb83e9 100644 --- a/files/build_templates/per_namespace/teamd.service.j2 +++ b/files/build_templates/per_namespace/teamd.service.j2 @@ -7,6 +7,8 @@ After=topology.service {% endif %} Requires=updategraph.service After=updategraph.service +BindsTo=sonic.target +After=sonic.target Before=ntp-config.service StartLimitIntervalSec=1200 StartLimitBurst=3 @@ -20,4 +22,4 @@ Restart=always RestartSec=30 [Install] -WantedBy=multi-user.target +WantedBy=sonic.target diff --git a/files/build_templates/pmon.service.j2 b/files/build_templates/pmon.service.j2 index 9195b4d38ad6..59d9e6c3319a 100644 --- a/files/build_templates/pmon.service.j2 +++ b/files/build_templates/pmon.service.j2 @@ -5,6 +5,8 @@ After=database.service updategraph.service {% if sonic_asic_platform == 'mellanox' %} After=syncd.service {% endif %} +BindsTo=sonic.target +After=sonic.target Before=ntp-config.service StartLimitIntervalSec=1200 StartLimitBurst=3 @@ -18,4 +20,4 @@ Restart=always RestartSec=30 [Install] -WantedBy=multi-user.target +WantedBy=sonic.target diff --git a/files/build_templates/radv.service.j2 b/files/build_templates/radv.service.j2 index 5cf25a21046d..0427b7e60505 100644 --- a/files/build_templates/radv.service.j2 +++ b/files/build_templates/radv.service.j2 @@ -3,6 +3,8 @@ Description=Router advertiser container Requires=updategraph.service After=updategraph.service swss.service syncd.service Before=ntp-config.service +BindsTo=sonic.target +After=sonic.target StartLimitIntervalSec=1200 StartLimitBurst=3 @@ -15,4 +17,4 @@ Restart=always RestartSec=30 [Install] -WantedBy=multi-user.target +WantedBy=sonic.target diff --git a/files/build_templates/restapi.service.j2 b/files/build_templates/restapi.service.j2 index df1a50eb56c7..edc18167e93a 100644 --- a/files/build_templates/restapi.service.j2 +++ b/files/build_templates/restapi.service.j2 @@ -2,6 +2,8 @@ Description=RestAPI container Requires=updategraph.service After=updategraph.service +BindsTo=sonic.target +After=sonic.target Before=ntp-config.service [Service] @@ -13,4 +15,4 @@ Restart=always RestartSec=30 [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=sonic.target diff --git a/files/build_templates/sflow.service.j2 b/files/build_templates/sflow.service.j2 index e9d5a871432d..3d6a3c7f569d 100644 --- a/files/build_templates/sflow.service.j2 +++ b/files/build_templates/sflow.service.j2 @@ -2,6 +2,8 @@ Description=sFlow container Requisite=swss.service After=swss.service syncd.service hostcfgd.service +BindsTo=sonic.target +After=sonic.target Before=ntp-config.service StartLimitIntervalSec=1200 StartLimitBurst=3 @@ -15,4 +17,4 @@ Restart=always RestartSec=30 [Install] -WantedBy=multi-user.target +WantedBy=sonic.target diff --git a/files/build_templates/snmp.service.j2 b/files/build_templates/snmp.service.j2 index 4997ab737e37..a510aac5571d 100644 --- a/files/build_templates/snmp.service.j2 +++ b/files/build_templates/snmp.service.j2 @@ -3,8 +3,9 @@ Description=SNMP container Requires=updategraph.service Requisite=swss.service After=updategraph.service swss.service syncd.service +BindsTo=sonic.target +After=sonic.target Before=ntp-config.service -Conflicts=snmp.timer StartLimitIntervalSec=1200 StartLimitBurst=3 @@ -14,4 +15,3 @@ ExecStart=/usr/bin/{{docker_container_name}}.sh wait ExecStop=/usr/bin/{{docker_container_name}}.sh stop Restart=always RestartSec=30 - diff --git a/files/build_templates/snmp.timer b/files/build_templates/snmp.timer index 1b3ccf633ce4..abbcb67f6dee 100644 --- a/files/build_templates/snmp.timer +++ b/files/build_templates/snmp.timer @@ -1,6 +1,6 @@ [Unit] Description=Delays snmp container until SONiC has started -Conflicts=snmp.service +PartOf=snmp.service After=swss.service [Timer] diff --git a/files/build_templates/sonic.target b/files/build_templates/sonic.target new file mode 100644 index 000000000000..4070e21a080e --- /dev/null +++ b/files/build_templates/sonic.target @@ -0,0 +1,5 @@ +[Unit] +Description=SONiC services target. + +[Install] +WantedBy=multi-user.target diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index e0199db84b99..2a110a2fd81c 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -685,6 +685,9 @@ sudo cp $BUILD_TEMPLATES/mgmt-framework.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_S echo "mgmt-framework.timer" | sudo tee -a $GENERATED_SERVICE_FILE {% endif %} +sudo cp $BUILD_TEMPLATES/sonic.target $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM +sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable sonic.target + sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get purge -y python-dev python3-dev sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get purge -y build-essential libssl-dev swig sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get clean -y diff --git a/files/build_templates/telemetry.service.j2 b/files/build_templates/telemetry.service.j2 index 43fa039156d7..aa02e75ac07b 100644 --- a/files/build_templates/telemetry.service.j2 +++ b/files/build_templates/telemetry.service.j2 @@ -3,6 +3,8 @@ Description=Telemetry container Requires=database.service After=database.service swss.service syncd.service Before=ntp-config.service +BindsTo=sonic.target +After=sonic.target StartLimitIntervalSec=1200 StartLimitBurst=3 @@ -13,4 +15,3 @@ ExecStart=/usr/bin/{{docker_container_name}}.sh wait ExecStop=/usr/bin/{{docker_container_name}}.sh stop Restart=always RestartSec=30 - diff --git a/files/build_templates/telemetry.timer b/files/build_templates/telemetry.timer index e08f1c09eac6..4a605b8c50cb 100644 --- a/files/build_templates/telemetry.timer +++ b/files/build_templates/telemetry.timer @@ -1,9 +1,11 @@ [Unit] Description=Delays telemetry container until SONiC has started +PartOf=telemetry.service [Timer] +OnUnitActiveSec=0 sec OnBootSec=3min 30 sec Unit=telemetry.service [Install] -WantedBy=timers.target +WantedBy=timers.target sonic.target diff --git a/files/image_config/hostname/hostname-config.service b/files/image_config/hostname/hostname-config.service index c23ae10227a4..c82c2d0bf54e 100644 --- a/files/image_config/hostname/hostname-config.service +++ b/files/image_config/hostname/hostname-config.service @@ -2,10 +2,13 @@ Description=Update hostname based on configdb Requires=updategraph.service After=updategraph.service +BindsTo=sonic.target +After=sonic.target [Service] Type=oneshot +RemainAfterExit=yes ExecStart=/usr/bin/hostname-config.sh [Install] -WantedBy=multi-user.target +WantedBy=sonic.target diff --git a/files/image_config/interfaces/interfaces-config.service b/files/image_config/interfaces/interfaces-config.service index 71178affdee8..a3f715764616 100644 --- a/files/image_config/interfaces/interfaces-config.service +++ b/files/image_config/interfaces/interfaces-config.service @@ -2,10 +2,13 @@ Description=Update interfaces configuration Requires=updategraph.service After=updategraph.service +BindsTo=sonic.target +After=sonic.target [Service] Type=oneshot +RemainAfterExit=yes ExecStart=/usr/bin/interfaces-config.sh [Install] -WantedBy=multi-user.target +WantedBy=sonic.target diff --git a/files/image_config/ntp/ntp-config.service b/files/image_config/ntp/ntp-config.service index a22a0331045d..5639b04520e0 100644 --- a/files/image_config/ntp/ntp-config.service +++ b/files/image_config/ntp/ntp-config.service @@ -2,12 +2,15 @@ Description=Update NTP configuration Requires=updategraph.service After=updategraph.service +BindsTo=sonic.target +After=sonic.target Before=ntp.service StartLimitIntervalSec=0 [Service] Type=oneshot +RemainAfterExit=yes ExecStart=/usr/bin/ntp-config.sh [Install] -WantedBy=multi-user.target +WantedBy=sonic.target diff --git a/files/image_config/ntp/ntp.service b/files/image_config/ntp/ntp.service index acfd7e17266a..32a55dea892e 100644 --- a/files/image_config/ntp/ntp.service +++ b/files/image_config/ntp/ntp.service @@ -3,6 +3,8 @@ Description=Network Time Service Documentation=man:ntpd(8) After=network.target Conflicts=systemd-timesyncd.service +BindsTo=sonic.target +After=sonic.target StartLimitIntervalSec=0 [Service] diff --git a/files/image_config/rsyslog/rsyslog-config.service b/files/image_config/rsyslog/rsyslog-config.service index ee62a36ccf2d..34c56fb0e00b 100644 --- a/files/image_config/rsyslog/rsyslog-config.service +++ b/files/image_config/rsyslog/rsyslog-config.service @@ -2,10 +2,13 @@ Description=Update rsyslog configuration Requires=updategraph.service After=updategraph.service +BindsTo=sonic.target +After=sonic.target [Service] Type=oneshot +RemainAfterExit=yes ExecStart=/usr/bin/rsyslog-config.sh [Install] -WantedBy=multi-user.target +WantedBy=sonic.target diff --git a/src/sonic-host-services-data/debian/sonic-host-services-data.caclmgrd.service b/src/sonic-host-services-data/debian/sonic-host-services-data.caclmgrd.service index 4df4d948ef1d..e24ed10bb33d 100644 --- a/src/sonic-host-services-data/debian/sonic-host-services-data.caclmgrd.service +++ b/src/sonic-host-services-data/debian/sonic-host-services-data.caclmgrd.service @@ -2,6 +2,8 @@ Description=Control Plane ACL configuration daemon Requires=updategraph.service After=updategraph.service +BindsTo=sonic.target +After=sonic.target [Service] Type=simple @@ -10,4 +12,4 @@ Restart=always RestartSec=30 [Install] -WantedBy=multi-user.target +WantedBy=sonic.target diff --git a/src/sonic-host-services-data/debian/sonic-host-services-data.hostcfgd.service b/src/sonic-host-services-data/debian/sonic-host-services-data.hostcfgd.service index ea0c3ba60fb7..4adf2aba77ad 100644 --- a/src/sonic-host-services-data/debian/sonic-host-services-data.hostcfgd.service +++ b/src/sonic-host-services-data/debian/sonic-host-services-data.hostcfgd.service @@ -2,10 +2,13 @@ Description=Host config enforcer daemon Requires=updategraph.service After=updategraph.service +BindsTo=sonic.target +After=sonic.target [Service] Type=simple ExecStart=/usr/local/bin/hostcfgd [Install] -WantedBy=multi-user.target +WantedBy=sonic.target + diff --git a/src/sonic-host-services-data/debian/sonic-host-services-data.procdockerstatsd.service b/src/sonic-host-services-data/debian/sonic-host-services-data.procdockerstatsd.service index 388197d9741b..68b9e61b62c2 100644 --- a/src/sonic-host-services-data/debian/sonic-host-services-data.procdockerstatsd.service +++ b/src/sonic-host-services-data/debian/sonic-host-services-data.procdockerstatsd.service @@ -2,6 +2,8 @@ Description=Process and docker CPU/memory utilization data export daemon Requires=database.service updategraph.service After=database.service updategraph.service +BindsTo=sonic.target +After=sonic.target [Service] Type=simple @@ -9,5 +11,4 @@ ExecStart=/usr/local/bin/procdockerstatsd Restart=always [Install] -WantedBy=multi-user.target - +WantedBy=sonic.target From 15aed52ef2c1ec6a0799dbadc0a77f85e3a400d7 Mon Sep 17 00:00:00 2001 From: Sujin Kang Date: Sun, 21 Feb 2021 08:27:37 -0800 Subject: [PATCH 0225/1674] [pcie.yaml] Move pcie configuration file path to platform directory (#6475) - Why I did it The pcie configuration file location is under plugin directory not under platform directory. #6437 - How I did it Move all pcie.yaml configuration file from plugin to platform directory. Remove unnecessary timer to start pcie-check.service Move pcie-check.service to sonic-host-services - How to verify it Verify on the device --- .gitignore | 7 +++++++ .../x86_64-arista_7050_qx32s/{plugins => }/pcie.yaml | 0 .../x86_64-arista_7050cx3_32s/{plugins => }/pcie.yaml | 0 .../x86_64-arista_7060_cx32s/{plugins => }/pcie.yaml | 0 .../x86_64-arista_7260cx3_64/{plugins => }/pcie.yaml | 0 .../x86_64-cel_e1031-r0/{plugins => }/pcie.yaml | 0 .../x86_64-cel_seastone-r0/{plugins => }/pcie.yaml | 0 .../x86_64-dell_s6000_s1220-r0/{plugins => }/pcie.yaml | 0 .../x86_64-dell_s6100_c2538-r0/{plugins => }/pcie.yaml | 0 files/build_templates/pcie-check.timer | 9 --------- files/build_templates/sonic_debian_extension.j2 | 4 ---- files/image_config/pcie-check/pcie-check.service | 3 +++ files/image_config/pcie-check/pcie-check.sh | 2 +- .../{plugins => }/pcie.yaml | 0 .../{plugins => }/pcie.yaml | 0 15 files changed, 11 insertions(+), 14 deletions(-) rename device/arista/x86_64-arista_7050_qx32s/{plugins => }/pcie.yaml (100%) rename device/arista/x86_64-arista_7050cx3_32s/{plugins => }/pcie.yaml (100%) rename device/arista/x86_64-arista_7060_cx32s/{plugins => }/pcie.yaml (100%) rename device/arista/x86_64-arista_7260cx3_64/{plugins => }/pcie.yaml (100%) rename device/celestica/x86_64-cel_e1031-r0/{plugins => }/pcie.yaml (100%) rename device/celestica/x86_64-cel_seastone-r0/{plugins => }/pcie.yaml (100%) rename device/dell/x86_64-dell_s6000_s1220-r0/{plugins => }/pcie.yaml (100%) rename device/dell/x86_64-dell_s6100_c2538-r0/{plugins => }/pcie.yaml (100%) delete mode 100644 files/build_templates/pcie-check.timer rename platform/barefoot/sonic-platform-modules-bfn-montara/{plugins => }/pcie.yaml (100%) rename platform/barefoot/sonic-platform-modules-bfn-newport/{plugins => }/pcie.yaml (100%) diff --git a/.gitignore b/.gitignore index 7e2f73f718e9..5e76a6cf92da 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,13 @@ platform/**/*-none-any.whl platform/**/.pybuild platform/**/debian/* platform/**/build +platform/**/*.ko +platform/**/*.mod.c +platform/**/*.mod.o +platform/**/*.o +platform/**/*.d +platform/**/*.cmd +platform/**/*.order platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/ipmihelper.py platform/broadcom/sonic-platform-modules-dell/s6100/modules/dell_ich.c platform/broadcom/sonic-platform-modules-dell/s6100/modules/dell_s6100_lpc.c diff --git a/device/arista/x86_64-arista_7050_qx32s/plugins/pcie.yaml b/device/arista/x86_64-arista_7050_qx32s/pcie.yaml similarity index 100% rename from device/arista/x86_64-arista_7050_qx32s/plugins/pcie.yaml rename to device/arista/x86_64-arista_7050_qx32s/pcie.yaml diff --git a/device/arista/x86_64-arista_7050cx3_32s/plugins/pcie.yaml b/device/arista/x86_64-arista_7050cx3_32s/pcie.yaml similarity index 100% rename from device/arista/x86_64-arista_7050cx3_32s/plugins/pcie.yaml rename to device/arista/x86_64-arista_7050cx3_32s/pcie.yaml diff --git a/device/arista/x86_64-arista_7060_cx32s/plugins/pcie.yaml b/device/arista/x86_64-arista_7060_cx32s/pcie.yaml similarity index 100% rename from device/arista/x86_64-arista_7060_cx32s/plugins/pcie.yaml rename to device/arista/x86_64-arista_7060_cx32s/pcie.yaml diff --git a/device/arista/x86_64-arista_7260cx3_64/plugins/pcie.yaml b/device/arista/x86_64-arista_7260cx3_64/pcie.yaml similarity index 100% rename from device/arista/x86_64-arista_7260cx3_64/plugins/pcie.yaml rename to device/arista/x86_64-arista_7260cx3_64/pcie.yaml diff --git a/device/celestica/x86_64-cel_e1031-r0/plugins/pcie.yaml b/device/celestica/x86_64-cel_e1031-r0/pcie.yaml similarity index 100% rename from device/celestica/x86_64-cel_e1031-r0/plugins/pcie.yaml rename to device/celestica/x86_64-cel_e1031-r0/pcie.yaml diff --git a/device/celestica/x86_64-cel_seastone-r0/plugins/pcie.yaml b/device/celestica/x86_64-cel_seastone-r0/pcie.yaml similarity index 100% rename from device/celestica/x86_64-cel_seastone-r0/plugins/pcie.yaml rename to device/celestica/x86_64-cel_seastone-r0/pcie.yaml diff --git a/device/dell/x86_64-dell_s6000_s1220-r0/plugins/pcie.yaml b/device/dell/x86_64-dell_s6000_s1220-r0/pcie.yaml similarity index 100% rename from device/dell/x86_64-dell_s6000_s1220-r0/plugins/pcie.yaml rename to device/dell/x86_64-dell_s6000_s1220-r0/pcie.yaml diff --git a/device/dell/x86_64-dell_s6100_c2538-r0/plugins/pcie.yaml b/device/dell/x86_64-dell_s6100_c2538-r0/pcie.yaml similarity index 100% rename from device/dell/x86_64-dell_s6100_c2538-r0/plugins/pcie.yaml rename to device/dell/x86_64-dell_s6100_c2538-r0/pcie.yaml diff --git a/files/build_templates/pcie-check.timer b/files/build_templates/pcie-check.timer deleted file mode 100644 index 4ad5c6481861..000000000000 --- a/files/build_templates/pcie-check.timer +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=Start the pcie-check.service 10 seconds after boot - -[Timer] -OnBootSec=10sec -Unit=pcie-check.service - -[Install] -WantedBy=timers.target diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 2a110a2fd81c..8edd9af847a6 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -506,10 +506,6 @@ sudo cp $IMAGE_CONFIGS/constants/constants.yml $FILESYSTEM_ROOT/etc/sonic/ sudo cp $IMAGE_CONFIGS/sudoers/sudoers $FILESYSTEM_ROOT/etc/ sudo cp $IMAGE_CONFIGS/sudoers/sudoers.lecture $FILESYSTEM_ROOT/etc/ -# Copy systemd timer configuration -sudo cp $BUILD_TEMPLATES/pcie-check.timer $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM -sudo LANG=C chroot $FILESYSTEM_ROOT systemctl enable pcie-check.timer - # Copy pcie-check service files sudo cp $IMAGE_CONFIGS/pcie-check/pcie-check.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM echo "pcie-check.service" | sudo tee -a $GENERATED_SERVICE_FILE diff --git a/files/image_config/pcie-check/pcie-check.service b/files/image_config/pcie-check/pcie-check.service index fbf3cfd3f19d..9df04ea840bc 100644 --- a/files/image_config/pcie-check/pcie-check.service +++ b/files/image_config/pcie-check/pcie-check.service @@ -5,3 +5,6 @@ After=rc.local.service database.service [Service] Type=simple ExecStart=/usr/bin/pcie-check.sh + +[Install] +WantedBy=multi-user.target diff --git a/files/image_config/pcie-check/pcie-check.sh b/files/image_config/pcie-check/pcie-check.sh index 4257a2544c4a..01a952d01374 100755 --- a/files/image_config/pcie-check/pcie-check.sh +++ b/files/image_config/pcie-check/pcie-check.sh @@ -19,7 +19,7 @@ function check_and_rescan_pcie_devices() PCIE_CHK_CMD='sudo pcieutil check | grep "$RESULTS"' PLATFORM=$(sonic-cfggen -H -v DEVICE_METADATA.localhost.platform) - if [ ! -f /usr/share/sonic/device/$PLATFORM/plugins/pcie.yaml ]; then + if [ ! -f /usr/share/sonic/device/$PLATFORM/pcie.yaml ]; then debug "pcie.yaml does not exist! Can't check PCIe status!" exit fi diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/plugins/pcie.yaml b/platform/barefoot/sonic-platform-modules-bfn-montara/pcie.yaml similarity index 100% rename from platform/barefoot/sonic-platform-modules-bfn-montara/plugins/pcie.yaml rename to platform/barefoot/sonic-platform-modules-bfn-montara/pcie.yaml diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/plugins/pcie.yaml b/platform/barefoot/sonic-platform-modules-bfn-newport/pcie.yaml similarity index 100% rename from platform/barefoot/sonic-platform-modules-bfn-newport/plugins/pcie.yaml rename to platform/barefoot/sonic-platform-modules-bfn-newport/pcie.yaml From e13672b94a042a115c3a4e69bfd97c5b94f7e7f5 Mon Sep 17 00:00:00 2001 From: ec-michael-shih <71379738+ec-michael-shih@users.noreply.github.com> Date: Fri, 26 Feb 2021 02:47:38 +0800 Subject: [PATCH 0226/1674] [Platform] Accton add to support as4630-54te platform. (#6683) Add support for Accton as4630-54te platform --- .../Accton-AS4630-54TE/port_config.ini | 55 + .../x86_64-accton_as4630_54te-r0/default_sku | 1 + .../installer.conf | 3 + .../plugins/eeprom.py | 13 + .../plugins/psuutil.py | 61 + .../plugins/sfputil.py | 196 +++ .../pmon_daemon_control.json | 5 + .../sonic_platform/__init__.py | 2 + .../sonic_platform/chassis.py | 194 +++ .../sonic_platform/component.py | 121 ++ .../sonic_platform/eeprom.py | 102 ++ .../sonic_platform/fan.py | 171 +++ .../sonic_platform/helper.py | 117 ++ .../sonic_platform/platform.py | 21 + .../sonic_platform/psu.py | 228 ++++ .../sonic_platform/sfp.py | 1169 +++++++++++++++++ .../sonic_platform/thermal.py | 145 ++ platform/broadcom/one-image.mk | 1 + platform/broadcom/platform-modules-accton.mk | 6 + .../as4630-54te/classes/__init__.py | 0 .../as4630-54te/classes/fanutil.py | 213 +++ .../as4630-54te/classes/thermalutil.py | 93 ++ .../as4630-54te/modules/Makefile | 19 + .../modules/x86-64-accton-as4630-54te-cpld.c | 1106 ++++++++++++++++ .../modules/x86-64-accton-as4630-54te-leds.c | 579 ++++++++ .../modules/x86-64-accton-as4630-54te-psu.c | 320 +++++ .../as4630-54te/modules/ym2651y.c | 1 + ...4te-platform-handle-mgmt-interface.service | 11 + .../as4630-54te-platform-monitor-fan.service | 16 + .../as4630-54te-platform-monitor-psu.service | 16 + .../as4630-54te-platform-monitor.service | 17 + .../as4630-54te/setup.py | 14 + .../as4630-54te/sonic_platform_setup.py | 34 + .../as4630-54te/utils/README | 67 + .../utils/accton_as4630_54te_monitor.py | 261 ++++ .../utils/accton_as4630_54te_monitor_fan.py | 186 +++ .../utils/accton_as4630_54te_monitor_psu.py | 168 +++ .../utils/accton_as4630_54te_util.py | 681 ++++++++++ .../utils/handle_mgmt_interface.sh | 8 + .../debian/control | 4 + .../debian/rules | 2 +- .../sonic-platform-accton-as4630-54te.install | 2 + 42 files changed, 6428 insertions(+), 1 deletion(-) create mode 100755 device/accton/x86_64-accton_as4630_54te-r0/Accton-AS4630-54TE/port_config.ini create mode 100755 device/accton/x86_64-accton_as4630_54te-r0/default_sku create mode 100755 device/accton/x86_64-accton_as4630_54te-r0/installer.conf create mode 100755 device/accton/x86_64-accton_as4630_54te-r0/plugins/eeprom.py create mode 100755 device/accton/x86_64-accton_as4630_54te-r0/plugins/psuutil.py create mode 100755 device/accton/x86_64-accton_as4630_54te-r0/plugins/sfputil.py create mode 100644 device/accton/x86_64-accton_as4630_54te-r0/pmon_daemon_control.json create mode 100644 device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/__init__.py create mode 100644 device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/chassis.py create mode 100644 device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/component.py create mode 100644 device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/eeprom.py create mode 100644 device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/fan.py create mode 100644 device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/helper.py create mode 100644 device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/platform.py create mode 100644 device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/psu.py create mode 100644 device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/sfp.py create mode 100644 device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/thermal.py create mode 100755 platform/broadcom/sonic-platform-modules-accton/as4630-54te/classes/__init__.py create mode 100755 platform/broadcom/sonic-platform-modules-accton/as4630-54te/classes/fanutil.py create mode 100755 platform/broadcom/sonic-platform-modules-accton/as4630-54te/classes/thermalutil.py create mode 100755 platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/Makefile create mode 100755 platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-cpld.c create mode 100755 platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-leds.c create mode 100755 platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-psu.c create mode 120000 platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/ym2651y.c create mode 100644 platform/broadcom/sonic-platform-modules-accton/as4630-54te/service/as4630-54te-platform-handle-mgmt-interface.service create mode 100644 platform/broadcom/sonic-platform-modules-accton/as4630-54te/service/as4630-54te-platform-monitor-fan.service create mode 100644 platform/broadcom/sonic-platform-modules-accton/as4630-54te/service/as4630-54te-platform-monitor-psu.service create mode 100644 platform/broadcom/sonic-platform-modules-accton/as4630-54te/service/as4630-54te-platform-monitor.service create mode 100755 platform/broadcom/sonic-platform-modules-accton/as4630-54te/setup.py create mode 100644 platform/broadcom/sonic-platform-modules-accton/as4630-54te/sonic_platform_setup.py create mode 100755 platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/README create mode 100755 platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_monitor.py create mode 100755 platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_monitor_fan.py create mode 100755 platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_monitor_psu.py create mode 100755 platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_util.py create mode 100755 platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/handle_mgmt_interface.sh create mode 100644 platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as4630-54te.install diff --git a/device/accton/x86_64-accton_as4630_54te-r0/Accton-AS4630-54TE/port_config.ini b/device/accton/x86_64-accton_as4630_54te-r0/Accton-AS4630-54TE/port_config.ini new file mode 100755 index 000000000000..f8965dfe41d0 --- /dev/null +++ b/device/accton/x86_64-accton_as4630_54te-r0/Accton-AS4630-54TE/port_config.ini @@ -0,0 +1,55 @@ +# name lanes alias index speed autoneg +Ethernet0 26 thousandE1 1 1000 1 +Ethernet1 25 thousandE2 2 1000 1 +Ethernet2 28 thousandE3 3 1000 1 +Ethernet3 27 thousandE4 4 1000 1 +Ethernet4 30 thousandE5 5 1000 1 +Ethernet5 29 thousandE6 6 1000 1 +Ethernet6 32 thousandE7 7 1000 1 +Ethernet7 31 thousandE8 8 1000 1 +Ethernet8 38 thousandE9 9 1000 1 +Ethernet9 37 thousandE10 10 1000 1 +Ethernet10 40 thousandE11 11 1000 1 +Ethernet11 39 thousandE12 12 1000 1 +Ethernet12 34 thousandE13 13 1000 1 +Ethernet13 33 thousandE14 14 1000 1 +Ethernet14 36 thousandE15 15 1000 1 +Ethernet15 35 thousandE16 16 1000 1 +Ethernet16 46 thousandE17 17 1000 1 +Ethernet17 45 thousandE18 18 1000 1 +Ethernet18 48 thousandE19 19 1000 1 +Ethernet19 47 thousandE20 20 1000 1 +Ethernet20 42 thousandE21 21 1000 1 +Ethernet21 41 thousandE22 22 1000 1 +Ethernet22 44 thousandE23 23 1000 1 +Ethernet23 43 thousandE24 24 1000 1 +Ethernet24 2 thousandE25 25 1000 1 +Ethernet25 1 thousandE26 26 1000 1 +Ethernet26 4 thousandE27 27 1000 1 +Ethernet27 3 thousandE28 28 1000 1 +Ethernet28 6 thousandE29 29 1000 1 +Ethernet29 5 thousandE30 30 1000 1 +Ethernet30 8 thousandE31 31 1000 1 +Ethernet31 7 thousandE32 32 1000 1 +Ethernet32 10 thousandE33 33 1000 1 +Ethernet33 9 thousandE34 34 1000 1 +Ethernet34 12 thousandE35 35 1000 1 +Ethernet35 11 thousandE36 36 1000 1 +Ethernet36 14 thousandE37 37 1000 1 +Ethernet37 13 thousandE38 38 1000 1 +Ethernet38 16 thousandE39 39 1000 1 +Ethernet39 15 thousandE40 40 1000 1 +Ethernet40 18 thousandE41 41 1000 1 +Ethernet41 17 thousandE42 42 1000 1 +Ethernet42 20 thousandE43 43 1000 1 +Ethernet43 19 thousandE44 44 1000 1 +Ethernet44 22 thousandE45 45 1000 1 +Ethernet45 21 thousandE46 46 1000 1 +Ethernet46 24 thousandE47 47 1000 1 +Ethernet47 23 thousandE48 48 1000 1 +Ethernet48 67 twentyfiveGigE49 49 25000 0 +Ethernet49 66 twentyfiveGigE50 50 25000 0 +Ethernet50 65 twentyfiveGigE51 51 25000 0 +Ethernet51 68 twentyfiveGigE52 52 25000 0 +Ethernet52 73,74,75,76 hundredGigE53 53 100000 0 +Ethernet56 69,70,71,72 hundredGigE54 54 100000 0 diff --git a/device/accton/x86_64-accton_as4630_54te-r0/default_sku b/device/accton/x86_64-accton_as4630_54te-r0/default_sku new file mode 100755 index 000000000000..8fb346d4ad3d --- /dev/null +++ b/device/accton/x86_64-accton_as4630_54te-r0/default_sku @@ -0,0 +1 @@ +Accton-AS4630-54TE t1 diff --git a/device/accton/x86_64-accton_as4630_54te-r0/installer.conf b/device/accton/x86_64-accton_as4630_54te-r0/installer.conf new file mode 100755 index 000000000000..925a32fc0c3a --- /dev/null +++ b/device/accton/x86_64-accton_as4630_54te-r0/installer.conf @@ -0,0 +1,3 @@ +CONSOLE_PORT=0x3f8 +CONSOLE_DEV=0 +CONSOLE_SPEED=115200 diff --git a/device/accton/x86_64-accton_as4630_54te-r0/plugins/eeprom.py b/device/accton/x86_64-accton_as4630_54te-r0/plugins/eeprom.py new file mode 100755 index 000000000000..7409239d01f3 --- /dev/null +++ b/device/accton/x86_64-accton_as4630_54te-r0/plugins/eeprom.py @@ -0,0 +1,13 @@ +try: + from sonic_eeprom import eeprom_tlvinfo + +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class board(eeprom_tlvinfo.TlvInfoDecoder): + _TLV_INFO_MAX_LEN = 256 + + def __init__(self, name, path, cpld_root, ro): + self.eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom" + super(board, self).__init__(self.eeprom_path, 0, '', True) diff --git a/device/accton/x86_64-accton_as4630_54te-r0/plugins/psuutil.py b/device/accton/x86_64-accton_as4630_54te-r0/plugins/psuutil.py new file mode 100755 index 000000000000..92ae68eb87bf --- /dev/null +++ b/device/accton/x86_64-accton_as4630_54te-r0/plugins/psuutil.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python + +############################################################################# +# Accton +# +# Module contains an implementation of SONiC PSU Base API and +# provides the PSUs status which are available in the platform +# +############################################################################# + + +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) + + self.psu_path = "/sys/bus/i2c/devices/" + self.psu_presence = "/psu_present" + self.psu_oper_status = "/psu_power_good" + self.psu_mapping = { + 1: "10-0050", + 2: "11-0051", + } + + def get_num_psus(self): + return len(self.psu_mapping) + + def get_psu_status(self, index): + if index is None: + return False + + status = 0 + node = self.psu_path + self.psu_mapping[index] + self.psu_oper_status + try: + with open(node, 'r') as power_status: + status = int(power_status.read()) + except IOError: + return False + + return status == 1 + + def get_psu_presence(self, index): + if index is None: + return False + + status = 0 + node = self.psu_path + self.psu_mapping[index] + self.psu_presence + try: + with open(node, 'r') as presence_status: + status = int(presence_status.read()) + except IOError: + return False + + return status == 1 diff --git a/device/accton/x86_64-accton_as4630_54te-r0/plugins/sfputil.py b/device/accton/x86_64-accton_as4630_54te-r0/plugins/sfputil.py new file mode 100755 index 000000000000..63e6bd53645c --- /dev/null +++ b/device/accton/x86_64-accton_as4630_54te-r0/plugins/sfputil.py @@ -0,0 +1,196 @@ +# sfputil.py +# +# Platform-specific SFP transceiver interface for SONiC +# + +try: + import sys + import time + from ctypes import create_string_buffer + from sonic_sfp.sfputilbase import SfpUtilBase +except ImportError as e: + raise ImportError("%s - required module not found" % str(e)) + +SFP_STATUS_INSERTED = '1' +SFP_STATUS_REMOVED = '0' + + +class SfpUtil(SfpUtilBase): + """Platform-specific SfpUtil class""" + + PORT_START = 49 + PORT_END = 54 + PORTS_IN_BLOCK = 54 + QSFP_START = 53 + + BASE_OOM_PATH = "/sys/bus/i2c/devices/{0}-0050/" + BASE_CPLD_PATH = "/sys/bus/i2c/devices/3-0060/" + + _port_to_is_present = {} + _port_to_lp_mode = {} + + _port_to_eeprom_mapping = {} + _port_to_i2c_mapping = { + 49: [18], + 50: [19], + 51: [20], + 52: [21], + 53: [22], + 54: [23], + } + + @property + def port_start(self): + return self.PORT_START + + @property + def port_end(self): + return self.PORT_END + + @property + def qsfp_ports(self): + return range(self.PORT_START, self.PORTS_IN_BLOCK + 1) + + @property + def port_to_eeprom_mapping(self): + return self._port_to_eeprom_mapping + + def __init__(self): + eeprom_path = self.BASE_OOM_PATH + "eeprom" + for x in range(self.port_start, self.port_end + 1): + self.port_to_eeprom_mapping[x] = eeprom_path.format( + self._port_to_i2c_mapping[x][0]) + SfpUtilBase.__init__(self) + + 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 + + present_path = self.BASE_CPLD_PATH + "module_present_" + str(port_num) + self.__port_to_is_present = present_path + + try: + val_file = open(self.__port_to_is_present) + content = val_file.readline().rstrip() + val_file.close() + except IOError as e: + print ('Error: unable to access file: %s') % str(e) + return False + + if content == "1": + return True + + return False + + def get_low_power_mode(self, port_num): + # Check for invalid port_num + if port_num < self.QSFP_START or port_num > self.port_end: + return False + + try: + eeprom = None + if not self.get_presence(port_num): + return False + eeprom = open(self.port_to_eeprom_mapping[port_num], "rb") + eeprom.seek(93) + lpmode = ord(eeprom.read(1)) + + # if "Power override" bit is 1 and "Power set" bit is 1 + if ((lpmode & 0x3) == 0x3): + return True + + # High Power Mode if one of the following conditions is matched: + # 1. "Power override" bit is 0 + # 2. "Power override" bit is 1 and "Power set" bit is 0 + else: + return False + + except IOError as e: + print ('Error: unable to open file: %s') % str(e) + return False + finally: + if eeprom is not None: + eeprom.close() + time.sleep(0.01) + + def set_low_power_mode(self, port_num, lpmode): + # Check for invalid port_num + if port_num < self.QSFP_START or port_num > self.port_end: + return False + + try: + eeprom = None + if not self.get_presence(port_num): + return False # Port is not present, unable to set the eeprom + + # Fill in write buffer + # 0x3:Low Power Mode, 0x1:High Power Mode + regval = 0x3 if lpmode else 0x1 + + buffer = create_string_buffer(1) + if sys.version_info[0] >= 3: + buffer[0] = regval + else: + buffer[0] = chr(regval) + + # Write to eeprom + eeprom = open(self.port_to_eeprom_mapping[port_num], "r+b") + eeprom.seek(93) + eeprom.write(buffer[0]) + return True + except IOError as e: + print ('Error: unable to open file: %s') % str(e) + return False + finally: + if eeprom is not None: + eeprom.close() + time.sleep(0.01) + + def reset(self, port_num): + raise NotImplementedError + + @property + def _get_presence_bitmap(self): + + bits = [] + for x in range(self.port_start, self.port_end + 1): + bits.append(str(int(self.get_presence(x)))) + + rev = "".join(bits[::-1]) + return int(rev, 2) + + data = {'present': 0} + + def get_transceiver_change_event(self, timeout=0): + port_dict = {} + + if timeout == 0: + cd_ms = sys.maxsize + else: + cd_ms = timeout + + # poll per second + while cd_ms > 0: + reg_value = self._get_presence_bitmap + changed_ports = self.data['present'] ^ reg_value + if changed_ports != 0: + break + time.sleep(1) + cd_ms = cd_ms - 1000 + + if changed_ports != 0: + for port in range(self.port_start, self.port_end + 1): + # Mask off the bit corresponding to our port + mask = (1 << (port - self.port_start)) + if changed_ports & mask: + if (reg_value & mask) == 0: + port_dict[port] = SFP_STATUS_REMOVED + else: + port_dict[port] = SFP_STATUS_INSERTED + + # Update cache + self.data['present'] = reg_value + return True, port_dict + else: + return True, {} diff --git a/device/accton/x86_64-accton_as4630_54te-r0/pmon_daemon_control.json b/device/accton/x86_64-accton_as4630_54te-r0/pmon_daemon_control.json new file mode 100644 index 000000000000..584a14b9d942 --- /dev/null +++ b/device/accton/x86_64-accton_as4630_54te-r0/pmon_daemon_control.json @@ -0,0 +1,5 @@ +{ + "skip_ledd": true, + "skip_thermalctld": true +} + diff --git a/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/__init__.py b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/__init__.py new file mode 100644 index 000000000000..a18a2a2d2a3b --- /dev/null +++ b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/__init__.py @@ -0,0 +1,2 @@ +__all__ = ['chassis', 'eeprom', 'platform', 'psu', 'sfp', 'thermal', 'fan'] +from . import platform diff --git a/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/chassis.py b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/chassis.py new file mode 100644 index 000000000000..d666e0c5bf86 --- /dev/null +++ b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/chassis.py @@ -0,0 +1,194 @@ +############################################################################# +# Edgecore +# +# Module contains an implementation of SONiC Platform Base API and +# provides the Chassis information which are available in the platform +# +############################################################################# + +import os + +try: + from sonic_platform_base.chassis_base import ChassisBase + from .helper import APIHelper +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +NUM_FAN_TRAY = 3 +NUM_FAN = 2 +NUM_PSU = 2 +NUM_THERMAL = 3 +NUM_QSFP = 6 +PORT_START = 49 +PORT_END = 54 +NUM_COMPONENT = 2 +HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/" +PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/" +REBOOT_CAUSE_FILE = "reboot-cause.txt" +PREV_REBOOT_CAUSE_FILE = "previous-reboot-cause.txt" +HOST_CHK_CMD = "docker > /dev/null 2>&1" + + +class Chassis(ChassisBase): + """Platform-specific Chassis class""" + + def __init__(self): + ChassisBase.__init__(self) + self._api_helper = APIHelper() + self._api_helper = APIHelper() + self.is_host = self._api_helper.is_host() + + self.config_data = {} + + self.__initialize_fan() + self.__initialize_psu() + self.__initialize_thermals() + self.__initialize_components() + self.__initialize_sfp() + self.__initialize_eeprom() + + def __initialize_sfp(self): + from sonic_platform.sfp import Sfp + for index in range(0, PORT_END): + sfp = Sfp(index) + self._sfp_list.append(sfp) + self.sfp_module_initialized = True + + def __initialize_fan(self): + from sonic_platform.fan import Fan + for fant_index in range(0, NUM_FAN_TRAY): + for fan_index in range(0, NUM_FAN): + fan = Fan(fant_index, fan_index) + self._fan_list.append(fan) + + def __initialize_psu(self): + from sonic_platform.psu import Psu + for index in range(0, NUM_PSU): + psu = Psu(index) + self._psu_list.append(psu) + + def __initialize_thermals(self): + from sonic_platform.thermal import Thermal + for index in range(0, NUM_THERMAL): + thermal = Thermal(index) + self._thermal_list.append(thermal) + + def __initialize_eeprom(self): + from sonic_platform.eeprom import Tlv + self._eeprom = Tlv() + + def __initialize_components(self): + from sonic_platform.component import Component + for index in range(0, NUM_COMPONENT): + component = Component(index) + self._component_list.append(component) + + def __initialize_watchdog(self): + from sonic_platform.watchdog import Watchdog + self._watchdog = Watchdog() + + + def __is_host(self): + return os.system(HOST_CHK_CMD) == 0 + + 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 None + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + + return self._api_helper.hwsku + + def get_presence(self): + """ + Retrieves the presence of the Chassis + Returns: + bool: True if Chassis is present, False if not + """ + return True + + def get_status(self): + """ + Retrieves the operational status of the device + Returns: + A boolean value, True if device is operating properly, False if not + """ + return True + + def get_base_mac(self): + """ + Retrieves the base MAC address for the chassis + Returns: + A string containing the MAC address in the format + 'XX:XX:XX:XX:XX:XX' + """ + return self._eeprom.get_mac() + + def get_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.get_serial() + + def get_system_eeprom_info(self): + """ + Retrieves the full content of system EEPROM information for the chassis + Returns: + A dictionary where keys are the type code defined in + OCP ONIE TlvInfo EEPROM format and values are their corresponding + values. + """ + return self._eeprom.get_eeprom() + + def get_reboot_cause(self): + """ + Retrieves the cause of the previous reboot + Returns: + A tuple (string, string) where the first element is a string + containing the cause of the previous reboot. This string must be + one of the predefined strings in this class. If the first string + is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used + to pass a description of the reboot cause. + """ + + reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE) + sw_reboot_cause = self._api_helper.read_txt_file( + reboot_cause_path) or "Unknown" + + + return ('REBOOT_CAUSE_NON_HARDWARE', sw_reboot_cause) + + def get_sfp(self, index): + """ + Retrieves sfp represented by (1-based) index + Args: + index: An integer, the index (1-based) of the sfp to retrieve. + The index should be the sequence of a physical port in a chassis, + starting from 1. + For example, 1 for Ethernet0, 2 for Ethernet4 and so on. + Returns: + An object dervied from SfpBase representing the specified sfp + """ + sfp = None + if not self.sfp_module_initialized: + self.__initialize_sfp() + + try: + # The index will start from 1 + sfp = self._sfp_list[index-1] + except IndexError: + sys.stderr.write("SFP index {} out of range (1-{})\n".format( + index, len(self._sfp_list))) + return sfp diff --git a/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/component.py b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/component.py new file mode 100644 index 000000000000..c34da704432a --- /dev/null +++ b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/component.py @@ -0,0 +1,121 @@ +############################################################################# +# Accton +# +# Component contains an implementation of SONiC Platform Base API and +# provides the components firmware management function +# +############################################################################# + +import shlex +import subprocess + + +try: + from sonic_platform_base.component_base import ComponentBase + from .helper import APIHelper +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +CPLD_ADDR_MAPPING = { + "CPLD1": "3-0060" +} +SYSFS_PATH = "/sys/bus/i2c/devices/" +BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version" +COMPONENT_LIST= [ + ("CPLD1", "CPLD 1"), + ("BIOS", "Basic Input/Output System") + +] + +class Component(ComponentBase): + """Platform-specific Component class""" + + DEVICE_TYPE = "component" + + def __init__(self, component_index=0): + self._api_helper=APIHelper() + ComponentBase.__init__(self) + self.index = component_index + self.name = self.get_name() + + def __run_command(self, command): + # Run bash command and print output to stdout + try: + process = subprocess.Popen( + shlex.split(command), stdout=subprocess.PIPE) + while True: + output = process.stdout.readline() + if output == '' and process.poll() is not None: + break + rc = process.poll() + if rc != 0: + return False + except Exception: + return False + return True + + def __get_bios_version(self): + # Retrieves the BIOS firmware version + try: + with open(BIOS_VERSION_PATH, 'r') as fd: + bios_version = fd.read() + return bios_version.strip() + except Exception as e: + return None + + def __get_cpld_version(self): + # Retrieves the CPLD firmware version + cpld_version = dict() + for cpld_name in CPLD_ADDR_MAPPING: + try: + cpld_path = "{}{}{}".format(SYSFS_PATH, CPLD_ADDR_MAPPING[cpld_name], '/version') + cpld_version_raw= self._api_helper.read_txt_file(cpld_path) + cpld_version[cpld_name] = "{}".format(int(cpld_version_raw,16)) + except Exception as e: + print('Get exception when read cpld') + cpld_version[cpld_name] = 'None' + + return cpld_version + + def get_name(self): + """ + Retrieves the name of the component + Returns: + A string containing the name of the component + """ + return COMPONENT_LIST[self.index][0] + + def get_description(self): + """ + Retrieves the description of the component + Returns: + A string containing the description of the component + """ + return COMPONENT_LIST[self.index][1] + + + def get_firmware_version(self): + """ + Retrieves the firmware version of module + Returns: + string: The firmware versions of the module + """ + fw_version = None + + if self.name == "BIOS": + fw_version = self.__get_bios_version() + elif "CPLD" in self.name: + cpld_version = self.__get_cpld_version() + fw_version = cpld_version.get(self.name) + + return fw_version + + def install_firmware(self, image_path): + """ + Install firmware to module + Args: + image_path: A string, path to firmware image + Returns: + A boolean, True if install successfully, False if not + """ + raise NotImplementedError diff --git a/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/eeprom.py b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/eeprom.py new file mode 100644 index 000000000000..7bf2bb58d19f --- /dev/null +++ b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/eeprom.py @@ -0,0 +1,102 @@ +try: + import os + import sys + import re + if sys.version_info[0] >= 3: + from io import StringIO + else: + from cStringIO import StringIO + + from sonic_platform_base.sonic_eeprom import eeprom_tlvinfo +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +CACHE_ROOT = '/var/cache/sonic/decode-syseeprom' +CACHE_FILE = 'syseeprom_cache' + + +class Tlv(eeprom_tlvinfo.TlvInfoDecoder): + + EEPROM_DECODE_HEADLINES = 6 + + def __init__(self): + self._eeprom_path = "/sys/bus/i2c/devices/1-0057/eeprom" + super(Tlv, self).__init__(self._eeprom_path, 0, '', True) + self._eeprom = self._load_eeprom() + + def __parse_output(self, decode_output): + decode_output.replace('\0', '') + lines = decode_output.split('\n') + lines = lines[self.EEPROM_DECODE_HEADLINES:] + _eeprom_info_dict = dict() + + for line in lines: + try: + match = re.search( + '(0x[0-9a-fA-F]{2})([\s]+[\S]+[\s]+)([\S]+)', line) + if match is not None: + idx = match.group(1) + value = match.group(3).rstrip('\0') + + _eeprom_info_dict[idx] = value + except Exception: + pass + + return _eeprom_info_dict + + def _load_eeprom(self): + original_stdout = sys.stdout + sys.stdout = StringIO() + try: + self.read_eeprom_db() + except Exception: + decode_output = sys.stdout.getvalue() + sys.stdout = original_stdout + return self.__parse_output(decode_output) + + status = self.check_status() + if 'ok' not in status: + return False + + if not os.path.exists(CACHE_ROOT): + try: + os.makedirs(CACHE_ROOT) + except Exception: + pass + + # + # only the eeprom classes that inherit from eeprom_base + # support caching. Others will work normally + # + try: + self.set_cache_name(os.path.join(CACHE_ROOT, CACHE_FILE)) + except Exception: + pass + + e = self.read_eeprom() + if e is None: + return 0 + + try: + self.update_cache(e) + except Exception: + pass + + self.decode_eeprom(e) + decode_output = sys.stdout.getvalue() + sys.stdout = original_stdout + + (is_valid, valid_crc) = self.is_checksum_valid(e) + if not is_valid: + return False + + return self.__parse_output(decode_output) + + def get_eeprom(self): + return self._eeprom + + def get_serial(self): + return self._eeprom.get('0x23', "Undefined.") + + def get_mac(self): + return self._eeprom.get('0x24', "Undefined.") diff --git a/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/fan.py b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/fan.py new file mode 100644 index 000000000000..663c343a75f6 --- /dev/null +++ b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/fan.py @@ -0,0 +1,171 @@ +############################################################################# +# Edgecore +# +# Module contains an implementation of SONiC Platform Base API and +# provides the fan status which are available in the platform +# +############################################################################# + +try: + from sonic_platform_base.fan_base import FanBase + from .helper import APIHelper +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +PSU_FAN_MAX_RPM = 26688 + +CPLD_I2C_PATH = "/sys/bus/i2c/devices/3-0060/fan_" +PSU_HWMON_I2C_PATH ="/sys/bus/i2c/devices/{}-00{}/" +PSU_I2C_MAPPING = { + 0: { + "num": 10, + "addr": "58" + }, + 1: { + "num": 11, + "addr": "59" + }, +} + + +class Fan(FanBase): + """Platform-specific Fan class""" + + def __init__(self, fan_tray_index, fan_index=0, is_psu_fan=False, psu_index=0): + self._api_helper=APIHelper() + self.fan_index = fan_index + self.fan_tray_index = fan_tray_index + self.is_psu_fan = is_psu_fan + + if self.is_psu_fan: + self.psu_index = psu_index + self.psu_i2c_num = PSU_I2C_MAPPING[self.psu_index]['num'] + self.psu_i2c_addr = PSU_I2C_MAPPING[self.psu_index]['addr'] + self.psu_hwmon_path = PSU_HWMON_I2C_PATH.format( + self.psu_i2c_num, self.psu_i2c_addr) + + FanBase.__init__(self) + + + def get_direction(self): + """ + Retrieves the direction of fan + Returns: + A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST + depending on fan direction + """ + + + if not self.is_psu_fan: + dir_str = "{}{}{}".format(CPLD_I2C_PATH, 'direction_', self.fan_tray_index) + val=self._api_helper.read_txt_file(dir_str) + if val is not None: + if val==0:#F2B + direction=self.FAN_DIRECTION_EXHAUST + else: + direction=self.FAN_DIRECTION_INTAKE + else: + direction=self.FAN_DIRECTION_EXHAUST + + else: #For PSU + dir_str = "{}{}".format(self.psu_hwmon_path,'psu_fan_dir') + val=self._api_helper.read_txt_file(dir_str) + if val is not None: + if val=='F2B': + direction=self.FAN_DIRECTION_EXHAUST + else: + direction=self.FAN_DIRECTION_INTAKE + else: + 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) + + """ + speed = 0 + if self.is_psu_fan: + psu_fan_path= "{}{}".format(self.psu_hwmon_path, 'psu_fan1_speed_rpm') + fan_speed_rpm = self._api_helper.read_txt_file(psu_fan_path) + if fan_speed_rpm is not None: + speed = (int(fan_speed_rpm,10))*100/26688 + if speed > 100: + speed=100 + else: + return 0 + elif self.get_presence(): + speed_path = "{}{}".format(CPLD_I2C_PATH, 'duty_cycle_percentage') + speed=self._api_helper.read_txt_file(speed_path) + if speed is None: + return 0 + return int(speed) + + def get_target_speed(self): + """ + Retrieves the target (expected) speed of the fan + Returns: + An integer, the percentage of full fan speed, in the range 0 (off) + to 100 (full speed) + Note: + speed_pc = pwm_target/255*100 + 0 : when PWM mode is use + pwm : when pwm mode is not use + """ + return False #Not supported + + 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 False #Not supported + + def set_speed(self, speed): + """ + Sets the fan speed + Args: + speed: An integer, the percentage of full fan speed to set fan to, + in the range 0 (off) to 100 (full speed) + Returns: + A boolean, True if speed is set successfully, False if not + """ + + if not self.is_psu_fan and self.get_presence(): + speed_path = "{}{}".format(CPLD_I2C_PATH, 'duty_cycle_percentage') + return self._api_helper.write_txt_file(speed_path, int(speed)) + + return False + + def set_status_led(self, color): + """ + Sets the state of the fan module status LED + Args: + color: A string representing the color with which to set the + fan module status LED + Returns: + bool: True if status LED state is set successfully, False if not + """ + return False #Not supported + + def get_presence(self): + """ + Retrieves the presence of the FAN + Returns: + bool: True if FAN is present, False if not + """ + present_path = "{}{}{}".format(CPLD_I2C_PATH, 'present_', self.fan_index+1) + val=self._api_helper.read_txt_file(present_path) + if not self.is_psu_fan: + if val is not None: + return int(val, 10)==1 + else: + return False + else: + return True diff --git a/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/helper.py b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/helper.py new file mode 100644 index 000000000000..4cd60ac90611 --- /dev/null +++ b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/helper.py @@ -0,0 +1,117 @@ +import os +import struct +import subprocess +from mmap import * +from sonic_py_common import device_info + +HOST_CHK_CMD = "docker > /dev/null 2>&1" +EMPTY_STRING = "" + + +class APIHelper(): + + def __init__(self): + (self.platform, self.hwsku) = device_info.get_platform_and_hwsku() + + def is_host(self): + return os.system(HOST_CHK_CMD) == 0 + + def pci_get_value(self, resource, offset): + status = True + result = "" + try: + fd = os.open(resource, os.O_RDWR) + mm = mmap(fd, 0) + mm.seek(int(offset)) + read_data_stream = mm.read(4) + result = struct.unpack('I', read_data_stream) + except Exception: + status = False + return status, result + + def run_command(self, cmd): + status = True + result = "" + try: + p = subprocess.Popen( + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err == '': + result = raw_data.strip() + except Exception: + status = False + return status, result + + def run_interactive_command(self, cmd): + try: + os.system(cmd) + except Exception: + return False + return True + + 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 None + + def write_txt_file(self, file_path, value): + try: + with open(file_path, 'w') as fd: + fd.write(str(value)) + except IOError: + return False + return True + + def ipmi_raw(self, netfn, cmd): + status = True + result = "" + try: + cmd = "ipmitool raw {} {}".format(str(netfn), str(cmd)) + p = subprocess.Popen( + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err == '': + result = raw_data.strip() + else: + status = False + except Exception: + status = False + return status, result + + def ipmi_fru_id(self, id, key=None): + status = True + result = "" + try: + cmd = "ipmitool fru print {}".format(str( + id)) if not key else "ipmitool fru print {0} | grep '{1}' ".format(str(id), str(key)) + + p = subprocess.Popen( + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err == '': + result = raw_data.strip() + else: + status = False + except Exception: + status = False + return status, result + + def ipmi_set_ss_thres(self, id, threshold_key, value): + status = True + result = "" + try: + cmd = "ipmitool sensor thresh '{}' {} {}".format(str(id), str(threshold_key), str(value)) + p = subprocess.Popen( + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err == '': + result = raw_data.strip() + else: + status = False + except Exception: + status = False + return status, result diff --git a/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/platform.py b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/platform.py new file mode 100644 index 000000000000..2f2c2a447fcf --- /dev/null +++ b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/platform.py @@ -0,0 +1,21 @@ +############################################################################# +# Edgecore +# +# Module contains an implementation of SONiC Platform Base API and +# provides the platform information +# +############################################################################# + +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): + """Platform-specific Platform class""" + + def __init__(self): + PlatformBase.__init__(self) + self._chassis = Chassis() diff --git a/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/psu.py b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/psu.py new file mode 100644 index 000000000000..3413ab5779cc --- /dev/null +++ b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/psu.py @@ -0,0 +1,228 @@ +############################################################################# +# Edgecore +# +# Module contains an implementation of SONiC Platform Base API and +# provides the PSUs status which are available in the platform +# +############################################################################# + +#import sonic_platform + +try: + from sonic_platform_base.psu_base import PsuBase + #from sonic_platform.fan import Fan + from .helper import APIHelper +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +I2C_PATH ="/sys/bus/i2c/devices/{0}-00{1}/" + +PSU_NAME_LIST = ["PSU-1", "PSU-2"] +PSU_NUM_FAN = [1, 1] +PSU_HWMON_I2C_MAPPING = { + 0: { + "num": 10, + "addr": "58" + }, + 1: { + "num": 11, + "addr": "59" + }, +} + +PSU_CPLD_I2C_MAPPING = { + 0: { + "num": 10, + "addr": "50" + }, + 1: { + "num": 11, + "addr": "51" + }, +} + +class Psu(PsuBase): + """Platform-specific Psu class""" + + def __init__(self, psu_index=0): + PsuBase.__init__(self) + self.index = psu_index + self._api_helper = APIHelper() + + self.i2c_num = PSU_HWMON_I2C_MAPPING[self.index]["num"] + self.i2c_addr = PSU_HWMON_I2C_MAPPING[self.index]["addr"] + self.hwmon_path = I2C_PATH.format(self.i2c_num, self.i2c_addr) + + self.i2c_num = PSU_CPLD_I2C_MAPPING[self.index]["num"] + self.i2c_addr = PSU_CPLD_I2C_MAPPING[self.index]["addr"] + self.cpld_path = I2C_PATH.format(self.i2c_num, self.i2c_addr) + self.__initialize_fan() + ''' + for fan_index in range(0, PSU_NUM_FAN[self.index]): + #def __init__(self, fan_tray_index, fan_index=0, is_psu_fan=False, psu_index=0): + #fan = Fan(fan_index, 0, is_psu_fan=True, psu_index=self.index) + fan = Fan(fan_index, 0, True, self.index) + self._fan_list.append(fan) + ''' + + def __initialize_fan(self): + from sonic_platform.fan import Fan + for fan_index in range(0, PSU_NUM_FAN[self.index]): + fan = Fan(fan_index, 0, is_psu_fan=True, psu_index=self.index) + self._fan_list.append(fan) + + def get_voltage(self): + """ + Retrieves current PSU voltage output + Returns: + A float number, the output voltage in volts, + e.g. 12.1 + """ + vout_path = "{}{}".format(self.hwmon_path, 'psu_v_out') + vout_val=self._api_helper.read_txt_file(vout_path) + if vout_val is not None: + return float(vout_val)/ 1000 + else: + return 0 + + def get_current(self): + """ + Retrieves present electric current supplied by PSU + Returns: + A float number, the electric current in amperes, e.g 15.4 + """ + iout_path = "{}{}".format(self.hwmon_path, 'psu_i_out') + val=self._api_helper.read_txt_file(iout_path) + if val is not None: + return float(val)/1000 + else: + return 0 + + def get_power(self): + """ + Retrieves current energy supplied by PSU + Returns: + A float number, the power in watts, e.g. 302.6 + """ + pout_path = "{}{}".format(self.hwmon_path, 'psu_p_out') + val=self._api_helper.read_txt_file(pout_path) + if val is not None: + return float(val)/1000 + else: + return 0 + + def get_powergood_status(self): + """ + Retrieves the powergood status of PSU + Returns: + A boolean, True if PSU has stablized its output voltages and passed all + its internal self-tests, False if not. + """ + return self.get_status() + + def set_status_led(self, color): + """ + Sets the state of the PSU status LED + Args: + color: A string representing the color with which to set the PSU status LED + Note: Only support green and off + Returns: + bool: True if status LED state is set successfully, False if not + """ + + return False #Controlled by HW + + def get_status_led(self): + """ + Gets the state of the PSU status LED + Returns: + A string, one of the predefined STATUS_LED_COLOR_* strings above + """ + + return False #Controlled by HW + + def get_temperature(self): + """ + Retrieves current temperature reading from PSU + Returns: + A float number of current temperature in Celsius up to nearest thousandth + of one degree Celsius, e.g. 30.125 + """ + temp_path = "{}{}".format(self.hwmon_path, 'psu_temp1_input') + val=self._api_helper.read_txt_file(temp_path) + if val is not None: + return float(val)/1000 + else: + return 0 + + def get_temperature_high_threshold(self): + """ + Retrieves the high threshold temperature of PSU + Returns: + A float number, the high threshold temperature of PSU in Celsius + up to nearest thousandth of one degree Celsius, e.g. 30.125 + """ + return False #Not supported + + def get_voltage_high_threshold(self): + """ + Retrieves the high threshold PSU voltage output + Returns: + A float number, the high threshold output voltage in volts, + e.g. 12.1 + """ + vout_path = "{}{}".format(self.hwmon_path, 'psu_mfr_vout_max') + vout_val=self._api_helper.read_txt_file(vout_path) + if vout_val is not None: + return float(vout_val)/ 1000 + else: + return 0 + + def get_voltage_low_threshold(self): + """ + Retrieves the low threshold PSU voltage output + Returns: + A float number, the low threshold output voltage in volts, + e.g. 12.1 + """ + vout_path = "{}{}".format(self.hwmon_path, 'psu_mfr_vout_min') + vout_val=self._api_helper.read_txt_file(vout_path) + if vout_val is not None: + return float(vout_val)/ 1000 + else: + return 0 + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + return PSU_NAME_LIST[self.index] + + def get_presence(self): + """ + Retrieves the presence of the PSU + Returns: + bool: True if PSU is present, False if not + """ + presence_path="{}{}".format(self.cpld_path, 'psu_present') + val=self._api_helper.read_txt_file(presence_path) + if val is not None: + return int(val, 10) == 1 + else: + return 0 + + def get_status(self): + """ + Retrieves the operational status of the device + Returns: + A boolean value, True if device is operating properly, False if not + """ + power_path="{}{}".format(self.cpld_path, 'psu_power_good') + val=self._api_helper.read_txt_file(power_path) + if val is not None: + return int(val, 10) == 1 + else: + return 0 diff --git a/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/sfp.py b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/sfp.py new file mode 100644 index 000000000000..25e5bce8fe40 --- /dev/null +++ b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/sfp.py @@ -0,0 +1,1169 @@ +#!/usr/bin/env python + +############################################################################# +# Edgecore +# +# 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 sys + +from ctypes import create_string_buffer + +try: + from sonic_platform_base.sfp_base import SfpBase + from sonic_platform_base.sonic_sfp.sff8436 import sff8436Dom + from sonic_platform_base.sonic_sfp.sff8436 import sff8436InterfaceId + from sonic_platform_base.sonic_sfp.sff8472 import sff8472Dom + from sonic_platform_base.sonic_sfp.sff8472 import sff8472InterfaceId + #from sonic_platform_base.sonic_sfp.sff8472 import sffbase + from sonic_platform_base.sonic_sfp.sfputilhelper import SfpUtilHelper + from .helper import APIHelper +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + +CPLD_I2C_PATH = "/sys/bus/i2c/devices/3-0060/" + +QSFP_INFO_OFFSET = 128 +QSFP_DOM_OFFSET = 0 + +SFP_INFO_OFFSET = 0 +SFP_DOM_OFFSET = 256 + +XCVR_INTFACE_BULK_OFFSET = 0 +XCVR_INTFACE_BULK_WIDTH_QSFP = 20 +XCVR_INTFACE_BULK_WIDTH_SFP = 21 +XCVR_HW_REV_WIDTH_QSFP = 2 +XCVR_HW_REV_WIDTH_SFP = 4 +XCVR_CABLE_LENGTH_WIDTH_QSFP = 5 +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_OSFP = 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 = 1 + +# 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_CHANNL_MON_OFFSET = 34 +QSFP_CHANNL_MON_WIDTH = 16 +QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH = 24 +QSFP_CONTROL_OFFSET = 86 +QSFP_CONTROL_WIDTH = 8 +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_POWEROVERRIDE_OFFSET = 93 +QSFP_POWEROVERRIDE_WIDTH = 1 +QSFP_MODULE_THRESHOLD_OFFSET = 128 +QSFP_MODULE_THRESHOLD_WIDTH = 24 +QSFP_CHANNEL_THRESHOLD_OFFSET = 176 +QSFP_CHANNEL_THRESHOLD_WIDTH = 16 + +qsfp_cable_length_tup = ('Length(km)', 'Length OM3(2m)', + 'Length OM2(m)', 'Length OM1(m)', + 'Length Cable Assembly(m)') + +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') + + +# Offset for values in SFP eeprom +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 + +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') + + +class Sfp(SfpBase): + """Platform-specific Sfp class""" + + # Port number + PORT_START = 49 + PORT_END = 54 + + # Path to 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-accton_as4630_54te-r0" + HWSKU = "Accton-AS4630-54TE" + + _port_to_i2c_mapping = { + 49: 18, + 50: 19, + 51: 20, + 52: 21, + 53: 22, + 54: 23, + } + + def __init__(self, sfp_index=0): + self._api_helper=APIHelper() + # Init index + self.index = sfp_index + self.port_num = self.index + 1 + # Init eeprom path + eeprom_path = '/sys/bus/i2c/devices/{0}-0050/eeprom' + self.port_to_eeprom_mapping = {} + for x in range(self.PORT_START, self.PORT_END + 1): + self.port_to_eeprom_mapping[x] = eeprom_path.format(self._port_to_i2c_mapping[x]) + + 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'] + + 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 __write_txt_file(self, file_path, value): + try: + with open(file_path, 'w', buffering=0) as fd: + fd.write(str(value)) + except Exception: + return False + return True + + 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 __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) + if sys.version_info[0] >= 3: + for n in range(0, num_bytes): + eeprom_raw[n] = hex(raw[n])[2:].zfill(2) + else: + for n in range(0, num_bytes): + eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2) + except Exception: + pass + finally: + if sysfsfile_eeprom: + sysfsfile_eeprom.close() + + return eeprom_raw + + def get_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 + ======================================================================== + """ + # check present status + if self.port_num < 49: + return {} + elif self.port_num < 53: + sfpi_obj = sff8472InterfaceId() #SFP + else: + sfpi_obj = sff8436InterfaceId() #QSFP + if not self.get_presence() or not sfpi_obj: + return {} + + if self.port_num < 53: + offset = SFP_INFO_OFFSET + sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_INTFACE_BULK_OFFSET), XCVR_INTFACE_BULK_WIDTH_SFP) + else: + offset = QSFP_INFO_OFFSET + sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_INTFACE_BULK_OFFSET), XCVR_INTFACE_BULK_WIDTH_QSFP) + + sfp_interface_bulk_data = sfpi_obj.parse_sfp_info_bulk( + sfp_interface_bulk_raw, 0) + + sfp_vendor_name_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_VENDOR_NAME_OFFSET), XCVR_VENDOR_NAME_WIDTH) + sfp_vendor_name_data = sfpi_obj.parse_vendor_name( + sfp_vendor_name_raw, 0) + + sfp_vendor_pn_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_VENDOR_PN_OFFSET), XCVR_VENDOR_PN_WIDTH) + sfp_vendor_pn_data = sfpi_obj.parse_vendor_pn( + sfp_vendor_pn_raw, 0) + + if self.port_num < 53: + sfp_vendor_rev_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_HW_REV_OFFSET), XCVR_HW_REV_WIDTH_SFP) + else: + sfp_vendor_rev_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_HW_REV_OFFSET), XCVR_HW_REV_WIDTH_QSFP) + + sfp_vendor_rev_data = sfpi_obj.parse_vendor_rev( + sfp_vendor_rev_raw, 0) + + sfp_vendor_sn_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_VENDOR_SN_OFFSET), XCVR_VENDOR_SN_WIDTH) + sfp_vendor_sn_data = sfpi_obj.parse_vendor_sn( + sfp_vendor_sn_raw, 0) + + sfp_vendor_oui_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_VENDOR_OUI_OFFSET), XCVR_VENDOR_OUI_WIDTH) + if sfp_vendor_oui_raw is not None: + sfp_vendor_oui_data = sfpi_obj.parse_vendor_oui( + sfp_vendor_oui_raw, 0) + + sfp_vendor_date_raw = self.__read_eeprom_specific_bytes( + (offset + XCVR_VENDOR_DATE_OFFSET), XCVR_VENDOR_DATE_WIDTH) + sfp_vendor_date_data = sfpi_obj.parse_vendor_date( + sfp_vendor_date_raw, 0) + + transceiver_info_dict = dict.fromkeys(self.info_dict_keys, 'N/A') + compliance_code_dict = dict() + + if sfp_interface_bulk_data: + transceiver_info_dict['type'] = sfp_interface_bulk_data['data']['type']['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'] = sfp_interface_bulk_data['data']['type_abbrv_name']['value'] + + transceiver_info_dict['manufacturer'] = sfp_vendor_name_data[ + 'data']['Vendor Name']['value'] if sfp_vendor_name_data else 'N/A' + transceiver_info_dict['model'] = sfp_vendor_pn_data['data']['Vendor PN']['value'] if sfp_vendor_pn_data else 'N/A' + transceiver_info_dict['hardware_rev'] = sfp_vendor_rev_data['data']['Vendor Rev']['value'] if sfp_vendor_rev_data else 'N/A' + transceiver_info_dict['serial'] = sfp_vendor_sn_data['data']['Vendor SN']['value'] if sfp_vendor_sn_data else 'N/A' + transceiver_info_dict['vendor_oui'] = sfp_vendor_oui_data['data']['Vendor OUI']['value'] if sfp_vendor_oui_data else 'N/A' + transceiver_info_dict['vendor_date'] = sfp_vendor_date_data[ + 'data']['VendorDataCode(YYYY-MM-DD Lot)']['value'] if sfp_vendor_date_data else 'N/A' + transceiver_info_dict['cable_type'] = "Unknown" + transceiver_info_dict['cable_length'] = "Unknown" + + if self.port_num < 53: + 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']) + else: + 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']) + + + 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. + ======================================================================== + """ + # check present status + if self.port_num < 53: #SFP case + sfpd_obj = sff8472Dom() + if not self.get_presence() or not sfpd_obj: + return {} + + eeprom_ifraw = self.__read_eeprom_specific_bytes(0, SFP_DOM_OFFSET) + 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: #QSFP case + sfpd_obj = sff8436Dom() + sfpi_obj = sff8436InterfaceId() + + if not self.get_presence() or not sfpi_obj or not sfpd_obj: + return {} + + 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: + qspf_dom_capability_data = sfpi_obj.parse_qsfp_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 = qspf_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'] + #End of else + + + 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() + + 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. + ======================================================================== + """ + # check present status + if self.port_num < 53: + sfpd_obj = sff8472Dom() + + if not self.get_presence() and not sfpd_obj: + return {} + + eeprom_ifraw = self.__read_eeprom_specific_bytes(0, SFP_DOM_OFFSET) + sfpi_obj = sff8472InterfaceId(eeprom_ifraw) + cal_type = sfpi_obj.get_calibration_type() + sfpd_obj._calibration_type = cal_type + + offset = SFP_DOM_OFFSET + transceiver_dom_threshold_info_dict = dict.fromkeys( + self.threshold_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: + sfpd_obj = sff8436Dom() + + if not self.get_presence() or not sfpd_obj: + return {} + + transceiver_dom_threshold_dict = dict.fromkeys( + self.threshold_dict_keys, 'N/A') + dom_thres_raw = self.__read_eeprom_specific_bytes( + QSFP_MODULE_THRESHOLD_OFFSET, QSFP_MODULE_THRESHOLD_WIDTH) if self.get_presence() and sfpd_obj else None + + if dom_thres_raw: + module_threshold_values = sfpd_obj.parse_module_threshold_values( + dom_thres_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_thres_raw = self.__read_eeprom_specific_bytes( + QSFP_CHANNEL_THRESHOLD_OFFSET, QSFP_CHANNEL_THRESHOLD_WIDTH) if self.get_presence() and sfpd_obj else None + channel_threshold_values = sfpd_obj.parse_channel_threshold_values( + dom_thres_raw, 0) + channel_threshold_data = channel_threshold_values.get('data') + 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 + + def get_reset_status(self): + """ + Retrieves the reset status of SFP + Returns: + A Boolean, True if reset enabled, False if disabled + """ + if self.port_num < 49: #Copper port, no sysfs + return False + + return False # CPLD port doesn't support this feature + + + 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. + """ + rx_los = False + + if self.port_num < 49: #Copper port, no sysfs + return False + + if self.port_num < 53: + rx_path = "{}{}{}".format(CPLD_I2C_PATH, '/module_rx_los_', self.port_num) + rx_los=self._api_helper.read_txt_file(rx_path) + if rx_los is None: + return False + #status_control_raw = self.__read_eeprom_specific_bytes( + # SFP_STATUS_CONTROL_OFFSET, SFP_STATUS_CONTROL_WIDTH) + #if status_control_raw: + # data = int(status_control_raw[0], 16) + # rx_los = (sffbase().test_bit(data, 1) != 0) + + else: + rx_los_list = [] + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + QSFP_CHANNL_RX_LOS_STATUS_OFFSET, QSFP_CHANNL_RX_LOS_STATUS_WIDTH) if self.get_presence() else None + if dom_channel_monitor_raw is not None: + rx_los_data = int(dom_channel_monitor_raw[0], 16) + rx_los_list.append(rx_los_data & 0x01 != 0) + rx_los_list.append(rx_los_data & 0x02 != 0) + rx_los_list.append(rx_los_data & 0x04 != 0) + rx_los_list.append(rx_los_data & 0x08 != 0) + rx_los = rx_los_list[0] and rx_los_list[1] and rx_los_list[2] and rx_los_list[3] + return rx_los + + 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. + """ + tx_fault = False + if self.port_num < 49: #Copper port, no sysfs + return False + + if self.port_num < 53: + tx_path = "{}{}{}".format(CPLD_I2C_PATH, '/module_tx_fault_', self.port_num) + tx_fault=self._api_helper.read_txt_file(tx_path) + if tx_fault is None: + return False + #status_control_raw = self.__read_eeprom_specific_bytes( + # SFP_STATUS_CONTROL_OFFSET, SFP_STATUS_CONTROL_WIDTH) + #if status_control_raw: + # data = int(status_control_raw[0], 16) + # tx_fault = (sffbase().test_bit(data, 2) != 0) + else: + tx_fault_list = [] + dom_channel_monitor_raw = self.__read_eeprom_specific_bytes( + QSFP_CHANNL_TX_FAULT_STATUS_OFFSET, QSFP_CHANNL_TX_FAULT_STATUS_WIDTH) if self.get_presence() else None + if dom_channel_monitor_raw is not None: + tx_fault_data = int(dom_channel_monitor_raw[0], 16) + tx_fault_list.append(tx_fault_data & 0x01 != 0) + tx_fault_list.append(tx_fault_data & 0x02 != 0) + tx_fault_list.append(tx_fault_data & 0x04 != 0) + tx_fault_list.append(tx_fault_data & 0x08 != 0) + tx_fault = tx_fault_list[0] and tx_fault_list[1] and tx_fault_list[2] and tx_fault_list[3] + + return tx_fault + + 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 self.port_num < 49: #Copper port, no sysfs + return False + + if self.port_num < 53: + tx_disable = False + + tx_path = "{}{}{}".format(CPLD_I2C_PATH, '/module_tx_disable_', self.port_num) + tx_disable=self._api_helper.read_txt_file(tx_path) + + + #status_control_raw = self.__read_eeprom_specific_bytes( + # SFP_STATUS_CONTROL_OFFSET, SFP_STATUS_CONTROL_WIDTH) + #if status_control_raw: + # data = int(status_control_raw[0], 16) + # tx_disable_hard = (sffbase().test_bit( + # data, SFP_TX_DISABLE_HARD_BIT) != 0) + # tx_disable_soft = (sffbase().test_bit( + # data, SFP_TX_DISABLE_SOFT_BIT) != 0) + # tx_disable = tx_disable_hard | tx_disable_soft + if tx_disable is not None: + return tx_disable + else: + return False + + else: + tx_disable_list = [] + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return False + + dom_control_raw = self.__read_eeprom_specific_bytes( + QSFP_CONTROL_OFFSET, QSFP_CONTROL_WIDTH) if self.get_presence() else None + if dom_control_raw is not None: + dom_control_data = sfpd_obj.parse_control_bytes(dom_control_raw, 0) + tx_disable_list.append( + 'On' == dom_control_data['data']['TX1Disable']['value']) + tx_disable_list.append( + 'On' == dom_control_data['data']['TX2Disable']['value']) + tx_disable_list.append( + 'On' == dom_control_data['data']['TX3Disable']['value']) + tx_disable_list.append( + 'On' == dom_control_data['data']['TX4Disable']['value']) + + return tx_disable_list + + 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. + """ + if self.port_num < 53: + # SFP doesn't support this feature + return False + else: + tx_disable_list = self.get_tx_disable() + if tx_disable_list is None: + return 0 + tx_disabled = 0 + for i in range(len(tx_disable_list)): + if tx_disable_list[i]: + tx_disabled |= 1 << i + return tx_disabled + + def get_lpmode(self): + """ + Retrieves the lpmode (low power mode) status of this SFP + Returns: + A Boolean, True if lpmode is enabled, False if disabled + """ + if self.port_num < 53: + # SFP doesn't support this feature + return False + else: + power_set=self.get_power_set() + power_override = self.get_power_override() + return power_set and power_override + + + def get_power_set(self): + + if self.port_num < 53: + # SFP doesn't support this feature + return False + else: + power_set = False + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return False + + dom_control_raw = self.__read_eeprom_specific_bytes( + QSFP_POWEROVERRIDE_OFFSET, QSFP_CONTROL_WIDTH) if self.get_presence() else None + if dom_control_raw is not None: + dom_control_data = sfpd_obj.parse_control_bytes(dom_control_raw, 0) + power_set = ( + 'On' == dom_control_data['data']['PowerSet']['value']) + + return power_set + + def get_power_override(self): + """ + Retrieves the power-override status of this SFP + Returns: + A Boolean, True if power-override is enabled, False if disabled + """ + if self.port_num < 53: + return False # SFP doesn't support this feature + else: + power_override = False + + + sfpd_obj = sff8436Dom() + if sfpd_obj is None: + return False + + dom_control_raw = self.__read_eeprom_specific_bytes( + QSFP_POWEROVERRIDE_OFFSET, QSFP_CONTROL_WIDTH) if self.get_presence() else None + if dom_control_raw is not None: + dom_control_data = sfpd_obj.parse_control_bytes(dom_control_raw, 0) + power_override = ( + 'On' == dom_control_data['data']['PowerOverride']['value']) + + return power_override + + def get_temperature(self): + """ + Retrieves the temperature of this SFP + Returns: + An integer number of current temperature in Celsius + """ + transceiver_dom_info_dict = self.get_transceiver_bulk_status() + return transceiver_dom_info_dict.get("temperature", "N/A") + + def get_voltage(self): + """ + Retrieves the supply voltage of this SFP + Returns: + An integer number of supply voltage in mV + """ + transceiver_dom_info_dict = self.get_transceiver_bulk_status() + return transceiver_dom_info_dict.get("voltage", "N/A") + + 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'] + """ + transceiver_dom_info_dict = self.get_transceiver_bulk_status() + + tx1_bs = transceiver_dom_info_dict.get("tx1bias", "N/A") + if self.port_num < 53: + return [tx1_bs, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else [] + + tx2_bs = transceiver_dom_info_dict.get("tx2bias", "N/A") + tx3_bs = transceiver_dom_info_dict.get("tx3bias", "N/A") + tx4_bs = transceiver_dom_info_dict.get("tx4bias", "N/A") + return [tx1_bs, tx2_bs, tx3_bs, tx4_bs] if transceiver_dom_info_dict else [] + + 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'] + """ + transceiver_dom_info_dict = self.get_transceiver_bulk_status() + + rx1_pw = transceiver_dom_info_dict.get("rx1power", "N/A") + if self.port_num < 53: + return [rx1_pw, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else [] + rx2_pw = transceiver_dom_info_dict.get("rx2power", "N/A") + rx3_pw = transceiver_dom_info_dict.get("rx3power", "N/A") + rx4_pw = transceiver_dom_info_dict.get("rx4power", "N/A") + return [rx1_pw, rx2_pw, rx3_pw, rx4_pw] if transceiver_dom_info_dict else [] + + 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'] + """ + transceiver_dom_info_dict = self.get_transceiver_bulk_status() + tx1_pw = transceiver_dom_info_dict.get("tx1power", "N/A") + if self.port_num < 53: + return [tx1_pw, "N/A", "N/A", "N/A"] if transceiver_dom_info_dict else [] + tx2_pw = transceiver_dom_info_dict.get("tx2power", "N/A") + tx3_pw = transceiver_dom_info_dict.get("tx3power", "N/A") + tx4_pw = transceiver_dom_info_dict.get("tx4power", "N/A") + return [tx1_pw, tx2_pw, tx3_pw, tx4_pw] + + def reset(self): + """ + Reset SFP and return all user module settings to their default srate. + Returns: + A boolean, True if successful, False if not + """ + # Check for invalid port_num + if self.port_num < 49: #Copper port, no sysfs + return False + + ''' + reset_path = "{}{}{}".format(CPLD_I2C_PATH, 'module_reset_', self.port_num) + ret = self.__write_txt_file(reset_path, 1) + if ret is not True: + return ret + + time.sleep(0.01) + ret = self.__write_txt_file(reset_path, 0) + time.sleep(0.2) + + return ret + ''' + + return False #CPLD doens't support this feature + + def tx_disable(self, tx_disable): + """ + Disable SFP TX for all channels + Args: + tx_disable : A Boolean, True to enable tx_disable mode, False to disable + tx_disable mode. + Returns: + A boolean, True if tx_disable is set successfully, False if not + """ + if self.port_num < 49: #Copper port, no sysfs + return False + + if self.port_num < 53: + tx_path = "{}{}{}".format(CPLD_I2C_PATH, '/module_tx_disable_', self.port_num) + ret = self.__write_txt_file(tx_path, 1 if tx_disable else 0) + if ret is not None: + time.sleep(0.01) + return ret + else: + return False + + else: + if not self.get_presence(): + return False + sysfsfile_eeprom = None + try: + tx_disable_ctl = 0xf if tx_disable else 0x0 + buffer = create_string_buffer(1) + if sys.version_info[0] >= 3: + buffer[0] = tx_disable_ctl + else: + buffer[0] = chr(tx_disable_ctl) + # Write to eeprom + sysfsfile_eeprom = open( + self.port_to_eeprom_mapping[self.port_num], "r+b") + sysfsfile_eeprom.seek(QSFP_CONTROL_OFFSET) + sysfsfile_eeprom.write(buffer[0]) + except IOError as e: + print ('Error: unable to open file: ',str(e)) + return False + finally: + if sysfsfile_eeprom is not None: + sysfsfile_eeprom.close() + time.sleep(0.01) + return True + + def tx_disable_channel(self, channel, disable): + """ + Sets the tx_disable for specified SFP channels + Args: + channel : A hex of 4 bits (bit 0 to bit 3) which represent channel 0 to 3, + e.g. 0x5 for channel 0 and channel 2. + disable : A boolean, True to disable TX channels specified in channel, + False to enable + Returns: + A boolean, True if successful, False if not + """ + + if self.port_num < 53: + return False # SFP doesn't support this feature + else: + if not self.get_presence(): + return False + + sysfsfile_eeprom = None + try: + channel_state = self.get_tx_disable_channel() + + for i in range(4): + channel_mask = (1 << i) + if not (channel & channel_mask): + continue + + if disable: + channel_state |= channel_mask + else: + channel_state &= ~channel_mask + + buffer = create_string_buffer(1) + if sys.version_info[0] >= 3: + buffer[0] = channel_state + else: + buffer[0] = chr(channel_state) + # Write to eeprom + sysfsfile_eeprom = open( + self.port_to_eeprom_mapping[self.port_num], "r+b") + sysfsfile_eeprom.seek(QSFP_CONTROL_OFFSET) + sysfsfile_eeprom.write(buffer[0]) + except IOError as e: + print ('Error: unable to open file: ', str(e)) + return False + finally: + if sysfsfile_eeprom is not None: + sysfsfile_eeprom.close() + time.sleep(0.01) + return True + + def set_lpmode(self, lpmode): + """ + Sets the lpmode (low power mode) of SFP + Args: + lpmode: A Boolean, True to enable lpmode, False to disable it + Note : lpmode can be overridden by set_power_override + Returns: + A boolean, True if lpmode is set successfully, False if not + """ + if self.port_num < 53: + return False # SFP doesn't support this feature + else: + if lpmode is True: + self.set_power_override(True, True) + else: + self.set_power_override(False, False) + + return True + + def set_power_override(self, power_override, power_set): + """ + Sets SFP power level using power_override and power_set + Args: + power_override : + A Boolean, True to override set_lpmode and use power_set + to control SFP power, False to disable SFP power control + through power_override/power_set and use set_lpmode + to control SFP power. + power_set : + Only valid when power_override is True. + A Boolean, True to set SFP to low power mode, False to set + SFP to high power mode. + Returns: + A boolean, True if power-override and power_set are set successfully, + False if not + """ + if self.port_num < 53: + return False # SFP doesn't support this feature + else: + if not self.get_presence(): + return False + try: + power_override_bit = (1 << 0) if power_override else 0 + power_set_bit = (1 << 1) if power_set else (1 << 3) + + buffer = create_string_buffer(1) + if sys.version_info[0] >= 3: + buffer[0] = (power_override_bit | power_set_bit) + else: + buffer[0] = chr(power_override_bit | power_set_bit) + # Write to eeprom + with open(self.port_to_eeprom_mapping[self.port_num], "r+b") as fd: + fd.seek(QSFP_POWEROVERRIDE_OFFSET) + fd.write(buffer[0]) + time.sleep(0.01) + except Exception: + print ('Error: unable to open file: ', str(e)) + return False + return True + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + sfputil_helper = SfpUtilHelper() + sfputil_helper.read_porttab_mappings( + self.__get_path_to_port_config_file()) + name = sfputil_helper.logical[self.index] or "Unknown" + return name + + def get_presence(self): + """ + Retrieves the presence of the device + Returns: + bool: True if device is present, False if not + """ + if self.port_num < 49: #Copper port, no sysfs + return False + + present_path = "{}{}{}".format(CPLD_I2C_PATH, '/module_present_', self.port_num) + val=self._api_helper.read_txt_file(present_path) + if val is not None: + return int(val, 10)==1 + else: + return False + + def get_model(self): + """ + Retrieves the model number (or part number) of the device + Returns: + string: Model/part number of device + """ + transceiver_dom_info_dict = self.get_transceiver_info() + return transceiver_dom_info_dict.get("model", "N/A") + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + transceiver_dom_info_dict = self.get_transceiver_info() + return transceiver_dom_info_dict.get("serial", "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_presence() and self.get_transceiver_bulk_status() diff --git a/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/thermal.py b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/thermal.py new file mode 100644 index 000000000000..7a453c594fde --- /dev/null +++ b/device/accton/x86_64-accton_as4630_54te-r0/sonic_platform/thermal.py @@ -0,0 +1,145 @@ +############################################################################# +# Edgecore +# +# Thermal contains an implementation of SONiC Platform Base API and +# provides the thermal device status which are available in the platform +# +############################################################################# + +import os +import os.path +import glob + +try: + from sonic_platform_base.thermal_base import ThermalBase +except ImportError as e: + raise ImportError(str(e) + "- required module not found") + + +class Thermal(ThermalBase): + """Platform-specific Thermal class""" + + THERMAL_NAME_LIST = [] + SYSFS_PATH = "/sys/bus/i2c/devices" + + def __init__(self, thermal_index=0): + self.THERMAL_NAME_LIST = [] + self.SYSFS_PATH = "/sys/bus/i2c/devices" + self.index = thermal_index + # Add thermal name + self.THERMAL_NAME_LIST.append("Temp sensor 1") + self.THERMAL_NAME_LIST.append("Temp sensor 2") + self.THERMAL_NAME_LIST.append("Temp sensor 3") + + # Set hwmon path + i2c_path = { + 0: "14-0048/hwmon/hwmon*/", + 1: "24-004b/hwmon/hwmon*/", + 2: "25-004a/hwmon/hwmon*/" + }.get(self.index, None) + + self.hwmon_path = "{}/{}".format(self.SYSFS_PATH, i2c_path) + self.ss_key = self.THERMAL_NAME_LIST[self.index] + self.ss_index = 1 + + def __read_txt_file(self, file_path): + for filename in glob.glob(file_path): + try: + with open(filename, 'r') as fd: + data =fd.readline().rstrip() + return data + except IOError as e: + pass + + return None + + 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) + if raw_temp is not None: + return float(raw_temp)/1000 + else: + return 0 + + def __set_threshold(self, file_name, temperature): + temp_file_path = os.path.join(self.hwmon_path, file_name) + for filename in glob.glob(temp_file_path): + try: + with open(filename, 'w') as fd: + fd.write(str(temperature)) + return True + except IOError as e: + print("IOError") + + + 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 + """ + temp_file = "temp{}_max".format(self.ss_index) + return self.__get_temp(temp_file) + + def set_high_threshold(self, temperature): + """ + Sets the high threshold temperature of thermal + Args : + temperature: A float number up to nearest thousandth of one degree Celsius, + e.g. 30.125 + Returns: + A boolean, True if threshold is set successfully, False if not + """ + temp_file = "temp{}_max".format(self.ss_index) + temperature = temperature *1000 + self.__set_threshold(temp_file, temperature) + + return True + + def get_name(self): + """ + Retrieves the name of the thermal device + Returns: + string: The name of the thermal device + """ + return self.THERMAL_NAME_LIST[self.index] + + def get_presence(self): + """ + Retrieves the presence of the Thermal + Returns: + bool: True if Thermal is present, False if not + """ + temp_file = "temp{}_input".format(self.ss_index) + temp_file_path = os.path.join(self.hwmon_path, temp_file) + raw_txt = self.__read_txt_file(temp_file_path) + if raw_txt is not None: + return True + else: + return False + + def get_status(self): + """ + Retrieves the operational status of the device + Returns: + A boolean value, True if device is operating properly, False if not + """ + + file_str = "temp{}_input".format(self.ss_index) + file_path = os.path.join(self.hwmon_path, file_str) + raw_txt = self.__read_txt_file(file_path) + if raw_txt is None: + return False + else: + return int(raw_txt) != 0 diff --git a/platform/broadcom/one-image.mk b/platform/broadcom/one-image.mk index f557f17c7cea..fb67521acf6c 100644 --- a/platform/broadcom/one-image.mk +++ b/platform/broadcom/one-image.mk @@ -29,6 +29,7 @@ $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(DELL_S6000_PLATFORM_MODULE) \ $(ACCTON_AS6712_32X_PLATFORM_MODULE) \ $(ACCTON_AS7726_32X_PLATFORM_MODULE) \ $(ACCTON_AS4630_54PE_PLATFORM_MODULE) \ + $(ACCTON_AS4630_54TE_PLATFORM_MODULE) \ $(ACCTON_MINIPACK_PLATFORM_MODULE) \ $(ACCTON_AS5812_54X_PLATFORM_MODULE) \ $(ACCTON_AS5812_54T_PLATFORM_MODULE) \ diff --git a/platform/broadcom/platform-modules-accton.mk b/platform/broadcom/platform-modules-accton.mk index 395040d7561d..3ccf2d675cbd 100755 --- a/platform/broadcom/platform-modules-accton.mk +++ b/platform/broadcom/platform-modules-accton.mk @@ -10,6 +10,7 @@ ACCTON_AS7716_32XB_PLATFORM_MODULE_VERSION = 1.1 ACCTON_AS6712_32X_PLATFORM_MODULE_VERSION = 1.1 ACCTON_AS7726_32X_PLATFORM_MODULE_VERSION = 1.1 ACCTON_AS4630_54PE_PLATFORM_MODULE_VERSION = 1.1 +ACCTON_AS4630_54TE_PLATFORM_MODULE_VERSION = 1.1 ACCTON_MINIPACK_PLATFORM_MODULE_VERSION = 1.1 ACCTON_AS5812_54X_PLATFORM_MODULE_VERSION = 1.1 ACCTON_AS5812_54T_PLATFORM_MODULE_VERSION = 1.1 @@ -29,6 +30,7 @@ export ACCTON_AS7716_32XB_PLATFORM_MODULE_VERSION export ACCTON_AS6712_32X_PLATFORM_MODULE_VERSION export ACCTON_AS7726_32X_PLATFORM_MODULE_VERSION export ACCTON_AS4630_54PE_PLATFORM_MODULE_VERSION +export ACCTON_AS4630_54TE_PLATFORM_MODULE_VERSION export ACCTON_MINIPACK_PLATFORM_MODULE_VERSION export ACCTON_AS5812_54X_PLATFORM_MODULE_VERSION export ACCTON_AS5812_54T_PLATFORM_MODULE_VERSION @@ -84,6 +86,10 @@ ACCTON_AS4630_54PE_PLATFORM_MODULE = sonic-platform-accton-as4630-54pe_$(ACCTON_ $(ACCTON_AS4630_54PE_PLATFORM_MODULE)_PLATFORM = x86_64-accton_as4630_54pe-r0 $(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE),$(ACCTON_AS4630_54PE_PLATFORM_MODULE))) +ACCTON_AS4630_54TE_PLATFORM_MODULE = sonic-platform-accton-as4630-54te_$(ACCTON_AS4630_54TE_PLATFORM_MODULE_VERSION)_amd64.deb +$(ACCTON_AS4630_54TE_PLATFORM_MODULE)_PLATFORM = x86_64-accton_as4630_54te-r0 +$(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE),$(ACCTON_AS4630_54TE_PLATFORM_MODULE))) + ACCTON_MINIPACK_PLATFORM_MODULE = sonic-platform-accton-minipack_$(ACCTON_MINIPACK_PLATFORM_MODULE_VERSION)_amd64.deb $(ACCTON_MINIPACK_PLATFORM_MODULE)_PLATFORM = x86_64-accton_minipack-r0 $(eval $(call add_extra_package,$(ACCTON_AS7712_32X_PLATFORM_MODULE),$(ACCTON_MINIPACK_PLATFORM_MODULE))) diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/classes/__init__.py b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/classes/__init__.py new file mode 100755 index 000000000000..e69de29bb2d1 diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/classes/fanutil.py b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/classes/fanutil.py new file mode 100755 index 000000000000..121b8409a585 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/classes/fanutil.py @@ -0,0 +1,213 @@ +#!/usr/bin/env python +# Copyright (c) 2019 Edgecore Networks Corporation +# +# 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 +# +# THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT +# LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS +# FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. +# +# See the Apache Version 2.0 License for specific language governing +# permissions and limitations under the License. +# +# ------------------------------------------------------------------ +# HISTORY: +# mm/dd/yyyy (A.D.) +# 10/24/2019:Jostar craete for as4630_54te +# ------------------------------------------------------------------ + +try: + import logging +except ImportError as e: + raise ImportError('%s - required module not found' % str(e)) + + +class FanUtil(object): + """Platform-specific FanUtil class""" + + FAN_NUM_ON_MAIN_BROAD = 3 + FAN_NUM_1_IDX = 1 + FAN_NUM_2_IDX = 2 + FAN_NUM_3_IDX = 3 + + FAN_NODE_NUM_OF_MAP = 4 + FAN_NODE_FAULT_IDX_OF_MAP = 1 + FAN_NODE_DIR_IDX_OF_MAP = 2 + FAN_NODE_PRESENT_IDX_OF_MAP = 3 + FAN_NODE_SPEED_IDX_OF_MAP = 4 + + BASE_VAL_PATH = '/sys/bus/i2c/devices/3-0060/{0}' + FAN_DUTY_PATH = '/sys/bus/i2c/devices/3-0060/fan_duty_cycle_percentage' + + """ Dictionary where + key1 = fan id index (integer) starting from 1 + key2 = fan node index (interger) starting from 1 + value = path to fan device file (string) """ + _fan_device_path_mapping = {} + + _fan_device_node_mapping = { + (FAN_NUM_1_IDX, FAN_NODE_FAULT_IDX_OF_MAP): 'fan_fault_1', + (FAN_NUM_1_IDX, FAN_NODE_DIR_IDX_OF_MAP): 'fan_direction_1', + (FAN_NUM_1_IDX, FAN_NODE_PRESENT_IDX_OF_MAP): 'fan_present_1', + (FAN_NUM_1_IDX, FAN_NODE_SPEED_IDX_OF_MAP): 'fan1_input', + + + (FAN_NUM_2_IDX, FAN_NODE_FAULT_IDX_OF_MAP): 'fan_fault_2', + (FAN_NUM_2_IDX, FAN_NODE_DIR_IDX_OF_MAP): 'fan_direction_2', + (FAN_NUM_2_IDX, FAN_NODE_PRESENT_IDX_OF_MAP): 'fan_present_2', + (FAN_NUM_2_IDX, FAN_NODE_SPEED_IDX_OF_MAP): 'fan2_input', + + (FAN_NUM_3_IDX, FAN_NODE_FAULT_IDX_OF_MAP): 'fan_fault_3', + (FAN_NUM_3_IDX, FAN_NODE_DIR_IDX_OF_MAP): 'fan_direction_3', + (FAN_NUM_3_IDX, FAN_NODE_PRESENT_IDX_OF_MAP): 'fan_present_3', + (FAN_NUM_3_IDX, FAN_NODE_SPEED_IDX_OF_MAP): 'fan3_input', + } + + def _get_fan_device_node(self, fan_num, node_num): + return self._fan_device_node_mapping[(fan_num, node_num)] + + def _get_fan_node_val(self, fan_num, node_num): + if fan_num < self.FAN_NUM_1_IDX or fan_num > self.FAN_NUM_ON_MAIN_BROAD: + logging.debug('GET. Parameter error. fan_num:%d', fan_num) + return None + + if node_num < self.FAN_NODE_FAULT_IDX_OF_MAP or node_num > self.FAN_NODE_NUM_OF_MAP: + logging.debug('GET. Parameter error. node_num:%d', node_num) + return None + + device_path = self.get_fan_device_path(fan_num, node_num) + + try: + val_file = open(device_path, 'r') + except IOError as e: + logging.error('GET. unable to open file: %s', str(e)) + return None + + content = val_file.readline().rstrip() + if content == '': + logging.debug('GET. content is NULL. device_path:%s', device_path) + return None + + try: + val_file.close() + except Exception: + logging.debug( + 'GET. unable to close file. device_path:%s', + device_path) + return None + + return int(content) + + def _set_fan_node_val(self, fan_num, node_num, val): + if fan_num < self.FAN_NUM_1_IDX or fan_num > self.FAN_NUM_ON_MAIN_BROAD: + logging.debug('GET. Parameter error. fan_num:%d', fan_num) + return None + + if node_num < self.FAN_NODE_FAULT_IDX_OF_MAP or node_num > self.FAN_NODE_NUM_OF_MAP: + logging.debug('GET. Parameter error. node_num:%d', node_num) + return None + + content = str(val) + if content == '': + logging.debug('GET. content is NULL. device_path:%s', device_path) + return None + + device_path = self.get_fan_device_path(fan_num, node_num) + try: + val_file = open(device_path, 'w') + except IOError as e: + logging.error('GET. unable to open file: %s', str(e)) + return None + + val_file.write(content) + + try: + val_file.close() + except BaseException: + logging.debug( + 'GET. unable to close file. device_path:%s', + device_path) + return None + + return True + + def __init__(self): + fan_path = self.BASE_VAL_PATH + for fan_num in range( + self.FAN_NUM_1_IDX, + self.FAN_NUM_ON_MAIN_BROAD + 1): + for node_num in range( + self.FAN_NODE_FAULT_IDX_OF_MAP, + self.FAN_NODE_NUM_OF_MAP + 1): + self._fan_device_path_mapping[(fan_num, node_num)] = fan_path.format( + self._fan_device_node_mapping[(fan_num, node_num)]) + + def get_size_node_map(self): + return len(self._fan_device_node_mapping) + + def get_fan_device_path(self, fan_num, node_num): + return self._fan_device_path_mapping[(fan_num, node_num)] + + def get_fan_fault(self, fan_num): + return self._get_fan_node_val(fan_num, self.FAN_NODE_FAULT_IDX_OF_MAP) + + def get_fan_present(self, fan_num): + return self._get_fan_node_val( + fan_num, self.FAN_NODE_PRESENT_IDX_OF_MAP) + + def get_fan_dir(self, fan_num): + return self._get_fan_node_val(fan_num, self.FAN_NODE_DIR_IDX_OF_MAP) + + def get_fan_duty_cycle(self): + try: + val_file = open(self.FAN_DUTY_PATH) + except IOError as e: + print "Error: unable to open file: %s" % str(e) + return False + + content = val_file.readline().rstrip() + val_file.close() + + return int(content) + + def set_fan_duty_cycle(self, val): + try: + fan_file = open(self.FAN_DUTY_PATH, 'r+') + except IOError as e: + print "Error: unable to open file: %s" % str(e) + return False + + fan_file.write(str(val)) + fan_file.close() + return True + + def get_fan_speed(self, fan_num): + return self._get_fan_node_val(fan_num, self.FAN_NODE_SPEED_IDX_OF_MAP) + + def get_fan_status(self, fan_num): + if fan_num < self.FAN_NUM_1_IDX or fan_num > self.FAN_NUM_ON_MAIN_BROAD: + logging.debug('GET. Parameter error. fan_num, %d', fan_num) + return None + if self.get_fan_fault( + fan_num) == 0 and self.get_fan_present(fan_num) > 0: + return 1 + else: + logging.debug('GET. FAN fault. fan_num, %d', fan_num) + return 0 + + +def main(): + fan = FanUtil() + logging.debug('fan_duty_cycle=%d', fan.get_fan_duty_cycle()) + for i in range(1, 4): + logging.debug('fan-%d speed=%d', i, fan.get_fan_speed(i)) + logging.debug('fan-%d present=%d', i, fan.get_fan_present(i)) + logging.debug('fan-%d fault=%d', i, fan.get_fan_fault(i)) + logging.debug('fan-%d status=%d', i, fan.get_fan_status(i)) + + +if __name__ == '__main__': + main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/classes/thermalutil.py b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/classes/thermalutil.py new file mode 100755 index 000000000000..15947da12ee3 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/classes/thermalutil.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python +# Copyright (c) 2019 Edgecore Networks Corporation +# +# 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 +# +# THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT +# LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS +# FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. +# +# See the Apache Version 2.0 License for specific language governing +# permissions and limitations under the License. +# +# ------------------------------------------------------------------ +# HISTORY: +# mm/dd/yyyy (A.D.) +# 10/24/2019:Jostar craete for as4630_54te +# ------------------------------------------------------------------ + +try: + import logging + import glob +except ImportError as e: + raise ImportError('%s - required module not found' % str(e)) + + +class ThermalUtil(object): + """Platform-specific ThermalUtil class""" + THERMAL_NUM_MAX = 4 + THERMAL_NUM_1_IDX = 1 + THERMAL_NUM_2_IDX = 2 + THERMAL_NUM_3_IDX = 3 + THERMAL_NUM_4_IDX = 4 + + """ Dictionary where + key1 = thermal id index (integer) starting from 1 + value = path to fan device file (string) """ + + thermal_sysfspath = { + THERMAL_NUM_1_IDX: ["/sys/bus/i2c/devices/14-0048/hwmon/hwmon*/temp1_input"], + THERMAL_NUM_2_IDX: ["/sys/bus/i2c/devices/24-004b/hwmon/hwmon*/temp1_input"], + THERMAL_NUM_3_IDX: ["/sys/bus/i2c/devices/25-004a/hwmon/hwmon*/temp1_input"], + THERMAL_NUM_4_IDX: ["/sys/class/hwmon/hwmon1/temp1_input"], + } + + def _get_thermal_val(self, thermal_num): + if thermal_num < self.THERMAL_NUM_1_IDX or thermal_num > self.THERMAL_NUM_MAX: + logging.debug('GET. Parameter error. thermal_num, %d', thermal_num) + return None + + device_path = self.get_thermal_path(thermal_num) + for filename in glob.glob(device_path): + try: + val_file = open(filename, 'r') + except IOError as e: + logging.error('GET. unable to open file: %s', str(e)) + return None + content = val_file.readline().rstrip() + if content == '': + logging.debug( + 'GET. content is NULL. device_path:%s', + device_path) + return None + try: + val_file.close() + except BaseException: + logging.debug( + 'GET. unable to close file. device_path:%s', + device_path) + return None + + return int(content) + + return 0 + + def get_num_thermals(self): + return self.THERMAL_NUM_MAX + + def get_size_path_map(self): + return len(self.thermal_sysfspath) + + def get_thermal_path(self, thermal_num): + return self.thermal_sysfspath[thermal_num][0] + + +def main(): + ThermalUtil() + + +if __name__ == '__main__': + main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/Makefile b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/Makefile new file mode 100755 index 000000000000..1b5914d9e5aa --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/Makefile @@ -0,0 +1,19 @@ +ifneq ($(KERNELRELEASE),) +obj-m:= x86-64-accton-as4630-54te-cpld.o x86-64-accton-as4630-54te-psu.o \ + x86-64-accton-as4630-54te-leds.o ym2651y.o + +else +ifeq (,$(KERNEL_SRC)) +#$(error KERNEL_SRC is not defined) +KVERSION=3.16.0-8-amd64 +KERNEL_DIR = /usr/src/linux-headers-$(KVERSION)/ +KERNELDIR:=$(KERNEL_DIR) +else +KERNELDIR:=$(KERNEL_SRC) +endif +PWD:=$(shell pwd) +default: + $(MAKE) -C $(KERNELDIR) M=$(PWD) modules +clean: + rm -rf *.o *.mod.o *.mod.o *.mod.c *.ko .*cmd .tmp_versions Module.markers Module.symvers modules.order +endif 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 new file mode 100755 index 000000000000..98b855329c64 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-cpld.c @@ -0,0 +1,1106 @@ +/* + * Copyright (C) Jostar yang + * + * This module supports the accton cpld that hold the channel select + * mechanism for other i2c slave devices, such as SFP. + * This includes the: + * Accton as4630_54te CPLD + * + * Based on: + * pca954x.c from Kumar Gala + * Copyright (C) 2006 + * + * Based on: + * pca954x.c from Ken Harrenstien + * Copyright (C) 2004 Google, Inc. (Ken Harrenstien) + * + * Based on: + * i2c-virtual_cb.c from Brian Kuschak + * and + * pca9540.c from Jean Delvare . + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define I2C_RW_RETRY_COUNT 10 +#define I2C_RW_RETRY_INTERVAL 60 /* ms */ +#define FAN_DUTY_CYCLE_REG_MASK 0x1F +#define FAN_MAX_DUTY_CYCLE 100 +#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); +static struct mutex list_lock; + +struct cpld_client_node { + struct i2c_client *client; + struct list_head list; +}; + +enum cpld_type { + as4630_54te_cpld, +}; +enum fan_id { + FAN1_ID, + FAN2_ID, + FAN3_ID, +}; + +static const u8 fan_reg[] = { + 0x87, /* fan status, fan direction */ + 0x1A, /* fan PWM(for fan1 ,fan2) */ + 0x1B, /* fan PWM(for fan1 ,fan2) */ + 0x88, /* front fan1 speed(rpm) */ + 0x89, /* front fan2 speed(rpm) */ + 0x8A, /* front fan3 speed(rpm) */ + 0x20, /*fan fault*/ +}; + +struct as4630_54te_cpld_data { + enum cpld_type type; + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_fan_val[ARRAY_SIZE(fan_reg)]; /* Register value */ + int system_temp; /*In unit of mini-Celsius*/ + int sensors_found; +}; + + + +static const struct i2c_device_id as4630_54te_cpld_id[] = { + { "as4630_54te_cpld", as4630_54te_cpld}, + { } +}; +MODULE_DEVICE_TABLE(i2c, as4630_54te_cpld_id); + +#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 FAN_SPEED_RPM_ATTR_ID(index) FAN_SPEED_RPM_##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 + +enum as4630_54te_cpld_sysfs_attributes { + CPLD_VERSION, + ACCESS, + /* transceiver attributes */ + TRANSCEIVER_RXLOS_ATTR_ID(49), + TRANSCEIVER_RXLOS_ATTR_ID(50), + TRANSCEIVER_RXLOS_ATTR_ID(51), + TRANSCEIVER_RXLOS_ATTR_ID(52), + TRANSCEIVER_TXFAULT_ATTR_ID(49), + TRANSCEIVER_TXFAULT_ATTR_ID(50), + TRANSCEIVER_TXFAULT_ATTR_ID(51), + TRANSCEIVER_TXFAULT_ATTR_ID(52), + TRANSCEIVER_PRESENT_ATTR_ID(49), + TRANSCEIVER_PRESENT_ATTR_ID(50), + TRANSCEIVER_PRESENT_ATTR_ID(51), + TRANSCEIVER_PRESENT_ATTR_ID(52), + TRANSCEIVER_PRESENT_ATTR_ID(53), + TRANSCEIVER_PRESENT_ATTR_ID(54), + TRANSCEIVER_TXDISABLE_ATTR_ID(49), + TRANSCEIVER_TXDISABLE_ATTR_ID(50), + TRANSCEIVER_TXDISABLE_ATTR_ID(51), + TRANSCEIVER_TXDISABLE_ATTR_ID(52), + FAN_PRESENT_ATTR_ID(1), + FAN_PRESENT_ATTR_ID(2), + FAN_PRESENT_ATTR_ID(3), + FAN_SPEED_RPM_ATTR_ID(1), + FAN_SPEED_RPM_ATTR_ID(2), + FAN_SPEED_RPM_ATTR_ID(3), + FAN_DIRECTION_ID(1), + FAN_DIRECTION_ID(2), + FAN_DIRECTION_ID(3), + FAN_FAULT_ATTR_ID(1), + FAN_FAULT_ATTR_ID(2), + FAN_FAULT_ATTR_ID(3), + FAN_DUTY_CYCLE_PERCENTAGE, +}; + +/* sysfs attributes for hwmon + */ +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 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, + char *buf); +static int as4630_54te_cpld_read_internal(struct i2c_client *client, u8 reg); +static int as4630_54te_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value); + +/*fan sysfs*/ +static struct as4630_54te_cpld_data *as4630_54te_fan_update_device(struct device *dev); +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) \ + static SENSOR_DEVICE_ATTR(module_present_##index, S_IRUGO, show_status, NULL, MODULE_PRESENT_##index); \ + static SENSOR_DEVICE_ATTR(module_tx_disable_##index, S_IRUGO | S_IWUSR, show_status, set_tx_disable, MODULE_TXDISABLE_##index); \ + static SENSOR_DEVICE_ATTR(module_rx_los_##index, S_IRUGO, show_status, NULL, MODULE_RXLOS_##index); \ + static SENSOR_DEVICE_ATTR(module_tx_fault_##index, S_IRUGO, show_status, NULL, MODULE_TXFAULT_##index); + +#define DECLARE_SFP_TRANSCEIVER_ATTR(index) \ + &sensor_dev_attr_module_present_##index.dev_attr.attr, \ + &sensor_dev_attr_module_tx_disable_##index.dev_attr.attr, \ + &sensor_dev_attr_module_rx_los_##index.dev_attr.attr, \ + &sensor_dev_attr_module_tx_fault_##index.dev_attr.attr + +#define DECLARE_QSFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(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_present_##index.dev_attr.attr + + +#define DECLARE_FAN_SENSOR_DEV_ATTR(index) \ + static SENSOR_DEVICE_ATTR(fan_present_##index, S_IRUGO, fan_show_value, NULL, FAN_PRESENT_##index); \ + static SENSOR_DEVICE_ATTR(fan_fault_##index, S_IRUGO, fan_show_value, NULL, FAN_FAULT_##index); \ + static SENSOR_DEVICE_ATTR(fan_speed_rpm_##index, S_IRUGO, fan_show_value, NULL, FAN_SPEED_RPM_##index); \ + static SENSOR_DEVICE_ATTR(fan##index##_input, S_IRUGO, fan_show_value, NULL, FAN_SPEED_RPM_##index);\ + static SENSOR_DEVICE_ATTR(fan_direction_##index, S_IRUGO, fan_show_value, NULL, FAN_DIRECTION_##index); + +#define DECLARE_FAN_ATTR(index) \ + &sensor_dev_attr_fan_present_##index.dev_attr.attr, \ + &sensor_dev_attr_fan_fault_##index.dev_attr.attr, \ + &sensor_dev_attr_fan_speed_rpm_##index.dev_attr.attr, \ + &sensor_dev_attr_fan##index##_input.dev_attr.attr, \ + &sensor_dev_attr_fan_direction_##index.dev_attr.attr + +#define DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(index) \ + 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); + + + +/* transceiver attributes */ +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(49); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(50); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(51); +DECLARE_SFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(52); +DECLARE_QSFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(53); +DECLARE_QSFP_TRANSCEIVER_SENSOR_DEVICE_ATTR(54); +/* fan attributes */ +DECLARE_FAN_SENSOR_DEV_ATTR(1); +DECLARE_FAN_SENSOR_DEV_ATTR(2); +DECLARE_FAN_SENSOR_DEV_ATTR(3); +DECLARE_FAN_DUTY_CYCLE_SENSOR_DEV_ATTR(1); + +static struct attribute *as4630_54te_cpld_attributes[] = { + &sensor_dev_attr_version.dev_attr.attr, + &sensor_dev_attr_access.dev_attr.attr, + DECLARE_SFP_TRANSCEIVER_ATTR(49), + DECLARE_SFP_TRANSCEIVER_ATTR(50), + DECLARE_SFP_TRANSCEIVER_ATTR(51), + DECLARE_SFP_TRANSCEIVER_ATTR(52), + DECLARE_QSFP_TRANSCEIVER_ATTR(53), + DECLARE_QSFP_TRANSCEIVER_ATTR(54), + DECLARE_FAN_ATTR(1), + DECLARE_FAN_ATTR(2), + DECLARE_FAN_ATTR(3), + DECLARE_FAN_DUTY_CYCLE_ATTR(1), + NULL +}; + +static const struct attribute_group as4630_54te_cpld_group = { + .attrs = as4630_54te_cpld_attributes, +}; + + +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + 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); + int status = 0; + u8 reg = 0, mask = 0, revert = 0; + + switch (attr->index) + { + case MODULE_RXLOS_49 ... MODULE_RXLOS_50: + reg=0x5; + mask = 0x1<< (attr->index==MODULE_RXLOS_49?4:0); + break; + case MODULE_TXFAULT_49 ... MODULE_TXFAULT_50: + reg=0x5; + mask=0x1 << (attr->index==MODULE_TXFAULT_49?5:1); + break; + case MODULE_PRESENT_49 ... MODULE_PRESENT_50: + reg=0x5; + mask=0x1 << (attr->index==MODULE_PRESENT_49?6:2); + break; + case MODULE_TXDISABLE_49 ... MODULE_TXDISABLE_50: + reg=0x5; + mask=0x1 << (attr->index==MODULE_TXFAULT_49?7:3); + break; + + case MODULE_RXLOS_51 ... MODULE_RXLOS_52: + reg=0x6; + mask = 0x1<< (attr->index==MODULE_RXLOS_51?4:0); + break; + case MODULE_TXFAULT_51 ... MODULE_TXFAULT_52: + reg=0x6; + mask=0x1 << (attr->index==MODULE_TXFAULT_51?5:1); + break; + case MODULE_PRESENT_51 ... MODULE_PRESENT_52: + reg=0x6; + mask=0x1 << (attr->index==MODULE_PRESENT_51?6:2); + break; + case MODULE_TXDISABLE_51 ... MODULE_TXDISABLE_52: + reg=0x6; + mask=0x1 << (attr->index==MODULE_TXFAULT_51?7:3); + break; + case MODULE_PRESENT_53 ... MODULE_PRESENT_54: + reg=0x21; + mask=0x1 << (attr->index==MODULE_PRESENT_53?0:4); + break; + default: + return 0; + } + + if( attr->index >= MODULE_PRESENT_49 && attr->index <= MODULE_PRESENT_54 ) + { + revert = 1; + } + + mutex_lock(&data->update_lock); + status = as4630_54te_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", revert ? !(status & mask) : !!(status & mask)); + +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) +{ + 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; + + status = kstrtol(buf, 10, &disable); + if (status) { + return status; + } + reg = 0x9; + switch (attr->index) + { + case MODULE_TXDISABLE_49 ... MODULE_TXDISABLE_50: + reg=0x5; + mask=0x1 << (attr->index==MODULE_TXFAULT_49?7:3); + break; + case MODULE_TXDISABLE_51 ... MODULE_TXDISABLE_52: + reg=0x6; + mask=0x1 << (attr->index==MODULE_TXFAULT_51?7:3); + break; + + default: + return 0; + } + + /* Read current status */ + mutex_lock(&data->update_lock); + status = as4630_54te_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + /* Update tx_disable status */ + 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 access(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int status; + u32 addr, val; + struct i2c_client *client = to_i2c_client(dev); + struct as4630_54te_cpld_data *data = i2c_get_clientdata(client); + + if (sscanf(buf, "0x%x 0x%x", &addr, &val) != 2) { + return -EINVAL; + } + + if (addr > 0xFF || val > 0xFF) { + return -EINVAL; + } + + mutex_lock(&data->update_lock); + status = as4630_54te_cpld_write_internal(client, addr, val); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + return count; + +exit: + mutex_unlock(&data->update_lock); + return status; +} + +static void as4630_54te_cpld_add_client(struct i2c_client *client) +{ + struct cpld_client_node *node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); + + if (!node) { + dev_dbg(&client->dev, "Can't allocate cpld_client_node (0x%x)\n", client->addr); + return; + } + + node->client = client; + + mutex_lock(&list_lock); + list_add(&node->list, &cpld_client_list); + mutex_unlock(&list_lock); +} + +static void as4630_54te_cpld_remove_client(struct i2c_client *client) +{ + struct list_head *list_node = NULL; + struct cpld_client_node *cpld_node = NULL; + int found = 0; + + 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 == client) { + found = 1; + break; + } + } + + if (found) { + list_del(list_node); + kfree(cpld_node); + } + + mutex_unlock(&list_lock); +} + +static ssize_t show_version(struct device *dev, struct device_attribute *attr, char *buf) +{ + int val = 0; + struct i2c_client *client = to_i2c_client(dev); + + val = i2c_smbus_read_byte_data(client, 0x1); + + if (val < 0) { + dev_dbg(&client->dev, "cpld(0x%x) reg(0x1) err %d\n", client->addr, val); + } + + return sprintf(buf, "%d\n", val); +} + +/* fan utility functions + */ +static u32 reg_val_to_duty_cycle(u8 reg_val) +{ + reg_val &= FAN_DUTY_CYCLE_REG_MASK; + return ((u32)(reg_val) * 625)/ 100; +} + +static u8 duty_cycle_to_reg_val(u8 duty_cycle) +{ + return ((u32)duty_cycle * 100 / 625); +} + +static u32 reg_val_to_speed_rpm(u8 reg_val) +{ + return (u32)reg_val * FAN_REG_VAL_TO_SPEED_RPM_STEP; +} + +static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + int error, value; + struct i2c_client *client = to_i2c_client(dev); + + error = kstrtoint(buf, 10, &value); + if (error) + return error; + + if (value < 0 || value > FAN_MAX_DUTY_CYCLE) + return -EINVAL; + + as4630_54te_cpld_write_internal(client, fan_reg[1], duty_cycle_to_reg_val(value)); + as4630_54te_cpld_write_internal(client, fan_reg[2], duty_cycle_to_reg_val(value)); + return count; +} + +static u8 reg_val_to_direction(u8 reg_val, enum fan_id id) +{ + u8 mask = (1 << id); + + reg_val &= mask; + + return reg_val ? 1 : 0; +} + +static u8 reg_val_to_is_present(u8 reg_val, enum fan_id id) +{ + u8 mask = (1 << id); + + reg_val &= mask; + + return reg_val ? 0 : 1; +} + +static u8 is_fan_fault(struct as4630_54te_cpld_data *data, enum fan_id id) +{ + u8 ret = 1; + + if(id > FAN3_ID) + return 1; + /* Check if the speed of front or rear fan is ZERO, + */ + if (reg_val_to_speed_rpm(data->reg_fan_val[id+3])) + { + + ret = 0; + } + + 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) +{ + u32 duty_cycle; + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as4630_54te_cpld_data *data = as4630_54te_fan_update_device(dev); + ssize_t ret = 0; + + if (data->valid) { + switch (attr->index) + { + case FAN_PRESENT_1: + case FAN_PRESENT_2: + case FAN_PRESENT_3: + ret = sprintf(buf, "%d\n", + reg_val_to_is_present(data->reg_fan_val[0], + attr->index - FAN_PRESENT_1)); + break; + case FAN_DUTY_CYCLE_PERCENTAGE: + duty_cycle = reg_val_to_duty_cycle(data->reg_fan_val[1]); + ret = sprintf(buf, "%u\n", duty_cycle); + break; + case FAN_SPEED_RPM_1: + case FAN_SPEED_RPM_2: + case FAN_SPEED_RPM_3: + ret = sprintf(buf, "%u\n", reg_val_to_speed_rpm(data->reg_fan_val[attr->index-FAN_SPEED_RPM_1+3])); + break; + case FAN_FAULT_1: + case FAN_FAULT_2: + case FAN_FAULT_3: + ret = sprintf(buf, "%d\n", is_fan_fault(data, attr->index - FAN_FAULT_1)); + break; + case FAN_DIRECTION_1: + case FAN_DIRECTION_2: + case FAN_DIRECTION_3: + ret = sprintf(buf, "%d\n", + reg_val_to_direction(data->reg_fan_val[0], + attr->index - FAN_DIRECTION_1)); + break; + default: + break; + } + } + + return ret; +} + +static struct as4630_54te_cpld_data *as4630_54te_fan_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as4630_54te_cpld_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || + !data->valid) { + int i; + + dev_dbg(&client->dev, "Starting as4630_54te_fan update\n"); + data->valid = 0; + + /* Update fan data + */ + for (i = 0; i < ARRAY_SIZE(data->reg_fan_val); i++) { + int status = as4630_54te_cpld_read_internal(client, fan_reg[i]); + if (status < 0) { + data->valid = 0; + mutex_unlock(&data->update_lock); + dev_dbg(&client->dev, "reg 0x%x, err %d\n", fan_reg[i], status); + return data; + } + else { + data->reg_fan_val[i] = status & 0xff; + } + } + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +/* +static ssize_t show_power(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as4630_54te_cpld_data *data = i2c_get_clientdata(client); + int status = 0; + u8 reg = 0, mask = 0; + + reg=0xc; + mask=0x2; + mutex_lock(&data->update_lock); + status = as4630_54te_cpld_read_internal(client, reg); + if (unlikely(status < 0)) { + goto exit; + } + mutex_unlock(&data->update_lock); + + return sprintf(buf, "%d\n", !(status & mask)); + +exit: + mutex_unlock(&data->update_lock); + return status; +} +*/ +/* + * I2C init/probing/exit functions + */ +static int as4630_54te_cpld_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); + struct as4630_54te_cpld_data *data; + int ret = -ENODEV; +// int status; + const struct attribute_group *group = NULL; + + if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE)) + goto exit; + + data = kzalloc(sizeof(struct as4630_54te_cpld_data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + mutex_init(&data->update_lock); + data->type = id->driver_data; + + /* Register sysfs hooks */ + switch (data->type) + { + case as4630_54te_cpld: + group = &as4630_54te_cpld_group; + break; + default: + break; + } + + if (group) + { + ret = sysfs_create_group(&client->dev.kobj, group); + if (ret) { + goto exit_free; + } + } + + as4630_54te_cpld_add_client(client); + + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + ret = PTR_ERR(data->hwmon_dev); + goto exit_free; + } + + + return 0; + +exit_free: + kfree(data); +exit: + return ret; +} + +static int as4630_54te_cpld_remove(struct i2c_client *client) +{ + struct as4630_54te_cpld_data *data = i2c_get_clientdata(client); + const struct attribute_group *group = NULL; + + as4630_54te_cpld_remove_client(client); + + /* Remove sysfs hooks */ + switch (data->type) + { + case as4630_54te_cpld: + group = &as4630_54te_cpld_group; + break; + default: + break; + } + + if (group) { + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, group); + } + + + kfree(data); + + return 0; +} + +static int as4630_54te_cpld_read_internal(struct i2c_client *client, u8 reg) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_read_byte_data(client, reg); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +static int as4630_54te_cpld_write_internal(struct i2c_client *client, u8 reg, u8 value) +{ + int status = 0, retry = I2C_RW_RETRY_COUNT; + + while (retry) { + status = i2c_smbus_write_byte_data(client, reg, value); + if (unlikely(status < 0)) { + msleep(I2C_RW_RETRY_INTERVAL); + retry--; + continue; + } + + break; + } + + return status; +} + +int as4630_54te_cpld_read(unsigned short cpld_addr, 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) { + ret = as4630_54te_cpld_read_internal(cpld_node->client, reg); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as4630_54te_cpld_read); + +int as4630_54te_cpld_write(unsigned short cpld_addr, 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) { + ret = as4630_54te_cpld_write_internal(cpld_node->client, reg, value); + break; + } + } + + mutex_unlock(&list_lock); + + return ret; +} +EXPORT_SYMBOL(as4630_54te_cpld_write); + +static struct i2c_driver as4630_54te_cpld_driver = { + .driver = { + .name = "as4630_54te_cpld", + .owner = THIS_MODULE, + }, + .probe = as4630_54te_cpld_probe, + .remove = as4630_54te_cpld_remove, + .id_table = as4630_54te_cpld_id, +}; + +static int __init as4630_54te_cpld_init(void) +{ + mutex_init(&list_lock); + return i2c_add_driver(&as4630_54te_cpld_driver); +} + +static void __exit as4630_54te_cpld_exit(void) +{ + i2c_del_driver(&as4630_54te_cpld_driver); +} + +MODULE_AUTHOR("Jostar Yang "); +MODULE_DESCRIPTION("Accton I2C CPLD driver"); +MODULE_LICENSE("GPL"); + +module_init(as4630_54te_cpld_init); +module_exit(as4630_54te_cpld_exit); + diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-leds.c b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-leds.c new file mode 100755 index 000000000000..f4e2668348ff --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-leds.c @@ -0,0 +1,579 @@ +/* + * A LED driver for the accton_as4630_54te_led + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/*#define DEBUG*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +extern int as4630_54te_cpld_read (unsigned short cpld_addr, u8 reg); +extern int as4630_54te_cpld_write(unsigned short cpld_addr, u8 reg, u8 value); + +#define DRVNAME "accton_as4630_54te_led" + +struct accton_as4630_54te_led_data { + struct platform_device *pdev; + struct mutex update_lock; + char valid; /* != 0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 reg_val[2]; /* only 1 register*/ +}; + +static struct accton_as4630_54te_led_data *ledctl = NULL; + +/* LED related data + */ + +#define LED_CNTRLER_I2C_ADDRESS (0x60) + +#define LED_TYPE_DIAG_REG_MASK (0x20|0x40|0x80) +#define LED_MODE_DIAG_GREEN_VALUE (0x20) +#define LED_MODE_DIAG_GREEN_BLINK_VALUE (0x60) +#define LED_MODE_DIAG_AMBER_VALUE (0x80) /*It's yellow actually. Green+Red=Yellow*/ +#define LED_MODE_DIAG_OFF_VALUE (0x0) + +#define LED_TYPE_PRI_REG_MASK (0x8|0x4) +#define LED_MODE_PRI_GREEN_VALUE 0x4 +#define LED_MODE_PRI_AMBER_VALUE 0x8 +#define LED_MODE_PRI_OFF_VALUE 0x0 + +#define LED_TYPE_POE_REG_MASK (0x2|0x1) +#define LED_MODE_POE_GREEN_VALUE 0x1 +#define LED_MODE_POE_AMBER_VALUE 0x2 +#define LED_MODE_POE_OFF_VALUE 0x0 + +#define LED_TYPE_STK1_REG_MASK 0x20 +#define LED_MODE_STK1_GREEN_VALUE 0x0 +#define LED_MODE_STK1_OFF_VALUE 0x20 + +#define LED_TYPE_STK2_REG_MASK 0x10 +#define LED_MODE_STK2_GREEN_VALUE 0x0 +#define LED_MODE_STK2_OFF_VALUE 0x10 + +#define LED_TYPE_FAN_REG_MASK (0x20|0x10) +#define LED_MODE_FAN_AMBER_VALUE 0x20 +#define LED_MODE_FAN_GREEN_VALUE 0x10 +#define LED_MODE_FAN_OFF_VALUE (0x0) + +#define LED_TYPE_PSU2_REG_MASK (0x8|0x4) +#define LED_MODE_PSU2_AMBER_VALUE 0x8 +#define LED_MODE_PSU2_GREEN_VALUE 0x4 +#define LED_MODE_PSU2_OFF_VALUE (0x0) + +#define LED_TYPE_PSU1_REG_MASK (0x2|0x1) +#define LED_MODE_PSU1_AMBER_VALUE 0x2 +#define LED_MODE_PSU1_GREEN_VALUE 0x1 +#define LED_MODE_PSU1_OFF_VALUE (0x0) + +enum led_type { + LED_TYPE_DIAG, + LED_TYPE_PRI, + LED_TYPE_POE, + LED_TYPE_STK1, + LED_TYPE_STK2, + LED_TYPE_FAN, + LED_TYPE_PSU1, + LED_TYPE_PSU2 +}; + +struct led_reg { + u32 types; + u8 reg_addr; +}; + +static const struct led_reg led_reg_map[] = { + {(1<update_lock); + + if (time_after(jiffies, ledctl->last_updated + HZ + HZ / 2) + || !ledctl->valid) { + int i; + + dev_dbg(&ledctl->pdev->dev, "Starting accton_as4630_54te_led update\n"); + + /* Update LED data + */ + for (i = 0; i < ARRAY_SIZE(ledctl->reg_val); i++) { + int status = accton_as4630_54te_led_read_value(led_reg_map[i].reg_addr); + + if (status < 0) { + ledctl->valid = 0; + dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", led_reg_map[i].reg_addr, status); + goto exit; + } + else + { + ledctl->reg_val[i] = status; + } + } + + ledctl->last_updated = jiffies; + ledctl->valid = 1; + } + +exit: + mutex_unlock(&ledctl->update_lock); +} + +static void accton_as4630_54te_led_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode, + enum led_type type) +{ + int reg_val; + u8 reg ; + mutex_lock(&ledctl->update_lock); + + if( !accton_getLedReg(type, ®)) + { + dev_dbg(&ledctl->pdev->dev, "Not match item for %d.\n", type); + } + + + reg_val = accton_as4630_54te_led_read_value(reg); + if (reg_val < 0) { + dev_dbg(&ledctl->pdev->dev, "reg %d, err %d\n", reg, reg_val); + goto exit; + } + reg_val = led_light_mode_to_reg_val(type, led_light_mode, reg_val); + + accton_as4630_54te_led_write_value(reg, reg_val); + + /* to prevent the slow-update issue */ + ledctl->valid = 0; + +exit: + mutex_unlock(&ledctl->update_lock); +} + + +static void accton_as4630_54te_led_diag_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as4630_54te_led_set(led_cdev, led_light_mode, LED_TYPE_DIAG); +} + +static enum led_brightness accton_as4630_54te_led_diag_get(struct led_classdev *cdev) +{ + accton_as4630_54te_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_DIAG, ledctl->reg_val[0]); +} + +static void accton_as4630_54te_led_pri_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as4630_54te_led_set(led_cdev, led_light_mode, LED_TYPE_PRI); +} + +static enum led_brightness accton_as4630_54te_led_pri_get(struct led_classdev *cdev) +{ + accton_as4630_54te_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_PRI, ledctl->reg_val[0]); +} + +static void accton_as4630_54te_led_poe_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as4630_54te_led_set(led_cdev, led_light_mode, LED_TYPE_POE); +} + +static enum led_brightness accton_as4630_54te_led_poe_get(struct led_classdev *cdev) +{ + accton_as4630_54te_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_POE, ledctl->reg_val[1]); +} + + +static void accton_as4630_54te_led_stk1_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as4630_54te_led_set(led_cdev, led_light_mode, LED_TYPE_STK1); +} + +static enum led_brightness accton_as4630_54te_led_stk1_get(struct led_classdev *cdev) +{ + accton_as4630_54te_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_STK1, ledctl->reg_val[1]); +} + +static void accton_as4630_54te_led_stk2_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as4630_54te_led_set(led_cdev, led_light_mode, LED_TYPE_STK2); +} + +static enum led_brightness accton_as4630_54te_led_stk2_get(struct led_classdev *cdev) +{ + accton_as4630_54te_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_STK2, ledctl->reg_val[1]); +} + +static void accton_as4630_54te_led_fan_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as4630_54te_led_set(led_cdev, led_light_mode, LED_TYPE_FAN); +} + +static enum led_brightness accton_as4630_54te_led_fan_get(struct led_classdev *cdev) +{ + accton_as4630_54te_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_FAN, ledctl->reg_val[0]); +} + +static void accton_as4630_54te_led_psu1_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as4630_54te_led_set(led_cdev, led_light_mode, LED_TYPE_PSU1); +} + +static enum led_brightness accton_as4630_54te_led_psu1_get(struct led_classdev *cdev) +{ + accton_as4630_54te_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_PSU1, ledctl->reg_val[0]); +} + +static void accton_as4630_54te_led_psu2_set(struct led_classdev *led_cdev, + enum led_brightness led_light_mode) +{ + accton_as4630_54te_led_set(led_cdev, led_light_mode, LED_TYPE_PSU2); +} + +static enum led_brightness accton_as4630_54te_led_psu2_get(struct led_classdev *cdev) +{ + accton_as4630_54te_led_update(); + return led_reg_val_to_light_mode(LED_TYPE_PSU2, ledctl->reg_val[0]); +} + +static struct led_classdev accton_as4630_54te_leds[] = { + [LED_TYPE_DIAG] = { + .name = "diag", + .default_trigger = "unused", + .brightness_set = accton_as4630_54te_led_diag_set, + .brightness_get = accton_as4630_54te_led_diag_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_GREEN, + }, + [LED_TYPE_PRI] = { + .name = "pri", + .default_trigger = "unused", + .brightness_set = accton_as4630_54te_led_pri_set, + .brightness_get = accton_as4630_54te_led_pri_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AMBER, + }, + [LED_TYPE_POE] = { + .name = "poe", + .default_trigger = "unused", + .brightness_set = accton_as4630_54te_led_poe_set, + .brightness_get = accton_as4630_54te_led_poe_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AMBER, + }, + [LED_TYPE_STK1] = { + .name = "stk1", + .default_trigger = "unused", + .brightness_set = accton_as4630_54te_led_stk1_set, + .brightness_get = accton_as4630_54te_led_stk1_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_GREEN, + }, + [LED_TYPE_STK2] = { + .name = "stk2", + .default_trigger = "unused", + .brightness_set = accton_as4630_54te_led_stk2_set, + .brightness_get = accton_as4630_54te_led_stk2_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_GREEN, + }, + [LED_TYPE_FAN] = { + .name = "fan", + .default_trigger = "unused", + .brightness_set = accton_as4630_54te_led_fan_set, + .brightness_get = accton_as4630_54te_led_fan_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_PSU1] = { + .name = "psu1", + .default_trigger = "unused", + .brightness_set = accton_as4630_54te_led_psu1_set, + .brightness_get = accton_as4630_54te_led_psu1_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AUTO, + }, + [LED_TYPE_PSU2] = { + .name = "psu2", + .default_trigger = "unused", + .brightness_set = accton_as4630_54te_led_psu2_set, + .brightness_get = accton_as4630_54te_led_psu2_get, + .flags = LED_CORE_SUSPENDRESUME, + .max_brightness = LED_MODE_AUTO, + }, +}; + +static int accton_as4630_54te_led_suspend(struct platform_device *dev, + pm_message_t state) +{ + int i = 0; + + for (i = 0; i < ARRAY_SIZE(accton_as4630_54te_leds); i++) { + led_classdev_suspend(&accton_as4630_54te_leds[i]); + } + + return 0; +} + +static int accton_as4630_54te_led_resume(struct platform_device *dev) +{ + int i = 0; + + for (i = 0; i < ARRAY_SIZE(accton_as4630_54te_leds); i++) { + led_classdev_resume(&accton_as4630_54te_leds[i]); + } + + return 0; +} + +static int accton_as4630_54te_led_probe(struct platform_device *pdev) +{ + int ret, i; + + for (i = 0; i < ARRAY_SIZE(accton_as4630_54te_leds); i++) { + ret = led_classdev_register(&pdev->dev, &accton_as4630_54te_leds[i]); + + if (ret < 0) + break; + } + + /* Check if all LEDs were successfully registered */ + if (i != ARRAY_SIZE(accton_as4630_54te_leds)) { + int j; + + /* only unregister the LEDs that were successfully registered */ + for (j = 0; j < i; j++) { + led_classdev_unregister(&accton_as4630_54te_leds[i]); + } + } + + return ret; +} + +static int accton_as4630_54te_led_remove(struct platform_device *pdev) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(accton_as4630_54te_leds); i++) { + led_classdev_unregister(&accton_as4630_54te_leds[i]); + } + + return 0; +} + +static struct platform_driver accton_as4630_54te_led_driver = { + .probe = accton_as4630_54te_led_probe, + .remove = accton_as4630_54te_led_remove, + .suspend = accton_as4630_54te_led_suspend, + .resume = accton_as4630_54te_led_resume, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +static int __init accton_as4630_54te_led_init(void) +{ + int ret; + + ret = platform_driver_register(&accton_as4630_54te_led_driver); + if (ret < 0) { + goto exit; + } + + ledctl = kzalloc(sizeof(struct accton_as4630_54te_led_data), GFP_KERNEL); + if (!ledctl) { + ret = -ENOMEM; + platform_driver_unregister(&accton_as4630_54te_led_driver); + goto exit; + } + + mutex_init(&ledctl->update_lock); + + ledctl->pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0); + if (IS_ERR(ledctl->pdev)) { + ret = PTR_ERR(ledctl->pdev); + platform_driver_unregister(&accton_as4630_54te_led_driver); + kfree(ledctl); + goto exit; + } + +exit: + return ret; +} + +static void __exit accton_as4630_54te_led_exit(void) +{ + platform_device_unregister(ledctl->pdev); + platform_driver_unregister(&accton_as4630_54te_led_driver); + kfree(ledctl); +} + +module_init(accton_as4630_54te_led_init); +module_exit(accton_as4630_54te_led_exit); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("accton_as4630_54te_led driver"); +MODULE_LICENSE("GPL"); diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-psu.c b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-psu.c new file mode 100755 index 000000000000..3a99f19a9cd2 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/x86-64-accton-as4630-54te-psu.c @@ -0,0 +1,320 @@ +/* + * An hwmon driver for accton as4630_54te Power Module + * + * Copyright (C) 2014 Accton Technology Corporation. + * Brandon Chuang + * + * Based on ad7414.c + * Copyright 2006 Stefan Roese , DENX Software Engineering + * + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX_MODEL_NAME 20 +#define MAX_SERIAL_NUMBER 18 + +static ssize_t show_status(struct device *dev, struct device_attribute *da, char *buf); +static ssize_t show_string(struct device *dev, struct device_attribute *da, char *buf); +static int as4630_54te_psu_read_block(struct i2c_client *client, u8 command, u8 *data,int data_len); +extern int as4630_54te_cpld_read(unsigned short cpld_addr, u8 reg); + +/* Addresses scanned + */ +static const unsigned short normal_i2c[] = { 0x50, 0x51, I2C_CLIENT_END }; + +/* Each client has this additional data + */ +struct as4630_54te_psu_data { + struct device *hwmon_dev; + struct mutex update_lock; + char valid; /* !=0 if registers are valid */ + unsigned long last_updated; /* In jiffies */ + u8 index; /* PSU index */ + u8 status; /* Status(present/power_good) register read from CPLD */ + char model_name[MAX_MODEL_NAME]; /* Model name, read from eeprom */ + char serial_number[MAX_SERIAL_NUMBER]; +}; + +static struct as4630_54te_psu_data *as4630_54te_psu_update_device(struct device *dev); + +enum as4630_54te_psu_sysfs_attributes { + PSU_PRESENT, + PSU_MODEL_NAME, + PSU_POWER_GOOD, + PSU_SERIAL_NUMBER +}; + +/* sysfs attributes for hwmon + */ +static SENSOR_DEVICE_ATTR(psu_present, S_IRUGO, show_status, NULL, PSU_PRESENT); +static SENSOR_DEVICE_ATTR(psu_model_name, S_IRUGO, show_string, NULL, PSU_MODEL_NAME); +static SENSOR_DEVICE_ATTR(psu_power_good, S_IRUGO, show_status, NULL, PSU_POWER_GOOD); +static SENSOR_DEVICE_ATTR(psu_serial_number, S_IRUGO, show_string, NULL, PSU_SERIAL_NUMBER); + + +static struct attribute *as4630_54te_psu_attributes[] = { + &sensor_dev_attr_psu_present.dev_attr.attr, + &sensor_dev_attr_psu_model_name.dev_attr.attr, + &sensor_dev_attr_psu_power_good.dev_attr.attr, + &sensor_dev_attr_psu_serial_number.dev_attr.attr, + NULL +}; + +static ssize_t show_status(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as4630_54te_psu_data *data = as4630_54te_psu_update_device(dev); + u8 status = 0; + + //printk("data->status=0x%x, attr->index=%d,data->index=%d \n", data->status, attr->index, data->index); + if (attr->index == PSU_PRESENT) { + if(data->index==0) + status = !( (data->status >> 5) & 0x1); + else + status = !( (data->status >> 1) & 0x1); + } + else { /* PSU_POWER_GOOD */ + if(data->index==0) + status = ( (data->status >> 6) & 0x1); + else + status = ( (data->status >> 2) & 0x1); + } + + return sprintf(buf, "%d\n", status); +} + +static ssize_t show_string(struct device *dev, struct device_attribute *da, + char *buf) +{ + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + struct as4630_54te_psu_data *data = as4630_54te_psu_update_device(dev); + char *ptr = NULL; + + if (!data->valid) { + return -EIO; + } + + switch (attr->index) { + case PSU_MODEL_NAME: + ptr = data->model_name; + break; + case PSU_SERIAL_NUMBER: + ptr = data->serial_number; + break; + default: + return -EINVAL; + } + + return sprintf(buf, "%s\n", ptr); +} + +static const struct attribute_group as4630_54te_psu_group = { + .attrs = as4630_54te_psu_attributes, +}; + +static int as4630_54te_psu_probe(struct i2c_client *client, + const struct i2c_device_id *dev_id) +{ + struct as4630_54te_psu_data *data; + int status; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { + status = -EIO; + goto exit; + } + + data = kzalloc(sizeof(struct as4630_54te_psu_data), GFP_KERNEL); + if (!data) { + status = -ENOMEM; + goto exit; + } + + i2c_set_clientdata(client, data); + data->valid = 0; + data->index = dev_id->driver_data; + mutex_init(&data->update_lock); + + dev_info(&client->dev, "chip found\n"); + + /* Register sysfs hooks */ + status = sysfs_create_group(&client->dev.kobj, &as4630_54te_psu_group); + if (status) { + goto exit_free; + } + + data->hwmon_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->hwmon_dev)) { + status = PTR_ERR(data->hwmon_dev); + goto exit_remove; + } + + dev_info(&client->dev, "%s: psu '%s'\n", + dev_name(data->hwmon_dev), client->name); + + return 0; + +exit_remove: + sysfs_remove_group(&client->dev.kobj, &as4630_54te_psu_group); +exit_free: + kfree(data); +exit: + + return status; +} + +static int as4630_54te_psu_remove(struct i2c_client *client) +{ + struct as4630_54te_psu_data *data = i2c_get_clientdata(client); + + hwmon_device_unregister(data->hwmon_dev); + sysfs_remove_group(&client->dev.kobj, &as4630_54te_psu_group); + kfree(data); + + return 0; +} + +enum psu_index +{ + as4630_54te_psu1, + as4630_54te_psu2 +}; + +static const struct i2c_device_id as4630_54te_psu_id[] = { + { "as4630_54te_psu1", as4630_54te_psu1 }, + { "as4630_54te_psu2", as4630_54te_psu2 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, as4630_54te_psu_id); + +static struct i2c_driver as4630_54te_psu_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "as4630_54te_psu", + }, + .probe = as4630_54te_psu_probe, + .remove = as4630_54te_psu_remove, + .id_table = as4630_54te_psu_id, + .address_list = normal_i2c, +}; + +static int as4630_54te_psu_read_block(struct i2c_client *client, u8 command, u8 *data, + int data_len) +{ + int result = 0; + int retry_count = 5; + + while (retry_count) { + retry_count--; + + result = i2c_smbus_read_i2c_block_data(client, command, data_len, data); + + if (unlikely(result < 0)) { + msleep(10); + continue; + } + + if (unlikely(result != data_len)) { + result = -EIO; + msleep(10); + continue; + } + + result = 0; + break; + } + + return result; +} + +static struct as4630_54te_psu_data *as4630_54te_psu_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct as4630_54te_psu_data *data = i2c_get_clientdata(client); + + mutex_lock(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) + || !data->valid) { + int status; + int power_good = 0; + + dev_dbg(&client->dev, "Starting as4630_54te update\n"); + + /* Read psu status */ + status = as4630_54te_cpld_read(0x60, 0x22); + //printk("status=0x%x in %s\n", status, __FUNCTION__); + if (status < 0) { + dev_dbg(&client->dev, "cpld reg 0x60 err %d\n", status); + } + else { + data->status = status; + } + + /* Read model name */ + memset(data->model_name, 0, sizeof(data->model_name)); + memset(data->serial_number, 0, sizeof(data->serial_number)); + power_good = (data->status >> (3-data->index) & 0x1); + + if (power_good) { + status = as4630_54te_psu_read_block(client, 0x20, data->model_name, + ARRAY_SIZE(data->model_name)-1); + if (status < 0) { + data->model_name[0] = '\0'; + dev_dbg(&client->dev, "unable to read model name from (0x%x)\n", client->addr); + printk("unable to read model name from (0x%x)\n", client->addr); + } + else { + data->model_name[ARRAY_SIZE(data->model_name)-1] = '\0'; + + } + /* Read from offset 0x2e ~ 0x3d (16 bytes) */ + status = as4630_54te_psu_read_block(client, 0x35,data->serial_number, MAX_SERIAL_NUMBER); + if (status < 0) + { + data->serial_number[0] = '\0'; + dev_dbg(&client->dev, "unable to read model name from (0x%x) offset(0x2e)\n", client->addr); + printk("unable to read model name from (0x%x) offset(0x2e)\n", client->addr); + } + data->serial_number[MAX_SERIAL_NUMBER-1]='\0'; + } + + data->last_updated = jiffies; + data->valid = 1; + } + + mutex_unlock(&data->update_lock); + + return data; +} + +module_i2c_driver(as4630_54te_psu_driver); + +MODULE_AUTHOR("Brandon Chuang "); +MODULE_DESCRIPTION("as4630_54te_psu driver"); +MODULE_LICENSE("GPL"); + diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/ym2651y.c b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/ym2651y.c new file mode 120000 index 000000000000..f4d67640ccc3 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/modules/ym2651y.c @@ -0,0 +1 @@ +../../common/modules/ym2651y.c \ No newline at end of file diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/service/as4630-54te-platform-handle-mgmt-interface.service b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/service/as4630-54te-platform-handle-mgmt-interface.service new file mode 100644 index 000000000000..fa4e1cca61c3 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/service/as4630-54te-platform-handle-mgmt-interface.service @@ -0,0 +1,11 @@ +[Unit] +Description=Accton AS4630-54TE Platform handle management interface service +After=sysinit.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/local/bin/handle_mgmt_interface.sh + +[Install] +WantedBy=multi-user.target diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/service/as4630-54te-platform-monitor-fan.service b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/service/as4630-54te-platform-monitor-fan.service new file mode 100644 index 000000000000..d7b8b8cb2d34 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/service/as4630-54te-platform-monitor-fan.service @@ -0,0 +1,16 @@ +[Unit] +Description=Accton AS4630-54TE Platform Monitoring FAN service +Before=pmon.service +After=as4630-54te-platform-monitor.service +DefaultDependencies=no + +[Service] +ExecStart=/usr/local/bin/accton_as4630_54te_monitor_fan.py +KillSignal=SIGKILL +SuccessExitStatus=SIGKILL + +# Resource Limitations +LimitCORE=infinity + +[Install] +WantedBy=multi-user.target diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/service/as4630-54te-platform-monitor-psu.service b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/service/as4630-54te-platform-monitor-psu.service new file mode 100644 index 000000000000..a85a0918e290 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/service/as4630-54te-platform-monitor-psu.service @@ -0,0 +1,16 @@ +[Unit] +Description=Accton AS4630-54TE Platform Monitoring PSU service +Before=pmon.service +After=as4630-54te-platform-monitor.service +DefaultDependencies=no + +[Service] +ExecStart=/usr/local/bin/accton_as4630_54te_monitor_psu.py +KillSignal=SIGKILL +SuccessExitStatus=SIGKILL + +# Resource Limitations +LimitCORE=infinity + +[Install] +WantedBy=multi-user.target diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/service/as4630-54te-platform-monitor.service b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/service/as4630-54te-platform-monitor.service new file mode 100644 index 000000000000..587e6a1cafa1 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/service/as4630-54te-platform-monitor.service @@ -0,0 +1,17 @@ +[Unit] +Description=Accton AS4630-54TE Platform Monitoring service +Before=pmon.service +After=sysinit.target +DefaultDependencies=no + +[Service] +ExecStartPre=/usr/local/bin/accton_as4630_54te_util.py install +ExecStart=/usr/local/bin/accton_as4630_54te_monitor.py +KillSignal=SIGKILL +SuccessExitStatus=SIGKILL + +# Resource Limitations +LimitCORE=infinity + +[Install] +WantedBy=multi-user.target diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/setup.py b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/setup.py new file mode 100755 index 000000000000..78b45368c791 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/setup.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +import os +from setuptools import setup +os.listdir + +setup( + name='as4630_54te', + version='1.0', + description='Module to initialize Accton AS4630-54TE platforms', + + packages=['as4630_54te'], + package_dir={'as4630_54te': 'as4630-54te/classes'}, +) diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/sonic_platform_setup.py b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/sonic_platform_setup.py new file mode 100644 index 000000000000..d256f7b3c1cd --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/sonic_platform_setup.py @@ -0,0 +1,34 @@ +from setuptools import setup + +DEVICE_NAME = 'accton' +HW_SKU = 'x86_64-accton_as4630_54te-r0' + +setup( + name='sonic-platform', + version='1.0', + description='SONiC platform API implementation on Accton Platforms', + license='Apache 2.0', + author='SONiC Team', + author_email='linuxnetdev@microsoft.com', + url='https://github.com/Azure/sonic-buildimage', + maintainer='Michael Shih', + maintainer_email='michael_shih@edge-core.com', + packages=[ + 'sonic_platform', + ], + package_dir={ + 'sonic_platform': '../../../../device/{}/{}/sonic_platform'.format(DEVICE_NAME, HW_SKU)}, + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Environment :: Plugins', + 'Intended Audience :: Developers', + 'Intended Audience :: Information Technology', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: Apache Software License', + 'Natural Language :: English', + 'Operating System :: POSIX :: Linux', + 'Programming Language :: Python :: 3.7', + 'Topic :: Utilities', + ], + keywords='sonic SONiC platform PLATFORM', +) diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/README b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/README new file mode 100755 index 000000000000..65bad2200816 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/README @@ -0,0 +1,67 @@ +Copyright (C) 2019 Accton Networks, Inc. + +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 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +All Linux kernel code is licensed under the GPLv1. All other code is +licensed under the GPLv3. Please see the LICENSE file for copies of +both licenses. + +The code for integacting with Accton AS4630-54te has 2 parts, +kernel drivers and operational script. +The kernel drivers of peripherals are under module/ directory. +1. These drivers are at module dir. +2. A operational script, accton_as4630_util.py, for device initializatian and + peripheral accessing should be installed at /usr/bin. + Run "accton_as4630_util.py install" to install drivers. + +To initialize the system, run "accton_as4630_util.py install". +To clean up the drivers & devices, run "accton_as4630_util.py clean". +To dump information of sensors, run "accton_as4630_util.py show". +To dump SFP EEPROM, run "accton_as4630_util.py sff". +To set fan speed, run "accton_as4630_util.py set fan". +To enable/disable SFP emission, run "accton_as4630_util.py set sfp". +To set system LEDs' color, run "accton_as4630_util.py set led" +For more information, run "accton_as4630_util.py --help". + +==================================================================== +Besides applying accton_as4630_util.py to access peripherals, you can +access peripherals by sysfs nodes directly after the installation is run. + +System LED: + There are 5 system LEDs at the lower-left corner of front panel. + They are loc, diag, fan, ps1, and ps2. + The sysfs interface color mappings are as follows: + Brightness: + 0 => off + 1 => green + 2 => amber + 3 => red + 4 => blue + But not all colors are available for each LED. + +Fan Control: + There are 10 fans inside 5 fan modules. + All fans share 1 duty setting, ranged from 0~100. + +Thermal sensers: + 3 temperature sensors are controlled by the lm75 kernel modules. + +PSUs: + There 2 power supplies slot at the left/right side of the back. + Once if a PSU is not plugged, the status of it is shown failed. + +There are 48 SFP+ and 6 QSFP modules are equipped. +Before operating on PSU and QSFP+, please make sure it is well plugged. +Otherwise, operation is going to fail. + diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_monitor.py b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_monitor.py new file mode 100755 index 000000000000..8c704ac60e86 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_monitor.py @@ -0,0 +1,261 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -* +# Copyright (c) 2019 Edgecore Networks Corporation +# +# 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 +# +# THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT +# LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS +# FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. +# +# See the Apache Version 2.0 License for specific language governing +# permissions and limitations under the License. +# +# HISTORY: +# mm/dd/yyyy (A.D.)# +# 10/24/2019:Jostar create for as4630_54te thermal plan +# ------------------------------------------------------------------ + +try: + import os + import sys + import getopt + import logging + import logging.config + import logging.handlers + import time + from as4630_54te.fanutil import FanUtil + from as4630_54te.thermalutil import ThermalUtil +except ImportError as e: + raise ImportError('%s - required module not found' % str(e)) + +# Deafults +VERSION = '1.0' +FUNCTION_NAME = '/usr/local/bin/accton_as4630_54te_monitor' + +# Temperature Policy +# If any fan fail , please set fan speed register to 16 +# The max value of fan speed register is 14 +# LM77(48)+LM75(4B)+LM75(4A) > 140, Set 10 +# LM77(48)+LM75(4B)+LM75(4A) > 150, Set 12 +# LM77(48)+LM75(4B)+LM75(4A) > 160, Set 14 +# LM77(48)+LM75(4B)+LM75(4A) < 140, Set 8 +# LM77(48)+LM75(4B)+LM75(4A) < 150, Set 10 +# LM77(48)+LM75(4B)+LM75(4A) < 160, Set 12 +# Reset DUT:LM77(48)>=70C +# +class switch(object): + def __init__(self, value): + self.value = value + self.fall = False + + def __iter__(self): + """Return the match method once, then stop""" + yield self.match + raise StopIteration + + def match(self, *args): + """Indicate whether or not to enter a case suite""" + if self.fall or not args: + return True + elif self.value in args: # changed for v1.5, see below + self.fall = True + return True + else: + return False + + +fan_policy_state = 0 +fan_fail = 0 +alarm_state = 0 # 0->default or clear, 1-->alarm detect +test_temp = 0 +test_temp_list = [0, 0, 0] +temp_test_data = 0 +test_temp_revert = 0 +# Make a class we can use to capture stdout and sterr in the log + + +class device_monitor(object): + # static temp var + temp = 0 + new_pwm = 0 + pwm = 0 + ori_pwm = 0 + default_pwm = 0x4 + + def __init__(self, log_file, log_level): + """Needs a logger and a logger level.""" + # set up logging to file + logging.basicConfig( + filename=log_file, + filemode='w', + level=log_level, + format='[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s', + datefmt='%H:%M:%S') + # set up logging to console + if log_level == logging.DEBUG: + console = logging.StreamHandler() + console.setLevel(log_level) + formatter = logging.Formatter( + '%(name)-12s: %(levelname)-8s %(message)s') + console.setFormatter(formatter) + logging.getLogger('').addHandler(console) + + sys_handler = logging.handlers.SysLogHandler( + address='/dev/log') + sys_handler.setLevel(logging.WARNING) + logging.getLogger('').addHandler(sys_handler) + + def get_state_from_fan_policy(self, temp, policy): + state = 0 + for i in range(0, len(policy)): + if (temp > policy[i][2]): # temp_down + if temp <= policy[i][3]: # temp_up + state = i + + return state + + def manage_fans(self): + global fan_policy_state + global fan_fail + global test_temp + global test_temp_list + global alarm_state + global temp_test_data + global test_temp_revert + LEVEL_FAN_MIN = 0 + LEVEL_FAN_NORMAL = 1 + LEVEL_FAN_MID = 2 + LEVEL_FAN_HIGH = 3 + LEVEL_TEMP_CRITICAL = 4 + fan_policy = { + LEVEL_FAN_MIN: [50, 8, 0, 140000], + LEVEL_FAN_NORMAL: [62, 10, 140000, 150000], + LEVEL_FAN_MID: [75, 12, 150000, 160000], + LEVEL_FAN_HIGH: [88, 14, 160000, 240000], + LEVEL_TEMP_CRITICAL: [100, 16, 240000, 300000], + } + temp = [0, 0, 0] + thermal = ThermalUtil() + fan = FanUtil() + ori_duty_cycle = fan.get_fan_duty_cycle() + new_duty_cycle = 0 + + if test_temp == 0: + for i in range(0, 3): + temp[i] = thermal._get_thermal_val(i + 1) + if temp[i] == 0 or temp[i] is None: + logging.warning("Get temp-%d fail", i) + return False + else: + if test_temp_revert == 0: + temp_test_data = temp_test_data + 2000 + else: + temp_test_data = temp_test_data - 2000 + + for i in range(0, 3): + temp[i] = test_temp_list[i] + temp_test_data + fan_fail = 0 + + temp_val = 0 + for i in range(0, 3): + if temp[i] is None: + break + temp_val += temp[i] + + # Check Fan status + for i in range(fan.FAN_NUM_1_IDX, fan.FAN_NUM_ON_MAIN_BROAD + 1): + if fan.get_fan_status(i) == 0: + new_pwm = 100 + logging.warning('Fan_%d fail, set pwm to 100', i) + if test_temp == 0: + fan_fail = 1 + fan.set_fan_duty_cycle(new_pwm) + break + else: + fan_fail = 0 + + ori_state = fan_policy_state + fan_policy_state = self.get_state_from_fan_policy(temp_val, fan_policy) + + if fan_policy_state > LEVEL_TEMP_CRITICAL or fan_policy_state < LEVEL_FAN_MIN: + logging.error("Get error fan current_state\n") + return 0 + + # Decision : Decide new fan pwm percent. + if fan_fail == 0 and ori_duty_cycle != fan_policy[fan_policy_state][0]: + new_duty_cycle = fan_policy[fan_policy_state][0] + fan.set_fan_duty_cycle(new_duty_cycle) + + if temp[0] >= 70000: # LM75-48 + # critical case*/ + logging.critical( + 'Alarm-Critical for temperature critical is detected, reset DUT') + cmd_str = "i2cset -y -f 3 0x60 0x4 0xE4" + time.sleep(2) + return_value = os.system(cmd_str) + logging.warning('Fan set: i2cset -y -f 3 0x60 0x4 0xE4, status is %d', return_value) + + #logging.debug('ori_state=%d, current_state=%d, temp_val=%d\n\n',ori_state, fan_policy_state, temp_val) + + if ori_state < LEVEL_FAN_HIGH: + if fan_policy_state >= LEVEL_FAN_HIGH: + if alarm_state == 0: + logging.warning('Alarm for temperature high is detected') + alarm_state = 1 + + if fan_policy_state < LEVEL_FAN_MID: + if alarm_state == 1: + logging.info('Alarm for temperature high is cleared') + alarm_state = 0 + + return True + + +def main(argv): + log_file = '%s.log' % FUNCTION_NAME + log_level = logging.INFO + global test_temp + if len(sys.argv) != 1: + try: + opts, args = getopt.getopt(argv, 'hdlt:', ['lfile=']) + except getopt.GetoptError: + print 'Usage: %s [-d] [-l ]' % sys.argv[0] + return 0 + for opt, arg in opts: + if opt == '-h': + print 'Usage: %s [-d] [-l ]' % sys.argv[0] + return 0 + elif opt in ('-d', '--debug'): + log_level = logging.DEBUG + elif opt in ('-l', '--lfile'): + log_file = arg + + if sys.argv[1] == '-t': + if len(sys.argv) != 5: + print "temp test, need input three temp" + return 0 + + i = 0 + for x in range(2, 5): + test_temp_list[i] = int(sys.argv[x]) * 1000 + i = i + 1 + test_temp = 1 + log_level = logging.DEBUG + print test_temp_list + + fan = FanUtil() + fan.set_fan_duty_cycle(50) + print "set default fan speed to 50%" + monitor = device_monitor(log_file, log_level) + # Loop forever, doing something useful hopefully: + while True: + monitor.manage_fans() + time.sleep(10) # 10sec + + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_monitor_fan.py b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_monitor_fan.py new file mode 100755 index 000000000000..6d8ab0ea3c95 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_monitor_fan.py @@ -0,0 +1,186 @@ +#!/usr/bin/env python +# +# Copyright (C) 2018 Accton Technology Corporation +# +# 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 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# ------------------------------------------------------------------ +# HISTORY: +# mm/dd/yyyy (A.D.) +# 5/15/2019: Jostar create for as4630-54te +# ------------------------------------------------------------------ + +try: + import sys + import getopt + import logging + import logging.config + import logging.handlers + import time # this is only being used as part of the example + +except ImportError as e: + raise ImportError('%s - required module not found' % str(e)) + +# Deafults +VERSION = '1.0' +FUNCTION_NAME = '/usr/local/bin/accton_as4630_54te_monitor_fan' + + +class switch(object): + def __init__(self, value): + self.value = value + self.fall = False + + def __iter__(self): + """Return the match method once, then stop""" + yield self.match + raise StopIteration + + def match(self, *args): + """Indicate whether or not to enter a case suite""" + if self.fall or not args: + return True + elif self.value in args: # changed for v1.5, see below + self.fall = True + return True + else: + return False + + +fan_state = [2, 2, 2, 2] # init state=2, insert=1, remove=0 +fan_status_state = [2, 2, 2, 2] # init state=2, fault=1, normal=0 +# Make a class we can use to capture stdout and sterr in the log + + +class device_monitor(object): + + def __init__(self, log_file, log_level): + + self.fan_num = 3 + self.fan_path = "/sys/bus/i2c/devices/3-0060/" + self.present = { + 0: "fan_present_1", + 1: "fan_present_2", + 2: "fan_present_3", + } + + self.fault = { + 0: "fan_fault_1", + 1: "fan_fault_2", + 2: "fan_fault_3", + } + + """Needs a logger and a logger level.""" + # set up logging to file + logging.basicConfig( + filename=log_file, + filemode='w', + level=log_level, + format='[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s', + datefmt='%H:%M:%S') + + # set up logging to console + if log_level == logging.DEBUG: + console = logging.StreamHandler() + console.setLevel(logging.DEBUG) + formatter = logging.Formatter( + '%(name)-12s: %(levelname)-8s %(message)s') + console.setFormatter(formatter) + logging.getLogger('').addHandler(console) + + sys_handler = logging.handlers.SysLogHandler(address='/dev/log') + # sys_handler.setLevel(logging.WARNING) + sys_handler.setLevel(logging.INFO) + logging.getLogger('').addHandler(sys_handler) + + #logging.debug('SET. logfile:%s / loglevel:%d', log_file, log_level) + + def manage_fan(self): + + FAN_STATE_REMOVE = 0 + FAN_STATE_INSERT = 1 + + FAN_STATUS_FAULT = 1 + FAN_STATUS_NORMAL = 0 + + global fan_state + global fan_status_state + + for idx in range(0, self.fan_num): + node = self.fan_path + self.present[idx] + try: + val_file = open(node) + except IOError as e: + print "Error: unable to open file: %s" % str(e) + return False + content = val_file.readline().rstrip() + val_file.close() + # content is a string, either "0" or "1" + if content == "1": + if fan_state[idx] != 1: + fan_state[idx] = FAN_STATE_INSERT + logging.info("FAN-%d present is detected", idx + 1) + else: + if fan_state[idx] != 0: + fan_state[idx] = FAN_STATE_REMOVE + logging.warning( + "Alarm for FAN-%d absent is detected", idx + 1) + + for idx in range(0, self.fan_num): + node = self.fan_path + self.fault[idx] + try: + val_file = open(node) + except IOError as e: + print "Error: unable to open file: %s" % str(e) + return False + content = val_file.readline().rstrip() + val_file.close() + # content is a string, either "0" or "1" + if content == "1": + if fan_status_state[idx] != FAN_STATUS_FAULT: + if fan_state[idx] == FAN_STATE_INSERT: + logging.warning( + "Alarm for FAN-%d failed is detected", idx + 1) + fan_status_state[idx] = FAN_STATUS_FAULT + else: + fan_status_state[idx] = FAN_STATUS_NORMAL + + return True + + +def main(argv): + log_file = '%s.log' % FUNCTION_NAME + log_level = logging.INFO + if len(sys.argv) != 1: + try: + opts, args = getopt.getopt(argv, 'hdl:', ['lfile=']) + except getopt.GetoptError: + print 'Usage: %s [-d] [-l ]' % sys.argv[0] + return 0 + for opt, arg in opts: + if opt == '-h': + print 'Usage: %s [-d] [-l ]' % sys.argv[0] + return 0 + elif opt in ('-d', '--debug'): + log_level = logging.DEBUG + elif opt in ('-l', '--lfile'): + log_file = arg + monitor = device_monitor(log_file, log_level) + while True: + monitor.manage_fan() + time.sleep(3) + + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_monitor_psu.py b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_monitor_psu.py new file mode 100755 index 000000000000..9bff640434bf --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_monitor_psu.py @@ -0,0 +1,168 @@ +#!/usr/bin/env python +# +# Copyright (C) 2018 Accton Technology Corporation +# +# 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 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# ------------------------------------------------------------------ +# HISTORY: +# mm/dd/yyyy (A.D.) +# 5/15/2019: Jostar create for as4630-54te +# ------------------------------------------------------------------ + +try: + import sys + import getopt + import logging + import logging.config + import logging.handlers + import time # this is only being used as part of the example + +except ImportError as e: + raise ImportError('%s - required module not found' % str(e)) + +# Deafults +VERSION = '1.0' +FUNCTION_NAME = '/usr/local/bin/accton_as4630_54te_monitor_psu' + + +psu_state = [2, 2] +psu_status_state = [2, 2] +# Make a class we can use to capture stdout and sterr in the log + + +class device_monitor(object): + + def __init__(self, log_file, log_level): + + self.psu_num = 2 + self.psu_path = "/sys/bus/i2c/devices/" + self.presence = "/psu_present" + self.oper_status = "/psu_power_good" + self.mapping = { + 0: "10-0050", + 1: "11-0051", + } + + """Needs a logger and a logger level.""" + # set up logging to file + logging.basicConfig( + filename=log_file, + filemode='w', + level=log_level, + format='[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s', + datefmt='%H:%M:%S') + # set up logging to console + + if log_level == logging.DEBUG: + console = logging.StreamHandler() + console.setLevel(log_level) + formatter = logging.Formatter( + '%(name)-12s: %(levelname)-8s %(message)s') + console.setFormatter(formatter) + logging.getLogger('').addHandler(console) + + sys_handler = logging.handlers.SysLogHandler(address='/dev/log') + # sys_handler.setLevel(logging.WARNING) + sys_handler.setLevel(logging.INFO) + logging.getLogger('').addHandler(sys_handler) + + #logging.debug('SET. logfile:%s / loglevel:%d', log_file, log_level) + + def manage_psu(self): + + PSU_STATE_REMOVE = 0 + PSU_STATE_INSERT = 1 + + PSU_STATUS_NO_POWER = 0 + PSU_STATUS_POWER_GOOD = 1 + PSU_STATUS_IDLE = 2 + + global psu_state + + for idx in range(0, self.psu_num): + node = self.psu_path + self.mapping[idx] + self.presence + try: + val_file = open(node) + except IOError as e: + print "Error: unable to open file: %s" % str(e) + return False + content = val_file.readline().rstrip() + val_file.close() + # content is a string, either "0" or "1" + if content == "1": + if psu_state[idx] != 1: + psu_state[idx] = PSU_STATE_INSERT + logging.info("PSU-%d present is detected", idx + 1) + # psu_status_state[idx]=PSU_STATUS_POWER_GOOD #when insert, + # assume power is good. If no_power, next code will find + # it. + else: + if psu_state[idx] != 0: + psu_state[idx] = PSU_STATE_REMOVE + logging.warning( + "Alarm for PSU-%d absent is detected", idx + 1) + psu_status_state[idx] = PSU_STATUS_IDLE + + for idx in range(0, self.psu_num): + node = self.psu_path + self.mapping[idx] + self.oper_status + try: + val_file = open(node) + except IOError as e: + print "Error: unable to open file: %s" % str(e) + return False + content = val_file.readline().rstrip() + val_file.close() + # content is a string, either "0" or "1" + if content == "0": + if psu_status_state[idx] != PSU_STATUS_NO_POWER: + if psu_state[idx] == PSU_STATE_INSERT: + logging.warning( + "Alarm for PSU-%d failed is detected", idx + 1) + psu_status_state[idx] = PSU_STATUS_NO_POWER + else: + if psu_state[idx] == PSU_STATE_INSERT: + if psu_status_state[idx] != PSU_STATUS_POWER_GOOD: + logging.info("PSU-%d power_good is detected", idx + 1) + psu_status_state[idx] = PSU_STATUS_POWER_GOOD + + return True + + +def main(argv): + log_file = '%s.log' % FUNCTION_NAME + log_level = logging.INFO + if len(sys.argv) != 1: + try: + opts, args = getopt.getopt(argv, 'hdl:', ['lfile=']) + except getopt.GetoptError: + print 'Usage: %s [-d] [-l ]' % sys.argv[0] + return 0 + for opt, arg in opts: + if opt == '-h': + print 'Usage: %s [-d] [-l ]' % sys.argv[0] + return 0 + elif opt in ('-d', '--debug'): + log_level = logging.DEBUG + elif opt in ('-l', '--lfile'): + log_file = arg + monitor = device_monitor(log_file, log_level) + # Loop forever, doing something useful hopefully: + while True: + monitor.manage_psu() + time.sleep(3) + + +if __name__ == '__main__': + main(sys.argv[1:]) 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 new file mode 100755 index 000000000000..172a9842a8bf --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/accton_as4630_54te_util.py @@ -0,0 +1,681 @@ +#!/usr/bin/env python +# +# Copyright (C) 2016 Accton Networks, Inc. +# +# 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 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +""" +Usage: %(scriptName)s [options] command object +options: + -h | --help : this help message + -d | --debug : run with debug mode + -f | --force : ignore error during installation or clean +command: + install : install drivers and generate related sysfs nodes + clean : uninstall drivers and remove related sysfs nodes + show : show all systen status + sff : dump SFP eeprom + set : change board setting with fan|led|sfp +""" + +import commands +import getopt +import sys +import logging +import re +import time +import os + +PROJECT_NAME = 'as4630_54te' +version = '0.0.1' +verbose = False +DEBUG = False +args = [] +ALL_DEVICE = {} +DEVICE_NO = { + 'led': 5, + 'fan1': 1, + 'fan2': 1, + 'fan3': 1, + 'fan4': 1, + 'fan5': 1, + 'thermal': 3, + 'psu': 2, + 'sfp': 54} + + +led_prefix = '/sys/devices/platform/as4630_54te_led/leds/accton_' + \ + PROJECT_NAME + '_led::' +fan_prefix = '/sys/devices/platform/as4630_54te_' +hwmon_types = {'led': ['diag', 'fan', 'loc', 'psu1', 'psu2'], + 'fan1': ['fan'], + 'fan2': ['fan'], + 'fan3': ['fan'], + 'fan4': ['fan'], + 'fan5': ['fan'], + } +hwmon_nodes = { + 'led': ['brightness'], + 'fan1': [ + 'fan_duty_cycle_percentage', + 'fan1_fault', + 'fan1_speed_rpm', + 'fan1_direction', + 'fanr1_fault', + 'fanr1_speed_rpm'], + 'fan2': [ + 'fan_duty_cycle_percentage', + 'fan2_fault', + 'fan2_speed_rpm', + 'fan2_direction', + 'fanr2_fault', + 'fanr2_speed_rpm'], + 'fan3': [ + 'fan_duty_cycle_percentage', + 'fan3_fault', + 'fan3_speed_rpm', + 'fan3_direction', + 'fanr3_fault', + 'fanr3_speed_rpm'], + 'fan4': [ + 'fan4_duty_cycle_percentage', + 'fan4_fault', + 'fan4_speed_rpm', + 'fan4_direction', + 'fanr4_fault', + 'fanr4_speed_rpm'], + 'fan5': [ + 'fan_duty_cycle_percentage', + 'fan5_fault', + 'fan5_speed_rpm', + 'fan5_direction', + 'fanr5_fault', + 'fanr5_speed_rpm'], +} +hwmon_prefix = {'led': led_prefix, + 'fan1': fan_prefix, + 'fan2': fan_prefix, + 'fan3': fan_prefix, + 'fan4': fan_prefix, + 'fan5': fan_prefix, + } + +i2c_prefix = '/sys/bus/i2c/devices/' +i2c_bus = {'fan': ['54-0066'], + 'thermal': ['54-004c', '55-0048', '55-0049', '55-004a', '55-004b'], + 'psu': ['49-0050', '50-0053'], + 'sfp': ['-0050']} +i2c_nodes = {'fan': ['present', 'front_speed_rpm', 'rear_speed_rpm'], + 'thermal': ['hwmon/hwmon*/temp1_input'], + 'psu': ['psu_present ', 'psu_power_good'], + 'sfp': ['module_present_ ', 'module_tx_disable_']} + +sfp_map = [18, 19, 20, 21, 22, 23] + +mknod = [ + 'echo pca9548 0x77 > /sys/bus/i2c/devices/i2c-1/new_device', + 'echo pca9548 0x71 > /sys/bus/i2c/devices/i2c-2/new_device', + 'echo pca9548 0x70 > /sys/bus/i2c/devices/i2c-3/new_device', + + 'echo as4630_54te_cpld 0x60 > /sys/bus/i2c/devices/i2c-3/new_device', + + 'echo lm77 0x48 > /sys/bus/i2c/devices/i2c-14/new_device', + 'echo lm75 0x4a > /sys/bus/i2c/devices/i2c-25/new_device', + 'echo lm75 0x4b > /sys/bus/i2c/devices/i2c-24/new_device', + + + # PSU-1 + 'echo as4630_54te_psu1 0x50 > /sys/bus/i2c/devices/i2c-10/new_device', + 'echo ype1200am 0x58 > /sys/bus/i2c/devices/i2c-10/new_device', + + # PSU-2 + 'echo as4630_54te_psu2 0x51> /sys/bus/i2c/devices/i2c-11/new_device', + 'echo ype1200am 0x59 > /sys/bus/i2c/devices/i2c-11/new_device', + + # EERPOM + 'echo 24c02 0x57 > /sys/bus/i2c/devices/i2c-1/new_device', +] + +# Disable CPLD debug mode +cpld_set = [ + 'i2cset -y -f 3 0x60 0x2a 0xff', + 'i2cset -y -f 3 0x60 0x2b 0xff', + 'i2cset -y -f 3 0x60 0x86 0x89' +] + +FORCE = 0 +#logging.basicConfig(filename= PROJECT_NAME+'.log', filemode='w',level=logging.DEBUG) +# logging.basicConfig(level=logging.INFO) + + +def main(): + global DEBUG + global args + global FORCE + + if DEBUG: + print(sys.argv[0]) + print('ARGV : %s' % sys.argv[1:]) + + if len(sys.argv) < 2: + show_help() + + options, args = getopt.getopt(sys.argv[1:], 'hdf', ['help', + 'debug', + 'force', + ]) + if DEBUG: + print options + print args + print len(sys.argv) + + for opt, arg in options: + if opt in ('-h', '--help'): + show_help() + elif opt in ('-d', '--debug'): + DEBUG = True + logging.basicConfig(level=logging.INFO) + elif opt in ('-f', '--force'): + FORCE = 1 + else: + print "TEST" + logging.info('no option') + for arg in args: + if arg == 'install': + do_install() + elif arg == 'clean': + do_uninstall() + elif arg == 'api': + do_sonic_platform_install() + elif arg == 'api_clean': + do_sonic_platform_clean() + elif arg == 'show': + device_traversal() + elif arg == 'sff': + if len(args) != 2: + show_eeprom_help() + elif int(args[1]) == 0 or int(args[1]) > DEVICE_NO['sfp']: + show_eeprom_help() + else: + show_eeprom(args[1]) + return + elif arg == 'set': + if len(args) < 3: + show_set_help() + else: + set_device(args[1:]) + return + else: + show_help() + + return 0 + + +def show_help(): + print __doc__ % {'scriptName': sys.argv[0].split("/")[-1]} + sys.exit(0) + + +def show_set_help(): + cmd = sys.argv[0].split("/")[-1] + " " + args[0] + print cmd + " [led|sfp|fan]" + print " use \"" + cmd + " led 0-4 \" to set led color" + print " use \"" + cmd + " fan 0-100\" to set fan duty percetage" + print " use \"" + cmd + " sfp 1-32 {0|1}\" to set sfp# tx_disable" + sys.exit(0) + + +def show_eeprom_help(): + cmd = sys.argv[0].split("/")[-1] + " " + args[0] + print " use \"" + cmd + " 1-32 \" to dump sfp# eeprom" + sys.exit(0) + + +def my_log(txt): + if DEBUG: + print "[ACCTON DBG]: " + txt + return + + +def log_os_system(cmd, show): + logging.info('Run :' + cmd) + output = "" + status, output = commands.getstatusoutput(cmd) + my_log(cmd + "with result:" + str(status)) + my_log("cmd:" + cmd) + my_log(" output:" + output) + if status: + logging.info('Failed :' + cmd) + if show: + print('Failed :' + cmd) + return status, output + + +def driver_inserted(): + ret, lsmod = log_os_system("ls /sys/module/*accton*", 0) + logging.info('mods:' + lsmod) + if ret: + return False + +#'modprobe cpr_4011_4mxx', + + +kos = [ + 'depmod -ae', + 'modprobe i2c_dev', + 'modprobe i2c_mux_pca954x force_deselect_on_exit=1', + 'modprobe ym2651y', + 'modprobe x86_64_accton_as4630_54te_cpld', + 'modprobe x86_64_accton_as4630_54te_leds', + 'modprobe x86_64_accton_as4630_54te_psu', + 'modprobe optoe'] + + +def driver_install(): + global FORCE + + my_log("rmmond i2cismt") + log_os_system("rmmod i2c_ismt", 1) + log_os_system("rmmod i2c_i801", 1) + log_os_system("modprobe i2c-i801", 1) + time.sleep(1) + log_os_system("modprobe i2c-ismt", 1) + + for i in range(0, len(kos)): + status, output = log_os_system(kos[i], 1) + if status: + if FORCE == 0: + return status + + return 0 + + +def driver_uninstall(): + global FORCE + for i in range(0, len(kos)): + rm = kos[-(i + 1)].replace("modprobe", "modprobe -rq") + lst = rm.split(" ") + print "lst=%s" % lst + if len(lst) > 3: + del(lst[3]) + rm = " ".join(lst) + status, output = log_os_system(rm, 1) + if status: + if FORCE == 0: + return status + return 0 + + +def device_install(): + global FORCE + + for i in range(0, len(mknod)): + # for pca954x need times to built new i2c buses + if mknod[i].find('pca954') != -1: + time.sleep(2) + + status, output = log_os_system(mknod[i], 1) + if status: + print output + if FORCE == 0: + return status + print("Check SFP") + for i in range(0, len(sfp_map)): + if(i < 4): + opt = 'optoe2' + else: + opt = 'optoe1' + status, output = log_os_system("echo " + + str(opt) + + " 0x50 > /sys/bus/i2c/devices/i2c-" + + str(sfp_map[i]) + + "/new_device", 1) + if status: + print output + if FORCE == 0: + return status + + status, output = log_os_system("echo port" + + str(i + + 49) + + " > /sys/bus/i2c/devices/" + + str(sfp_map[i]) + + "-0050/port_name", 1) + if status: + print output + if FORCE == 0: + return status + + return + + +def device_uninstall(): + global FORCE + + for i in range(0, len(sfp_map)): + target = "/sys/bus/i2c/devices/i2c-" + \ + str(sfp_map[i]) + "/delete_device" + status, output = log_os_system("echo 0x50 > " + target, 1) + if status: + print output + if FORCE == 0: + return status + + nodelist = mknod + + for i in range(len(nodelist)): + target = nodelist[-(i + 1)] + temp = target.split() + del temp[1] + temp[-1] = temp[-1].replace('new_device', 'delete_device') + status, output = log_os_system(" ".join(temp), 1) + if status: + print output + if FORCE == 0: + return status + + return + + +def system_ready(): + if driver_inserted() == False: + return False + if not device_exist(): + print "not device_exist()" + return False + return True + +PLATFORM_ROOT_PATH = '/usr/share/sonic/device' +PLATFORM_API2_WHL_FILE_PY3 ='sonic_platform-1.0-py3-none-any.whl' +def do_sonic_platform_install(): + device_path = "{}{}{}{}".format(PLATFORM_ROOT_PATH, '/x86_64-accton_', PROJECT_NAME, '-r0') + SONIC_PLATFORM_BSP_WHL_PKG_PY3 = "/".join([device_path, PLATFORM_API2_WHL_FILE_PY3]) + + #Check API2.0 on py whl file + status, output = log_os_system("pip3 show sonic-platform > /dev/null 2>&1", 0) + if status: + if os.path.exists(SONIC_PLATFORM_BSP_WHL_PKG_PY3): + status, output = log_os_system("pip3 install "+ SONIC_PLATFORM_BSP_WHL_PKG_PY3, 1) + if status: + print "Error: Failed to install {}".format(PLATFORM_API2_WHL_FILE_PY3) + return status + else: + print "Successfully installed {} package".format(PLATFORM_API2_WHL_FILE_PY3) + else: + print('{} is not found'.format(PLATFORM_API2_WHL_FILE_PY3)) + else: + print('{} has installed'.format(PLATFORM_API2_WHL_FILE_PY3)) + + return + +def do_sonic_platform_clean(): + status, output = log_os_system("pip3 show sonic-platform > /dev/null 2>&1", 0) + if status: + print('{} does not install, not need to uninstall'.format(PLATFORM_API2_WHL_FILE_PY3)) + + else: + status, output = log_os_system("pip3 uninstall sonic-platform -y", 0) + if status: + print('Error: Failed to uninstall {}'.format(PLATFORM_API2_WHL_FILE_PY3)) + return status + else: + print('{} is uninstalled'.format(PLATFORM_API2_WHL_FILE_PY3)) + + return + + +def do_install(): + if driver_inserted() == False: + status = driver_install() + if status: + if FORCE == 0: + return status + else: + print PROJECT_NAME.upper() + " drivers detected...." + if not device_exist(): + status = device_install() + if status: + if FORCE == 0: + return status + else: + print PROJECT_NAME.upper() + " devices detected...." + + for i in range(len(cpld_set)): + status, output = log_os_system(cpld_set[i], 1) + if status: + if FORCE == 0: + return status + + do_sonic_platform_install() + + return + + +def do_uninstall(): + if not device_exist(): + print PROJECT_NAME.upper() + " has no device installed...." + else: + print "Removing device...." + status = device_uninstall() + if status: + if FORCE == 0: + return status + + if driver_inserted() == False: + print PROJECT_NAME.upper() + " has no driver installed...." + else: + print "Removing installed driver...." + status = driver_uninstall() + if status: + if FORCE == 0: + return status + + do_sonic_platform_clean() + + return + + +def devices_info(): + global DEVICE_NO + global ALL_DEVICE + global i2c_bus, hwmon_types + for key in DEVICE_NO: + ALL_DEVICE[key] = {} + for i in range(0, DEVICE_NO[key]): + ALL_DEVICE[key][key + str(i + 1)] = [] + + for key in i2c_bus: + buses = i2c_bus[key] + nodes = i2c_nodes[key] + for i in range(0, len(buses)): + for j in range(0, len(nodes)): + if 'fan' == key: + for k in range(0, DEVICE_NO[key]): + node = key + str(k + 1) + path = i2c_prefix + \ + buses[i] + "/fan" + str(k + 1) + "_" + nodes[j] + my_log(node + ": " + path) + ALL_DEVICE[key][node].append(path) + elif 'sfp' == key: + for k in range(0, DEVICE_NO[key]): + node = key + str(k + 1) + path = i2c_prefix + \ + str(sfp_map[k]) + buses[i] + "/" + nodes[j] + my_log(node + ": " + path) + ALL_DEVICE[key][node].append(path) + else: + node = key + str(i + 1) + path = i2c_prefix + buses[i] + "/" + nodes[j] + my_log(node + ": " + path) + ALL_DEVICE[key][node].append(path) + + for key in hwmon_types: + itypes = hwmon_types[key] + nodes = hwmon_nodes[key] + for i in range(0, len(itypes)): + for j in range(0, len(nodes)): + node = key + "_" + itypes[i] + path = hwmon_prefix[key] + itypes[i] + "/" + nodes[j] + my_log(node + ": " + path) + ALL_DEVICE[key][key + str(i + 1)].append(path) + + # show dict all in the order + if DEBUG: + for i in sorted(ALL_DEVICE.keys()): + print(i + ": ") + for j in sorted(ALL_DEVICE[i].keys()): + print(" " + j) + for k in (ALL_DEVICE[i][j]): + print(" " + " " + k) + return + + +def show_eeprom(index): + if system_ready() == False: + print("System's not ready.") + print("Please install first!") + return + + if len(ALL_DEVICE) == 0: + devices_info() + node = ALL_DEVICE['sfp']['sfp' + str(index)][0] + node = node.replace(node.split("/")[-1], 'eeprom') + # check if got hexdump command in current environment + ret, log = log_os_system("which hexdump", 0) + ret, log2 = log_os_system("which busybox hexdump", 0) + if len(log): + hex_cmd = 'hexdump' + elif len(log2): + hex_cmd = ' busybox hexdump' + else: + log = 'Failed : no hexdump cmd!!' + logging.info(log) + print log + return 1 + print "node=%s" % node + print node + ":" + ret, log = log_os_system("cat " + node + "| " + hex_cmd + " -C", 1) + if ret == 0: + print log + else: + print "**********device no found**********" + return + + +def set_device(args): + global DEVICE_NO + global ALL_DEVICE + if system_ready() == False: + print("System's not ready.") + print("Please install first!") + return + + if len(ALL_DEVICE) == 0: + devices_info() + + if args[0] == 'led': + if int(args[1]) > 4: + show_set_help() + return + #print ALL_DEVICE['led'] + for i in range(0, len(ALL_DEVICE['led'])): + for k in (ALL_DEVICE['led']['led' + str(i + 1)]): + ret, log = log_os_system("echo " + args[1] + " >" + k, 1) + if ret: + return ret + elif args[0] == 'fan': + if int(args[1]) > 100: + show_set_help() + return + #print ALL_DEVICE['fan'] + # fan1~6 is all fine, all fan share same setting + node = ALL_DEVICE['fan1']['fan11'][0] + node = node.replace(node.split("/")[-1], 'fan1_duty_cycle_percentage') + ret, log = log_os_system("cat " + node, 1) + if ret == 0: + print ("Previous fan duty: " + log.strip() + "%") + ret, log = log_os_system("echo " + args[1] + " >" + node, 1) + if ret == 0: + print ("Current fan duty: " + args[1] + "%") + return ret + elif args[0] == 'sfp': + if int(args[1]) > DEVICE_NO[args[0]] or int(args[1]) == 0: + show_set_help() + return + if len(args) < 2: + show_set_help() + return + + if int(args[2]) > 1: + show_set_help() + return + + #print ALL_DEVICE[args[0]] + for i in range(0, len(ALL_DEVICE[args[0]])): + for j in ALL_DEVICE[args[0]][args[0] + str(args[1])]: + if j.find('tx_disable') != -1: + ret, log = log_os_system("echo " + args[2] + " >" + j, 1) + if ret: + return ret + + return + +# get digits inside a string. +# Ex: 31 for "sfp31" + + +def get_value(input): + digit = re.findall(r'\d+', input) + return int(digit[0]) + + +def device_traversal(): + if system_ready() == False: + print("System's not ready.") + print("Please install first!") + return + + if len(ALL_DEVICE) == 0: + devices_info() + for i in sorted(ALL_DEVICE.keys()): + print("============================================") + print(i.upper() + ": ") + print("============================================") + + for j in sorted(ALL_DEVICE[i].keys(), key=get_value): + print " " + j + ":", + for k in (ALL_DEVICE[i][j]): + ret, log = log_os_system("cat " + k, 0) + func = k.split("/")[-1].strip() + func = re.sub(j + '_', '', func, 1) + func = re.sub(i.lower() + '_', '', func, 1) + if ret == 0: + print func + "=" + log + " ", + else: + print func + "=" + "X" + " ", + print + print("----------------------------------------------------------------") + + print + return + + +def device_exist(): + ret1, log = log_os_system("ls " + i2c_prefix + "*0077", 0) + ret2, log = log_os_system("ls " + i2c_prefix + "i2c-2", 0) + return not(ret1 or ret2) + + +if __name__ == "__main__": + main() diff --git a/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/handle_mgmt_interface.sh b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/handle_mgmt_interface.sh new file mode 100755 index 000000000000..82f4d5e02116 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/as4630-54te/utils/handle_mgmt_interface.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +#Due to the hardware design, as4630-54te use "eth2" instead of "eth0" as management interface. +#Rename netdev "eth0" and "eth2" to swap original "eth2" to "eth0". +ifconfig eth0 down +ip link set eth0 name eth3 +ip link set eth2 name eth0 +ifconfig eth0 up diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/control b/platform/broadcom/sonic-platform-modules-accton/debian/control index 2b3c1af3d80f..431e177cea48 100755 --- a/platform/broadcom/sonic-platform-modules-accton/debian/control +++ b/platform/broadcom/sonic-platform-modules-accton/debian/control @@ -45,6 +45,10 @@ Package: sonic-platform-accton-as4630-54pe Architecture: amd64 Description: kernel modules for platform devices such as fan, led, sfp +Package: sonic-platform-accton-as4630-54te +Architecture: amd64 +Description: kernel modules for platform devices such as fan, led, sfp + Package: sonic-platform-accton-minipack Architecture: amd64 Description: kernel modules for platform devices such as fan, led, sfp diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/rules b/platform/broadcom/sonic-platform-modules-accton/debian/rules index e894b10f8234..a672ec655d41 100755 --- a/platform/broadcom/sonic-platform-modules-accton/debian/rules +++ b/platform/broadcom/sonic-platform-modules-accton/debian/rules @@ -21,7 +21,7 @@ KVERSION ?= $(shell uname -r) KERNEL_SRC := /lib/modules/$(KVERSION) MOD_SRC_DIR:= $(shell pwd) MODULE_DIRS := as7712-32x as5712-54x as7816-64x as7716-32x as7716-32xb as7312-54x -MODULE_DIRS += as7326-56x as6712-32x as7726-32x as4630-54pe minipack as5812-54x +MODULE_DIRS += as7326-56x as6712-32x as7726-32x as4630-54pe as4630-54te minipack as5812-54x MODULE_DIRS += as5835-54x as9716-32d as5835-54t as7312-54xs as7315-27xb as5812-54t MODULE_DIR := modules UTILS_DIR := utils diff --git a/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as4630-54te.install b/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as4630-54te.install new file mode 100644 index 000000000000..fe4f35f1e2c1 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-accton/debian/sonic-platform-accton-as4630-54te.install @@ -0,0 +1,2 @@ +as4630-54te/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-accton_as4630_54te-r0 + From 5e44bc5e6819d11c3972f98054b5fa851d227835 Mon Sep 17 00:00:00 2001 From: Kebo Liu Date: Mon, 1 Mar 2021 16:01:50 +0800 Subject: [PATCH 0227/1674] [Mellanox] Update hw-management package to version 7.0010.2000 (#6692) - Why I did it Bug fixes - In rare cases when thermal algorithm is reactivated after FAN/PSU insertion, FAN remains at high rpm - When stop hw-management code received error in the log instead of exit code '0'. - In SPC1 i2c sometimes collide with chip reset coming from SDK - Remove raw eeprom data link, when working with PSU which don't have eeprom for "msn274x", "msn24xx" and "msn27xx" systems - Fix memory leak on mlxsw_core_bus_device module removal - How I did it Update the hw-mgmt version number in the make file Update the hw-mgmt repo pointer - How to verify it run platform related test cases on all Mellanox platform Signed-off-by: Kebo Liu --- platform/mellanox/hw-management.mk | 2 +- platform/mellanox/hw-management/hw-mgmt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/mellanox/hw-management.mk b/platform/mellanox/hw-management.mk index 521daa1c7c3b..c273f779cbb2 100644 --- a/platform/mellanox/hw-management.mk +++ b/platform/mellanox/hw-management.mk @@ -1,6 +1,6 @@ # Mellanox HW Management -MLNX_HW_MANAGEMENT_VERSION = 7.0010.1300 +MLNX_HW_MANAGEMENT_VERSION = 7.0010.2000 export MLNX_HW_MANAGEMENT_VERSION diff --git a/platform/mellanox/hw-management/hw-mgmt b/platform/mellanox/hw-management/hw-mgmt index dec7935777b5..4ae17192db86 160000 --- a/platform/mellanox/hw-management/hw-mgmt +++ b/platform/mellanox/hw-management/hw-mgmt @@ -1 +1 @@ -Subproject commit dec7935777b52d31a2220bad8b0cec4b71ec0961 +Subproject commit 4ae17192db868de19ea0725860b320c0d319d23a From 4893666b1d829d6858bbac22cbb2f414140a35ce Mon Sep 17 00:00:00 2001 From: Aravind Mani <53524901+aravindmani-1@users.noreply.github.com> Date: Thu, 25 Feb 2021 23:47:05 +0530 Subject: [PATCH 0228/1674] DellEMC:Fix EEPROM read error (#6736) #### Why I did it EEPROM read failure was seen in Dell platforms #### How I did it Make python 2/3 compliant API's to fix the issue --- .../s5232f/sonic_platform/sfp.py | 9 +++- .../z9264f/sonic_platform/sfp.py | 9 +++- .../z9332f/sonic_platform/sfp.py | 42 ++++++++++++------- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/sfp.py index b2cceab9b08f..eed6dc7b03da 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/sfp.py @@ -214,8 +214,13 @@ def _read_eeprom_bytes(self, eeprom_path, offset, num_bytes): return None try: - for n in range(0, num_bytes): - eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2) + if isinstance(raw , str): + for n in range(0, num_bytes): + eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2) + else: + for n in range(0, num_bytes): + eeprom_raw[n] = hex(raw[n])[2:].zfill(2) + except BaseException: eeprom.close() return None diff --git a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/sfp.py index 225aef90e00a..4ede81f3d169 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/sfp.py @@ -219,8 +219,13 @@ def _read_eeprom_bytes(self, eeprom_path, offset, num_bytes): return None try: - for n in range(0, num_bytes): - eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2) + if isinstance(raw , str): + for n in range(0, num_bytes): + eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2) + else: + for n in range(0, num_bytes): + eeprom_raw[n] = hex(raw[n])[2:].zfill(2) + except BaseException: eeprom.close() return None diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/sfp.py index ef6a2c5d339a..efda0d13c63f 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/sfp.py @@ -283,8 +283,13 @@ def _read_eeprom_bytes(self, eeprom_path, offset, num_bytes): return None try: - for n in range(0, num_bytes): - eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2) + if isinstance(raw , str): + for n in range(0, num_bytes): + eeprom_raw[n] = hex(ord(raw[n]))[2:].zfill(2) + else: + for n in range(0, num_bytes): + eeprom_raw[n] = hex(raw[n])[2:].zfill(2) + except BaseException: eeprom.close() return None @@ -296,7 +301,7 @@ def _get_eeprom_data(self, eeprom_key): eeprom_data = None page_offset = None - if(self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): + if self.media_type.startswith('QSFP'): page_offset = sff8436_parser[eeprom_key][PAGE_OFFSET] eeprom_data_raw = self._read_eeprom_bytes( self.eeprom_path, @@ -351,7 +356,8 @@ def get_transceiver_info(self): compliance_code_dict = {} transceiver_info_dict = dict.fromkeys(info_dict_keys, 'N/A') self.media_type = self.set_media_type() - self.reinit_sfp_driver() + if self.reinit_sfp_driver() == False: + return transceiver_info_dict # BaseInformation try: @@ -362,7 +368,7 @@ def get_transceiver_info(self): rate_identifier = iface_data['data']['RateIdentifier']['value'] identifier = iface_data['data']['type']['value'] type_abbrv_name=iface_data['data']['type_abbrv_name']['value'] - if(self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): + if self.media_type.startswith('QSFP'): bit_rate = str( iface_data['data']['Nominal Bit Rate(100Mbs)']['value']) for key in qsfp_compliance_code_tup: @@ -459,7 +465,7 @@ def get_transceiver_threshold_info(self): try: # Module Threshold module_threshold_data = self._get_eeprom_data('ModuleThreshold') - if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): + if self.media_type.startswith('QSFP'): transceiver_dom_threshold_dict['temphighalarm'] = module_threshold_data['data']['TempHighAlarm']['value'] transceiver_dom_threshold_dict['temphighwarning'] = module_threshold_data['data']['TempHighWarning']['value'] transceiver_dom_threshold_dict['templowalarm'] = module_threshold_data['data']['TempLowAlarm']['value'] @@ -492,7 +498,7 @@ def get_transceiver_threshold_info(self): except (ValueError, TypeError) : pass try: - if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): + if self.media_type.startswith('QSFP'): channel_threshold_data = self._get_eeprom_data('ChannelThreshold') transceiver_dom_threshold_dict['rxpowerhighalarm'] = channel_threshold_data['data']['RxPowerHighAlarm']['value'] transceiver_dom_threshold_dict['rxpowerhighwarning'] = channel_threshold_data['data']['RxPowerHighWarning']['value'] @@ -659,7 +665,7 @@ def get_rx_los(self): """ rx_los = False try: - if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): + if self.media_type.startswith('QSFP'): rx_los_data = self._get_eeprom_data('rx_los') # As the function expects a single boolean, if any one channel experience LOS, # is considered LOS for QSFP @@ -679,7 +685,7 @@ def get_tx_fault(self): """ tx_fault = False try: - if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): + if self.media_type.startswith('QSFP'): tx_fault_data = self._get_eeprom_data('tx_fault') for tx_fault_id in ('Tx1Fault', 'Tx2Fault', 'Tx3Fault', 'Tx4Fault') : tx_fault |= (tx_fault_data['data'][tx_fault_id]['value'] is 'On') @@ -697,7 +703,7 @@ def get_tx_disable(self): """ tx_disable = False try: - if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): + if self.media_type.startswith('QSFP'): tx_disable_data = self._get_eeprom_data('tx_disable') for tx_disable_id in ('Tx1Disable', 'Tx2Disable', 'Tx3Disable', 'Tx4Disable'): tx_disable |= (tx_disable_data['data'][tx_disable_id]['value'] is 'On') @@ -717,7 +723,7 @@ def get_tx_disable_channel(self): """ tx_disable_channel = 0 try: - if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): + if self.media_type.startswith('QSFP'): tx_disable_data = self._get_eeprom_data('tx_disable') for tx_disable_id in ('Tx1Disable', 'Tx2Disable', 'Tx3Disable', 'Tx4Disable'): tx_disable_channel <<= 1 @@ -732,7 +738,7 @@ def get_lpmode(self): """ lpmode_state = False try: - if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): + if self.media_type.startswith('QSFP'): # Port offset starts with 0x4000 port_offset = 16384 + ((self.index-1) * 16) @@ -753,7 +759,7 @@ def get_power_override(self): power_override_state = False try: - if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): + if self.media_type.startswith('QSFP'): power_override_data = self._get_eeprom_data('power_override') power_override = power_override_data['data']['PowerOverRide']['value'] power_override_state = (power_override is 'On') @@ -791,7 +797,7 @@ def get_tx_bias(self): tx_bias_list = [] try: tx_bias_data = self._get_eeprom_data('ChannelMonitor') - if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): + if self.media_type.startswith('QSFP'): for tx_bias_id in ('TX1Bias', 'TX2Bias', 'TX3Bias', 'TX4Bias') : tx_bias = tx_bias_data['data'][tx_bias_id]['value'] tx_bias_list.append(tx_bias) @@ -809,7 +815,7 @@ def get_rx_power(self): rx_power_list = [] try: rx_power_data = self._get_eeprom_data('ChannelMonitor') - if (self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): + if self.media_type.startswith('QSFP'): for rx_power_id in ('RX1Power', 'RX2Power', 'RX3Power', 'RX4Power'): rx_power = rx_power_data['data'][rx_power_id]['value'] rx_power_list.append(rx_power) @@ -826,7 +832,7 @@ def get_tx_power(self): """ tx_power_list = [] try: - if(self.media_type == 'QSFP' or self.media_type == 'QSFP-DD'): + if self.media_type.startswith('QSFP'): # 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 @@ -1003,6 +1009,10 @@ def reinit_sfp_driver(self): driver_path = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/name".format(self._port_to_i2c_mapping[self.index]) delete_device = "echo 0x50 >" + del_sfp_path + if not os.path.isfile(driver_path): + print(driver_path, "does not exist") + return False + try: with os.fdopen(os.open(driver_path, os.O_RDONLY)) as fd: driver_name = fd.read() From a21babef114b06ce9eeb2ff6fd83e907e381a051 Mon Sep 17 00:00:00 2001 From: Eran Dahan Date: Wed, 24 Feb 2021 19:49:58 +0200 Subject: [PATCH 0229/1674] [Docker] Added support for python2 (#6753) - Why I did it Mellanox SDK APIs support python 2 at the moment. - How I did it Mellanox SDK APIs support python 2 at the moment. - How to verify it Add python 2 to Mellanox syncd only. - Which release branch to backport (provide reason below if selected) docker exec -t syncd /bin/bash -c "sx_api_dbg_generate_dump.py /home/sx_api_dbg_dump" You can see that it will work and generate /home/sx_api_dbg_dump Signed-off-by: allas --- platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 b/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 index 5c9ac6c1c145..c862106c2b63 100755 --- a/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 +++ b/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 @@ -11,7 +11,13 @@ ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && \ apt-get install -y \ - libxml2 + libxml2 \ + python-pip \ + python-dev \ + python-setuptools + +RUN pip2 install --upgrade pip +RUN apt-get purge -y python-pip {% if docker_syncd_mlnx_debs.strip() -%} # Copy locally-built Debian package dependencies From bc3a1de4c0809d89c224eedcff7f3cf749bbc6ff Mon Sep 17 00:00:00 2001 From: shlomibitton <60430976+shlomibitton@users.noreply.github.com> Date: Thu, 25 Feb 2021 12:41:29 +0200 Subject: [PATCH 0230/1674] [Mellanox] Add hw-mgmt patch for SimX platform adaptation (#6782) - Why I did it System is stuck on 'starting' state on SimX platform because of infinite loop on 'hw-management-ready.sh' script . The loop is polling to check if the hw-mgmt sysfs created before proceeding with the flow, for SimX platform the sysfs will never create so the system is not starting properly. - How I did it Add a condition to poll on hw-mgmt sysfs only if the switch is real HW and not SimX platform. - How to verify it Check "systemctl status hw-management.service" output on a SimX switch with this patch, the state will be "active". Signed-off-by: Shlomi Bitton --- .../0003-Make-hw-mgmt-SimX-compatiable.patch | 48 +++++++++++++++++++ platform/mellanox/mlnx-fw-upgrade.j2 | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 platform/mellanox/hw-management/0003-Make-hw-mgmt-SimX-compatiable.patch diff --git a/platform/mellanox/hw-management/0003-Make-hw-mgmt-SimX-compatiable.patch b/platform/mellanox/hw-management/0003-Make-hw-mgmt-SimX-compatiable.patch new file mode 100644 index 000000000000..0eb3daa7977e --- /dev/null +++ b/platform/mellanox/hw-management/0003-Make-hw-mgmt-SimX-compatiable.patch @@ -0,0 +1,48 @@ +diff --git a/usr/usr/bin/hw-management-ready.sh b/usr/usr/bin/hw-management-ready.sh +index 3c9f7b6..05d143f 100755 +--- a/usr/usr/bin/hw-management-ready.sh ++++ b/usr/usr/bin/hw-management-ready.sh +@@ -49,9 +49,12 @@ if [ -d /var/run/hw-management ]; then + rm -fr /var/run/hw-management + fi + +-while [ ! -d /sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon ] +-do +- sleep 1 +-done ++if [ -z "$(lspci -vvv | grep SimX)" ]; then ++ while [ ! -d /sys/devices/platform/mlxplat/mlxreg-hotplug/hwmon ] ++ do ++ sleep 1 ++ done ++fi ++ + echo "Start Chassis HW management service." + logger -t hw-management -p daemon.notice "Start Chassis HW management service." +diff --git a/usr/usr/bin/hw-management.sh b/usr/usr/bin/hw-management.sh +index 70f1297..e427a3d 100755 +--- a/usr/usr/bin/hw-management.sh ++++ b/usr/usr/bin/hw-management.sh +@@ -1110,6 +1110,13 @@ do_chip_down() + /usr/bin/hw-management-thermal-events.sh change hotplug_asic down %S %p + } + ++check_simx() ++{ ++ if [ -n "$(lspci -vvv | grep SimX)" ]; then ++ exit 0 ++ fi ++} ++ + __usage=" + Usage: $(basename $0) [Options] + +@@ -1135,6 +1142,8 @@ Options: + force-reload Performs hw-management 'stop' and the 'start. + " + ++check_simx ++ + case $ACTION in + start) + if [ -d /var/run/hw-management ]; then diff --git a/platform/mellanox/mlnx-fw-upgrade.j2 b/platform/mellanox/mlnx-fw-upgrade.j2 index 245ce75d5f18..e17ec176503c 100755 --- a/platform/mellanox/mlnx-fw-upgrade.j2 +++ b/platform/mellanox/mlnx-fw-upgrade.j2 @@ -251,7 +251,7 @@ function UpgradeFWFromImage() { } function ExitIfQEMU() { - if [[ $(cat /sys/devices/virtual/dmi/id/chassis_vendor) = "QEMU" ]]; then + if [ -n "$(lspci -vvv | grep SimX)" ]; then ExitSuccess "No FW upgrade for SimX platform" fi } From 40e445794b258620b525a52cb3ee61ec810a46b0 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Wed, 24 Feb 2021 16:41:03 -0800 Subject: [PATCH 0231/1674] Use 'importlib' module in lieu of deprecated 'imp' module (#6832) Migrate from using the `imp` module to using the `importlib` module. As of Python 3, the `imp` module has been deprecated in favor of the `importlib` module. --- .../scripts/procdockerstatsd | 2 +- .../tests/determine-reboot-cause_test.py | 62 +++++++++---------- .../tests/procdockerstatsd_test.py | 13 ++-- .../sonic_py_common/daemon_base.py | 15 ++++- 4 files changed, 53 insertions(+), 39 deletions(-) diff --git a/src/sonic-host-services/scripts/procdockerstatsd b/src/sonic-host-services/scripts/procdockerstatsd index 90b7bd10c95f..d0b4c8fbf2ac 100755 --- a/src/sonic-host-services/scripts/procdockerstatsd +++ b/src/sonic-host-services/scripts/procdockerstatsd @@ -72,7 +72,7 @@ class ProcDockerStats(daemon_base.DaemonBase): UNITS_MiB = 'MiB' UNITS_GiB = 'GiB' - res = re.match('(\d+\.?\d*)([a-zA-Z]+)', value) + res = re.match(r'(\d+\.?\d*)([a-zA-Z]+)', value) value = float(res.groups()[0]) units = res.groups()[1] if units.lower() == UNITS_KB.lower(): diff --git a/src/sonic-host-services/tests/determine-reboot-cause_test.py b/src/sonic-host-services/tests/determine-reboot-cause_test.py index afd74957b6f4..924befdf48ee 100644 --- a/src/sonic-host-services/tests/determine-reboot-cause_test.py +++ b/src/sonic-host-services/tests/determine-reboot-cause_test.py @@ -1,4 +1,4 @@ -import imp +import importlib import sys import os import pytest @@ -28,6 +28,15 @@ scripts_path = os.path.join(modules_path, "scripts") sys.path.insert(0, modules_path) +# Load the file under test +determine_reboot_cause_path = os.path.join(scripts_path, 'determine-reboot-cause') +loader = importlib.machinery.SourceFileLoader('determine_reboot_cause', determine_reboot_cause_path) +spec = importlib.util.spec_from_loader(loader.name, loader) +determine_reboot_cause = importlib.util.module_from_spec(spec) +loader.exec_module(determine_reboot_cause) +sys.modules['determine_reboot_cause'] = determine_reboot_cause + + PROC_CMDLINE_CONTENTS = """\ BOOT_IMAGE=/image-20191130.52/boot/vmlinuz-4.9.0-11-2-amd64 root=/dev/sda4 rw console=tty0 console=ttyS1,9600n8 quiet net.ifnames=0 biosdevname=0 loop=image-20191130.52/fs.squashfs loopfstype=squashfs apparmor=1 security=apparmor varlog_size=4096 usbcore.autosuspend=-1 module_blacklist=gpio_ich SONIC_BOOT_TYPE=warm""" @@ -37,9 +46,9 @@ BOOT_IMAGE=/image-20191130.52/boot/vmlinuz-4.9.0-11-2-amd64 root=/dev/sda4 rw console=tty0 console=ttyS1,9600n8 quiet net.ifnames=0 biosdevname=0 loop=image-20191130.52/fs.squashfs loopfstype=squashfs apparmor=1 security=apparmor varlog_size=4096 usbcore.autosuspend=-1 module_blacklist=gpio_ich SONIC_BOOT_TYPE=warm""" REBOOT_CAUSE_CONTENTS = """\ -User issued 'warm-reboot' command [User: admin, Time: Mon Nov 2 22:37:45 UTC 2020]""" +User issued 'warm-reboot' command [User: admin, Time: Mon Nov 2 22:37:45 UTC 2020]""" -GET_SONIC_VERSION_INFO = {'commit_id': 'e59ec8291', 'build_date': 'Mon Nov 2 06:00:14 UTC 2020', 'build_number': 75, 'kernel_version': '4.9.0-11-2-amd64', 'debian_version': '9.13', 'built_by': 'sonicbld@jenkins-slave-phx-2', 'asic_type': 'mellanox', 'build_version': '20191130.52'} +GET_SONIC_VERSION_INFO = {'commit_id': 'e59ec8291', 'build_date': 'Mon Nov 2 06:00:14 UTC 2020', 'build_number': 75, 'kernel_version': '4.9.0-11-2-amd64', 'debian_version': '9.13', 'built_by': 'sonicbld@jenkins-slave-phx-2', 'asic_type': 'mellanox', 'build_version': '20191130.52'} REBOOT_CAUSE_WATCHDOG = "Watchdog" GEN_TIME_WATCHDOG = "2020_10_22_03_15_08" @@ -55,63 +64,52 @@ EXPECTED_WATCHDOG_REBOOT_CAUSE_DICT = {'comment': '', 'gen_time': '2020_10_22_03_15_08', 'cause': 'Watchdog', 'user': 'N/A', 'time': 'N/A'} EXPECTED_USER_REBOOT_CAUSE_DICT = {'comment': '', 'gen_time': '2020_10_22_03_14_07', 'cause': 'reboot', 'user': 'admin', 'time': 'Thu Oct 22 03:11:08 UTC 2020'} -imp.load_source('determine_reboot_cause', scripts_path + '/determine-reboot-cause') -from determine_reboot_cause import * class TestDetermineRebootCause(object): - @classmethod - def setup_class(cls): - print("SETUP") - def test_parse_warmfast_reboot_from_proc_cmdline(self): with mock.patch("os.path.isfile") as mock_isfile: mock_isfile.return_value = True - open_mocked = mock.mock_open(read_data=PROC_CMDLINE_CONTENTS) - with mock.patch("{}.open".format(BUILTINS), open_mocked): - result = parse_warmfast_reboot_from_proc_cmdline() + open_mocked = mock.mock_open(read_data=PROC_CMDLINE_CONTENTS) + with mock.patch("{}.open".format(BUILTINS), open_mocked): + result = determine_reboot_cause.parse_warmfast_reboot_from_proc_cmdline() assert result == EXPECTED_PARSE_WARMFAST_REBOOT_FROM_PROC_CMDLINE - open_mocked.assert_called_once_with("/proc/cmdline") + open_mocked.assert_called_once_with("/proc/cmdline") def test_find_software_reboot_cause_user(self): - with mock.patch("os.path.isfile") as mock_isfile: - mock_isfile.return_value = True - open_mocked = mock.mock_open(read_data=REBOOT_CAUSE_CONTENTS) - with mock.patch("{}.open".format(BUILTINS), open_mocked): - result = find_software_reboot_cause_from_reboot_cause_file() + with mock.patch("os.path.isfile") as mock_isfile: + mock_isfile.return_value = True + open_mocked = mock.mock_open(read_data=REBOOT_CAUSE_CONTENTS) + with mock.patch("{}.open".format(BUILTINS), open_mocked): + result = determine_reboot_cause.find_software_reboot_cause_from_reboot_cause_file() assert result == EXPECTED_FIND_SOFTWARE_REBOOT_CAUSE_USER - open_mocked.assert_called_once_with("/host/reboot-cause/reboot-cause.txt") + open_mocked.assert_called_once_with("/host/reboot-cause/reboot-cause.txt") def test_find_software_reboot_cause_first_boot(self): with mock.patch("sonic_py_common.device_info.get_sonic_version_info", return_value=GET_SONIC_VERSION_INFO): - result = find_first_boot_version() + result = determine_reboot_cause.find_first_boot_version() assert result == EXPECTED_FIND_FIRSTBOOT_VERSION def test_find_software_reboot_cause(self): with mock.patch("determine_reboot_cause.find_software_reboot_cause_from_reboot_cause_file", return_value="Unknown"): - with mock.patch("os.path.isfile") as mock_isfile: - mock_isfile.return_value = False - result = find_software_reboot_cause() + with mock.patch("os.path.isfile") as mock_isfile: + mock_isfile.return_value = False + result = determine_reboot_cause.find_software_reboot_cause() assert result == "Unknown" def test_find_proc_cmdline_reboot_cause(self): with mock.patch("determine_reboot_cause.parse_warmfast_reboot_from_proc_cmdline", return_value="fast-reboot"): - result = find_proc_cmdline_reboot_cause() + result = determine_reboot_cause.find_proc_cmdline_reboot_cause() assert result == "fast-reboot" def test_find_hardware_reboot_cause(self): with mock.patch("determine_reboot_cause.get_reboot_cause_from_platform", return_value=("Powerloss", None)): - result = find_hardware_reboot_cause() + result = determine_reboot_cause.find_hardware_reboot_cause() assert result == "Powerloss (None)" def test_get_reboot_cause_dict_watchdog(self): - reboot_cause_dict = get_reboot_cause_dict(REBOOT_CAUSE_WATCHDOG, "", GEN_TIME_WATCHDOG) + reboot_cause_dict = determine_reboot_cause.get_reboot_cause_dict(REBOOT_CAUSE_WATCHDOG, "", GEN_TIME_WATCHDOG) assert reboot_cause_dict == EXPECTED_WATCHDOG_REBOOT_CAUSE_DICT def test_get_reboot_cause_dict_user(self): - reboot_cause_dict = get_reboot_cause_dict(REBOOT_CAUSE_USER, "", GEN_TIME_USER) + reboot_cause_dict = determine_reboot_cause.get_reboot_cause_dict(REBOOT_CAUSE_USER, "", GEN_TIME_USER) assert reboot_cause_dict == EXPECTED_USER_REBOOT_CAUSE_DICT - - @classmethod - def teardown_class(cls): - print("TEARDOWN") - diff --git a/src/sonic-host-services/tests/procdockerstatsd_test.py b/src/sonic-host-services/tests/procdockerstatsd_test.py index 5c47e91458f3..db7c6a1f0e3d 100644 --- a/src/sonic-host-services/tests/procdockerstatsd_test.py +++ b/src/sonic-host-services/tests/procdockerstatsd_test.py @@ -1,4 +1,4 @@ -import imp +import importlib import sys import os import pytest @@ -14,8 +14,13 @@ scripts_path = os.path.join(modules_path, "scripts") sys.path.insert(0, modules_path) -imp.load_source('procdockerstatsd', scripts_path + '/procdockerstatsd') -from procdockerstatsd import * +# Load the file under test +procdockerstatsd_path = os.path.join(scripts_path, 'procdockerstatsd') +loader = importlib.machinery.SourceFileLoader('procdockerstatsd', procdockerstatsd_path) +spec = importlib.util.spec_from_loader(loader.name, loader) +procdockerstatsd = importlib.util.module_from_spec(spec) +loader.exec_module(procdockerstatsd) +sys.modules['procdockerstatsd'] = procdockerstatsd class TestProcDockerStatsDaemon(object): def test_convert_to_bytes(self): @@ -35,7 +40,7 @@ def test_convert_to_bytes(self): ('7.751GiB', 8322572878) ] - pdstatsd = ProcDockerStats(SYSLOG_IDENTIFIER) + pdstatsd = procdockerstatsd.ProcDockerStats(procdockerstatsd.SYSLOG_IDENTIFIER) for test_input, expected_output in test_data: res = pdstatsd.convert_to_bytes(test_input) diff --git a/src/sonic-py-common/sonic_py_common/daemon_base.py b/src/sonic-py-common/sonic_py_common/daemon_base.py index c3ecc12cf856..3797c19b6b7d 100644 --- a/src/sonic-py-common/sonic_py_common/daemon_base.py +++ b/src/sonic-py-common/sonic_py_common/daemon_base.py @@ -1,4 +1,4 @@ -import imp +import importlib import signal import sys @@ -25,10 +25,21 @@ def db_connect(db_name, namespace=EMPTY_NAMESPACE): from swsscommon import swsscommon return swsscommon.DBConnector(db_name, REDIS_TIMEOUT_MSECS, True, namespace) + +def _load_module_from_file(module_name, file_path): + loader = importlib.machinery.SourceFileLoader(module_name, file_path) + spec = importlib.util.spec_from_loader(loader.name, loader) + module = importlib.util.module_from_spec(spec) + loader.exec_module(module) + sys.modules[module_name] = module + return module + + # # DaemonBase =================================================================== # + class DaemonBase(Logger): def __init__(self, log_identifier): super(DaemonBase, self).__init__( @@ -68,7 +79,7 @@ def load_platform_util(self, module_name, class_name): try: module_file = "/".join([platform_path, "plugins", module_name + ".py"]) - module = imp.load_source(module_name, module_file) + module = _load_module_from_file(module_name, module_file) except IOError as e: raise IOError("Failed to load platform module '%s': %s" % (module_name, str(e))) From 926572ee8291158c7da925d8a7a8a9cbea7a484c Mon Sep 17 00:00:00 2001 From: rkdevi27 <54701695+rkdevi27@users.noreply.github.com> Date: Thu, 25 Feb 2021 01:30:24 +0530 Subject: [PATCH 0232/1674] [dell/s6000]: Enable graceful reboot in S6000 (#6835) The S6000 devices, the cold reboot is abrupt and it is likely to cause issues which will cause the device to land into EFI shell. Hence the platform reboot will happen after graceful unmount of all the filesystems as in S6100. Moved the platform_reboot to platform_reboot_override and hooked it to the systemd shutdown services as in S6100 --- .../platform_reboot | 63 ------------------- .../debian/platform-modules-s6000.install | 3 + .../s6000/scripts/override.conf | 3 + .../s6000/scripts/platform_reboot_override | 27 ++++++++ .../scripts/platform_update_reboot_cause | 25 ++++++++ 5 files changed, 58 insertions(+), 63 deletions(-) delete mode 100755 device/dell/x86_64-dell_s6000_s1220-r0/platform_reboot create mode 100644 platform/broadcom/sonic-platform-modules-dell/s6000/scripts/override.conf create mode 100755 platform/broadcom/sonic-platform-modules-dell/s6000/scripts/platform_reboot_override create mode 100755 platform/broadcom/sonic-platform-modules-dell/s6000/scripts/platform_update_reboot_cause diff --git a/device/dell/x86_64-dell_s6000_s1220-r0/platform_reboot b/device/dell/x86_64-dell_s6000_s1220-r0/platform_reboot deleted file mode 100755 index 28f2ec626605..000000000000 --- a/device/dell/x86_64-dell_s6000_s1220-r0/platform_reboot +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/python3 - -import sys -import os -import struct - -PORT_RES = '/dev/port' -NVRAM_RES = '/dev/nvram' -COLD_RESET = 0xE # Cold Reset -WARM_RESET = 0x6 # Warm Reset -RESET_REG = 0xCF9 - -def io_reg_write(resource, offset, val): - fd = os.open(resource, os.O_RDWR) - if(fd < 0): - print('file open failed %s" % resource') - return - if(os.lseek(fd, offset, os.SEEK_SET) != offset): - print('lseek failed on %s' % resource) - return - ret = os.write(fd, struct.pack('B', val)) - if(ret != 1): - print('write failed %d' % ret) - return - os.close(fd) - -def power_reset(val): - with open('/sys/devices/platform/dell-s6000-cpld.0/power_reset', 'w') as p: - p.write(str(int(val)) + '\n') - p.flush() - -def gpio_direction(pin, direction): - kernpath = '/sys/class/gpio/gpio'+str(pin)+'/direction' - with open(('kernpath'), 'w') as p: - p.write(str(direction) + '\n') - p.flush() - -def gpio_set(pin, value): - kernpath = '/sys/class/gpio/gpio'+str(pin)+'/value' - with open(('kernpath'), 'w') as p: - p.write(str(int(value)) + '\n') - p.flush() - -def gpio_export(value): - with open('/sys/class/gpio/export', 'w') as p: - p.write(str(int(value)) + '\n') - p.flush() - -if __name__ == "__main__": - - retry_count = 0 - io_reg_write(NVRAM_RES, 0x49, COLD_RESET) - - while retry_count < 3: - if not os.path.isdir("/sys/class/gpio/gpio10"): - gpio_export(10) - gpio_direction("10", "out") - # Toggle GPIO10 pin (to reset MUX) - gpio_set("10", 1) - gpio_set("10", 0) - power_reset(1) - retry_count += 1 - io_reg_write(PORT_RES, RESET_REG, COLD_RESET) diff --git a/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6000.install b/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6000.install index d87efb31c488..e67a59485136 100644 --- a/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6000.install +++ b/platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6000.install @@ -5,5 +5,8 @@ s6000/scripts/fancontrol.sh usr/local/bin s6000/systemd/platform-modules-s6000.service etc/systemd/system s6000/systemd/fancontrol.service etc/systemd/system common/io_rd_wr.py usr/local/bin +s6000/scripts/platform_reboot_override usr/share/sonic/device/x86_64-dell_s6000_s1220-r0 +s6000/scripts/platform_update_reboot_cause usr/share/sonic/device/x86_64-dell_s6000_s1220-r0 +s6000/scripts/override.conf /etc/systemd/system/systemd-reboot.service.d s6000/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-dell_s6000_s1220-r0 s6000/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-dell_s6000_s1220-r0 diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/scripts/override.conf b/platform/broadcom/sonic-platform-modules-dell/s6000/scripts/override.conf new file mode 100644 index 000000000000..4291afe0d249 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/scripts/override.conf @@ -0,0 +1,3 @@ +[Service] +ExecStart= +ExecStart=/usr/share/sonic/device/x86_64-dell_s6000_s1220-r0/platform_reboot_override diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/scripts/platform_reboot_override b/platform/broadcom/sonic-platform-modules-dell/s6000/scripts/platform_reboot_override new file mode 100755 index 000000000000..cae804f2cfb1 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/scripts/platform_reboot_override @@ -0,0 +1,27 @@ +#!/usr/bin/python3 + +import os +import struct + +PORT_RES = '/dev/port' +COLD_RESET = 0xE # Cold Reset +WARM_RESET = 0x6 # Warm Reset +RESET_REG = 0xCF9 + +def io_reg_write(resource, offset, val): + fd = os.open(resource, os.O_RDWR) + if(fd < 0): + print('file open failed %s" % resource') + return + if(os.lseek(fd, offset, os.SEEK_SET) != offset): + print('lseek failed on %s' % resource) + return + ret = os.write(fd, struct.pack('B', val)) + if(ret != 1): + print('write failed %d' % ret) + return + os.close(fd) + + +if __name__ == "__main__": + io_reg_write(PORT_RES, RESET_REG, COLD_RESET) diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/scripts/platform_update_reboot_cause b/platform/broadcom/sonic-platform-modules-dell/s6000/scripts/platform_update_reboot_cause new file mode 100755 index 000000000000..ba6e3bbab539 --- /dev/null +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/scripts/platform_update_reboot_cause @@ -0,0 +1,25 @@ +#!/usr/bin/python3 + +import os +import struct + +NVRAM_RES = '/dev/nvram' +COLD_RESET = 0xE # Cold Reset +WARM_RESET = 0x6 # Warm Reset + +def io_reg_write(resource, offset, val): + fd = os.open(resource, os.O_RDWR) + if(fd < 0): + print('file open failed %s" % resource') + return + if(os.lseek(fd, offset, os.SEEK_SET) != offset): + print('lseek failed on %s' % resource) + return + ret = os.write(fd, struct.pack('B', val)) + if(ret != 1): + print('write failed %d' % ret) + return + os.close(fd) + +if __name__ == "__main__": + io_reg_write(NVRAM_RES, 0x49, COLD_RESET) From 3d52e3f69ab6695343998e8ebedd2a134cb6a380 Mon Sep 17 00:00:00 2001 From: Arun Saravanan Balachandran <52521751+ArunSaravananBalachandran@users.noreply.github.com> Date: Wed, 24 Feb 2021 20:42:01 +0000 Subject: [PATCH 0233/1674] DellEMC: S5232, Z9264, Z9332 - Platform API fixes (#6842) #### Why I did it To incorporate the below changes in DellEMC S5232, Z9264, Z9332 platforms. - Update thermal high threshold values - Make watchdog API Python2 and Python3 compatible - Fix LGTM alerts - Z9264: Fix get_change_event timer value #### How I did it - Use 'universal_newlines=True' in subprocess.Popen call. - Change the timeout in 'get_change_event' to milliseconds to match specification in sonic_platform_common/chassis_base.py --- .../s5232f/sonic_platform/chassis.py | 6 ++---- .../s5232f/sonic_platform/thermal.py | 9 ++++----- .../s5232f/sonic_platform/watchdog.py | 3 +-- .../z9264f/sonic_platform/chassis.py | 9 +++++---- .../z9264f/sonic_platform/component.py | 15 ++++++--------- .../z9264f/sonic_platform/sfp.py | 16 +++------------- .../z9264f/sonic_platform/thermal.py | 10 +++++----- .../z9264f/sonic_platform/watchdog.py | 7 +------ .../z9332f/sonic_platform/chassis.py | 2 +- .../z9332f/sonic_platform/thermal.py | 8 ++++---- 10 files changed, 32 insertions(+), 53 deletions(-) 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 1022d0bb481b..356e69526d89 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 @@ -87,7 +87,6 @@ def __del__(self): # check for this event change for sfp / do we need to handle timeout/sleep def get_change_event(self, timeout=0): - from time import sleep """ Returns a nested dictionary containing all devices which have experienced a change at chassis level @@ -116,7 +115,6 @@ def get_change_event(self, timeout=0): if (now_ms - start_ms >= timeout): return True, change_dict - def get_sfp(self, index): """ Retrieves sfp represented by (0-based) index @@ -136,7 +134,7 @@ def get_sfp(self, index): # The index will start from 0 sfp = self._sfp_list[index-1] except IndexError: - sys.stderr.write("SFP index {} out of range (0-{})\n".format( + sys.stderr.write("SFP index {} out of range (1-{})\n".format( index, len(self._sfp_list))) return sfp @@ -223,6 +221,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 @@ -259,4 +258,3 @@ def get_reboot_cause(self): return (self.REBOOT_CAUSE_HARDWARE_OTHER, "Reset Button Cold Reboot") else: return (self.REBOOT_CAUSE_NON_HARDWARE, None) - diff --git a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/thermal.py index d8c4ef14d5b2..2a6ff8927e0a 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/thermal.py @@ -105,9 +105,9 @@ def get_high_threshold(self): Celsius up to nearest thousandth of one degree Celsius, e.g. 30.125 """ - is_valid, high_threshold = self.sensor.get_threshold("UpperCritical") + is_valid, high_threshold = self.sensor.get_threshold("UpperNonCritical") if not is_valid: - high_threshold = 0 + return super(Thermal, self).get_high_threshold() return float(high_threshold) @@ -134,12 +134,11 @@ def get_high_critical_threshold(self): thermal in Celsius up to nearest thousandth of one degree Celsius, e.g. 30.125 """ - is_valid, high_crit_threshold = self.sensor.get_threshold("UpperNonRecoverable") + is_valid, high_crit_threshold = self.sensor.get_threshold("UpperCritical") if not is_valid: - high_crit_threshold = 0 + return super(Thermal, self).get_high_critical_threshold() return float(high_crit_threshold) - def set_high_threshold(self, temperature): """ diff --git a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/watchdog.py b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/watchdog.py index 878d5f4f952d..14485decc896 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/watchdog.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/watchdog.py @@ -43,7 +43,7 @@ def __init__(self): def _get_command_result(self, cmdline): try: proc = subprocess.Popen(cmdline.split(), stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, universal_newlines=True) stdout = proc.communicate()[0] proc.wait() result = stdout.rstrip('\n') @@ -207,4 +207,3 @@ def get_remaining_time(self): return self.timeout - diff_time return 0 - diff --git a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/chassis.py index 3f99cf503b3b..78e8dea999c8 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/chassis.py @@ -104,7 +104,7 @@ def _get_register(self, reg_file): try: with os.fdopen(os.open(reg_file, os.O_RDONLY)) as fd: retval = fd.read() - except: + except Exception: pass retval = retval.rstrip('\r\n') retval = retval.lstrip(" ") @@ -134,6 +134,8 @@ def get_change_event(self, timeout=0): port_dict = {} change_dict = {} change_dict['sfp'] = port_dict + if timeout != 0: + timeout = timeout / 1000 try: # We get notified when there is a MSI interrupt (vector 4/5)CVR # Open the sysfs file and register the epoll object @@ -174,7 +176,7 @@ def get_change_event(self, timeout=0): if (retval != 0): return False, change_dict return True, change_dict - except: + except Exception: return False, change_dict finally: if self.oir_fd != -1: @@ -183,7 +185,6 @@ def get_change_event(self, timeout=0): self.oir_fd.close() self.oir_fd = -1 self.epoll = -1 - return False, change_dict def get_sfp(self, index): """ @@ -281,7 +282,7 @@ def get_reboot_cause(self): try: with open(self.REBOOT_CAUSE_PATH) as fd: reboot_cause = int(fd.read(), 16) - except: + except Exception: return (self.REBOOT_CAUSE_NON_HARDWARE, None) if reboot_cause & 0x1: diff --git a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/component.py index 6ead7ef524f2..c4e2c06b135c 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/component.py @@ -10,7 +10,6 @@ ######################################################################## try: - import os import re from sonic_platform_base.component_base import ComponentBase @@ -24,17 +23,18 @@ class Component(ComponentBase): CHASSIS_COMPONENTS = [ ["BIOS", ("Performs initialization of hardware components during " - "booting")], + "booting")], ["FPGA", ("Used for managing the system LEDs")], ["BMC", ("Platform management controller for on-board temperature " - "monitoring, in-chassis power, Fan and LED control")], + "monitoring, in-chassis power, Fan and LED control")], ["System CPLD", ("Used for managing the CPU power sequence and CPU states")], ["Slave CPLD 1", ("Used for managing QSFP/QSFP28 port transceivers (1-16)")], ["Slave CPLD 2", ("Used for managing QSFP/QSFP28 port transceivers (17-32)")], ["Slave CPLD 3", ("Used for managing QSFP/QSFP28 port transceivers (33-48)")], ["Slave CPLD 4", ("Used for managing QSFP/QSFP28 port transceivers (49-64) and SFP/SFP28 " - "port transceivers (65 and 66)")], - ] + "port transceivers (65 and 66)")], + ] + def __init__(self, component_index=0): self.index = component_index self.name = self.CHASSIS_COMPONENTS[self.index][0] @@ -48,7 +48,6 @@ def get_name(self): """ return self.name - def get_description(self): """ Retrieves the description of the component @@ -77,7 +76,7 @@ def get_firmware_version(self): if version: rv = version.group(1).strip() return rv - + def install_firmware(self, image_path): """ Installs firmware to the component @@ -87,5 +86,3 @@ def install_firmware(self, image_path): A boolean, True if install was successful, False if not """ return False - - diff --git a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/sfp.py b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/sfp.py index 4ede81f3d169..d6d3e59b5891 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/sfp.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/sfp.py @@ -12,11 +12,7 @@ import os import time import struct - import sys - import getopt - import select import mmap - from sonic_platform_base.chassis_base import ChassisBase from sonic_platform_base.sfp_base import SfpBase from sonic_platform_base.sonic_sfp.sff8436 import sff8436InterfaceId from sonic_platform_base.sonic_sfp.sff8436 import sff8436Dom @@ -976,7 +972,7 @@ def reset(self): reg_value = reg_value & ~mask # Convert our register value back to a hex string and write back - status = self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset) + self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset) # Sleep 1 second to allow it to settle time.sleep(1) @@ -984,7 +980,7 @@ def reset(self): reg_value = reg_value | mask # Convert our register value back to a hex string and write back - status = self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset) + self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset) return True @@ -1016,7 +1012,7 @@ def set_lpmode(self, lpmode): reg_value = reg_value & ~mask # Convert our register value back to a hex string and write back - status = self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset) + self.pci_set_value(self.BASE_RES_PATH, reg_value, port_offset) return True @@ -1035,12 +1031,6 @@ def tx_disable_channel(self, channel, disable): """ return False - def tx_disable_channel(self, channel, disable): - """ - Sets the tx_disable for specified SFP channels - """ - return False - def set_power_override(self, power_override, power_set): """ Sets SFP power level using power_override and power_set diff --git a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/thermal.py index 1f3caaa02dd3..d6432f66bcab 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/thermal.py @@ -11,7 +11,7 @@ try: from sonic_platform_base.thermal_base import ThermalBase - from sonic_platform.ipmihelper import IpmiSensor, IpmiFru + from sonic_platform.ipmihelper import IpmiSensor except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -105,9 +105,9 @@ def get_high_threshold(self): Celsius up to nearest thousandth of one degree Celsius, e.g. 30.125 """ - is_valid, high_threshold = self.sensor.get_threshold("UpperCritical") + is_valid, high_threshold = self.sensor.get_threshold("UpperNonCritical") if not is_valid: - high_threshold = 0 + return super(Thermal, self).get_high_threshold() return float(high_threshold) @@ -135,9 +135,9 @@ def get_high_critical_threshold(self): thermal in Celsius up to nearest thousandth of one degree Celsius, e.g. 30.125 """ - is_valid, high_crit_threshold = self.sensor.get_threshold("UpperNonRecoverable") + is_valid, high_crit_threshold = self.sensor.get_threshold("UpperCritical") if not is_valid: - high_crit_threshold = 0 + return super(Thermal, self).get_high_critical_threshold() return float(high_crit_threshold) diff --git a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/watchdog.py b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/watchdog.py index d3363067db63..0ecb42685c6d 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/watchdog.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/watchdog.py @@ -10,8 +10,6 @@ ######################################################################## try: - import sys - import struct import ctypes import subprocess from sonic_platform_base.watchdog_base import WatchdogBase @@ -45,7 +43,7 @@ def __init__(self): def _get_command_result(self, cmdline): try: proc = subprocess.Popen(cmdline.split(), stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, universal_newlines=True) stdout = proc.communicate()[0] proc.wait() result = stdout.rstrip('\n') @@ -139,8 +137,6 @@ def arm(self, seconds): self.timeout = seconds return seconds - return -1 - def disarm(self): """ Disarm the hardware watchdog @@ -211,4 +207,3 @@ def get_remaining_time(self): return self.timeout - diff_time return 0 - diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/chassis.py b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/chassis.py index cead0eb326ef..8ac97943cc09 100755 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/chassis.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/chassis.py @@ -200,7 +200,7 @@ def get_sfp(self, index): # The index will start from 0 sfp = self._sfp_list[index-1] except IndexError: - sys.stderr.write("SFP index {} out of range (0-{})\n".format( + sys.stderr.write("SFP index {} out of range (1-{})\n".format( index, len(self._sfp_list))) return sfp diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/thermal.py index 86d5f9492d50..1c7fe59857a3 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/thermal.py @@ -111,9 +111,9 @@ def get_high_threshold(self): Celsius up to nearest thousandth of one degree Celsius, e.g. 30.125 """ - is_valid, high_threshold = self.sensor.get_threshold("UpperCritical") + is_valid, high_threshold = self.sensor.get_threshold("UpperNonCritical") if not is_valid: - high_threshold = 0 + return super(Thermal, self).get_high_threshold() return float(high_threshold) @@ -140,9 +140,9 @@ def get_high_critical_threshold(self): thermal in Celsius up to nearest thousandth of one degree Celsius, e.g. 30.125 """ - is_valid, high_crit_threshold = self.sensor.get_threshold("UpperNonRecoverable") + is_valid, high_crit_threshold = self.sensor.get_threshold("UpperCritical") if not is_valid: - high_crit_threshold = 0 + return super(Thermal, self).get_high_critical_threshold() return float(high_crit_threshold) From 7748597fa2416aa5e723f2c936b821318c972845 Mon Sep 17 00:00:00 2001 From: yozhao101 <56170650+yozhao101@users.noreply.github.com> Date: Thu, 25 Feb 2021 14:35:29 -0800 Subject: [PATCH 0234/1674] [Supervisord] Deduplicate the alerting messages of critical processes from Supervisord. (#6849) Signed-off-by: Yong Zhao yozhao@microsoft.com Why I did it In the configuration of rsyslog, duplicate messages will be suppressed and reported in the format of message repeated n times. Due to this behavior, if a critical process in a container exited unexpectedly, the alerting message will be written into syslog once and not be written into syslog anymore until the second critical process exited. This PR aims to differentiate these alerting messages such that they will not be suppressed by rsyslogd and can appear in the syslog periodically. How I did it This PR adds a counter into the alerting message and shows how many minutes a critical process was not running. How to verify it I verified and test this implementation on a physical DUT. --- files/scripts/supervisor-proc-exit-listener | 22 +++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/files/scripts/supervisor-proc-exit-listener b/files/scripts/supervisor-proc-exit-listener index e8565b4d52f2..7bf3059b5e9a 100755 --- a/files/scripts/supervisor-proc-exit-listener +++ b/files/scripts/supervisor-proc-exit-listener @@ -8,6 +8,7 @@ import signal import sys import syslog import time +from collections import defaultdict import swsssdk @@ -64,7 +65,7 @@ def get_critical_group_and_process_list(): return critical_group_list, critical_process_list -def generate_alerting_message(process_name): +def generate_alerting_message(process_name, dead_minutes): """ @summary: If a critical process was not running, this function will determine it resides in host or in a specific namespace. Then an alerting message will be written into syslog. @@ -77,7 +78,8 @@ def generate_alerting_message(process_name): else: namespace = namespace_prefix + namespace_id - syslog.syslog(syslog.LOG_ERR, "Process '{}' is not running in namespace '{}'.".format(process_name, namespace)) + syslog.syslog(syslog.LOG_ERR, "Process '{}' is not running in namespace '{}' ({} minutes)." + .format(process_name, namespace, dead_minutes)) def get_autorestart_state(container_name): @@ -118,7 +120,7 @@ def main(argv): critical_group_list, critical_process_list = get_critical_group_and_process_list() - process_under_alerting = {} + process_under_alerting = defaultdict(dict) # Transition from ACKNOWLEDGED to READY childutils.listener.ready() @@ -145,7 +147,8 @@ def main(argv): syslog.syslog(syslog.LOG_INFO, msg) os.kill(os.getppid(), signal.SIGTERM) else: - process_under_alerting[process_name] = time.time() + process_under_alerting[process_name]["last_alerted"] = time.time() + process_under_alerting[process_name]["dead_minutes"] = 0 # Handle the PROCESS_STATE_RUNNING event elif headers['eventname'] == 'PROCESS_STATE_RUNNING': @@ -162,11 +165,14 @@ def main(argv): childutils.listener.ready() # Check whether we need write alerting messages into syslog - for process in process_under_alerting.keys(): + for process_name in process_under_alerting.keys(): epoch_time = time.time() - if epoch_time - process_under_alerting[process] >= ALERTING_INTERVAL_SECS: - process_under_alerting[process] = epoch_time - generate_alerting_message(process) + elapsed_secs = epoch_time - process_under_alerting[process_name]["last_alerted"] + if elapsed_secs >= ALERTING_INTERVAL_SECS: + elapsed_mins = elapsed_secs // 60 + process_under_alerting[process_name]["last_alerted"] = epoch_time + process_under_alerting[process_name]["dead_minutes"] += elapsed_mins + generate_alerting_message(process_name, process_under_alerting[process_name]["dead_minutes"]) if __name__ == "__main__": From bd14dd377ca8e6de3a99c6e0fda3cd172ca604a9 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 25 Feb 2021 11:20:53 -0800 Subject: [PATCH 0235/1674] [Celestica] Ensure concrete platform API classes call base class initializer (#6852) In preparation for the merging of Azure/sonic-platform-common#173, which properly defines class and instance members in the Platform API base classes. It is proper object-oriented methodology to call the base class initializer, even if it is only the default initializer. This also future-proofs the potential addition of custom initializers in the base classes down the road. --- device/celestica/x86_64-cel_e1031-r0/sonic_platform/thermal.py | 2 ++ device/celestica/x86_64-cel_e1031-r0/sonic_platform/watchdog.py | 1 + .../celestica/x86_64-cel_seastone-r0/sonic_platform/thermal.py | 1 + .../celestica/x86_64-cel_seastone-r0/sonic_platform/watchdog.py | 2 ++ .../x86_64-cel_seastone_2-r0/sonic_platform_config/watchdog.py | 2 ++ .../celestica/x86_64-cel_silverstone-r0/sonic_platform/fan.py | 1 + 6 files changed, 9 insertions(+) diff --git a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/thermal.py b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/thermal.py index 157f49a7c3e2..6c73845287cd 100644 --- a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/thermal.py +++ b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/thermal.py @@ -25,6 +25,8 @@ class Thermal(ThermalBase): SS_CONFIG_PATH = "/usr/share/sonic/device/x86_64-cel_e1031-r0/sensors.conf" def __init__(self, thermal_index): + ThermalBase.__init__(self) + self.index = thermal_index # Add thermal name diff --git a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/watchdog.py b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/watchdog.py index 882285251784..6db0508cb845 100644 --- a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/watchdog.py +++ b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/watchdog.py @@ -53,6 +53,7 @@ class Watchdog(WatchdogBase): def __init__(self): + WatchdogBase.__init__(self) self.watchdog, self.wdt_main_dev_name = self._get_wdt() self.status_path = "/sys/class/watchdog/%s/status" % self.wdt_main_dev_name diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal.py index 2b38ef94d6c4..3848f9340541 100644 --- a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal.py +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/thermal.py @@ -67,6 +67,7 @@ class Thermal(ThermalBase): SS_CONFIG_PATH = "/usr/share/sonic/device/x86_64-cel_seastone-r0/sensors.conf" def __init__(self, thermal_index, airflow): + ThermalBase.__init__(self) self.index = thermal_index self._api_helper = APIHelper() self._airflow = airflow diff --git a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/watchdog.py b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/watchdog.py index 31bb911d2401..5ab79309f0fe 100644 --- a/device/celestica/x86_64-cel_seastone-r0/sonic_platform/watchdog.py +++ b/device/celestica/x86_64-cel_seastone-r0/sonic_platform/watchdog.py @@ -31,6 +31,8 @@ class Watchdog(WatchdogBase): def __init__(self): + WatchdogBase.__init__(self) + # Init helper self._api_helper = APIHelper() diff --git a/device/celestica/x86_64-cel_seastone_2-r0/sonic_platform_config/watchdog.py b/device/celestica/x86_64-cel_seastone_2-r0/sonic_platform_config/watchdog.py index cc87c3d6b32a..fac5c40e134f 100644 --- a/device/celestica/x86_64-cel_seastone_2-r0/sonic_platform_config/watchdog.py +++ b/device/celestica/x86_64-cel_seastone_2-r0/sonic_platform_config/watchdog.py @@ -29,6 +29,8 @@ class Watchdog(WatchdogBase): def __init__(self): + WatchdogBase.__init__(self) + self._api_common = Common() # Init cpld reg path diff --git a/device/celestica/x86_64-cel_silverstone-r0/sonic_platform/fan.py b/device/celestica/x86_64-cel_silverstone-r0/sonic_platform/fan.py index 1055aee68fc7..1a18eed9c8d5 100644 --- a/device/celestica/x86_64-cel_silverstone-r0/sonic_platform/fan.py +++ b/device/celestica/x86_64-cel_silverstone-r0/sonic_platform/fan.py @@ -54,6 +54,7 @@ class Fan(FanBase): """Platform-specific Fan class""" def __init__(self, fan_tray_index, fan_index=0, is_psu_fan=False, psu_index=0): + FanBase.__init__(self) self.fan_index = fan_index self.fan_tray_index = fan_tray_index self.is_psu_fan = is_psu_fan From 88f4c6523d99dfdc4609ac9f9a92237105058790 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 25 Feb 2021 11:20:34 -0800 Subject: [PATCH 0236/1674] [DellEMC] Ensure concrete platform API classes call base class initializer (#6853) In preparation for the merging of Azure/sonic-platform-common#173, which properly defines class and instance members in the Platform API base classes. It is proper object-oriented methodology to call the base class initializer, even if it is only the default initializer. This also future-proofs the potential addition of custom initializers in the base classes down the road. --- .../s5232f/sonic_platform/component.py | 1 + .../sonic-platform-modules-dell/s5232f/sonic_platform/fan.py | 1 + .../s5232f/sonic_platform/watchdog.py | 1 + .../s6000/sonic_platform/component.py | 1 + .../sonic-platform-modules-dell/s6000/sonic_platform/fan.py | 1 + .../sonic-platform-modules-dell/s6000/sonic_platform/thermal.py | 1 + .../s6100/sonic_platform/component.py | 1 + .../sonic-platform-modules-dell/s6100/sonic_platform/fan.py | 1 + .../sonic-platform-modules-dell/s6100/sonic_platform/thermal.py | 1 + .../sonic-platform-modules-dell/s6100/sonic_platform/watchdog.py | 1 + .../z9100/sonic_platform/component.py | 1 + .../sonic-platform-modules-dell/z9100/sonic_platform/fan.py | 1 + .../sonic-platform-modules-dell/z9100/sonic_platform/psu.py | 1 + .../sonic-platform-modules-dell/z9100/sonic_platform/thermal.py | 1 + .../z9264f/sonic_platform/component.py | 1 + .../sonic-platform-modules-dell/z9264f/sonic_platform/fan.py | 1 + .../z9264f/sonic_platform/watchdog.py | 1 + .../z9332f/sonic_platform/component.py | 1 + .../sonic-platform-modules-dell/z9332f/sonic_platform/fan.py | 1 + .../z9332f/sonic_platform/watchdog.py | 1 + 20 files changed, 20 insertions(+) diff --git a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/component.py index f7fcc94662c1..52f2bacd70aa 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/component.py @@ -82,6 +82,7 @@ class Component(ComponentBase): ] def __init__(self, component_index = 0): + ComponentBase.__init__(self) self.index = component_index self.name = self.CHASSIS_COMPONENTS[self.index][0] self.description = self.CHASSIS_COMPONENTS[self.index][1] diff --git a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/fan.py index 1b624cb76eda..c634dc7d0d17 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/fan.py @@ -41,6 +41,7 @@ class Fan(FanBase): def __init__(self, fantray_index=1, fan_index=1, psu_fan=False, dependency=None): + FanBase.__init__(self) self.is_psu_fan = psu_fan if not self.is_psu_fan: # API index is starting from 0, DellEMC platform index is diff --git a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/watchdog.py b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/watchdog.py index 14485decc896..961bd8b3dbb4 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/watchdog.py +++ b/platform/broadcom/sonic-platform-modules-dell/s5232f/sonic_platform/watchdog.py @@ -36,6 +36,7 @@ class Watchdog(WatchdogBase): CLOCK_MONOTONIC = 1 def __init__(self): + WatchdogBase.__init__(self) self._librt = ctypes.CDLL('librt.so.1', use_errno=True) self._clock_gettime = self._librt.clock_gettime self._clock_gettime.argtypes=[ctypes.c_int, ctypes.POINTER(_timespec)] diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/component.py index d9459be47c4f..92ae95fae4f6 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/component.py @@ -34,6 +34,7 @@ class Component(ComponentBase): ] def __init__(self, component_index): + ComponentBase.__init__(self) self.index = component_index self.name = self.CHASSIS_COMPONENTS[self.index][0] self.description = self.CHASSIS_COMPONENTS[self.index][1] diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/fan.py index d5a4f379e90b..940c70cebede 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/fan.py @@ -33,6 +33,7 @@ class Fan(FanBase): def __init__(self, fantray_index=1, fan_index=1, psu_index=1, psu_fan=False, dependency=None): + FanBase.__init__(self) self.is_psu_fan = psu_fan self.is_driver_initialized = True diff --git a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/thermal.py index ad089a8946a9..bfb1385a9f05 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/thermal.py @@ -35,6 +35,7 @@ class Thermal(ThermalBase): def __init__(self, thermal_index, psu_index=1, psu_thermal=False, dependency=None): + ThermalBase.__init__(self) self.is_psu_thermal = psu_thermal self.dependency = dependency self.is_driver_initialized = True diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/component.py index bea180d440b5..2e916488123d 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/component.py @@ -41,6 +41,7 @@ class Component(ComponentBase): def __init__(self, component_index=0, is_module=False, iom_index=0, i2c_line=0, dependency=None): + ComponentBase.__init__(self) self.is_module_component = is_module self.dependency = dependency diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/fan.py index 5b3c8977ac0a..e95fceaff91d 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/fan.py @@ -27,6 +27,7 @@ class Fan(FanBase): MAILBOX_DIR = HWMON_DIR + HWMON_NODE def __init__(self, fantray_index=1, psu_index=1, psu_fan=False, dependency=None): + FanBase.__init__(self) self.is_psu_fan = psu_fan if not self.is_psu_fan: self.fantrayindex = fantray_index diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/thermal.py index cac17f4b83aa..6b8ce0954c96 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/thermal.py @@ -26,6 +26,7 @@ class Thermal(ThermalBase): ) def __init__(self, thermal_index): + ThermalBase.__init__(self) self.is_cpu_thermal = False self.index = thermal_index + 1 diff --git a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/watchdog.py b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/watchdog.py index 0e5e102b7b52..177315ef1805 100644 --- a/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/watchdog.py +++ b/platform/broadcom/sonic-platform-modules-dell/s6100/sonic_platform/watchdog.py @@ -41,6 +41,7 @@ class Watchdog(WatchdogBase): CLOCK_MONOTONIC = 1 def __init__(self): + WatchdogBase.__init__(self) self._librt = ctypes.CDLL('librt.so.1', use_errno=True) self._clock_gettime = self._librt.clock_gettime self._clock_gettime.argtypes=[ctypes.c_int, ctypes.POINTER(_timespec)] diff --git a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/component.py index 52dee31a524e..d3822307e24b 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/component.py @@ -39,6 +39,7 @@ class Component(ComponentBase): ] def __init__(self, component_index=0): + ComponentBase.__init__(self) self.index = component_index self.name = self.CHASSIS_COMPONENTS[self.index][0] self.description = self.CHASSIS_COMPONENTS[self.index][1] diff --git a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/fan.py index 31bda2f4cefb..e85f614a82e4 100755 --- a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/fan.py @@ -27,6 +27,7 @@ class Fan(FanBase): MAILBOX_DIR = HWMON_DIR + HWMON_NODE def __init__(self, fantray_index=1, fan_index=1, psu_fan=False): + FanBase.__init__(self) self.is_psu_fan = psu_fan if not self.is_psu_fan: # API index is starting from 0, DellEMC platform index is starting diff --git a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/psu.py b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/psu.py index f76d0ac1bec6..d32cb8f7f3aa 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/psu.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/psu.py @@ -25,6 +25,7 @@ class Psu(PsuBase): MAILBOX_DIR = HWMON_DIR + HWMON_NODE def __init__(self, psu_index): + PsuBase.__init__(self) # PSU is 1-based in DellEMC platforms self.index = psu_index + 1 self.psu_presence_reg = "psu{}_presence".format(self.index) diff --git a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/thermal.py b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/thermal.py index 942934ed7638..72e6fff1e16b 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/thermal.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9100/sonic_platform/thermal.py @@ -26,6 +26,7 @@ class Thermal(ThermalBase): ) def __init__(self, thermal_index): + ThermalBase.__init__(self) self.is_cpu_thermal = False self.index = thermal_index + 1 diff --git a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/component.py index c4e2c06b135c..aa09d730b5ce 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/component.py @@ -36,6 +36,7 @@ class Component(ComponentBase): ] def __init__(self, component_index=0): + ComponentBase.__init__(self) self.index = component_index self.name = self.CHASSIS_COMPONENTS[self.index][0] self.description = self.CHASSIS_COMPONENTS[self.index][1] diff --git a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/fan.py index 39307d453486..b7d990877daa 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/fan.py @@ -43,6 +43,7 @@ class Fan(FanBase): def __init__(self, fantray_index=1, fan_index=1, psu_fan=False, dependency=None): + FanBase.__init__(self) self.is_psu_fan = psu_fan if not self.is_psu_fan: # API index is starting from 0, DellEMC platform index is diff --git a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/watchdog.py b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/watchdog.py index 0ecb42685c6d..3ba9f671a9fc 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/watchdog.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9264f/sonic_platform/watchdog.py @@ -36,6 +36,7 @@ class Watchdog(WatchdogBase): CLOCK_MONOTONIC = 1 def __init__(self): + WatchdogBase.__init__(self) self._librt = ctypes.CDLL('librt.so.1', use_errno=True) self._clock_gettime = self._librt.clock_gettime self._clock_gettime.argtypes=[ctypes.c_int, ctypes.POINTER(_timespec)] diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/component.py b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/component.py index 58c944cd6eb3..b564c1664533 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/component.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/component.py @@ -81,6 +81,7 @@ class Component(ComponentBase): ] def __init__(self, component_index = 0): + ComponentBase.__init__(self) self.index = component_index self.name = self.CHASSIS_COMPONENTS[self.index][0] self.description = self.CHASSIS_COMPONENTS[self.index][1] diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/fan.py b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/fan.py index ff7a08bdd1ad..d7bc0fdd3924 100755 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/fan.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/fan.py @@ -38,6 +38,7 @@ class Fan(FanBase): PSU_FRU_MAPPING = { 1: 3, 2: 4 } def __init__(self, fantray_index=1, fan_index=1, psu_fan=False, dependency=None): + FanBase.__init__(self) self.is_psu_fan = psu_fan if not self.is_psu_fan: # API index is starting from 0, DellEMC platform index is diff --git a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/watchdog.py b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/watchdog.py index 265fab66d922..76a7584e91aa 100644 --- a/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/watchdog.py +++ b/platform/broadcom/sonic-platform-modules-dell/z9332f/sonic_platform/watchdog.py @@ -36,6 +36,7 @@ class Watchdog(WatchdogBase): CLOCK_MONOTONIC = 1 def __init__(self): + WatchdogBase.__init__(self) self._librt = ctypes.CDLL('librt.so.1', use_errno=True) self._clock_gettime = self._librt.clock_gettime self._clock_gettime.argtypes=[ctypes.c_int, ctypes.POINTER(_timespec)] From b4555b9dbd767eaf1af06c385c64ce5f6f619ee9 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 25 Feb 2021 11:06:22 -0800 Subject: [PATCH 0237/1674] [Mellanox] Ensure concrete platform API classes call base class initializer (#6854) In preparation for the merging of Azure/sonic-platform-common#173, which properly defines class and instance members in the Platform API base classes. It is proper object-oriented methodology to call the base class initializer, even if it is only the default initializer. This also future-proofs the potential addition of custom initializers in the base classes down the road. --- platform/mellanox/mlnx-platform-api/sonic_platform/component.py | 1 + platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py | 1 + platform/mellanox/mlnx-platform-api/sonic_platform/watchdog.py | 1 + 3 files changed, 3 insertions(+) diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/component.py b/platform/mellanox/mlnx-platform-api/sonic_platform/component.py index e70007e96562..f2a66c6d42ee 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/component.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/component.py @@ -323,6 +323,7 @@ def is_non_onie_firmware_update_supported(self): class Component(ComponentBase): def __init__(self): + super(Component, self).__init__() self.name = None self.description = None self.image_ext_name = None diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py index c942b0d89d35..b4347d556854 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py @@ -373,6 +373,7 @@ def __init__(self, category, index, has_index, position, dependency = None): """ index should be a string for category ambient and int for other categories """ + super(Thermal, self).__init__() if category == THERMAL_DEV_CATEGORY_AMBIENT: self.name = thermal_ambient_name[index] self.index = index diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/watchdog.py b/platform/mellanox/mlnx-platform-api/sonic_platform/watchdog.py index e9694f1b2a59..909ec6a8884a 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/watchdog.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/watchdog.py @@ -63,6 +63,7 @@ def __init__(self, wd_device_path): Open a watchdog handle @param wd_device_path Path to watchdog device """ + super(WatchdogImplBase, self).__init__() self.watchdog_path = wd_device_path self.watchdog = os.open(self.watchdog_path, os.O_WRONLY) From 0d15e07d14d97ef95bf7a000c39f38afd4795e9d Mon Sep 17 00:00:00 2001 From: Volodymyr Boiko <66446128+vboykox@users.noreply.github.com> Date: Tue, 23 Feb 2021 23:16:42 +0200 Subject: [PATCH 0238/1674] [barefoot][device][platform] Moved pcie.yaml (#6862) To fix #6860 Signed-off-by: Volodymyr Boyko --- .../barefoot/x86_64-accton_as9516_32d-r0}/pcie.yaml | 0 .../barefoot/x86_64-accton_wedge100bf_32x-r0}/pcie.yaml | 0 .../barefoot/sonic-platform-modules-bfn-montara/debian/rules | 3 --- .../barefoot/sonic-platform-modules-bfn-newport/debian/rules | 3 --- 4 files changed, 6 deletions(-) rename {platform/barefoot/sonic-platform-modules-bfn-newport => device/barefoot/x86_64-accton_as9516_32d-r0}/pcie.yaml (100%) rename {platform/barefoot/sonic-platform-modules-bfn-montara => device/barefoot/x86_64-accton_wedge100bf_32x-r0}/pcie.yaml (100%) diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/pcie.yaml b/device/barefoot/x86_64-accton_as9516_32d-r0/pcie.yaml similarity index 100% rename from platform/barefoot/sonic-platform-modules-bfn-newport/pcie.yaml rename to device/barefoot/x86_64-accton_as9516_32d-r0/pcie.yaml diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/pcie.yaml b/device/barefoot/x86_64-accton_wedge100bf_32x-r0/pcie.yaml similarity index 100% rename from platform/barefoot/sonic-platform-modules-bfn-montara/pcie.yaml rename to device/barefoot/x86_64-accton_wedge100bf_32x-r0/pcie.yaml diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/debian/rules b/platform/barefoot/sonic-platform-modules-bfn-montara/debian/rules index b04234a0df1b..4070b66dfdac 100755 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/debian/rules +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/debian/rules @@ -6,7 +6,6 @@ SCRIPT_SRC := $(shell pwd)/scripts CONFIGS_SRC := $(shell pwd)/configs BUILD_DIR := $(shell pwd)/build WHEEL_BUILD_DIR := $(BUILD_DIR)/wheel -PLUGINS_DIR := $(shell pwd)/plugins %: dh $@ @@ -24,8 +23,6 @@ override_dh_auto_install: cp -r $(CONFIGS_SRC)/network/interfaces.d/* debian/$(PACKAGE_NAME)/etc/network/interfaces.d/ dh_installdirs -p$(PACKAGE_NAME) usr/share/sonic/device/$(PLATFORM_NAME)/ cp -r $(WHEEL_BUILD_DIR)/* debian/$(PACKAGE_NAME)/usr/share/sonic/device/$(PLATFORM_NAME)/ - dh_installdirs -p$(PACKAGE_NAME) usr/share/sonic/device/$(PLATFORM_NAME)/plugins - cp -r $(PLUGINS_DIR)/* debian/$(PACKAGE_NAME)/usr/share/sonic/device/$(PLATFORM_NAME)/plugins/ override_dh_usrlocal: diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/debian/rules b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/rules index 962a1de8204e..da70905cb239 100755 --- a/platform/barefoot/sonic-platform-modules-bfn-newport/debian/rules +++ b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/rules @@ -10,7 +10,6 @@ SCRIPT_SRC := $(shell pwd)/scripts CONFIGS_SRC := $(shell pwd)/configs BUILD_DIR := $(shell pwd)/build WHEEL_BUILD_DIR := $(BUILD_DIR)/wheel -PLUGINS_DIR := $(shell pwd)/plugins MODULE_NAMES := as9516 as9516bf %: @@ -33,8 +32,6 @@ override_dh_auto_install: cp -r $(CONFIGS_SRC)/network/interfaces.d/* debian/$(PACKAGE_PRE_NAME)-$${mod}/etc/network/interfaces.d/; \ dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} usr/share/sonic/device/x86_64-accton_$${mod}_32d-r0/; \ cp -r $(WHEEL_BUILD_DIR)/* debian/$(PACKAGE_PRE_NAME)-$${mod}/usr/share/sonic/device/x86_64-accton_$${mod}_32d-r0/; \ - dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} usr/share/sonic/device/x86_64-accton_$${mod}_32d-r0/plugins; \ - cp -r $(PLUGINS_DIR)/* debian/$(PACKAGE_PRE_NAME)-$${mod}/usr/share/sonic/device/x86_64-accton_$${mod}_32d-r0/plugins/; \ done) override_dh_usrlocal: From 760b3361ae2e943fc7b7ac4b9ffd1c8199076a1d Mon Sep 17 00:00:00 2001 From: Volodymyr Boiko <66446128+vboykox@users.noreply.github.com> Date: Wed, 24 Feb 2021 19:42:18 +0200 Subject: [PATCH 0239/1674] [barefoot][platform] Refactor legacy scripts (#6871) Removed or adapted obsolete code Signed-off-by: Volodymyr Boyko --- .../scripts/bf-fancontrol | 3 + .../scripts/bf-sfputil | 10 ---- .../scripts/eeprom | 10 ---- .../scripts/fancontrol | 11 ---- .../scripts/ps_info | 10 ---- .../scripts/sensors | 5 +- .../scripts/test | 1 - .../setup.py | 3 +- .../sonic_platform/bfn_extensions/__init__.py | 4 ++ .../bfn_extensions/platform_fancontrol.py | 59 +++++++++++++++++++ .../bfn_extensions/platform_sensors.py | 26 ++++++++ .../scripts | 1 + .../scripts/bf-sfputil | 10 ---- .../scripts/eeprom | 10 ---- .../scripts/fancontrol | 11 ---- .../scripts/ps_info | 10 ---- .../scripts/sensors | 12 ---- .../scripts/test | 1 - .../sonic-platform-modules-bfn/scripts | 1 + .../scripts/bf-sfputil | 10 ---- .../sonic-platform-modules-bfn/scripts/eeprom | 10 ---- .../scripts/fancontrol | 11 ---- .../scripts/ps_info | 10 ---- .../scripts/sensors | 12 ---- .../sonic-platform-modules-bfn/scripts/test | 1 - 25 files changed, 98 insertions(+), 154 deletions(-) create mode 100755 platform/barefoot/sonic-platform-modules-bfn-montara/scripts/bf-fancontrol delete mode 100755 platform/barefoot/sonic-platform-modules-bfn-montara/scripts/bf-sfputil delete mode 100755 platform/barefoot/sonic-platform-modules-bfn-montara/scripts/eeprom delete mode 100755 platform/barefoot/sonic-platform-modules-bfn-montara/scripts/fancontrol delete mode 100755 platform/barefoot/sonic-platform-modules-bfn-montara/scripts/ps_info delete mode 100755 platform/barefoot/sonic-platform-modules-bfn-montara/scripts/test create mode 100644 platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/bfn_extensions/__init__.py create mode 100644 platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/bfn_extensions/platform_fancontrol.py create mode 100644 platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/bfn_extensions/platform_sensors.py create mode 120000 platform/barefoot/sonic-platform-modules-bfn-newport/scripts delete mode 100755 platform/barefoot/sonic-platform-modules-bfn-newport/scripts/bf-sfputil delete mode 100755 platform/barefoot/sonic-platform-modules-bfn-newport/scripts/eeprom delete mode 100755 platform/barefoot/sonic-platform-modules-bfn-newport/scripts/fancontrol delete mode 100755 platform/barefoot/sonic-platform-modules-bfn-newport/scripts/ps_info delete mode 100755 platform/barefoot/sonic-platform-modules-bfn-newport/scripts/sensors delete mode 100755 platform/barefoot/sonic-platform-modules-bfn-newport/scripts/test create mode 120000 platform/barefoot/sonic-platform-modules-bfn/scripts delete mode 100755 platform/barefoot/sonic-platform-modules-bfn/scripts/bf-sfputil delete mode 100755 platform/barefoot/sonic-platform-modules-bfn/scripts/eeprom delete mode 100755 platform/barefoot/sonic-platform-modules-bfn/scripts/fancontrol delete mode 100755 platform/barefoot/sonic-platform-modules-bfn/scripts/ps_info delete mode 100755 platform/barefoot/sonic-platform-modules-bfn/scripts/sensors delete mode 100755 platform/barefoot/sonic-platform-modules-bfn/scripts/test diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/bf-fancontrol b/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/bf-fancontrol new file mode 100755 index 000000000000..7407c2d7241d --- /dev/null +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/bf-fancontrol @@ -0,0 +1,3 @@ +#!/bin/bash + +python3 -m sonic_platform.bfn_extensions.platform_fancontrol "$@" diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/bf-sfputil b/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/bf-sfputil deleted file mode 100755 index 3df67614e499..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/bf-sfputil +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -DOCKER_EXEC_FLAGS="i" - -# Determine whether stdout is on a terminal -if [ -t 1 ] ; then - DOCKER_EXEC_FLAGS+="t" -fi - -docker exec -$DOCKER_EXEC_FLAGS syncd sfputil "$@" diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/eeprom b/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/eeprom deleted file mode 100755 index 07d98556cbbf..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/eeprom +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -DOCKER_EXEC_FLAGS="i" - -# Determine whether stdout is on a terminal -if [ -t 1 ] ; then - DOCKER_EXEC_FLAGS+="t" -fi - -docker exec -$DOCKER_EXEC_FLAGS syncd eeprom "$@" diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/fancontrol b/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/fancontrol deleted file mode 100755 index 515fcbdd69da..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/fancontrol +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -DOCKER_EXEC_FLAGS="i" - -# Determine whether stdout is on a terminal -if [ -t 1 ] ; then - DOCKER_EXEC_FLAGS+="t" -fi - -docker exec -$DOCKER_EXEC_FLAGS syncd fancontrol "$@" - diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/ps_info b/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/ps_info deleted file mode 100755 index 38c9d3330414..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/ps_info +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -DOCKER_EXEC_FLAGS="i" - -# Determine whether stdout is on a terminal -if [ -t 1 ] ; then - DOCKER_EXEC_FLAGS+="t" -fi - -docker exec -$DOCKER_EXEC_FLAGS syncd ps_info "$@" diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/sensors b/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/sensors index 07af6955321e..5f06a9c99b05 100755 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/sensors +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/sensors @@ -7,6 +7,5 @@ if [ -t 1 ] ; then DOCKER_EXEC_FLAGS+="t" fi -docker exec -$DOCKER_EXEC_FLAGS syncd sensors "$@" - - +python3 -m sonic_platform.bfn_extensions.platform_sensors "$@" +docker exec -$DOCKER_EXEC_FLAGS pmon sensors "$@" diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/test b/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/test deleted file mode 100755 index 38327722c91f..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/scripts/test +++ /dev/null @@ -1 +0,0 @@ -echo "test" diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/setup.py b/platform/barefoot/sonic-platform-modules-bfn-montara/setup.py index fc14c94ac4a0..14e1bb6b6c02 100755 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/setup.py +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/setup.py @@ -12,7 +12,8 @@ maintainer_email='', packages=[ 'sonic_platform', - 'sonic_platform/pltfm_mgr_rpc' + 'sonic_platform/pltfm_mgr_rpc', + 'sonic_platform/bfn_extensions', ], package_data = {'sonic_platform':['logging.conf']}, classifiers=[ diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/bfn_extensions/__init__.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/bfn_extensions/__init__.py new file mode 100644 index 000000000000..67517a64e886 --- /dev/null +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/bfn_extensions/__init__.py @@ -0,0 +1,4 @@ +__all__ = [ + 'platform_sensors', + 'platform_fancontrol', +] diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/bfn_extensions/platform_fancontrol.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/bfn_extensions/platform_fancontrol.py new file mode 100644 index 000000000000..43a700c21dcb --- /dev/null +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/bfn_extensions/platform_fancontrol.py @@ -0,0 +1,59 @@ +import sys + +from sonic_platform.platform_thrift_client import thrift_try + +_MAX_FAN = 10 + +def fan_speed_set(fan, percent): + def set_fan_speed(client): + return client.pltfm_mgr.pltfm_mgr_fan_speed_set(fan, percent) + return thrift_try(set_fan_speed) + +def fan_speed_info_get(): + 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 + +if __name__ == '__main__': + def print_usage(): + print("Usage: platform_fancontrol.py ", file=sys.stderr) + print(" function: fan_speed_set ", file=sys.stderr) + print(" fan_speed_info_get ", file=sys.stderr) + + argc = len(sys.argv) + if argc == 1: + print_usage() + exit(0) + + if sys.argv[1] == "fan_speed_set": + if argc != 4: + print_usage() + exit(0) + + fan = int(sys.argv[2]) + percent = int(sys.argv[3]) + + if (fan > _MAX_FAN) | (fan < 0): + print("Invalid value for fan #.\n", file=sys.stderr) + print_usage() + exit(0) + + if (percent > 100) | (percent < 0): + print("Invalid value for precent\n", file=sys.stderr) + print_usage() + exit(0) + + fan_speed_set(fan, percent) + exit(0) + + if sys.argv[1] == "fan_speed_info_get": + for fan_info in fan_speed_info_get(): + print("fan number: %d front rpm: %d rear rpm: %d percent: %d%% " % + (fan_info.fan_num, fan_info.front_rpm, fan_info.rear_rpm, fan_info.percent)) + + exit(0) + + print_usage() diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/bfn_extensions/platform_sensors.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/bfn_extensions/platform_sensors.py new file mode 100644 index 000000000000..330884ca733b --- /dev/null +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/bfn_extensions/platform_sensors.py @@ -0,0 +1,26 @@ +import sys +import codecs +import urllib + +from sonic_platform.platform_thrift_client import thrift_try + +def platform_sensors_get(args): + options = "" + if len(args)!=0: + options = urllib.quote(" ".join(args)) + def get_data(client): + return client.pltfm_mgr.pltfm_mgr_sensor_info_get(options) + raw_out = thrift_try(get_data) + raw_list = raw_out.split('\"') + if len(raw_list) >= 2: + sensors_out = raw_list[1] + sensors_out = codecs.decode(sensors_out, "unicode_escape") + return sensors_out + return None + +if __name__ == '__main__': + data = platform_sensors_get(sys.argv[1:]) + if data: + print(data) + else: + print("No sensors info available", file=sys.stderr) diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/scripts b/platform/barefoot/sonic-platform-modules-bfn-newport/scripts new file mode 120000 index 000000000000..14008f061862 --- /dev/null +++ b/platform/barefoot/sonic-platform-modules-bfn-newport/scripts @@ -0,0 +1 @@ +../sonic-platform-modules-bfn-montara/scripts \ No newline at end of file diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/bf-sfputil b/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/bf-sfputil deleted file mode 100755 index 3df67614e499..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/bf-sfputil +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -DOCKER_EXEC_FLAGS="i" - -# Determine whether stdout is on a terminal -if [ -t 1 ] ; then - DOCKER_EXEC_FLAGS+="t" -fi - -docker exec -$DOCKER_EXEC_FLAGS syncd sfputil "$@" diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/eeprom b/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/eeprom deleted file mode 100755 index 07d98556cbbf..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/eeprom +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -DOCKER_EXEC_FLAGS="i" - -# Determine whether stdout is on a terminal -if [ -t 1 ] ; then - DOCKER_EXEC_FLAGS+="t" -fi - -docker exec -$DOCKER_EXEC_FLAGS syncd eeprom "$@" diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/fancontrol b/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/fancontrol deleted file mode 100755 index 515fcbdd69da..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/fancontrol +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -DOCKER_EXEC_FLAGS="i" - -# Determine whether stdout is on a terminal -if [ -t 1 ] ; then - DOCKER_EXEC_FLAGS+="t" -fi - -docker exec -$DOCKER_EXEC_FLAGS syncd fancontrol "$@" - diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/ps_info b/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/ps_info deleted file mode 100755 index 38c9d3330414..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/ps_info +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -DOCKER_EXEC_FLAGS="i" - -# Determine whether stdout is on a terminal -if [ -t 1 ] ; then - DOCKER_EXEC_FLAGS+="t" -fi - -docker exec -$DOCKER_EXEC_FLAGS syncd ps_info "$@" diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/sensors b/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/sensors deleted file mode 100755 index 07af6955321e..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/sensors +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -DOCKER_EXEC_FLAGS="i" - -# Determine whether stdout is on a terminal -if [ -t 1 ] ; then - DOCKER_EXEC_FLAGS+="t" -fi - -docker exec -$DOCKER_EXEC_FLAGS syncd sensors "$@" - - diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/test b/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/test deleted file mode 100755 index 38327722c91f..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn-newport/scripts/test +++ /dev/null @@ -1 +0,0 @@ -echo "test" diff --git a/platform/barefoot/sonic-platform-modules-bfn/scripts b/platform/barefoot/sonic-platform-modules-bfn/scripts new file mode 120000 index 000000000000..14008f061862 --- /dev/null +++ b/platform/barefoot/sonic-platform-modules-bfn/scripts @@ -0,0 +1 @@ +../sonic-platform-modules-bfn-montara/scripts \ No newline at end of file diff --git a/platform/barefoot/sonic-platform-modules-bfn/scripts/bf-sfputil b/platform/barefoot/sonic-platform-modules-bfn/scripts/bf-sfputil deleted file mode 100755 index 3df67614e499..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn/scripts/bf-sfputil +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -DOCKER_EXEC_FLAGS="i" - -# Determine whether stdout is on a terminal -if [ -t 1 ] ; then - DOCKER_EXEC_FLAGS+="t" -fi - -docker exec -$DOCKER_EXEC_FLAGS syncd sfputil "$@" diff --git a/platform/barefoot/sonic-platform-modules-bfn/scripts/eeprom b/platform/barefoot/sonic-platform-modules-bfn/scripts/eeprom deleted file mode 100755 index 07d98556cbbf..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn/scripts/eeprom +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -DOCKER_EXEC_FLAGS="i" - -# Determine whether stdout is on a terminal -if [ -t 1 ] ; then - DOCKER_EXEC_FLAGS+="t" -fi - -docker exec -$DOCKER_EXEC_FLAGS syncd eeprom "$@" diff --git a/platform/barefoot/sonic-platform-modules-bfn/scripts/fancontrol b/platform/barefoot/sonic-platform-modules-bfn/scripts/fancontrol deleted file mode 100755 index 515fcbdd69da..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn/scripts/fancontrol +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -DOCKER_EXEC_FLAGS="i" - -# Determine whether stdout is on a terminal -if [ -t 1 ] ; then - DOCKER_EXEC_FLAGS+="t" -fi - -docker exec -$DOCKER_EXEC_FLAGS syncd fancontrol "$@" - diff --git a/platform/barefoot/sonic-platform-modules-bfn/scripts/ps_info b/platform/barefoot/sonic-platform-modules-bfn/scripts/ps_info deleted file mode 100755 index 38c9d3330414..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn/scripts/ps_info +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -DOCKER_EXEC_FLAGS="i" - -# Determine whether stdout is on a terminal -if [ -t 1 ] ; then - DOCKER_EXEC_FLAGS+="t" -fi - -docker exec -$DOCKER_EXEC_FLAGS syncd ps_info "$@" diff --git a/platform/barefoot/sonic-platform-modules-bfn/scripts/sensors b/platform/barefoot/sonic-platform-modules-bfn/scripts/sensors deleted file mode 100755 index 07af6955321e..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn/scripts/sensors +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -DOCKER_EXEC_FLAGS="i" - -# Determine whether stdout is on a terminal -if [ -t 1 ] ; then - DOCKER_EXEC_FLAGS+="t" -fi - -docker exec -$DOCKER_EXEC_FLAGS syncd sensors "$@" - - diff --git a/platform/barefoot/sonic-platform-modules-bfn/scripts/test b/platform/barefoot/sonic-platform-modules-bfn/scripts/test deleted file mode 100755 index 38327722c91f..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn/scripts/test +++ /dev/null @@ -1 +0,0 @@ -echo "test" From e4b62880f606e2a3b4d636d8ac8ee6ad3bcac758 Mon Sep 17 00:00:00 2001 From: Dror Prital <76714716+dprital@users.noreply.github.com> Date: Wed, 24 Feb 2021 20:34:12 +0200 Subject: [PATCH 0240/1674] Add new SKU of Mellanox-SN2700-D40C8S8 (#6876) #### Why I did it Add new SKU for SN2700 Mellanox system that supports the following port configuration: 8 X 100G 40 X 50G 8 X 10G #### How I did it Add new Folder - "Mellanox-SN2700-D40C8S8" under /sonic-buildimage/device/mellanox/x86_64-mlnx_msn2700-r0/ that contains the relevant files supporting this SKU the buffers are based on SKU: D48C8 . Later on it will be configured specific for this SKU #### How to verify it Bring up the image, run "show interface status" and make sure that all ports are up and reflect the following requirement: Port 1/3 will be used as 4x10G Port 2/4 - Not exist (blocked since 1 and 3 split to 4) Port 7/8/9/10/23/24/25/26 will used as 100G All other ports will be used as 2x50G #### Which release branch to backport (provide reason below if selected) - [ ] 201811 - [ ] 201911 - [ ] 202006 - [X] 202012 #### Description for the changelog Support new SKU under the name of SN2700-D40C8S8 --- .../Mellanox-SN2700-D40C8S8/buffers.json.j2 | 1 + .../buffers_defaults_t0.j2 | 102 +++++++ .../buffers_defaults_t1.j2 | 102 +++++++ .../pg_profile_lookup.ini | 17 ++ .../Mellanox-SN2700-D40C8S8/port_config.ini | 57 ++++ .../Mellanox-SN2700-D40C8S8/qos.json.j2 | 1 + .../Mellanox-SN2700-D40C8S8/sai.profile | 1 + .../sai_2700_8x100g_40x50g_8x10g.xml | 269 ++++++++++++++++++ 8 files changed, 550 insertions(+) create mode 120000 device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers.json.j2 create mode 100644 device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t0.j2 create mode 100644 device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t1.j2 create mode 100644 device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/pg_profile_lookup.ini create mode 100644 device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/port_config.ini create mode 100644 device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/qos.json.j2 create mode 100644 device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/sai.profile create mode 100644 device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/sai_2700_8x100g_40x50g_8x10g.xml diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers.json.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers.json.j2 new file mode 120000 index 000000000000..30c4e1d5bfdd --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers.json.j2 @@ -0,0 +1 @@ +../ACS-MSN2700/buffers.json.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t0.j2 new file mode 100644 index 000000000000..c2bdb607d5a7 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t0.j2 @@ -0,0 +1,102 @@ +{% set default_cable = '5m' %} +{% set ingress_lossless_pool_size = '7719936' %} +{% set ingress_lossless_pool_xoff = '1032192' %} +{% set egress_lossless_pool_size = '13945824' %} +{% set egress_lossy_pool_size = '7719936' %} + +{%- 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 %} + +{%- macro generate_buffer_pool_and_profiles() %} + "BUFFER_POOL": { + "ingress_lossless_pool": { + "size": "{{ ingress_lossless_pool_size }}", + "xoff": "{{ ingress_lossless_pool_xoff }}", + "type": "ingress", + "mode": "dynamic" + }, + "egress_lossless_pool": { + "size": "{{ egress_lossless_pool_size }}", + "type": "egress", + "mode": "dynamic" + }, + "egress_lossy_pool": { + "size": "{{ egress_lossy_pool_size }}", + "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" + } + }, +{%- 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 %} + } +{%- 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 %} + } +{%- endmacro %} + + diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t1.j2 new file mode 100644 index 000000000000..6f444b61df43 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t1.j2 @@ -0,0 +1,102 @@ +{% set default_cable = '5m' %} +{% set ingress_lossless_pool_size = '9686016' %} +{% set ingress_lossless_pool_xoff = '1179648' %} +{% set egress_lossless_pool_size = '13945824' %} +{% set egress_lossy_pool_size = '9686016' %} + +{%- 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 %} + +{%- macro generate_buffer_pool_and_profiles() %} + "BUFFER_POOL": { + "ingress_lossless_pool": { + "size": "{{ ingress_lossless_pool_size }}", + "xoff": "{{ ingress_lossless_pool_xoff }}", + "type": "ingress", + "mode": "dynamic" + }, + "egress_lossless_pool": { + "size": "{{ egress_lossless_pool_size }}", + "type": "egress", + "mode": "dynamic" + }, + "egress_lossy_pool": { + "size": "{{ egress_lossy_pool_size }}", + "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" + } + }, +{%- 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 %} + } +{%- 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 %} + } +{%- endmacro %} + + diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/pg_profile_lookup.ini b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/pg_profile_lookup.ini new file mode 100644 index 000000000000..cdd674e4e715 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/pg_profile_lookup.ini @@ -0,0 +1,17 @@ +# PG lossless profiles. +# speed cable size xon xoff threshold + 10000 5m 19456 19456 22528 0 + 25000 5m 19456 19456 22528 0 + 40000 5m 19456 19456 22528 0 + 50000 5m 19456 19456 22528 0 + 100000 5m 19456 19456 23552 0 + 10000 40m 19456 19456 22528 0 + 25000 40m 19456 19456 24576 0 + 40000 40m 19456 19456 25600 0 + 50000 40m 19456 19456 25600 0 + 100000 40m 19456 19456 29696 0 + 10000 300m 19456 19456 27648 0 + 25000 300m 19456 19456 36864 0 + 40000 300m 19456 19456 45056 0 + 50000 300m 19456 19456 50176 0 + 100000 300m 19456 19456 78848 0 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/port_config.ini b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/port_config.ini new file mode 100644 index 000000000000..b4072ceb32a1 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/port_config.ini @@ -0,0 +1,57 @@ +# name lanes alias index speed +Ethernet0 0 etp1a 1 10000 +Ethernet1 1 etp1b 1 10000 +Ethernet2 2 etp1c 1 10000 +Ethernet3 3 etp1d 1 10000 +Ethernet8 8 etp3a 3 10000 +Ethernet9 9 etp3b 3 10000 +Ethernet10 10 etp3c 3 10000 +Ethernet11 11 etp3d 3 10000 +Ethernet16 16,17 etp5a 5 50000 +Ethernet18 18,19 etp5b 5 50000 +Ethernet20 20,21 etp6a 6 50000 +Ethernet22 22,23 etp6b 6 50000 +Ethernet24 24,25,26,27 etp7 7 100000 +Ethernet28 28,29,30,31 etp8 8 100000 +Ethernet32 32,33,34,35 etp9 9 100000 +Ethernet36 36,37,38,39 etp10 10 100000 +Ethernet40 40,41 etp11a 11 50000 +Ethernet42 42,43 etp11b 11 50000 +Ethernet44 44,45 etp12a 12 50000 +Ethernet46 46,47 etp12b 12 50000 +Ethernet48 48,49 etp13a 13 50000 +Ethernet50 50,51 etp13b 13 50000 +Ethernet52 52,53 etp14a 14 50000 +Ethernet54 54,55 etp14b 14 50000 +Ethernet56 56,57 etp15a 15 50000 +Ethernet58 58,59 etp15b 15 50000 +Ethernet60 60,61 etp16a 16 50000 +Ethernet62 62,63 etp16b 16 50000 +Ethernet64 64,65 etp17a 17 50000 +Ethernet66 66,67 etp17b 17 50000 +Ethernet68 68,69 etp18a 18 50000 +Ethernet70 70,71 etp18b 18 50000 +Ethernet72 72,73 etp19a 19 50000 +Ethernet74 74,75 etp19b 19 50000 +Ethernet76 76,77 etp20a 20 50000 +Ethernet78 78,79 etp20b 20 50000 +Ethernet80 80,81 etp21a 21 50000 +Ethernet82 82,83 etp21b 21 50000 +Ethernet84 84,85 etp22a 22 50000 +Ethernet86 86,87 etp22b 22 50000 +Ethernet88 88,89,90,91 etp23 23 100000 +Ethernet92 92,93,94,95 etp24 24 100000 +Ethernet96 96,97,98,99 etp25 25 100000 +Ethernet100 100,101,102,103 etp26 26 100000 +Ethernet104 104,105 etp27a 27 50000 +Ethernet106 106,107 etp27b 27 50000 +Ethernet108 108,109 etp28a 28 50000 +Ethernet110 110,111 etp28b 28 50000 +Ethernet112 112,113 etp29a 29 50000 +Ethernet114 114,115 etp29b 29 50000 +Ethernet116 116,117 etp30a 30 50000 +Ethernet118 118,119 etp30b 30 50000 +Ethernet120 120,121 etp31a 31 50000 +Ethernet122 122,123 etp31b 31 50000 +Ethernet124 124,125 etp32a 32 50000 +Ethernet126 126,127 etp32b 32 50000 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/qos.json.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/qos.json.j2 new file mode 100644 index 000000000000..3e548325ea30 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/qos.json.j2 @@ -0,0 +1 @@ +{%- include 'qos_config.j2' %} diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/sai.profile b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/sai.profile new file mode 100644 index 000000000000..a98e620cfa10 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/sai.profile @@ -0,0 +1 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_2700_8x100g_40x50g_8x10g.xml diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/sai_2700_8x100g_40x50g_8x10g.xml b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/sai_2700_8x100g_40x50g_8x10g.xml new file mode 100644 index 000000000000..0376eb548d26 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/sai_2700_8x100g_40x50g_8x10g.xml @@ -0,0 +1,269 @@ + + + + + + 00:02:03:04:05:00 + + + 1 + + + 32 + + + + + 1 + 2 + 4 + 16 + + + 3 + + + 3221225472 + + + 3 + 2 + 4 + 17 + 1 + 3221225472 + + + 5 + 2 + 4 + 18 + 3 + 3221225472 + + + 7 + 2 + 4 + 19 + 1 + 3221225472 + + + 9 + 2 + 4 + 20 + 3 + 3221225472 + + + 11 + 2 + 4 + 21 + 1 + 3221225472 + + + 13 + 4 + 22 + 3 + 11534336 + + + 15 + 4 + 23 + 1 + 11534336 + + + 17 + 4 + 24 + 3 + 11534336 + + + 19 + 4 + 25 + 1 + 11534336 + + + 21 + 2 + 4 + 26 + 3 + 3221225472 + + + 23 + 2 + 4 + 27 + 1 + 3221225472 + + + 25 + 4 + 28 + 3 + 3221225472 + 2 + + + 27 + 2 + 4 + 29 + 1 + 3221225472 + + + 29 + 2 + 4 + 30 + 3 + 3221225472 + + + 31 + 2 + 4 + 31 + 1 + 3221225472 + + + 33 + 2 + 4 + 14 + 3 + 3221225472 + + + 35 + 2 + 4 + 15 + 1 + 3221225472 + + + 37 + 2 + 4 + 12 + 3 + 3221225472 + + + 39 + 2 + 4 + 13 + 1 + 3221225472 + + + 41 + 2 + 4 + 10 + 3 + 3221225472 + + + 43 + 2 + 4 + 11 + 1 + 3221225472 + + + 45 + 4 + 8 + 3 + 11534336 + + + 47 + 4 + 9 + 1 + 11534336 + + + 49 + 2 + 4 + 6 + 3 + 3221225472 + + + 51 + 4 + 7 + 1 + 11534336 + + + 53 + 2 + 4 + 4 + 3 + 3221225472 + + + 55 + 2 + 4 + 5 + 1 + 3221225472 + + + 57 + 4 + 4 + 2 + 3 + 4096 + + + 59 + 4 + 3 + 1 + 11534336 + + + 61 + 4 + 4 + 0 + 3 + 4096 + + + 63 + 4 + 1 + 1 + 11534336 + + + + From fac295a02364aa24734be60425603df1aac8b74b Mon Sep 17 00:00:00 2001 From: DavidZagury <32644413+DavidZagury@users.noreply.github.com> Date: Thu, 25 Feb 2021 09:30:43 +0200 Subject: [PATCH 0241/1674] [Mellanox] Add support for SN4600 system (#6879) - Why I did it Add support for new 64x200G SN4600 systems - How I did it Add all relevant files (w/o platform.json and hwsku.json as they will come later) with default SKU. - How to verify it Install image on switch, verify all ports are up and configured properly, run full platform SONiC tests. --- .../x86_64-mlnx_msn2700-r0/plugins/sfputil.py | 6 +- .../ACS-MSN4600/buffers.json.j2 | 1 + .../ACS-MSN4600/buffers_defaults_t0.j2 | 1 + .../ACS-MSN4600/buffers_defaults_t1.j2 | 1 + .../ACS-MSN4600/buffers_dynamic.json.j2 | 1 + .../ACS-MSN4600/pg_profile_lookup.ini | 1 + .../ACS-MSN4600/port_config.ini | 65 +++ .../ACS-MSN4600/qos.json.j2 | 1 + .../ACS-MSN4600/sai.profile | 1 + .../ACS-MSN4600/sai_4600.xml | 471 ++++++++++++++++++ .../x86_64-mlnx_msn4600-r0/default_sku | 1 + .../mellanox/x86_64-mlnx_msn4600-r0/pcie.yaml | 419 ++++++++++++++++ .../platform_components.json | 14 + .../x86_64-mlnx_msn4600-r0/platform_reboot | 1 + .../x86_64-mlnx_msn4600-r0/platform_wait | 1 + .../x86_64-mlnx_msn4600-r0/plugins/eeprom.py | 1 + .../x86_64-mlnx_msn4600-r0/plugins/psuutil.py | 1 + .../plugins/sfplpmget.py | 1 + .../plugins/sfplpmset.py | 1 + .../plugins/sfpreset.py | 1 + .../x86_64-mlnx_msn4600-r0/plugins/sfputil.py | 1 + .../pmon_daemon_control.json | 1 + .../x86_64-mlnx_msn4600-r0/sensors.conf | 189 +++++++ .../system_health_monitoring_config.json | 1 + .../thermal_policy.json | 1 + platform/mellanox/asic_table.j2 | 1 + .../sonic_platform/chassis.py | 6 +- .../sonic_platform/device_data.py | 23 +- .../mlnx-platform-api/sonic_platform/psu.py | 4 +- .../sonic_platform/thermal.py | 46 +- 30 files changed, 1245 insertions(+), 18 deletions(-) create mode 120000 device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/buffers.json.j2 create mode 120000 device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/buffers_defaults_t0.j2 create mode 120000 device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/buffers_defaults_t1.j2 create mode 120000 device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/buffers_dynamic.json.j2 create mode 120000 device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/pg_profile_lookup.ini create mode 100644 device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/port_config.ini create mode 120000 device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/qos.json.j2 create mode 100644 device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/sai.profile create mode 100644 device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/sai_4600.xml create mode 100644 device/mellanox/x86_64-mlnx_msn4600-r0/default_sku create mode 100644 device/mellanox/x86_64-mlnx_msn4600-r0/pcie.yaml create mode 100644 device/mellanox/x86_64-mlnx_msn4600-r0/platform_components.json create mode 120000 device/mellanox/x86_64-mlnx_msn4600-r0/platform_reboot create mode 120000 device/mellanox/x86_64-mlnx_msn4600-r0/platform_wait create mode 120000 device/mellanox/x86_64-mlnx_msn4600-r0/plugins/eeprom.py create mode 120000 device/mellanox/x86_64-mlnx_msn4600-r0/plugins/psuutil.py create mode 120000 device/mellanox/x86_64-mlnx_msn4600-r0/plugins/sfplpmget.py create mode 120000 device/mellanox/x86_64-mlnx_msn4600-r0/plugins/sfplpmset.py create mode 120000 device/mellanox/x86_64-mlnx_msn4600-r0/plugins/sfpreset.py create mode 120000 device/mellanox/x86_64-mlnx_msn4600-r0/plugins/sfputil.py create mode 120000 device/mellanox/x86_64-mlnx_msn4600-r0/pmon_daemon_control.json create mode 100644 device/mellanox/x86_64-mlnx_msn4600-r0/sensors.conf create mode 120000 device/mellanox/x86_64-mlnx_msn4600-r0/system_health_monitoring_config.json create mode 120000 device/mellanox/x86_64-mlnx_msn4600-r0/thermal_policy.json diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py index df60c5256f2a..64618a0e5a21 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py @@ -41,8 +41,10 @@ # magic code defnition for port number, qsfp port position of each platform # port_position_tuple = (PORT_START, QSFP_PORT_START, PORT_END, PORT_IN_BLOCK, EEPROM_OFFSET) -platform_dict = {'x86_64-mlnx_msn2700-r0': 0, 'x86_64-mlnx_msn2740-r0': 0, 'x86_64-mlnx_msn2100-r0': 1, 'x86_64-mlnx_msn2410-r0': 2, 'x86_64-mlnx_msn2010-r0': 3, - 'x86_64-mlnx_msn3420-r0': 5, 'x86_64-mlnx_msn3700-r0': 0, 'x86_64-mlnx_msn3700c-r0': 0, 'x86_64-mlnx_msn3800-r0': 4, 'x86_64-mlnx_msn4600c': 4, 'x86_64-mlnx_msn4700-r0': 0} +platform_dict = {'x86_64-mlnx_msn2700-r0': 0, 'x86_64-mlnx_msn2740-r0': 0, 'x86_64-mlnx_msn2100-r0': 1, + 'x86_64-mlnx_msn2410-r0': 2, 'x86_64-mlnx_msn2010-r0': 3, 'x86_64-mlnx_msn3420-r0': 5, + 'x86_64-mlnx_msn3700-r0': 0, 'x86_64-mlnx_msn3700c-r0': 0, 'x86_64-mlnx_msn3800-r0': 4, + 'x86_64-mlnx_msn4600-r0': 4, 'x86_64-mlnx_msn4600c': 4, 'x86_64-mlnx_msn4700-r0': 0} port_position_tuple_list = [(0, 0, 31, 32, 1), (0, 0, 15, 16, 1), (0, 48, 55, 56, 1), (0, 18, 21, 22, 1), (0, 0, 63, 64, 1), (0, 48, 59, 60, 1)] diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/buffers.json.j2 b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/buffers.json.j2 new file mode 120000 index 000000000000..f46e9600153b --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/buffers.json.j2 @@ -0,0 +1 @@ +../../x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers.json.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/buffers_defaults_t0.j2 new file mode 120000 index 000000000000..ddb883a1daa4 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/buffers_defaults_t0.j2 @@ -0,0 +1 @@ +../../x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t0.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/buffers_defaults_t1.j2 new file mode 120000 index 000000000000..f8bbb6e631e7 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/buffers_defaults_t1.j2 @@ -0,0 +1 @@ +../../x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t1.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/buffers_dynamic.json.j2 b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/buffers_dynamic.json.j2 new file mode 120000 index 000000000000..8c4117c66214 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/buffers_dynamic.json.j2 @@ -0,0 +1 @@ +../../x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_dynamic.json.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/pg_profile_lookup.ini b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/pg_profile_lookup.ini new file mode 120000 index 000000000000..88e51ceae044 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/pg_profile_lookup.ini @@ -0,0 +1 @@ +../../x86_64-mlnx_msn4700-r0/ACS-MSN4700/pg_profile_lookup.ini \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/port_config.ini b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/port_config.ini new file mode 100644 index 000000000000..a1ecf9aa3266 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/port_config.ini @@ -0,0 +1,65 @@ +# name lanes alias index +Ethernet0 0,1,2,3 etp1 1 +Ethernet8 8,9,10,11 etp2 2 +Ethernet16 16,17,18,19 etp3 3 +Ethernet24 24,25,26,27 etp4 4 +Ethernet32 32,33,34,35 etp5 5 +Ethernet40 40,41,42,43 etp6 6 +Ethernet48 48,49,50,51 etp7 7 +Ethernet56 56,57,58,59 etp8 8 +Ethernet64 64,65,66,67 etp9 9 +Ethernet72 72,73,74,75 etp10 10 +Ethernet80 80,81,82,83 etp11 11 +Ethernet88 88,89,90,91 etp12 12 +Ethernet96 96,97,98,99 etp13 13 +Ethernet104 104,105,106,107 etp14 14 +Ethernet112 112,113,114,115 etp15 15 +Ethernet120 120,121,122,123 etp16 16 +Ethernet128 128,129,130,131 etp17 17 +Ethernet136 136,137,138,139 etp18 18 +Ethernet144 144,145,146,147 etp19 19 +Ethernet152 152,153,154,155 etp20 20 +Ethernet160 160,161,162,163 etp21 21 +Ethernet168 168,169,170,171 etp22 22 +Ethernet176 176,177,178,179 etp23 23 +Ethernet184 184,185,186,187 etp24 24 +Ethernet192 192,193,194,195 etp25 25 +Ethernet200 200,201,202,203 etp26 26 +Ethernet208 208,209,210,211 etp27 27 +Ethernet216 216,217,218,219 etp28 28 +Ethernet224 224,225,226,227 etp29 29 +Ethernet232 232,233,234,235 etp30 30 +Ethernet240 240,241,242,243 etp31 31 +Ethernet248 248,249,250,251 etp32 32 +Ethernet256 256,257,258,259 etp33 33 +Ethernet264 264,265,266,267 etp34 34 +Ethernet272 272,273,274,275 etp35 35 +Ethernet280 280,281,282,283 etp36 36 +Ethernet288 288,289,290,291 etp37 37 +Ethernet296 296,297,298,299 etp38 38 +Ethernet304 304,305,306,307 etp39 39 +Ethernet312 312,313,314,315 etp40 40 +Ethernet320 320,321,322,323 etp41 41 +Ethernet328 328,329,330,331 etp42 42 +Ethernet336 336,337,338,339 etp43 43 +Ethernet344 344,345,346,347 etp44 44 +Ethernet352 352,353,354,355 etp45 45 +Ethernet360 360,361,362,363 etp46 46 +Ethernet368 368,369,370,371 etp47 47 +Ethernet376 376,377,378,379 etp48 48 +Ethernet384 384,385,386,387 etp49 49 +Ethernet392 392,393,394,395 etp50 50 +Ethernet400 400,401,402,403 etp51 51 +Ethernet408 408,409,410,411 etp52 52 +Ethernet416 416,417,418,419 etp53 53 +Ethernet424 424,425,426,427 etp54 54 +Ethernet432 432,433,434,435 etp55 55 +Ethernet440 440,441,442,443 etp56 56 +Ethernet448 448,449,450,451 etp57 57 +Ethernet456 456,457,458,459 etp58 58 +Ethernet464 464,465,466,467 etp59 59 +Ethernet472 472,473,474,475 etp60 60 +Ethernet480 480,481,482,483 etp61 61 +Ethernet488 488,489,490,491 etp62 62 +Ethernet496 496,497,498,499 etp63 63 +Ethernet504 504,505,506,507 etp64 64 diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/qos.json.j2 b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/qos.json.j2 new file mode 120000 index 000000000000..8633303ece77 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/qos.json.j2 @@ -0,0 +1 @@ +../../x86_64-mlnx_msn4700-r0/ACS-MSN4700/qos.json.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/sai.profile b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/sai.profile new file mode 100644 index 000000000000..8d18361c1620 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/sai.profile @@ -0,0 +1 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_4600.xml diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/sai_4600.xml b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/sai_4600.xml new file mode 100644 index 000000000000..96e09ce694f5 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/sai_4600.xml @@ -0,0 +1,471 @@ + + + + + + 00:02:03:04:05:80 + + + 1 + + + 64 + + + + + 105 + 4 + 0 + + + 3 + + + 4096 + + + 107 + 4 + 1 + 3 + 4096 + + + 109 + 4 + 2 + 3 + 4096 + + + 111 + 4 + 3 + 3 + 4096 + + + 97 + 4 + 4 + 3 + 4096 + + + 99 + 4 + 5 + 3 + 4096 + + + 101 + 4 + 6 + 3 + 4096 + + + 103 + 4 + 7 + 3 + 4096 + + + 121 + 4 + 8 + 3 + 4096 + + + 123 + 4 + 9 + 3 + 4096 + + + 125 + 4 + 10 + 3 + 4096 + + + 127 + 4 + 11 + 3 + 4096 + + + 113 + 4 + 12 + 3 + 4096 + + + 115 + 4 + 13 + 3 + 4096 + + + 117 + 4 + 14 + 3 + 4096 + + + 119 + 4 + 15 + 3 + 4096 + + + 89 + 4 + 16 + 3 + 4096 + + + 91 + 4 + 17 + 3 + 4096 + + + 93 + 4 + 18 + 3 + 4096 + + + 95 + 4 + 19 + 3 + 4096 + + + 81 + 4 + 20 + 3 + 4096 + + + 83 + 4 + 21 + 3 + 4096 + + + 85 + 4 + 22 + 3 + 4096 + + + 87 + 4 + 23 + 3 + 4096 + + + 73 + 4 + 24 + 3 + 4096 + + + 75 + 4 + 25 + 3 + 4096 + + + 77 + 4 + 26 + 3 + 4096 + + + 79 + 4 + 27 + 3 + 4096 + + + 65 + 4 + 28 + 3 + 4096 + + + 67 + 4 + 29 + 3 + 4096 + + + 69 + 4 + 30 + 3 + 4096 + + + 71 + 4 + 31 + 3 + 4096 + + + 5 + 4 + 32 + 3 + 4096 + + + 7 + 4 + 33 + 3 + 4096 + + + 1 + 4 + 34 + 3 + 4096 + + + 3 + 4 + 35 + 3 + 4096 + + + 13 + 4 + 36 + 3 + 4096 + + + 15 + 4 + 37 + 3 + 4096 + + + 9 + 4 + 38 + 3 + 4096 + + + 11 + 4 + 39 + 3 + 4096 + + + 21 + 4 + 40 + 3 + 4096 + + + 23 + 4 + 41 + 3 + 4096 + + + 17 + 4 + 42 + 3 + 4096 + + + 19 + 4 + 43 + 3 + 4096 + + + 29 + 4 + 44 + 3 + 4096 + + + 31 + 4 + 45 + 3 + 4096 + + + 25 + 4 + 46 + 3 + 4096 + + + 27 + 4 + 47 + 3 + 4096 + + + 53 + 4 + 48 + 3 + 4096 + + + 55 + 4 + 49 + 3 + 4096 + + + 49 + 4 + 50 + 3 + 4096 + + + 51 + 4 + 51 + 3 + 4096 + + + 61 + 4 + 52 + 3 + 4096 + + + 63 + 4 + 53 + 3 + 4096 + + + 57 + 4 + 54 + 3 + 4096 + + + 59 + 4 + 55 + 3 + 4096 + + + 37 + 4 + 56 + 3 + 4096 + + + 39 + 4 + 57 + 3 + 4096 + + + 33 + 4 + 58 + 3 + 4096 + + + 35 + 4 + 59 + 3 + 4096 + + + 45 + 4 + 60 + 3 + 4096 + + + 47 + 4 + 61 + 3 + 4096 + + + 41 + 4 + 62 + 3 + 4096 + + + 43 + 4 + 63 + 3 + 4096 + + + + + diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/default_sku b/device/mellanox/x86_64-mlnx_msn4600-r0/default_sku new file mode 100644 index 000000000000..08921eaa2578 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/default_sku @@ -0,0 +1 @@ +ACS-MSN4600 t1 diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/pcie.yaml b/device/mellanox/x86_64-mlnx_msn4600-r0/pcie.yaml new file mode 100644 index 000000000000..dcfdf1c9a59c --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/pcie.yaml @@ -0,0 +1,419 @@ +- bus: '00' + dev: '00' + fn: '0' + id: 6f00 + name: 'Host bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D DMI2 + (rev 03)' +- bus: '00' + dev: '01' + fn: '0' + id: 6f02 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 1 (rev 03)' +- bus: '00' + dev: '01' + fn: '1' + id: 6f03 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 1 (rev 03)' +- bus: '00' + dev: '02' + fn: '0' + id: 6f04 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 2 (rev 03)' +- bus: '00' + dev: '02' + fn: '2' + id: 6f06 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 2 (rev 03)' +- bus: '00' + dev: '03' + fn: '0' + id: 6f08 + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 3 (rev 03)' +- bus: '00' + dev: '03' + fn: '2' + id: 6f0a + name: 'PCI bridge: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D PCI + Express Root Port 3 (rev 03)' +- bus: '00' + dev: '05' + fn: '0' + id: 6f28 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Map/VTd_Misc/System Management (rev 03)' +- bus: '00' + dev: '05' + fn: '1' + id: 6f29 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D IIO Hot Plug (rev 03)' +- bus: '00' + dev: '05' + fn: '2' + id: 6f2a + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D IIO RAS/Control Status/Global Errors (rev 03)' +- bus: '00' + dev: '05' + fn: '4' + id: 6f2c + name: 'PIC: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D I/O APIC (rev + 03)' +- bus: '00' + dev: '14' + fn: '0' + id: 8c31 + name: 'USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB + xHCI (rev 05)' +- bus: '00' + dev: 1c + fn: '0' + id: 8c10 + name: 'PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express + Root Port #1 (rev d5)' +- bus: '00' + dev: 1c + fn: '7' + id: 8c1e + name: 'PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express + Root Port #8 (rev d5)' +- bus: '00' + dev: 1d + fn: '0' + id: 8c26 + name: 'USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB + EHCI #1 (rev 05)' +- bus: '00' + dev: 1f + fn: '0' + id: 8c54 + name: 'ISA bridge: Intel Corporation C224 Series Chipset Family Server Standard + SKU LPC Controller (rev 05)' +- bus: '00' + dev: 1f + fn: '2' + id: 8c02 + name: 'SATA controller: Intel Corporation 8 Series/C220 Series Chipset Family 6-port + SATA Controller 1 [AHCI mode] (rev 05)' +- bus: '00' + dev: 1f + fn: '3' + id: 8c22 + name: 'SMBus: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller + (rev 05)' +- bus: '03' + dev: '00' + fn: '0' + id: 6f50 + name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology + Register DMA Channel 0' +- bus: '03' + dev: '00' + fn: '1' + id: 6f51 + name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology + Register DMA Channel 1' +- bus: '03' + dev: '00' + fn: '2' + id: 6f52 + name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology + Register DMA Channel 2' +- bus: '03' + dev: '00' + fn: '3' + id: 6f53 + name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology + Register DMA Channel 3' +- bus: '06' + dev: '00' + fn: '0' + id: cf70 + name: 'Ethernet controller: Mellanox Technologies Device cf70' +- bus: 08 + dev: '00' + fn: '0' + id: '1533' + name: 'Ethernet controller: Intel Corporation I210 Gigabit Network Connection (rev + 03)' +- bus: ff + dev: 0b + fn: '0' + id: 6f81 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R3 QPI Link 0/1 (rev 03)' +- bus: ff + dev: 0b + fn: '1' + id: 6f36 + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R3 QPI Link 0/1 (rev 03)' +- bus: ff + dev: 0b + fn: '2' + id: 6f37 + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R3 QPI Link 0/1 (rev 03)' +- bus: ff + dev: 0b + fn: '3' + id: 6f76 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R3 QPI Link Debug (rev 03)' +- bus: ff + dev: 0c + fn: '0' + id: 6fe0 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0c + fn: '1' + id: 6fe1 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0c + fn: '2' + id: 6fe2 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0c + fn: '3' + id: 6fe3 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0f + fn: '0' + id: 6ff8 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0f + fn: '4' + id: 6ffc + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0f + fn: '5' + id: 6ffd + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: 0f + fn: '6' + id: 6ffe + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Caching Agent (rev 03)' +- bus: ff + dev: '10' + fn: '0' + id: 6f1d + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R2PCIe Agent (rev 03)' +- bus: ff + dev: '10' + fn: '1' + id: 6f34 + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D R2PCIe Agent (rev 03)' +- bus: ff + dev: '10' + fn: '5' + id: 6f1e + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Ubox (rev 03)' +- bus: ff + dev: '10' + fn: '6' + id: 6f7d + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Ubox (rev 03)' +- bus: ff + dev: '10' + fn: '7' + id: 6f1f + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Ubox (rev 03)' +- bus: ff + dev: '12' + fn: '0' + id: 6fa0 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Home Agent 0 (rev 03)' +- bus: ff + dev: '12' + fn: '1' + id: 6f30 + name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Home Agent 0 (rev 03)' +- bus: ff + dev: '13' + fn: '0' + id: 6fa8 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Target Address/Thermal/RAS (rev 03)' +- bus: ff + dev: '13' + fn: '1' + id: 6f71 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Target Address/Thermal/RAS (rev 03)' +- bus: ff + dev: '13' + fn: '2' + id: 6faa + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel Target Address Decoder (rev 03)' +- bus: ff + dev: '13' + fn: '3' + id: 6fab + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel Target Address Decoder (rev 03)' +- bus: ff + dev: '13' + fn: '4' + id: 6fac + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel Target Address Decoder (rev 03)' +- bus: ff + dev: '13' + fn: '5' + id: 6fad + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel Target Address Decoder (rev 03)' +- bus: ff + dev: '13' + fn: '6' + id: 6fae + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Broadcast (rev 03)' +- bus: ff + dev: '13' + fn: '7' + id: 6faf + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Global Broadcast (rev 03)' +- bus: ff + dev: '14' + fn: '0' + id: 6fb0 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 0 Thermal Control (rev 03)' +- bus: ff + dev: '14' + fn: '1' + id: 6fb1 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 1 Thermal Control (rev 03)' +- bus: ff + dev: '14' + fn: '2' + id: 6fb2 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 0 Error (rev 03)' +- bus: ff + dev: '14' + fn: '3' + id: 6fb3 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 1 Error (rev 03)' +- bus: ff + dev: '14' + fn: '4' + id: 6fbc + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Interface (rev 03)' +- bus: ff + dev: '14' + fn: '5' + id: 6fbd + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Interface (rev 03)' +- bus: ff + dev: '14' + fn: '6' + id: 6fbe + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Interface (rev 03)' +- bus: ff + dev: '14' + fn: '7' + id: 6fbf + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D DDRIO Channel 0/1 Interface (rev 03)' +- bus: ff + dev: '15' + fn: '0' + id: 6fb4 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 2 Thermal Control (rev 03)' +- bus: ff + dev: '15' + fn: '1' + id: 6fb5 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 3 Thermal Control (rev 03)' +- bus: ff + dev: '15' + fn: '2' + id: 6fb6 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 2 Error (rev 03)' +- bus: ff + dev: '15' + fn: '3' + id: 6fb7 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Memory Controller 0 - Channel 3 Error (rev 03)' +- bus: ff + dev: 1e + fn: '0' + id: 6f98 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1e + fn: '1' + id: 6f99 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1e + fn: '2' + id: 6f9a + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1e + fn: '3' + id: 6fc0 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1e + fn: '4' + id: 6f9c + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1f + fn: '0' + id: 6f88 + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' +- bus: ff + dev: 1f + fn: '2' + id: 6f8a + name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon + D Power Control Unit (rev 03)' diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/platform_components.json b/device/mellanox/x86_64-mlnx_msn4600-r0/platform_components.json new file mode 100644 index 000000000000..35ebe3943dac --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/platform_components.json @@ -0,0 +1,14 @@ +{ + "chassis": { + "MSN4600": { + "component": { + "ONIE": { }, + "SSD": { }, + "BIOS": { }, + "CPLD1": { }, + "CPLD2": { }, + "CPLD3": { } + } + } + } +} diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/platform_reboot b/device/mellanox/x86_64-mlnx_msn4600-r0/platform_reboot new file mode 120000 index 000000000000..43c8ea567493 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/platform_reboot @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/platform_reboot \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/platform_wait b/device/mellanox/x86_64-mlnx_msn4600-r0/platform_wait new file mode 120000 index 000000000000..4b30bd429854 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/platform_wait @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/platform_wait \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/eeprom.py b/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/eeprom.py new file mode 120000 index 000000000000..b4e2a6a61671 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/eeprom.py @@ -0,0 +1 @@ +../../x86_64-mlnx_msn2700-r0/plugins/eeprom.py \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/psuutil.py b/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/psuutil.py new file mode 120000 index 000000000000..9f724238a8d5 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/psuutil.py @@ -0,0 +1 @@ +../../x86_64-mlnx_msn2700-r0/plugins/psuutil.py \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/sfplpmget.py b/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/sfplpmget.py new file mode 120000 index 000000000000..2e84f435abd9 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/sfplpmget.py @@ -0,0 +1 @@ +../../x86_64-mlnx_msn2700-r0/plugins/sfplpmget.py \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/sfplpmset.py b/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/sfplpmset.py new file mode 120000 index 000000000000..6a88bac30467 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/sfplpmset.py @@ -0,0 +1 @@ +../../x86_64-mlnx_msn2700-r0/plugins/sfplpmset.py \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/sfpreset.py b/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/sfpreset.py new file mode 120000 index 000000000000..fef2063e3496 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/sfpreset.py @@ -0,0 +1 @@ +../../x86_64-mlnx_msn2700-r0/plugins/sfpreset.py \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/sfputil.py b/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/sfputil.py new file mode 120000 index 000000000000..45909b880fc9 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/plugins/sfputil.py @@ -0,0 +1 @@ +../../x86_64-mlnx_msn2700-r0/plugins/sfputil.py \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/pmon_daemon_control.json b/device/mellanox/x86_64-mlnx_msn4600-r0/pmon_daemon_control.json new file mode 120000 index 000000000000..435a2ce7c0ba --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/pmon_daemon_control.json @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/pmon_daemon_control.json \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/sensors.conf b/device/mellanox/x86_64-mlnx_msn4600-r0/sensors.conf new file mode 100644 index 000000000000..da05cd94bf9f --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/sensors.conf @@ -0,0 +1,189 @@ +################################################################################ +# Copyright (c) 2021 Mellanox Technologies +# +# Platform specific sensors config for SN4600 +################################################################################ + +# 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 "xdpe12284-i2c-*-62" + label in1 "PMIC-1 PSU 12V Rail (in)" + ignore in2 + label in3 "PMIC-1 ASIC 0.8V VCORE_MAIN Rail (out)" + ignore in4 + label temp1 "PMIC-1 Temp 1" + label temp2 "PMIC-1 Temp 2" + label power1 "PMIC-1 ASIC 12V VCORE_MAIN Rail Pwr (in)" + ignore power2 + label power3 "PMIC-1 ASIC 0.8V VCORE_MAIN Rail Pwr (out)" + ignore power4 + label curr1 "PMIC-1 ASIC 12V VCORE_MAIN Rail Curr (in)" + ignore curr2 + label curr3 "PMIC-1 ASIC 0.8V VCORE_MAIN Rail Curr (out)" + ignore curr4 + chip "xdpe12284-i2c-*-64" + label in1 "PMIC-2 PSU 12V Rail_1 (in)" + label in2 "PMIC-2 PSU 12V Rail_2 (in)" + label in3 "PMIC-2 ASIC 1.8V Rail_1 (out)" + label in4 "PMIC-2 ASIC 1.2V Rail_2 (out)" + label temp1 "PMIC-2 Temp 1" + label temp2 "PMIC-2 Temp 2" + label power1 "PMIC-2 ASIC 12V Rail_1 Pwr (in)" + label power2 "PMIC-2 ASIC 12V Rail_2 Pwr (in)" + label power3 "PMIC-2 ASIC 1.8V Rail_1 Pwr (out)" + label power4 "PMIC-2 ASIC 1.2V Rail_2 Pwr (out)" + label curr1 "PMIC-2 ASIC 12V Rail_1 Curr (in)" + label curr2 "PMIC-2 ASIC 12V Rail_2 Curr (in)" + label curr3 "PMIC-2 ASIC 1.8V Rail_1 Curr (out)" + label curr4 "PMIC-2 ASIC 1.2V Rail_2 Curr (out)" + chip "xdpe12284-i2c-*-66" + label in1 "PMIC-3 PSU 12V Rail_1 (in)" + label in2 "PMIC-3 PSU 12V Rail_2 (in)" + label in3 "PMIC-3 ASIC 0.85V Rail_1 T0_1 (out)" + label in4 "PMIC-3 ASIC 1.8V Rail_2 T0_1 (out)" + label temp1 "PMIC-3 Temp 1" + label temp2 "PMIC-3 Temp 2" + label power1 "PMIC-3 ASIC 12V Rail_1 Pwr (in)" + label power2 "PMIC-3 ASIC 12V Rail_2 Pwr (in)" + label power3 "PMIC-3 ASIC 0.85V Rail_1 T0_1 Pwr (out)" + label power4 "PMIC-3 ASIC 1.8V Rail_2 T0_1 Pwr (out)" + label curr1 "PMIC-3 ASIC 12V Rail_1 Curr (in)" + label curr2 "PMIC-3 ASIC 12V Rail_2 Curr (in)" + label curr3 "PMIC-3 ASIC 0.85V Rail_1 T0_1 Curr (out)" + label curr4 "PMIC-3 ASIC 1.8V Rail_2 T0_1 Curr (out)" + chip "xdpe12284-i2c-*-68" + label in1 "PMIC-4 PSU 12V Rail_1 (in)" + label in2 "PMIC-4 PSU 12V Rail_2 (in)" + label in3 "PMIC-4 ASIC 0.85V Rail_1 T2_3 (out)" + label in4 "PMIC-4 ASIC 1.8V Rail_2 T2_3 (out)" + label temp1 "PMIC-4 Temp 1" + label temp2 "PMIC-4 Temp 2" + label power1 "PMIC-4 ASIC 12V Rail_1 Pwr (in)" + label power2 "PMIC-4 ASIC 12V Rail_2 Pwr (in)" + label power3 "PMIC-4 ASIC 0.85V Rail_1 T2_3 Pwr (out)" + label power4 "PMIC-4 ASIC 1.8V Rail_2 T2_3 Pwr (out)" + label curr1 "PMIC-4 ASIC 12V Rail_1 Curr (in)" + label curr2 "PMIC-4 ASIC 12V Rail_2 Curr (in)" + label curr3 "PMIC-4 ASIC 0.85V Rail_1 T2_3 Curr (out)" + label curr4 "PMIC-4 ASIC 1.8V Rail_2 T2_3 Curr (out)" + chip "xdpe12284-i2c-*-6a" + label in1 "PMIC-5 PSU 12V Rail_1 (in)" + label in2 "PMIC-5 PSU 12V Rail_2 (in)" + label in3 "PMIC-5 ASIC 0.85V Rail_1 T4_5 (out)" + label in4 "PMIC-5 ASIC 1.8V Rail_2 T4_5 (out)" + label temp1 "PMIC-5 Temp 1" + label temp2 "PMIC-5 Temp 2" + label power1 "PMIC-5 ASIC 12V Rail_1 Pwr (in)" + label power2 "PMIC-5 ASIC 12V Rail_2 Pwr (in)" + label power3 "PMIC-5 ASIC 0.85V Rail_1 T4_5 Pwr (out)" + label power4 "PMIC-5 ASIC 1.8V Rail_2 T4_5 Pwr (out)" + label curr1 "PMIC-5 ASIC 12V Rail_1 Curr (in)" + label curr2 "PMIC-5 ASIC 12V Rail_2 Curr (in)" + label curr3 "PMIC-5 ASIC 0.85V Rail_1 T4_5 Curr (out)" + label curr4 "PMIC-5 ASIC 1.8V Rail_2 T4_5 Curr (out)" + chip "xdpe12284-i2c-*-6c" + label in1 "PMIC-6 PSU 12V Rail_1 (in)" + label in2 "PMIC-6 PSU 12V Rail_2 (in)" + label in3 "PMIC-6 ASIC 0.85V Rail_1 T6_7 (out)" + label in4 "PMIC-6 ASIC 1.8V Rail_2 T6_7 (out)" + label temp1 "PMIC-6 Temp 1" + label temp2 "PMIC-6 Temp 2" + label power1 "PMIC-6 ASIC 12V Rail_1 Pwr (in)" + label power2 "PMIC-6 ASIC 12V Rail_2 Pwr (in)" + label power3 "PMIC-6 ASIC 0.85V Rail_1 T6_7 Pwr (out)" + label power4 "PMIC-6 ASIC 1.8V Rail_2 T6_7 Pwr (out)" + label curr1 "PMIC-6 ASIC 12V Rail_1 Curr (in)" + label curr2 "PMIC-6 ASIC 12V Rail_2 Curr (in)" + label curr3 "PMIC-6 ASIC 0.85V Rail_1 T6_7 Curr (out)" + label curr4 "PMIC-6 ASIC 1.8V Rail_2 T6_7 Curr (out)" + chip "xdpe12284-i2c-*-6e" + label in1 "PMIC-7 PSU 12V Rail_1 (in)" + label in2 "PMIC-7 PSU 12V Rail_2 (in)" + label in3 "PMIC-7 ASIC 1.2V Rail_1 T0_3 (out)" + label in4 "PMIC-7 ASIC 1.2V Rail_2 T4_7 (out)" + label temp1 "PMIC-7 Temp 1" + label temp2 "PMIC-7 Temp 2" + label power1 "PMIC-7 ASIC 12V Rail_1 Pwr (in)" + label power2 "PMIC-7 ASIC 12V Rail_2 Pwr (in)" + label power3 "PMIC-7 ASIC 1.2V Rail_1 T0_3 Pwr (out)" + label power4 "PMIC-7 ASIC 1.2V Rail_2 T4_7 Pwr (out)" + label curr1 "PMIC-7 ASIC 12V Rail_1 Curr (in)" + label curr2 "PMIC-7 ASIC 12V Rail_2 Curr (in)" + label curr3 "PMIC-7 ASIC 1.2V Rail_1 T0_3 Curr (out)" + label curr4 "PMIC-7 ASIC 1.2V Rail_2 T4_7 Curr (out)" + +bus "i2c-15" "i2c-1-mux (chan_id 6)" + chip "tps53679-i2c-*-58" + label in1 "PMIC-8 PSU 12V Rail (in1)" + label in2 "PMIC-8 PSU 12V Rail (in2)" + label in3 "PMIC-8 COMEX 1.8V Rail (out)" + label in4 "PMIC-8 COMEX 1.05V Rail (out)" + label temp1 "PMIC-8 Temp 1" + label temp2 "PMIC-8 Temp 2" + label power1 "PMIC-8 COMEX 1.8V Rail Pwr (out)" + label power2 "PMIC-8 COMEX 1.05V Rail Pwr (out)" + label curr1 "PMIC-8 COMEX 1.8V Rail Curr (out)" + label curr2 "PMIC-8 COMEX 1.05V Rail Curr (out)" + chip "tps53679-i2c-*-61" + label in1 "PMIC-9 PSU 12V Rail (in1)" + label in2 "PMIC-9 PSU 12V Rail (in2)" + label in3 "PMIC-9 COMEX 1.2V Rail (out)" + ignore in4 + label temp1 "PMIC-9 Temp 1" + label temp2 "PMIC-9 Temp 2" + label power1 "PMIC-9 COMEX 1.2V Rail Pwr (out)" + ignore power2 + label curr1 "PMIC-9 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_msn4600-r0/system_health_monitoring_config.json b/device/mellanox/x86_64-mlnx_msn4600-r0/system_health_monitoring_config.json new file mode 120000 index 000000000000..98df66c27ca5 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/system_health_monitoring_config.json @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/system_health_monitoring_config.json \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/thermal_policy.json b/device/mellanox/x86_64-mlnx_msn4600-r0/thermal_policy.json new file mode 120000 index 000000000000..5a25cd87f70c --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/thermal_policy.json @@ -0,0 +1 @@ +../x86_64-mlnx_msn2700-r0/thermal_policy.json \ No newline at end of file diff --git a/platform/mellanox/asic_table.j2 b/platform/mellanox/asic_table.j2 index 4afc780b0b06..4e41a416b6e0 100644 --- a/platform/mellanox/asic_table.j2 +++ b/platform/mellanox/asic_table.j2 @@ -21,6 +21,7 @@ 'x86_64-mlnx_msn4700_simx-r0':'MELLANOX-SPECTRUM-3', 'x86_64-mlnx_msn4700-r0':'MELLANOX-SPECTRUM-3', 'x86_64-mlnx_msn4600c-r0':'MELLANOX-SPECTRUM-3', + 'x86_64-mlnx_msn4600-r0':'MELLANOX-SPECTRUM-3', 'vs-platform':'vs' } %} diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py b/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py index b5ca79286d1f..585a664efce1 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py @@ -45,7 +45,11 @@ # magic code defnition for port number, qsfp port position of each Platform # port_position_tuple = (PORT_START, QSFP_PORT_START, PORT_END, PORT_IN_BLOCK, EEPROM_OFFSET) -platform_dict_port = {'x86_64-mlnx_msn2010-r0': 3, 'x86_64-mlnx_msn2100-r0': 1, 'x86_64-mlnx_msn2410-r0': 2, 'x86_64-mlnx_msn2700-r0': 0, 'x86_64-mlnx_lssn2700':0, 'x86_64-mlnx_msn2740-r0': 0, 'x86_64-mlnx_msn3420-r0':5, 'x86_64-mlnx_msn3700-r0': 0, 'x86_64-mlnx_msn3700c-r0': 0, 'x86_64-mlnx_msn3800-r0': 4, 'x86_64-mlnx_msn4600c-r0':4, 'x86_64-mlnx_msn4700-r0': 0, 'x86_64-mlnx_msn4410-r0': 0} +platform_dict_port = {'x86_64-mlnx_msn2010-r0': 3, 'x86_64-mlnx_msn2100-r0': 1, 'x86_64-mlnx_msn2410-r0': 2, + 'x86_64-mlnx_msn2700-r0': 0, 'x86_64-mlnx_lssn2700': 0, 'x86_64-mlnx_msn2740-r0': 0, + 'x86_64-mlnx_msn3420-r0': 5, 'x86_64-mlnx_msn3700-r0': 0, 'x86_64-mlnx_msn3700c-r0': 0, + 'x86_64-mlnx_msn3800-r0': 4, 'x86_64-mlnx_msn4600-r0': 4, 'x86_64-mlnx_msn4600c-r0': 4, + 'x86_64-mlnx_msn4700-r0': 0, 'x86_64-mlnx_msn4410-r0': 0} port_position_tuple_list = [(0, 0, 31, 32, 1), (0, 0, 15, 16, 1), (0, 48, 55, 56, 1), (0, 18, 21, 22, 1), (0, 0, 63, 64, 1), (0, 48, 59, 60, 1)] class Chassis(ChassisBase): 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 3853cac3f713..a52886a9de51 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py @@ -250,5 +250,26 @@ 'hot_swappable': True, 'led_num': 1 } + }, + 'x86_64-mlnx_msn4600-r0': { + 'thermal': { + 'minimum_table': { + "unk_trust": {"-127:40": 12, "41:120": 13}, + "unk_untrust": {"-127:5": 12, "6:20": 13, "21:30": 14, "31:35": 15, "36:40": 16, "41:120": 17}, + } + }, + 'fans': { + 'drawer_num': 3, + 'drawer_type': 'real', + 'fan_num_per_drawer': 1, + 'support_fan_direction': True, + 'hot_swappable': True + }, + 'psus': { + 'psu_num': 2, + 'fan_num_per_psu': 1, + 'hot_swappable': True, + 'led_num': 1 + } } -} \ No newline at end of file +} diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py b/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py index 7b73b7196ce2..cb05278d5b66 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py @@ -31,7 +31,9 @@ # in most platforms the file psuX_curr, psuX_volt and psuX_power contain current, voltage and power data respectively. # but there are exceptions which will be handled by the following dictionary -platform_dict_psu = {'x86_64-mlnx_msn3420-r0':1, 'x86_64-mlnx_msn3700-r0': 1, 'x86_64-mlnx_msn3700c-r0': 1, 'x86_64-mlnx_msn3800-r0': 1, 'x86_64-mlnx_msn4600c-r0':1, 'x86_64-mlnx_msn4700-r0': 1, 'x86_64-mlnx_msn4410-r0': 1} +platform_dict_psu = {'x86_64-mlnx_msn3420-r0': 1, 'x86_64-mlnx_msn3700-r0': 1, 'x86_64-mlnx_msn3700c-r0': 1, + 'x86_64-mlnx_msn3800-r0': 1, 'x86_64-mlnx_msn4600-r0': 1, 'x86_64-mlnx_msn4600c-r0': 1, + 'x86_64-mlnx_msn4700-r0': 1, 'x86_64-mlnx_msn4410-r0': 1} psu_profile_list = [ # default filename convention diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py index b4347d556854..b0ddf13f7bb5 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py @@ -128,9 +128,13 @@ THERMAL_API_GET_HIGH_THRESHOLD ] -platform_dict_thermal = {'x86_64-mlnx_msn2700-r0': 0, 'x86_64-mlnx_lssn2700-r0':0, 'x86_64-mlnx_msn2740-r0': 3, 'x86_64-mlnx_msn2100-r0': 1, 'x86_64-mlnx_msn2410-r0': 2, 'x86_64-mlnx_msn2010-r0': 4, 'x86_64-mlnx_msn3420-r0':9, 'x86_64-mlnx_msn3700-r0': 5, 'x86_64-mlnx_msn3700c-r0': 6, 'x86_64-mlnx_msn3800-r0': 7, 'x86_64-mlnx_msn4600c-r0':9, 'x86_64-mlnx_msn4700-r0': 8, 'x86_64-mlnx_msn4410-r0': 8} +platform_dict_thermal = {'x86_64-mlnx_msn2700-r0': 0, 'x86_64-mlnx_lssn2700-r0': 0, 'x86_64-mlnx_msn2740-r0': 3, + 'x86_64-mlnx_msn2100-r0': 1, 'x86_64-mlnx_msn2410-r0': 2, 'x86_64-mlnx_msn2010-r0': 4, + 'x86_64-mlnx_msn3420-r0': 9, 'x86_64-mlnx_msn3700-r0': 5, 'x86_64-mlnx_msn3700c-r0': 6, + 'x86_64-mlnx_msn3800-r0': 7, 'x86_64-mlnx_msn4600-r0': 12, 'x86_64-mlnx_msn4600c-r0': 9, + 'x86_64-mlnx_msn4700-r0': 8, 'x86_64-mlnx_msn4410-r0': 8} thermal_profile_list = [ - # 2700 + # 0 2700 { THERMAL_DEV_CATEGORY_CPU_CORE:(0, 2), THERMAL_DEV_CATEGORY_MODULE:(1, 32), @@ -145,7 +149,7 @@ ] ) }, - # 2100 + # 1 2100 { THERMAL_DEV_CATEGORY_CPU_CORE:(0, 4), THERMAL_DEV_CATEGORY_MODULE:(1, 16), @@ -160,7 +164,7 @@ ] ) }, - # 2410 + # 2 2410 { THERMAL_DEV_CATEGORY_CPU_CORE:(0, 2), THERMAL_DEV_CATEGORY_MODULE:(1, 56), @@ -175,7 +179,7 @@ ] ) }, - # 2740 + # 3 2740 { THERMAL_DEV_CATEGORY_CPU_CORE:(0, 4), THERMAL_DEV_CATEGORY_MODULE:(1, 32), @@ -190,7 +194,7 @@ ] ) }, - # 2010 + # 4 2010 { THERMAL_DEV_CATEGORY_CPU_CORE:(0, 4), THERMAL_DEV_CATEGORY_MODULE:(1, 22), @@ -205,7 +209,7 @@ ] ) }, - # 3700 + # 5 3700 { THERMAL_DEV_CATEGORY_CPU_CORE:(0, 4), THERMAL_DEV_CATEGORY_MODULE:(1, 32), @@ -221,7 +225,7 @@ ] ) }, - # 3700c + # 6 3700c { THERMAL_DEV_CATEGORY_CPU_CORE:(0, 2), THERMAL_DEV_CATEGORY_MODULE:(1, 32), @@ -237,7 +241,7 @@ ] ) }, - # 3800 + # 7 3800 { THERMAL_DEV_CATEGORY_CPU_CORE:(0, 4), THERMAL_DEV_CATEGORY_MODULE:(1, 64), @@ -253,7 +257,7 @@ ] ) }, - # 4700 + # 8 4700 { THERMAL_DEV_CATEGORY_CPU_CORE:(0, 4), THERMAL_DEV_CATEGORY_MODULE:(1, 32), @@ -269,7 +273,7 @@ ] ) }, - # 3420 + # 9 3420 { THERMAL_DEV_CATEGORY_CPU_CORE:(0, 2), THERMAL_DEV_CATEGORY_MODULE:(1, 60), @@ -285,7 +289,7 @@ ] ) }, - # 4600C + # 10 4600C { THERMAL_DEV_CATEGORY_CPU_CORE:(0, 4), THERMAL_DEV_CATEGORY_MODULE:(1, 64), @@ -301,7 +305,7 @@ ] ) }, - # 4410 + # 11 4410 { THERMAL_DEV_CATEGORY_CPU_CORE:(0, 4), THERMAL_DEV_CATEGORY_MODULE:(1, 32), @@ -316,6 +320,22 @@ THERMAL_DEV_FAN_AMBIENT ] ) + }, + # 12 4600 + { + THERMAL_DEV_CATEGORY_CPU_CORE:(0, 4), + THERMAL_DEV_CATEGORY_MODULE:(1, 64), + THERMAL_DEV_CATEGORY_PSU:(1, 2), + THERMAL_DEV_CATEGORY_CPU_PACK:(0,1), + THERMAL_DEV_CATEGORY_GEARBOX:(0,0), + THERMAL_DEV_CATEGORY_AMBIENT:(0, + [ + THERMAL_DEV_ASIC_AMBIENT, + THERMAL_DEV_COMEX_AMBIENT, + THERMAL_DEV_PORT_AMBIENT, + THERMAL_DEV_FAN_AMBIENT + ] + ) } ] From bb2014a0af0f99fecec0e9a27d66f3397a41ec56 Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Fri, 26 Feb 2021 10:28:32 +0200 Subject: [PATCH 0242/1674] [Mellanox]: Fix PCIEd config for SN4600c (#6892) Signed-off-by: Nazarii Hnydyn --- .../x86_64-mlnx_msn4600c-r0/pcie.yaml | 148 +++++++++--------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/pcie.yaml b/device/mellanox/x86_64-mlnx_msn4600c-r0/pcie.yaml index dcfdf1c9a59c..d110ef7c79cb 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/pcie.yaml +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/pcie.yaml @@ -71,37 +71,37 @@ name: 'USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI (rev 05)' - bus: '00' - dev: 1c + dev: '1c' fn: '0' id: 8c10 name: 'PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #1 (rev d5)' - bus: '00' - dev: 1c + dev: '1c' fn: '7' id: 8c1e name: 'PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #8 (rev d5)' - bus: '00' - dev: 1d + dev: '1d' fn: '0' id: 8c26 name: 'USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1 (rev 05)' - bus: '00' - dev: 1f + dev: '1f' fn: '0' id: 8c54 name: 'ISA bridge: Intel Corporation C224 Series Chipset Family Server Standard SKU LPC Controller (rev 05)' - bus: '00' - dev: 1f + dev: '1f' fn: '2' id: 8c02 name: 'SATA controller: Intel Corporation 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode] (rev 05)' - bus: '00' - dev: 1f + dev: '1f' fn: '3' id: 8c22 name: 'SMBus: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller @@ -130,289 +130,289 @@ id: 6f53 name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology Register DMA Channel 3' -- bus: '06' +- bus: '07' dev: '00' fn: '0' id: cf70 name: 'Ethernet controller: Mellanox Technologies Device cf70' -- bus: 08 +- bus: '09' dev: '00' fn: '0' - id: '1533' + id: 1533 name: 'Ethernet controller: Intel Corporation I210 Gigabit Network Connection (rev 03)' -- bus: ff - dev: 0b +- bus: 'ff' + dev: '0b' fn: '0' id: 6f81 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D R3 QPI Link 0/1 (rev 03)' -- bus: ff - dev: 0b +- bus: 'ff' + dev: '0b' fn: '1' id: 6f36 name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D R3 QPI Link 0/1 (rev 03)' -- bus: ff - dev: 0b +- bus: 'ff' + dev: '0b' fn: '2' id: 6f37 name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D R3 QPI Link 0/1 (rev 03)' -- bus: ff - dev: 0b +- bus: 'ff' + dev: '0b' fn: '3' id: 6f76 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D R3 QPI Link Debug (rev 03)' -- bus: ff - dev: 0c +- bus: 'ff' + dev: '0c' fn: '0' id: 6fe0 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Caching Agent (rev 03)' -- bus: ff - dev: 0c +- bus: 'ff' + dev: '0c' fn: '1' id: 6fe1 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Caching Agent (rev 03)' -- bus: ff - dev: 0c +- bus: 'ff' + dev: '0c' fn: '2' id: 6fe2 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Caching Agent (rev 03)' -- bus: ff - dev: 0c +- bus: 'ff' + dev: '0c' fn: '3' id: 6fe3 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Caching Agent (rev 03)' -- bus: ff - dev: 0f +- bus: 'ff' + dev: '0f' fn: '0' id: 6ff8 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Caching Agent (rev 03)' -- bus: ff - dev: 0f +- bus: 'ff' + dev: '0f' fn: '4' id: 6ffc name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Caching Agent (rev 03)' -- bus: ff - dev: 0f +- bus: 'ff' + dev: '0f' fn: '5' id: 6ffd name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Caching Agent (rev 03)' -- bus: ff - dev: 0f +- bus: 'ff' + dev: '0f' fn: '6' id: 6ffe name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Caching Agent (rev 03)' -- bus: ff +- bus: 'ff' dev: '10' fn: '0' id: 6f1d name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D R2PCIe Agent (rev 03)' -- bus: ff +- bus: 'ff' dev: '10' fn: '1' id: 6f34 name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D R2PCIe Agent (rev 03)' -- bus: ff +- bus: 'ff' dev: '10' fn: '5' id: 6f1e name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Ubox (rev 03)' -- bus: ff +- bus: 'ff' dev: '10' fn: '6' id: 6f7d name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Ubox (rev 03)' -- bus: ff +- bus: 'ff' dev: '10' fn: '7' id: 6f1f name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Ubox (rev 03)' -- bus: ff +- bus: 'ff' dev: '12' fn: '0' id: 6fa0 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Home Agent 0 (rev 03)' -- bus: ff +- bus: 'ff' dev: '12' fn: '1' id: 6f30 name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Home Agent 0 (rev 03)' -- bus: ff +- bus: 'ff' dev: '13' fn: '0' id: 6fa8 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Target Address/Thermal/RAS (rev 03)' -- bus: ff +- bus: 'ff' dev: '13' fn: '1' id: 6f71 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Target Address/Thermal/RAS (rev 03)' -- bus: ff +- bus: 'ff' dev: '13' fn: '2' id: 6faa name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel Target Address Decoder (rev 03)' -- bus: ff +- bus: 'ff' dev: '13' fn: '3' id: 6fab name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel Target Address Decoder (rev 03)' -- bus: ff +- bus: 'ff' dev: '13' fn: '4' id: 6fac name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel Target Address Decoder (rev 03)' -- bus: ff +- bus: 'ff' dev: '13' fn: '5' id: 6fad name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel Target Address Decoder (rev 03)' -- bus: ff +- bus: 'ff' dev: '13' fn: '6' id: 6fae name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D DDRIO Channel 0/1 Broadcast (rev 03)' -- bus: ff +- bus: 'ff' dev: '13' fn: '7' id: 6faf name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D DDRIO Global Broadcast (rev 03)' -- bus: ff +- bus: 'ff' dev: '14' fn: '0' id: 6fb0 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel 0 Thermal Control (rev 03)' -- bus: ff +- bus: 'ff' dev: '14' fn: '1' id: 6fb1 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel 1 Thermal Control (rev 03)' -- bus: ff +- bus: 'ff' dev: '14' fn: '2' id: 6fb2 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel 0 Error (rev 03)' -- bus: ff +- bus: 'ff' dev: '14' fn: '3' id: 6fb3 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel 1 Error (rev 03)' -- bus: ff +- bus: 'ff' dev: '14' fn: '4' id: 6fbc name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D DDRIO Channel 0/1 Interface (rev 03)' -- bus: ff +- bus: 'ff' dev: '14' fn: '5' id: 6fbd name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D DDRIO Channel 0/1 Interface (rev 03)' -- bus: ff +- bus: 'ff' dev: '14' fn: '6' id: 6fbe name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D DDRIO Channel 0/1 Interface (rev 03)' -- bus: ff +- bus: 'ff' dev: '14' fn: '7' id: 6fbf name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D DDRIO Channel 0/1 Interface (rev 03)' -- bus: ff +- bus: 'ff' dev: '15' fn: '0' id: 6fb4 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel 2 Thermal Control (rev 03)' -- bus: ff +- bus: 'ff' dev: '15' fn: '1' id: 6fb5 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel 3 Thermal Control (rev 03)' -- bus: ff +- bus: 'ff' dev: '15' fn: '2' id: 6fb6 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel 2 Error (rev 03)' -- bus: ff +- bus: 'ff' dev: '15' fn: '3' id: 6fb7 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel 3 Error (rev 03)' -- bus: ff - dev: 1e +- bus: 'ff' + dev: '1e' fn: '0' id: 6f98 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Power Control Unit (rev 03)' -- bus: ff - dev: 1e +- bus: 'ff' + dev: '1e' fn: '1' id: 6f99 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Power Control Unit (rev 03)' -- bus: ff - dev: 1e +- bus: 'ff' + dev: '1e' fn: '2' id: 6f9a name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Power Control Unit (rev 03)' -- bus: ff - dev: 1e +- bus: 'ff' + dev: '1e' fn: '3' id: 6fc0 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Power Control Unit (rev 03)' -- bus: ff - dev: 1e +- bus: 'ff' + dev: '1e' fn: '4' id: 6f9c name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Power Control Unit (rev 03)' -- bus: ff - dev: 1f +- bus: 'ff' + dev: '1f' fn: '0' id: 6f88 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Power Control Unit (rev 03)' -- bus: ff - dev: 1f +- bus: 'ff' + dev: '1f' fn: '2' id: 6f8a name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon From 0e5df6f4155e4558189aab98d347b4a7405c032c Mon Sep 17 00:00:00 2001 From: Nazarii Hnydyn Date: Fri, 26 Feb 2021 10:28:17 +0200 Subject: [PATCH 0243/1674] [Mellanox]: Fix PCIEd config for SN4600 (#6894) Signed-off-by: Nazarii Hnydyn --- .../mellanox/x86_64-mlnx_msn4600-r0/pcie.yaml | 148 +++++++++--------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/pcie.yaml b/device/mellanox/x86_64-mlnx_msn4600-r0/pcie.yaml index dcfdf1c9a59c..d110ef7c79cb 100644 --- a/device/mellanox/x86_64-mlnx_msn4600-r0/pcie.yaml +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/pcie.yaml @@ -71,37 +71,37 @@ name: 'USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI (rev 05)' - bus: '00' - dev: 1c + dev: '1c' fn: '0' id: 8c10 name: 'PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #1 (rev d5)' - bus: '00' - dev: 1c + dev: '1c' fn: '7' id: 8c1e name: 'PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #8 (rev d5)' - bus: '00' - dev: 1d + dev: '1d' fn: '0' id: 8c26 name: 'USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1 (rev 05)' - bus: '00' - dev: 1f + dev: '1f' fn: '0' id: 8c54 name: 'ISA bridge: Intel Corporation C224 Series Chipset Family Server Standard SKU LPC Controller (rev 05)' - bus: '00' - dev: 1f + dev: '1f' fn: '2' id: 8c02 name: 'SATA controller: Intel Corporation 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode] (rev 05)' - bus: '00' - dev: 1f + dev: '1f' fn: '3' id: 8c22 name: 'SMBus: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller @@ -130,289 +130,289 @@ id: 6f53 name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology Register DMA Channel 3' -- bus: '06' +- bus: '07' dev: '00' fn: '0' id: cf70 name: 'Ethernet controller: Mellanox Technologies Device cf70' -- bus: 08 +- bus: '09' dev: '00' fn: '0' - id: '1533' + id: 1533 name: 'Ethernet controller: Intel Corporation I210 Gigabit Network Connection (rev 03)' -- bus: ff - dev: 0b +- bus: 'ff' + dev: '0b' fn: '0' id: 6f81 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D R3 QPI Link 0/1 (rev 03)' -- bus: ff - dev: 0b +- bus: 'ff' + dev: '0b' fn: '1' id: 6f36 name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D R3 QPI Link 0/1 (rev 03)' -- bus: ff - dev: 0b +- bus: 'ff' + dev: '0b' fn: '2' id: 6f37 name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D R3 QPI Link 0/1 (rev 03)' -- bus: ff - dev: 0b +- bus: 'ff' + dev: '0b' fn: '3' id: 6f76 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D R3 QPI Link Debug (rev 03)' -- bus: ff - dev: 0c +- bus: 'ff' + dev: '0c' fn: '0' id: 6fe0 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Caching Agent (rev 03)' -- bus: ff - dev: 0c +- bus: 'ff' + dev: '0c' fn: '1' id: 6fe1 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Caching Agent (rev 03)' -- bus: ff - dev: 0c +- bus: 'ff' + dev: '0c' fn: '2' id: 6fe2 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Caching Agent (rev 03)' -- bus: ff - dev: 0c +- bus: 'ff' + dev: '0c' fn: '3' id: 6fe3 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Caching Agent (rev 03)' -- bus: ff - dev: 0f +- bus: 'ff' + dev: '0f' fn: '0' id: 6ff8 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Caching Agent (rev 03)' -- bus: ff - dev: 0f +- bus: 'ff' + dev: '0f' fn: '4' id: 6ffc name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Caching Agent (rev 03)' -- bus: ff - dev: 0f +- bus: 'ff' + dev: '0f' fn: '5' id: 6ffd name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Caching Agent (rev 03)' -- bus: ff - dev: 0f +- bus: 'ff' + dev: '0f' fn: '6' id: 6ffe name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Caching Agent (rev 03)' -- bus: ff +- bus: 'ff' dev: '10' fn: '0' id: 6f1d name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D R2PCIe Agent (rev 03)' -- bus: ff +- bus: 'ff' dev: '10' fn: '1' id: 6f34 name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D R2PCIe Agent (rev 03)' -- bus: ff +- bus: 'ff' dev: '10' fn: '5' id: 6f1e name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Ubox (rev 03)' -- bus: ff +- bus: 'ff' dev: '10' fn: '6' id: 6f7d name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Ubox (rev 03)' -- bus: ff +- bus: 'ff' dev: '10' fn: '7' id: 6f1f name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Ubox (rev 03)' -- bus: ff +- bus: 'ff' dev: '12' fn: '0' id: 6fa0 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Home Agent 0 (rev 03)' -- bus: ff +- bus: 'ff' dev: '12' fn: '1' id: 6f30 name: 'Performance counters: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Home Agent 0 (rev 03)' -- bus: ff +- bus: 'ff' dev: '13' fn: '0' id: 6fa8 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Target Address/Thermal/RAS (rev 03)' -- bus: ff +- bus: 'ff' dev: '13' fn: '1' id: 6f71 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Target Address/Thermal/RAS (rev 03)' -- bus: ff +- bus: 'ff' dev: '13' fn: '2' id: 6faa name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel Target Address Decoder (rev 03)' -- bus: ff +- bus: 'ff' dev: '13' fn: '3' id: 6fab name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel Target Address Decoder (rev 03)' -- bus: ff +- bus: 'ff' dev: '13' fn: '4' id: 6fac name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel Target Address Decoder (rev 03)' -- bus: ff +- bus: 'ff' dev: '13' fn: '5' id: 6fad name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel Target Address Decoder (rev 03)' -- bus: ff +- bus: 'ff' dev: '13' fn: '6' id: 6fae name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D DDRIO Channel 0/1 Broadcast (rev 03)' -- bus: ff +- bus: 'ff' dev: '13' fn: '7' id: 6faf name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D DDRIO Global Broadcast (rev 03)' -- bus: ff +- bus: 'ff' dev: '14' fn: '0' id: 6fb0 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel 0 Thermal Control (rev 03)' -- bus: ff +- bus: 'ff' dev: '14' fn: '1' id: 6fb1 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel 1 Thermal Control (rev 03)' -- bus: ff +- bus: 'ff' dev: '14' fn: '2' id: 6fb2 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel 0 Error (rev 03)' -- bus: ff +- bus: 'ff' dev: '14' fn: '3' id: 6fb3 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel 1 Error (rev 03)' -- bus: ff +- bus: 'ff' dev: '14' fn: '4' id: 6fbc name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D DDRIO Channel 0/1 Interface (rev 03)' -- bus: ff +- bus: 'ff' dev: '14' fn: '5' id: 6fbd name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D DDRIO Channel 0/1 Interface (rev 03)' -- bus: ff +- bus: 'ff' dev: '14' fn: '6' id: 6fbe name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D DDRIO Channel 0/1 Interface (rev 03)' -- bus: ff +- bus: 'ff' dev: '14' fn: '7' id: 6fbf name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D DDRIO Channel 0/1 Interface (rev 03)' -- bus: ff +- bus: 'ff' dev: '15' fn: '0' id: 6fb4 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel 2 Thermal Control (rev 03)' -- bus: ff +- bus: 'ff' dev: '15' fn: '1' id: 6fb5 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel 3 Thermal Control (rev 03)' -- bus: ff +- bus: 'ff' dev: '15' fn: '2' id: 6fb6 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel 2 Error (rev 03)' -- bus: ff +- bus: 'ff' dev: '15' fn: '3' id: 6fb7 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Memory Controller 0 - Channel 3 Error (rev 03)' -- bus: ff - dev: 1e +- bus: 'ff' + dev: '1e' fn: '0' id: 6f98 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Power Control Unit (rev 03)' -- bus: ff - dev: 1e +- bus: 'ff' + dev: '1e' fn: '1' id: 6f99 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Power Control Unit (rev 03)' -- bus: ff - dev: 1e +- bus: 'ff' + dev: '1e' fn: '2' id: 6f9a name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Power Control Unit (rev 03)' -- bus: ff - dev: 1e +- bus: 'ff' + dev: '1e' fn: '3' id: 6fc0 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Power Control Unit (rev 03)' -- bus: ff - dev: 1e +- bus: 'ff' + dev: '1e' fn: '4' id: 6f9c name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Power Control Unit (rev 03)' -- bus: ff - dev: 1f +- bus: 'ff' + dev: '1f' fn: '0' id: 6f88 name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D Power Control Unit (rev 03)' -- bus: ff - dev: 1f +- bus: 'ff' + dev: '1f' fn: '2' id: 6f8a name: 'System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon From ea12bb397b6a1755281d7ac38910d999fba7eb05 Mon Sep 17 00:00:00 2001 From: Danny Allen Date: Sun, 28 Feb 2021 15:02:31 -0800 Subject: [PATCH 0244/1674] [openconfig_acl] Add SONiC ACL extension to open config ACL model (#6896) - Add support for VLAN ID match - Add support for ICMP type/code match Signed-off-by: Danny Allen --- src/sonic-config-engine/openconfig_acl.py | 1815 +++++++++++------ .../sonic-acl-extension.yang | 76 + 2 files changed, 1236 insertions(+), 655 deletions(-) create mode 100644 src/sonic-config-engine/sonic-acl-extension.yang diff --git a/src/sonic-config-engine/openconfig_acl.py b/src/sonic-config-engine/openconfig_acl.py index c49f79c70175..5399f21a7d7f 100644 --- a/src/sonic-config-engine/openconfig_acl.py +++ b/src/sonic-config-engine/openconfig_acl.py @@ -5,21 +5,45 @@ # 1. Sync openconfig ACL yang models from https://github.com/openconfig/public/tree/master/release/models/acl # 2. Sync inet yang models which contain type dependencies for openconfig ACL yang models from https://github.com/YangModels/yang/tree/master/standard/ietf/RFC , and put them in the same folder with models from step 1. # 3. Install PyangBind: -# pip install pyangbind +# pip3 install pyangbind # 4. Get PyangBind install path: -# export PYBINDPLUGIN=`/usr/bin/env python -c \ +# export PYBINDPLUGIN=`/usr/bin/env python3 -c \ # 'import pyangbind; import os; print "%s/plugin" % os.path.dirname(pyangbind.__file__)'` -# 5. Generate this file with pyang: -# pyang --plugindir $PYBINDPLUGIN -f pybind -o openconfig_acl.py openconfig-acl.yang +# 5. Generate this file with pyang: +# pyang --plugindir $PYBINDPLUGIN -f pybind -o openconfig_acl.py openconfig-acl.yang sonic-acl-extension.yang +# -*- coding: utf-8 -*- from operator import attrgetter -from pyangbind.lib.yangtypes import RestrictedPrecisionDecimalType, RestrictedClassType, TypedListType -from pyangbind.lib.yangtypes import YANGBool, YANGListType, YANGDynClass, ReferenceType +from pyangbind.lib.yangtypes import RestrictedPrecisionDecimalType +from pyangbind.lib.yangtypes import RestrictedClassType +from pyangbind.lib.yangtypes import TypedListType +from pyangbind.lib.yangtypes import YANGBool +from pyangbind.lib.yangtypes import YANGListType +from pyangbind.lib.yangtypes import YANGDynClass +from pyangbind.lib.yangtypes import ReferenceType from pyangbind.lib.base import PybindBase +from collections import OrderedDict from decimal import Decimal from bitarray import bitarray +import six -import builtins +# PY3 support of some PY2 keywords (needs improved) +if six.PY3: + import builtins as __builtin__ + long = int +elif six.PY2: + import __builtin__ + +class sonic_acl_extension(PybindBase): + """ + This class was auto-generated by the PythonClass plugin for PYANG + from YANG module sonic-acl-extension - based on the path /sonic-acl-extension. Each member element of + the container is represented as a class variable - with a specific + YANG type. + """ + _pyangbind_elements = {} + + class yc_state_openconfig_acl__acl_state(PybindBase): """ @@ -30,14 +54,18 @@ class yc_state_openconfig_acl__acl_state(PybindBase): YANG Description: Global operational state data for ACLs """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__counter_capability',) + __slots__ = ('_path_helper', '_extmethods', '__counter_capability',) + + _yang_name = 'state' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'state' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__counter_capability = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'oc-acl:AGGREGATE_ONLY': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:INTERFACE_AGGREGATE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'AGGREGATE_ONLY': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'INTERFACE_AGGREGATE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'INTERFACE_ONLY': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:INTERFACE_ONLY': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}},), is_leaf=True, yang_name="counter-capability", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) + self.__counter_capability = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-acl:AGGREGATE_ONLY': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:INTERFACE_AGGREGATE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'AGGREGATE_ONLY': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'INTERFACE_AGGREGATE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'INTERFACE_ONLY': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:INTERFACE_ONLY': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), is_leaf=True, yang_name="counter-capability", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) load = kwargs.pop("load", None) if args: @@ -64,7 +92,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'state'] + return [u'acl', u'state'] def _get_counter_capability(self): """ @@ -89,12 +117,12 @@ def _set_counter_capability(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'oc-acl:AGGREGATE_ONLY': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:INTERFACE_AGGREGATE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'AGGREGATE_ONLY': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'INTERFACE_AGGREGATE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'INTERFACE_ONLY': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:INTERFACE_ONLY': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}},), is_leaf=True, yang_name="counter-capability", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-acl:AGGREGATE_ONLY': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:INTERFACE_AGGREGATE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'AGGREGATE_ONLY': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'INTERFACE_AGGREGATE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'INTERFACE_ONLY': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:INTERFACE_ONLY': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), is_leaf=True, yang_name="counter-capability", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """counter_capability must be of a type compatible with identityref""", 'defined-type': "openconfig-acl:identityref", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'oc-acl:AGGREGATE_ONLY': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'oc-acl:INTERFACE_AGGREGATE': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'AGGREGATE_ONLY': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'INTERFACE_AGGREGATE': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'INTERFACE_ONLY': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'oc-acl:INTERFACE_ONLY': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}},), is_leaf=True, yang_name="counter-capability", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-acl:AGGREGATE_ONLY': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:INTERFACE_AGGREGATE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'AGGREGATE_ONLY': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'INTERFACE_AGGREGATE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'INTERFACE_ONLY': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:INTERFACE_ONLY': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), is_leaf=True, yang_name="counter-capability", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False)""", }) self.__counter_capability = t @@ -102,12 +130,12 @@ def _set_counter_capability(self, v, load=False): self._set() def _unset_counter_capability(self): - self.__counter_capability = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'oc-acl:AGGREGATE_ONLY': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:INTERFACE_AGGREGATE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'AGGREGATE_ONLY': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'INTERFACE_AGGREGATE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'INTERFACE_ONLY': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:INTERFACE_ONLY': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}},), is_leaf=True, yang_name="counter-capability", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) + self.__counter_capability = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-acl:AGGREGATE_ONLY': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:INTERFACE_AGGREGATE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'AGGREGATE_ONLY': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'INTERFACE_AGGREGATE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'INTERFACE_ONLY': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:INTERFACE_ONLY': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), is_leaf=True, yang_name="counter-capability", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) - counter_capability = builtins.property(_get_counter_capability) + counter_capability = __builtin__.property(_get_counter_capability) - _pyangbind_elements = {'counter_capability': counter_capability, } + _pyangbind_elements = OrderedDict([('counter_capability', counter_capability), ]) class yc_config_openconfig_acl__acl_acl_sets_acl_set_config(PybindBase): @@ -119,15 +147,19 @@ class yc_config_openconfig_acl__acl_acl_sets_acl_set_config(PybindBase): YANG Description: Access list config """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__name','__description',) + __slots__ = ('_path_helper', '_extmethods', '__name','__description',) + + _yang_name = 'config' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'config' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__name = YANGDynClass(base=str, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) - self.__description = YANGDynClass(base=str, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) + self.__name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) + self.__description = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) load = kwargs.pop("load", None) if args: @@ -154,7 +186,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'config'] + return [u'acl', u'acl-sets', u'acl-set', u'config'] def _get_name(self): """ @@ -177,12 +209,12 @@ def _set_name(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """name must be of a type compatible with string""", 'defined-type': "string", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True)""", }) self.__name = t @@ -190,7 +222,7 @@ def _set_name(self, v, load=False): self._set() def _unset_name(self): - self.__name = YANGDynClass(base=str, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) + self.__name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) def _get_description(self): @@ -214,12 +246,12 @@ def _set_description(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """description must be of a type compatible with string""", 'defined-type': "string", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True)""", }) self.__description = t @@ -227,13 +259,13 @@ def _set_description(self, v, load=False): self._set() def _unset_description(self): - self.__description = YANGDynClass(base=str, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) + self.__description = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) - name = builtins.property(_get_name, _set_name) - description = builtins.property(_get_description, _set_description) + name = __builtin__.property(_get_name, _set_name) + description = __builtin__.property(_get_description, _set_description) - _pyangbind_elements = {'name': name, 'description': description, } + _pyangbind_elements = OrderedDict([('name', name), ('description', description), ]) class yc_state_openconfig_acl__acl_acl_sets_acl_set_state(PybindBase): @@ -245,15 +277,19 @@ class yc_state_openconfig_acl__acl_acl_sets_acl_set_state(PybindBase): YANG Description: Access list state information """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__name','__description',) + __slots__ = ('_path_helper', '_extmethods', '__name','__description',) + + _yang_name = 'state' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'state' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__name = YANGDynClass(base=str, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) - self.__description = YANGDynClass(base=str, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) + self.__name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) + self.__description = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) load = kwargs.pop("load", None) if args: @@ -280,7 +316,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'state'] + return [u'acl', u'acl-sets', u'acl-set', u'state'] def _get_name(self): """ @@ -303,12 +339,12 @@ def _set_name(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """name must be of a type compatible with string""", 'defined-type': "string", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False)""", }) self.__name = t @@ -316,7 +352,7 @@ def _set_name(self, v, load=False): self._set() def _unset_name(self): - self.__name = YANGDynClass(base=str, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) + self.__name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) def _get_description(self): @@ -340,12 +376,12 @@ def _set_description(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """description must be of a type compatible with string""", 'defined-type': "string", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False)""", }) self.__description = t @@ -353,13 +389,13 @@ def _set_description(self, v, load=False): self._set() def _unset_description(self): - self.__description = YANGDynClass(base=str, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) + self.__description = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) - name = builtins.property(_get_name) - description = builtins.property(_get_description) + name = __builtin__.property(_get_name) + description = __builtin__.property(_get_description) - _pyangbind_elements = {'name': name, 'description': description, } + _pyangbind_elements = OrderedDict([('name', name), ('description', description), ]) class yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_config(PybindBase): @@ -371,15 +407,19 @@ class yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_confi YANG Description: Access list entries config """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__sequence_id','__description',) + __slots__ = ('_path_helper', '_extmethods', '__sequence_id','__description',) + + _yang_name = 'config' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'config' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__sequence_id = YANGDynClass(base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint32', is_config=True) - self.__description = YANGDynClass(base=str, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) + self.__sequence_id = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint32', is_config=True) + self.__description = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) load = kwargs.pop("load", None) if args: @@ -406,7 +446,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'config'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'config'] def _get_sequence_id(self): """ @@ -437,7 +477,7 @@ def _set_sequence_id(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint32', is_config=True) + t = YANGDynClass(v,base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint32', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """sequence_id must be of a type compatible with uint32""", @@ -450,7 +490,7 @@ def _set_sequence_id(self, v, load=False): self._set() def _unset_sequence_id(self): - self.__sequence_id = YANGDynClass(base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint32', is_config=True) + self.__sequence_id = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint32', is_config=True) def _get_description(self): @@ -476,12 +516,12 @@ def _set_description(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """description must be of a type compatible with string""", 'defined-type': "string", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True)""", }) self.__description = t @@ -489,13 +529,13 @@ def _set_description(self, v, load=False): self._set() def _unset_description(self): - self.__description = YANGDynClass(base=str, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) + self.__description = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=True) - sequence_id = builtins.property(_get_sequence_id, _set_sequence_id) - description = builtins.property(_get_description, _set_description) + sequence_id = __builtin__.property(_get_sequence_id, _set_sequence_id) + description = __builtin__.property(_get_description, _set_description) - _pyangbind_elements = {'sequence_id': sequence_id, 'description': description, } + _pyangbind_elements = OrderedDict([('sequence_id', sequence_id), ('description', description), ]) class yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_state(PybindBase): @@ -507,17 +547,21 @@ class yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_state( YANG Description: State information for ACL entries """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__sequence_id','__description','__matched_packets','__matched_octets',) + __slots__ = ('_path_helper', '_extmethods', '__sequence_id','__description','__matched_packets','__matched_octets',) + + _yang_name = 'state' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'state' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__matched_octets = YANGDynClass(base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) - self.__sequence_id = YANGDynClass(base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint32', is_config=False) - self.__description = YANGDynClass(base=str, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) - self.__matched_packets = YANGDynClass(base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + self.__matched_octets = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + self.__sequence_id = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint32', is_config=False) + self.__description = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) + self.__matched_packets = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) load = kwargs.pop("load", None) if args: @@ -544,7 +588,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'state'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'state'] def _get_sequence_id(self): """ @@ -575,7 +619,7 @@ def _set_sequence_id(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint32', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint32', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """sequence_id must be of a type compatible with uint32""", @@ -588,7 +632,7 @@ def _set_sequence_id(self, v, load=False): self._set() def _unset_sequence_id(self): - self.__sequence_id = YANGDynClass(base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint32', is_config=False) + self.__sequence_id = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint32', is_config=False) def _get_description(self): @@ -614,12 +658,12 @@ def _set_description(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """description must be of a type compatible with string""", 'defined-type': "string", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False)""", }) self.__description = t @@ -627,7 +671,7 @@ def _set_description(self, v, load=False): self._set() def _unset_description(self): - self.__description = YANGDynClass(base=str, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) + self.__description = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="description", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='string', is_config=False) def _get_matched_packets(self): @@ -677,7 +721,7 @@ def _set_matched_packets(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """matched_packets must be of a type compatible with yang:counter64""", @@ -690,7 +734,7 @@ def _set_matched_packets(self, v, load=False): self._set() def _unset_matched_packets(self): - self.__matched_packets = YANGDynClass(base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + self.__matched_packets = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) def _get_matched_octets(self): @@ -740,7 +784,7 @@ def _set_matched_octets(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """matched_octets must be of a type compatible with yang:counter64""", @@ -753,15 +797,15 @@ def _set_matched_octets(self, v, load=False): self._set() def _unset_matched_octets(self): - self.__matched_octets = YANGDynClass(base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + self.__matched_octets = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) - sequence_id = builtins.property(_get_sequence_id) - description = builtins.property(_get_description) - matched_packets = builtins.property(_get_matched_packets) - matched_octets = builtins.property(_get_matched_octets) + sequence_id = __builtin__.property(_get_sequence_id) + description = __builtin__.property(_get_description) + matched_packets = __builtin__.property(_get_matched_packets) + matched_octets = __builtin__.property(_get_matched_octets) - _pyangbind_elements = {'sequence_id': sequence_id, 'description': description, 'matched_packets': matched_packets, 'matched_octets': matched_octets, } + _pyangbind_elements = OrderedDict([('sequence_id', sequence_id), ('description', description), ('matched_packets', matched_packets), ('matched_octets', matched_octets), ]) class yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_l2_config(PybindBase): @@ -773,18 +817,23 @@ class yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_l2_co YANG Description: Configuration data """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__source_mac','__source_mac_mask','__destination_mac','__destination_mac_mask','__ethertype',) + __slots__ = ('_path_helper', '_extmethods', '__source_mac','__source_mac_mask','__destination_mac','__destination_mac_mask','__ethertype','__vlan_id',) + + _yang_name = 'config' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'config' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__source_mac = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) - self.__destination_mac = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) - self.__destination_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) - self.__ethertype = YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['1..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'oc-pkt-match-types:ETHERTYPE_LLDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_VLAN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_ROCE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_ARP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_IPV4': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_IPV6': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_ARP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_MPLS': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_VLAN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_ROCE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_IPV6': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_MPLS': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_IPV4': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_LLDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="ethertype", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ethertype-type', is_config=True) - self.__source_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) + self.__ethertype = YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'1..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:ETHERTYPE_LLDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_VLAN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ROCE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ARP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV4': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV6': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ARP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_MPLS': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_VLAN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ROCE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV6': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_MPLS': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV4': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_LLDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="ethertype", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ethertype-type', is_config=True) + self.__destination_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) + self.__source_mac = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) + self.__source_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) + self.__vlan_id = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..4095']}), is_leaf=True, yang_name="vlan-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='vlan-id-type', is_config=True) + self.__destination_mac = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) load = kwargs.pop("load", None) if args: @@ -811,7 +860,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'l2', 'config'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'l2', u'config'] def _get_source_mac(self): """ @@ -834,12 +883,12 @@ def _set_source_mac(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) + t = YANGDynClass(v,base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """source_mac must be of a type compatible with yang:mac-address""", 'defined-type': "yang:mac-address", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True)""", }) self.__source_mac = t @@ -847,7 +896,7 @@ def _set_source_mac(self, v, load=False): self._set() def _unset_source_mac(self): - self.__source_mac = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) + self.__source_mac = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) def _get_source_mac_mask(self): @@ -871,12 +920,12 @@ def _set_source_mac_mask(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) + t = YANGDynClass(v,base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """source_mac_mask must be of a type compatible with yang:mac-address""", 'defined-type': "yang:mac-address", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True)""", }) self.__source_mac_mask = t @@ -884,7 +933,7 @@ def _set_source_mac_mask(self, v, load=False): self._set() def _unset_source_mac_mask(self): - self.__source_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) + self.__source_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) def _get_destination_mac(self): @@ -908,12 +957,12 @@ def _set_destination_mac(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) + t = YANGDynClass(v,base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """destination_mac must be of a type compatible with yang:mac-address""", 'defined-type': "yang:mac-address", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True)""", }) self.__destination_mac = t @@ -921,7 +970,7 @@ def _set_destination_mac(self, v, load=False): self._set() def _unset_destination_mac(self): - self.__destination_mac = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) + self.__destination_mac = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) def _get_destination_mac_mask(self): @@ -945,12 +994,12 @@ def _set_destination_mac_mask(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) + t = YANGDynClass(v,base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """destination_mac_mask must be of a type compatible with yang:mac-address""", 'defined-type': "yang:mac-address", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True)""", }) self.__destination_mac_mask = t @@ -958,7 +1007,7 @@ def _set_destination_mac_mask(self, v, load=False): self._set() def _unset_destination_mac_mask(self): - self.__destination_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) + self.__destination_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) def _get_ethertype(self): @@ -982,12 +1031,12 @@ def _set_ethertype(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['1..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'oc-pkt-match-types:ETHERTYPE_LLDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_VLAN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_ROCE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_ARP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_IPV4': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_IPV6': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_ARP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_MPLS': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_VLAN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_ROCE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_IPV6': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_MPLS': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_IPV4': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_LLDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="ethertype", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ethertype-type', is_config=True) + t = YANGDynClass(v,base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'1..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:ETHERTYPE_LLDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_VLAN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ROCE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ARP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV4': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV6': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ARP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_MPLS': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_VLAN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ROCE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV6': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_MPLS': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV4': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_LLDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="ethertype", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ethertype-type', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """ethertype must be of a type compatible with oc-pkt-match-types:ethertype-type""", 'defined-type': "oc-pkt-match-types:ethertype-type", - 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': [u'1..65535']}),RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:ETHERTYPE_LLDP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_VLAN': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ROCE': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ARP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV4': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV6': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ARP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_MPLS': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_VLAN': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ROCE': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV6': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_MPLS': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV4': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_LLDP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="ethertype", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ethertype-type', is_config=True)""", + 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'1..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:ETHERTYPE_LLDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_VLAN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ROCE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ARP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV4': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV6': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ARP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_MPLS': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_VLAN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ROCE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV6': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_MPLS': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV4': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_LLDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="ethertype", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ethertype-type', is_config=True)""", }) self.__ethertype = t @@ -995,16 +1044,54 @@ def _set_ethertype(self, v, load=False): self._set() def _unset_ethertype(self): - self.__ethertype = YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['1..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'oc-pkt-match-types:ETHERTYPE_LLDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_VLAN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_ROCE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_ARP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_IPV4': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_IPV6': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_ARP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_MPLS': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_VLAN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_ROCE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_IPV6': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_MPLS': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_IPV4': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_LLDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="ethertype", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ethertype-type', is_config=True) + self.__ethertype = YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'1..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:ETHERTYPE_LLDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_VLAN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ROCE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ARP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV4': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV6': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ARP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_MPLS': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_VLAN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ROCE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV6': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_MPLS': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV4': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_LLDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="ethertype", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ethertype-type', is_config=True) + + + def _get_vlan_id(self): + """ + Getter method for vlan_id, mapped from YANG variable /acl/acl_sets/acl_set/acl_entries/acl_entry/l2/config/vlan_id (vlan-id-type) + + YANG Description: VLAN ID field to match in DOT1Q packets + """ + return self.__vlan_id + + def _set_vlan_id(self, v, load=False): + """ + Setter method for vlan_id, mapped from YANG variable /acl/acl_sets/acl_set/acl_entries/acl_entry/l2/config/vlan_id (vlan-id-type) + If this variable is read-only (config: false) in the + source YANG file, then _set_vlan_id is considered as a private + method. Backends looking to populate this variable should + do so via calling thisObj._set_vlan_id() directly. + + YANG Description: VLAN ID field to match in DOT1Q packets + """ + if hasattr(v, "_utype"): + v = v._utype(v) + try: + t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..4095']}), is_leaf=True, yang_name="vlan-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='vlan-id-type', is_config=True) + except (TypeError, ValueError): + raise ValueError({ + 'error-string': """vlan_id must be of a type compatible with vlan-id-type""", + 'defined-type': "sonic-acl-extension:vlan-id-type", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..4095']}), is_leaf=True, yang_name="vlan-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='vlan-id-type', is_config=True)""", + }) + + self.__vlan_id = t + if hasattr(self, '_set'): + self._set() + + def _unset_vlan_id(self): + self.__vlan_id = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..4095']}), is_leaf=True, yang_name="vlan-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='vlan-id-type', is_config=True) - source_mac = builtins.property(_get_source_mac, _set_source_mac) - source_mac_mask = builtins.property(_get_source_mac_mask, _set_source_mac_mask) - destination_mac = builtins.property(_get_destination_mac, _set_destination_mac) - destination_mac_mask = builtins.property(_get_destination_mac_mask, _set_destination_mac_mask) - ethertype = builtins.property(_get_ethertype, _set_ethertype) + source_mac = __builtin__.property(_get_source_mac, _set_source_mac) + source_mac_mask = __builtin__.property(_get_source_mac_mask, _set_source_mac_mask) + destination_mac = __builtin__.property(_get_destination_mac, _set_destination_mac) + destination_mac_mask = __builtin__.property(_get_destination_mac_mask, _set_destination_mac_mask) + ethertype = __builtin__.property(_get_ethertype, _set_ethertype) + vlan_id = __builtin__.property(_get_vlan_id, _set_vlan_id) - _pyangbind_elements = {'source_mac': source_mac, 'source_mac_mask': source_mac_mask, 'destination_mac': destination_mac, 'destination_mac_mask': destination_mac_mask, 'ethertype': ethertype, } + _pyangbind_elements = OrderedDict([('source_mac', source_mac), ('source_mac_mask', source_mac_mask), ('destination_mac', destination_mac), ('destination_mac_mask', destination_mac_mask), ('ethertype', ethertype), ('vlan_id', vlan_id), ]) class yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_l2_state(PybindBase): @@ -1016,18 +1103,22 @@ class yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_l2_sta YANG Description: State Information. """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__source_mac','__source_mac_mask','__destination_mac','__destination_mac_mask','__ethertype',) + __slots__ = ('_path_helper', '_extmethods', '__source_mac','__source_mac_mask','__destination_mac','__destination_mac_mask','__ethertype',) + + _yang_name = 'state' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'state' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__source_mac = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) - self.__destination_mac = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) - self.__destination_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) - self.__ethertype = YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['1..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'oc-pkt-match-types:ETHERTYPE_LLDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_VLAN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_ROCE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_ARP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_IPV4': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_IPV6': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_ARP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_MPLS': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_VLAN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_ROCE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_IPV6': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_MPLS': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_IPV4': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_LLDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="ethertype", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ethertype-type', is_config=False) - self.__source_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) + self.__source_mac = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) + self.__destination_mac = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) + self.__destination_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) + self.__ethertype = YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'1..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:ETHERTYPE_LLDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_VLAN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ROCE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ARP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV4': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV6': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ARP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_MPLS': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_VLAN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ROCE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV6': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_MPLS': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV4': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_LLDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="ethertype", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ethertype-type', is_config=False) + self.__source_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) load = kwargs.pop("load", None) if args: @@ -1054,7 +1145,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'l2', 'state'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'l2', u'state'] def _get_source_mac(self): """ @@ -1077,12 +1168,12 @@ def _set_source_mac(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """source_mac must be of a type compatible with yang:mac-address""", 'defined-type': "yang:mac-address", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False)""", }) self.__source_mac = t @@ -1090,7 +1181,7 @@ def _set_source_mac(self, v, load=False): self._set() def _unset_source_mac(self): - self.__source_mac = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) + self.__source_mac = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) def _get_source_mac_mask(self): @@ -1114,12 +1205,12 @@ def _set_source_mac_mask(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """source_mac_mask must be of a type compatible with yang:mac-address""", 'defined-type': "yang:mac-address", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False)""", }) self.__source_mac_mask = t @@ -1127,7 +1218,7 @@ def _set_source_mac_mask(self, v, load=False): self._set() def _unset_source_mac_mask(self): - self.__source_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) + self.__source_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) def _get_destination_mac(self): @@ -1151,12 +1242,12 @@ def _set_destination_mac(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """destination_mac must be of a type compatible with yang:mac-address""", 'defined-type': "yang:mac-address", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False)""", }) self.__destination_mac = t @@ -1164,7 +1255,7 @@ def _set_destination_mac(self, v, load=False): self._set() def _unset_destination_mac(self): - self.__destination_mac = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) + self.__destination_mac = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) def _get_destination_mac_mask(self): @@ -1188,12 +1279,12 @@ def _set_destination_mac_mask(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """destination_mac_mask must be of a type compatible with yang:mac-address""", 'defined-type': "yang:mac-address", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False)""", }) self.__destination_mac_mask = t @@ -1201,7 +1292,7 @@ def _set_destination_mac_mask(self, v, load=False): self._set() def _unset_destination_mac_mask(self): - self.__destination_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_dict={'pattern': '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) + self.__destination_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=False) def _get_ethertype(self): @@ -1225,12 +1316,12 @@ def _set_ethertype(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['1..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'oc-pkt-match-types:ETHERTYPE_LLDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_VLAN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_ROCE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_ARP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_IPV4': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_IPV6': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_ARP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_MPLS': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_VLAN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_ROCE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_IPV6': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_MPLS': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_IPV4': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_LLDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="ethertype", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ethertype-type', is_config=False) + t = YANGDynClass(v,base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'1..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:ETHERTYPE_LLDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_VLAN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ROCE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ARP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV4': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV6': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ARP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_MPLS': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_VLAN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ROCE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV6': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_MPLS': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV4': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_LLDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="ethertype", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ethertype-type', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """ethertype must be of a type compatible with oc-pkt-match-types:ethertype-type""", 'defined-type': "oc-pkt-match-types:ethertype-type", - 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': [u'1..65535']}),RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:ETHERTYPE_LLDP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_VLAN': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ROCE': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ARP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV4': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV6': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ARP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_MPLS': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_VLAN': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ROCE': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV6': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_MPLS': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV4': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_LLDP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="ethertype", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ethertype-type', is_config=False)""", + 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'1..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:ETHERTYPE_LLDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_VLAN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ROCE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ARP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV4': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV6': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ARP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_MPLS': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_VLAN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ROCE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV6': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_MPLS': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV4': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_LLDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="ethertype", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ethertype-type', is_config=False)""", }) self.__ethertype = t @@ -1238,16 +1329,16 @@ def _set_ethertype(self, v, load=False): self._set() def _unset_ethertype(self): - self.__ethertype = YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['1..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'oc-pkt-match-types:ETHERTYPE_LLDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_VLAN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_ROCE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_ARP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_IPV4': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_IPV6': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_ARP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_MPLS': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_VLAN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_ROCE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_IPV6': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_MPLS': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:ETHERTYPE_IPV4': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'ETHERTYPE_LLDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="ethertype", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ethertype-type', is_config=False) + self.__ethertype = YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'1..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:ETHERTYPE_LLDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_VLAN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ROCE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ARP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV4': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_IPV6': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_ARP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_MPLS': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_VLAN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_ROCE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV6': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_MPLS': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:ETHERTYPE_IPV4': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'ETHERTYPE_LLDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="ethertype", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ethertype-type', is_config=False) - source_mac = builtins.property(_get_source_mac) - source_mac_mask = builtins.property(_get_source_mac_mask) - destination_mac = builtins.property(_get_destination_mac) - destination_mac_mask = builtins.property(_get_destination_mac_mask) - ethertype = builtins.property(_get_ethertype) + source_mac = __builtin__.property(_get_source_mac) + source_mac_mask = __builtin__.property(_get_source_mac_mask) + destination_mac = __builtin__.property(_get_destination_mac) + destination_mac_mask = __builtin__.property(_get_destination_mac_mask) + ethertype = __builtin__.property(_get_ethertype) - _pyangbind_elements = {'source_mac': source_mac, 'source_mac_mask': source_mac_mask, 'destination_mac': destination_mac, 'destination_mac_mask': destination_mac_mask, 'ethertype': ethertype, } + _pyangbind_elements = OrderedDict([('source_mac', source_mac), ('source_mac_mask', source_mac_mask), ('destination_mac', destination_mac), ('destination_mac_mask', destination_mac_mask), ('ethertype', ethertype), ]) class yc_l2_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_l2(PybindBase): @@ -1259,12 +1350,16 @@ class yc_l2_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_l2(Pybind YANG Description: Ethernet header fields """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__config','__state',) + __slots__ = ('_path_helper', '_extmethods', '__config','__state',) + + _yang_name = 'l2' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'l2' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_l2_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__config = YANGDynClass(base=yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_l2_config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) @@ -1294,7 +1389,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'l2'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'l2'] def _get_config(self): """ @@ -1369,11 +1464,11 @@ def _set_state(self, v, load=False): def _unset_state(self): self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_l2_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) - config = builtins.property(_get_config, _set_config) - state = builtins.property(_get_state, _set_state) + config = __builtin__.property(_get_config, _set_config) + state = __builtin__.property(_get_state, _set_state) - _pyangbind_elements = {'config': config, 'state': state, } + _pyangbind_elements = OrderedDict([('config', config), ('state', state), ]) class yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_ip_config(PybindBase): @@ -1385,21 +1480,25 @@ class yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_ip_co YANG Description: Configuration data """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__ip_version','__source_ip_address','__source_ip_flow_label','__destination_ip_address','__destination_ip_flow_label','__dscp','__protocol','__hop_limit',) + __slots__ = ('_path_helper', '_extmethods', '__ip_version','__source_ip_address','__source_ip_flow_label','__destination_ip_address','__destination_ip_flow_label','__dscp','__protocol','__hop_limit',) + + _yang_name = 'config' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'config' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__hop_limit = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..255']}), is_leaf=True, yang_name="hop-limit", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint8', is_config=True) - self.__protocol = YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..254']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'oc-pkt-match-types:IP_TCP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_L2TP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_L2TP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_AUTH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_RSVP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_GRE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_TCP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_AUTH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_UDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_PIM': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_GRE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_IGMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_RSVP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_ICMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_PIM': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_UDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_IGMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_ICMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="protocol", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ip-protocol-type', is_config=True) - self.__dscp = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..63']}), is_leaf=True, yang_name="dscp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:dscp', is_config=True) - self.__source_ip_address = YANGDynClass(base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=str, restriction_dict={'pattern': '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="source-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=True) - self.__destination_ip_address = YANGDynClass(base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=str, restriction_dict={'pattern': '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="destination-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=True) - self.__ip_version = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'unknown': {'value': 0}, 'ipv4': {'value': 1}, 'ipv6': {'value': 2}},), is_leaf=True, yang_name="ip-version", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-version', is_config=True) - self.__destination_ip_flow_label = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={'range': ['0..1048575']}), is_leaf=True, yang_name="destination-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=True) - self.__source_ip_flow_label = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={'range': ['0..1048575']}), is_leaf=True, yang_name="source-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=True) + self.__hop_limit = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="hop-limit", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint8', is_config=True) + self.__protocol = YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..254']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:IP_TCP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_L2TP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_L2TP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_AUTH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_RSVP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_GRE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_TCP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_AUTH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_UDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_PIM': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_GRE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_IGMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_RSVP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_ICMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_PIM': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_UDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_IGMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_ICMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="protocol", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ip-protocol-type', is_config=True) + self.__dscp = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..63']}), is_leaf=True, yang_name="dscp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:dscp', is_config=True) + self.__source_ip_address = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="source-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=True) + self.__destination_ip_address = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="destination-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=True) + self.__ip_version = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'unknown': {u'value': 0}, u'ipv4': {u'value': 1}, u'ipv6': {u'value': 2}},), is_leaf=True, yang_name="ip-version", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-version', is_config=True) + self.__destination_ip_flow_label = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={u'range': [u'0..1048575']}), is_leaf=True, yang_name="destination-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=True) + self.__source_ip_flow_label = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={u'range': [u'0..1048575']}), is_leaf=True, yang_name="source-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=True) load = kwargs.pop("load", None) if args: @@ -1426,7 +1525,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'ip', 'config'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'ip', u'config'] def _get_ip_version(self): """ @@ -1449,12 +1548,12 @@ def _set_ip_version(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'unknown': {'value': 0}, 'ipv4': {'value': 1}, 'ipv6': {'value': 2}},), is_leaf=True, yang_name="ip-version", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-version', is_config=True) + t = YANGDynClass(v,base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'unknown': {u'value': 0}, u'ipv4': {u'value': 1}, u'ipv6': {u'value': 2}},), is_leaf=True, yang_name="ip-version", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-version', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """ip_version must be of a type compatible with inet:ip-version""", 'defined-type': "inet:ip-version", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'unknown': {'value': 0}, u'ipv4': {'value': 1}, u'ipv6': {'value': 2}},), is_leaf=True, yang_name="ip-version", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-version', is_config=True)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'unknown': {u'value': 0}, u'ipv4': {u'value': 1}, u'ipv6': {u'value': 2}},), is_leaf=True, yang_name="ip-version", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-version', is_config=True)""", }) self.__ip_version = t @@ -1462,7 +1561,7 @@ def _set_ip_version(self, v, load=False): self._set() def _unset_ip_version(self): - self.__ip_version = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'unknown': {'value': 0}, 'ipv4': {'value': 1}, 'ipv6': {'value': 2}},), is_leaf=True, yang_name="ip-version", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-version', is_config=True) + self.__ip_version = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'unknown': {u'value': 0}, u'ipv4': {u'value': 1}, u'ipv6': {u'value': 2}},), is_leaf=True, yang_name="ip-version", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-version', is_config=True) def _get_source_ip_address(self): @@ -1486,12 +1585,12 @@ def _set_source_ip_address(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=str, restriction_dict={'pattern': '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="source-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=True) + t = YANGDynClass(v,base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="source-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """source_ip_address must be of a type compatible with inet:ip-prefix""", 'defined-type': "inet:ip-prefix", - 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="source-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=True)""", + 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="source-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=True)""", }) self.__source_ip_address = t @@ -1499,7 +1598,7 @@ def _set_source_ip_address(self, v, load=False): self._set() def _unset_source_ip_address(self): - self.__source_ip_address = YANGDynClass(base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=str, restriction_dict={'pattern': '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="source-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=True) + self.__source_ip_address = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="source-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=True) def _get_source_ip_flow_label(self): @@ -1523,12 +1622,12 @@ def _set_source_ip_flow_label(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={'range': ['0..1048575']}), is_leaf=True, yang_name="source-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=True) + t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={u'range': [u'0..1048575']}), is_leaf=True, yang_name="source-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """source_ip_flow_label must be of a type compatible with inet:ipv6-flow-label""", 'defined-type': "inet:ipv6-flow-label", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={'range': [u'0..1048575']}), is_leaf=True, yang_name="source-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=True)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={u'range': [u'0..1048575']}), is_leaf=True, yang_name="source-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=True)""", }) self.__source_ip_flow_label = t @@ -1536,7 +1635,7 @@ def _set_source_ip_flow_label(self, v, load=False): self._set() def _unset_source_ip_flow_label(self): - self.__source_ip_flow_label = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={'range': ['0..1048575']}), is_leaf=True, yang_name="source-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=True) + self.__source_ip_flow_label = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={u'range': [u'0..1048575']}), is_leaf=True, yang_name="source-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=True) def _get_destination_ip_address(self): @@ -1560,12 +1659,12 @@ def _set_destination_ip_address(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=str, restriction_dict={'pattern': '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="destination-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=True) + t = YANGDynClass(v,base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="destination-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """destination_ip_address must be of a type compatible with inet:ip-prefix""", 'defined-type': "inet:ip-prefix", - 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="destination-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=True)""", + 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="destination-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=True)""", }) self.__destination_ip_address = t @@ -1573,7 +1672,7 @@ def _set_destination_ip_address(self, v, load=False): self._set() def _unset_destination_ip_address(self): - self.__destination_ip_address = YANGDynClass(base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=str, restriction_dict={'pattern': '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="destination-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=True) + self.__destination_ip_address = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="destination-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=True) def _get_destination_ip_flow_label(self): @@ -1597,12 +1696,12 @@ def _set_destination_ip_flow_label(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={'range': ['0..1048575']}), is_leaf=True, yang_name="destination-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=True) + t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={u'range': [u'0..1048575']}), is_leaf=True, yang_name="destination-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """destination_ip_flow_label must be of a type compatible with inet:ipv6-flow-label""", 'defined-type': "inet:ipv6-flow-label", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={'range': [u'0..1048575']}), is_leaf=True, yang_name="destination-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=True)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={u'range': [u'0..1048575']}), is_leaf=True, yang_name="destination-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=True)""", }) self.__destination_ip_flow_label = t @@ -1610,7 +1709,7 @@ def _set_destination_ip_flow_label(self, v, load=False): self._set() def _unset_destination_ip_flow_label(self): - self.__destination_ip_flow_label = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={'range': ['0..1048575']}), is_leaf=True, yang_name="destination-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=True) + self.__destination_ip_flow_label = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={u'range': [u'0..1048575']}), is_leaf=True, yang_name="destination-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=True) def _get_dscp(self): @@ -1634,12 +1733,12 @@ def _set_dscp(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..63']}), is_leaf=True, yang_name="dscp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:dscp', is_config=True) + t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..63']}), is_leaf=True, yang_name="dscp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:dscp', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """dscp must be of a type compatible with inet:dscp""", 'defined-type': "inet:dscp", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': [u'0..63']}), is_leaf=True, yang_name="dscp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:dscp', is_config=True)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..63']}), is_leaf=True, yang_name="dscp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:dscp', is_config=True)""", }) self.__dscp = t @@ -1647,7 +1746,7 @@ def _set_dscp(self, v, load=False): self._set() def _unset_dscp(self): - self.__dscp = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..63']}), is_leaf=True, yang_name="dscp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:dscp', is_config=True) + self.__dscp = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..63']}), is_leaf=True, yang_name="dscp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:dscp', is_config=True) def _get_protocol(self): @@ -1671,12 +1770,12 @@ def _set_protocol(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..254']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'oc-pkt-match-types:IP_TCP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_L2TP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_L2TP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_AUTH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_RSVP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_GRE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_TCP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_AUTH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_UDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_PIM': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_GRE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_IGMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_RSVP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_ICMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_PIM': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_UDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_IGMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_ICMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="protocol", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ip-protocol-type', is_config=True) + t = YANGDynClass(v,base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..254']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:IP_TCP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_L2TP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_L2TP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_AUTH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_RSVP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_GRE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_TCP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_AUTH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_UDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_PIM': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_GRE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_IGMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_RSVP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_ICMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_PIM': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_UDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_IGMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_ICMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="protocol", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ip-protocol-type', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """protocol must be of a type compatible with oc-pkt-match-types:ip-protocol-type""", 'defined-type': "oc-pkt-match-types:ip-protocol-type", - 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': [u'0..254']}),RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:IP_TCP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_L2TP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_L2TP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_AUTH': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_RSVP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_GRE': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_TCP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_AUTH': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_UDP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_PIM': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_GRE': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_IGMP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_RSVP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_ICMP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_PIM': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_UDP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_IGMP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_ICMP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="protocol", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ip-protocol-type', is_config=True)""", + 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..254']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:IP_TCP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_L2TP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_L2TP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_AUTH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_RSVP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_GRE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_TCP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_AUTH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_UDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_PIM': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_GRE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_IGMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_RSVP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_ICMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_PIM': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_UDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_IGMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_ICMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="protocol", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ip-protocol-type', is_config=True)""", }) self.__protocol = t @@ -1684,7 +1783,7 @@ def _set_protocol(self, v, load=False): self._set() def _unset_protocol(self): - self.__protocol = YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..254']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'oc-pkt-match-types:IP_TCP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_L2TP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_L2TP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_AUTH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_RSVP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_GRE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_TCP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_AUTH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_UDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_PIM': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_GRE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_IGMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_RSVP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_ICMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_PIM': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_UDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_IGMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_ICMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="protocol", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ip-protocol-type', is_config=True) + self.__protocol = YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..254']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:IP_TCP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_L2TP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_L2TP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_AUTH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_RSVP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_GRE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_TCP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_AUTH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_UDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_PIM': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_GRE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_IGMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_RSVP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_ICMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_PIM': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_UDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_IGMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_ICMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="protocol", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ip-protocol-type', is_config=True) def _get_hop_limit(self): @@ -1710,12 +1809,12 @@ def _set_hop_limit(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..255']}), is_leaf=True, yang_name="hop-limit", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint8', is_config=True) + t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="hop-limit", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint8', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """hop_limit must be of a type compatible with uint8""", 'defined-type': "uint8", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': [u'0..255']}), is_leaf=True, yang_name="hop-limit", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint8', is_config=True)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="hop-limit", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint8', is_config=True)""", }) self.__hop_limit = t @@ -1723,19 +1822,19 @@ def _set_hop_limit(self, v, load=False): self._set() def _unset_hop_limit(self): - self.__hop_limit = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..255']}), is_leaf=True, yang_name="hop-limit", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint8', is_config=True) + self.__hop_limit = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="hop-limit", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint8', is_config=True) - ip_version = builtins.property(_get_ip_version, _set_ip_version) - source_ip_address = builtins.property(_get_source_ip_address, _set_source_ip_address) - source_ip_flow_label = builtins.property(_get_source_ip_flow_label, _set_source_ip_flow_label) - destination_ip_address = builtins.property(_get_destination_ip_address, _set_destination_ip_address) - destination_ip_flow_label = builtins.property(_get_destination_ip_flow_label, _set_destination_ip_flow_label) - dscp = builtins.property(_get_dscp, _set_dscp) - protocol = builtins.property(_get_protocol, _set_protocol) - hop_limit = builtins.property(_get_hop_limit, _set_hop_limit) + ip_version = __builtin__.property(_get_ip_version, _set_ip_version) + source_ip_address = __builtin__.property(_get_source_ip_address, _set_source_ip_address) + source_ip_flow_label = __builtin__.property(_get_source_ip_flow_label, _set_source_ip_flow_label) + destination_ip_address = __builtin__.property(_get_destination_ip_address, _set_destination_ip_address) + destination_ip_flow_label = __builtin__.property(_get_destination_ip_flow_label, _set_destination_ip_flow_label) + dscp = __builtin__.property(_get_dscp, _set_dscp) + protocol = __builtin__.property(_get_protocol, _set_protocol) + hop_limit = __builtin__.property(_get_hop_limit, _set_hop_limit) - _pyangbind_elements = {'ip_version': ip_version, 'source_ip_address': source_ip_address, 'source_ip_flow_label': source_ip_flow_label, 'destination_ip_address': destination_ip_address, 'destination_ip_flow_label': destination_ip_flow_label, 'dscp': dscp, 'protocol': protocol, 'hop_limit': hop_limit, } + _pyangbind_elements = OrderedDict([('ip_version', ip_version), ('source_ip_address', source_ip_address), ('source_ip_flow_label', source_ip_flow_label), ('destination_ip_address', destination_ip_address), ('destination_ip_flow_label', destination_ip_flow_label), ('dscp', dscp), ('protocol', protocol), ('hop_limit', hop_limit), ]) class yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_ip_state(PybindBase): @@ -1747,21 +1846,25 @@ class yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_ip_sta YANG Description: State information """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__ip_version','__source_ip_address','__source_ip_flow_label','__destination_ip_address','__destination_ip_flow_label','__dscp','__protocol','__hop_limit',) + __slots__ = ('_path_helper', '_extmethods', '__ip_version','__source_ip_address','__source_ip_flow_label','__destination_ip_address','__destination_ip_flow_label','__dscp','__protocol','__hop_limit',) + + _yang_name = 'state' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'state' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__hop_limit = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..255']}), is_leaf=True, yang_name="hop-limit", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint8', is_config=False) - self.__protocol = YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..254']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'oc-pkt-match-types:IP_TCP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_L2TP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_L2TP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_AUTH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_RSVP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_GRE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_TCP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_AUTH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_UDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_PIM': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_GRE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_IGMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_RSVP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_ICMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_PIM': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_UDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_IGMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_ICMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="protocol", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ip-protocol-type', is_config=False) - self.__dscp = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..63']}), is_leaf=True, yang_name="dscp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:dscp', is_config=False) - self.__source_ip_address = YANGDynClass(base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=str, restriction_dict={'pattern': '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="source-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=False) - self.__destination_ip_address = YANGDynClass(base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=str, restriction_dict={'pattern': '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="destination-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=False) - self.__ip_version = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'unknown': {'value': 0}, 'ipv4': {'value': 1}, 'ipv6': {'value': 2}},), is_leaf=True, yang_name="ip-version", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-version', is_config=False) - self.__destination_ip_flow_label = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={'range': ['0..1048575']}), is_leaf=True, yang_name="destination-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=False) - self.__source_ip_flow_label = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={'range': ['0..1048575']}), is_leaf=True, yang_name="source-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=False) + self.__hop_limit = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="hop-limit", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint8', is_config=False) + self.__protocol = YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..254']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:IP_TCP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_L2TP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_L2TP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_AUTH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_RSVP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_GRE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_TCP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_AUTH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_UDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_PIM': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_GRE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_IGMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_RSVP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_ICMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_PIM': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_UDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_IGMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_ICMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="protocol", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ip-protocol-type', is_config=False) + self.__dscp = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..63']}), is_leaf=True, yang_name="dscp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:dscp', is_config=False) + self.__source_ip_address = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="source-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=False) + self.__destination_ip_address = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="destination-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=False) + self.__ip_version = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'unknown': {u'value': 0}, u'ipv4': {u'value': 1}, u'ipv6': {u'value': 2}},), is_leaf=True, yang_name="ip-version", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-version', is_config=False) + self.__destination_ip_flow_label = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={u'range': [u'0..1048575']}), is_leaf=True, yang_name="destination-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=False) + self.__source_ip_flow_label = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={u'range': [u'0..1048575']}), is_leaf=True, yang_name="source-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=False) load = kwargs.pop("load", None) if args: @@ -1788,7 +1891,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'ip', 'state'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'ip', u'state'] def _get_ip_version(self): """ @@ -1811,12 +1914,12 @@ def _set_ip_version(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'unknown': {'value': 0}, 'ipv4': {'value': 1}, 'ipv6': {'value': 2}},), is_leaf=True, yang_name="ip-version", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-version', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'unknown': {u'value': 0}, u'ipv4': {u'value': 1}, u'ipv6': {u'value': 2}},), is_leaf=True, yang_name="ip-version", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-version', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """ip_version must be of a type compatible with inet:ip-version""", 'defined-type': "inet:ip-version", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'unknown': {'value': 0}, u'ipv4': {'value': 1}, u'ipv6': {'value': 2}},), is_leaf=True, yang_name="ip-version", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-version', is_config=False)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'unknown': {u'value': 0}, u'ipv4': {u'value': 1}, u'ipv6': {u'value': 2}},), is_leaf=True, yang_name="ip-version", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-version', is_config=False)""", }) self.__ip_version = t @@ -1824,7 +1927,7 @@ def _set_ip_version(self, v, load=False): self._set() def _unset_ip_version(self): - self.__ip_version = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'unknown': {'value': 0}, 'ipv4': {'value': 1}, 'ipv6': {'value': 2}},), is_leaf=True, yang_name="ip-version", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-version', is_config=False) + self.__ip_version = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'unknown': {u'value': 0}, u'ipv4': {u'value': 1}, u'ipv6': {u'value': 2}},), is_leaf=True, yang_name="ip-version", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-version', is_config=False) def _get_source_ip_address(self): @@ -1848,12 +1951,12 @@ def _set_source_ip_address(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=str, restriction_dict={'pattern': '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="source-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=False) + t = YANGDynClass(v,base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="source-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """source_ip_address must be of a type compatible with inet:ip-prefix""", 'defined-type': "inet:ip-prefix", - 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="source-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=False)""", + 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="source-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=False)""", }) self.__source_ip_address = t @@ -1861,7 +1964,7 @@ def _set_source_ip_address(self, v, load=False): self._set() def _unset_source_ip_address(self): - self.__source_ip_address = YANGDynClass(base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=str, restriction_dict={'pattern': '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="source-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=False) + self.__source_ip_address = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="source-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=False) def _get_source_ip_flow_label(self): @@ -1885,12 +1988,12 @@ def _set_source_ip_flow_label(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={'range': ['0..1048575']}), is_leaf=True, yang_name="source-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={u'range': [u'0..1048575']}), is_leaf=True, yang_name="source-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """source_ip_flow_label must be of a type compatible with inet:ipv6-flow-label""", 'defined-type': "inet:ipv6-flow-label", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={'range': [u'0..1048575']}), is_leaf=True, yang_name="source-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=False)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={u'range': [u'0..1048575']}), is_leaf=True, yang_name="source-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=False)""", }) self.__source_ip_flow_label = t @@ -1898,7 +2001,7 @@ def _set_source_ip_flow_label(self, v, load=False): self._set() def _unset_source_ip_flow_label(self): - self.__source_ip_flow_label = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={'range': ['0..1048575']}), is_leaf=True, yang_name="source-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=False) + self.__source_ip_flow_label = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={u'range': [u'0..1048575']}), is_leaf=True, yang_name="source-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=False) def _get_destination_ip_address(self): @@ -1922,12 +2025,12 @@ def _set_destination_ip_address(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=str, restriction_dict={'pattern': '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="destination-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=False) + t = YANGDynClass(v,base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="destination-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """destination_ip_address must be of a type compatible with inet:ip-prefix""", 'defined-type': "inet:ip-prefix", - 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="destination-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=False)""", + 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="destination-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=False)""", }) self.__destination_ip_address = t @@ -1935,7 +2038,7 @@ def _set_destination_ip_address(self, v, load=False): self._set() def _unset_destination_ip_address(self): - self.__destination_ip_address = YANGDynClass(base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=str, restriction_dict={'pattern': '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="destination-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=False) + self.__destination_ip_address = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))'}),RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))'}),], is_leaf=True, yang_name="destination-ip-address", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ip-prefix', is_config=False) def _get_destination_ip_flow_label(self): @@ -1959,12 +2062,12 @@ def _set_destination_ip_flow_label(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={'range': ['0..1048575']}), is_leaf=True, yang_name="destination-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={u'range': [u'0..1048575']}), is_leaf=True, yang_name="destination-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """destination_ip_flow_label must be of a type compatible with inet:ipv6-flow-label""", 'defined-type': "inet:ipv6-flow-label", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={'range': [u'0..1048575']}), is_leaf=True, yang_name="destination-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=False)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={u'range': [u'0..1048575']}), is_leaf=True, yang_name="destination-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=False)""", }) self.__destination_ip_flow_label = t @@ -1972,7 +2075,7 @@ def _set_destination_ip_flow_label(self, v, load=False): self._set() def _unset_destination_ip_flow_label(self): - self.__destination_ip_flow_label = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={'range': ['0..1048575']}), is_leaf=True, yang_name="destination-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=False) + self.__destination_ip_flow_label = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..4294967295']}, int_size=32), restriction_dict={u'range': [u'0..1048575']}), is_leaf=True, yang_name="destination-ip-flow-label", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:ipv6-flow-label', is_config=False) def _get_dscp(self): @@ -1996,12 +2099,12 @@ def _set_dscp(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..63']}), is_leaf=True, yang_name="dscp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:dscp', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..63']}), is_leaf=True, yang_name="dscp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:dscp', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """dscp must be of a type compatible with inet:dscp""", 'defined-type': "inet:dscp", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': [u'0..63']}), is_leaf=True, yang_name="dscp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:dscp', is_config=False)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..63']}), is_leaf=True, yang_name="dscp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:dscp', is_config=False)""", }) self.__dscp = t @@ -2009,7 +2112,7 @@ def _set_dscp(self, v, load=False): self._set() def _unset_dscp(self): - self.__dscp = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..63']}), is_leaf=True, yang_name="dscp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:dscp', is_config=False) + self.__dscp = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..63']}), is_leaf=True, yang_name="dscp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='inet:dscp', is_config=False) def _get_protocol(self): @@ -2033,12 +2136,12 @@ def _set_protocol(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..254']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'oc-pkt-match-types:IP_TCP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_L2TP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_L2TP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_AUTH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_RSVP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_GRE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_TCP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_AUTH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_UDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_PIM': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_GRE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_IGMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_RSVP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_ICMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_PIM': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_UDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_IGMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_ICMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="protocol", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ip-protocol-type', is_config=False) + t = YANGDynClass(v,base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..254']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:IP_TCP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_L2TP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_L2TP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_AUTH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_RSVP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_GRE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_TCP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_AUTH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_UDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_PIM': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_GRE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_IGMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_RSVP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_ICMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_PIM': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_UDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_IGMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_ICMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="protocol", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ip-protocol-type', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """protocol must be of a type compatible with oc-pkt-match-types:ip-protocol-type""", 'defined-type': "oc-pkt-match-types:ip-protocol-type", - 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': [u'0..254']}),RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:IP_TCP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_L2TP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_L2TP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_AUTH': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_RSVP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_GRE': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_TCP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_AUTH': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_UDP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_PIM': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_GRE': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_IGMP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_RSVP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_ICMP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_PIM': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_UDP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_IGMP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'IP_ICMP': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="protocol", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ip-protocol-type', is_config=False)""", + 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..254']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:IP_TCP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_L2TP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_L2TP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_AUTH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_RSVP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_GRE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_TCP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_AUTH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_UDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_PIM': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_GRE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_IGMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_RSVP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_ICMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_PIM': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_UDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_IGMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_ICMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="protocol", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ip-protocol-type', is_config=False)""", }) self.__protocol = t @@ -2046,7 +2149,7 @@ def _set_protocol(self, v, load=False): self._set() def _unset_protocol(self): - self.__protocol = YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..254']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'oc-pkt-match-types:IP_TCP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_L2TP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_L2TP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_AUTH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_RSVP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_GRE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_TCP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_AUTH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_UDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_PIM': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_GRE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_IGMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_RSVP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_ICMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_PIM': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_UDP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:IP_IGMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'IP_ICMP': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="protocol", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ip-protocol-type', is_config=False) + self.__protocol = YANGDynClass(base=[RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..254']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'oc-pkt-match-types:IP_TCP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_L2TP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_L2TP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_AUTH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_RSVP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_GRE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_TCP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_AUTH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_UDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_PIM': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_GRE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_IGMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_RSVP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_ICMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_PIM': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_UDP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:IP_IGMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'IP_ICMP': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},),], is_leaf=True, yang_name="protocol", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:ip-protocol-type', is_config=False) def _get_hop_limit(self): @@ -2072,12 +2175,12 @@ def _set_hop_limit(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..255']}), is_leaf=True, yang_name="hop-limit", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint8', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="hop-limit", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint8', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """hop_limit must be of a type compatible with uint8""", 'defined-type': "uint8", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': [u'0..255']}), is_leaf=True, yang_name="hop-limit", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint8', is_config=False)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="hop-limit", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint8', is_config=False)""", }) self.__hop_limit = t @@ -2085,19 +2188,19 @@ def _set_hop_limit(self, v, load=False): self._set() def _unset_hop_limit(self): - self.__hop_limit = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={'range': ['0..255']}), is_leaf=True, yang_name="hop-limit", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint8', is_config=False) + self.__hop_limit = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="hop-limit", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='uint8', is_config=False) - ip_version = builtins.property(_get_ip_version) - source_ip_address = builtins.property(_get_source_ip_address) - source_ip_flow_label = builtins.property(_get_source_ip_flow_label) - destination_ip_address = builtins.property(_get_destination_ip_address) - destination_ip_flow_label = builtins.property(_get_destination_ip_flow_label) - dscp = builtins.property(_get_dscp) - protocol = builtins.property(_get_protocol) - hop_limit = builtins.property(_get_hop_limit) + ip_version = __builtin__.property(_get_ip_version) + source_ip_address = __builtin__.property(_get_source_ip_address) + source_ip_flow_label = __builtin__.property(_get_source_ip_flow_label) + destination_ip_address = __builtin__.property(_get_destination_ip_address) + destination_ip_flow_label = __builtin__.property(_get_destination_ip_flow_label) + dscp = __builtin__.property(_get_dscp) + protocol = __builtin__.property(_get_protocol) + hop_limit = __builtin__.property(_get_hop_limit) - _pyangbind_elements = {'ip_version': ip_version, 'source_ip_address': source_ip_address, 'source_ip_flow_label': source_ip_flow_label, 'destination_ip_address': destination_ip_address, 'destination_ip_flow_label': destination_ip_flow_label, 'dscp': dscp, 'protocol': protocol, 'hop_limit': hop_limit, } + _pyangbind_elements = OrderedDict([('ip_version', ip_version), ('source_ip_address', source_ip_address), ('source_ip_flow_label', source_ip_flow_label), ('destination_ip_address', destination_ip_address), ('destination_ip_flow_label', destination_ip_flow_label), ('dscp', dscp), ('protocol', protocol), ('hop_limit', hop_limit), ]) class yc_ip_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_ip(PybindBase): @@ -2109,12 +2212,16 @@ class yc_ip_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_ip(Pybind YANG Description: Top level container """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__config','__state',) + __slots__ = ('_path_helper', '_extmethods', '__config','__state',) + + _yang_name = 'ip' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'ip' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_ip_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__config = YANGDynClass(base=yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_ip_config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) @@ -2144,7 +2251,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'ip'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'ip'] def _get_config(self): """ @@ -2219,11 +2326,11 @@ def _set_state(self, v, load=False): def _unset_state(self): self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_ip_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) - config = builtins.property(_get_config, _set_config) - state = builtins.property(_get_state, _set_state) + config = __builtin__.property(_get_config, _set_config) + state = __builtin__.property(_get_state, _set_state) - _pyangbind_elements = {'config': config, 'state': state, } + _pyangbind_elements = OrderedDict([('config', config), ('state', state), ]) class yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_transport_config(PybindBase): @@ -2235,16 +2342,20 @@ class yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_trans YANG Description: Configuration data """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__source_port','__destination_port','__tcp_flags',) + __slots__ = ('_path_helper', '_extmethods', '__source_port','__destination_port','__tcp_flags',) + + _yang_name = 'config' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'config' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__source_port = YANGDynClass(base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['0..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'ANY': {}},),], is_leaf=True, yang_name="source-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=True) - self.__tcp_flags = YANGDynClass(base=TypedListType(allowed_type=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'TCP_FIN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_ACK': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_URG': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_RST': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_SYN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_ECE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_ACK': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_SYN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_CWR': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_CWR': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_URG': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_RST': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_FIN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_ECE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_PSH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_PSH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},)), is_leaf=False, yang_name="tcp-flags", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) - self.__destination_port = YANGDynClass(base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['0..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'ANY': {}},),], is_leaf=True, yang_name="destination-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=True) + self.__source_port = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="source-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=True) + self.__tcp_flags = YANGDynClass(unique=True, base=TypedListType(allowed_type=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'TCP_FIN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_ACK': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_URG': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_RST': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_SYN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_ECE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ACK': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_SYN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_CWR': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_CWR': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_URG': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_RST': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_FIN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ECE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_PSH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_PSH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},)), is_leaf=False, yang_name="tcp-flags", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) + self.__destination_port = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="destination-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=True) load = kwargs.pop("load", None) if args: @@ -2271,7 +2382,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'transport', 'config'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'transport', u'config'] def _get_source_port(self): """ @@ -2294,12 +2405,12 @@ def _set_source_port(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['0..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'ANY': {}},),], is_leaf=True, yang_name="source-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=True) + t = YANGDynClass(v,base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="source-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """source_port must be of a type compatible with oc-pkt-match-types:port-num-range""", 'defined-type': "oc-pkt-match-types:port-num-range", - 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': [u'0..65535']}),RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="source-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=True)""", + 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="source-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=True)""", }) self.__source_port = t @@ -2307,7 +2418,7 @@ def _set_source_port(self, v, load=False): self._set() def _unset_source_port(self): - self.__source_port = YANGDynClass(base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['0..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'ANY': {}},),], is_leaf=True, yang_name="source-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=True) + self.__source_port = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="source-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=True) def _get_destination_port(self): @@ -2331,12 +2442,12 @@ def _set_destination_port(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['0..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'ANY': {}},),], is_leaf=True, yang_name="destination-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=True) + t = YANGDynClass(v,base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="destination-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """destination_port must be of a type compatible with oc-pkt-match-types:port-num-range""", 'defined-type': "oc-pkt-match-types:port-num-range", - 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': [u'0..65535']}),RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="destination-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=True)""", + 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="destination-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=True)""", }) self.__destination_port = t @@ -2344,7 +2455,7 @@ def _set_destination_port(self, v, load=False): self._set() def _unset_destination_port(self): - self.__destination_port = YANGDynClass(base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['0..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'ANY': {}},),], is_leaf=True, yang_name="destination-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=True) + self.__destination_port = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="destination-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=True) def _get_tcp_flags(self): @@ -2368,12 +2479,12 @@ def _set_tcp_flags(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=TypedListType(allowed_type=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'TCP_FIN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_ACK': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_URG': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_RST': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_SYN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_ECE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_ACK': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_SYN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_CWR': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_CWR': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_URG': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_RST': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_FIN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_ECE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_PSH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_PSH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},)), is_leaf=False, yang_name="tcp-flags", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) + t = YANGDynClass(v,unique=True, base=TypedListType(allowed_type=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'TCP_FIN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_ACK': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_URG': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_RST': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_SYN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_ECE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ACK': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_SYN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_CWR': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_CWR': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_URG': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_RST': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_FIN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ECE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_PSH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_PSH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},)), is_leaf=False, yang_name="tcp-flags", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """tcp_flags must be of a type compatible with identityref""", 'defined-type': "openconfig-acl:identityref", - 'generated-type': """YANGDynClass(base=TypedListType(allowed_type=RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'TCP_FIN': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'TCP_ACK': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'TCP_URG': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_RST': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_SYN': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'TCP_ECE': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ACK': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'TCP_SYN': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_CWR': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'TCP_CWR': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_URG': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'TCP_RST': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_FIN': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ECE': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'TCP_PSH': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_PSH': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}},)), is_leaf=False, yang_name="tcp-flags", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True)""", + 'generated-type': """YANGDynClass(unique=True, base=TypedListType(allowed_type=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'TCP_FIN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_ACK': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_URG': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_RST': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_SYN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_ECE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ACK': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_SYN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_CWR': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_CWR': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_URG': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_RST': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_FIN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ECE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_PSH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_PSH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},)), is_leaf=False, yang_name="tcp-flags", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True)""", }) self.__tcp_flags = t @@ -2381,14 +2492,14 @@ def _set_tcp_flags(self, v, load=False): self._set() def _unset_tcp_flags(self): - self.__tcp_flags = YANGDynClass(base=TypedListType(allowed_type=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'TCP_FIN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_ACK': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_URG': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_RST': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_SYN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_ECE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_ACK': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_SYN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_CWR': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_CWR': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_URG': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_RST': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_FIN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_ECE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_PSH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_PSH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},)), is_leaf=False, yang_name="tcp-flags", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) + self.__tcp_flags = YANGDynClass(unique=True, base=TypedListType(allowed_type=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'TCP_FIN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_ACK': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_URG': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_RST': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_SYN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_ECE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ACK': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_SYN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_CWR': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_CWR': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_URG': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_RST': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_FIN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ECE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_PSH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_PSH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},)), is_leaf=False, yang_name="tcp-flags", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) - source_port = builtins.property(_get_source_port, _set_source_port) - destination_port = builtins.property(_get_destination_port, _set_destination_port) - tcp_flags = builtins.property(_get_tcp_flags, _set_tcp_flags) + source_port = __builtin__.property(_get_source_port, _set_source_port) + destination_port = __builtin__.property(_get_destination_port, _set_destination_port) + tcp_flags = __builtin__.property(_get_tcp_flags, _set_tcp_flags) - _pyangbind_elements = {'source_port': source_port, 'destination_port': destination_port, 'tcp_flags': tcp_flags, } + _pyangbind_elements = OrderedDict([('source_port', source_port), ('destination_port', destination_port), ('tcp_flags', tcp_flags), ]) class yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_transport_state(PybindBase): @@ -2400,16 +2511,20 @@ class yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_transp YANG Description: State data """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__source_port','__destination_port','__tcp_flags',) + __slots__ = ('_path_helper', '_extmethods', '__source_port','__destination_port','__tcp_flags',) + + _yang_name = 'state' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'state' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__source_port = YANGDynClass(base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['0..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'ANY': {}},),], is_leaf=True, yang_name="source-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=False) - self.__tcp_flags = YANGDynClass(base=TypedListType(allowed_type=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'TCP_FIN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_ACK': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_URG': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_RST': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_SYN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_ECE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_ACK': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_SYN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_CWR': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_CWR': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_URG': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_RST': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_FIN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_ECE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_PSH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_PSH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},)), is_leaf=False, yang_name="tcp-flags", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) - self.__destination_port = YANGDynClass(base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['0..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'ANY': {}},),], is_leaf=True, yang_name="destination-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=False) + self.__source_port = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="source-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=False) + self.__tcp_flags = YANGDynClass(unique=True, base=TypedListType(allowed_type=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'TCP_FIN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_ACK': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_URG': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_RST': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_SYN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_ECE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ACK': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_SYN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_CWR': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_CWR': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_URG': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_RST': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_FIN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ECE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_PSH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_PSH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},)), is_leaf=False, yang_name="tcp-flags", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) + self.__destination_port = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="destination-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=False) load = kwargs.pop("load", None) if args: @@ -2436,7 +2551,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'transport', 'state'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'transport', u'state'] def _get_source_port(self): """ @@ -2459,12 +2574,12 @@ def _set_source_port(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['0..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'ANY': {}},),], is_leaf=True, yang_name="source-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=False) + t = YANGDynClass(v,base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="source-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """source_port must be of a type compatible with oc-pkt-match-types:port-num-range""", 'defined-type': "oc-pkt-match-types:port-num-range", - 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': [u'0..65535']}),RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="source-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=False)""", + 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="source-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=False)""", }) self.__source_port = t @@ -2472,7 +2587,7 @@ def _set_source_port(self, v, load=False): self._set() def _unset_source_port(self): - self.__source_port = YANGDynClass(base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['0..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'ANY': {}},),], is_leaf=True, yang_name="source-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=False) + self.__source_port = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="source-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=False) def _get_destination_port(self): @@ -2496,12 +2611,12 @@ def _set_destination_port(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['0..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'ANY': {}},),], is_leaf=True, yang_name="destination-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=False) + t = YANGDynClass(v,base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="destination-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """destination_port must be of a type compatible with oc-pkt-match-types:port-num-range""", 'defined-type': "oc-pkt-match-types:port-num-range", - 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=unicode, restriction_dict={'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': [u'0..65535']}),RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="destination-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=False)""", + 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="destination-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=False)""", }) self.__destination_port = t @@ -2509,7 +2624,7 @@ def _set_destination_port(self, v, load=False): self._set() def _unset_destination_port(self): - self.__destination_port = YANGDynClass(base=[RestrictedClassType(base_type=str, restriction_dict={'pattern': '^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={'range': ['0..65535']}),RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'ANY': {}},),], is_leaf=True, yang_name="destination-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=False) + self.__destination_port = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'^(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)\\.\\.(6[0-5][0-5][0-3][0-5]|[0-5]?[0-9]?[0-9]?[0-9]?[0-9]?)$'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..65535']}),RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'ANY': {}},),], is_leaf=True, yang_name="destination-port", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-pkt-match-types:port-num-range', is_config=False) def _get_tcp_flags(self): @@ -2533,12 +2648,12 @@ def _set_tcp_flags(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=TypedListType(allowed_type=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'TCP_FIN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_ACK': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_URG': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_RST': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_SYN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_ECE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_ACK': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_SYN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_CWR': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_CWR': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_URG': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_RST': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_FIN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_ECE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_PSH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_PSH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},)), is_leaf=False, yang_name="tcp-flags", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) + t = YANGDynClass(v,unique=True, base=TypedListType(allowed_type=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'TCP_FIN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_ACK': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_URG': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_RST': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_SYN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_ECE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ACK': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_SYN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_CWR': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_CWR': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_URG': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_RST': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_FIN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ECE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_PSH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_PSH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},)), is_leaf=False, yang_name="tcp-flags", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """tcp_flags must be of a type compatible with identityref""", 'defined-type': "openconfig-acl:identityref", - 'generated-type': """YANGDynClass(base=TypedListType(allowed_type=RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'TCP_FIN': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'TCP_ACK': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'TCP_URG': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_RST': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_SYN': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'TCP_ECE': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ACK': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'TCP_SYN': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_CWR': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'TCP_CWR': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_URG': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'TCP_RST': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_FIN': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ECE': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'TCP_PSH': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_PSH': {'@namespace': u'http://openconfig.net/yang/packet-match-types', '@module': u'openconfig-packet-match-types'}},)), is_leaf=False, yang_name="tcp-flags", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False)""", + 'generated-type': """YANGDynClass(unique=True, base=TypedListType(allowed_type=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'TCP_FIN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_ACK': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_URG': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_RST': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_SYN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_ECE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ACK': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_SYN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_CWR': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_CWR': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_URG': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_RST': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_FIN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ECE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_PSH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_PSH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},)), is_leaf=False, yang_name="tcp-flags", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False)""", }) self.__tcp_flags = t @@ -2546,14 +2661,14 @@ def _set_tcp_flags(self, v, load=False): self._set() def _unset_tcp_flags(self): - self.__tcp_flags = YANGDynClass(base=TypedListType(allowed_type=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'TCP_FIN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_ACK': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_URG': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_RST': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_SYN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_ECE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_ACK': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_SYN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_CWR': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_CWR': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_URG': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_RST': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_FIN': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_ECE': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'TCP_PSH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}, 'oc-pkt-match-types:TCP_PSH': {'@namespace': 'http://openconfig.net/yang/packet-match-types', '@module': 'openconfig-packet-match-types'}},)), is_leaf=False, yang_name="tcp-flags", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) + self.__tcp_flags = YANGDynClass(unique=True, base=TypedListType(allowed_type=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'TCP_FIN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_ACK': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_URG': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_RST': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_SYN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_ECE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ACK': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_SYN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_CWR': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_CWR': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_URG': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_RST': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_FIN': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_ECE': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'TCP_PSH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}, u'oc-pkt-match-types:TCP_PSH': {u'@namespace': u'http://openconfig.net/yang/packet-match-types', u'@module': u'openconfig-packet-match-types'}},)), is_leaf=False, yang_name="tcp-flags", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) - source_port = builtins.property(_get_source_port) - destination_port = builtins.property(_get_destination_port) - tcp_flags = builtins.property(_get_tcp_flags) + source_port = __builtin__.property(_get_source_port) + destination_port = __builtin__.property(_get_destination_port) + tcp_flags = __builtin__.property(_get_tcp_flags) - _pyangbind_elements = {'source_port': source_port, 'destination_port': destination_port, 'tcp_flags': tcp_flags, } + _pyangbind_elements = OrderedDict([('source_port', source_port), ('destination_port', destination_port), ('tcp_flags', tcp_flags), ]) class yc_transport_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_transport(PybindBase): @@ -2565,12 +2680,16 @@ class yc_transport_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_tr YANG Description: Transport fields container """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__config','__state',) + __slots__ = ('_path_helper', '_extmethods', '__config','__state',) + + _yang_name = 'transport' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'transport' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_transport_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__config = YANGDynClass(base=yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_transport_config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) @@ -2600,7 +2719,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'transport'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'transport'] def _get_config(self): """ @@ -2675,11 +2794,11 @@ def _set_state(self, v, load=False): def _unset_state(self): self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_transport_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) - config = builtins.property(_get_config, _set_config) - state = builtins.property(_get_state, _set_state) + config = __builtin__.property(_get_config, _set_config) + state = __builtin__.property(_get_state, _set_state) - _pyangbind_elements = {'config': config, 'state': state, } + _pyangbind_elements = OrderedDict([('config', config), ('state', state), ]) class yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_input_interface_interface_ref_config(PybindBase): @@ -2691,15 +2810,19 @@ class yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_input YANG Description: Configured reference to interface / subinterface """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__interface','__subinterface',) + __slots__ = ('_path_helper', '_extmethods', '__interface','__subinterface',) + + _yang_name = 'config' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'config' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__interface = YANGDynClass(base=str, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) - self.__subinterface = YANGDynClass(base=str, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__interface = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__subinterface = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) load = kwargs.pop("load", None) if args: @@ -2726,7 +2849,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'input-interface', 'interface-ref', 'config'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'input-interface', u'interface-ref', u'config'] def _get_interface(self): """ @@ -2753,12 +2876,12 @@ def _set_interface(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """interface must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", }) self.__interface = t @@ -2766,7 +2889,7 @@ def _set_interface(self, v, load=False): self._set() def _unset_interface(self): - self.__interface = YANGDynClass(base=str, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__interface = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) def _get_subinterface(self): @@ -2796,12 +2919,12 @@ def _set_subinterface(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """subinterface must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", }) self.__subinterface = t @@ -2809,13 +2932,13 @@ def _set_subinterface(self, v, load=False): self._set() def _unset_subinterface(self): - self.__subinterface = YANGDynClass(base=str, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__subinterface = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) - interface = builtins.property(_get_interface, _set_interface) - subinterface = builtins.property(_get_subinterface, _set_subinterface) + interface = __builtin__.property(_get_interface, _set_interface) + subinterface = __builtin__.property(_get_subinterface, _set_subinterface) - _pyangbind_elements = {'interface': interface, 'subinterface': subinterface, } + _pyangbind_elements = OrderedDict([('interface', interface), ('subinterface', subinterface), ]) class yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_input_interface_interface_ref_state(PybindBase): @@ -2827,15 +2950,19 @@ class yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_input_ YANG Description: Operational state for interface-ref """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__interface','__subinterface',) + __slots__ = ('_path_helper', '_extmethods', '__interface','__subinterface',) + + _yang_name = 'state' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'state' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__interface = YANGDynClass(base=str, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) - self.__subinterface = YANGDynClass(base=str, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__interface = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__subinterface = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) load = kwargs.pop("load", None) if args: @@ -2862,7 +2989,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'input-interface', 'interface-ref', 'state'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'input-interface', u'interface-ref', u'state'] def _get_interface(self): """ @@ -2889,12 +3016,12 @@ def _set_interface(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """interface must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", }) self.__interface = t @@ -2902,7 +3029,7 @@ def _set_interface(self, v, load=False): self._set() def _unset_interface(self): - self.__interface = YANGDynClass(base=str, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__interface = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) def _get_subinterface(self): @@ -2932,12 +3059,12 @@ def _set_subinterface(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """subinterface must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", }) self.__subinterface = t @@ -2945,13 +3072,13 @@ def _set_subinterface(self, v, load=False): self._set() def _unset_subinterface(self): - self.__subinterface = YANGDynClass(base=str, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__subinterface = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) - interface = builtins.property(_get_interface) - subinterface = builtins.property(_get_subinterface) + interface = __builtin__.property(_get_interface) + subinterface = __builtin__.property(_get_subinterface) - _pyangbind_elements = {'interface': interface, 'subinterface': subinterface, } + _pyangbind_elements = OrderedDict([('interface', interface), ('subinterface', subinterface), ]) class yc_interface_ref_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_input_interface_interface_ref(PybindBase): @@ -2963,12 +3090,16 @@ class yc_interface_ref_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entr YANG Description: Reference to an interface or subinterface """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__config','__state',) + __slots__ = ('_path_helper', '_extmethods', '__config','__state',) + + _yang_name = 'interface-ref' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'interface-ref' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_input_interface_interface_ref_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__config = YANGDynClass(base=yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_input_interface_interface_ref_config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) @@ -2998,7 +3129,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'input-interface', 'interface-ref'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'input-interface', u'interface-ref'] def _get_config(self): """ @@ -3073,11 +3204,11 @@ def _set_state(self, v, load=False): def _unset_state(self): self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_input_interface_interface_ref_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) - config = builtins.property(_get_config, _set_config) - state = builtins.property(_get_state, _set_state) + config = __builtin__.property(_get_config, _set_config) + state = __builtin__.property(_get_state, _set_state) - _pyangbind_elements = {'config': config, 'state': state, } + _pyangbind_elements = OrderedDict([('config', config), ('state', state), ]) class yc_input_interface_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_input_interface(PybindBase): @@ -3089,12 +3220,16 @@ class yc_input_interface_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_en YANG Description: Input interface container """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__interface_ref',) + __slots__ = ('_path_helper', '_extmethods', '__interface_ref',) + + _yang_name = 'input-interface' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'input-interface' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__interface_ref = YANGDynClass(base=yc_interface_ref_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_input_interface_interface_ref, is_container='container', yang_name="interface-ref", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) @@ -3123,7 +3258,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'input-interface'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'input-interface'] def _get_interface_ref(self): """ @@ -3161,10 +3296,10 @@ def _set_interface_ref(self, v, load=False): def _unset_interface_ref(self): self.__interface_ref = YANGDynClass(base=yc_interface_ref_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_input_interface_interface_ref, is_container='container', yang_name="interface-ref", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) - interface_ref = builtins.property(_get_interface_ref, _set_interface_ref) + interface_ref = __builtin__.property(_get_interface_ref, _set_interface_ref) - _pyangbind_elements = {'interface_ref': interface_ref, } + _pyangbind_elements = OrderedDict([('interface_ref', interface_ref), ]) class yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_actions_config(PybindBase): @@ -3176,15 +3311,19 @@ class yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_actio YANG Description: Config data for ACL actions """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__forwarding_action','__log_action',) + __slots__ = ('_path_helper', '_extmethods', '__forwarding_action','__log_action',) + + _yang_name = 'config' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'config' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__forwarding_action = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'DROP': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:REJECT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'ACCEPT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'REJECT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:ACCEPT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:DROP': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}},), is_leaf=True, yang_name="forwarding-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) - self.__log_action = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'LOG_SYSLOG': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:LOG_SYSLOG': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'LOG_NONE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:LOG_NONE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}},), default=str("LOG_NONE"), is_leaf=True, yang_name="log-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) + self.__forwarding_action = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'DROP': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:REJECT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'ACCEPT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'REJECT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:ACCEPT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:DROP': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), is_leaf=True, yang_name="forwarding-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) + self.__log_action = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'LOG_SYSLOG': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:LOG_SYSLOG': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'LOG_NONE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:LOG_NONE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), default=six.text_type("LOG_NONE"), is_leaf=True, yang_name="log-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) load = kwargs.pop("load", None) if args: @@ -3211,7 +3350,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'actions', 'config'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'actions', u'config'] def _get_forwarding_action(self): """ @@ -3236,12 +3375,12 @@ def _set_forwarding_action(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'DROP': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:REJECT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'ACCEPT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'REJECT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:ACCEPT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:DROP': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}},), is_leaf=True, yang_name="forwarding-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) + t = YANGDynClass(v,base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'DROP': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:REJECT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'ACCEPT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'REJECT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:ACCEPT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:DROP': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), is_leaf=True, yang_name="forwarding-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """forwarding_action must be of a type compatible with identityref""", 'defined-type': "openconfig-acl:identityref", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'DROP': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'oc-acl:REJECT': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'ACCEPT': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'REJECT': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'oc-acl:ACCEPT': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'oc-acl:DROP': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}},), is_leaf=True, yang_name="forwarding-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'DROP': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:REJECT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'ACCEPT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'REJECT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:ACCEPT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:DROP': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), is_leaf=True, yang_name="forwarding-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True)""", }) self.__forwarding_action = t @@ -3249,7 +3388,7 @@ def _set_forwarding_action(self, v, load=False): self._set() def _unset_forwarding_action(self): - self.__forwarding_action = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'DROP': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:REJECT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'ACCEPT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'REJECT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:ACCEPT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:DROP': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}},), is_leaf=True, yang_name="forwarding-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) + self.__forwarding_action = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'DROP': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:REJECT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'ACCEPT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'REJECT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:ACCEPT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:DROP': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), is_leaf=True, yang_name="forwarding-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) def _get_log_action(self): @@ -3277,12 +3416,12 @@ def _set_log_action(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'LOG_SYSLOG': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:LOG_SYSLOG': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'LOG_NONE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:LOG_NONE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}},), default=str("LOG_NONE"), is_leaf=True, yang_name="log-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) + t = YANGDynClass(v,base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'LOG_SYSLOG': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:LOG_SYSLOG': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'LOG_NONE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:LOG_NONE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), default=six.text_type("LOG_NONE"), is_leaf=True, yang_name="log-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """log_action must be of a type compatible with identityref""", 'defined-type': "openconfig-acl:identityref", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'LOG_SYSLOG': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'oc-acl:LOG_SYSLOG': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'LOG_NONE': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'oc-acl:LOG_NONE': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}},), default=unicode("LOG_NONE"), is_leaf=True, yang_name="log-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'LOG_SYSLOG': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:LOG_SYSLOG': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'LOG_NONE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:LOG_NONE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), default=six.text_type("LOG_NONE"), is_leaf=True, yang_name="log-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True)""", }) self.__log_action = t @@ -3290,13 +3429,13 @@ def _set_log_action(self, v, load=False): self._set() def _unset_log_action(self): - self.__log_action = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'LOG_SYSLOG': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:LOG_SYSLOG': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'LOG_NONE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:LOG_NONE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}},), default=str("LOG_NONE"), is_leaf=True, yang_name="log-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) + self.__log_action = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'LOG_SYSLOG': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:LOG_SYSLOG': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'LOG_NONE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:LOG_NONE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), default=six.text_type("LOG_NONE"), is_leaf=True, yang_name="log-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=True) - forwarding_action = builtins.property(_get_forwarding_action, _set_forwarding_action) - log_action = builtins.property(_get_log_action, _set_log_action) + forwarding_action = __builtin__.property(_get_forwarding_action, _set_forwarding_action) + log_action = __builtin__.property(_get_log_action, _set_log_action) - _pyangbind_elements = {'forwarding_action': forwarding_action, 'log_action': log_action, } + _pyangbind_elements = OrderedDict([('forwarding_action', forwarding_action), ('log_action', log_action), ]) class yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_actions_state(PybindBase): @@ -3308,15 +3447,19 @@ class yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_action YANG Description: State information for ACL actions """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__forwarding_action','__log_action',) + __slots__ = ('_path_helper', '_extmethods', '__forwarding_action','__log_action',) + + _yang_name = 'state' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'state' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__forwarding_action = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'DROP': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:REJECT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'ACCEPT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'REJECT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:ACCEPT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:DROP': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}},), is_leaf=True, yang_name="forwarding-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) - self.__log_action = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'LOG_SYSLOG': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:LOG_SYSLOG': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'LOG_NONE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:LOG_NONE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}},), default=str("LOG_NONE"), is_leaf=True, yang_name="log-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) + self.__forwarding_action = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'DROP': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:REJECT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'ACCEPT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'REJECT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:ACCEPT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:DROP': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), is_leaf=True, yang_name="forwarding-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) + self.__log_action = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'LOG_SYSLOG': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:LOG_SYSLOG': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'LOG_NONE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:LOG_NONE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), default=six.text_type("LOG_NONE"), is_leaf=True, yang_name="log-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) load = kwargs.pop("load", None) if args: @@ -3343,7 +3486,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'actions', 'state'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'actions', u'state'] def _get_forwarding_action(self): """ @@ -3368,12 +3511,12 @@ def _set_forwarding_action(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'DROP': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:REJECT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'ACCEPT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'REJECT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:ACCEPT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:DROP': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}},), is_leaf=True, yang_name="forwarding-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'DROP': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:REJECT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'ACCEPT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'REJECT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:ACCEPT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:DROP': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), is_leaf=True, yang_name="forwarding-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """forwarding_action must be of a type compatible with identityref""", 'defined-type': "openconfig-acl:identityref", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'DROP': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'oc-acl:REJECT': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'ACCEPT': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'REJECT': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'oc-acl:ACCEPT': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'oc-acl:DROP': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}},), is_leaf=True, yang_name="forwarding-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'DROP': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:REJECT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'ACCEPT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'REJECT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:ACCEPT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:DROP': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), is_leaf=True, yang_name="forwarding-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False)""", }) self.__forwarding_action = t @@ -3381,7 +3524,7 @@ def _set_forwarding_action(self, v, load=False): self._set() def _unset_forwarding_action(self): - self.__forwarding_action = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'DROP': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:REJECT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'ACCEPT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'REJECT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:ACCEPT': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:DROP': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}},), is_leaf=True, yang_name="forwarding-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) + self.__forwarding_action = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'DROP': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:REJECT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'ACCEPT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'REJECT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:ACCEPT': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:DROP': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), is_leaf=True, yang_name="forwarding-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) def _get_log_action(self): @@ -3409,12 +3552,12 @@ def _set_log_action(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'LOG_SYSLOG': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:LOG_SYSLOG': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'LOG_NONE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:LOG_NONE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}},), default=str("LOG_NONE"), is_leaf=True, yang_name="log-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'LOG_SYSLOG': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:LOG_SYSLOG': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'LOG_NONE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:LOG_NONE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), default=six.text_type("LOG_NONE"), is_leaf=True, yang_name="log-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """log_action must be of a type compatible with identityref""", 'defined-type': "openconfig-acl:identityref", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=unicode, restriction_type="dict_key", restriction_arg={u'LOG_SYSLOG': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'oc-acl:LOG_SYSLOG': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'LOG_NONE': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}, u'oc-acl:LOG_NONE': {'@namespace': u'http://openconfig.net/yang/acl', '@module': u'openconfig-acl'}},), default=unicode("LOG_NONE"), is_leaf=True, yang_name="log-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False)""", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'LOG_SYSLOG': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:LOG_SYSLOG': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'LOG_NONE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:LOG_NONE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), default=six.text_type("LOG_NONE"), is_leaf=True, yang_name="log-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False)""", }) self.__log_action = t @@ -3422,13 +3565,13 @@ def _set_log_action(self, v, load=False): self._set() def _unset_log_action(self): - self.__log_action = YANGDynClass(base=RestrictedClassType(base_type=str, restriction_type="dict_key", restriction_arg={'LOG_SYSLOG': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:LOG_SYSLOG': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'LOG_NONE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}, 'oc-acl:LOG_NONE': {'@namespace': 'http://openconfig.net/yang/acl', '@module': 'openconfig-acl'}},), default=str("LOG_NONE"), is_leaf=True, yang_name="log-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) + self.__log_action = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_type="dict_key", restriction_arg={u'LOG_SYSLOG': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:LOG_SYSLOG': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'LOG_NONE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}, u'oc-acl:LOG_NONE': {u'@namespace': u'http://openconfig.net/yang/acl', u'@module': u'openconfig-acl'}},), default=six.text_type("LOG_NONE"), is_leaf=True, yang_name="log-action", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='identityref', is_config=False) - forwarding_action = builtins.property(_get_forwarding_action) - log_action = builtins.property(_get_log_action) + forwarding_action = __builtin__.property(_get_forwarding_action) + log_action = __builtin__.property(_get_log_action) - _pyangbind_elements = {'forwarding_action': forwarding_action, 'log_action': log_action, } + _pyangbind_elements = OrderedDict([('forwarding_action', forwarding_action), ('log_action', log_action), ]) class yc_actions_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_actions(PybindBase): @@ -3441,12 +3584,16 @@ class yc_actions_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_acti YANG Description: Enclosing container for list of ACL actions associated with an entry """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__config','__state',) + __slots__ = ('_path_helper', '_extmethods', '__config','__state',) + + _yang_name = 'actions' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'actions' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_actions_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__config = YANGDynClass(base=yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_actions_config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) @@ -3476,7 +3623,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry', 'actions'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'actions'] def _get_config(self): """ @@ -3551,11 +3698,224 @@ def _set_state(self, v, load=False): def _unset_state(self): self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_actions_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) - config = builtins.property(_get_config, _set_config) - state = builtins.property(_get_state, _set_state) + config = __builtin__.property(_get_config, _set_config) + state = __builtin__.property(_get_state, _set_state) + + + _pyangbind_elements = OrderedDict([('config', config), ('state', state), ]) + + +class yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_icmp_config(PybindBase): + """ + This class was auto-generated by the PythonClass plugin for PYANG + from YANG module openconfig-acl - based on the path /acl/acl-sets/acl-set/acl-entries/acl-entry/icmp/config. Each member element of + the container is represented as a class variable - with a specific + YANG type. + """ + __slots__ = ('_path_helper', '_extmethods', '__type','__code',) + + _yang_name = 'config' + + _pybind_generated_by = 'container' + + def __init__(self, *args, **kwargs): + + self._path_helper = False + + self._extmethods = False + self.__code = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="code", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-code-type', is_config=True) + self.__type = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-type-type', is_config=True) + + load = kwargs.pop("load", None) + if args: + if len(args) > 1: + raise TypeError("cannot create a YANG container with >1 argument") + all_attr = True + for e in self._pyangbind_elements: + if not hasattr(args[0], e): + all_attr = False + break + if not all_attr: + raise ValueError("Supplied object did not have the correct attributes") + for e in self._pyangbind_elements: + nobj = getattr(args[0], e) + if nobj._changed() is False: + continue + setmethod = getattr(self, "_set_%s" % e) + if load is None: + setmethod(getattr(args[0], e)) + else: + setmethod(getattr(args[0], e), load=load) + + def _path(self): + if hasattr(self, "_parent"): + return self._parent._path()+[self._yang_name] + else: + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'icmp', u'config'] + + def _get_type(self): + """ + Getter method for type, mapped from YANG variable /acl/acl_sets/acl_set/acl_entries/acl_entry/icmp/config/type (icmp-type-type) + + YANG Description: ICMP(V6) type. + """ + return self.__type + + def _set_type(self, v, load=False): + """ + Setter method for type, mapped from YANG variable /acl/acl_sets/acl_set/acl_entries/acl_entry/icmp/config/type (icmp-type-type) + If this variable is read-only (config: false) in the + source YANG file, then _set_type is considered as a private + method. Backends looking to populate this variable should + do so via calling thisObj._set_type() directly. + + YANG Description: ICMP(V6) type. + """ + if hasattr(v, "_utype"): + v = v._utype(v) + try: + t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-type-type', is_config=True) + except (TypeError, ValueError): + raise ValueError({ + 'error-string': """type must be of a type compatible with icmp-type-type""", + 'defined-type': "sonic-acl-extension:icmp-type-type", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-type-type', is_config=True)""", + }) + + self.__type = t + if hasattr(self, '_set'): + self._set() + + def _unset_type(self): + self.__type = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-type-type', is_config=True) + + + def _get_code(self): + """ + Getter method for code, mapped from YANG variable /acl/acl_sets/acl_set/acl_entries/acl_entry/icmp/config/code (icmp-code-type) + + YANG Description: ICMP(V6) code. + """ + return self.__code + + def _set_code(self, v, load=False): + """ + Setter method for code, mapped from YANG variable /acl/acl_sets/acl_set/acl_entries/acl_entry/icmp/config/code (icmp-code-type) + If this variable is read-only (config: false) in the + source YANG file, then _set_code is considered as a private + method. Backends looking to populate this variable should + do so via calling thisObj._set_code() directly. + + YANG Description: ICMP(V6) code. + """ + if hasattr(v, "_utype"): + v = v._utype(v) + try: + t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="code", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-code-type', is_config=True) + except (TypeError, ValueError): + raise ValueError({ + 'error-string': """code must be of a type compatible with icmp-code-type""", + 'defined-type': "sonic-acl-extension:icmp-code-type", + 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="code", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-code-type', is_config=True)""", + }) + + self.__code = t + if hasattr(self, '_set'): + self._set() + + def _unset_code(self): + self.__code = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="code", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-code-type', is_config=True) + + type = __builtin__.property(_get_type, _set_type) + code = __builtin__.property(_get_code, _set_code) + + + _pyangbind_elements = OrderedDict([('type', type), ('code', code), ]) - _pyangbind_elements = {'config': config, 'state': state, } +class yc_icmp_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_icmp(PybindBase): + """ + This class was auto-generated by the PythonClass plugin for PYANG + from YANG module openconfig-acl - based on the path /acl/acl-sets/acl-set/acl-entries/acl-entry/icmp. Each member element of + the container is represented as a class variable - with a specific + YANG type. + """ + __slots__ = ('_path_helper', '_extmethods', '__config',) + + _yang_name = 'icmp' + + _pybind_generated_by = 'container' + + def __init__(self, *args, **kwargs): + + self._path_helper = False + + self._extmethods = False + self.__config = YANGDynClass(base=yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_icmp_config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='container', is_config=True) + + load = kwargs.pop("load", None) + if args: + if len(args) > 1: + raise TypeError("cannot create a YANG container with >1 argument") + all_attr = True + for e in self._pyangbind_elements: + if not hasattr(args[0], e): + all_attr = False + break + if not all_attr: + raise ValueError("Supplied object did not have the correct attributes") + for e in self._pyangbind_elements: + nobj = getattr(args[0], e) + if nobj._changed() is False: + continue + setmethod = getattr(self, "_set_%s" % e) + if load is None: + setmethod(getattr(args[0], e)) + else: + setmethod(getattr(args[0], e), load=load) + + def _path(self): + if hasattr(self, "_parent"): + return self._parent._path()+[self._yang_name] + else: + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry', u'icmp'] + + def _get_config(self): + """ + Getter method for config, mapped from YANG variable /acl/acl_sets/acl_set/acl_entries/acl_entry/icmp/config (container) + """ + return self.__config + + def _set_config(self, v, load=False): + """ + Setter method for config, mapped from YANG variable /acl/acl_sets/acl_set/acl_entries/acl_entry/icmp/config (container) + If this variable is read-only (config: false) in the + source YANG file, then _set_config is considered as a private + method. Backends looking to populate this variable should + do so via calling thisObj._set_config() directly. + """ + if hasattr(v, "_utype"): + v = v._utype(v) + try: + t = YANGDynClass(v,base=yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_icmp_config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='container', is_config=True) + except (TypeError, ValueError): + raise ValueError({ + 'error-string': """config must be of a type compatible with container""", + 'defined-type': "container", + 'generated-type': """YANGDynClass(base=yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_icmp_config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='container', is_config=True)""", + }) + + self.__config = t + if hasattr(self, '_set'): + self._set() + + def _unset_config(self): + self.__config = YANGDynClass(base=yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_icmp_config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='container', is_config=True) + + config = __builtin__.property(_get_config, _set_config) + + + _pyangbind_elements = OrderedDict([('config', config), ]) class yc_acl_entry_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry(PybindBase): @@ -3567,19 +3927,24 @@ class yc_acl_entry_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry(Py YANG Description: List of ACL entries comprising an ACL set """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__sequence_id','__config','__state','__l2','__ip','__transport','__input_interface','__actions',) + __slots__ = ('_path_helper', '_extmethods', '__sequence_id','__config','__state','__l2','__ip','__transport','__input_interface','__actions','__icmp',) + + _yang_name = 'acl-entry' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'acl-entry' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__ip = YANGDynClass(base=yc_ip_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_ip, is_container='container', yang_name="ip", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__input_interface = YANGDynClass(base=yc_input_interface_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_input_interface, is_container='container', yang_name="input-interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__actions = YANGDynClass(base=yc_actions_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_actions, is_container='container', yang_name="actions", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) - self.__sequence_id = YANGDynClass(base=str, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__sequence_id = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) self.__l2 = YANGDynClass(base=yc_l2_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_l2, is_container='container', yang_name="l2", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) + self.__icmp = YANGDynClass(base=yc_icmp_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_icmp, is_container='container', yang_name="icmp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='container', is_config=True) self.__config = YANGDynClass(base=yc_config_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__transport = YANGDynClass(base=yc_transport_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_transport, is_container='container', yang_name="transport", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) @@ -3608,7 +3973,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries', 'acl-entry'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries', u'acl-entry'] def _get_sequence_id(self): """ @@ -3636,12 +4001,12 @@ def _set_sequence_id(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """sequence_id must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", }) self.__sequence_id = t @@ -3649,7 +4014,7 @@ def _set_sequence_id(self, v, load=False): self._set() def _unset_sequence_id(self): - self.__sequence_id = YANGDynClass(base=str, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__sequence_id = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) def _get_config(self): @@ -3912,17 +4277,51 @@ def _set_actions(self, v, load=False): def _unset_actions(self): self.__actions = YANGDynClass(base=yc_actions_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_actions, is_container='container', yang_name="actions", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) - sequence_id = builtins.property(_get_sequence_id, _set_sequence_id) - config = builtins.property(_get_config, _set_config) - state = builtins.property(_get_state, _set_state) - l2 = builtins.property(_get_l2, _set_l2) - ip = builtins.property(_get_ip, _set_ip) - transport = builtins.property(_get_transport, _set_transport) - input_interface = builtins.property(_get_input_interface, _set_input_interface) - actions = builtins.property(_get_actions, _set_actions) + + def _get_icmp(self): + """ + Getter method for icmp, mapped from YANG variable /acl/acl_sets/acl_set/acl_entries/acl_entry/icmp (container) + """ + return self.__icmp + + def _set_icmp(self, v, load=False): + """ + Setter method for icmp, mapped from YANG variable /acl/acl_sets/acl_set/acl_entries/acl_entry/icmp (container) + If this variable is read-only (config: false) in the + source YANG file, then _set_icmp is considered as a private + method. Backends looking to populate this variable should + do so via calling thisObj._set_icmp() directly. + """ + if hasattr(v, "_utype"): + v = v._utype(v) + try: + t = YANGDynClass(v,base=yc_icmp_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_icmp, is_container='container', yang_name="icmp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='container', is_config=True) + except (TypeError, ValueError): + raise ValueError({ + 'error-string': """icmp must be of a type compatible with container""", + 'defined-type': "container", + 'generated-type': """YANGDynClass(base=yc_icmp_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_icmp, is_container='container', yang_name="icmp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='container', is_config=True)""", + }) + + self.__icmp = t + if hasattr(self, '_set'): + self._set() + + def _unset_icmp(self): + self.__icmp = YANGDynClass(base=yc_icmp_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry_icmp, is_container='container', yang_name="icmp", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='container', is_config=True) + + sequence_id = __builtin__.property(_get_sequence_id, _set_sequence_id) + config = __builtin__.property(_get_config, _set_config) + state = __builtin__.property(_get_state, _set_state) + l2 = __builtin__.property(_get_l2, _set_l2) + ip = __builtin__.property(_get_ip, _set_ip) + transport = __builtin__.property(_get_transport, _set_transport) + input_interface = __builtin__.property(_get_input_interface, _set_input_interface) + actions = __builtin__.property(_get_actions, _set_actions) + icmp = __builtin__.property(_get_icmp, _set_icmp) - _pyangbind_elements = {'sequence_id': sequence_id, 'config': config, 'state': state, 'l2': l2, 'ip': ip, 'transport': transport, 'input_interface': input_interface, 'actions': actions, } + _pyangbind_elements = OrderedDict([('sequence_id', sequence_id), ('config', config), ('state', state), ('l2', l2), ('ip', ip), ('transport', transport), ('input_interface', input_interface), ('actions', actions), ('icmp', icmp), ]) class yc_acl_entries_openconfig_acl__acl_acl_sets_acl_set_acl_entries(PybindBase): @@ -3934,12 +4333,16 @@ class yc_acl_entries_openconfig_acl__acl_acl_sets_acl_set_acl_entries(PybindBase YANG Description: Access list entries container """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__acl_entry',) + __slots__ = ('_path_helper', '_extmethods', '__acl_entry',) + + _yang_name = 'acl-entries' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'acl-entries' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__acl_entry = YANGDynClass(base=YANGListType("sequence_id",yc_acl_entry_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry, yang_name="acl-entry", parent=self, is_container='list', user_ordered=False, path_helper=self._path_helper, yang_keys='sequence-id', extensions=None), is_container='list', yang_name="acl-entry", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='list', is_config=True) @@ -3968,7 +4371,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set', 'acl-entries'] + return [u'acl', u'acl-sets', u'acl-set', u'acl-entries'] def _get_acl_entry(self): """ @@ -4006,10 +4409,10 @@ def _set_acl_entry(self, v, load=False): def _unset_acl_entry(self): self.__acl_entry = YANGDynClass(base=YANGListType("sequence_id",yc_acl_entry_openconfig_acl__acl_acl_sets_acl_set_acl_entries_acl_entry, yang_name="acl-entry", parent=self, is_container='list', user_ordered=False, path_helper=self._path_helper, yang_keys='sequence-id', extensions=None), is_container='list', yang_name="acl-entry", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='list', is_config=True) - acl_entry = builtins.property(_get_acl_entry, _set_acl_entry) + acl_entry = __builtin__.property(_get_acl_entry, _set_acl_entry) - _pyangbind_elements = {'acl_entry': acl_entry, } + _pyangbind_elements = OrderedDict([('acl_entry', acl_entry), ]) class yc_acl_set_openconfig_acl__acl_acl_sets_acl_set(PybindBase): @@ -4022,16 +4425,20 @@ class yc_acl_set_openconfig_acl__acl_acl_sets_acl_set(PybindBase): YANG Description: List of ACL sets, each comprising of a list of ACL entries """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__name','__config','__state','__acl_entries',) + __slots__ = ('_path_helper', '_extmethods', '__name','__config','__state','__acl_entries',) + + _yang_name = 'acl-set' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'acl-set' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_acl_sets_acl_set_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__config = YANGDynClass(base=yc_config_openconfig_acl__acl_acl_sets_acl_set_config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) - self.__name = YANGDynClass(base=str, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) self.__acl_entries = YANGDynClass(base=yc_acl_entries_openconfig_acl__acl_acl_sets_acl_set_acl_entries, is_container='container', yang_name="acl-entries", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) load = kwargs.pop("load", None) @@ -4059,7 +4466,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets', 'acl-set'] + return [u'acl', u'acl-sets', u'acl-set'] def _get_name(self): """ @@ -4087,12 +4494,12 @@ def _set_name(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """name must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", }) self.__name = t @@ -4100,7 +4507,7 @@ def _set_name(self, v, load=False): self._set() def _unset_name(self): - self.__name = YANGDynClass(base=str, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) def _get_config(self): @@ -4213,13 +4620,13 @@ def _set_acl_entries(self, v, load=False): def _unset_acl_entries(self): self.__acl_entries = YANGDynClass(base=yc_acl_entries_openconfig_acl__acl_acl_sets_acl_set_acl_entries, is_container='container', yang_name="acl-entries", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) - name = builtins.property(_get_name, _set_name) - config = builtins.property(_get_config, _set_config) - state = builtins.property(_get_state, _set_state) - acl_entries = builtins.property(_get_acl_entries, _set_acl_entries) + name = __builtin__.property(_get_name, _set_name) + config = __builtin__.property(_get_config, _set_config) + state = __builtin__.property(_get_state, _set_state) + acl_entries = __builtin__.property(_get_acl_entries, _set_acl_entries) - _pyangbind_elements = {'name': name, 'config': config, 'state': state, 'acl_entries': acl_entries, } + _pyangbind_elements = OrderedDict([('name', name), ('config', config), ('state', state), ('acl_entries', acl_entries), ]) class yc_acl_sets_openconfig_acl__acl_acl_sets(PybindBase): @@ -4231,12 +4638,16 @@ class yc_acl_sets_openconfig_acl__acl_acl_sets(PybindBase): YANG Description: Access list entries variables enclosing container """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__acl_set',) + __slots__ = ('_path_helper', '_extmethods', '__acl_set',) + + _yang_name = 'acl-sets' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'acl-sets' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__acl_set = YANGDynClass(base=YANGListType("name",yc_acl_set_openconfig_acl__acl_acl_sets_acl_set, yang_name="acl-set", parent=self, is_container='list', user_ordered=False, path_helper=self._path_helper, yang_keys='name', extensions=None), is_container='list', yang_name="acl-set", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='list', is_config=True) @@ -4265,7 +4676,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'acl-sets'] + return [u'acl', u'acl-sets'] def _get_acl_set(self): """ @@ -4305,10 +4716,10 @@ def _set_acl_set(self, v, load=False): def _unset_acl_set(self): self.__acl_set = YANGDynClass(base=YANGListType("name",yc_acl_set_openconfig_acl__acl_acl_sets_acl_set, yang_name="acl-set", parent=self, is_container='list', user_ordered=False, path_helper=self._path_helper, yang_keys='name', extensions=None), is_container='list', yang_name="acl-set", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='list', is_config=True) - acl_set = builtins.property(_get_acl_set, _set_acl_set) + acl_set = __builtin__.property(_get_acl_set, _set_acl_set) - _pyangbind_elements = {'acl_set': acl_set, } + _pyangbind_elements = OrderedDict([('acl_set', acl_set), ]) class yc_config_openconfig_acl__acl_interfaces_interface_config(PybindBase): @@ -4320,14 +4731,18 @@ class yc_config_openconfig_acl__acl_interfaces_interface_config(PybindBase): YANG Description: Configuration for ACL per-interface data """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__id',) + __slots__ = ('_path_helper', '_extmethods', '__id',) + + _yang_name = 'config' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'config' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__id = YANGDynClass(base=str, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-if:interface-id', is_config=True) + self.__id = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-if:interface-id', is_config=True) load = kwargs.pop("load", None) if args: @@ -4354,7 +4769,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'config'] + return [u'acl', u'interfaces', u'interface', u'config'] def _get_id(self): """ @@ -4379,12 +4794,12 @@ def _set_id(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-if:interface-id', is_config=True) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-if:interface-id', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """id must be of a type compatible with oc-if:interface-id""", 'defined-type': "oc-if:interface-id", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-if:interface-id', is_config=True)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-if:interface-id', is_config=True)""", }) self.__id = t @@ -4392,12 +4807,12 @@ def _set_id(self, v, load=False): self._set() def _unset_id(self): - self.__id = YANGDynClass(base=str, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-if:interface-id', is_config=True) + self.__id = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-if:interface-id', is_config=True) - id = builtins.property(_get_id, _set_id) + id = __builtin__.property(_get_id, _set_id) - _pyangbind_elements = {'id': id, } + _pyangbind_elements = OrderedDict([('id', id), ]) class yc_state_openconfig_acl__acl_interfaces_interface_state(PybindBase): @@ -4409,14 +4824,18 @@ class yc_state_openconfig_acl__acl_interfaces_interface_state(PybindBase): YANG Description: Operational state for ACL per-interface data """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__id',) + __slots__ = ('_path_helper', '_extmethods', '__id',) + + _yang_name = 'state' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'state' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__id = YANGDynClass(base=str, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-if:interface-id', is_config=False) + self.__id = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-if:interface-id', is_config=False) load = kwargs.pop("load", None) if args: @@ -4443,7 +4862,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'state'] + return [u'acl', u'interfaces', u'interface', u'state'] def _get_id(self): """ @@ -4468,12 +4887,12 @@ def _set_id(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-if:interface-id', is_config=False) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-if:interface-id', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """id must be of a type compatible with oc-if:interface-id""", 'defined-type': "oc-if:interface-id", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-if:interface-id', is_config=False)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-if:interface-id', is_config=False)""", }) self.__id = t @@ -4481,12 +4900,12 @@ def _set_id(self, v, load=False): self._set() def _unset_id(self): - self.__id = YANGDynClass(base=str, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-if:interface-id', is_config=False) + self.__id = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='oc-if:interface-id', is_config=False) - id = builtins.property(_get_id) + id = __builtin__.property(_get_id) - _pyangbind_elements = {'id': id, } + _pyangbind_elements = OrderedDict([('id', id), ]) class yc_config_openconfig_acl__acl_interfaces_interface_interface_ref_config(PybindBase): @@ -4498,15 +4917,19 @@ class yc_config_openconfig_acl__acl_interfaces_interface_interface_ref_config(Py YANG Description: Configured reference to interface / subinterface """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__interface','__subinterface',) + __slots__ = ('_path_helper', '_extmethods', '__interface','__subinterface',) + + _yang_name = 'config' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'config' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__interface = YANGDynClass(base=str, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) - self.__subinterface = YANGDynClass(base=str, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__interface = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__subinterface = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) load = kwargs.pop("load", None) if args: @@ -4533,7 +4956,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'interface-ref', 'config'] + return [u'acl', u'interfaces', u'interface', u'interface-ref', u'config'] def _get_interface(self): """ @@ -4560,12 +4983,12 @@ def _set_interface(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """interface must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", }) self.__interface = t @@ -4573,7 +4996,7 @@ def _set_interface(self, v, load=False): self._set() def _unset_interface(self): - self.__interface = YANGDynClass(base=str, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__interface = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) def _get_subinterface(self): @@ -4603,12 +5026,12 @@ def _set_subinterface(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """subinterface must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", }) self.__subinterface = t @@ -4616,13 +5039,13 @@ def _set_subinterface(self, v, load=False): self._set() def _unset_subinterface(self): - self.__subinterface = YANGDynClass(base=str, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__subinterface = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) - interface = builtins.property(_get_interface, _set_interface) - subinterface = builtins.property(_get_subinterface, _set_subinterface) + interface = __builtin__.property(_get_interface, _set_interface) + subinterface = __builtin__.property(_get_subinterface, _set_subinterface) - _pyangbind_elements = {'interface': interface, 'subinterface': subinterface, } + _pyangbind_elements = OrderedDict([('interface', interface), ('subinterface', subinterface), ]) class yc_state_openconfig_acl__acl_interfaces_interface_interface_ref_state(PybindBase): @@ -4634,15 +5057,19 @@ class yc_state_openconfig_acl__acl_interfaces_interface_interface_ref_state(Pybi YANG Description: Operational state for interface-ref """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__interface','__subinterface',) + __slots__ = ('_path_helper', '_extmethods', '__interface','__subinterface',) + + _yang_name = 'state' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'state' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__interface = YANGDynClass(base=str, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) - self.__subinterface = YANGDynClass(base=str, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__interface = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__subinterface = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) load = kwargs.pop("load", None) if args: @@ -4669,7 +5096,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'interface-ref', 'state'] + return [u'acl', u'interfaces', u'interface', u'interface-ref', u'state'] def _get_interface(self): """ @@ -4696,12 +5123,12 @@ def _set_interface(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """interface must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", }) self.__interface = t @@ -4709,7 +5136,7 @@ def _set_interface(self, v, load=False): self._set() def _unset_interface(self): - self.__interface = YANGDynClass(base=str, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__interface = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) def _get_subinterface(self): @@ -4739,12 +5166,12 @@ def _set_subinterface(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """subinterface must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", }) self.__subinterface = t @@ -4752,13 +5179,13 @@ def _set_subinterface(self, v, load=False): self._set() def _unset_subinterface(self): - self.__subinterface = YANGDynClass(base=str, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__subinterface = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="subinterface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) - interface = builtins.property(_get_interface) - subinterface = builtins.property(_get_subinterface) + interface = __builtin__.property(_get_interface) + subinterface = __builtin__.property(_get_subinterface) - _pyangbind_elements = {'interface': interface, 'subinterface': subinterface, } + _pyangbind_elements = OrderedDict([('interface', interface), ('subinterface', subinterface), ]) class yc_interface_ref_openconfig_acl__acl_interfaces_interface_interface_ref(PybindBase): @@ -4770,12 +5197,16 @@ class yc_interface_ref_openconfig_acl__acl_interfaces_interface_interface_ref(Py YANG Description: Reference to an interface or subinterface """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__config','__state',) + __slots__ = ('_path_helper', '_extmethods', '__config','__state',) + + _yang_name = 'interface-ref' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'interface-ref' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_interfaces_interface_interface_ref_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__config = YANGDynClass(base=yc_config_openconfig_acl__acl_interfaces_interface_interface_ref_config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) @@ -4805,7 +5236,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'interface-ref'] + return [u'acl', u'interfaces', u'interface', u'interface-ref'] def _get_config(self): """ @@ -4880,11 +5311,11 @@ def _set_state(self, v, load=False): def _unset_state(self): self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_interfaces_interface_interface_ref_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) - config = builtins.property(_get_config, _set_config) - state = builtins.property(_get_state, _set_state) + config = __builtin__.property(_get_config, _set_config) + state = __builtin__.property(_get_state, _set_state) - _pyangbind_elements = {'config': config, 'state': state, } + _pyangbind_elements = OrderedDict([('config', config), ('state', state), ]) class yc_config_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress_acl_set_config(PybindBase): @@ -4896,14 +5327,18 @@ class yc_config_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingres YANG Description: Configuration data """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__set_name',) + __slots__ = ('_path_helper', '_extmethods', '__set_name',) + + _yang_name = 'config' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'config' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__set_name = YANGDynClass(base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__set_name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) load = kwargs.pop("load", None) if args: @@ -4930,7 +5365,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'ingress-acl-sets', 'ingress-acl-set', 'config'] + return [u'acl', u'interfaces', u'interface', u'ingress-acl-sets', u'ingress-acl-set', u'config'] def _get_set_name(self): """ @@ -4953,12 +5388,12 @@ def _set_set_name(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """set_name must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", }) self.__set_name = t @@ -4966,12 +5401,12 @@ def _set_set_name(self, v, load=False): self._set() def _unset_set_name(self): - self.__set_name = YANGDynClass(base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__set_name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) - set_name = builtins.property(_get_set_name, _set_set_name) + set_name = __builtin__.property(_get_set_name, _set_set_name) - _pyangbind_elements = {'set_name': set_name, } + _pyangbind_elements = OrderedDict([('set_name', set_name), ]) class yc_state_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress_acl_set_state(PybindBase): @@ -4983,14 +5418,18 @@ class yc_state_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress YANG Description: Operational state data for interface ingress ACLs """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__set_name',) + __slots__ = ('_path_helper', '_extmethods', '__set_name',) + + _yang_name = 'state' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'state' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__set_name = YANGDynClass(base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__set_name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) load = kwargs.pop("load", None) if args: @@ -5017,7 +5456,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'ingress-acl-sets', 'ingress-acl-set', 'state'] + return [u'acl', u'interfaces', u'interface', u'ingress-acl-sets', u'ingress-acl-set', u'state'] def _get_set_name(self): """ @@ -5040,12 +5479,12 @@ def _set_set_name(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """set_name must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", }) self.__set_name = t @@ -5053,12 +5492,12 @@ def _set_set_name(self, v, load=False): self._set() def _unset_set_name(self): - self.__set_name = YANGDynClass(base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__set_name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) - set_name = builtins.property(_get_set_name) + set_name = __builtin__.property(_get_set_name) - _pyangbind_elements = {'set_name': set_name, } + _pyangbind_elements = OrderedDict([('set_name', set_name), ]) class yc_state_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress_acl_set_acl_entries_acl_entry_state(PybindBase): @@ -5070,16 +5509,20 @@ class yc_state_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress YANG Description: Operational state data for per-interface ACL entries """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__sequence_id','__matched_packets','__matched_octets',) + __slots__ = ('_path_helper', '_extmethods', '__sequence_id','__matched_packets','__matched_octets',) + + _yang_name = 'state' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'state' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__sequence_id = YANGDynClass(base=str, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) - self.__matched_packets = YANGDynClass(base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) - self.__matched_octets = YANGDynClass(base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + self.__sequence_id = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__matched_packets = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + self.__matched_octets = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) load = kwargs.pop("load", None) if args: @@ -5106,7 +5549,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'ingress-acl-sets', 'ingress-acl-set', 'acl-entries', 'acl-entry', 'state'] + return [u'acl', u'interfaces', u'interface', u'ingress-acl-sets', u'ingress-acl-set', u'acl-entries', u'acl-entry', u'state'] def _get_sequence_id(self): """ @@ -5131,12 +5574,12 @@ def _set_sequence_id(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """sequence_id must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", }) self.__sequence_id = t @@ -5144,7 +5587,7 @@ def _set_sequence_id(self, v, load=False): self._set() def _unset_sequence_id(self): - self.__sequence_id = YANGDynClass(base=str, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__sequence_id = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) def _get_matched_packets(self): @@ -5194,7 +5637,7 @@ def _set_matched_packets(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """matched_packets must be of a type compatible with yang:counter64""", @@ -5207,7 +5650,7 @@ def _set_matched_packets(self, v, load=False): self._set() def _unset_matched_packets(self): - self.__matched_packets = YANGDynClass(base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + self.__matched_packets = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) def _get_matched_octets(self): @@ -5257,7 +5700,7 @@ def _set_matched_octets(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """matched_octets must be of a type compatible with yang:counter64""", @@ -5270,14 +5713,14 @@ def _set_matched_octets(self, v, load=False): self._set() def _unset_matched_octets(self): - self.__matched_octets = YANGDynClass(base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + self.__matched_octets = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) - sequence_id = builtins.property(_get_sequence_id) - matched_packets = builtins.property(_get_matched_packets) - matched_octets = builtins.property(_get_matched_octets) + sequence_id = __builtin__.property(_get_sequence_id) + matched_packets = __builtin__.property(_get_matched_packets) + matched_octets = __builtin__.property(_get_matched_octets) - _pyangbind_elements = {'sequence_id': sequence_id, 'matched_packets': matched_packets, 'matched_octets': matched_octets, } + _pyangbind_elements = OrderedDict([('sequence_id', sequence_id), ('matched_packets', matched_packets), ('matched_octets', matched_octets), ]) class yc_acl_entry_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress_acl_set_acl_entries_acl_entry(PybindBase): @@ -5289,14 +5732,18 @@ class yc_acl_entry_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ing YANG Description: List of ACL entries assigned to an interface """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__sequence_id','__state',) + __slots__ = ('_path_helper', '_extmethods', '__sequence_id','__state',) + + _yang_name = 'acl-entry' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'acl-entry' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__sequence_id = YANGDynClass(base=str, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__sequence_id = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress_acl_set_acl_entries_acl_entry_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=False) load = kwargs.pop("load", None) @@ -5324,7 +5771,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'ingress-acl-sets', 'ingress-acl-set', 'acl-entries', 'acl-entry'] + return [u'acl', u'interfaces', u'interface', u'ingress-acl-sets', u'ingress-acl-set', u'acl-entries', u'acl-entry'] def _get_sequence_id(self): """ @@ -5352,12 +5799,12 @@ def _set_sequence_id(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """sequence_id must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", }) self.__sequence_id = t @@ -5365,7 +5812,7 @@ def _set_sequence_id(self, v, load=False): self._set() def _unset_sequence_id(self): - self.__sequence_id = YANGDynClass(base=str, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__sequence_id = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) def _get_state(self): @@ -5404,11 +5851,11 @@ def _set_state(self, v, load=False): def _unset_state(self): self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress_acl_set_acl_entries_acl_entry_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=False) - sequence_id = builtins.property(_get_sequence_id) - state = builtins.property(_get_state) + sequence_id = __builtin__.property(_get_sequence_id) + state = __builtin__.property(_get_state) - _pyangbind_elements = {'sequence_id': sequence_id, 'state': state, } + _pyangbind_elements = OrderedDict([('sequence_id', sequence_id), ('state', state), ]) class yc_acl_entries_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress_acl_set_acl_entries(PybindBase): @@ -5420,12 +5867,16 @@ class yc_acl_entries_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_i YANG Description: Enclosing container for list of references to ACLs """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__acl_entry',) + __slots__ = ('_path_helper', '_extmethods', '__acl_entry',) + + _yang_name = 'acl-entries' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'acl-entries' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__acl_entry = YANGDynClass(base=YANGListType("sequence_id",yc_acl_entry_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress_acl_set_acl_entries_acl_entry, yang_name="acl-entry", parent=self, is_container='list', user_ordered=False, path_helper=self._path_helper, yang_keys='sequence-id', extensions=None), is_container='list', yang_name="acl-entry", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='list', is_config=False) @@ -5454,7 +5905,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'ingress-acl-sets', 'ingress-acl-set', 'acl-entries'] + return [u'acl', u'interfaces', u'interface', u'ingress-acl-sets', u'ingress-acl-set', u'acl-entries'] def _get_acl_entry(self): """ @@ -5492,10 +5943,10 @@ def _set_acl_entry(self, v, load=False): def _unset_acl_entry(self): self.__acl_entry = YANGDynClass(base=YANGListType("sequence_id",yc_acl_entry_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress_acl_set_acl_entries_acl_entry, yang_name="acl-entry", parent=self, is_container='list', user_ordered=False, path_helper=self._path_helper, yang_keys='sequence-id', extensions=None), is_container='list', yang_name="acl-entry", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='list', is_config=False) - acl_entry = builtins.property(_get_acl_entry) + acl_entry = __builtin__.property(_get_acl_entry) - _pyangbind_elements = {'acl_entry': acl_entry, } + _pyangbind_elements = OrderedDict([('acl_entry', acl_entry), ]) class yc_ingress_acl_set_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress_acl_set(PybindBase): @@ -5507,14 +5958,18 @@ class yc_ingress_acl_set_openconfig_acl__acl_interfaces_interface_ingress_acl_se YANG Description: List of ingress ACLs on the interface """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__set_name','__config','__state','__acl_entries',) + __slots__ = ('_path_helper', '_extmethods', '__set_name','__config','__state','__acl_entries',) + + _yang_name = 'ingress-acl-set' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'ingress-acl-set' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__set_name = YANGDynClass(base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__set_name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) self.__config = YANGDynClass(base=yc_config_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress_acl_set_config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress_acl_set_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__acl_entries = YANGDynClass(base=yc_acl_entries_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress_acl_set_acl_entries, is_container='container', yang_name="acl-entries", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) @@ -5544,7 +5999,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'ingress-acl-sets', 'ingress-acl-set'] + return [u'acl', u'interfaces', u'interface', u'ingress-acl-sets', u'ingress-acl-set'] def _get_set_name(self): """ @@ -5572,12 +6027,12 @@ def _set_set_name(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """set_name must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", }) self.__set_name = t @@ -5585,7 +6040,7 @@ def _set_set_name(self, v, load=False): self._set() def _unset_set_name(self): - self.__set_name = YANGDynClass(base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__set_name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) def _get_config(self): @@ -5698,13 +6153,13 @@ def _set_acl_entries(self, v, load=False): def _unset_acl_entries(self): self.__acl_entries = YANGDynClass(base=yc_acl_entries_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress_acl_set_acl_entries, is_container='container', yang_name="acl-entries", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) - set_name = builtins.property(_get_set_name, _set_set_name) - config = builtins.property(_get_config, _set_config) - state = builtins.property(_get_state, _set_state) - acl_entries = builtins.property(_get_acl_entries, _set_acl_entries) + set_name = __builtin__.property(_get_set_name, _set_set_name) + config = __builtin__.property(_get_config, _set_config) + state = __builtin__.property(_get_state, _set_state) + acl_entries = __builtin__.property(_get_acl_entries, _set_acl_entries) - _pyangbind_elements = {'set_name': set_name, 'config': config, 'state': state, 'acl_entries': acl_entries, } + _pyangbind_elements = OrderedDict([('set_name', set_name), ('config', config), ('state', state), ('acl_entries', acl_entries), ]) class yc_ingress_acl_sets_openconfig_acl__acl_interfaces_interface_ingress_acl_sets(PybindBase): @@ -5717,12 +6172,16 @@ class yc_ingress_acl_sets_openconfig_acl__acl_interfaces_interface_ingress_acl_s YANG Description: Enclosing container the list of ingress ACLs on the interface """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__ingress_acl_set',) + __slots__ = ('_path_helper', '_extmethods', '__ingress_acl_set',) + + _yang_name = 'ingress-acl-sets' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'ingress-acl-sets' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__ingress_acl_set = YANGDynClass(base=YANGListType("set_name",yc_ingress_acl_set_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress_acl_set, yang_name="ingress-acl-set", parent=self, is_container='list', user_ordered=False, path_helper=self._path_helper, yang_keys='set-name', extensions=None), is_container='list', yang_name="ingress-acl-set", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='list', is_config=True) @@ -5751,7 +6210,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'ingress-acl-sets'] + return [u'acl', u'interfaces', u'interface', u'ingress-acl-sets'] def _get_ingress_acl_set(self): """ @@ -5789,10 +6248,10 @@ def _set_ingress_acl_set(self, v, load=False): def _unset_ingress_acl_set(self): self.__ingress_acl_set = YANGDynClass(base=YANGListType("set_name",yc_ingress_acl_set_openconfig_acl__acl_interfaces_interface_ingress_acl_sets_ingress_acl_set, yang_name="ingress-acl-set", parent=self, is_container='list', user_ordered=False, path_helper=self._path_helper, yang_keys='set-name', extensions=None), is_container='list', yang_name="ingress-acl-set", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='list', is_config=True) - ingress_acl_set = builtins.property(_get_ingress_acl_set, _set_ingress_acl_set) + ingress_acl_set = __builtin__.property(_get_ingress_acl_set, _set_ingress_acl_set) - _pyangbind_elements = {'ingress_acl_set': ingress_acl_set, } + _pyangbind_elements = OrderedDict([('ingress_acl_set', ingress_acl_set), ]) class yc_config_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_acl_set_config(PybindBase): @@ -5804,14 +6263,18 @@ class yc_config_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_ YANG Description: Configuration data """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__set_name',) + __slots__ = ('_path_helper', '_extmethods', '__set_name',) + + _yang_name = 'config' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'config' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__set_name = YANGDynClass(base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__set_name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) load = kwargs.pop("load", None) if args: @@ -5838,7 +6301,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'egress-acl-sets', 'egress-acl-set', 'config'] + return [u'acl', u'interfaces', u'interface', u'egress-acl-sets', u'egress-acl-set', u'config'] def _get_set_name(self): """ @@ -5861,12 +6324,12 @@ def _set_set_name(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """set_name must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", }) self.__set_name = t @@ -5874,12 +6337,12 @@ def _set_set_name(self, v, load=False): self._set() def _unset_set_name(self): - self.__set_name = YANGDynClass(base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__set_name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) - set_name = builtins.property(_get_set_name, _set_set_name) + set_name = __builtin__.property(_get_set_name, _set_set_name) - _pyangbind_elements = {'set_name': set_name, } + _pyangbind_elements = OrderedDict([('set_name', set_name), ]) class yc_state_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_acl_set_state(PybindBase): @@ -5891,14 +6354,18 @@ class yc_state_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_a YANG Description: Operational state data for interface egress ACLs """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__set_name',) + __slots__ = ('_path_helper', '_extmethods', '__set_name',) + + _yang_name = 'state' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'state' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__set_name = YANGDynClass(base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__set_name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) load = kwargs.pop("load", None) if args: @@ -5925,7 +6392,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'egress-acl-sets', 'egress-acl-set', 'state'] + return [u'acl', u'interfaces', u'interface', u'egress-acl-sets', u'egress-acl-set', u'state'] def _get_set_name(self): """ @@ -5948,12 +6415,12 @@ def _set_set_name(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """set_name must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", }) self.__set_name = t @@ -5961,12 +6428,12 @@ def _set_set_name(self, v, load=False): self._set() def _unset_set_name(self): - self.__set_name = YANGDynClass(base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__set_name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) - set_name = builtins.property(_get_set_name) + set_name = __builtin__.property(_get_set_name) - _pyangbind_elements = {'set_name': set_name, } + _pyangbind_elements = OrderedDict([('set_name', set_name), ]) class yc_state_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_acl_set_acl_entries_acl_entry_state(PybindBase): @@ -5978,16 +6445,20 @@ class yc_state_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_a YANG Description: Operational state data for per-interface ACL entries """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__sequence_id','__matched_packets','__matched_octets',) + __slots__ = ('_path_helper', '_extmethods', '__sequence_id','__matched_packets','__matched_octets',) + + _yang_name = 'state' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'state' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__sequence_id = YANGDynClass(base=str, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) - self.__matched_packets = YANGDynClass(base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) - self.__matched_octets = YANGDynClass(base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + self.__sequence_id = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__matched_packets = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + self.__matched_octets = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) load = kwargs.pop("load", None) if args: @@ -6014,7 +6485,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'egress-acl-sets', 'egress-acl-set', 'acl-entries', 'acl-entry', 'state'] + return [u'acl', u'interfaces', u'interface', u'egress-acl-sets', u'egress-acl-set', u'acl-entries', u'acl-entry', u'state'] def _get_sequence_id(self): """ @@ -6039,12 +6510,12 @@ def _set_sequence_id(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """sequence_id must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", }) self.__sequence_id = t @@ -6052,7 +6523,7 @@ def _set_sequence_id(self, v, load=False): self._set() def _unset_sequence_id(self): - self.__sequence_id = YANGDynClass(base=str, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__sequence_id = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) def _get_matched_packets(self): @@ -6102,7 +6573,7 @@ def _set_matched_packets(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """matched_packets must be of a type compatible with yang:counter64""", @@ -6115,7 +6586,7 @@ def _set_matched_packets(self, v, load=False): self._set() def _unset_matched_packets(self): - self.__matched_packets = YANGDynClass(base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + self.__matched_packets = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-packets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) def _get_matched_octets(self): @@ -6165,7 +6636,7 @@ def _set_matched_octets(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + t = YANGDynClass(v,base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """matched_octets must be of a type compatible with yang:counter64""", @@ -6178,14 +6649,14 @@ def _set_matched_octets(self, v, load=False): self._set() def _unset_matched_octets(self): - self.__matched_octets = YANGDynClass(base=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) + self.__matched_octets = YANGDynClass(base=RestrictedClassType(base_type=long, restriction_dict={'range': ['0..18446744073709551615']}, int_size=64), is_leaf=True, yang_name="matched-octets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:counter64', is_config=False) - sequence_id = builtins.property(_get_sequence_id) - matched_packets = builtins.property(_get_matched_packets) - matched_octets = builtins.property(_get_matched_octets) + sequence_id = __builtin__.property(_get_sequence_id) + matched_packets = __builtin__.property(_get_matched_packets) + matched_octets = __builtin__.property(_get_matched_octets) - _pyangbind_elements = {'sequence_id': sequence_id, 'matched_packets': matched_packets, 'matched_octets': matched_octets, } + _pyangbind_elements = OrderedDict([('sequence_id', sequence_id), ('matched_packets', matched_packets), ('matched_octets', matched_octets), ]) class yc_acl_entry_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_acl_set_acl_entries_acl_entry(PybindBase): @@ -6197,14 +6668,18 @@ class yc_acl_entry_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egre YANG Description: List of ACL entries assigned to an interface """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__sequence_id','__state',) + __slots__ = ('_path_helper', '_extmethods', '__sequence_id','__state',) + + _yang_name = 'acl-entry' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'acl-entry' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__sequence_id = YANGDynClass(base=str, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__sequence_id = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_acl_set_acl_entries_acl_entry_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=False) load = kwargs.pop("load", None) @@ -6232,7 +6707,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'egress-acl-sets', 'egress-acl-set', 'acl-entries', 'acl-entry'] + return [u'acl', u'interfaces', u'interface', u'egress-acl-sets', u'egress-acl-set', u'acl-entries', u'acl-entry'] def _get_sequence_id(self): """ @@ -6260,12 +6735,12 @@ def _set_sequence_id(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """sequence_id must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False)""", }) self.__sequence_id = t @@ -6273,7 +6748,7 @@ def _set_sequence_id(self, v, load=False): self._set() def _unset_sequence_id(self): - self.__sequence_id = YANGDynClass(base=str, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) + self.__sequence_id = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="sequence-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=False) def _get_state(self): @@ -6312,11 +6787,11 @@ def _set_state(self, v, load=False): def _unset_state(self): self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_acl_set_acl_entries_acl_entry_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=False) - sequence_id = builtins.property(_get_sequence_id) - state = builtins.property(_get_state) + sequence_id = __builtin__.property(_get_sequence_id) + state = __builtin__.property(_get_state) - _pyangbind_elements = {'sequence_id': sequence_id, 'state': state, } + _pyangbind_elements = OrderedDict([('sequence_id', sequence_id), ('state', state), ]) class yc_acl_entries_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_acl_set_acl_entries(PybindBase): @@ -6328,12 +6803,16 @@ class yc_acl_entries_openconfig_acl__acl_interfaces_interface_egress_acl_sets_eg YANG Description: Enclosing container for list of references to ACLs """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__acl_entry',) + __slots__ = ('_path_helper', '_extmethods', '__acl_entry',) + + _yang_name = 'acl-entries' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'acl-entries' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__acl_entry = YANGDynClass(base=YANGListType("sequence_id",yc_acl_entry_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_acl_set_acl_entries_acl_entry, yang_name="acl-entry", parent=self, is_container='list', user_ordered=False, path_helper=self._path_helper, yang_keys='sequence-id', extensions=None), is_container='list', yang_name="acl-entry", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='list', is_config=False) @@ -6362,7 +6841,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'egress-acl-sets', 'egress-acl-set', 'acl-entries'] + return [u'acl', u'interfaces', u'interface', u'egress-acl-sets', u'egress-acl-set', u'acl-entries'] def _get_acl_entry(self): """ @@ -6400,10 +6879,10 @@ def _set_acl_entry(self, v, load=False): def _unset_acl_entry(self): self.__acl_entry = YANGDynClass(base=YANGListType("sequence_id",yc_acl_entry_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_acl_set_acl_entries_acl_entry, yang_name="acl-entry", parent=self, is_container='list', user_ordered=False, path_helper=self._path_helper, yang_keys='sequence-id', extensions=None), is_container='list', yang_name="acl-entry", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='list', is_config=False) - acl_entry = builtins.property(_get_acl_entry) + acl_entry = __builtin__.property(_get_acl_entry) - _pyangbind_elements = {'acl_entry': acl_entry, } + _pyangbind_elements = OrderedDict([('acl_entry', acl_entry), ]) class yc_egress_acl_set_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_acl_set(PybindBase): @@ -6415,14 +6894,18 @@ class yc_egress_acl_set_openconfig_acl__acl_interfaces_interface_egress_acl_sets YANG Description: List of egress ACLs on the interface """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__set_name','__config','__state','__acl_entries',) + __slots__ = ('_path_helper', '_extmethods', '__set_name','__config','__state','__acl_entries',) + + _yang_name = 'egress-acl-set' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'egress-acl-set' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False - self.__set_name = YANGDynClass(base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__set_name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) self.__config = YANGDynClass(base=yc_config_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_acl_set_config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_acl_set_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__acl_entries = YANGDynClass(base=yc_acl_entries_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_acl_set_acl_entries, is_container='container', yang_name="acl-entries", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) @@ -6452,7 +6935,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'egress-acl-sets', 'egress-acl-set'] + return [u'acl', u'interfaces', u'interface', u'egress-acl-sets', u'egress-acl-set'] def _get_set_name(self): """ @@ -6480,12 +6963,12 @@ def _set_set_name(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """set_name must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", }) self.__set_name = t @@ -6493,7 +6976,7 @@ def _set_set_name(self, v, load=False): self._set() def _unset_set_name(self): - self.__set_name = YANGDynClass(base=str, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__set_name = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="set-name", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) def _get_config(self): @@ -6606,13 +7089,13 @@ def _set_acl_entries(self, v, load=False): def _unset_acl_entries(self): self.__acl_entries = YANGDynClass(base=yc_acl_entries_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_acl_set_acl_entries, is_container='container', yang_name="acl-entries", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) - set_name = builtins.property(_get_set_name, _set_set_name) - config = builtins.property(_get_config, _set_config) - state = builtins.property(_get_state, _set_state) - acl_entries = builtins.property(_get_acl_entries, _set_acl_entries) + set_name = __builtin__.property(_get_set_name, _set_set_name) + config = __builtin__.property(_get_config, _set_config) + state = __builtin__.property(_get_state, _set_state) + acl_entries = __builtin__.property(_get_acl_entries, _set_acl_entries) - _pyangbind_elements = {'set_name': set_name, 'config': config, 'state': state, 'acl_entries': acl_entries, } + _pyangbind_elements = OrderedDict([('set_name', set_name), ('config', config), ('state', state), ('acl_entries', acl_entries), ]) class yc_egress_acl_sets_openconfig_acl__acl_interfaces_interface_egress_acl_sets(PybindBase): @@ -6625,12 +7108,16 @@ class yc_egress_acl_sets_openconfig_acl__acl_interfaces_interface_egress_acl_set YANG Description: Enclosing container the list of egress ACLs on the interface """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__egress_acl_set',) + __slots__ = ('_path_helper', '_extmethods', '__egress_acl_set',) + + _yang_name = 'egress-acl-sets' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'egress-acl-sets' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__egress_acl_set = YANGDynClass(base=YANGListType("set_name",yc_egress_acl_set_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_acl_set, yang_name="egress-acl-set", parent=self, is_container='list', user_ordered=False, path_helper=self._path_helper, yang_keys='set-name', extensions=None), is_container='list', yang_name="egress-acl-set", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='list', is_config=True) @@ -6659,7 +7146,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface', 'egress-acl-sets'] + return [u'acl', u'interfaces', u'interface', u'egress-acl-sets'] def _get_egress_acl_set(self): """ @@ -6697,10 +7184,10 @@ def _set_egress_acl_set(self, v, load=False): def _unset_egress_acl_set(self): self.__egress_acl_set = YANGDynClass(base=YANGListType("set_name",yc_egress_acl_set_openconfig_acl__acl_interfaces_interface_egress_acl_sets_egress_acl_set, yang_name="egress-acl-set", parent=self, is_container='list', user_ordered=False, path_helper=self._path_helper, yang_keys='set-name', extensions=None), is_container='list', yang_name="egress-acl-set", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='list', is_config=True) - egress_acl_set = builtins.property(_get_egress_acl_set, _set_egress_acl_set) + egress_acl_set = __builtin__.property(_get_egress_acl_set, _set_egress_acl_set) - _pyangbind_elements = {'egress_acl_set': egress_acl_set, } + _pyangbind_elements = OrderedDict([('egress_acl_set', egress_acl_set), ]) class yc_interface_openconfig_acl__acl_interfaces_interface(PybindBase): @@ -6712,18 +7199,22 @@ class yc_interface_openconfig_acl__acl_interfaces_interface(PybindBase): YANG Description: List of interfaces on which ACLs are set """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__id','__config','__state','__interface_ref','__ingress_acl_sets','__egress_acl_sets',) + __slots__ = ('_path_helper', '_extmethods', '__id','__config','__state','__interface_ref','__ingress_acl_sets','__egress_acl_sets',) + + _yang_name = 'interface' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'interface' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__ingress_acl_sets = YANGDynClass(base=yc_ingress_acl_sets_openconfig_acl__acl_interfaces_interface_ingress_acl_sets, is_container='container', yang_name="ingress-acl-sets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__egress_acl_sets = YANGDynClass(base=yc_egress_acl_sets_openconfig_acl__acl_interfaces_interface_egress_acl_sets, is_container='container', yang_name="egress-acl-sets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_interfaces_interface_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__config = YANGDynClass(base=yc_config_openconfig_acl__acl_interfaces_interface_config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) - self.__id = YANGDynClass(base=str, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__id = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) self.__interface_ref = YANGDynClass(base=yc_interface_ref_openconfig_acl__acl_interfaces_interface_interface_ref, is_container='container', yang_name="interface-ref", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) load = kwargs.pop("load", None) @@ -6751,7 +7242,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces', 'interface'] + return [u'acl', u'interfaces', u'interface'] def _get_id(self): """ @@ -6779,12 +7270,12 @@ def _set_id(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=str, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + t = YANGDynClass(v,base=six.text_type, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """id must be of a type compatible with leafref""", 'defined-type': "leafref", - 'generated-type': """YANGDynClass(base=unicode, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", + 'generated-type': """YANGDynClass(base=six.text_type, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True)""", }) self.__id = t @@ -6792,7 +7283,7 @@ def _set_id(self, v, load=False): self._set() def _unset_id(self): - self.__id = YANGDynClass(base=str, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) + self.__id = YANGDynClass(base=six.text_type, is_leaf=True, yang_name="id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, is_keyval=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='leafref', is_config=True) def _get_config(self): @@ -6983,15 +7474,15 @@ def _set_egress_acl_sets(self, v, load=False): def _unset_egress_acl_sets(self): self.__egress_acl_sets = YANGDynClass(base=yc_egress_acl_sets_openconfig_acl__acl_interfaces_interface_egress_acl_sets, is_container='container', yang_name="egress-acl-sets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) - id = builtins.property(_get_id, _set_id) - config = builtins.property(_get_config, _set_config) - state = builtins.property(_get_state, _set_state) - interface_ref = builtins.property(_get_interface_ref, _set_interface_ref) - ingress_acl_sets = builtins.property(_get_ingress_acl_sets, _set_ingress_acl_sets) - egress_acl_sets = builtins.property(_get_egress_acl_sets, _set_egress_acl_sets) + id = __builtin__.property(_get_id, _set_id) + config = __builtin__.property(_get_config, _set_config) + state = __builtin__.property(_get_state, _set_state) + interface_ref = __builtin__.property(_get_interface_ref, _set_interface_ref) + ingress_acl_sets = __builtin__.property(_get_ingress_acl_sets, _set_ingress_acl_sets) + egress_acl_sets = __builtin__.property(_get_egress_acl_sets, _set_egress_acl_sets) - _pyangbind_elements = {'id': id, 'config': config, 'state': state, 'interface_ref': interface_ref, 'ingress_acl_sets': ingress_acl_sets, 'egress_acl_sets': egress_acl_sets, } + _pyangbind_elements = OrderedDict([('id', id), ('config', config), ('state', state), ('interface_ref', interface_ref), ('ingress_acl_sets', ingress_acl_sets), ('egress_acl_sets', egress_acl_sets), ]) class yc_interfaces_openconfig_acl__acl_interfaces(PybindBase): @@ -7004,12 +7495,16 @@ class yc_interfaces_openconfig_acl__acl_interfaces(PybindBase): YANG Description: Enclosing container for the list of interfaces on which ACLs are set """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__interface',) + __slots__ = ('_path_helper', '_extmethods', '__interface',) + + _yang_name = 'interfaces' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'interfaces' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__interface = YANGDynClass(base=YANGListType("id",yc_interface_openconfig_acl__acl_interfaces_interface, yang_name="interface", parent=self, is_container='list', user_ordered=False, path_helper=self._path_helper, yang_keys='id', extensions=None), is_container='list', yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='list', is_config=True) @@ -7038,7 +7533,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl', 'interfaces'] + return [u'acl', u'interfaces'] def _get_interface(self): """ @@ -7076,10 +7571,10 @@ def _set_interface(self, v, load=False): def _unset_interface(self): self.__interface = YANGDynClass(base=YANGListType("id",yc_interface_openconfig_acl__acl_interfaces_interface, yang_name="interface", parent=self, is_container='list', user_ordered=False, path_helper=self._path_helper, yang_keys='id', extensions=None), is_container='list', yang_name="interface", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='list', is_config=True) - interface = builtins.property(_get_interface, _set_interface) + interface = __builtin__.property(_get_interface, _set_interface) - _pyangbind_elements = {'interface': interface, } + _pyangbind_elements = OrderedDict([('interface', interface), ]) class yc_acl_openconfig_acl__acl(PybindBase): @@ -7092,12 +7587,16 @@ class yc_acl_openconfig_acl__acl(PybindBase): YANG Description: Top level enclosing container for ACL model config and operational state data """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__state','__acl_sets','__interfaces',) + __slots__ = ('_path_helper', '_extmethods', '__state','__acl_sets','__interfaces',) + + _yang_name = 'acl' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'acl' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__state = YANGDynClass(base=yc_state_openconfig_acl__acl_state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) self.__acl_sets = YANGDynClass(base=yc_acl_sets_openconfig_acl__acl_acl_sets, is_container='container', yang_name="acl-sets", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) @@ -7128,7 +7627,7 @@ def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: - return ['acl'] + return [u'acl'] def _get_state(self): """ @@ -7242,12 +7741,12 @@ def _set_interfaces(self, v, load=False): def _unset_interfaces(self): self.__interfaces = YANGDynClass(base=yc_interfaces_openconfig_acl__acl_interfaces, is_container='container', yang_name="interfaces", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) - state = builtins.property(_get_state, _set_state) - acl_sets = builtins.property(_get_acl_sets, _set_acl_sets) - interfaces = builtins.property(_get_interfaces, _set_interfaces) + state = __builtin__.property(_get_state, _set_state) + acl_sets = __builtin__.property(_get_acl_sets, _set_acl_sets) + interfaces = __builtin__.property(_get_interfaces, _set_interfaces) - _pyangbind_elements = {'state': state, 'acl_sets': acl_sets, 'interfaces': interfaces, } + _pyangbind_elements = OrderedDict([('state', state), ('acl_sets', acl_sets), ('interfaces', interfaces), ]) class openconfig_acl(PybindBase): @@ -7272,12 +7771,16 @@ class openconfig_acl(PybindBase): criteria that cross protocol layers, e.g., MAC layer and IP layer matches. """ - __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__acl',) + __slots__ = ('_path_helper', '_extmethods', '__acl',) + + _yang_name = 'openconfig-acl' + + _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): - self._yang_name = 'openconfig-acl' - self._pybind_generated_by = 'container' + self._path_helper = False + self._extmethods = False self.__acl = YANGDynClass(base=yc_acl_openconfig_acl__acl, is_container='container', yang_name="acl", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) @@ -7346,7 +7849,9 @@ def _set_acl(self, v, load=False): def _unset_acl(self): self.__acl = YANGDynClass(base=yc_acl_openconfig_acl__acl, is_container='container', yang_name="acl", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions=None, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='container', is_config=True) - acl = builtins.property(_get_acl, _set_acl) + acl = __builtin__.property(_get_acl, _set_acl) + + + _pyangbind_elements = OrderedDict([('acl', acl), ]) - _pyangbind_elements = {'acl': acl, } diff --git a/src/sonic-config-engine/sonic-acl-extension.yang b/src/sonic-config-engine/sonic-acl-extension.yang new file mode 100644 index 000000000000..eac83b985f30 --- /dev/null +++ b/src/sonic-config-engine/sonic-acl-extension.yang @@ -0,0 +1,76 @@ +module sonic-acl-extension { + yang-version "1"; + namespace "https://github.com/Azure/sonic-buildimage"; + + prefix "sonic-acl-extension"; + + import openconfig-acl { prefix oc-acl; } + + typedef vlan-id-type { + type uint16 { + range 0..4095; + } + description + "The VLAN ID value may be expressed as a 12-bit number in decimal notation"; + } + + typedef icmp-type-type { + type uint8 { + range 0..255; + } + description + "The ICMP type value may be expressed as an 8-bit number in decimal notation"; + } + + typedef icmp-code-type { + type uint8 { + range 0..255; + } + description + "The ICMP code value may be expressed as an 8-bit number in decimal notation"; + } + + grouping extended-l2-match { + leaf vlan-id { + type vlan-id-type; + description + "VLAN ID field to match in DOT1Q packets"; + } + } + + grouping icmp-protocol-fields-config { + description + "Configuration data of ICMP protocol fields."; + + leaf type { + type icmp-type-type; + description + "ICMP(V6) type."; + } + + leaf code { + type icmp-code-type; + description + "ICMP(V6) code."; + } + } + + grouping icmp-protocol-fields-top { + description + "ICMP header fields for IPv4 and IPv6"; + + container icmp { + container config { + uses icmp-protocol-fields-config; + } + } + } + + augment "/oc-acl:acl/oc-acl:acl-sets/oc-acl:acl-set/oc-acl:acl-entries/oc-acl:acl-entry/oc-acl:l2/oc-acl:config" { + uses extended-l2-match; + } + + augment "/oc-acl:acl/oc-acl:acl-sets/oc-acl:acl-set/oc-acl:acl-entries/oc-acl:acl-entry" { + uses icmp-protocol-fields-top; + } +} From 870eb46fce8f47a0d84f042816593022225f9668 Mon Sep 17 00:00:00 2001 From: Lior Avramov <73036155+liorghub@users.noreply.github.com> Date: Mon, 1 Mar 2021 12:36:18 +0200 Subject: [PATCH 0245/1674] [Mellanox]: Fix PCIEd configuration files for SN3700 and SN3800 systems (#6913) - Why I did it To fix PCIEd errors in log. - How I did it Update pcie.yaml with the right PCI addresses. - How to verify it Check logs, operation occurs each minute. Signed-off-by: liora --- device/mellanox/x86_64-mlnx_msn3700c-r0/pcie.yaml | 4 ++-- device/mellanox/x86_64-mlnx_msn3800-r0/pcie.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/device/mellanox/x86_64-mlnx_msn3700c-r0/pcie.yaml b/device/mellanox/x86_64-mlnx_msn3700c-r0/pcie.yaml index 21c48fe64008..6daf5eefa130 100644 --- a/device/mellanox/x86_64-mlnx_msn3700c-r0/pcie.yaml +++ b/device/mellanox/x86_64-mlnx_msn3700c-r0/pcie.yaml @@ -130,13 +130,13 @@ id: 6f53 name: 'System peripheral: Intel Corporation Xeon Processor D Family QuickData Technology Register DMA Channel 3' -- bus: '06' +- bus: '07' dev: '00' fn: '0' id: cf6c name: 'Ethernet controller: Mellanox Technologies MT53100 [Spectrum-2, 64 x 100GbE switch]' -- bus: 08 +- bus: 09 dev: '00' fn: '0' id: '1533' diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/pcie.yaml b/device/mellanox/x86_64-mlnx_msn3800-r0/pcie.yaml index d4a25d40bd54..3dc31739f7d9 120000 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/pcie.yaml +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/pcie.yaml @@ -1 +1 @@ -../x86_64-mlnx_msn3700-r0/pcie.yaml \ No newline at end of file +../x86_64-mlnx_msn3700c-r0/pcie.yaml \ No newline at end of file From f240859c6168df4a6ec9d244f9630612ffff7d83 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Sun, 28 Feb 2021 23:59:48 -0800 Subject: [PATCH 0246/1674] [build] No longer install scpay Debian package in host (#6919) As of the merging of PR #6799, we are now installing a newer version of scapy via pip, therefore there is no longer a need to install the older Debian package. --- build_debian.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/build_debian.sh b/build_debian.sh index 61252adabe2d..3559560b1ed4 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -300,7 +300,6 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in ethtool \ screen \ hping3 \ - python-scapy \ tcptraceroute \ mtr-tiny \ locales \ From 12cc180e29a14a58a62770b88cb187f3608c3f59 Mon Sep 17 00:00:00 2001 From: Danny Allen Date: Tue, 2 Mar 2021 14:32:00 -0800 Subject: [PATCH 0247/1674] [openconfig_acl] Allow setting ICMP type/code to 0 (#6932) There is a bug in how pyangbind translates yang models into python bindings. The model always sets integer values to 0 by default, so there is no way to check if a user has provided a value that is equal to 0. This is problematic for ICMP and VLAN (among others) because 0 is a valid input value. This change converts ICMP and VLAN fields to union types so that acl-loader will treat them as null values unless a user explicitly adds an integer value. Signed-off-by: Danny Allen --- src/sonic-config-engine/openconfig_acl.py | 24 ++++++++--------- .../sonic-acl-extension.yang | 27 ++++++++++++++----- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/sonic-config-engine/openconfig_acl.py b/src/sonic-config-engine/openconfig_acl.py index 5399f21a7d7f..5939bce44d6a 100644 --- a/src/sonic-config-engine/openconfig_acl.py +++ b/src/sonic-config-engine/openconfig_acl.py @@ -832,7 +832,7 @@ def __init__(self, *args, **kwargs): self.__destination_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) self.__source_mac = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) self.__source_mac_mask = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="source-mac-mask", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) - self.__vlan_id = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..4095']}), is_leaf=True, yang_name="vlan-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='vlan-id-type', is_config=True) + self.__vlan_id = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'null'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'1..4095']}),], is_leaf=True, yang_name="vlan-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='vlan-id-type', is_config=True) self.__destination_mac = YANGDynClass(base=RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}'}), is_leaf=True, yang_name="destination-mac", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/acl', defining_module='openconfig-acl', yang_type='yang:mac-address', is_config=True) load = kwargs.pop("load", None) @@ -1068,12 +1068,12 @@ def _set_vlan_id(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..4095']}), is_leaf=True, yang_name="vlan-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='vlan-id-type', is_config=True) + t = YANGDynClass(v,base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'null'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'1..4095']}),], is_leaf=True, yang_name="vlan-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='vlan-id-type', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """vlan_id must be of a type compatible with vlan-id-type""", 'defined-type': "sonic-acl-extension:vlan-id-type", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..4095']}), is_leaf=True, yang_name="vlan-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='vlan-id-type', is_config=True)""", + 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'null'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'1..4095']}),], is_leaf=True, yang_name="vlan-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='vlan-id-type', is_config=True)""", }) self.__vlan_id = t @@ -1081,7 +1081,7 @@ def _set_vlan_id(self, v, load=False): self._set() def _unset_vlan_id(self): - self.__vlan_id = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'0..4095']}), is_leaf=True, yang_name="vlan-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='vlan-id-type', is_config=True) + self.__vlan_id = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'null'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..65535']},int_size=16), restriction_dict={u'range': [u'1..4095']}),], is_leaf=True, yang_name="vlan-id", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='vlan-id-type', is_config=True) source_mac = __builtin__.property(_get_source_mac, _set_source_mac) source_mac_mask = __builtin__.property(_get_source_mac_mask, _set_source_mac_mask) @@ -3723,8 +3723,8 @@ def __init__(self, *args, **kwargs): self._path_helper = False self._extmethods = False - self.__code = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="code", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-code-type', is_config=True) - self.__type = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-type-type', is_config=True) + self.__code = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'null'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}),], is_leaf=True, yang_name="code", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-code-type', is_config=True) + self.__type = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'null'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}),], is_leaf=True, yang_name="type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-type-type', is_config=True) load = kwargs.pop("load", None) if args: @@ -3774,12 +3774,12 @@ def _set_type(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-type-type', is_config=True) + t = YANGDynClass(v,base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'null'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}),], is_leaf=True, yang_name="type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-type-type', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """type must be of a type compatible with icmp-type-type""", 'defined-type': "sonic-acl-extension:icmp-type-type", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-type-type', is_config=True)""", + 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'null'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}),], is_leaf=True, yang_name="type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-type-type', is_config=True)""", }) self.__type = t @@ -3787,7 +3787,7 @@ def _set_type(self, v, load=False): self._set() def _unset_type(self): - self.__type = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-type-type', is_config=True) + self.__type = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'null'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}),], is_leaf=True, yang_name="type", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-type-type', is_config=True) def _get_code(self): @@ -3811,12 +3811,12 @@ def _set_code(self, v, load=False): if hasattr(v, "_utype"): v = v._utype(v) try: - t = YANGDynClass(v,base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="code", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-code-type', is_config=True) + t = YANGDynClass(v,base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'null'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}),], is_leaf=True, yang_name="code", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-code-type', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """code must be of a type compatible with icmp-code-type""", 'defined-type': "sonic-acl-extension:icmp-code-type", - 'generated-type': """YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="code", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-code-type', is_config=True)""", + 'generated-type': """YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'null'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}),], is_leaf=True, yang_name="code", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-code-type', is_config=True)""", }) self.__code = t @@ -3824,7 +3824,7 @@ def _set_code(self, v, load=False): self._set() def _unset_code(self): - self.__code = YANGDynClass(base=RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}), is_leaf=True, yang_name="code", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-code-type', is_config=True) + self.__code = YANGDynClass(base=[RestrictedClassType(base_type=six.text_type, restriction_dict={u'pattern': u'null'}),RestrictedClassType(base_type=RestrictedClassType(base_type=int, restriction_dict={'range': ['0..255']}, int_size=8), restriction_dict={u'range': [u'0..255']}),], is_leaf=True, yang_name="code", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='https://github.com/Azure/sonic-buildimage', defining_module='sonic-acl-extension', yang_type='icmp-code-type', is_config=True) type = __builtin__.property(_get_type, _set_type) code = __builtin__.property(_get_code, _set_code) diff --git a/src/sonic-config-engine/sonic-acl-extension.yang b/src/sonic-config-engine/sonic-acl-extension.yang index eac83b985f30..2ff9919b78d5 100644 --- a/src/sonic-config-engine/sonic-acl-extension.yang +++ b/src/sonic-config-engine/sonic-acl-extension.yang @@ -7,24 +7,39 @@ module sonic-acl-extension { import openconfig-acl { prefix oc-acl; } typedef vlan-id-type { - type uint16 { - range 0..4095; + type union { + type string { + pattern "null"; + } + type uint16 { + range 1..4095; + } } description "The VLAN ID value may be expressed as a 12-bit number in decimal notation"; } typedef icmp-type-type { - type uint8 { - range 0..255; + type union { + type string { + pattern "null"; + } + type uint8 { + range 0..255; + } } description "The ICMP type value may be expressed as an 8-bit number in decimal notation"; } typedef icmp-code-type { - type uint8 { - range 0..255; + type union { + type string { + pattern "null"; + } + type uint8 { + range 0..255; + } } description "The ICMP code value may be expressed as an 8-bit number in decimal notation"; From 2e1e7e095966834f5547e3f6252578bfcc26efe0 Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Tue, 2 Mar 2021 18:31:19 -0800 Subject: [PATCH 0248/1674] Fix Python 3 'importlib' bug; Add support for Python 2 back in sonic-py-common (#6933) Fix a strange bug introduced by https://github.com/Azure/sonic-buildimage/pull/6832 which would only occur in environments with both Python 2 and Python 3 installed (e.g., the PMon container). Error messages such as the following would be seen: ``` ERR pmon#ledd[29]: Failed to load ledutil: module 'importlib' has no attribute 'machinery' ``` This is very odd, and it seems like the Python 2 version of importlib, which is basically just a stub, is taking precedence over the Python 3 version. I found that this occurs when calling `import importlib`. However, calling `import importlib.machinery` and `import importlib.util` causes the proper package to be referenced, and the `machinery` and `util` modules are loaded successfully. This is how it is specified in examples in the official documentation, however there is nothing mentioned regarding that it *should* be done this way or that `import importlib` is unreliable. Also, since sonic-py-common is still used in environments with Python 2 installed we should maintain support for both Python 2 and 3 until we completely deprecate Python 2, so I have added this back in. --- src/sonic-ctrmgrd/tests/common_test.py | 3 ++- .../tests/determine-reboot-cause_test.py | 3 ++- .../tests/procdockerstatsd_test.py | 3 ++- .../sonic_py_common/daemon_base.py | 23 +++++++++++++++---- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/sonic-ctrmgrd/tests/common_test.py b/src/sonic-ctrmgrd/tests/common_test.py index 35447be7ad9a..5b3eae151cb0 100755 --- a/src/sonic-ctrmgrd/tests/common_test.py +++ b/src/sonic-ctrmgrd/tests/common_test.py @@ -1,5 +1,6 @@ import copy -import importlib +import importlib.machinery +import importlib.util import json import os import subprocess diff --git a/src/sonic-host-services/tests/determine-reboot-cause_test.py b/src/sonic-host-services/tests/determine-reboot-cause_test.py index 924befdf48ee..381313ba97f5 100644 --- a/src/sonic-host-services/tests/determine-reboot-cause_test.py +++ b/src/sonic-host-services/tests/determine-reboot-cause_test.py @@ -1,4 +1,5 @@ -import importlib +import importlib.machinery +import importlib.util import sys import os import pytest diff --git a/src/sonic-host-services/tests/procdockerstatsd_test.py b/src/sonic-host-services/tests/procdockerstatsd_test.py index db7c6a1f0e3d..bb218e52ce2d 100644 --- a/src/sonic-host-services/tests/procdockerstatsd_test.py +++ b/src/sonic-host-services/tests/procdockerstatsd_test.py @@ -1,4 +1,5 @@ -import importlib +import importlib.machinery +import importlib.util import sys import os import pytest diff --git a/src/sonic-py-common/sonic_py_common/daemon_base.py b/src/sonic-py-common/sonic_py_common/daemon_base.py index 3797c19b6b7d..745b3c55ba96 100644 --- a/src/sonic-py-common/sonic_py_common/daemon_base.py +++ b/src/sonic-py-common/sonic_py_common/daemon_base.py @@ -1,4 +1,3 @@ -import importlib import signal import sys @@ -26,12 +25,26 @@ def db_connect(db_name, namespace=EMPTY_NAMESPACE): return swsscommon.DBConnector(db_name, REDIS_TIMEOUT_MSECS, True, namespace) +# TODO: Consider moving this logic out of daemon_base and into antoher file +# so that it can be used by non-daemons. We can simply call that function here +# to retain backward compatibility. def _load_module_from_file(module_name, file_path): - loader = importlib.machinery.SourceFileLoader(module_name, file_path) - spec = importlib.util.spec_from_loader(loader.name, loader) - module = importlib.util.module_from_spec(spec) - loader.exec_module(module) + module = None + + # TODO: Remove this check once we no longer support Python 2 + if sys.version_info.major == 3: + import importlib.machinery + import importlib.util + loader = importlib.machinery.SourceFileLoader(module_name, file_path) + spec = importlib.util.spec_from_loader(loader.name, loader) + module = importlib.util.module_from_spec(spec) + loader.exec_module(module) + else: + import imp + module = imp.load_source(module_name, file_path) + sys.modules[module_name] = module + return module From 9d8a3bbdd8fec0233731ddc4f21e04a9e9ceb25a Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Mon, 22 Feb 2021 10:14:55 -0800 Subject: [PATCH 0249/1674] [minigraph] Support tagged VlanInterface if attached to multiple vlans (#6833) It is possible that one interface attaches multiple vlans. The VlanInterface should be in tagged mode. Signed-off-by: Qi Luo --- src/sonic-config-engine/minigraph.py | 9 +++++++++ .../tests/simple-sample-graph.xml | 16 ++++++++++++++++ src/sonic-config-engine/tests/test_cfggen.py | 14 +++++++++++--- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 06b799cdeff7..0635f9171ebd 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -526,6 +526,13 @@ def parse_dpg(dpg, hname): vlans = {} vlan_members = {} vlantype_name = "" + intf_vlan_mbr = defaultdict(list) + for vintf in vlanintfs.findall(str(QName(ns, "VlanInterface"))): + vlanid = vintf.find(str(QName(ns, "VlanID"))).text + vintfmbr = vintf.find(str(QName(ns, "AttachTo"))).text + vmbr_list = vintfmbr.split(';') + for i, member in enumerate(vmbr_list): + intf_vlan_mbr[member].append(vlanid) for vintf in vlanintfs.findall(str(QName(ns, "VlanInterface"))): vintfname = vintf.find(str(QName(ns, "Name"))).text vlanid = vintf.find(str(QName(ns, "VlanID"))).text @@ -539,6 +546,8 @@ def parse_dpg(dpg, hname): sonic_vlan_member_name = "Vlan%s" % (vlanid) if vlantype_name == "Tagged": vlan_members[(sonic_vlan_member_name, vmbr_list[i])] = {'tagging_mode': 'tagged'} + elif len(intf_vlan_mbr[member]) > 1: + vlan_members[(sonic_vlan_member_name, vmbr_list[i])] = {'tagging_mode': 'tagged'} else: vlan_members[(sonic_vlan_member_name, vmbr_list[i])] = {'tagging_mode': 'untagged'} diff --git a/src/sonic-config-engine/tests/simple-sample-graph.xml b/src/sonic-config-engine/tests/simple-sample-graph.xml index 7215209da545..703a005ea5bc 100644 --- a/src/sonic-config-engine/tests/simple-sample-graph.xml +++ b/src/sonic-config-engine/tests/simple-sample-graph.xml @@ -173,6 +173,22 @@ Tagged 192.168.0.0/28 + + ab2 + fortyGigE0/12 + 192.0.0.1;192.0.0.2 + 2000 + 2000 + 192.168.0.240/27 + + + ab3 + fortyGigE0/12 + 192.0.0.1;192.0.0.2 + 2001 + 2001 + 192.168.0.240/27 + diff --git a/src/sonic-config-engine/tests/test_cfggen.py b/src/sonic-config-engine/tests/test_cfggen.py index 3a85346de2fd..9fbf351c3a47 100644 --- a/src/sonic-config-engine/tests/test_cfggen.py +++ b/src/sonic-config-engine/tests/test_cfggen.py @@ -121,6 +121,8 @@ def test_var_json_data(self): utils.to_dict(output.strip()), utils.to_dict( '{\n "Vlan1000|Ethernet8": {\n "tagging_mode": "untagged"\n },' + ' \n "Vlan2000|Ethernet12": {\n "tagging_mode": "tagged"\n },' + ' \n "Vlan2001|Ethernet12": {\n "tagging_mode": "tagged"\n },' ' \n "Vlan2020|Ethernet12": {\n "tagging_mode": "tagged"\n }\n}' ) ) @@ -206,6 +208,8 @@ def test_minigraph_vlans(self): utils.to_dict(output.strip()), utils.to_dict( "{'Vlan1000': {'alias': 'ab1', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '1000'}, " + "'Vlan2001': {'alias': 'ab3', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '2001'}," + "'Vlan2000': {'alias': 'ab2', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '2000'}," "'Vlan2020': {'alias': 'kk1', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '2020'}}" ) ) @@ -214,9 +218,13 @@ def test_minigraph_vlan_members(self): argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v VLAN_MEMBER' output = self.run_script(argument) self.assertEqual( - output.strip(), - "{('Vlan1000', 'Ethernet8'): {'tagging_mode': 'untagged'}, " - "('Vlan2020', 'Ethernet12'): {'tagging_mode': 'tagged'}}" + utils.to_dict(output.strip()), + utils.to_dict( + "{('Vlan2000', 'Ethernet12'): {'tagging_mode': 'tagged'}, " + "('Vlan1000', 'Ethernet8'): {'tagging_mode': 'untagged'}, " + "('Vlan2020', 'Ethernet12'): {'tagging_mode': 'tagged'}, " + "('Vlan2001', 'Ethernet12'): {'tagging_mode': 'tagged'}}" + ) ) def test_minigraph_vlan_interfaces(self): From 3f999598281bb570e48b1a5734c44eacd5748ba9 Mon Sep 17 00:00:00 2001 From: Volodymyr Boiko <66446128+vboykox@users.noreply.github.com> Date: Wed, 3 Mar 2021 19:23:40 +0200 Subject: [PATCH 0250/1674] [platform][barefoot] Fix as9516bf installation (#6938) To fix sonic_platform installation on as9516bf platform Signed-off-by: Volodymyr Boyko --- .../debian/postinst | 27 ------------------- ...atform-modules-bfn-newport-as9516.postinst | 13 +++++++++ ...platform-modules-bfn-newport-as9516.prerm} | 0 ...form-modules-bfn-newport-as9516bf.postinst | 13 +++++++++ ...latform-modules-bfn-newport-as9516bf.prerm | 6 +++++ 5 files changed, 32 insertions(+), 27 deletions(-) delete mode 100644 platform/barefoot/sonic-platform-modules-bfn-newport/debian/postinst create mode 100644 platform/barefoot/sonic-platform-modules-bfn-newport/debian/sonic-platform-modules-bfn-newport-as9516.postinst rename platform/barefoot/sonic-platform-modules-bfn-newport/debian/{prerm => sonic-platform-modules-bfn-newport-as9516.prerm} (100%) create mode 100644 platform/barefoot/sonic-platform-modules-bfn-newport/debian/sonic-platform-modules-bfn-newport-as9516bf.postinst create mode 100644 platform/barefoot/sonic-platform-modules-bfn-newport/debian/sonic-platform-modules-bfn-newport-as9516bf.prerm diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/debian/postinst b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/postinst deleted file mode 100644 index 90d772ef89df..000000000000 --- a/platform/barefoot/sonic-platform-modules-bfn-newport/debian/postinst +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -set -e -depmod -a -systemctl enable bfn-newport.service -systemctl start bfn-newport.service - -PLATFORM_NAME=x86_64-accton_as9516bf_32d-r0 -SONIC_PLATFORM_WHEEL_PY2="/usr/share/sonic/device/${PLATFORM_NAME}/sonic_platform-1.0-py2-none-any.whl" -if [ -e ${SONIC_PLATFORM_WHEEL_PY2} ]; then - python2 -m pip install ${SONIC_PLATFORM_WHEEL_PY2} -fi -SONIC_PLATFORM_WHEEL_PY3="/usr/share/sonic/device/${PLATFORM_NAME}/sonic_platform-1.0-py3-none-any.whl" -if [ -e ${SONIC_PLATFORM_WHEEL_PY3} ]; then - python3 -m pip install ${SONIC_PLATFORM_WHEEL_PY3} -fi - -PLATFORM_NAME=x86_64-accton_as9516_32d-r0 -SONIC_PLATFORM_WHEEL_PY2="/usr/share/sonic/device/${PLATFORM_NAME}/sonic_platform-1.0-py2-none-any.whl" -if [ -e ${SONIC_PLATFORM_WHEEL_PY2} ]; then - python2 -m pip install ${SONIC_PLATFORM_WHEEL_PY2} -fi -SONIC_PLATFORM_WHEEL_PY3="/usr/share/sonic/device/${PLATFORM_NAME}/sonic_platform-1.0-py3-none-any.whl" -if [ -e ${SONIC_PLATFORM_WHEEL_PY3} ]; then - python3 -m pip install ${SONIC_PLATFORM_WHEEL_PY3} -fi - -#DEBHELPER# diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/debian/sonic-platform-modules-bfn-newport-as9516.postinst b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/sonic-platform-modules-bfn-newport-as9516.postinst new file mode 100644 index 000000000000..94dbd584f1b2 --- /dev/null +++ b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/sonic-platform-modules-bfn-newport-as9516.postinst @@ -0,0 +1,13 @@ +#!/bin/sh +set -e +depmod -a +systemctl enable bfn-newport.service +systemctl start bfn-newport.service + +PLATFORM_NAME=x86_64-accton_as9516_32d-r0 +SONIC_PLATFORM_WHEEL_PY2="/usr/share/sonic/device/${PLATFORM_NAME}/sonic_platform-1.0-py2-none-any.whl" +python2 -m pip install ${SONIC_PLATFORM_WHEEL_PY2} +SONIC_PLATFORM_WHEEL_PY3="/usr/share/sonic/device/${PLATFORM_NAME}/sonic_platform-1.0-py3-none-any.whl" +python3 -m pip install ${SONIC_PLATFORM_WHEEL_PY3} + +#DEBHELPER# diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/debian/prerm b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/sonic-platform-modules-bfn-newport-as9516.prerm similarity index 100% rename from platform/barefoot/sonic-platform-modules-bfn-newport/debian/prerm rename to platform/barefoot/sonic-platform-modules-bfn-newport/debian/sonic-platform-modules-bfn-newport-as9516.prerm diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/debian/sonic-platform-modules-bfn-newport-as9516bf.postinst b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/sonic-platform-modules-bfn-newport-as9516bf.postinst new file mode 100644 index 000000000000..87ca2f5de64b --- /dev/null +++ b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/sonic-platform-modules-bfn-newport-as9516bf.postinst @@ -0,0 +1,13 @@ +#!/bin/sh +set -e +depmod -a +systemctl enable bfn-newport.service +systemctl start bfn-newport.service + +PLATFORM_NAME=x86_64-accton_as9516bf_32d-r0 +SONIC_PLATFORM_WHEEL_PY2="/usr/share/sonic/device/${PLATFORM_NAME}/sonic_platform-1.0-py2-none-any.whl" +python2 -m pip install ${SONIC_PLATFORM_WHEEL_PY2} +SONIC_PLATFORM_WHEEL_PY3="/usr/share/sonic/device/${PLATFORM_NAME}/sonic_platform-1.0-py3-none-any.whl" +python3 -m pip install ${SONIC_PLATFORM_WHEEL_PY3} + +#DEBHELPER# diff --git a/platform/barefoot/sonic-platform-modules-bfn-newport/debian/sonic-platform-modules-bfn-newport-as9516bf.prerm b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/sonic-platform-modules-bfn-newport-as9516bf.prerm new file mode 100644 index 000000000000..ee19dbb1db98 --- /dev/null +++ b/platform/barefoot/sonic-platform-modules-bfn-newport/debian/sonic-platform-modules-bfn-newport-as9516bf.prerm @@ -0,0 +1,6 @@ +#!/bin/sh + +python2 -m pip uninstall -y sonic-platform +python3 -m pip uninstall -y sonic-platform + +#DEBHELPER# From 84a091d99c8df4120f1f9429dc1398bc9cb88c58 Mon Sep 17 00:00:00 2001 From: vdahiya12 <67608553+vdahiya12@users.noreply.github.com> Date: Thu, 4 Mar 2021 09:42:30 -0800 Subject: [PATCH 0251/1674] [sonic-platform-daemons] submodule update (#6957) 30d09be fix the muxcable state change notification received from other modules, omit the check inside hw_state table (#159) 32ec23c [xcvrd] Fix crash on platforms which support media settings with Python 3 (#158) 47bcf90 [xcvrd] Save the dom_capability of transceiver into db (#72) b9381a5 [xcvrd] Fix xcvrd crash on other port prefixes (#123) c3c1a59 [xcvrd] Make functions used for media setting python3 compatible (#153) e179ffc [psud] Refactor unit tests; increase unit test coverage (#146) Signed-off-by: vaibhav-dahiya --- src/sonic-platform-daemons | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-platform-daemons b/src/sonic-platform-daemons index 068bcccf1f30..30d09be2be7a 160000 --- a/src/sonic-platform-daemons +++ b/src/sonic-platform-daemons @@ -1 +1 @@ -Subproject commit 068bcccf1f3057607b8f37709033d7f44a6ff844 +Subproject commit 30d09be2be7acdb1c3349e2c0e4650bb2d25fade From 57085e4a6ac0914abfea202cf13f3014515d503f Mon Sep 17 00:00:00 2001 From: mssonicbld <79238446+mssonicbld@users.noreply.github.com> Date: Fri, 5 Mar 2021 13:45:16 +0800 Subject: [PATCH 0252/1674] Update SONiC version files (#6963) Co-authored-by: mssonicbld --- .../build/build-sonic-slave-buster/versions-deb-buster | 1 - files/build/versions/default/versions-py3 | 4 ++-- files/build/versions/host-image/versions-deb-buster | 4 ++-- files/build/versions/host-image/versions-py3 | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster b/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster index 44be902df6cc..3681bae194bf 100644 --- a/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster +++ b/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster @@ -91,7 +91,6 @@ python3-yang==1.0.73 sonic-mgmt-common==1.0.0 sonic-mgmt-common-codegen==1.0.0 sonic-mgmt-framework==1.0-01 -swss==1.0.0 sx-acl-helper==1.mlnx.4.4.2308 sx-acl-helper-dev==1.mlnx.4.4.2308 sx-complib==1.mlnx.4.4.2308 diff --git a/files/build/versions/default/versions-py3 b/files/build/versions/default/versions-py3 index b00f6be0ec4c..791915bc3931 100644 --- a/files/build/versions/default/versions-py3 +++ b/files/build/versions/default/versions-py3 @@ -6,7 +6,7 @@ click==7.1.2 clickclick==20.10.2 connexion==2.7.0 Flask==1.1.2 -grpcio==1.36.0 +grpcio==1.36.1 grpcio-tools==1.20.0 hiredis==1.1.0 idna==2.10 @@ -25,7 +25,7 @@ netaddr==0.8.0 netifaces==0.10.9 openapi-schema-validator==0.1.4 openapi-spec-validator==0.3.0 -protobuf==3.15.3 +protobuf==3.15.4 psutil==5.8.0 pyang==2.4.0 pyangbind==0.8.1 diff --git a/files/build/versions/host-image/versions-deb-buster b/files/build/versions/host-image/versions-deb-buster index 01cb7447bb94..54d76cf5f81d 100644 --- a/files/build/versions/host-image/versions-deb-buster +++ b/files/build/versions/host-image/versions-deb-buster @@ -42,8 +42,8 @@ gpg-wks-client==2.2.12-1+deb10u1 gpg-wks-server==2.2.12-1+deb10u1 gpgconf==2.2.12-1+deb10u1 gpgsm==2.2.12-1+deb10u1 -grub-common==2.02+dfsg1-20+deb10u3 -grub2-common==2.02+dfsg1-20+deb10u3 +grub-common==2.02+dfsg1-20+deb10u4 +grub2-common==2.02+dfsg1-20+deb10u4 haveged==1.9.1-7 hdparm==9.58+ds-1 hping3==3.a2.ds2-7 diff --git a/files/build/versions/host-image/versions-py3 b/files/build/versions/host-image/versions-py3 index 661e6c171995..e83b16af1be5 100644 --- a/files/build/versions/host-image/versions-py3 +++ b/files/build/versions/host-image/versions-py3 @@ -40,5 +40,5 @@ tabulate==0.8.2 thrift==0.13.0 urllib3==1.26.3 watchdog==0.10.3 -websocket-client==0.57.0 +websocket-client==0.58.0 xmltodict==0.12.0 \ No newline at end of file From 1650777723555a74c7bf9e6a3632b039038f7581 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Fri, 26 Feb 2021 10:41:49 -0800 Subject: [PATCH 0253/1674] [minigraph] For egress ACL attaching to vlan, break them into vlan members (#6895) #### Why I did it Some platforms have difficult to attach egress ACL to vlan. #### How I did it For egress ACL attaching to vlan, break them into vlan members. #### How to verify it Unit test Tested in DUT --- src/sonic-config-engine/minigraph.py | 19 ++++++++++++++----- .../tests/t0-sample-graph.xml | 16 +++++++++++++++- src/sonic-config-engine/tests/test_cfggen.py | 10 +++++----- .../tests/test_minigraph_case.py | 2 +- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 0635f9171ebd..70f7f839f91b 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -522,7 +522,6 @@ def parse_dpg(dpg, hname): dpg_ecmp_content['ipv4'] = ipv4_content dpg_ecmp_content['ipv6'] = ipv6_content vlanintfs = child.find(str(QName(ns, "VlanInterfaces"))) - vlan_intfs = [] vlans = {} vlan_members = {} vlantype_name = "" @@ -551,7 +550,7 @@ def parse_dpg(dpg, hname): else: vlan_members[(sonic_vlan_member_name, vmbr_list[i])] = {'tagging_mode': 'untagged'} - vlan_attributes = {'vlanid': vlanid} + vlan_attributes = {'vlanid': vlanid, 'members': vmbr_list } # If this VLAN requires a DHCP relay agent, it will contain a element # containing a list of DHCP server IPs @@ -579,7 +578,7 @@ def parse_dpg(dpg, hname): aclname = aclintf.find(str(QName(ns, "OutAcl"))).text.upper().replace(" ", "_").replace("-", "_") stage = "egress" else: - system.exit("Error: 'AclInterface' must contain either an 'InAcl' or 'OutAcl' subelement.") + sys.exit("Error: 'AclInterface' must contain either an 'InAcl' or 'OutAcl' subelement.") aclattach = aclintf.find(str(QName(ns, "AttachTo"))).text.split(';') acl_intfs = [] is_mirror = False @@ -596,7 +595,11 @@ def parse_dpg(dpg, hname): # to LAG will be applied to all the LAG members internally by SAI/SDK acl_intfs.append(member) elif member in vlans: - acl_intfs.append(member) + # For egress ACL attaching to vlan, we break them into vlan members + if stage == "egress": + acl_intfs.extend(vlans[member]['members']) + else: + acl_intfs.append(member) elif member in port_alias_map: acl_intfs.append(port_alias_map[member]) # Give a warning if trying to attach ACL to a LAG member interface, correct way is to attach ACL to the LAG interface @@ -620,9 +623,15 @@ def parse_dpg(dpg, hname): acl_intfs.append(panel_port) break if acl_intfs: + # Remove duplications + dedup_intfs = [] + for intf in acl_intfs: + if intf not in dedup_intfs: + dedup_intfs.append(intf) + acls[aclname] = {'policy_desc': aclname, 'stage': stage, - 'ports': acl_intfs} + 'ports': dedup_intfs} if is_mirror: acls[aclname]['type'] = 'MIRROR' elif is_mirror_v6: diff --git a/src/sonic-config-engine/tests/t0-sample-graph.xml b/src/sonic-config-engine/tests/t0-sample-graph.xml index 63f892fe6d04..d3d0a7f93d53 100644 --- a/src/sonic-config-engine/tests/t0-sample-graph.xml +++ b/src/sonic-config-engine/tests/t0-sample-graph.xml @@ -260,6 +260,20 @@ + + Vlan98 + fortyGigE0/100;PortChannel01;PortChannel03 + False + 0.0.0.0/0 + + UserDefinedL2Vlan + 192.0.0.1;192.0.0.2 + 98 + 98 + + + + @@ -331,7 +345,7 @@ DataPlane - PortChannel01;PortChannel02 + PortChannel01;PortChannel02;Vlan98 DataAclEgress DataPlane diff --git a/src/sonic-config-engine/tests/test_cfggen.py b/src/sonic-config-engine/tests/test_cfggen.py index 9fbf351c3a47..89984a6fedd1 100644 --- a/src/sonic-config-engine/tests/test_cfggen.py +++ b/src/sonic-config-engine/tests/test_cfggen.py @@ -177,7 +177,7 @@ def test_minigraph_acl(self): "'DATAACLINGRESS': {'stage': 'ingress', 'type': 'L3', 'ports': ['PortChannel01', 'PortChannel02', 'PortChannel03', 'PortChannel04'], 'policy_desc': 'DATAACLINGRESS'}, " "'SNMP_ACL': {'services': ['SNMP'], 'type': 'CTRLPLANE', 'policy_desc': 'SNMP_ACL', 'stage': 'ingress'}, " "'SSH_ACL': {'services': ['SSH'], 'type': 'CTRLPLANE', 'policy_desc': 'SSH_ACL', 'stage': 'ingress'}, " - "'DATAACLEGRESS': {'stage': 'egress', 'type': 'L3', 'ports': ['PortChannel01', 'PortChannel02'], 'policy_desc': 'DATAACLEGRESS'}, " + "'DATAACLEGRESS': {'stage': 'egress', 'type': 'L3', 'ports': ['PortChannel01', 'PortChannel02', 'Ethernet100', 'PortChannel03'], 'policy_desc': 'DATAACLEGRESS'}, " "'EVERFLOWV6': {'stage': 'ingress', 'type': 'MIRRORV6', 'ports': ['PortChannel01', 'PortChannel02', 'PortChannel03', 'PortChannel04', 'Ethernet4', 'Ethernet100'], 'policy_desc': 'EVERFLOWV6'}}" ) ) @@ -207,10 +207,10 @@ def test_minigraph_vlans(self): self.assertEqual( utils.to_dict(output.strip()), utils.to_dict( - "{'Vlan1000': {'alias': 'ab1', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '1000'}, " - "'Vlan2001': {'alias': 'ab3', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '2001'}," - "'Vlan2000': {'alias': 'ab2', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '2000'}," - "'Vlan2020': {'alias': 'kk1', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '2020'}}" + "{'Vlan1000': {'alias': 'ab1', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '1000', 'members': ['Ethernet8']}, " + "'Vlan2001': {'alias': 'ab3', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '2001', 'members': ['Ethernet12']}," + "'Vlan2000': {'alias': 'ab2', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '2000', 'members': ['Ethernet12']}," + "'Vlan2020': {'alias': 'kk1', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '2020', 'members': ['Ethernet12']}}" ) ) diff --git a/src/sonic-config-engine/tests/test_minigraph_case.py b/src/sonic-config-engine/tests/test_minigraph_case.py index 64e0bb09d730..806916639b76 100644 --- a/src/sonic-config-engine/tests/test_minigraph_case.py +++ b/src/sonic-config-engine/tests/test_minigraph_case.py @@ -94,7 +94,7 @@ def test_minigraph_vlans(self): output = self.run_script(argument) self.assertEqual( utils.to_dict(output.strip()), - utils.to_dict("{'Vlan1000': {'alias': 'ab1', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '1000', 'mac': '00:aa:bb:cc:dd:ee' }}") + utils.to_dict("{'Vlan1000': {'alias': 'ab1', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '1000', 'mac': '00:aa:bb:cc:dd:ee', 'members': ['Ethernet8'] }}") ) def test_minigraph_vlan_members(self): From 30e9f02f84998b530cec3f181dd56e8fab93d679 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Fri, 5 Mar 2021 14:04:33 -0800 Subject: [PATCH 0254/1674] [202012][swss][utilities] advance submodule head (#6969) swss: * c712c24 2021-03-04 | Update StateDB with error if state change failed, Update APP_DB in all state chg req (#1662) (HEAD -> 202012) [Prince Sunny] utilities: * 9a9bff4 2021-03-03 | [acl] Expand VLAN into VLAN members when creating an ACL table (#1475) (HEAD -> 202012) [Danny Allen] * d1e7d4e 2021-03-04 | [Mellanox] Change mellanox buffer migrator for new SKU Mellanox-SN2700-D40C8S8 (#1470) [Junchao-Mellanox] * a1df1b4 2021-03-03 | [acl-loader] Add support for matching on ICMP and VLAN info (#1469) [Danny Allen] * bab4a23 2021-03-03 | [config reload]: On dual ToR systems, cache ARP and FDB tables (#1465) [Lawrence Lee] Signed-off-by: Ying Xie --- src/sonic-swss | 2 +- src/sonic-utilities | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sonic-swss b/src/sonic-swss index 9376ec694925..c712c244a61a 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit 9376ec694925c5cd715870e48a5aec7c8060c8a8 +Subproject commit c712c244a61a61fa593866a7c4bbc354ce318c2d diff --git a/src/sonic-utilities b/src/sonic-utilities index d2f0e8fdd74b..9a9bff42d193 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit d2f0e8fdd74b21700d535843ca30c12d448bd04d +Subproject commit 9a9bff42d1931ba0cd006569410e99fd989c6d32 From 7452720d01256d9ddb234eb25de0476fa78b9dc3 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Sat, 6 Mar 2021 19:06:10 -0800 Subject: [PATCH 0255/1674] Revert "[sonic-platform-daemons] submodule update (#6957)" (#6979) This reverts commit 7034edc9af23ecedfb2251d757f36e3c58fcd2c8. --- src/sonic-platform-daemons | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-platform-daemons b/src/sonic-platform-daemons index 30d09be2be7a..068bcccf1f30 160000 --- a/src/sonic-platform-daemons +++ b/src/sonic-platform-daemons @@ -1 +1 @@ -Subproject commit 30d09be2be7acdb1c3349e2c0e4650bb2d25fade +Subproject commit 068bcccf1f3057607b8f37709033d7f44a6ff844 From e1f8c07d9edd245594d005ee81458910939d5571 Mon Sep 17 00:00:00 2001 From: Samuel Angebault Date: Mon, 8 Mar 2021 09:37:16 -0800 Subject: [PATCH 0256/1674] [Arista] Update platform drivers (#6946) - Provide `hw-management-generate-dump.sh` for `show techsupport` - Load `optoe3` for OSFP and QSFP-DD transceivers - Enhance reboot-cause caching robustness Signed-off-by: Samuel Angebault --- platform/barefoot/sonic-platform-modules-arista | 2 +- platform/broadcom/sonic-platform-modules-arista | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/barefoot/sonic-platform-modules-arista b/platform/barefoot/sonic-platform-modules-arista index 86f7b81834a1..6ec714040c57 160000 --- a/platform/barefoot/sonic-platform-modules-arista +++ b/platform/barefoot/sonic-platform-modules-arista @@ -1 +1 @@ -Subproject commit 86f7b81834a1093d1df644b09232ddacb40784ef +Subproject commit 6ec714040c5733d4c0b2e3feb347a1e980280bf9 diff --git a/platform/broadcom/sonic-platform-modules-arista b/platform/broadcom/sonic-platform-modules-arista index 86f7b81834a1..6ec714040c57 160000 --- a/platform/broadcom/sonic-platform-modules-arista +++ b/platform/broadcom/sonic-platform-modules-arista @@ -1 +1 @@ -Subproject commit 86f7b81834a1093d1df644b09232ddacb40784ef +Subproject commit 6ec714040c5733d4c0b2e3feb347a1e980280bf9 From 08307385032087ac1a682e7de79aff95763315dc Mon Sep 17 00:00:00 2001 From: mssonicbld <79238446+mssonicbld@users.noreply.github.com> Date: Tue, 9 Mar 2021 06:55:35 +0800 Subject: [PATCH 0257/1674] Update SONiC version files (#6972) Co-authored-by: mssonicbld --- .../build/build-sonic-slave-buster/versions-deb-buster | 2 +- files/build/versions/default/versions-deb-buster | 2 +- files/build/versions/default/versions-py3 | 2 +- files/build/versions/default/versions-web | 4 ++-- .../dockers/docker-sonic-mgmt-framework/versions-py3 | 2 +- .../dockers/docker-syncd-mlnx/versions-deb-buster | 9 +++++++++ .../dockers/sonic-slave-stretch/versions-deb-stretch | 2 +- files/build/versions/host-image/versions-deb-buster | 3 +-- files/build/versions/host-image/versions-py2 | 1 - 9 files changed, 17 insertions(+), 10 deletions(-) diff --git a/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster b/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster index 3681bae194bf..d8d78fd6470b 100644 --- a/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster +++ b/files/build/versions/build/build-sonic-slave-buster/versions-deb-buster @@ -42,7 +42,7 @@ libnl-route-3-dev==3.5.0-1 libpango1.0-dev==1.42.4-8~deb10u1 libpangoxft-1.0-0==1.42.4-8~deb10u1 libpixman-1-dev==0.36.0-1 -libsaibcm==4.3.0.13-1 +libsaibcm==4.3.3.1 libsaimetadata==1.0.0 libsaimetadata-dev==1.0.0 libsairedis==1.0.0 diff --git a/files/build/versions/default/versions-deb-buster b/files/build/versions/default/versions-deb-buster index 6a82e67ada8c..42b3e1f4a2d3 100644 --- a/files/build/versions/default/versions-deb-buster +++ b/files/build/versions/default/versions-deb-buster @@ -119,7 +119,7 @@ libreadline7==7.0-5 librrd-dev==1.7.1-2 librrd8==1.7.1-2 librtmp1==2.4+20151223.gitfa8646d.1-2 -libsaibcm==4.3.0.13-1 +libsaibcm==4.3.3.1 libsaimetadata==1.0.0 libsairedis==1.0.0 libsasl2-2==2.1.27+dfsg-1+deb10u1 diff --git a/files/build/versions/default/versions-py3 b/files/build/versions/default/versions-py3 index 791915bc3931..c7c2096220d2 100644 --- a/files/build/versions/default/versions-py3 +++ b/files/build/versions/default/versions-py3 @@ -25,7 +25,7 @@ netaddr==0.8.0 netifaces==0.10.9 openapi-schema-validator==0.1.4 openapi-spec-validator==0.3.0 -protobuf==3.15.4 +protobuf==3.15.5 psutil==5.8.0 pyang==2.4.0 pyangbind==0.8.1 diff --git a/files/build/versions/default/versions-web b/files/build/versions/default/versions-web index 38cd555295ad..9fa8fa8caee1 100644 --- a/files/build/versions/default/versions-web +++ b/files/build/versions/default/versions-web @@ -42,8 +42,8 @@ https://sonicstorage.blob.core.windows.net/debian/pool/main/n/net-snmp/net-snmp_ https://sonicstorage.blob.core.windows.net/debian/pool/main/n/net-snmp/net-snmp_5.7.3+dfsg.orig.tar.xz==6391ae27eb1ae34ff5530712bb1c4209 https://sonicstorage.blob.core.windows.net/packages/20190307/bcmcmd?sv=2015-04-05&sr=b&sig=sUdbU7oVbh5exbXXHVL5TDFBTWDDBASHeJ8Cp0B0TIc%3D&se=2038-05-06T22%3A34%3A19Z&sp=r==b8aefc751bdf93218716bca6797460ff https://sonicstorage.blob.core.windows.net/packages/20190307/dsserve?sv=2015-04-05&sr=b&sig=lk7BH3DtW%2F5ehc0Rkqfga%2BUCABI0UzQmDamBsZH9K6w%3D&se=2038-05-06T22%3A34%3A45Z&sp=r==f9d4b815ebb9be9f755dedca8a51170d -https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.0.13-1_amd64.deb?sv=2015-04-05&sr=b&sig=twfshldM6GQEphfU%2BQ4xmJlGJkv2Sy7KU1F72RYYM0A%3D&se=2034-10-22T06%3A00%3A45Z&sp=r==84fd57e010281c66d2343b68bd10f7a2 -https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.0.13-1_amd64.deb?sv=2015-04-05&sr=b&sig=e%2BBucofzEwCC%2BclqK1OeCi5YFpQAD4ID4FfODzszsuM%3D&se=2034-10-22T06%3A00%3A14Z&sp=r==d4f4fb23b955792d102351e23678eba8 +https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.3.1_amd64.deb?sv=2019-12-12&st=2021-03-03T00%3A37%3A16Z&se=2030-03-04T00%3A37%3A00Z&sr=b&sp=r&sig=xxnhJC%2FKsOvApuAlB1Yds8Uzzkdyy6fmWX%2BuJ4v0UYA%3D==5ddbdab8865d3c232f4d664edb7ff334 +https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.3.1_amd64.deb?sv=2019-12-12&st=2021-03-03T00%3A35%3A37Z&se=2030-03-04T00%3A35%3A00Z&sr=b&sp=r&sig=1miXMYs0%2BZ6v9Dpby1vSYsDezWDnr%2Be4gZ7Gi3kAQXE%3D==2f250ddee8fdab04956ad7dc3f0a5a70 https://sonicstorage.blob.core.windows.net/packages/cmake/cmake-data_3.13.2-1_bpo9%2B1_all.deb?st=2020-03-27T02%3A22%3A24Z&se=2100-03-26T19%3A00%3A00Z&sp=rl&sv=2018-03-28&sr=b&sig=Xby%2Bm3OZOjPB%2FSlDbHD65yDcPzAgoys%2FA3vK8RB4BzA%3D==147cf42f3a68f6d6f1e53d95a599a1af https://sonicstorage.blob.core.windows.net/packages/cmake/cmake_3.13.2-1_bpo9%2B1_amd64.deb?st=2020-03-27T02%3A27%3A21Z&se=2100-03-26T19%3A00%3A00Z&sp=rl&sv=2018-03-28&sr=b&sig=4MvmmDBQuicFEJYakLm7xCNU19yJ8GIP4ankFSnITKY%3D==e75c741e8b6918b8f03625e456fa0275 https://sonicstorage.blob.core.windows.net/packages/debian/smartmontools_6.6-1.debian.tar.xz?sv=2015-04-05&sr=b&sig=H0RFeC41MCvhTQCln85DuPLn5v2goozwz%2FB9sA9p5eQ%3D&se=2046-08-20T23%3A46%3A02Z&sp=r==47a284f4762f86ba24753ea75d85e6cb diff --git a/files/build/versions/dockers/docker-sonic-mgmt-framework/versions-py3 b/files/build/versions/dockers/docker-sonic-mgmt-framework/versions-py3 index 494327b626b8..9ecf272e6792 100644 --- a/files/build/versions/dockers/docker-sonic-mgmt-framework/versions-py3 +++ b/files/build/versions/dockers/docker-sonic-mgmt-framework/versions-py3 @@ -1,2 +1,2 @@ six==1.11.0 -zipp==3.4.0 \ No newline at end of file +zipp==3.4.1 \ No newline at end of file diff --git a/files/build/versions/dockers/docker-syncd-mlnx/versions-deb-buster b/files/build/versions/dockers/docker-syncd-mlnx/versions-deb-buster index 9a3346645c8d..147fc780a2bf 100644 --- a/files/build/versions/dockers/docker-syncd-mlnx/versions-deb-buster +++ b/files/build/versions/dockers/docker-syncd-mlnx/versions-deb-buster @@ -3,8 +3,17 @@ applibs-dev==1.mlnx.4.4.2308 iproute2==1.mlnx.4.4.2308 iproute2-dev==1.mlnx.4.4.2308 libelf1==0.176-1.1 +libexpat1-dev==2.2.6-2+deb10u1 +libpython-dev==2.7.16-1 +libpython2-dev==2.7.16-1 +libpython2.7-dev==2.7.16-2+deb10u1 mlnx-sai==1.mlnx.SAIRel1.18.1.0 +python-dev==2.7.16-1 +python-pkg-resources==40.8.0-1 python-sdk-api==1.mlnx.4.4.2308 +python-setuptools==40.8.0-1 +python2-dev==2.7.16-1 +python2.7-dev==2.7.16-2+deb10u1 sx-acl-helper==1.mlnx.4.4.2308 sx-acl-helper-dev==1.mlnx.4.4.2308 sx-complib==1.mlnx.4.4.2308 diff --git a/files/build/versions/dockers/sonic-slave-stretch/versions-deb-stretch b/files/build/versions/dockers/sonic-slave-stretch/versions-deb-stretch index 2863f0c1cc03..edc0de9766cf 100644 --- a/files/build/versions/dockers/sonic-slave-stretch/versions-deb-stretch +++ b/files/build/versions/dockers/sonic-slave-stretch/versions-deb-stretch @@ -334,7 +334,7 @@ libc6-dev-i386==2.24-11+deb9u4 libc6-dev-x32==2.24-11+deb9u4 libc6-i386==2.24-11+deb9u4 libc6-x32==2.24-11+deb9u4 -libcaca0==0.99.beta19-2.1~deb9u1 +libcaca0==0.99.beta19-2.1~deb9u2 libcacard0==1:2.5.0-3 libcairo-gobject2==1.14.8-1+deb9u1 libcairo2==1.14.8-1+deb9u1 diff --git a/files/build/versions/host-image/versions-deb-buster b/files/build/versions/host-image/versions-deb-buster index 54d76cf5f81d..4a30be01057c 100644 --- a/files/build/versions/host-image/versions-deb-buster +++ b/files/build/versions/host-image/versions-deb-buster @@ -47,7 +47,7 @@ grub2-common==2.02+dfsg1-20+deb10u4 haveged==1.9.1-7 hdparm==9.58+ds-1 hping3==3.a2.ds2-7 -hw-management==1.mlnx.7.0010.1300 +hw-management==1.mlnx.7.0010.2000 i2c-tools==4.1-1 ifmetric==0.3-5 ifupdown2==1.2.8-1 @@ -220,7 +220,6 @@ python-bottle==0.12.15-2+deb10u1 python-enum34==1.1.6-2 python-ipaddr==2.2.0-2 python-minimal==2.7.16-1 -python-scapy==2.4.0-2 python-smbus==4.1-1 python-sonic-platform-arista==1.0 python-swsscommon==1.0.0 diff --git a/files/build/versions/host-image/versions-py2 b/files/build/versions/host-image/versions-py2 index 1359a2472dc6..7b7f1c9f1946 100644 --- a/files/build/versions/host-image/versions-py2 +++ b/files/build/versions/host-image/versions-py2 @@ -22,7 +22,6 @@ python-apt==1.8.4.3 PyYAML==5.4.1 redis==3.5.3 scandir==1.10.0 -scapy==2.4.0 singledispatch==3.6.1 six==1.15.0 thrift==0.13.0 From 6f84018342168986b8f349b59f06af92cd05fcbc Mon Sep 17 00:00:00 2001 From: Junchao-Mellanox <57339448+Junchao-Mellanox@users.noreply.github.com> Date: Fri, 5 Mar 2021 06:12:59 +0800 Subject: [PATCH 0258/1674] Change buffer config for new SKU Mellanox-SN2700-D40C8S8 (#6926) #### Why I did it Change buffer config for new SKU Mellanox-SN2700-D40C8S8 #### How I did it Reuse the buffer config of SKU Mellanox-SN2700-D48C8 #### How to verify it Run sonic-mgmt qos test and all passed --- .../buffers_defaults_t0.j2 | 103 +----------------- .../buffers_defaults_t1.j2 | 103 +----------------- 2 files changed, 2 insertions(+), 204 deletions(-) mode change 100644 => 120000 device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t0.j2 mode change 100644 => 120000 device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t1.j2 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t0.j2 deleted file mode 100644 index c2bdb607d5a7..000000000000 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t0.j2 +++ /dev/null @@ -1,102 +0,0 @@ -{% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '7719936' %} -{% set ingress_lossless_pool_xoff = '1032192' %} -{% set egress_lossless_pool_size = '13945824' %} -{% set egress_lossy_pool_size = '7719936' %} - -{%- 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 %} - -{%- macro generate_buffer_pool_and_profiles() %} - "BUFFER_POOL": { - "ingress_lossless_pool": { - "size": "{{ ingress_lossless_pool_size }}", - "xoff": "{{ ingress_lossless_pool_xoff }}", - "type": "ingress", - "mode": "dynamic" - }, - "egress_lossless_pool": { - "size": "{{ egress_lossless_pool_size }}", - "type": "egress", - "mode": "dynamic" - }, - "egress_lossy_pool": { - "size": "{{ egress_lossy_pool_size }}", - "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" - } - }, -{%- 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 %} - } -{%- 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 %} - } -{%- endmacro %} - - diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t0.j2 new file mode 120000 index 000000000000..a1d24c418b3e --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t0.j2 @@ -0,0 +1 @@ +../Mellanox-SN2700-D48C8/buffers_defaults_t0.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t1.j2 deleted file mode 100644 index 6f444b61df43..000000000000 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t1.j2 +++ /dev/null @@ -1,102 +0,0 @@ -{% set default_cable = '5m' %} -{% set ingress_lossless_pool_size = '9686016' %} -{% set ingress_lossless_pool_xoff = '1179648' %} -{% set egress_lossless_pool_size = '13945824' %} -{% set egress_lossy_pool_size = '9686016' %} - -{%- 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 %} - -{%- macro generate_buffer_pool_and_profiles() %} - "BUFFER_POOL": { - "ingress_lossless_pool": { - "size": "{{ ingress_lossless_pool_size }}", - "xoff": "{{ ingress_lossless_pool_xoff }}", - "type": "ingress", - "mode": "dynamic" - }, - "egress_lossless_pool": { - "size": "{{ egress_lossless_pool_size }}", - "type": "egress", - "mode": "dynamic" - }, - "egress_lossy_pool": { - "size": "{{ egress_lossy_pool_size }}", - "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" - } - }, -{%- 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 %} - } -{%- 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 %} - } -{%- endmacro %} - - diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t1.j2 new file mode 120000 index 000000000000..bef0c9d9531c --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/buffers_defaults_t1.j2 @@ -0,0 +1 @@ +../Mellanox-SN2700-D48C8/buffers_defaults_t1.j2 \ No newline at end of file From 7ec9fbb678fdb10be7971a4af53c09086a5a3886 Mon Sep 17 00:00:00 2001 From: Tamer Ahmed Date: Thu, 4 Mar 2021 20:43:08 -0800 Subject: [PATCH 0259/1674] Start DHCP Relay When Helpers IPs Are Available (#6961) #### Why I did it It is possible to have DHCP relay configuration with no servers/ helpers which result in DHCP container to crash. This PR fixes this issue by not starting DHCP relay for vlans with no DHCP helpers. resolves: #6931 closes: #6931 #### How I did it Do not add program group for dhcp relay with not dhcp helpers #### How to verify it Unit test --- .../docker-dhcp-relay.supervisord.conf.j2 | 10 +++++----- .../tests/sample_output/py2/bgpd_frr.conf | 5 ++++- .../tests/sample_output/py2/bgpd_quagga.conf | 1 + .../py2/docker-dhcp-relay.supervisord.conf | 4 ++-- .../tests/sample_output/py2/frr.conf | 5 ++++- .../tests/sample_output/py2/ipinip.json | 2 +- .../tests/sample_output/py2/wait_for_intf.sh | 1 + .../tests/sample_output/py3/bgpd_frr.conf | 3 +++ .../tests/sample_output/py3/bgpd_quagga.conf | 1 + .../py3/docker-dhcp-relay.supervisord.conf | 4 ++-- .../tests/sample_output/py3/frr.conf | 3 +++ .../tests/sample_output/py3/ipinip.json | 2 +- .../tests/sample_output/py3/wait_for_intf.sh | 1 + .../tests/t0-sample-graph.xml | 19 +++++++++++++++++++ 14 files changed, 48 insertions(+), 13 deletions(-) diff --git a/dockers/docker-dhcp-relay/docker-dhcp-relay.supervisord.conf.j2 b/dockers/docker-dhcp-relay/docker-dhcp-relay.supervisord.conf.j2 index 19a6cc294f7f..debbc81af0d3 100644 --- a/dockers/docker-dhcp-relay/docker-dhcp-relay.supervisord.conf.j2 +++ b/dockers/docker-dhcp-relay/docker-dhcp-relay.supervisord.conf.j2 @@ -43,7 +43,7 @@ dependent_startup_wait_for=rsyslogd:running {# Count how many VLANs require a DHCP relay agent... #} {% set num_relays = { 'count': 0 } %} {% for vlan_name in VLAN_INTERFACE %} -{% if VLAN and vlan_name in VLAN and VLAN[vlan_name]['dhcp_servers'] %} +{% if VLAN and vlan_name in VLAN and 'dhcp_servers' in VLAN[vlan_name] and VLAN[vlan_name]['dhcp_servers']|length > 0 %} {% set _dummy = num_relays.update({'count': num_relays.count + 1}) %} {% endif %} {% endfor %} @@ -53,7 +53,7 @@ dependent_startup_wait_for=rsyslogd:running programs= {%- set add_preceding_comma = { 'flag': False } %} {% for vlan_name in VLAN_INTERFACE %} -{% if VLAN and vlan_name in VLAN and VLAN[vlan_name]['dhcp_servers'] %} +{% if VLAN and vlan_name in VLAN and 'dhcp_servers' in VLAN[vlan_name] and VLAN[vlan_name]['dhcp_servers']|length > 0 %} {% if add_preceding_comma.flag %},{% endif %} {% set _dummy = add_preceding_comma.update({'flag': True}) %} isc-dhcp-relay-{{ vlan_name }} @@ -64,7 +64,7 @@ isc-dhcp-relay-{{ vlan_name }} {# Create a program entry for each DHCP relay agent instance #} {% set relay_for_ipv4 = { 'flag': False } %} {% for vlan_name in VLAN_INTERFACE %} -{% if VLAN and vlan_name in VLAN and VLAN[vlan_name]['dhcp_servers'] %} +{% if VLAN and vlan_name in VLAN and 'dhcp_servers' in VLAN[vlan_name] and VLAN[vlan_name]['dhcp_servers']|length > 0 %} {% for dhcp_server in VLAN[vlan_name]['dhcp_servers'] %} {% if dhcp_server | ipv4 %} {% set _dummy = relay_for_ipv4.update({'flag': True}) %} @@ -107,7 +107,7 @@ dependent_startup_wait_for=start:exited programs= {%- set add_preceding_comma = { 'flag': False } %} {% for vlan_name in VLAN_INTERFACE %} -{% if VLAN and vlan_name in VLAN and VLAN[vlan_name]['dhcp_servers'] %} +{% if VLAN and vlan_name in VLAN and 'dhcp_servers' in VLAN[vlan_name] and VLAN[vlan_name]['dhcp_servers']|length > 0 %} {% if add_preceding_comma.flag %},{% endif %} {% set _dummy = add_preceding_comma.update({'flag': True}) %} dhcpmon-{{ vlan_name }} @@ -118,7 +118,7 @@ dhcpmon-{{ vlan_name }} {# Create a program entry for each DHCP MONitor instance #} {% set relay_for_ipv4 = { 'flag': False } %} {% for vlan_name in VLAN_INTERFACE %} -{% if VLAN and vlan_name in VLAN and VLAN[vlan_name]['dhcp_servers'] %} +{% if VLAN and vlan_name in VLAN and 'dhcp_servers' in VLAN[vlan_name] and VLAN[vlan_name]['dhcp_servers']|length > 0 %} {% for dhcp_server in VLAN[vlan_name]['dhcp_servers'] %} {% if dhcp_server | ipv4 %} {% set _dummy = relay_for_ipv4.update({'flag': True}) %} diff --git a/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr.conf b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr.conf index a312e7532620..4245076ad96f 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr.conf +++ b/src/sonic-config-engine/tests/sample_output/py2/bgpd_frr.conf @@ -33,7 +33,9 @@ ip prefix-list PL_LoopbackV4 permit 10.1.0.32/32 ! ipv6 prefix-list PL_LoopbackV6 permit fc00:1::/64 ! -ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 192.168.0.0/27 +ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 192.168.200.0/27 +! +ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 10 permit 192.168.0.0/27 ! ! ! @@ -57,6 +59,7 @@ router bgp 65100 network fc00:1::32/64 exit-address-family ! + network 192.168.200.1/27 network 192.168.0.1/27 ! ! diff --git a/src/sonic-config-engine/tests/sample_output/py2/bgpd_quagga.conf b/src/sonic-config-engine/tests/sample_output/py2/bgpd_quagga.conf index f75d9de9a30e..f5a4b22f0ee0 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/bgpd_quagga.conf +++ b/src/sonic-config-engine/tests/sample_output/py2/bgpd_quagga.conf @@ -27,6 +27,7 @@ router bgp 65100 network fc00:1::32/64 exit-address-family network 10.1.0.32/32 + network 192.168.200.1/27 network 192.168.0.1/27 neighbor 10.0.0.59 remote-as 64600 neighbor 10.0.0.59 description ARISTA02T1 diff --git a/src/sonic-config-engine/tests/sample_output/py2/docker-dhcp-relay.supervisord.conf b/src/sonic-config-engine/tests/sample_output/py2/docker-dhcp-relay.supervisord.conf index dad758947f22..1d5b61390438 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/docker-dhcp-relay.supervisord.conf +++ b/src/sonic-config-engine/tests/sample_output/py2/docker-dhcp-relay.supervisord.conf @@ -42,7 +42,7 @@ dependent_startup_wait_for=rsyslogd:running programs=isc-dhcp-relay-Vlan1000 [program:isc-dhcp-relay-Vlan1000] -command=/usr/sbin/dhcrelay -d -m discard -a %%h:%%p %%P --name-alias-map-file /tmp/port-name-alias-map.txt -id Vlan1000 -iu PortChannel02 -iu PortChannel03 -iu PortChannel04 -iu PortChannel01 192.0.0.1 192.0.0.2 +command=/usr/sbin/dhcrelay -d -m discard -a %%h:%%p %%P --name-alias-map-file /tmp/port-name-alias-map.txt -id Vlan1000 -iu Vlan2000 -iu PortChannel02 -iu PortChannel03 -iu PortChannel04 -iu PortChannel01 192.0.0.1 192.0.0.2 priority=3 autostart=false autorestart=false @@ -56,7 +56,7 @@ dependent_startup_wait_for=start:exited programs=dhcpmon-Vlan1000 [program:dhcpmon-Vlan1000] -command=/usr/sbin/dhcpmon -id Vlan1000 -iu PortChannel02 -iu PortChannel03 -iu PortChannel04 -iu PortChannel01 -im eth0 +command=/usr/sbin/dhcpmon -id Vlan1000 -iu Vlan2000 -iu PortChannel02 -iu PortChannel03 -iu PortChannel04 -iu PortChannel01 -im eth0 priority=4 autostart=false autorestart=false diff --git a/src/sonic-config-engine/tests/sample_output/py2/frr.conf b/src/sonic-config-engine/tests/sample_output/py2/frr.conf index 43df66c3f4e7..0b0c22db6809 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/frr.conf +++ b/src/sonic-config-engine/tests/sample_output/py2/frr.conf @@ -56,7 +56,9 @@ ip prefix-list PL_LoopbackV4 permit 10.1.0.32/32 ! ipv6 prefix-list PL_LoopbackV6 permit fc00:1::/64 ! -ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 192.168.0.0/27 +ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 192.168.200.0/27 +! +ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 10 permit 192.168.0.0/27 ! ! ! @@ -80,6 +82,7 @@ router bgp 65100 network fc00:1::32/64 exit-address-family ! + network 192.168.200.1/27 network 192.168.0.1/27 ! ! diff --git a/src/sonic-config-engine/tests/sample_output/py2/ipinip.json b/src/sonic-config-engine/tests/sample_output/py2/ipinip.json index db70ea403121..62346451af04 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/ipinip.json +++ b/src/sonic-config-engine/tests/sample_output/py2/ipinip.json @@ -2,7 +2,7 @@ { "TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : { "tunnel_type":"IPINIP", - "dst_ip":"10.0.0.56,10.0.0.58,10.0.0.60,10.0.0.62,10.1.0.32,192.168.0.1", + "dst_ip":"10.0.0.56,10.0.0.58,10.0.0.60,10.0.0.62,10.1.0.32,192.168.0.1,192.168.200.1", "dscp_mode":"pipe", "ecn_mode":"copy_from_outer", "ttl_mode":"pipe" diff --git a/src/sonic-config-engine/tests/sample_output/py2/wait_for_intf.sh b/src/sonic-config-engine/tests/sample_output/py2/wait_for_intf.sh index 2af5cee2f005..4852f6167bad 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/wait_for_intf.sh +++ b/src/sonic-config-engine/tests/sample_output/py2/wait_for_intf.sh @@ -23,6 +23,7 @@ function wait_until_iface_ready # Wait for all interfaces with IPv4 addresses to be up and ready +wait_until_iface_ready Vlan2000 192.168.200.1/27 wait_until_iface_ready Vlan1000 192.168.0.1/27 wait_until_iface_ready PortChannel02 10.0.0.58/31 wait_until_iface_ready PortChannel03 10.0.0.60/31 diff --git a/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr.conf b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr.conf index a312e7532620..b8a7f2568232 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/bgpd_frr.conf @@ -35,6 +35,8 @@ ipv6 prefix-list PL_LoopbackV6 permit fc00:1::/64 ! ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 192.168.0.0/27 ! +ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 10 permit 192.168.200.0/27 +! ! ! router bgp 65100 @@ -58,6 +60,7 @@ router bgp 65100 exit-address-family ! network 192.168.0.1/27 + network 192.168.200.1/27 ! ! ! diff --git a/src/sonic-config-engine/tests/sample_output/py3/bgpd_quagga.conf b/src/sonic-config-engine/tests/sample_output/py3/bgpd_quagga.conf index 16eb6095463b..72988e555261 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/bgpd_quagga.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/bgpd_quagga.conf @@ -28,6 +28,7 @@ router bgp 65100 network fc00:1::32/64 exit-address-family network 192.168.0.1/27 + network 192.168.200.1/27 neighbor 10.0.0.57 remote-as 64600 neighbor 10.0.0.57 description ARISTA01T1 address-family ipv4 diff --git a/src/sonic-config-engine/tests/sample_output/py3/docker-dhcp-relay.supervisord.conf b/src/sonic-config-engine/tests/sample_output/py3/docker-dhcp-relay.supervisord.conf index e2135d05296b..8b836dec38af 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/docker-dhcp-relay.supervisord.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/docker-dhcp-relay.supervisord.conf @@ -42,7 +42,7 @@ dependent_startup_wait_for=rsyslogd:running programs=isc-dhcp-relay-Vlan1000 [program:isc-dhcp-relay-Vlan1000] -command=/usr/sbin/dhcrelay -d -m discard -a %%h:%%p %%P --name-alias-map-file /tmp/port-name-alias-map.txt -id Vlan1000 -iu PortChannel01 -iu PortChannel02 -iu PortChannel03 -iu PortChannel04 192.0.0.1 192.0.0.2 +command=/usr/sbin/dhcrelay -d -m discard -a %%h:%%p %%P --name-alias-map-file /tmp/port-name-alias-map.txt -id Vlan1000 -iu Vlan2000 -iu PortChannel01 -iu PortChannel02 -iu PortChannel03 -iu PortChannel04 192.0.0.1 192.0.0.2 priority=3 autostart=false autorestart=false @@ -56,7 +56,7 @@ dependent_startup_wait_for=start:exited programs=dhcpmon-Vlan1000 [program:dhcpmon-Vlan1000] -command=/usr/sbin/dhcpmon -id Vlan1000 -iu PortChannel01 -iu PortChannel02 -iu PortChannel03 -iu PortChannel04 -im eth0 +command=/usr/sbin/dhcpmon -id Vlan1000 -iu Vlan2000 -iu PortChannel01 -iu PortChannel02 -iu PortChannel03 -iu PortChannel04 -im eth0 priority=4 autostart=false autorestart=false diff --git a/src/sonic-config-engine/tests/sample_output/py3/frr.conf b/src/sonic-config-engine/tests/sample_output/py3/frr.conf index bb3c4e214e20..032eb26c5337 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/frr.conf +++ b/src/sonic-config-engine/tests/sample_output/py3/frr.conf @@ -58,6 +58,8 @@ ipv6 prefix-list PL_LoopbackV6 permit fc00:1::/64 ! ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 192.168.0.0/27 ! +ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 10 permit 192.168.200.0/27 +! ! ! router bgp 65100 @@ -81,6 +83,7 @@ router bgp 65100 exit-address-family ! network 192.168.0.1/27 + network 192.168.200.1/27 ! ! ! diff --git a/src/sonic-config-engine/tests/sample_output/py3/ipinip.json b/src/sonic-config-engine/tests/sample_output/py3/ipinip.json index db70ea403121..62346451af04 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/ipinip.json +++ b/src/sonic-config-engine/tests/sample_output/py3/ipinip.json @@ -2,7 +2,7 @@ { "TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : { "tunnel_type":"IPINIP", - "dst_ip":"10.0.0.56,10.0.0.58,10.0.0.60,10.0.0.62,10.1.0.32,192.168.0.1", + "dst_ip":"10.0.0.56,10.0.0.58,10.0.0.60,10.0.0.62,10.1.0.32,192.168.0.1,192.168.200.1", "dscp_mode":"pipe", "ecn_mode":"copy_from_outer", "ttl_mode":"pipe" diff --git a/src/sonic-config-engine/tests/sample_output/py3/wait_for_intf.sh b/src/sonic-config-engine/tests/sample_output/py3/wait_for_intf.sh index 6d90afa60ad7..68a3a830f068 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/wait_for_intf.sh +++ b/src/sonic-config-engine/tests/sample_output/py3/wait_for_intf.sh @@ -24,6 +24,7 @@ function wait_until_iface_ready # Wait for all interfaces with IPv4 addresses to be up and ready wait_until_iface_ready Vlan1000 192.168.0.1/27 +wait_until_iface_ready Vlan2000 192.168.200.1/27 wait_until_iface_ready PortChannel01 10.0.0.56/31 wait_until_iface_ready PortChannel02 10.0.0.58/31 wait_until_iface_ready PortChannel03 10.0.0.60/31 diff --git a/src/sonic-config-engine/tests/t0-sample-graph.xml b/src/sonic-config-engine/tests/t0-sample-graph.xml index d3d0a7f93d53..9f416d008d33 100644 --- a/src/sonic-config-engine/tests/t0-sample-graph.xml +++ b/src/sonic-config-engine/tests/t0-sample-graph.xml @@ -246,6 +246,20 @@ + + Vlan2000 + fortyGigE0/112;fortyGigE0/116;fortyGigE0/120 + False + 0.0.0.0/0 + + + + 2000 + 2000 + 192.168.200.0/27 + + + Vlan99 fortyGigE0/100 @@ -321,6 +335,11 @@ Vlan1000 192.168.0.1/27 + + + Vlan2000 + 192.168.200.1/27 + From e60603cd964a74c367e8857f6b27a4d86f829335 Mon Sep 17 00:00:00 2001 From: anish-n <44376847+anish-n@users.noreply.github.com> Date: Fri, 5 Mar 2021 10:17:56 -0800 Subject: [PATCH 0260/1674] [minigraph] Adjust minigraph parsing per Fine Grained ECMP matchmode changes (#6885) To adjust config db generated via minigraph per matchmode changes in fine grained ecmp. The changes are done so that nexthop IP based filtering can occur to determine routes as requiring Fine Grained ECMP, in the past the only mode was to use the IP prefix of the route for filtering, with this matchmode change we will use nexthop IP based filtering Azure/SONiC#727 How I did it Change will modify config db entry created for FG_NHG to include 'match_mode': 'nexthop-based' so that nexthop IP based filtering can occur to determine routes as requiring Fine Grained ECMP. Changes also remove FG_NHG_PREFIX entry since its not needed under matchmode nexthop-based. --- src/sonic-config-engine/minigraph.py | 31 +++++--------------- src/sonic-config-engine/tests/test_cfggen.py | 15 +++++----- 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 70f7f839f91b..47db73c34f29 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -146,7 +146,6 @@ def formulate_fine_grained_ecmp(version, dpg_ecmp_content, port_device_map, port tag = "fgnhg_v6" port_nhip_map = dpg_ecmp_content['port_nhip_map'] - nhgaddr = dpg_ecmp_content['nhgaddr'] nhg_int = dpg_ecmp_content['nhg_int'] nhip_device_map = {port_nhip_map[x]: port_device_map[x] for x in port_device_map @@ -159,20 +158,17 @@ def formulate_fine_grained_ecmp(version, dpg_ecmp_content, port_device_map, port FG_NHG_MEMBER = {ip: {"FG_NHG": tag, "bank": bank} for ip, bank in nhip_bank_map.items()} nhip_port_map = dict(zip(port_nhip_map.values(), port_nhip_map.keys())) - - for nhip, memberinfo in FG_NHG_MEMBER.items(): if nhip in nhip_port_map: memberinfo["link"] = port_alias_map[nhip_port_map[nhip]] FG_NHG_MEMBER[nhip] = memberinfo - FG_NHG_PREFIX = {nhgaddr: {"FG_NHG": tag}} - FG_NHG = {tag: {"bucket_size": LCM}} + FG_NHG = {tag: {"bucket_size": LCM, "match_mode": "nexthop-based"}} for ip in nhip_bank_map: neigh_key.append(str(nhg_int + "|" + ip)) NEIGH = {neigh_key: {"family": family} for neigh_key in neigh_key} - fine_grained_content = {"FG_NHG_MEMBER": FG_NHG_MEMBER, "FG_NHG": FG_NHG, "FG_NHG_PREFIX": FG_NHG_PREFIX, "NEIGH": NEIGH} + fine_grained_content = {"FG_NHG_MEMBER": FG_NHG_MEMBER, "FG_NHG": FG_NHG, "NEIGH": NEIGH} return fine_grained_content def parse_png(png, hname, dpg_ecmp_content = None): @@ -189,7 +185,6 @@ def parse_png(png, hname, dpg_ecmp_content = None): port_device_map = {} png_ecmp_content = {} FG_NHG_MEMBER = {} - FG_NHG_PREFIX = {} FG_NHG = {} NEIGH = {} @@ -292,12 +287,10 @@ def parse_png(png, hname, dpg_ecmp_content = None): for version, content in dpg_ecmp_content.items(): # version is ipv4 or ipv6 fine_grained_content = formulate_fine_grained_ecmp(version, content, port_device_map, port_alias_map) # port_alias_map FG_NHG_MEMBER.update(fine_grained_content['FG_NHG_MEMBER']) - FG_NHG_PREFIX.update(fine_grained_content['FG_NHG_PREFIX']) FG_NHG.update(fine_grained_content['FG_NHG']) NEIGH.update(fine_grained_content['NEIGH']) - png_ecmp_content = {"FG_NHG_PREFIX": FG_NHG_PREFIX, "FG_NHG_MEMBER": FG_NHG_MEMBER, "FG_NHG": FG_NHG, - "NEIGH": NEIGH} + png_ecmp_content = {"FG_NHG_MEMBER": FG_NHG_MEMBER, "FG_NHG": FG_NHG, "NEIGH": NEIGH} return (neighbors, devices, console_dev, console_port, mgmt_dev, mgmt_port, port_speeds, console_ports, mux_cable_ports, is_storage_device, png_ecmp_content) @@ -483,7 +476,6 @@ def parse_dpg(dpg, hname): pcs[pcintfname] = {'members': pcmbr_list, 'min_links': str(int(math.ceil(len(pcmbr_list) * 0.75)))} port_nhipv4_map = {} port_nhipv6_map = {} - nhgaddr = ["", ""] nhg_int = "" nhportlist = [] dpg_ecmp_content = {} @@ -507,20 +499,12 @@ def parse_dpg(dpg, hname): n = list(ipaddress.ip_network(UNICODE_TYPE(subnet_range), False).hosts()) if a in n: nhg_int = ip_intfs_map[subnet_range] - dwnstrms = child.find(str(QName(ns, "DownstreamSummarySet"))) - for dwnstrm in dwnstrms.findall(str(QName(ns, "DownstreamSummary"))): - dwnstrmentry = str(ET.tostring(dwnstrm)) - if ("FineGrainedECMPGroupDestination" in dwnstrmentry): - subnet_ip = dwnstrm.find(str(QName(ns1, "Subnet"))).text - truncsubnet_ip = subnet_ip.split("/")[0] - if "." in (truncsubnet_ip): - nhgaddr[0] = subnet_ip - elif ":" in (truncsubnet_ip): - nhgaddr[1] = subnet_ip - ipv4_content = {"port_nhip_map": port_nhipv4_map, "nhgaddr": nhgaddr[0], "nhg_int": nhg_int} - ipv6_content = {"port_nhip_map": port_nhipv6_map, "nhgaddr": nhgaddr[1], "nhg_int": nhg_int} + + ipv4_content = {"port_nhip_map": port_nhipv4_map, "nhg_int": nhg_int} + ipv6_content = {"port_nhip_map": port_nhipv6_map, "nhg_int": nhg_int} dpg_ecmp_content['ipv4'] = ipv4_content dpg_ecmp_content['ipv6'] = ipv6_content + vlanintfs = child.find(str(QName(ns, "VlanInterfaces"))) vlans = {} vlan_members = {} @@ -1490,7 +1474,6 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw if len(png_ecmp_content): results['FG_NHG_MEMBER'] = png_ecmp_content['FG_NHG_MEMBER'] - results['FG_NHG_PREFIX'] = png_ecmp_content['FG_NHG_PREFIX'] results['FG_NHG'] = png_ecmp_content['FG_NHG'] results['NEIGH'] = png_ecmp_content['NEIGH'] diff --git a/src/sonic-config-engine/tests/test_cfggen.py b/src/sonic-config-engine/tests/test_cfggen.py index 89984a6fedd1..f6edb58d15a9 100644 --- a/src/sonic-config-engine/tests/test_cfggen.py +++ b/src/sonic-config-engine/tests/test_cfggen.py @@ -233,9 +233,14 @@ def test_minigraph_vlan_interfaces(self): self.assertEqual(output.strip(), "[('Vlan1000', '192.168.0.1/27'), 'Vlan1000']") def test_minigraph_ecmp_fg_nhg(self): - argument = '-m "' + self.ecmp_graph + '" -p "' + self.mlnx_port_config + '" -v \"FG_NHG.values()|list\"' + argument = '-m "' + self.ecmp_graph + '" -p "' + self.mlnx_port_config + '" -v FG_NHG' output = self.run_script(argument) - self.assertEqual(output.strip(), "[{'bucket_size': 120}, {'bucket_size': 120}]") + print(output.strip()) + self.assertEqual(utils.to_dict(output.strip()), + utils.to_dict( + "{'fgnhg_v4': {'match_mode': 'nexthop-based', 'bucket_size': 120}, " + "'fgnhg_v6': {'match_mode': 'nexthop-based', 'bucket_size': 120}}" + )) def test_minigraph_ecmp_members(self): argument = '-m "' + self.ecmp_graph + '" -p "' + self.mlnx_port_config + '" -v "FG_NHG_MEMBER.keys()|list|sort"' @@ -254,12 +259,6 @@ def test_minigraph_ecmp_neighbors(self): " 'Vlan31|200:200:200:200::2', 'Vlan31|200:200:200:200::3', 'Vlan31|200:200:200:200::4', 'Vlan31|200:200:200:200::5', " "'Vlan31|200:200:200:200::6', 'Vlan31|200:200:200:200::7', 'Vlan31|200:200:200:200::8', 'Vlan31|200:200:200:200::9']") - def test_minigraph_ecmp_prefixes(self): - argument = '-m "' + self.ecmp_graph + '" -p "' + self.mlnx_port_config + '" -v "FG_NHG_PREFIX.keys()|list|sort"' - output = self.run_script(argument) - self.assertEqual(output.strip(), "['100.50.25.12/32', 'fc:5::/128']") - - def test_minigraph_portchannels(self): argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v PORTCHANNEL' output = self.run_script(argument) From 8b8c9665016a782fc723607f653685da61acc5ad Mon Sep 17 00:00:00 2001 From: Samuel Angebault Date: Fri, 5 Mar 2021 11:23:47 -0800 Subject: [PATCH 0261/1674] [Arista] Refresh device folder for DCS-7060DX4-32 (#6942) As booting on DCS-7060DX4-32 would use the default sku of DCS-7060PX4-32 which is not compatible, thus move some files around to properly separate the configurations that are device specific. Signed-off-by: Samuel Angebault --- device/arista/x86_64-arista_7060dx4_32/Arista-7060DX4-C32 | 1 - .../Arista-7060DX4-C32/port_config.ini | 0 .../Arista-7060DX4-C32/sai.profile | 0 .../Arista-7060DX4-C32/th3-a7060dx4-c32-32x400G.config.bcm | 0 device/arista/x86_64-arista_7060dx4_32/Arista-7060PX4-C64 | 1 - device/arista/x86_64-arista_7060dx4_32/Arista-7060PX4-O32 | 1 - device/arista/x86_64-arista_7060dx4_32/default_sku | 2 +- 7 files changed, 1 insertion(+), 4 deletions(-) delete mode 120000 device/arista/x86_64-arista_7060dx4_32/Arista-7060DX4-C32 rename device/arista/{x86_64-arista_7060px4_32 => x86_64-arista_7060dx4_32}/Arista-7060DX4-C32/port_config.ini (100%) rename device/arista/{x86_64-arista_7060px4_32 => x86_64-arista_7060dx4_32}/Arista-7060DX4-C32/sai.profile (100%) rename device/arista/{x86_64-arista_7060px4_32 => x86_64-arista_7060dx4_32}/Arista-7060DX4-C32/th3-a7060dx4-c32-32x400G.config.bcm (100%) delete mode 120000 device/arista/x86_64-arista_7060dx4_32/Arista-7060PX4-C64 delete mode 120000 device/arista/x86_64-arista_7060dx4_32/Arista-7060PX4-O32 mode change 120000 => 100644 device/arista/x86_64-arista_7060dx4_32/default_sku diff --git a/device/arista/x86_64-arista_7060dx4_32/Arista-7060DX4-C32 b/device/arista/x86_64-arista_7060dx4_32/Arista-7060DX4-C32 deleted file mode 120000 index 19cc64c75f13..000000000000 --- a/device/arista/x86_64-arista_7060dx4_32/Arista-7060DX4-C32 +++ /dev/null @@ -1 +0,0 @@ -../x86_64-arista_7060px4_32/Arista-7060DX4-C32 \ No newline at end of file diff --git a/device/arista/x86_64-arista_7060px4_32/Arista-7060DX4-C32/port_config.ini b/device/arista/x86_64-arista_7060dx4_32/Arista-7060DX4-C32/port_config.ini similarity index 100% rename from device/arista/x86_64-arista_7060px4_32/Arista-7060DX4-C32/port_config.ini rename to device/arista/x86_64-arista_7060dx4_32/Arista-7060DX4-C32/port_config.ini diff --git a/device/arista/x86_64-arista_7060px4_32/Arista-7060DX4-C32/sai.profile b/device/arista/x86_64-arista_7060dx4_32/Arista-7060DX4-C32/sai.profile similarity index 100% rename from device/arista/x86_64-arista_7060px4_32/Arista-7060DX4-C32/sai.profile rename to device/arista/x86_64-arista_7060dx4_32/Arista-7060DX4-C32/sai.profile diff --git a/device/arista/x86_64-arista_7060px4_32/Arista-7060DX4-C32/th3-a7060dx4-c32-32x400G.config.bcm b/device/arista/x86_64-arista_7060dx4_32/Arista-7060DX4-C32/th3-a7060dx4-c32-32x400G.config.bcm similarity index 100% rename from device/arista/x86_64-arista_7060px4_32/Arista-7060DX4-C32/th3-a7060dx4-c32-32x400G.config.bcm rename to device/arista/x86_64-arista_7060dx4_32/Arista-7060DX4-C32/th3-a7060dx4-c32-32x400G.config.bcm diff --git a/device/arista/x86_64-arista_7060dx4_32/Arista-7060PX4-C64 b/device/arista/x86_64-arista_7060dx4_32/Arista-7060PX4-C64 deleted file mode 120000 index f0d5c7697f08..000000000000 --- a/device/arista/x86_64-arista_7060dx4_32/Arista-7060PX4-C64 +++ /dev/null @@ -1 +0,0 @@ -../x86_64-arista_7060px4_32/Arista-7060PX4-C64 \ No newline at end of file diff --git a/device/arista/x86_64-arista_7060dx4_32/Arista-7060PX4-O32 b/device/arista/x86_64-arista_7060dx4_32/Arista-7060PX4-O32 deleted file mode 120000 index 1e0685f3fb42..000000000000 --- a/device/arista/x86_64-arista_7060dx4_32/Arista-7060PX4-O32 +++ /dev/null @@ -1 +0,0 @@ -../x86_64-arista_7060px4_32/Arista-7060PX4-O32 \ No newline at end of file diff --git a/device/arista/x86_64-arista_7060dx4_32/default_sku b/device/arista/x86_64-arista_7060dx4_32/default_sku deleted file mode 120000 index ebca56647346..000000000000 --- a/device/arista/x86_64-arista_7060dx4_32/default_sku +++ /dev/null @@ -1 +0,0 @@ -../x86_64-arista_7060px4_32/default_sku \ No newline at end of file diff --git a/device/arista/x86_64-arista_7060dx4_32/default_sku b/device/arista/x86_64-arista_7060dx4_32/default_sku new file mode 100644 index 000000000000..ed73fdf88eeb --- /dev/null +++ b/device/arista/x86_64-arista_7060dx4_32/default_sku @@ -0,0 +1 @@ +Arista-7060DX4-C32 t1 From 5f088e20afa55fd6ea7d5a3255351c0f508eb415 Mon Sep 17 00:00:00 2001 From: gechiang <62408185+gechiang@users.noreply.github.com> Date: Sun, 7 Mar 2021 12:40:15 -0800 Subject: [PATCH 0262/1674] BRCM SAI 4.3.3.1-1 pick up Temp Patch to fix Dual TOR ACL issue CS00011559393 (#6980) --- platform/broadcom/sai.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index 41e028ee2e1d..bc553755d6ee 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,8 +1,8 @@ -BRCM_SAI = libsaibcm_4.3.3.1_amd64.deb -$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.3.1_amd64.deb?sv=2019-12-12&st=2021-03-03T00%3A35%3A37Z&se=2030-03-04T00%3A35%3A00Z&sr=b&sp=r&sig=1miXMYs0%2BZ6v9Dpby1vSYsDezWDnr%2Be4gZ7Gi3kAQXE%3D" -BRCM_SAI_DEV = libsaibcm-dev_4.3.3.1_amd64.deb +BRCM_SAI = libsaibcm_4.3.3.1-1_amd64.deb +$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm_4.3.3.1-1_amd64.deb?sv=2015-04-05&sr=b&sig=n7KoEZ5wXY%2FobPAy62d9C%2BKyAkKo4PIdIAWwqnDBm3E%3D&se=2034-11-14T03%3A30%3A33Z&sp=r" +BRCM_SAI_DEV = libsaibcm-dev_4.3.3.1-1_amd64.deb $(eval $(call add_derived_package,$(BRCM_SAI),$(BRCM_SAI_DEV))) -$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.3.1_amd64.deb?sv=2019-12-12&st=2021-03-03T00%3A37%3A16Z&se=2030-03-04T00%3A37%3A00Z&sr=b&sp=r&sig=xxnhJC%2FKsOvApuAlB1Yds8Uzzkdyy6fmWX%2BuJ4v0UYA%3D" +$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/4.3/master/libsaibcm-dev_4.3.3.1-1_amd64.deb?sv=2015-04-05&sr=b&sig=EavLNMXA6OS3s9oD34bKbdtfYHppR4egkh7V7jc4gWM%3D&se=2034-11-14T03%3A31%3A04Z&sp=r" SONIC_ONLINE_DEBS += $(BRCM_SAI) $(BRCM_SAI_DEV)_DEPENDS += $(BRCM_SAI) From df89f6dcb63568bc59cabb00c04bcef04d6adee3 Mon Sep 17 00:00:00 2001 From: Wirut Getbamrung Date: Tue, 9 Mar 2021 01:10:11 +0700 Subject: [PATCH 0263/1674] [device/celestica]: Add xcvrd event support for Haliburton (#6517) #### Why I did it - The xcvrd service requires an event detection function, unplug or plug in the transceiver. #### How I did it - Add sysfs interrupt to notify userspace app of external interrupt - Implement get_change_event() in chassis api. - Also begin installing Python 3 sonic-platform package for Celestica platforms --- .../sonic_platform/chassis.py | 205 +++++++++++++++--- .../sonic_platform/event.py | 62 ++++++ .../x86_64-cel_e1031-r0/sonic_platform/fan.py | 8 + .../sonic_platform/helper.py | 133 ++++++++++++ .../x86_64-cel_e1031-r0/sonic_platform/sfp.py | 18 +- .../platform-modules-haliburton.install | 1 + .../sonic-platform-modules-cel/debian/rules | 13 +- .../platform_api/platform_api_mgnt.sh | 1 + 8 files changed, 393 insertions(+), 48 deletions(-) create mode 100644 device/celestica/x86_64-cel_e1031-r0/sonic_platform/event.py create mode 100644 device/celestica/x86_64-cel_e1031-r0/sonic_platform/helper.py diff --git a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/chassis.py b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/chassis.py index 40c4bb4ef73b..b6e2dea0f67c 100644 --- a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/chassis.py +++ b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/chassis.py @@ -13,13 +13,11 @@ import json try: + from sonic_platform_base.sonic_sfp.sfputilhelper import SfpUtilHelper from sonic_platform_base.chassis_base import ChassisBase - from sonic_platform.fan import Fan - from sonic_platform.psu import Psu - from sonic_platform.component import Component - from sonic_platform.thermal import Thermal - from sonic_platform.sfp import Sfp - from sonic_platform.eeprom import Tlv + from sonic_py_common import device_info + from .event import SfpEvent + from .helper import APIHelper except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -40,29 +38,62 @@ class Chassis(ChassisBase): def __init__(self): ChassisBase.__init__(self) - self.config_data = {} + self._api_helper = APIHelper() + self.sfp_module_initialized = False + self.__initialize_eeprom() + self.is_host = self._api_helper.is_host() + + + if not self.is_host: + self.__initialize_fan() + self.__initialize_psu() + self.__initialize_thermals() + else: + self.__initialize_components() + + self._reboot_cause_path = HOST_REBOOT_CAUSE_PATH if self.__is_host( + ) else PMON_REBOOT_CAUSE_PATH + + def __initialize_sfp(self): + sfputil_helper = SfpUtilHelper() + port_config_file_path = device_info.get_path_to_port_config_file() + sfputil_helper.read_porttab_mappings(port_config_file_path, 0) + + from sonic_platform.sfp import Sfp + for index in range(0, NUM_SFP): + name_idx = 0 if index+1 == NUM_SFP else index+1 + sfp = Sfp(index, sfputil_helper.logical[name_idx]) + self._sfp_list.append(sfp) + self.sfp_module_initialized = True + + def __initialize_psu(self): + from sonic_platform.psu import Psu + for index in range(0, NUM_PSU): + psu = Psu(index) + self._psu_list.append(psu) + + def __initialize_fan(self): + from sonic_platform.fan import Fan for fant_index in range(0, NUM_FAN_TRAY): for fan_index in range(0, NUM_FAN): fan = Fan(fant_index, fan_index) self._fan_list.append(fan) - for index in range(0, NUM_PSU): - psu = Psu(index) - self._psu_list.append(psu) + + def __initialize_thermals(self): + from sonic_platform.thermal import Thermal for index in range(0, NUM_THERMAL): thermal = Thermal(index) self._thermal_list.append(thermal) - # sfp index start from 1 - self._sfp_list.append(None) - for index in range(1, NUM_SFP+1): - sfp = Sfp(index) - self._sfp_list.append(sfp) + + def __initialize_eeprom(self): + from sonic_platform.eeprom import Tlv + self._eeprom = Tlv() + + def __initialize_components(self): + from sonic_platform.component import Component for index in range(0, NUM_COMPONENT): component = Component(index) self._component_list.append(component) - self._reboot_cause_path = HOST_REBOOT_CAUSE_PATH if self.__is_host( - ) else PMON_REBOOT_CAUSE_PATH - - self._eeprom = Tlv() def __is_host(self): return os.system(HOST_CHK_CMD) == 0 @@ -85,14 +116,6 @@ def get_base_mac(self): """ return self._eeprom.get_mac() - def get_serial(self): - """ - Retrieves the hardware serial number for the chassis - Returns: - A string containing the hardware serial number for this chassis. - """ - return self._eeprom.get_serial() - def get_system_eeprom_info(self): """ Retrieves the full content of system EEPROM information for the chassis @@ -116,7 +139,8 @@ def get_reboot_cause(self): """ description = 'None' reboot_cause = self.REBOOT_CAUSE_HARDWARE_OTHER - hw_reboot_cause = self._component_list[0].get_register_value(RESET_REGISTER) + hw_reboot_cause = self._component_list[0].get_register_value( + RESET_REGISTER) sw_reboot_cause = self.__read_txt_file( self._reboot_cause_path) or "Unknown" @@ -145,3 +169,128 @@ def get_watchdog(self): self._watchdog = Watchdog() return self._watchdog + + 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. + """ + # SFP event + if not self.sfp_module_initialized: + self.__initialize_sfp() + + sfp_event = SfpEvent(self._sfp_list).get_sfp_event(timeout) + if sfp_event: + return True, {'sfp': sfp_event} + + return False, {'sfp': {}} + + ############################################################## + ######################## 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 + """ + if not self.sfp_module_initialized: + self.__initialize_sfp() + + 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 + """ + if not self.sfp_module_initialized: + self.__initialize_sfp() + + return self._sfp_list + + def get_sfp(self, index): + """ + Retrieves sfp represented by (1-based) index + Args: + index: An integer, the index (1-based) of the sfp to retrieve. + The index should be the sequence of a physical port in a chassis, + starting from 1. + For example, 1 for Ethernet0, 2 for Ethernet4 and so on. + Returns: + An object dervied from SfpBase representing the specified sfp + """ + sfp = None + if not self.sfp_module_initialized: + self.__initialize_sfp() + + try: + # The index will start from 1 + sfp = self._sfp_list[index-1] + except IndexError: + sys.stderr.write("SFP index {} out of range (1-{})\n".format( + index, len(self._sfp_list))) + return sfp + + ############################################################## + ###################### Device methods ######################## + ############################################################## + + def get_name(self): + """ + Retrieves the name of the device + Returns: + string: The name of the device + """ + return self._api_helper.hwsku + + 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 device + Returns: + string: Model/part number of device + """ + return self._eeprom.get_pn() + + def get_serial(self): + """ + Retrieves the serial number of the device + Returns: + string: Serial number of device + """ + return self._eeprom.get_serial() + + def get_status(self): + """ + Retrieves the operational status of the device + Returns: + A boolean value, True if device is operating properly, False if not + """ + return True diff --git a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/event.py b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/event.py new file mode 100644 index 000000000000..c8a487f383ea --- /dev/null +++ b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/event.py @@ -0,0 +1,62 @@ +try: + import time + import select + from .helper import APIHelper + from sonic_py_common.logger import Logger +except ImportError as e: + raise ImportError(repr(e) + " - required module not found") + + +class SfpEvent: + ''' Listen to insert/remove sfp events ''' + + SFP_NUM_START = 49 + DELAY = 0.05 + INT_PATH = '/sys/devices/platform/e1031.smc/SFP/modabs_int' + GPIO_SUS7 = '/sys/devices/platform/hlx-ich.0/sci_int_gpio_sus7' + + def __init__(self, sfp_list): + self._api_helper = APIHelper() + self._sfp_list = sfp_list + self._logger = Logger() + + # clear interrupt + self._api_helper.read_one_line_file(self.INT_PATH) + + def get_sfp_event(self, timeout): + epoll = select.epoll() + port_dict = {} + timeout_sec = timeout/1000 + + try: + # We get notified when there is an SCI interrupt from GPIO SUS7 + fd = open(self.GPIO_SUS7, "r") + fd.read() + + epoll.register(fd.fileno(), select.EPOLLIN & select.EPOLLET) + events = epoll.poll(timeout=timeout_sec if timeout != 0 else -1) + if events: + # Read the QSFP ABS interrupt & status registers + port_changes = self._api_helper.read_one_line_file( + self.INT_PATH) + changes = int(port_changes, 16) + for sfp in self._sfp_list: + if sfp.port_num < self.SFP_NUM_START: + continue + + change = (changes >> sfp.port_num-self.SFP_NUM_START) & 1 + if change == 1: + time.sleep(self.DELAY) + port_status = sfp.get_presence() + port_dict[str(sfp.port_num)] = '1' if port_status else '0' + + return port_dict + except Exception as e: + self._logger.log_error("Failed to detect SfpEvent - " + repr(e)) + return False + + finally: + fd.close() + epoll.close() + + return False diff --git a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/fan.py b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/fan.py index 18cf513800aa..cebed613db92 100644 --- a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/fan.py +++ b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/fan.py @@ -247,3 +247,11 @@ def get_presence(self): present_str = self.__read_txt_file(fan_direction_file) or '1' return int(present_str) == 0 if not self.is_psu_fan else True + + def get_status(self): + """ + Retrieves the operational status of the device + Returns: + A boolean value, True if device is operating properly, False if not + """ + return self.get_presence() and self.get_speed() > 0 \ No newline at end of file diff --git a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/helper.py b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/helper.py new file mode 100644 index 000000000000..75449ab55185 --- /dev/null +++ b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/helper.py @@ -0,0 +1,133 @@ +import os +import struct +import subprocess +from mmap import * + +from sonic_py_common import device_info + +HOST_CHK_CMD = "docker > /dev/null 2>&1" +EMPTY_STRING = "" + + +class APIHelper(): + + def __init__(self): + (self.platform, self.hwsku) = device_info.get_platform_and_hwsku() + + def is_host(self): + return os.system(HOST_CHK_CMD) == 0 + + def pci_get_value(self, resource, offset): + status = True + result = "" + try: + fd = os.open(resource, os.O_RDWR) + mm = mmap(fd, 0) + mm.seek(int(offset)) + read_data_stream = mm.read(4) + result = struct.unpack('I', read_data_stream) + except Exception: + status = False + return status, result + + def run_command(self, cmd): + status = True + result = "" + try: + p = subprocess.Popen( + cmd, shell=True, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err == '': + result = raw_data.strip() + except Exception: + status = False + return status, result + + def run_interactive_command(self, cmd): + try: + os.system(cmd) + except Exception: + return False + return True + + 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 None + + def read_one_line_file(self, file_path): + try: + with open(file_path, 'r') as fd: + data = fd.readline() + return data.strip() + except IOError: + pass + return None + + def write_txt_file(self, file_path, value): + try: + with open(file_path, 'w') as fd: + fd.write(str(value)) + except Exception: + return False + return True + + def get_cpld_reg_value(self, getreg_path, register): + cmd = "echo {1} > {0}; cat {0}".format(getreg_path, register) + status, result = self.run_command(cmd) + return result if status else None + + def ipmi_raw(self, netfn, cmd): + status = True + result = "" + try: + cmd = "ipmitool raw {} {}".format(str(netfn), str(cmd)) + p = subprocess.Popen( + cmd, shell=True, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err == '': + result = raw_data.strip() + else: + status = False + except Exception: + status = False + return status, result + + def ipmi_fru_id(self, id, key=None): + status = True + result = "" + try: + cmd = "ipmitool fru print {}".format(str( + id)) if not key else "ipmitool fru print {0} | grep '{1}' ".format(str(id), str(key)) + + p = subprocess.Popen( + cmd, shell=True, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err == '': + result = raw_data.strip() + else: + status = False + except Exception: + status = False + return status, result + + def ipmi_set_ss_thres(self, id, threshold_key, value): + status = True + result = "" + try: + cmd = "ipmitool sensor thresh '{}' {} {}".format( + str(id), str(threshold_key), str(value)) + p = subprocess.Popen( + cmd, shell=True, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + raw_data, err = p.communicate() + if err == '': + result = raw_data.strip() + else: + status = False + except Exception: + status = False + return status, result diff --git a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/sfp.py b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/sfp.py index 608111d7e2fd..36ee9cbc01a0 100644 --- a/device/celestica/x86_64-cel_e1031-r0/sonic_platform/sfp.py +++ b/device/celestica/x86_64-cel_e1031-r0/sonic_platform/sfp.py @@ -16,7 +16,6 @@ from sonic_platform_base.sonic_sfp.sff8472 import sff8472Dom from sonic_platform_base.sonic_sfp.sff8472 import sff8472InterfaceId from sonic_platform_base.sonic_sfp.sff8472 import sffbase - from sonic_platform_base.sonic_sfp.sfputilhelper import SfpUtilHelper except ImportError as e: raise ImportError(str(e) + "- required module not found") @@ -88,10 +87,10 @@ class Sfp(SfpBase): PLATFORM = "x86_64-cel_e1031-r0" HWSKU = "Celestica-E1031-T48S4" - def __init__(self, sfp_index): + def __init__(self, sfp_index, sfp_name): # Init index self.index = sfp_index - self.port_num = self.index + self.port_num = self.index + 1 # Init eeprom path eeprom_path = '/sys/bus/i2c/devices/i2c-{0}/{0}-0050/eeprom' @@ -111,6 +110,7 @@ def __init__(self, sfp_index): self.threshold_dict_keys = ['temphighalarm', 'temphighwarning', 'templowalarm', 'templowwarning', 'vcchighalarm', 'vcchighwarning', 'vcclowalarm', 'vcclowwarning', 'rxpowerhighalarm', 'rxpowerhighwarning', 'rxpowerlowalarm', 'rxpowerlowwarning', 'txpowerhighalarm', 'txpowerhighwarning', 'txpowerlowalarm', 'txpowerlowwarning', 'txbiashighalarm', 'txbiashighwarning', 'txbiaslowalarm', 'txbiaslowwarning'] + self.name = sfp_name SfpBase.__init__(self) def _convert_string_to_num(self, value_str): @@ -145,12 +145,6 @@ def __read_txt_file(self, file_path): 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 __read_eeprom_specific_bytes(self, offset, num_bytes): sysfsfile_eeprom = None eeprom_raw = [] @@ -670,11 +664,7 @@ def get_name(self): Returns: string: The name of the device """ - sfputil_helper = SfpUtilHelper() - sfputil_helper.read_porttab_mappings( - self.__get_path_to_port_config_file()) - name = sfputil_helper.logical[self.index] or "Unknown" - return name + return self.name def get_presence(self): """ diff --git a/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-haliburton.install b/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-haliburton.install index 167de45532db..ec56777b9ffb 100644 --- a/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-haliburton.install +++ b/platform/broadcom/sonic-platform-modules-cel/debian/platform-modules-haliburton.install @@ -4,6 +4,7 @@ haliburton/script/fancontrol.sh etc/init.d haliburton/script/fancontrol.service lib/systemd/system services/fancontrol/fancontrol usr/local/bin haliburton/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-cel_e1031-r0 +haliburton/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-cel_e1031-r0 services/platform_api/platform_api_mgnt.sh usr/local/bin haliburton/script/popmsg.sh usr/local/bin haliburton/script/udev_prefix.sh usr/local/bin diff --git a/platform/broadcom/sonic-platform-modules-cel/debian/rules b/platform/broadcom/sonic-platform-modules-cel/debian/rules index a7293e0b6700..efb5aa47b437 100755 --- a/platform/broadcom/sonic-platform-modules-cel/debian/rules +++ b/platform/broadcom/sonic-platform-modules-cel/debian/rules @@ -13,13 +13,15 @@ MODULE_DIRS:= dx010 haliburton silverstone seastone2 override_dh_auto_build: (for mod in $(MODULE_DIRS); do \ make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \ - cd $(MOD_SRC_DIR)/$${mod}; \ - python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ - cd $(MOD_SRC_DIR); \ if [ $$mod = "seastone2" ]; then \ cd services/platform_api; \ - python2 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ - fi \ + python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ + python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ + continue; \ + fi; \ + cd $(MOD_SRC_DIR)/$${mod}; \ + python2.7 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ + python3 setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \ done) override_dh_auto_install: @@ -37,4 +39,3 @@ override_dh_clean: (for mod in $(MODULE_DIRS); do \ make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \ done) - diff --git a/platform/broadcom/sonic-platform-modules-cel/services/platform_api/platform_api_mgnt.sh b/platform/broadcom/sonic-platform-modules-cel/services/platform_api/platform_api_mgnt.sh index e1d330357894..493119bd37f6 100755 --- a/platform/broadcom/sonic-platform-modules-cel/services/platform_api/platform_api_mgnt.sh +++ b/platform/broadcom/sonic-platform-modules-cel/services/platform_api/platform_api_mgnt.sh @@ -9,6 +9,7 @@ install() { # Install sonic-platform package if [ -e $DEVICE/$PLATFORM/sonic_platform-1.0-py2-none-any.whl ]; then pip install $DEVICE/$PLATFORM/sonic_platform-1.0-py2-none-any.whl + pip3 install $device/$platform/sonic_platform-1.0-py3-none-any.whl fi } From d9e917507daa5d03c4d2a32f6c365b8682f7e56a Mon Sep 17 00:00:00 2001 From: vdahiya12 <67608553+vdahiya12@users.noreply.github.com> Date: Mon, 8 Mar 2021 10:16:25 -0800 Subject: [PATCH 0264/1674] [sonic-platform-common] submodule update (#6983) Includes the following commits: 1673d25 [y_cable] refactor upgrade firmware API's; Fix vendor and part number API's read size for read_eeprom (#174) ed93a15 [sonic_platform_base] Proper use of class and instance attributes (#173) 691de92 [sonic_y_cable] add stub function for upgrade firmware of Y cable and split the get_part_number and get_vendor API's (#171) Signed-off-by: vaibhav-dahiya --- src/sonic-platform-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sonic-platform-common b/src/sonic-platform-common index c6b642b03a64..1673d2594842 160000 --- a/src/sonic-platform-common +++ b/src/sonic-platform-common @@ -1 +1 @@ -Subproject commit c6b642b03a64fbd530b229a0a79d5bff9a938845 +Subproject commit 1673d25948428c10305674553095199b25cf89e5 From fdbb7fedd918948f8303eae933bac3553f7cb792 Mon Sep 17 00:00:00 2001 From: trzhang-msft Date: Tue, 9 Mar 2021 18:12:44 -0800 Subject: [PATCH 0265/1674] dhcp for dual tor: include all vlan intf into downstream intf (#6990) * include all vlan intf into downstream intf * add a comment --- src/isc-dhcp/patch/0009-Support-for-dual-tor-scenario.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/isc-dhcp/patch/0009-Support-for-dual-tor-scenario.patch b/src/isc-dhcp/patch/0009-Support-for-dual-tor-scenario.patch index e918cc619106..0f7495f49e7c 100644 --- a/src/isc-dhcp/patch/0009-Support-for-dual-tor-scenario.patch +++ b/src/isc-dhcp/patch/0009-Support-for-dual-tor-scenario.patch @@ -238,7 +238,7 @@ index e158efe..055d97f 100644 (flags & INTERFACE_UPSTREAM ? 'Y' : 'N'), (flags & INTERFACE_DOWNSTREAM ? 'Y' : 'N')); -+ if (flags & INTERFACE_DOWNSTREAM) { ++ if (flags & INTERFACE_DOWNSTREAM || flags & INTERFACE_UPSTREAM) { /* include all vlan intf in downstream_intf_list */ + ci = ((struct downstream_intf_list *)dmalloc(sizeof *ci, MDL)); + if (!ci) + log_fatal("no memory for downstream interface pointer.\n"); From 97426aff5afea36950d90765bfab7631c3414550 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Tue, 9 Mar 2021 18:15:16 -0800 Subject: [PATCH 0266/1674] [build]: Fix get-pip 2.7 url according to upstream announcement (#6999) ref: https://bootstrap.pypa.io/2.7/get-pip.py The URL you are using to fetch this script has changed, and this one will no longer work. Please use get-pip.py from the following URL instead: https://bootstrap.pypa.io/pip/2.7/get-pip.py --- dockers/docker-ptf/Dockerfile.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockers/docker-ptf/Dockerfile.j2 b/dockers/docker-ptf/Dockerfile.j2 index 43eefcd9eeff..eba818da9fcc 100644 --- a/dockers/docker-ptf/Dockerfile.j2 +++ b/dockers/docker-ptf/Dockerfile.j2 @@ -78,7 +78,7 @@ RUN rm -rf /debs \ && apt-get -y autoclean \ && apt-get -y autoremove \ && rm -rf /var/lib/apt/lists/* \ - && wget --https-only https://bootstrap.pypa.io/2.7/get-pip.py \ + && wget --https-only https://bootstrap.pypa.io/pip/2.7/get-pip.py \ && python get-pip.py \ && rm -f get-pip.py \ && pip install setuptools \ From a4d81f3c19cc4156a3d2b7d11cdb8a2e91f30107 Mon Sep 17 00:00:00 2001 From: Renuka Manavalan <47282725+renukamanavalan@users.noreply.github.com> Date: Tue, 9 Mar 2021 19:49:54 -0800 Subject: [PATCH 0267/1674] Copy dummy flannel.conf to get around absence of CNI Network (#6985) Why I did it We skip install of CNI plugin, as we don't need. But this leaves node in "not ready" state, upon joining master. To fix, we copy this dummy .conf file in /etc/cni/net.d How I did it Keep this file in /usr/share/sonic/templates and copy to /etc/cni/net.d upon joining k8s master. How to verify it Upon configuring master-IP and enable join, watch node join and move to ready state. You may verify using kubectl get nodes command --- .../build_templates/sonic_debian_extension.j2 | 4 +++ src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py | 6 ++-- src/sonic-ctrmgrd/ctrmgr/kube_commands.py | 19 ++++++++----- src/sonic-ctrmgrd/tests/kube_commands_test.py | 28 ++++++++++++++----- 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 8edd9af847a6..9d2556edb572 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -403,6 +403,10 @@ sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install azure- sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install watchdog==0.10.3 {% if include_kubernetes == "y" %} +# Copy Flannel conf file into sonic-templates +# +sudo cp $BUILD_TEMPLATES/kube_cni.10-flannel.conflist $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/ + # Install remote Container mgmt package # Required even if include_kubernetes != y, as it contains the # the container wrapper for docker start/stop/wait commands. diff --git a/src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py b/src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py index ba4f0057bd05..49c11d278170 100755 --- a/src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py +++ b/src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py @@ -201,7 +201,7 @@ def mod_db_entry(self, db_name, table_name, key, data): """ Modify entry for given table|key with given dict type data """ conn = self.db_connectors[db_name] tbl = swsscommon.Table(conn, table_name) - print("mod_db_entry: db={} tbl={} key={} data={}".format(db_name, table_name, key, str(data))) + log_debug("mod_db_entry: db={} tbl={} key={} data={}".format(db_name, table_name, key, str(data))) tbl.set(key, list(data.items())) @@ -242,7 +242,7 @@ def run(self): if not UNIT_TESTING: raise Exception("Received error from select") else: - print("Skipped Exception; Received error from select") + log_debug("Skipped Exception; Received error from select") return for subscriber in self.subscribers: @@ -588,7 +588,7 @@ def main(): FeatureTransitionHandler(server) LabelsPendingHandler(server) server.run() - print("ctrmgrd.py main called") + log_debug("ctrmgrd.py main called") return 0 diff --git a/src/sonic-ctrmgrd/ctrmgr/kube_commands.py b/src/sonic-ctrmgrd/ctrmgr/kube_commands.py index 1ebfa606f07f..db8cb348fcb2 100755 --- a/src/sonic-ctrmgrd/ctrmgr/kube_commands.py +++ b/src/sonic-ctrmgrd/ctrmgr/kube_commands.py @@ -22,6 +22,8 @@ KUBELET_YAML = "/var/lib/kubelet/config.yaml" SERVER_ADMIN_URL = "https://{}/admin.conf" LOCK_FILE = "/var/lock/kube_join.lock" +FLANNEL_CONF_FILE = "/usr/share/sonic/templates/kube_cni.10-flannel.conflist" +CNI_DIR = "/etc/cni/net.d" # kubectl --kubeconfig label nodes #